PageSourceSearch

https://app.zeroco2.eco/_next/static/chunks/ca4dcb09.ac5ebc9cb1bd0045.js

js zeroco2.eco collected 2026-10-02 05:32:32 UTC 559,021 bytes, 816 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8301],{29613:(t,i,r)=>{let a,o,s,n,l,h,c,u,d,_,p;r.d(i,{QE:()=>oV,T5:()=>oL,ov:()=>oF,pH:()=>oG});var m=r(49167);function f(){var t=new m.Pi(4);return m.Pi!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t}let g={frame(t,i,r,a){let o=a||window,s=o.requestAnimationFrame(t=>{n(),i(t)}),{unsubscribe:n}=(0,m.kr)(t.signal,"abort",()=>{n(),o.cancelAnimationFrame(s),r(new m.jn(t.signal.reason))},!1)},frameAsync(t,i){return new Promise((r,a)=>{this.frame(t,r,a,i)})},getImageData(t,i=0){return this.getImageCanvasContext(t).getImageData(-i,-i,t.width+2*i,t.height+2*i)},getImageCanvasContext(t){let i;if((0,m.Ii)()&&!(0,m.Fi)())i=new OffscreenCanvas(t.width,t.height).getContext("2d",{willReadFrequently:!0});else{let r=window.document.createElement("canvas");r.width=t.width,r.height=t.height,i=r.getContext("2d",{willReadFrequently:!0})}if(!i)throw Error("failed to create canvas 2d context");return i.drawImage(t,0,0,t.width,t.height),i},resolveURL:t=>((a||=document.createElement("a")).href=t,a.href),get hardwareConcurrency(){return"u">typeof navigator&&navigator.hardwareConcurrency||4},get prefersReducedMotion(){return void 0===s?!!matchMedia&&(o??=matchMedia("(prefers-reduced-motion: reduce)")).matches:s},set prefersReducedMotion(e){s=e}},v=new class{constructor(){this._frozenAt=null}getCurrentTime(){return null===this._frozenAt?performance.now():this._frozenAt}setNow(t){this._frozenAt=t}restoreNow(){this._frozenAt=null}isFrozen(){return null!==this._frozenAt}};function y(){return v.getCurrentTime()}var x=class t{static{this.docStyle="u">typeof window&&window.document?.documentElement.style}static{this.selectProp=!t.docStyle||"userSelect"in t.docStyle?"userSelect":"webkitUserSelect"}static create(t,i,r){let a=window.document.createElement(t);return void 0!==i&&(a.className=i),r&&r.appendChild(a),a}static createNS(t,i){return window.document.createElementNS(t,i)}static disableDrag(){t.docStyle&&t.selectProp&&(t.userSelect=t.docStyle[t.selectProp],t.docStyle[t.selectProp]="none")}static enableDrag(){t.docStyle&&t.selectProp&&(t.docStyle[t.selectProp]=t.userSelect)}static suppressClickInternal(i){i.preventDefault(),i.stopPropagation(),window.removeEventListener("click",t.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",t.suppressClickInternal,!0),window.setTimeout(()=>{window.removeEventListener("click",t.suppressClickInternal,!0)},0)}static getScale(t){let i=t.getBoundingClientRect();return{x:i.width/t.offsetWidth||1,y:i.height/t.offsetHeight||1,boundingClientRect:i}}static getPoint(t,i,r){let a=i.boundingClientRect;return new m.Li((r.clientX-a.left)/i.x-t.clientLeft,(r.clientY-a.top)/i.y-t.clientTop)}static mousePos(i,r){let a=t.getScale(i);return t.getPoint(i,a,r)}static touchPos(i,r){let a=[],o=t.getScale(i);for(let s of r)a.push(t.getPoint(i,o,s));return a}static sanitize(i){let r=new DOMParser().parseFromString(i,"text/html").body||document.createElement("body");for(let t of r.querySelectorAll("script, iframe"))t.remove();return t.clean(r),r.innerHTML}static isPossiblyDangerous(t,i){let r=i.replace(/\s+/g,"").toLowerCase();if(["src","href","xlink:href"].includes(t)&&(r.includes("javascript:")||r.includes("data:"))||"srcdoc"===t||t.startsWith("on"))return!0}static clean(i){for(let r of i.children)t.removeAttributes(r),t.clean(r)}static removeAttributes(i){for(let{name:r,value:a}of Array.from(i.attributes))t.isPossiblyDangerous(r,a)&&i.removeAttribute(r)}};(function(t){let i,r,a,o;t.resetRequestQueue=()=>{i=[],r=0,a=0,o={}},t.addThrottleControl=t=>{let i=a++;return o[i]=t,i},t.removeThrottleControl=t=>{delete o[t],l()},t.transformAndGetImage=async function(t,i,r,a,o=!0,s){let l=await t.transformRequest(i,r);return(0,m.Nn)(a.signal),n.getImage(l,a,o,s)},t.getImage=(t,r,a=!0,o)=>new Promise((s,n)=>{t.headers||={},t.headers.accept="image/webp,*/*",(0,m.er)(t,{type:"image"}),i.push({abortController:r,requestParameters:t,supportImageRefresh:a,imageBitmapOptions:o,state:"queued",onError:t=>{n(t)},onSuccess:t=>{s(t)}}),l()});let s=async t=>{t.state="running";let{requestParameters:i,supportImageRefresh:a,imageBitmapOptions:o,onError:s,onSuccess:n,abortController:c}=t,u=!1===a&&!o&&!(0,m.pr)(self)&&!(0,m.On)(i.url)&&(!i.headers||Object.keys(i.headers).reduce((t,i)=>t&&"accept"===i,!0));r++;let d=u?h(i,c):(0,m.Tn)(i,c);try{let i,r=await d;delete t.abortController,t.state="completed",r.data instanceof HTMLImageElement||(0,m.cr)(r.data)?n(r):n(r.data&&0!==r.data.byteLength?{data:await (i=r.data,"function"==typeof createImageBitmap?(0,m.Rn)(i,o):(0,m.Ln)(i)),cacheControl:r.cacheControl,expires:r.expires}:{data:null,cacheControl:r.cacheControl,expires:r.expires})}catch(i){delete t.abortController,s((0,m.Qn)(i))}finally{r--,l()}},l=()=>{let t=(()=>{for(let t of Object.keys(o))if(o[t]())return!0;return!1})()?m.An.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:m.An.MAX_PARALLEL_IMAGE_REQUESTS;for(let a=r;a<t&&i.length>0;a++){let t=i.shift();if(t.abortController.signal.aborted){a--;continue}s(t)}},h=(t,i)=>new Promise((r,a)=>{let o=new Image,s=t.url,n=t.credentials;n&&"include"===n?o.crossOrigin="use-credentials":(n&&"same-origin"===n||!(0,m.En)(s))&&(o.crossOrigin="anonymous"),i.signal.addEventListener("abort",()=>{o.src="",a(new m.jn(i.signal.reason))}),o.fetchPriority="high",o.onload=()=>{o.onerror=o.onload=null,r({data:o})},o.onerror=()=>{o.onerror=o.onload=null,i.signal.aborted||a(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."))},o.src=s})})(n||={}),n.resetRequestQueue();var b=class{constructor(t){this._transformRequestFn=t??null}transformRequest(t,i){return this._transformRequestFn&&this._transformRequestFn(t,i)||{url:t}}setTransformRequest(t){this._transformRequestFn=t}},w=class extends m._n{},T=class extends w{},P=class extends w{constructor(t={}){super("style.load",t)}},M=class extends w{constructor(t,i={}){super(t,i),this.dataType="style"}}
1,I=class extends w{constructor(t,i={}){super(t,i),this.dataType="source"}},C=class extends w{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,r,a={}){r=r instanceof MouseEvent?r:new MouseEvent(t,r);let o=x.mousePos(i.getCanvas(),r);super(t,(0,m.er)({point:o,lngLat:i.unproject(o),originalEvent:r},a)),this._defaultPrevented=!1,this.target=i}},S=class extends w{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,r){let a="touchend"===t?r.changedTouches:r.touches,o=x.touchPos(i.getCanvasContainer(),a),s=o.map(t=>i.unproject(t)),n=o.reduce((t,i,r,a)=>t.add(i.div(a.length)),new m.Li(0,0));super(t,{points:o,point:n,lngLats:s,lngLat:i.unproject(n),originalEvent:r}),this._defaultPrevented=!1}},E=class extends w{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,i){super("wheel",{originalEvent:i}),this._defaultPrevented=!1}},z=class extends w{},R=class extends w{constructor(t={}){super("terrain",t)}},D=class extends w{constructor(t={}){super("projectiontransition",t)}},L=class extends w{},A=class extends w{constructor(t={}){super("styleimagemissing",t)}};function F(t){t=t.slice();let i=Object.create(null);for(let r=0;r<t.length;r++)i[t[r].id]=t[r];for(let r=0;r<t.length;r++)"ref"in t[r]&&(t[r]=function(t,i){let r={};for(let i in t)"ref"!==i&&(r[i]=t[i]);return m.mn.forEach(t=>{t in i&&(r[t]=i[t])}),r}(t[r],i[t[r].ref]));return t}function k(t,i){if(Array.isArray(t)){if(!Array.isArray(i)||t.length!==i.length)return!1;for(let r=0;r<t.length;r++)if(!k(t[r],i[r]))return!1;return!0}if("object"==typeof t&&t&&null!==i){if("object"!=typeof i||Object.keys(t).length!==Object.keys(i).length)return!1;for(let r in t)if(!k(t[r],i[r]))return!1;return!0}return t===i}function B(t,i){t.push(i)}function O(t,i,r){B(r,{command:"addSource",args:[t,i[t]]})}function j(t,i,r){B(i,{command:"removeSource",args:[t]}),r[t]=!0}function N(t,i,r,a,o){B(i,{command:o,args:[r,a,t[a]]})}function Z(t,i,r,a,o){for(let s in i||={},t||={})Object.prototype.hasOwnProperty.call(t,s)&&(k(t[s],i[s])||N(i,r,a,s,o));for(let s in i)Object.prototype.hasOwnProperty.call(i,s)&&!Object.prototype.hasOwnProperty.call(t,s)&&(k(t[s],i[s])||N(i,r,a,s,o))}function U(t){return t.id}function G(t,i){return t[i.id]=i,t}function V(t){let i=[];if("string"==typeof t)i.push({id:"default",url:t});else if(t&&t.length>0){let r=[];for(let{id:a,url:o}of t){let t=`${a}${o}`;r.includes(t)||(r.push(t),i.push({id:a,url:o}))}}return i}function q(t,i,r){try{let a=new URL(t);return a.pathname+=`${i}${r}`,a.toString()}catch{throw Error(`Invalid sprite URL "${t}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}async function W(t,i,r,a){let o=V(t),s=r>1?"@2x":"",l={},h={};for(let{id:t,url:r}of o){let o=await i.transformRequest(q(r,s,".json"),"SpriteJSON");l[t]=(0,m.Sn)(o,a);let c=await i.transformRequest(q(r,s,".png"),"SpriteImage");h[t]=n.getImage(c,a)}return await Promise.all([...Object.values(l),...Object.values(h)]),$(l,h)}async function $(t,i){let r={};for(let a in t){r[a]={};let o=(await i[a]).data;if(!o)throw Error(`Could not load sprite image for ${a}: the response is empty`);let s=g.getImageCanvasContext(o),n=(await t[a]).data;for(let t in n){let{width:i,height:o,x:l,y:h,sdf:c,pixelRatio:u,stretchX:d,stretchY:_,content:p,textFitWidth:m,textFitHeight:f}=n[t],g={width:i,height:o,x:l,y:h,context:s};r[a][t]={data:null,pixelRatio:u,sdf:c,stretchX:d,stretchY:_,content:p,textFitWidth:m,textFitHeight:f,spriteData:g}}}return r}var H=class extends m.vn{constructor(){super(),this.images={},this.updateVersion=0,this.loaded=!1,this.requestors=[],this.missingImageResolver=null,this._spriteImagesIds={},this._imagesIds=null,this._renderCallbacksDispatchedThisFrame={}}destroy(){for(let t of Object.keys(this.images))this.removeImage(t);this._spriteImagesIds={}}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(let{ids:t,promiseResolve:i}of this.requestors)i(this._getImagesForIds(t));this.requestors=[]}}getImage(t){let i=this.images[t];if(i&&!i.data&&i.spriteData){let t=i.spriteData;i.data=new m.Dt({width:t.width,height:t.height},t.context.getImageData(t.x,t.y,t.width,t.height).data),i.spriteData=null}return i}addImage(t,i){if(this.images[t])throw Error(`Image id ${t} already exist, use updateImage instead`);
1this._validate(t,i)&&(this.images[t]=i,this._imagesIds=null,i.isWebGLImage&&this.updateImage(t,i,!1))}_validate(t,i){let r=!0,a=i.data||i.spriteData;return this._validateStretch(i.stretchX,a?.width)||(this.fire(new m.gn(Error(`Image "${t}" has invalid "stretchX" value`))),r=!1),this._validateStretch(i.stretchY,a?.height)||(this.fire(new m.gn(Error(`Image "${t}" has invalid "stretchY" value`))),r=!1),this._validateContent(i.content,i)||(this.fire(new m.gn(Error(`Image "${t}" has invalid "content" value`))),r=!1),r}_validateStretch(t,i){if(!t)return!0;let r=0;for(let a of t){if(a[0]<r||a[1]<a[0]||i<a[1])return!1;r=a[1]}return!0}_validateContent(t,i){if(!t)return!0;if(4!==t.length)return!1;let r=i.spriteData,a=r?.width||i.data.width,o=r?.height||i.data.height;return!(t[0]<0)&&!(a<t[0])&&!(t[1]<0)&&!(o<t[1])&&!(t[2]<0)&&!(a<t[2])&&!(t[3]<0)&&!(o<t[3])&&!(t[2]<t[0])&&t[3]>=t[1]}updateImage(t,i,r=!0){let a=this.images[t];if(r){let t=a.data||a.spriteData;if(t.width!==i.data.width||t.height!==i.data.height)throw Error(`size mismatch between old image (${t.width}x${t.height}) and new image (${i.data.width}x${i.data.height}).`)}i.version=(a.version??0)+1,this.images[t]=i,this.updateVersion++}removeImage(t){let i=this.images[t];i&&(delete this.images[t],this._imagesIds=null,i.userImage?.onRemove&&i.userImage.onRemove())}listImages(){return this._imagesIds??=Object.keys(this.images),this._imagesIds}_getSpriteImageId(t,i){return"default"===t?i:`${t}:${i}`}setSpriteImages(t,i){let r=this._spriteImagesIds[t]??[],a=[];for(let r in i){let o=this._getSpriteImageId(t,r);a.push(o),o in this.images?this.updateImage(o,i[r],!1):this.addImage(o,i[r])}let o=new Set(a),s=r.filter(t=>!o.has(t));for(let t of s)this.removeImage(t);return this._spriteImagesIds[t]=a,{loaded:a,removed:s}}removeSpriteImages(t){let i=this._spriteImagesIds[t]??[];for(let t of i)this.removeImage(t);return delete this._spriteImagesIds[t],i}removeAllSpriteImages(){let t=Object.values(this._spriteImagesIds).flat();for(let i of t)this.removeImage(i);return this._spriteImagesIds={},t}setMissingImageResolver(t){this.missingImageResolver=t}getImages(t){return new Promise((i,r)=>{let a=!0;if(!this.isLoaded())for(let i of t)this.images[i]||(a=!1);this.isLoaded()||a?i(this._getImagesForIds(t)):this.requestors.push({ids:t,promiseResolve:i})})}async _getImagesForIds(t){let i=new Set(t.filter(t=>!this.getImage(t))),r=this.missingImageResolver;r&&await Promise.allSettled(Array.from(i,t=>r(t)));let a={};for(let r of t){let t=this.getImage(r);t&&(i.delete(r),a[r]={data:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,textFitWidth:t.textFitWidth,textFitHeight:t.textFitHeight,hasRenderCallback:!!t.userImage?.render,isWebGLImage:t.isWebGLImage})}for(let t of i)this.fire(new A({id:t})),(0,m.Nr)(`Image "${t}" could not be loaded. Please make sure you have added the image before it is needed with map.addImage(), resolved it with map.setMissingStyleImageResolver(), or included it in a "sprite" property in your style.`);return a}beginFrame(){this._renderCallbacksDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(let i of t){if(this._renderCallbacksDispatchedThisFrame[i])continue;this._renderCallbacksDispatchedThisFrame[i]=!0;let t=this.getImage(i);t||(0,m.Nr)(`Image with ID: "${i}" was not found`),(0,m.L)(t)&&this.updateImage(i,t)}}cloneImages(){let t={};for(let i in this.images){let r=this.images[i];t[i]={...r,data:r.data?r.data.clone():null}}return t}},X=class{constructor(t){this._imageManager=t,this._entries={},this._image=new m.Dt({width:1,height:1}),this._dirty=!0}destroy(){this._texture&&=(this._texture.destroy(),null),this._entries={},this._image=new m.Dt({width:1,height:1}),this._dirty=!0}getPixelSize(){let{width:t,height:i}=this._image;return{width:t,height:i}}getPattern(t){let i=this._imageManager.getImage(t);if(!i)return null;let r=this._entries[t];
1if(r?.image!==i){let r={w:i.data.width+2,h:i.data.height+2,x:0,y:0};this._entries[t]={bin:r,position:new m.P(r,i),image:i}}else{if(r.position.version===i.version)return r.position;r.position.version=i.version}return this._update(),this._entries[t].position}bind(t){let i=t.gl;this._texture?this._dirty&&=(this._texture.update(this._image),!1):(this._texture=new m.xt(t,this._image,i.RGBA),this._dirty=!1),this._texture.bind(i.LINEAR,i.CLAMP_TO_EDGE)}_update(){for(let t in this._entries)this._imageManager.getImage(t)||delete this._entries[t];let t=[];for(let i in this._entries)t.push(this._entries[i].bin);let{w:i,h:r}=(0,m.F)(t),a=this._image;for(let t in a.resize({width:i||1,height:r||1}),this._entries){let{bin:i}=this._entries[t],r=i.x+1,o=i.y+1,s=this._entries[t].image.data,n=s.width,l=s.height;m.Dt.copy(s,a,{x:0,y:0},{x:r,y:o},{width:n,height:l}),m.Dt.copy(s,a,{x:0,y:l-1},{x:r,y:o-1},{width:n,height:1}),m.Dt.copy(s,a,{x:0,y:0},{x:r,y:o+l},{width:n,height:1}),m.Dt.copy(s,a,{x:n-1,y:0},{x:r-1,y:o},{width:1,height:l}),m.Dt.copy(s,a,{x:0,y:0},{x:r+n,y:o},{width:1,height:l})}this._dirty=!0}};let Y={start:0,end:1114111},K=0;function J(t,i){return t>i||t>1114111?null:{start:t,end:Math.min(i,1114111)}}var Q=class{constructor(t){this.requestManager=t,this._faces={},this._registered=new Set}setFontFaces(t){for(let[i,r]of(this._unregisterAll(),this._faces={},Object.entries(t??{}))){let t=Array.isArray(r)?r:[r];this._faces[i]=t.map(t=>this._declareFontFace(i,t)).filter(t=>null!==t)}}hasFontFaces(){return Object.keys(this._faces).length>0}async getFontFamily(t,i){for(let r of t.split(","))for(let t of this._faces[r.trim()]??[])if(function(t,i){return t.ranges.some(({start:t,end:r})=>i>=t&&i<=r)}(t,i)&&(t.loaded??=this._loadFontFace(t),await t.loaded))return t.family;return null}_declareFontFace(t,i){let r="string"==typeof i?{url:i}:i;if("string"!=typeof r?.url)return(0,m.Nr)(`Ignoring the font face declared for "${t}": it has no URL.`),null;let a=`maplibre-gl-font-face-${K++}`,o=r["unicode-range"];if(!o?.length)return{url:r.url,ranges:[Y],family:a};let s=[];for(let t of o){let i=function(t){let i=/^u\+([0-9a-f]*)(\?+)$/i.exec(t);if(i){let[,t,r]=i;return t.length+r.length>6?null:J(parseInt(`${t}${"0".repeat(r.length)}`,16),parseInt(`${t}${"f".repeat(r.length)}`,16))}let r=/^u\+([0-9a-f]{1,6})(?:-([0-9a-f]{1,6}))?$/i.exec(t);if(!r)return null;let a=parseInt(r[1],16);return J(a,void 0===r[2]?a:parseInt(r[2],16))}(t);if(!i){(0,m.Nr)(`Ignoring the unicode range "${t}" of the font face at ${r.url}: it is not a valid range.`);continue}s.push(i)}return s.length?{url:r.url,ranges:s,family:a}:null}async _loadFontFace(t){let i;if(typeof FontFace>"u"||typeof document>"u"||!document.fonts)return(0,m.Nr)(`Ignoring the font face at ${t.url}: this environment has no CSS Font Loading API.`),!1;try{return i=new FontFace(t.family,await this._downloadFontFile(t.url)),!!Object.values(this._faces).some(i=>i.includes(t))&&(document.fonts.add(i),this._registered.add(i),await i.load(),!0)}catch(r){return i&&this._unregister(i),(0,m.Nr)(`Ignoring the font face at ${t.url}: ${(0,m.Qn)(r).message}`),!1}}async _downloadFontFile(t){let i=await this.requestManager.transformRequest(t,"Glyphs"),r=await (0,m.xn)(i,new AbortController);if(!r?.data)throw Error(`the response was empty for the font file at ${t}`);return r.data}_unregister(t){document.fonts?.delete(t),this._registered.delete(t)}_unregisterAll(){for(let t of this._registered)document.fonts?.delete(t);this._registered.clear()}destroy(){this._unregisterAll(),this._faces={}}};let ee=new Float64Array(256);for(let t=0;t<256;t++){let i=.5-(t/255)**(1/2.2);ee[t]=i*Math.abs(i)}ee[255]=-1e20;var et=class{constructor({fontSize:t=24,buffer:i=3,radius:r=8,cutoff:a=.25,fontFamily:o="sans-serif",fontWeight:s="normal",fontStyle:n="normal",lang:l=null}={}){this.buffer=i,this.radius=r,this.cutoff=a,this.lang=l;let h=this.size=t+4*i,c=this._createCanvas(h),u=this.ctx=c.getContext("2d",{willReadFrequently:!0});u.font=`${n} ${s} ${t}px ${o}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(h*h),this.gridInner=new Float64Array(h*h),this.f=new Float64Array(h),this.z=new Float64Array(h+1),this.v=new Uint16Array(h)}_createCanvas(t){if("u">typeof OffscreenCanvas)return new OffscreenCanvas(t,t);let i=document.createElement("canvas");return i.width=i.height=t,i}draw(t){let{width:i,actualBoundingBoxAscent:r,actualBoundingBoxDescent:a,actualBoundingBoxLeft:o,actualBoundingBoxRight:s}=this.ctx.measureText(t),n=Math.ceil(r),l=Math.floor(-o),h=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(s)-l)),c=Math.max(0,Math.min(this.size-this.buffer,n+Math.ceil(a))),u=h+2*this.buffer,d=c+2*this.buffer,_=Math.max(u*d,0),p=new Uint8ClampedArray(_),m={data:p,width:u,height:d,glyphWidth:h,glyphHeight:c,glyphTop:n,glyphLeft:l,glyphAdvance:i};if(0===h||0===c)return m;let{ctx:f,buffer:g,gridInner:v,gridOuter:y}=this;this.lang&&(f.lang=this.lang),f.clearRect(g,g,h,c),f.fillText(t,g-l,g+n);let x=f.getImageData(g,g,h,c);y.fill(1e20,0,_),v.fill(0,0,_);let b=3;for(let t=0;t<c;t++){let i=(t+g)*u+g;for(let t=0;t<h;t++,b+=4,i++){let t=x.data[b];if(0===t)continue;let r=ee[t];y[i]=Math.max(0,r),v[i]=Math.max(0,-r)}}ei(y,0,0,u,d,u,this.f,this.v,this.z);let w=Math.min(g,1);ei(v,g-w,g-w,h+2*w,c+2*w,u,this.f,this.v,this.z);let T=255/this.radius,P=255*(1-this.cutoff);for(let t=0;t<_;t++){let i=Math.sqrt(y[t])-Math.sqrt(v[t]);p[t]=Math.round(P-T*i)}return m}};function ei(t,i,r,a,o,s,n,l,h){for(let c=i;c<i+a;c++)er(t,r*s+c,s,o,n,l,h);for(let c=r;c<r+o;c++)er(t,c*s+i,1,a,n,l,h)}function er(t,i,r,a,o,s,n){s[0]=0,n[0]=-1e20,n[1]=1e20,o[0]=t[i];for(let l=1,h=0,c=0;l<a;l++){o[l]=t[i+l*r];let a=l*l;do{let t=s[h];c=(o[l]-o[t]+a-t*t)/(l-t)/2}while(c<=n[h]&&--h>-1);s[++h]=l,n[h]=c,n[h+1]=1e20}for(let l=0,h=0;l<a;l++){for(;n[h+1]<l;)h++;let a=s[h],c=l-a;t[i+l*r]=o[a]+c*c}}let ea=m.hn.layout_symbol["text-font"].default.join(","),eo=(t,i)=>{let r=new et(t);return r.buffer=i,r};var es=class{constructor(t,i,r,a=eo){this.requestManager=t,this.localIdeographFontFamily=i,this.entries={},this.lang=r,this.fontFaceManager=new Q(t),this.createRasterizer=a}setURL(t){this.url=t}setFontFaces(t){this.fontFaceManager.setFontFaces(t),this.entries={}}async getGlyphs(t){let i=[];for(let r in t)for(let a of t[r])i.push(this._getAndCacheGlyphsPromise(r,a));let r=await Promise.all(i),a={};for(let{stack:t,id:i,glyph:o}of r)a[t]||={},a[t][i]=o&&{id:o.id,bitmap:o.bitmap.clone(),metrics:o.metrics};return a}
1async _getAndCacheGlyphsPromise(t,i){this.entries[t]??={glyphs:{},requests:{},ranges:{}};let r=this.entries[t],a=r.glyphs[i];if(void 0!==a)return{stack:t,id:i,glyph:a};let o=i.codePointAt(0),s=this.fontFaceManager.hasFontFaces()?await this.fontFaceManager.getFontFamily(t,o):null;return s?(a=r.glyphs[i]=await this._drawGlyph(r,t,i,s),{stack:t,id:i,glyph:a}):!this.url||(0,m.B)(i)||this._charUsesLocalIdeographFontFamily(o)?(a=r.glyphs[i]=await this._drawGlyph(r,t,i),{stack:t,id:i,glyph:a}):await this._downloadAndCacheRangePromise(t,i)}async _downloadAndCacheRangePromise(t,i){let r=i.codePointAt(0),a=this.entries[t],o=Math.floor(r/256);if(a.ranges[o])return{stack:t,id:i,glyph:null};a.requests[o]||=this._loadGlyphRange(t,o);try{let s=await a.requests[o];for(let t in s)a.glyphs[String.fromCodePoint(+t)]=s[+t];return a.ranges[o]=!0,{stack:t,id:i,glyph:s[r]||null}}catch(n){let s=a.glyphs[i]=await this._drawGlyph(a,t,i);return this._warnOnMissingGlyphRange(s,o,r,(0,m.Qn)(n)),{stack:t,id:i,glyph:s}}}async _loadGlyphRange(t,i){let r=256*i,a=r+255,o=await this.requestManager.transformRequest(this.url.replace("{fontstack}",t).replace("{range}",`${r}-${a}`),"Glyphs"),s=await (0,m.xn)(o,new AbortController);if(!s?.data)throw Error(`Could not load glyph range. range: ${i}, ${r}-${a}`);let n={};for(let t of(0,m.R)(s.data))n[t.id]=t;return n}_warnOnMissingGlyphRange(t,i,r,a){let o=256*i,s=r.toString(16).padStart(4,"0").toUpperCase();(0,m.Nr)(`Unable to load glyph range ${i}, ${o}-${o+255}. Rendering codepoint U+${s} locally instead. ${a}`)}_charUsesLocalIdeographFontFamily(t){return!!this.localIdeographFontFamily&&(0,m.V)(t)}async _drawGlyph(t,i,r,a){let o=(await this._getTinySDF(t,i,r,a)).draw(r),s=/^\p{gc=Cf}+$/u.test(r);return{id:r.codePointAt(0),bitmap:new m.Et({width:o.width||60,height:o.height||60},o.data),metrics:{width:s?0:o.glyphWidth/2||24,height:o.glyphHeight/2||24,left:o.glyphLeft/2+.5||0,top:o.glyphTop/2-27.5||-8,advance:s?0:o.glyphAdvance/2||24,isDoubleResolution:!0}}}_getTinySDF(t,i,r,a){let o=(0,m.B)(r);if(a){let i=o?"clusterTinySDFs":"fontFaceTinySDFs";return t[i]??={},t[i][a]||=this._createTinySDF(a,!1,o?3:1),t[i][a]}let s=i===ea&&""!==this.localIdeographFontFamily&&this._charUsesLocalIdeographFontFamily(r.codePointAt(0)),n=s?this.localIdeographFontFamily:i;if(o)return t.clusterTinySDFs??={},t.clusterTinySDFs[n]||=this._createTinySDF(n,!0,3),t.clusterTinySDFs[n];let l=s?"ideographTinySDF":"tinySDF";return t[l]||=this._createTinySDF(n),t[l]}async _createTinySDF(t,i=!0,r=1){let a=t?t.split(","):[];a.push("sans-serif");let o=a.map(t=>/[-\w]+/.test(t)?t:`'${CSS.escape(t)}'`).join(","),s=i?this._fontWeight(a[0]):void 0,n=i?this._fontStyle(a[
10]):"normal";if("u">typeof document&&document.fonts?.load)try{await document.fonts.load(`${n} ${s||"normal"} 48px ${o}`)}catch(t){(0,m.Nr)(`Failed to load font "${o}": ${(0,m.Qn)(t).message}`)}return this.createRasterizer({fontSize:48,buffer:Math.max(6,Math.ceil(48*(r-1)/4)),radius:16,cutoff:.25,fontFamily:o,fontWeight:s,fontStyle:n,lang:this.lang},6)}_fontStyle(t){return/italic/i.test(t)?"italic":/oblique/i.test(t)?"oblique":"normal"}_fontWeight(t){let i;for(let[r,a]of Object.entries({thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950}))RegExp(`\\b${r}\\b`,"i").test(t)&&(i=`${a}`);return i}destroy(){for(let t in this.entries){let i=this.entries[t];i.tinySDF=null,i.ideographTinySDF=null,i.fontFaceTinySDFs={},i.glyphs={},i.requests={},i.ranges={}}this.entries={},this.fontFaceManager.destroy()}},en=class extends m.vn{constructor(t,i){super(),this._transitionable=new m.$t(l||=new m.Qt({anchor:new m.Zt(m.hn.light.anchor,"anchor"),position:new m.Zt(m.hn.light.position,"position"),color:new m.Zt(m.hn.light.color,"color"),intensity:new m.Zt(m.hn.light.intensity,"intensity")}),"light",i),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}getCartesianPosition(){return(0,m.Or)(this.properties.get("position"))}setLight(t,i={}){this._validate(m.on.light,t,i)||this._transitionable.setValues(t)}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,i,r){return(0,m.an)(this,t,{value:i},r)}},el=class extends m.vn{constructor(t,i){super(),this._transitionable=new m.$t(h||=new m.Qt({"sky-color":new m.Zt(m.hn.sky["sky-color"],"sky-color"),"horizon-color":new m.Zt(m.hn.sky["horizon-color"],"horizon-color"),"fog-color":new m.Zt(m.hn.sky["fog-color"],"fog-color"),"fog-ground-blend":new m.Zt(m.hn.sky["fog-ground-blend"],"fog-ground-blend"),"horizon-fog-blend":new m.Zt(m.hn.sky["horizon-fog-blend"],"horizon-fog-blend"),"sky-horizon-blend":new m.Zt(m.hn.sky["sky-horizon-blend"],"sky-horizon-blend"),"atmosphere-blend":new m.Zt(m.hn.sky["atmosphere-blend"],"atmosphere-blend")}),"sky",i),this.setSky(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new m.en(0))}setSky(t,i={}){this._validate(m.on.sky,t,i)||(t||={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0},this._transitionable.setValues(t))}getSky(){return this._transitionable.serialize()}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,i,r={}){return(0,m.an)(this,t,{value:i},r)}calculateFogBlendOpacity(t){return t<60?0:t<70?(t-60)/10:1}},eh=class{constructor(t,i){this.width=t,this.height=i,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(t,i){let r=t.join(",")+String(i);return this.dashEntry[r]||=this.addDash(t,i),this.dashEntry[r]}getDashRanges(t,i,r){let a=t.length%2==1,o=[],s=a?-t[t.length-1]*r:0,n=t[0]*r,l=!0;o.push({left:s,right:n,isDash:l,zeroLength:0===t[0]});let h=t[0];for(let i=1;i<t.length;i++){l=!l;let a=t[i];s=h*r,h+=a,n=h*r,o.push({left:s,right:n,isDash:l,zeroLength:0===a})}return o}addRoundDash(t,i,r){let a=i/2;for(let i=-r;i<=r;i++){let o=this.nextRow+r+i,s=this.width*o,n=0,l=t[0];for(let o=0;o<this.width;o++){o/l.right>1&&(l=t[++n]);let h=Math.min(Math.abs(o-l.left),Math.abs(o-l.right)),c,u=i/r*(a+1);if(l.isDash){let t=a-Math.abs(u);c=Math.sqrt(h*h+t*t)}else c=a-Math.sqrt(h*h+u*u);this.data[s+o]=Math.max(0,Math.min(255,c+128))}}}addRegularDash(t){for(let i=t.length-1;i>=0;--i){let r=t[i],a=t[i+1];r.zeroLength?t.splice(i,1):a?.isDash===r.isDash&&(a.left=r.left,t.splice(i,1))}let i=t[0],r=t[t.length-1];
1i.isDash===r.isDash&&(i.left=r.left-this.width,r.right=i.right+this.width);let a=this.width*this.nextRow,o=0,s=t[0];for(let i=0;i<this.width;i++){i/s.right>1&&(s=t[++o]);let r=Math.min(Math.abs(i-s.left),Math.abs(i-s.right)),n=s.isDash?r:-r;this.data[a+i]=Math.max(0,Math.min(255,n+128))}}addDash(t,i){let r=7*!!i,a=2*r+1;if(this.nextRow+a>this.height)return(0,m.Nr)("LineAtlas out of space"),null;let o=0;for(let i of t)o+=i;if(0!==o){let a=this.width/o,s=this.getDashRanges(t,this.width,a);i?this.addRoundDash(s,a,r):this.addRegularDash(s)}let s={y:this.nextRow+r,height:2*r,width:o};return this.nextRow+=a,this.dirty=!0,s}bind(t){let i=t.gl;this.texture?(i.bindTexture(i.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,i.texSubImage2D(i.TEXTURE_2D,0,0,0,this.width,this.height,i.ALPHA,i.UNSIGNED_BYTE,this.data))):(this.texture=i.createTexture(),i.bindTexture(i.TEXTURE_2D,this.texture),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.REPEAT),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.REPEAT),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texImage2D(i.TEXTURE_2D,0,i.ALPHA,this.width,this.height,0,i.ALPHA,i.UNSIGNED_BYTE,this.data))}};function ec(t,i){if(i)try{return new Worker(t,{type:"module"})}catch(t){console.warn("Module worker not supported, falling back to classic worker",t)}return new Worker(t)}async function eu(t){let i=await fetch(t);if(!i.ok)throw Error(`Failed to fetch worker script (${i.status}): ${t}`);let r=new Blob([await i.text()],{type:"text/javascript"});return URL.createObjectURL(r)}async function ed(){let t=m.An.WORKER_URL||function(){let t="file:///private/tmp/zeroco2-release-QGirHf/src/node_modules/maplibre-gl/dist/maplibre-gl.mjs";if(!/^https?:/.test(t))return"";let i=t.endsWith("-dev.mjs")?"maplibre-gl-worker-dev.mjs":"maplibre-gl-worker.mjs";return new URL(`./${i}`,t).href}(),i=!t?.endsWith(".cjs");if(!function(t){if(!t)return!1;let i=globalThis.location;if(!i)return!1;try{return new URL(t,i.href).origin!==i.origin}catch{return!1}}(t))return ec(t,i);if(i){let r,a=(r=new Blob([`import ${JSON.stringify(new URL(t,"file:///private/tmp/zeroco2-release-QGirHf/src/node_modules/maplibre-gl/dist/maplibre-gl.mjs").href)}`],{type:"text/javascript"}),URL.createObjectURL(r));try{return ec(a,i)}finally{URL.revokeObjectURL(a)}}let r=await eu(t);try{return ec(r,i)}finally{URL.revokeObjectURL(r)}}var e_=class t{constructor(){this.active={},this.workersPromise=null}async acquire(i){if(this.active[i]=!0,!this.workersPromise){let i=[];for(;i.length<t.workerCount;)i.push(ed());this.workersPromise=Promise.all(i)}return(await this.workersPromise).slice()}release(t){if(delete this.active[t],0===this.numActive()&&this.workersPromise){let t=this.workersPromise;this.workersPromise=null,t.then(t=>{for(let i of t)i.terminate()})}}isPreloaded(){return!!this.active.maplibre_preloaded_worker_pool}numActive(){return Object.keys(this.active).length}};let ep=Math.floor(g.hardwareConcurrency/2);e_.workerCount=(0,m.ur)(globalThis)?Math.max(Math.min(ep,3),1):1;var em=class{constructor(t,i){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=i,this.removed=!1,this.actorsPromise=this.initActors(i)}async initActors(t){let i=await this.workerPool.acquire(t);if(this.removed)return[];if(this.actors=i.map((i,r)=>{let a=new m.g(i,t);return a.name=`Worker ${r}`,a}),!this.actors.length)throw Error("No actors found");return this.actors}async broadcast(t,i){return Promise.all((await this.actorsPromise).map(r=>r.sendAsync({type:t,data:i})))}async getActor(){let t=await this.actorsPromise;return this.currentActor=(this.currentActor+1)%t.length,t[this.currentActor]}async waitForInitComplete(){0===this.actors.length&&await this.actorsPromise}getReadyActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(t=!0){for(let t of(this.removed=!0,this.actors))t.remove();this.actors=[],t&&this.workerPool.release(this.id)}async registerMessageHandler(t,i){for(let r of(await this.actorsPromise))r.registerMessageHandler(t,i)}async unregisterMessageHandler(t){for(let i of(await this.actorsPromise))i.unregisterMessageHandler(t)}};function ef(t,i){let r=t.tileID,a=i.tileID;return r.overscaledZ-a.overscaledZ||r.canonical.y-a.canonical.y||r.wrap-a.wrap||r.canonical.x-a.canonical.x}function eg(t,i){let r=t.feature,a=i.getFeatureState(r.layer["source-layer"],r.id);r.source=r.layer.source,r.layer["source-layer"]&&(r.sourceLayer=r.layer["source-layer"]),r.state=a}async function ev(t,i,r,a){let o=t;if(t.url?o=(await (0,m.Sn)(await i.transformRequest(t.url,"Source"),r)).data:await g.frameAsync(r,a),!o)return null;let s=(0,m.yr)((0,m.er)(o,t),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in o&&o.vector_layers&&(s.vectorLayerIds=o.vector_layers.map(t=>
1t.id)),s}var ey=class t{constructor(t,i){t&&(i?this.setSouthWest(t).setNorthEast(i):Array.isArray(t)&&(4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1])))}setNorthEast(t){return this._ne=t instanceof m.lt?new m.lt(t.lng,t.lat):m.lt.convert(t),this}setSouthWest(t){return this._sw=t instanceof m.lt?new m.lt(t.lng,t.lat):m.lt.convert(t),this}extend(i){let r=this._sw,a=this._ne,o,s;if(i instanceof m.lt)o=i,s=i;else if(i instanceof t){if(o=i._sw,s=i._ne,!o||!s)return this}else return Array.isArray(i)?4===i.length||i.every(Array.isArray)?this.extend(t.convert(i)):this.extend(m.lt.convert(i)):i&&("lng"in i||"lon"in i)&&"lat"in i?this.extend(m.lt.convert(i)):this;return r||a?(r.lng=Math.min(o.lng,r.lng),r.lat=Math.min(o.lat,r.lat),a.lng=Math.max(s.lng,a.lng),a.lat=Math.max(s.lat,a.lat)):(this._sw=new m.lt(o.lng,o.lat),this._ne=new m.lt(s.lng,s.lat)),this}getCenter(){return new m.lt((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 m.lt(this.getWest(),this.getNorth())}getSouthEast(){return new m.lt(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){let{lng:i,lat:r}=m.lt.convert(t),a=this._sw.lat<=r&&r<=this._ne.lat,o=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(o=this._sw.lng>=i&&i>=this._ne.lng),a&&o}intersects(i){if(!((i=t.convert(i)).getNorth()>=this.getSouth()&&i.getSouth()<=this.getNorth()))return!1;let r=Math.abs(this.getEast()-this.getWest()),a=Math.abs(i.getEast()-i.getWest());if(r>=360||a>=360)return!0;let o=(0,m.Pr)(this.getWest(),-180,180),s=(0,m.Pr)(this.getEast(),-180,180),n=(0,m.Pr)(i.getWest(),-180,180),l=(0,m.Pr)(i.getEast(),-180,180),h=o>s,c=n>l;return!!h&&!!c||(h?l>=o||n<=s:c?s>=n||o<=l:n<=s&&l>=o)}static convert(i){return i instanceof t||!i?i:new t(i)}static fromLngLat(i,r=0){let a=360*r/0x2637f09,o=a/Math.cos(Math.PI/180*i.lat);return new t(new m.lt(i.lng-o,i.lat-a),new m.lt(i.lng+o,i.lat+a))}adjustAntiMeridian(){let i=new m.lt(this._sw.lng,this._sw.lat),r=new m.lt(this._ne.lng,this._ne.lat);return i.lng>r.lng?new t(i,new m.lt(r.lng+360,r.lat)):new t(i,r)}},ex=class{constructor(t,i,r){this.bounds=ey.convert(this.validateBounds(t)),this.minzoom=i||0,this.maxzoom=r||24}validateBounds(t){return Array.isArray(t)&&4===t.length?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(t){let i=2**t.z,r={minX:Math.floor((0,m.ot)(this.bounds.getWest())*i),minY:Math.floor((0,m.st)(this.bounds.getNorth())*i),maxX:Math.ceil((0,m.ot)(this.bounds.getEast())*i),maxY:Math.ceil((0,m.st)(this.bounds.getSouth())*i)};return t.x>=r.minX&&t.x<r.maxX&&t.y>=r.minY&&t.y<r.maxY}},eb=class extends m.vn{constructor(t,i,r,a){if(super(),this.id=t,this.dispatcher=r,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,(0,m.er)(this,(0,m.yr)(i,["url","scheme","tileSize","promoteId","encoding"])),this._options=(0,m.er)({type:"vector"},i),this._collectResourceTiming=i.collectResourceTiming,512!==this.tileSize)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(a)}async load(t=!1){this._loaded=!1,this.fire(new I("dataloading")),this._tileJSONRequest=new AbortController;try{let i=await ev(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,i&&((0,m.er)(this,i),i.bounds&&(this.tileBounds=new ex(i.bounds,this.minzoom,this.maxzoom)),this.fire(new I("data",{sourceDataType:"metadata"})),this.fire(new I("data",{sourceDataType:"content",sourceDataChanged:t})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,(0,m.Mn)(t)||this.fire(new m.gn((0,m.Qn)(t)))}}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.abort(),t(),this.load(!0)}setTiles(t){return this.setSourceProperty(()=>{this.tiles=t,this._options.tiles=t}),this}setUrl(t){return this.setSourceProperty(()=>{this.url=t,this._options.url=t}),this}onRemove(){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null)}serialize(){return(0,m.er)({},this._options)}
vendor: 2,034 bytes, line 1
1async loadTile(t){let i=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r={request:await this.map._requestManager.transformRequest(i,"Tile"),uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,encoding:this.encoding,overzoomParameters:await this._getOverzoomParameters(t),etag:t.etag};r.request.collectResourceTiming=this._collectResourceTiming,await this.dispatcher.waitForInitComplete();let a="RT";if(t.actor&&"expired"!==t.state){if("loading"===t.state)return new Promise((i,r)=>{t.reloadPromise={resolve:i,reject:r}})}else t.actor=this.dispatcher.getReadyActor(),a="LT";t.abortController=new AbortController;try{let i=await t.actor.sendAsync({type:a,data:r},t.abortController);if(delete t.abortController,t.aborted)return;this._afterTileLoadWorkerResponse(t,i);let o={};return i?.etagUnmodified&&(o.unmodified=!0),o}catch(i){if(delete t.abortController,t.aborted||(0,m.Mn)(i))return;if(i&&404!==i.status)throw i;this._afterTileLoadWorkerResponse(t,null)}}async _getOverzoomParameters(t){if(t.tileID.canonical.z<=this.maxzoom||void 0===this.map._zoomLevelsToOverscale)return;let i=t.tileID.scaledTo(this.maxzoom).canonical,r=i.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:i,overzoomRequest:await this.map._requestManager.transformRequest(r,"Tile")}}_afterTileLoadWorkerResponse(t,i){if(i?.resourceTiming&&(t.resourceTiming=i.resourceTiming),i&&this.map._refreshExpiredTiles&&t.setExpiryData(i),t.etag=i?.etag,t.loadVectorData(i,this.map.painter),t.reloadPromise){let i=t.reloadPromise;t.reloadPromise=null,this.loadTile(t).then(i.resolve).catch(i.reject)}}async abortTile(t){t.abortController&&(t.abortController.abort(),delete t.abortController),t.actor&&await t.actor.sendAsync({type:"AT",data:{uid:t.uid,type:this.t
1ype,source:this.id}})}async unloadTile(t){t.unloadVectorData(),t.actor&&await t.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}})}hasTransition(){return!1}},ew=class extends m.vn{constructor(t,i,r,a){super(),this.id=t,this.dispatcher=r,this.setEventedParent(a),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._premultiplyAlpha=!0,this._options=(0,m.er)({type:"raster"},i),(0,m.er)(this,(0,m.yr)(i,["url","scheme","tileSize"]))}async load(t=!1){this._loaded=!1,this.fire(new I("dataloading")),this._tileJSONRequest=new AbortController;try{let i=await ev(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,i&&((0,m.er)(this,i),i.bounds&&(this.tileBounds=new ex(i.bounds,this.minzoom,this.maxzoom)),this.fire(new I("data",{sourceDataType:"metadata"})),this.fire(new I("data",{sourceDataType:"content",sourceDataChanged:t})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,(0,m.Mn)(t)||this.fire(new m.gn((0,m.Qn)(t)))}}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null)}setSourceProperty(t){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null),t(),this.load(!0)}setTiles(t){return this.setSourceProperty(()=>{this.tiles=t,this._options.tiles=t}),this}setUrl(t){return this.setSourceProperty(()=>{this.url=t,this._options.url=t}),this}serialize(){return(0,m.er)({},this._options)}setPremultiplyAlpha(t){return this._premultiplyAlpha===t||this.setSourceProperty(()=>{this._premultiplyAlpha=t}),this}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}async loadTile(t){let i=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r=this._premultiplyAlpha,a=r?void 0:{premultiplyAlpha:"none"};t.abortController=new AbortController;try{let o=await n.transformAndGetImage(this.map._requestManager,i,"Tile",t.abortController,this.map._refreshExpiredTiles,a);if(delete t.abortController,t.aborted){t.state="unloaded";return}if(o){this.map._refreshExpiredTiles&&(o.cacheControl||o.expires)&&t.setExpiryData({cacheControl:o.cacheControl,expires:o.expires});let i=this.map.painter.context,a=i.gl,s=o.data??new m.Dt({width:1,height:1},new Uint8Array(4));t.texture=this.map.painter.getTileTexture(s.width),t.texture?t.texture.update(s,{useMipmap:!0,premultiply:r}):(t.texture=new m.xt(i,s,a.RGBA,{useMipmap:!0,premultiply:r}),t.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE,a.LINEAR_MIPMAP_NEAREST)),t.state="loaded"}}catch(i){if(delete t.abortController,t.aborted)t.state="unloaded";else if(i)throw t.state="errored",i}}async abortTile(t){t.abortController&&(t.abortController.abort(),delete t.abortController)}async unloadTile(t){t.texture&&this.map.painter.saveTileTexture(t.texture)}hasTransition(){return!1}},eT=class extends ew{constructor(t,i,r,a){super(t,i,r,a),this.type="raster-dem",this.maxzoom=22,this._options=(0,m.er)({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox",this.redFactor=i.redFactor,this.greenFactor=i.greenFactor,this.blueFactor=i.blueFactor,this.baseShift=i.baseShift}async loadTile(t){let i=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);t.neighboringTiles=this._getNeighboringTiles(t.tileID),t.abortController=new AbortController;try{let r=await n.transformAndGetImage(this.map._requestManager,i,"Tile",t.abortController,this.map._refreshExpiredTiles,{colorSpaceConversion:"none"});if(delete t.abortController,t.aborted){t.state="unloaded";return}if(r){if(this.map._refreshExpiredTiles&&(r.cacheControl||r.expires)&&t.setExpiryData({cacheControl:r.cacheControl,expires:r.expires}),!r.data){t.state="loaded";return}let i=r.data,a=(0,m.cr)(i)&&(0,m.Ii)()?i:await this.readImageNow(i),o={type:this.type,uid:t.uid,source:this.id,rawImageData:a,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(t.actor&&"expired"!==t.state&&"reloading"!==t.state)return;await this.dispatcher.waitForInitComplete(),t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getReadyActor()),t.dem=await t.actor.sendAsync({type:"LDT",data:o}
1),t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.needsColorReliefPrepare=!0,t.state="loaded"}}catch(i){if(delete t.abortController,t.aborted)t.state="unloaded";else if(i)throw t.state="errored",i}}async readImageNow(t){if("u">typeof VideoFrame&&(0,m.Fi)()){let i=t.width+4,r=t.height+4;try{return new m.Dt({width:i,height:r},await (0,m.Cr)(t,-2,-2,i,r))}catch{}}return g.getImageData(t,2)}_getNeighboringTiles(t){let i=t.canonical,r=2**i.z,a=(i.x-1+r)%r,o=0===i.x?t.wrap-1:t.wrap,s=(i.x+1+r)%r,n=i.x+1===r?t.wrap+1:t.wrap,l={};return l[new m.d(t.overscaledZ,o,i.z,a,i.y).key]={backfilled:!1},l[new m.d(t.overscaledZ,n,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new m.d(t.overscaledZ,o,i.z,a,i.y-1).key]={backfilled:!1},l[new m.d(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new m.d(t.overscaledZ,n,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1<r&&(l[new m.d(t.overscaledZ,o,i.z,a,i.y+1).key]={backfilled:!1},l[new m.d(t.overscaledZ,t.wrap,i.z,i.x,i.y+1).key]={backfilled:!1},l[new m.d(t.overscaledZ,n,i.z,s,i.y+1).key]={backfilled:!1}),l}async unloadTile(t){t.demTexture&&this.map.painter.saveTileTexture(t.demTexture),t.fbo&&(t.fbo.destroy(),delete t.fbo),t.dem&&delete t.dem,delete t.neighboringTiles,t.state="unloaded",t.actor&&await t.actor.sendAsync({type:"RDT",data:{type:this.type,uid:t.uid,source:this.id}})}};function eP(t,i){return i?t.properties[i]:t.id}function eM(t){if(!t)return{};let i={};
1return i.removeAll=t.removeAll,i.remove=new Set(t.remove||[]),i.add=new Map(t.add?.map(t=>[t.id,t])),i.update=new Map(t.update?.map(t=>[t.id,t])),i}function eI(t){return"GeometryCollection"===t.type?t.geometries.flatMap(t=>eI(t)):function t(i){return i&&0!==i.length?"number"==typeof i[0]?[i]:i.flatMap(i=>t(i)):[]}(t.coordinates)}function eC(t){let i=new ey,r;switch(t.type){case"FeatureCollection":r=t.features.flatMap(t=>eI(t.geometry));break;case"Feature":r=eI(t.geometry);break;default:r=eI(t)}if(0===r.length)return i;for(let t of r){let[r,a]=t;i.extend([r,a])}return i}var eS=class extends m.vn{constructor(t,i,r,a){super(),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._isUpdatingWorker=!1,this._pendingWorkerUpdate={data:i.data},this.actorPromise=r.getActor(),this.setEventedParent(a),this._data="string"==typeof i.data?{url:i.data}:{geojson:i.data},this._options=(0,m.er)({},i),this._collectResourceTiming=i.collectResourceTiming,void 0!==i.maxzoom&&(this.maxzoom=i.maxzoom),i.type&&(this.type=i.type),i.attribution&&(this.attribution=i.attribution),this.promoteId=i.promoteId,void 0!==i.clusterMaxZoom&&this.maxzoom<=i.clusterMaxZoom&&(0,m.Nr)(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${i.clusterMaxZoom}".`),this.workerOptions=(0,m.er)({source:this.id,geojsonVtOptions:{buffer:this._pixelsToTileUnits(void 0===i.buffer?128:i.buffer),tolerance:this._pixelsToTileUnits(void 0===i.tolerance?.375:i.tolerance),extent:m.Lr,maxZoom:this.maxzoom,lineMetrics:i.lineMetrics||!1,generateId:i.generateId||!1,promoteId:"string"==typeof i.promoteId?i.promoteId:void 0,cluster:i.cluster||!1,clusterOptions:{maxZoom:this._getClusterMaxZoom(i.clusterMaxZoom),minPoints:Math.max(2,i.clusterMinPoints||2),extent:m.Lr,radius:this._pixelsToTileUnits(i.clusterRadius||50),log:!1,generateId:i.generateId||!1}},clusterProperties:i.clusterProperties,filter:i.filter},i.workerOptions)}_hasPendingWorkerUpdate(){return void 0!==this._pendingWorkerUpdate.data||void 0!==this._pendingWorkerUpdate.diff||this._pendingWorkerUpdate.updateCluster}_pixelsToTileUnits(t){return t*(m.Lr/this.tileSize)}_tileUnitsToPixels(t){return t/(m.Lr/this.tileSize)}_getClusterMaxZoom(t){let i=t?Math.round(t):this.maxzoom-1;return Number.isInteger(t)||void 0===t||(0,m.Nr)(`Integer expected for option 'clusterMaxZoom': provided value "${t}" rounded to "${i}"`),i}async load(){await this._updateWorkerData()}onAdd(t){this.map=t,this.load()}setData(t){return this._data="string"==typeof t?{url:t}:{geojson:t},this._pendingWorkerUpdate={data:t},this._updateWorkerData()}updateData(t){return this._pendingWorkerUpdate.diff=function(t,i,r){let a;if(!t)return i||{};if(!i)return t||{};let o=eM(t),s=eM(i);var n,l=o,h=s;for(let t of(h.removeAll&&(l.add.clear(),l.update.clear(),l.remove.clear(),h.remove.clear()),h.remove))l.add.delete(t),l.update.delete(t);for(let[t,i]of h.update){let r=l.update.get(t);r&&(h.update.set(t,function(t,i){let r={id:t.id};if(i.removeAllProperties&&(delete t.removeProperties,delete t.addOrUpdateProperties,delete i.removeProperties),i.removeProperties&&t.addOrUpdateProperties){let r=new Set(i.removeProperties);t.addOrUpdateProperties=t.addOrUpdateProperties.filter(t=>!r.has(t.key))}return(t.removeAllProperties||i.removeAllProperties)&&(r.removeAllProperties=!0),(t.removeProperties||i.removeProperties)&&(r.removeProperties=[...t.removeProperties||[],...i.removeProperties||[]]),(t.addOrUpdateProperties||i.addOrUpdateProperties)&&(r.addOrUpdateProperties=[...t.addOrUpdateProperties||[],...i.addOrUpdateProperties||[]]),(t.newGeometry||i.newGeometry)&&(r.newGeometry=i.newGeometry||t.newGeometry),r}(r,i)),l.update.delete(t))}let c={};
vendor: 4,862 bytes, line 1
1if((o.removeAll||s.removeAll)&&(c.removeAll=!0),c.remove=new Set([...o.remove,...s.remove]),c.add=new Map([...o.add,...s.add]),c.update=new Map([...o.update,...s.update]),c.remove.size&&c.add.size)for(let t of c.add.keys())c.remove.delete(t);let u=(a={},(n=c).removeAll&&(a.removeAll=n.removeAll),n.remove&&(a.remove=Array.from(n.remove)),n.add&&(a.add=Array.from(n.add.values())),n.update&&(a.update=Array.from(n.update.values())),a);return u}(this._pendingWorkerUpdate.diff,t),this._updateWorkerData()}async getData(){return this._data.url&&await this.once("data"),this._data.geojson?this._data.geojson:{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}}async getBounds(){return eC(await this.getData())}setClusterOptions(t){return this.workerOptions.geojsonVtOptions.cluster=t.cluster,void 0!==t.clusterRadius&&(this.workerOptions.geojsonVtOptions.clusterOptions.radius=this._pixelsToTileUnits(t.clusterRadius)),void 0!==t.clusterMaxZoom&&(this.workerOptions.geojsonVtOptions.clusterOptions.maxZoom=this._getClusterMaxZoom(t.clusterMaxZoom)),this._pendingWorkerUpdate.updateCluster=!0,this._updateWorkerData()}getClusterOptions(){let{cluster:t,clusterOptions:i}=this.workerOptions.geojsonVtOptions;return{cluster:t,clusterMaxZoom:i.maxZoom,clusterRadius:this._tileUnitsToPixels(i.radius)}}async getClusterExpansionZoom(t){return(await this.actorPromise).sendAsync({type:"GCEZ",data:{type:this.type,clusterId:t,source:this.id}})}async getClusterChildren(t){return(await this.actorPromise).sendAsync({type:"GCC",data:{type:this.type,clusterId:t,source:this.id}})}async getClusterLeaves(t,i,r){return(await this.actorPromise).sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:t,limit:i,offset:r}})}async _updateWorkerData(){if(this._isUpdatingWorker)return this._updatePromise;if(!this._hasPendingWorkerUpdate())return void(0,m.Nr)(`No pending worker updates for GeoJSONSource ${this.id}.`);let{data:t,diff:i,updateCluster:r}=this._pendingWorkerUpdate,a=this._getLoadGeoJSONParameters(t,i,r);void 0===t?i?this._pendingWorkerUpdate.diff=void 0:r&&(this._pendingWorkerUpdate.updateCluster=void 0):this._pendingWorkerUpdate.data=void 0,this._updatePromise=this._dispatchWorkerUpdate(a),await this._updatePromise}async _getLoadGeoJSONParameters(t,i,r){let a=(0,m.er)({type:this.type,source:this.id},this.workerOptions);return"string"==typeof t?(a.request=await this.map._requestManager.transformRequest(g.resolveURL(t),"Source"),a.request.collectResourceTiming=this._collectResourceTiming,a):void 0!==t?(a.data=t,a):i?(a.dataDiff=i,a):r?(a.updateCluster=!0,a):void 0}async _dispatchWorkerUpdate(t){this._isUpdatingWorker=!0,this.fire(new I("dataloading"));try{let i=await t,r=await (await this.actorPromise).sendAsync({type:"LD",data:i});if(this._isUpdatingWorker=!1,this._removed||r.abandoned)return void this.fire(new I("dataabort"));r.data&&(this._data={geojson:r.data});let a=this._applyDiffToSource(i.dataDiff),o=this._getShouldReloadTileOptions(a),s={};this._applyResourceTiming(s,r),this.fire(new I("data",{...s,sourceDataType:"metadata"})),this.fire(new I("data",{...s,sourceDataType:"content",shouldReloadTileOptions:o}))}catch(t){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new I("dataabort"));this.fire(new m.gn((0,m.Qn)(t)))}finally{this._hasPendingWorkerUpdate()&&await this._updateWorkerData()}}_applyResourceTiming(t,i){if(!this._collectResourceTiming)return;let r=i.resourceTiming?.[this.id];if(!r)return;let a=r.slice(0);a?.length&&(0,m.er)(t,{resourceTiming:a})}_applyDiffToSource(t){if(!t)return;let i="string"==typeof this.promoteId?this.promoteId:void 0;if(!this._data.url&&!this._data.updateable){let t=function(t,i){let r=new Map;if(null==t||null==t.type)return r;if("Feature"===t.type){let a=eP(t,i);return null==a?void 0:(r.set(a,t),r)}if("FeatureCollection"===t.type){let a=new Set;for(let o of t.features){let t=eP(o,i);if(null==t||a.has(t))return;a.add(t),r.set(t,o)}return r}}(this._data.geojson,i);if(!t)throw Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:t}}if(!this._data.updateable)return;let r=function(t,i,r){let a=[];if(i.removeAll)t.clear();else if(i.remove)for(let r of i.remove){let i=t.get(r);i&&(a.push(i.geometry),t.delete(r))}if(i.add)for(let o of i.add){let i=eP(o,r);if(null==i)continue;let s=t.get(i);s&&a.push(s.geometry),a.push(o.geometry),t.set(i,o)}if(i.update)for(let r of i.update){let i=t.get(r.id);if(!i)continue;let o=!!r.newGeometry,s=r.removeAllProperties||r.removeProperties?.length>0||r.addOrUpdateProperties?.length>0;if(!o&&!s)continue;a.push(i.geometry);let n={...i};if(t.set(r.id,n),o&&(a.push(r.newGeometry),n.geometry=r.newGeometry),s){if(n.properties=r.removeAllProperties?{}:{...n.properties||{}},r.removeProperties)for(let t of r.removeProperties)delete n.properties[t];
1if(r.addOrUpdateProperties)for(let{key:t,value:i}of r.addOrUpdateProperties)n.properties[t]=i}}return a}(this._data.updateable,t,i);if(!(t.removeAll||this._options.cluster))return r}_getShouldReloadTileOptions(t){if(t)return{affectedBounds:t.filter(Boolean).map(t=>eC(t))}}shouldReloadTile(t,{affectedBounds:i}){if("loading"===t.state)return!0;if("unloaded"===t.state)return!1;let{buffer:r,extent:a}=this.workerOptions.geojsonVtOptions,o=function({x:t,y:i,z:r},a=0){return new ey([(0,m.at)((t-a)/2**r),(0,m.it)((i+1+a)/2**r)],[(0,m.at)((t+1+a)/2**r),(0,m.it)((i-a)/2**r)])}(t.tileID.canonical,r/a);for(let t of i)if(o.intersects(t))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}async loadTile(t){let i=t.actor?"RT":"LT";t.actor=await this.actorPromise;let r={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};t.abortController=new AbortController;try{let a=await (await this.actorPromise).sendAsync({type:i,data:r},t.abortController);delete t.abortController,t.unloadVectorData(),t.aborted||t.loadVectorData(a,this.map.painter,"RT"===i)}catch(i){if(delete t.abortController,t.aborted||(0,m.Mn)(i))return;throw i}}async abortTile(t){t.abortController&&(t.abortController.abort(),delete t.abortController),t.aborted=!0}async unloadTile(t){t.unloadVectorData(),await (await this.actorPromise).sendAsync({type:"RMT",data:{uid:t.uid,type:this.t
1ype,source:this.id}})}onRemove(){this._removed=!0,this.actorPromise.then(t=>t.sendAsync({type:"RS",data:{type:this.type,source:this.id}}))}serialize(){return(0,m.er)({},this._options,{type:this.type,data:this._data.updateable?{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}:this._data.url||this._data.geojson})}hasTransition(){return!1}};let eE=[0,0,1],ez=(t,i,r,a,o,s)=>{var n;return{u_tl_parent:t,u_scale_parent:i,u_buffer_scale:1,u_image_warp:s,u_fade_t:r.mix,u_opacity:r.opacity*a.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:a.paint.get("raster-brightness-min"),u_brightness_high:a.paint.get("raster-brightness-max"),u_saturation_factor:function(t){return t>0?1-1/(1.001-t):-t}(a.paint.get("raster-saturation")),u_contrast_factor:(n=a.paint.get("raster-contrast"))>0?1/(1-n):1+n,u_spin_weights:function(t){let i=Math.sin(t*=Math.PI/180),r=Math.cos(t);return[(2*r+1)/3,(-Math.sqrt(3)*i-r+1)/3,(Math.sqrt(3)*i-r+1)/3]}(a.paint.get("raster-hue-rotate")),u_coords_top:[o[0].x,o[0].y,o[1].x,o[1].y],u_coords_bottom:[o[3].x,o[3].y,o[2].x,o[2].y]}};var eR=class{constructor(t,i,r){this.vertexBuffer=t,this.indexBuffer=i,this.segments=r}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}};let eD=(0,m.Yt)([{name:"a_pos",type:"Int16",components:2}]),eL=m.Lr/128;function eA(t,i){let r=function(t,i){let r=void 0===t.granularity?1:Math.max(t.granularity,1),a=r+2*!!t.generateBorders,o=r+(t.extendToNorthPole||t.generateBorders?1:0)+(t.extendToSouthPole||t.generateBorders?1:0),s=a+1,n=o+1,l=t.generateBorders?-1:0,h=t.generateBorders||t.extendToNorthPole?-1:0,c=r+ +!!t.generateBorders,u=r+(t.generateBorders||t.extendToSouthPole?1:0),d=a*o*6,_=s*n>65536;if(_&&"16bit"===i)throw Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");let p=_||"32bit"===i,f=new Int16Array(s*n*2),g=0;for(let i=h;i<=u;i++)for(let a=l;a<=c;a++){let o=a/r*m.Lr;-1===a&&(o=-eL),a===r+1&&(o=m.Lr+eL);let s=i/r*m.Lr;-1===i&&(s=t.extendToNorthPole?m.ht:-eL),i===r+1&&(s=t.extendToSouthPole?m.gt:m.Lr+eL),f[g++]=o,f[g++]=s}let v=p?new Uint32Array(d):new Uint16Array(d),y=0;for(let t=0;t<o;t++)for(let i=0;i<a;i++){let r=i+t*s,a=i+1+t*s,o=i+(t+1)*s,n=i+1+(t+1)*s;v[y++]=r,v[y++]=o,v[y++]=a,v[y++]=a,v[y++]=o,v[y++]=n}return{vertices:f.buffer.slice(0),indices:v.buffer.slice(0),uses32bitIndices:p}}(i,"16bit"),a=m.Gt.deserialize({arrayBuffer:r.vertices,length:r.vertices.byteLength/2/2}),o=m.Jt.deserialize({arrayBuffer:r.indices,length:r.indices.byteLength/2/3});return new eR(t.createVertexBuffer(a,eD.members),t.createIndexBuffer(o),m.Bt.simpleSegment(0,0,a.length,o.length))}var eF=class extends m.vn{constructor(t,i,r,a){super(),this.imageWarp=eE,this.flippedWindingOrder=!1,this._warp="auto",this._imageDirty=!1,this._subdividedQuad=!1,this._subdividedMesh=null,this.id=t,this.dispatcher=r,this.coordinates=i.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(a),this.options=i}async load(t){if(void 0===this.options.url){this._loaded=!0,this._finishLoading();return}this._loaded=!1,this.fire(new I("dataloading")),this.url=this.options.url,this._abortController=new AbortController;try{let i=await n.transformAndGetImage(this.map._requestManager,this.url,"Image",this._abortController);this._abortController=null,this._loaded=!0,i?.data?(this._setImage(i.data),t&&(this.coordinates=t),this._finishLoading()):this.fire(new m.gn(Error(`Could not load image ${this.url}: the response is empty`)))}catch(t){if((0,m.Mn)(t))return;this._abortController=null,this._loaded=!0,this.fire(new m.gn((0,m.Qn)(t)))}}loaded(){return this._loaded}updateImage(t){return this._abortController&&=(this._abortController.abort(),null),"image"in t?(this._loaded=!0,this._setImage(t.image),t.coordinates&&(this.coordinates=t.coordinates),this._finishLoading()):t.url&&(this.options.url=t.url,this.load(t.coordinates)),this}_setImage(t){this.image=t,this._imageDirty=!0}getMesh(t,i){return!this._subdividedQuad||i?null:(this._subdividedMesh??=eA(t,{granularity:16}),this._subdividedMesh)}_disposeTexture(){this.texture?.destroy(),this.texture=null}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new I("data",{sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this._abortController&&=(this._abortController.abort(),null),this._disposeTexture(),this._subdividedMesh?.destroy(),this._subdividedMesh=null,this.image=null,this.tiles={}}setWarp(t){return this._warp===t||(this._warp=t,this.tileCoords&&this.setCoordinates(this.coordinates)),this}getWarp(){return this._warp}setCoordinates(t){var i,r;let a,o,s,n,l,h;this.coordinates=t;let c=t.map(m.nt.fromLngLat);return this.tileID=(i=c,o=Math.max(0,Math.floor(-Math.log(Math.max((a=m.pt.fromPoints(i)).width(),a.height()))/Math.LN2)),s=2**o,new m.u(o,Math.floor((a.minX+a.maxX)/2*s),Math.floor((a.minY+a.maxY)/2*s))),this.terrainTileRanges=this._getOverlappingTileRanges(c),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=c.map(t=>
1this.tileID.getTilePoint(t)._round()),this.imageWarp=function(t,i){if("flat"===i||ek(t))return eE;let[r,a,o,s]=t,n=r.x-a.x+o.x-s.x,l=r.y-a.y+o.y-s.y,h=[a.x-o.x,a.y-o.y,s.x-o.x,s.y-o.y],[c,u,d,_]=h,p=h[0]*h[3]-h[2]*h[1],m=(n*_-d*l)/p,f=(c*l-n*u)/p,g=[1,1+m,1+m+f,1+f],v=Math.max(...g)/Math.min(...g),y="perspective"===i?0:Math.max(0,(1-4/v)/(1-4/512));return!(v>=1&&v<=512)||y>=1?eE:[m,f,y]}(this.tileCoords,this._warp),this._subdividedQuad=this.imageWarp[2]>0&&!ek(this.tileCoords),this.flippedWindingOrder=(n=(r=this.tileCoords)[1].x-r[0].x,l=r[1].y-r[0].y,h=r[2].x-r[0].x,n*(r[2].y-r[0].y)-l*h<0),this.fire(new I("data",{sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;let t=this.map.painter.context,i=t.gl;this.texture?this._imageDirty&&(this.texture.update(this.image),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE)):(this.texture=new m.xt(t,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE)),this._imageDirty=!1;let r=!1;for(let t in this.tiles){let i=this.tiles[t];"loaded"!==i.state&&(i.state="loaded",i.texture=this.texture,r=!0)}r&&this.fire(new I("data",{sourceDataType:"idle",sourceId:this.id}))}async loadTile(t){this.tileID?.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={}):t.state="errored"}serialize(){let t={type:"image",coordinates:this.coordinates};return void 0!==this.options.url&&(t.url=this.options.url),t}hasTransition(){return!1}_getOverlappingTileRanges(t){let{minX:i,minY:r,maxX:a,maxY:o}=m.pt.fromPoints(t),s={};for(let t=0;t<=25;t++){let n=2**t,l=Math.floor(i*n),h=Math.floor(r*n),c=Math.floor(a*n),u=Math.floor(o*n),d=(l%n+n)%n,_=c%n,p=Math.floor(l/n),m=Math.floor(c/n);s[t]={minWrap:p,maxWrap:m,minTileXWrapped:d,maxTileXWrapped:_,minTileY:h,maxTileY:u}}return s}};function ek(t){let[i,r,a,o]=t;return i.x+a.x===r.x+o.x&&i.y+a.y===r.y+o.y}var eB=class extends eF{constructor(t,i,r,a){super(t,i,r,a),this._onPlayingHandler=()=>{this.map?.triggerRepaint()},this.roundZoom=!0,this.type="video",this.options=i}async load(){this._loaded=!1;let t=this.options;for(let i of(this.urls=[],t.urls))this.urls.push((await this.map._requestManager.transformRequest(i,"Source")).url);try{let t=await (0,m.wn)(this.urls);if(this._loaded=!0,!t)return;this.video=t,this.video.loop=!0,this.video.addEventListener("playing",this._onPlayingHandler),this.map&&this.video.play(),this._finishLoading()}catch(t){this.fire(new m.gn((0,m.Qn)(t)))}}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){let i=this.video.seekable;t<i.start(0)||t>i.end(0)?this.fire(new m.gn(new m.pn(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}onRemove(){super.onRemove(),this.video&&(this.video.removeEventListener("playing",this._onPlayingHandler),this.video.pause())}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;let t=this.map.painter.context,i=t.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new m.xt(t,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(let t in this.tiles){let i=this.tiles[t];"loaded"!==i.state&&(i.state="loaded",i.texture=this.texture,r=!0)}r&&this.fire(new I("data",{sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},eO=class extends eF{constructor(t,i,r,a){super(t,i,r,a),i.coordinates?(!Array.isArray(i.coordinates)||4!==i.coordinates.length||i.coordinates.some(t=>!Array.isArray(t)||2!==t.length||t.some(t=>"number"!=typeof t)))&&this.fire(new m.gn(new m.pn(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new m.gn(new m.pn(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new m.gn(new m.pn(`sources.${t}
1`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new m.gn(new m.pn(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new m.gn(new m.pn(`sources.${t}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}async load(){if(this._loaded=!0,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())return void this.fire(new m.gn(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(),!1)},this._finishLoading()}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this._playing=!1,super.onRemove()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions()||0===Object.keys(this.tiles).length)return;let i=this.map.painter.context,r=i.gl;this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new m.xt(i,this.canvas,r.RGBA,{premultiply:!0}),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE));let a=!1;for(let t in this.tiles){let i=this.tiles[t];"loaded"!==i.state&&(i.state="loaded",i.texture=this.texture,a=!0)}a&&this.fire(new I("data",{sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",animate:this.animate,canvas:this.options.canvas,coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(let t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}};let ej={},eN="RTLPluginLoaded";var eZ=class extends m.vn{constructor(...t){super(...t),this.status="unavailable",this.url=null,this.dispatcher=(u||(u=new em(c||=new e_,m.bn)).registerMessageHandler("GR",(t,i,r)=>(0,m.Tn)(i,r)),u)}_syncState(t){return this.status=t,this.dispatcher.broadcast("SRPS",{pluginStatus:t,pluginURL:this.url}).catch(t=>{throw this.status="error",t})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}async setRTLTextPlugin(t,i=!1){if(this.url)throw Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=g.resolveURL(t),!this.url)throw Error(`requested url ${t} is invalid`);if("unavailable"===this.status)if(!i)return this._requestImport();else this.status="deferred",this._syncState(this.status);else if("requested"===this.status)return this._requestImport()}async _requestImport(){await this._syncState("loading"),this.status="loaded",this.fire(new m._n(eN))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}};let eU=null;function eG(){return eU||=new eZ}var eV=class{constructor(t,i){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=t,this.uid=(0,m.Mr)(),this.uses=0,this.tileSize=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rttObjects=[],this.rttFingerprint={},this.expiredRequestCount=0,this.state="loading",this.featureStateRevision=-1}isRenderable(t){return this.hasData()&&(!this.fadeEndTime||0!==this.fadingDirection||this.fadeOpacity>0)&&(t||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:t,fadingDirection:i,fadingParentID:r,fadeEndTime:a}){this.resetFadeLogic(),this.fadingRole=t,this.fadingDirection=i,this.fadingParentID=r,this.fadeEndTime=a}setSelfFadeLogic(t){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=t}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=y(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}clearTextures(t){this.demTexture&&t.saveTileTexture(this.demTexture),this.demTexture=null}getRTT(t){return this.rttObjects[t]}acquireRTT(t,i,r){return this.rttObjects[i]=t.acquireRTT(r)}releaseRTT(t){if(0!==this.rttObjects.length){for(let i of this.rttObjects)i&&t.releaseRTT(i);this.rttObjects.length=0}}loadVectorData(t,i,r){if(t?.etagUnmodified===!0){this.state="loaded";return}if(this.hasData()&&this.unloadVectorData(),this.state="loaded",!t){this.collisionBoxArray=new m.Vt;return}for(let a in t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestEncoding=t.encoding,this.latestFeatureIndex.rawTileData=t.rawTileData,this.latestFeatureIndex.encoding=t.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=function(t,i){let r={};if(!i)return r;for(let a of t){let t=a.layerIds.map(t=>
1i.getLayer(t)).filter(Boolean);if(0!==t.length)for(let i of(a.layers=t,a.stateDependentLayerIds&&(a.stateDependentLayers=a.stateDependentLayerIds.map(i=>t.filter(t=>t.id===i)[0])),t))r[i.id]=a}return r}(t.buckets,i?.style),this.hasSymbolBuckets=!1,this.buckets){let t=this.buckets[a];if(t instanceof m.S)if(this.hasSymbolBuckets=!0,r)t.justReloaded=!0;else break}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let t in this.buckets){let i=this.buckets[t];if(i instanceof m.S&&i.hasRTLText){this.hasRTLText=!0,eG().lazyLoad();break}}for(let t in this.queryPadding=0,this.buckets){let r=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(t).queryRadius(r))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),this.dashPositions=t.dashPositions}unloadVectorData(){for(let t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.imageAtlas=null,this.dashPositions=null,this.latestFeatureIndex=null,this.state="unloaded"}getBucket(t){return this.buckets[t.id]}upload(t){for(let i in this.buckets){let r=this.buckets[i];r.uploadPending()&&r.upload(t)}let i=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new m.xt(t,this.imageAtlas.image,i.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&=(this.glyphAtlasTexture=new m.xt(t,this.glyphAtlasImage,i.ALPHA),null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,i,r,a,o,s,n,l,h,c,u){return this.latestFeatureIndex?.rawTileData?this.latestFeatureIndex.query({queryGeometry:a,cameraQueryGeometry:o,scale:s,tileSize:this.tileSize,pixelPosMatrix:c,transform:l,params:n,queryPadding:this.queryPadding*h,getElevation:u},t,i,r):{}}querySourceFeatures(t,i){let r=this.latestFeatureIndex;if(!r?.rawTileData)return;let a=r.loadVTLayers(),o=i?.sourceLayer?i.sourceLayer:"",s=a._geojsonTileLayer||a[o];if(!s)return;let n=(0,m.cn)(i?.filter,`querySourceFeatures[${o}].filter`,i?.globalState),{z:l,x:h,y:c}=this.tileID.canonical,u={z:l,x:h,y:c};for(let i=0;i<s.length;i++){let a=s.feature(i);if(n.needGeometry){let t=(0,m.At)(a,!0);if(!n.filter(new m.en(this.tileID.overscaledZ),t,this.tileID.canonical))continue}else if(!n.filter(new m.en(this.tileID.overscaledZ),a))continue;let d=r.getId(a,o),_=new m.a(a,l,h,c,d);_.tile=u,t.push(_)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){let i=this.expirationTime;if(t.cacheControl){let i=(0,m.vr)(t.cacheControl);i["max-age"]&&(this.expirationTime=Date.now()+1e3*i["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){let t=Date.now(),r=!1;if(this.expirationTime>t)r=!1;else if(i)if(this.expirationTime<i)r=!0;else{let a=this.expirationTime-i;a?this.expirationTime=t+Math.max(a,3e4):r=!0}else r=!0;r?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),0x80000000-1)}setFeatureState(t,i,r){if(!this.latestFeatureIndex?.rawTileData||0===Object.keys(t).length||this.featureStateRevision===r)return;this.featureStateRevision=r;let a=this.latestFeatureIndex.loadVTLayers();for(let r in this.buckets){if(!i.style.hasLayer(r))continue;let o=this.buckets[r],s=o.layers[0].sourceLayer||"_geojsonTileLayer",n=a[s],l=t[s];if(!n||!l||0===l.length)continue;o.update(l,n,this.imageAtlas?.patternPositions||{},this.dashPositions||{});let h=i?.style?.getLayer(r);h&&(this.queryPadding=Math.max(this.queryPadding,h.queryRadius(o)))}}holdingForSymbolFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<y()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(t){this.symbolFadeHoldUntil=y()+t}
1setDependencies(t,i){let r={};for(let t of i)r[t]=!0;this.dependencies[t]=r}hasDependency(t,i){for(let r of t){let t=this.dependencies[r];if(t){for(let r of i)if(t[r])return!0}}return!1}};function eq(t){let i=[];for(let r in t)i.push({id:r,state:t[r]});return i}var eW=class{constructor(){this.state={},this.stateChanges={},this.deletedStates={},this.revision=0}updateState(t,i,r){let a=String(i);if(this.stateChanges[t]||={},this.stateChanges[t][a]||={},(0,m.er)(this.stateChanges[t][a],r),null===this.deletedStates[t])for(let i in this.deletedStates[t]={},this.state[t])if(i===a)for(let o in this.deletedStates[t][a]={},this.state[t][i])void 0===r[o]&&(this.deletedStates[t][a][o]=null);else this.deletedStates[t][i]=null;else if(this.deletedStates[t]?.[a]===null)for(let i in this.deletedStates[t][a]={},this.state[t][a])void 0===r[i]&&(this.deletedStates[t][a][i]=null);else for(let i in r)this.deletedStates[t]?.[a]?.[i]===null&&delete this.deletedStates[t][a][i]}removeFeatureState(t,i,r){if(null===this.deletedStates[t])return;let a=String(i);if(this.deletedStates[t]||={},r&&void 0!==i)null!==this.deletedStates[t][a]&&(this.deletedStates[t][a]||={},this.deletedStates[t][a][r]=null);else if(void 0!==i)if(this.stateChanges[t]?.[a])for(r in this.deletedStates[t][a]={},this.stateChanges[t][a])this.deletedStates[t][a][r]=null;else this.deletedStates[t][a]=null;else this.deletedStates[t]=null}getState(t,i){let r=String(i),a=this.state[t]||{},o=this.stateChanges[t]||{},s=(0,m.er)({},a[r],o[r]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){let r=this.deletedStates[t][i];if(null===r)return{};for(let t in r)delete s[t]}return s}initializeTileState(t,i){let r={};for(let t in this.state)r[t]=eq(this.state[t]);t.setFeatureState(r,i,this.revision)}coalesceChanges(t,i){let r={};for(let t in this.stateChanges)for(let i in this.state[t]||={},r[t]||={},this.stateChanges[t])this.state[t][i]||={},(0,m.er)(this.state[t][i],this.stateChanges[t][i]),r[t][i]=this.state[t][i];for(let t in this.deletedStates)if(this.state[t]||={},r[t]||={},null===this.deletedStates[t])for(let i in this.state[t])this.state[t][i]={},r[t][i]={};else for(let i in this.deletedStates[t]){if(null===this.deletedStates[t][i])this.state[t][i]={};else for(let r of Object.keys(this.deletedStates[t][i]))delete this.state[t][i][r];r[t][i]=this.state[t][i]}if(this.stateChanges={},this.deletedStates={},0===Object.keys(r).length)return;this.revision++;let a={};for(let t in r)a[t]=eq(r[t]);t.setFeatureState(a,i,this.revision)}},e$=class t{constructor(t,i){this.min=t,this.max=i,this.center=(0,m.ci)([],(0,m.Xr)([],this.min,this.max),.5)}quadrant(i){let r=[i%2==0,i<2],a=(0,m.Zr)(this.min),o=(0,m.Zr)(this.max);for(let t=0;t<r.length;t++)a[t]=r[t]?this.min[t]:this.center[t],o[t]=r[t]?this.center[t]:this.max[t];return o[2]=this.max[2],new t(a,o)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}intersectsFrustum(t){let i=!0;for(let r of t.planes){let t=this.intersectsPlane(r);if(0===t)return 0;1===t&&(i=!1)}return i?2:t.aabb.min[0]>this.max[0]||t.aabb.min[1]>this.max[1]||t.aabb.min[2]>this.max[2]||t.aabb.max[0]<this.min[0]||t.aabb.max[1]<this.min[1]||t.aabb.max[2]<this.min[2]?0:1}intersectsPlane(t){let i=t[3],r=t[3];for(let a=0;a<3;a++)t[a]>0?(i+=t[a]*this.min[a],r+=t[a]*this.max[a]):(r+=t[a]*this.min[a],i+=t[a]*this.max[a]);return i>=0?2:r<0?0:1}},eH=class t{constructor(t,i,r){this.points=t,this.planes=i,this.aabb=r}static fromInvProjectionMatrix(i,r=1,a=0,o,s){let n=s?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],l=2**a,h=[[-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(t=>{var a,o,s,n;let h,c;return a=t,o=i,s=r,n=l,c=1/(h=(0,m.Yr)([],a,o))[3]/s*n,(0,m.qr)(h,h,[c,c,1/h[3],c])});o&&function(t,i,r,a){var o,s;let n,l,h,c=4*!!a,u=4*!a,d=0,_=[],p=[];for(let i=0;i<4;i++){let r=(0,m.ui)([],t[i+u],t[i+c]),a=(0,m.ni)(r);(0,m.ci)(r,r,1/a),_.push(a),p.push(r)}for(let i=0;i<4;i++){let a=(0,m.Sr)(t[i+c],p[i],r);d=null!==a&&a>=0?Math.max(d,a):Math.max(d,_[i])}let f=(o=t,s=i,n=(0,m.ui)([],o[s[0]],o[s[1]]),l=(0,m.ui)([],o[s[2]],o[s[1]]),h=[0,0,0,0],(0,m.ii)(h,(0,m.Qr)([],n,l)),h[3]=-(0,m.ei)(h,o[s[0]]),h),g=function(t,i){let r=(0,m.ti)(t),a=(0,m.Jr)([],t,1/r),o=(0,m.ui)([],i,(0,m.ci)([],a,(0,m.ei)(i,a))),s=(0,m.ti)(o);if(s>0){let t=Math.sqrt(1-a[3]*a[3]),r=(0,m.ci)([],a,-a[3]),n=(0,m.Xr)([],r,(0,m.ci)([],o,t/s));return(0,m.br)(i,n)}return null}(r,f);null!==g&&(d=Math.min(d,g/(0,m.ei)(p[0],f)));for(let i=0;i<4;i++){let r=Math.min(d,_[i]);t[i+u]=[t[i+c][0]+p[i][0]*r,t[i+c][1]+p[i][1]*r,t[i+c][2]+p[i][2]*r,1]}}(h,n[0],o,s);let c=n.map(t=>{let i=(0,m.ui)([],h[t[0]],h[t[1]]),r=(0,m.ui)([],h[t[2]],h[t[1]]),a=(0,m.ii)([],(0,m.Qr)([],i,r)),o=-(0,m.ei)(a,h[t[1]]);return a.concat(o)}),u=[1/0,1/0,1/0],d=[-1/0,-1/0,-1/0];for(let t of h)for(let i=0;i<3;i++)u[i]=Math.min(u[i],t[i]),d[i]=Math.max(d[i],t[i]);return new t(h,c,new e$(u,d))}};function eX(t,i,r){let a=0,o=(r-i)/10;for(let s=0;s<10;s++){let n=i+(s+.5)/10*(r-i);a+=o*Math.cos(n)**t}return a}function eY(t,i){return function(r,a,o,s,n){let l=2*((t-1)/(0,m.Dr)(Math.cos((0,m.Yn)(m.Q-n))/Math.cos((0,m.Yn)(m.Q)))-1),h=Math.acos(o/s),c=2*eX(l-1,0,(0,m.Yn)(n/2)),u=Math.min((0,m.Yn)(m.Q),h+(0,m.Yn)(n/2)),d=eX(l-1,Math.min(u,h-(0,m.Yn)(n/2)),u),_=Math.atan(a/o),p=Math.hypot(a,o),f=r;return f+=(0,m.Dr)(s/p/Math.max(.5,Math.cos((0,m.Yn)(n/2)))),f+=l*(0,m.Dr)(Math.cos(_))/2,f-=(0,m.Dr)(Math.max(1,d/c/i))/2}}let eK=eY(9.314,3);function eJ(t,i){return Math.max(0,(i.roundZoom?Math.round:Math.floor)(t.zoom+(0,m.Dr)(t.tileSize/i.tileSize)))}function eQ(t,i){var r;let a,o,s,n=t.getCameraFrustum(),l=t.getClippingPlane();if(l&&i.maxContentElevation>0){let r=Math.hypot(l[0],l[1],l[2]);if(r>0){let a=1+i.maxContentElevation/m.ut,o=Math.cos(Math.acos((0,m.Bn)(-l[3]/r,-1,1))+Math.acos(1/a));l=[l[0],l[1],l[2],-o*r],n=function(t,i,r){let a=t.planes[1],o=t.points.map(t=>{if(Math.abs(a[0]*t[0]+a[1]*t[1]+a[2]*t[2]+a[3])>1e-6)return t;
1let o=[t[0]-r[0],t[1]-r[1],t[2]-r[2]],s=a[0]*o[0]+a[1]*o[1]+a[2]*o[2];if(s>=-1e-9)return t;let n=-(i/s);return[t[0]+o[0]*n,t[1]+o[1]*n,t[2]+o[2]*n,t[3]]}),s=t.planes.map((t,r)=>1===r?[t[0],t[1],t[2],t[3]+i]:t),n=[1/0,1/0,1/0],l=[-1/0,-1/0,-1/0];for(let t of o)for(let i=0;i<3;i++)n[i]=Math.min(n[i],t[i]),l[i]=Math.max(l[i],t[i]);return new eH(o,s,new e$(n,l))}(n,Math.sqrt(a*a-1),t.cameraPosition)}}let h=(0,m.Y)(t),c=m.nt.fromLngLat(t.center,t.elevation),u=(r=i.maxContentElevation,a=m.Q-t.pitch-t.fov/2,o=(0,m.Bn)((15-a)/15,0,1),s=Math.max(500,r??0),t.elevation+o*s),d=t.getCoveringTilesDetailsProvider(),_=d.allowVariableZoom(t,i),p=eJ(t,i),f=i.minzoom||0,g=void 0===i.maxzoom?t.maxZoom:i.maxzoom,v=Math.min(Math.max(0,p),g),y=2**v,x=[y*h.x,y*h.y,0],b=[y*c.x,y*c.y,0],w=Math.hypot(c.x-h.x,c.y-h.y),T=Math.abs(c.z-h.z),P=Math.hypot(w,T),M=t=>({zoom:0,x:0,y:0,wrap:t,fullyVisible:!1}),I=[],C=[];if(t.renderWorldCopies&&d.allowWorldCopies())for(let t=1;t<=3;t++)I.push(M(-t)),I.push(M(t));for(I.push(M(0));I.length>0;){let r=I.pop(),a=r.x,o=r.y,s=r.fullyVisible,y={x:a,y:o,z:r.zoom},w=d.getTileBoundingVolume(y,r.wrap,u,i);if(!s){let t=function(t,i,r){let a=i.intersectsFrustum(t);if(!r||0===a)return a;let o=i.intersectsPlane(r);return 0===o?0:2===a&&2===o?2:1}(n,w,l);if(0===t)continue;s=2===t}let M=d.distanceToTile2d(h.x,h.y,y,w),S=p;_&&(S=(i.calculateTileZoom||eK)(t.zoom+(0,m.Dr)(t.tileSize/i.tileSize),M,T,P,t.fov));let E=Math.min(S=Math.max(0,S=(i.roundZoom?Math.round:Math.floor)(S)),g);if(r.wrap=d.getWrap(c,y,r.wrap),r.zoom>=E){if(r.zoom<f)continue;let t=v-r.zoom,s=x[0]-.5-(a<<t),n=x[1]-.5-(o<<t),l=i.reparseOverscaled?Math.max(r.zoom,S):r.zoom;C.push({tileID:new m.d(r.zoom===g?l:r.zoom,r.wrap,r.zoom,a,o),distanceSq:(0,m.Vr)([b[0]-.5-a,b[1]-.5-o]),tileDistanceToCamera:Math.sqrt(s*s+n*n)});continue}for(let t=0;t<4;t++){let i=(a<<1)+t%2,n=(o<<1)+(t>>1),l=r.zoom+1;I.push({zoom:l,x:i,y:n,wrap:r.wrap,fullyVisible:s})}}return C.sort((t,i)=>t.distanceSq-i.distanceSq).map(t=>t.tileID)}function e0(t){return"raster"===t||"image"===t||"video"===t}function e1(t,i,r,a,o,s,n){if(r[0].overscaledZ>=s)return!1;let l=!1;for(let s of r){let r=t.getLoadedTile(s);if(!r)continue;let{fadingRole:h,fadingDirection:c,fadingParentID:u}=r;0===h&&0===c&&u||(r.setCrossFadeLogic({fadingRole:0,fadingDirection:0,fadingParentID:i.tileID,fadeEndTime:o+n}),i.setCrossFadeLogic({fadingRole:1,fadingDirection:1,fadeEndTime:o+n})),a[s.key]=s,l=!0}return l}function e2(t,i){t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.needsColorReliefPrepare=!0;let r=i.tileID.canonical.x-t.tileID.canonical.x,a=i.tileID.canonical.y-t.tileID.canonical.y,o=2**t.tileID.canonical.z,s=i.tileID.key;(0!==r||0!==a)&&(Math.abs(a)>1||(Math.abs(r)>1&&(1===Math.abs(r+o)?r+=o:1===Math.abs(r-o)&&(r-=o)),i.dem&&t.dem&&(t.dem.backfillBorder(i.dem,r,a),t.neighboringTiles?.[s]&&(t.neighboringTiles[s].backfilled=!0))))}var e4=class{constructor(){this._tiles={}}handleWrapJump(t){let i={};for(let r in this._tiles){let a=this._tiles[r];a.tileID=a.tileID.unwrapTo(a.tileID.wrap+t),i[a.tileID.key]=a}this._tiles=i}setFeatureState(t,i,r){for(let a in this._tiles)this._tiles[a].setFeatureState(t,i,r)}getAllTiles(){return Object.values(this._tiles)}getAllIds(t=!1){return t?Object.values(this._tiles).map(t=>t.tileID).sort(m.m).map(t=>t.key):Object.keys(this._tiles)}getTileById(t){return this._tiles[t]}setTile(t,i){this._tiles[t]=i}deleteTileById(t){delete this._tiles[t]}getLoadedTile(t){let i=this.getTileById(t.key);return i?.hasData()?i:null}isIdRenderable(t,i=!1){return this.getTileById(t)?.isRenderable(i)}getRenderableIds(t=0,i){let r=[];for(let t of this.getAllIds())this.isIdRenderable(t,i)&&r.push(this.getTileById(t));return i?r.sort((i,r)=>{let a=i.tileID,o=r.tileID,s=new m.Li(a.canonical.x,a.canonical.y)._rotate(-t),n=new m.Li(o.canonical.x,o.canonical.y)._rotate(-t);return a.overscaledZ-o.overscaledZ||n.y-s.y||n.x-s.x}).map(t=>t.tileID.key):r.map(t=>t.tileID).sort(m.m).map(t=>t.key)}},e3=class t extends m.vn{static{this.maxUnderzooming=10}static{this.maxOverzooming=3}constructor(t,i,r){super(),this._maxContentElevationSeen=0,this.id=t,this.dispatcher=r,this.on("data",t=>{this._dataHandler(t)}),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((t,i,r,a)=>{let o=new((t=>{switch(t){case"geojson":return eS;case"image":return eF;case"raster":return ew;case"raster-dem":return eT;case"vector":return eb;case"video":return eB;case"canvas":return eO}return ej[t]})(i.type))(t,i,r,a);if(o.id!==t)throw Error(`Expected Source id to be ${t} instead of ${o.id}`);return o}
1)(t,i,r,this),this._inViewTiles=new e4,this._outOfViewCache=new m.n(0,t=>this._unloadTile(t)),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new eW,this._didEmitContent=!1,this._updated=!1}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,this._source?.onAdd&&this._source.onAdd(t)}onRemove(t){for(let t of this._inViewTiles.getAllTiles())t.unloadVectorData();this.clearTiles(),this._source?.onRemove&&this._source.onRemove(t),this._inViewTiles=new e4}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if((void 0!==this.used||void 0!==this.usedForTerrain)&&!this.used&&!this.usedForTerrain)return!0;if(!this._updated)return!1;for(let t of this._inViewTiles.getAllTiles())if("loaded"!==t.state&&"errored"!==t.state)return!1;return!0}getSource(){return this._source}getState(){return this._state}pause(){this._paused=!0}resume(){if(!this._paused)return;let t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}async _loadTile(t,i,r,a){try{let o=await this._source.loadTile(t);this._tileLoaded(t,i,r,a,o)}catch(i){t.state="errored",404===i.status?this.update(this.transform,this.terrain):this._source.fire(new m.gn((0,m.Qn)(i),{tile:t}))}}_unloadTile(t){this._source.unloadTile&&this._source.unloadTile(t)}_abortTile(t){this._source.abortTile&&this._source.abortTile(t),this._source.fire(new I("dataabort",{tile:t,coord:t.tileID}))}serialize(){return this._source.serialize()}prepare(t){for(let i of(this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._inViewTiles,this.map?this.map.painter:null),this._inViewTiles.getAllTiles()))i.upload(t),i.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(t){return this._inViewTiles.getRenderableIds(this.transform?.bearingInRadians,t)}hasRenderableParent(t){let i=t.overscaledZ-1;if(i>=this._source.minzoom){let r=this.getLoadedTile(t.scaledTo(i));if(r)return this._inViewTiles.isIdRenderable(r.tileID.key)}return!1}reload(t,i){if(this._paused){this._shouldReloadOnResume=!0;return}for(let r of(this._outOfViewCache.reset(),this._inViewTiles.getAllIds())){let a=this._inViewTiles.getTileById(r);(!i||this._source.shouldReloadTile(a,i))&&(t?this._reloadTile(r,"errored"===a.state?"loading":"expired"):"errored"!==a.state&&this._reloadTile(r,"reloading"))}}async _reloadTile(t,i){let r=this._inViewTiles.getTileById(t);if(!r)return;let a=r.hasData();"loading"!==r.state&&(r.state=i),await this._loadTile(r,t,i,a)}_tileLoaded(t,i,r,a,o){a||(t.timeAdded=y(),t.selfFading&&(t.fadeEndTime=t.timeAdded+this._rasterFadeDuration)),"expired"===r&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(i,t),!o?.unmodified&&("raster-dem"===this.getSource().type&&t.dem&&function(t,i){for(let r of i.getRenderableIds()){if(!t.neighboringTiles?.[r])continue;let a=i.getTileById(r);t.neighboringTiles[r].backfilled||e2(t,a),a.neighboringTiles?.[t.tileID.key]?.backfilled||e2(a,t)}}(t,this._inViewTiles),t.featureStateRevision=-1,this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new I("data",{tile:t,coord:t.tileID})))}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._inViewTiles.getTileById(t)}_retainLoadedChildren(i,r){let a=this._getLoadedDescendents(r),o=new Set;for(let s of r){let r=a[s.key];if(!r?.length){o.add(s);continue}let n=s.overscaledZ+t.maxOverzooming,l=r.filter(t=>t.tileID.overscaledZ<=n);if(!l.length){o.add(s);continue}let h=Math.min(...l.map(t=>t.tileID.overscaledZ)),c=l.filter(t=>t.tileID.overscaledZ===h).map(t=>t.tileID);for(let t of c)i[t.key]=t;this._areDescendentsComplete(c,h,s.overscaledZ)||o.add(s)}return o}_getLoadedDescendents(t){let i={};for(let r of this._inViewTiles.getAllTiles().filter(t=>t.hasData()))for(let a of t)r.tileID.isChildOf(a)&&(i[a.key]||=[],i[a.key].push(r));return i}_areDescendentsComplete(t,i,r){return 1===t.length&&t[0].isOverscaled()?t[0].overscaledZ===i:4**(i-r)===t.length}getLoadedTile(t){return this._inViewTiles.getLoadedTile(t)}updateCacheSize(t){let i=Math.floor((Math.ceil(t.width/this._source.tileSize)+1)*(Math.ceil(t.height/this._source.tileSize)+1)*(null===this._maxTileC
1acheZoomLevels?m.An.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),r="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,i):i;this._outOfViewCache.setMaxSize(r)}handleWrapJump(t){let i=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);this._prevLng=t,i&&(this._inViewTiles.handleWrapJump(i),this._resetTileReloadTimers())}_updateMaxContentElevation(){let t=this._maxContentElevationSeen,i=this.map?.style?._layers;if(!i)return t;let r=this._inViewTiles.getAllTiles();for(let a in i){let o=i[a];if(!("symbol"!==o.type||o.source!==this.id||o.isHidden(this.transform.zoom))&&o.layout)for(let i of(t=Math.max(t,o.layout.get("symbol-height-offset").constantOr(0)),r)){let r=i.getBucket(o);r&&r.maxHeightOffset>t&&(t=r.maxHeightOffset)}}return this._maxContentElevationSeen=t,t}update(t,i){let r;if(!this._sourceLoaded||this._paused)return;this.transform=t,this.terrain=i,this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(t=>new m.d(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)):(r=eQ(t,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:"vector"===this._source.type&&void 0!==this.map._zoomLevelsToOverscale?Math.max(this._source.maxzoom,t.maxZoom-this.map._zoomLevelsToOverscale):this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:i,calculateTileZoom:this._source.calculateTileZoom,maxContentElevation:this._updateMaxContentElevation()}),this._source.hasTile&&(r=r.filter(t=>this._source.hasTile(t)))):r=[],this.usedForTerrain&&(r=this._addTerrainIdealTiles(r));let a=0===r.length&&!this._updated&&this._didEmitContent;this._updated=!0,a&&this.fire(new I("data",{sourceDataType:"idle",sourceId:this.id}));let o=eJ(t,this._source),s=this._updateRetainedTiles(r,o),n=e0(this._source.type);n&&this._rasterFadeDuration>0&&!i&&function(t,i,r,a,o,s,n){let l=y(),h=(0,m.ar)(i);for(let c of i){let i=t.getTileById(c.key);(0===i.fadingDirection||0===i.fadeOpacity)&&i.resetFadeLogic(),!function(t,i,r,a,o,s,n){if(!i.hasData())return!1;let{tileID:l,fadingRole:h,fadingDirection:c,fadingParentID:u}=i;if(0===h&&1===c&&u)return r[u.key]=u,!0;let d=Math.max(l.overscaledZ-o,s);for(let o=l.overscaledZ-1;o>=d;o--){let s=l.scaledTo(o),h=t.getLoadedTile(s);if(h)return i.setCrossFadeLogic({fadingRole:0,fadingDirection:1,fadingParentID:h.tileID,fadeEndTime:a+n}),h.setCrossFadeLogic({fadingRole:1,fadingDirection:0,fadeEndTime:a+n}),r[s.key]=s,!0}return!1}(t,i,r,l,a,o,n)&&(function(t,i,r,a,o,s){if(!i.hasData())return!1;let n=i.tileID.children(o),l=e1(t,i,n,r,a,o,s);if(l)return!0;for(let h of n)e1(t,i,h.children(o),r,a,o,s)&&(l=!0);return l}(t,i,r,l,s,n)||function(t,i,r,a){let o=t.tileID;return!!t.selfFading||!t.hasData()&&!!i.has(o)&&(t.setSelfFadeLogic(r+a),!0)}(i,h,l,n)||i.resetFadeLogic())}}(this._inViewTiles,r,s,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),n?this._cleanUpRasterTiles(s):this._cleanUpVectorTiles(s)}_cleanUpRasterTiles(t){for(let i of this._inViewTiles.getAllIds())t[i]||this._removeTile(i)}_cleanUpVectorTiles(t){for(let i of this._inViewTiles.getAllIds()){let r=this._inViewTiles.getTileById(i);if(t[i]){r.clearSymbolFadeHold();continue}if(!r.hasSymbolBuckets){this._removeTile(i);continue}r.holdingForSymbolFade()?r.symbolFadeFinished()&&this._removeTile(i):r.setSymbolHoldDuration(this.map._fadeDuration)}}_addTerrainIdealTiles(t){let i=[];for(let r of t)if(r.canonical.z>this._source.minzoom){let t=r.scaledTo(r.canonical.z-1);i.push(t);let a=r.scaledTo(Math.max(this._source.minzoom,Math.min(r.canonical.z,5)));i.push(a)}return t.concat(i)}releaseSymbolFadeTiles(){for(let t of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(t).holdingForSymbolFade()&&this._removeTile(t)}_updateRetainedTiles(i,r){let a=new Set;for(let t of i)this._addTile(t).hasData()||a.add(t);let o=i.reduce((t,i)=>(t[i.key]=i,t),{}),s=this._retainLoadedChildren(o,a),n={},l=Math.max(r-t.maxUnderzooming,this._source.minzoom);for(let t of s){let i=this._inViewTiles.getTileById(t.key),r=i?.wasRequested();for(let a=t.overscaledZ-1;a>=l;--a){let s=t.scaledTo(a);if(n[s.key])break;if(n[s.key]=!0,(i=this.getTile(s))||!r||(i=this._addTile(s)),i){let t=i.hasData();if((t||!this.map?.cancelPendingTileRequestsWhileZooming||r)&&(o[s.key]=s),r=i.wasRequested(),t)break}}}return o}_addTile(t){let i=this._inViewTiles.getTileById(t.key);if(i)return i;(i=this._outOfViewCache.getAndRemove(t))&&(i.resetFadeLogic(),this._setTileReloadTimer(t.key,i),i.tileID=t,this._state.initializeTileState(i,this.map?this.map.painter:null));let r=i;
1return i||(i=new eV(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(i,t.key,i.state,!1)),i.uses++,this._inViewTiles.setTile(t.key,i),r||this._source.fire(new I("dataloading",{tile:i,coord:i.tileID})),i}_setTileReloadTimer(t,i){this._clearTileReloadTimer(t);let r=i.getExpiryTimeout();if(r){let i=()=>{this._reloadTile(t,"expired"),delete this._timers[t]};this._timers[t]=setTimeout(i,r)}}_clearTileReloadTimer(t){let i=this._timers[t];i&&(clearTimeout(i),delete this._timers[t])}_resetTileReloadTimers(){for(let t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(let t of this._inViewTiles.getAllIds()){let i=this._inViewTiles.getTileById(t);this._setTileReloadTimer(t,i)}}refreshTiles(t){for(let i of this._inViewTiles.getAllIds()){let r=this._inViewTiles.getTileById(i);(this._inViewTiles.isIdRenderable(i)||"errored"==r.state)&&t.some(t=>t.equals(r.tileID.canonical))&&this._reloadTile(i,"expired")}}_removeTile(t){let i=this._inViewTiles.getTileById(t);i&&(i.uses--,this._inViewTiles.deleteTileById(t),this._clearTileReloadTimer(t),i.uses>0||(i.hasData()&&"reloading"!==i.state?this._outOfViewCache.add(i.tileID,i,i.getExpiryTimeout()):(i.aborted=!0,this._abortTile(i),this._unloadTile(i))))}_dataHandler(t){if("source"===t.dataType){if("metadata"===t.sourceDataType){this._sourceLoaded=!0;return}"content"===t.sourceDataType&&this._sourceLoaded&&!this._paused&&(this.reload(t.sourceDataChanged,t.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}}resetMaxContentElevation(){this._maxContentElevationSeen=0}clearTiles(){for(let t of(this._shouldReloadOnResume=!1,this._paused=!1,this.resetMaxContentElevation(),this._inViewTiles.getAllIds()))this._removeTile(t);this._outOfViewCache.reset()}tilesIn(t,i,r){let a=[],o=this.transform;if(!o)return a;let s=o.getCoveringTilesDetailsProvider().allowWorldCopies(),n=r?o.getCameraQueryGeometry(t):t,l=t=>o.screenPointToMercatorCoordinate(t,this.terrain),h=this.transformBbox(t,l,!s),c=this.transformBbox(n,l,!s),u=this.getIds(),d=m.pt.fromPoints(c);for(let t of u){let r=this._inViewTiles.getTileById(t);if(r.holdingForSymbolFade())continue;let n=s?[r.tileID]:[r.tileID.unwrapTo(-1),r.tileID.unwrapTo(0)],l=2**(o.zoom-r.tileID.overscaledZ),u=i*r.queryPadding*m.Lr/r.tileSize/l;for(let t of n){let i=d.map(i=>t.getTilePoint(new m.nt(i.x,i.y)));if(i.expandBy(u),i.intersects(m.ft)){let i=h.map(i=>t.getTilePoint(i)),o=c.map(i=>t.getTilePoint(i));a.push({tile:r,tileID:s?t:t.unwrapTo(0),queryGeometry:i,cameraQueryGeometry:o,scale:l})}}}return a}transformBbox(t,i,r){let a=t.map(i);if(r){let r=m.pt.fromPoints(t);r.shrinkBy(.001*Math.min(r.width(),r.height()));let o=r.map(i);m.pt.fromPoints(a).covers(o)||(a=a.map(t=>t.x>.5?new m.nt(t.x-1,t.y,t.z):t))}return a}getVisibleCoordinates(t){let i=this.getRenderableIds(t).map(t=>this._inViewTiles.getTileById(t).tileID);return this.transform&&this.transform.populateCache(i),i}hasTransition(){return!!this._source.hasTransition()||e0(this._source.type)&&function(t,i){if(i<=0)return!1;let r=y();for(let i of t.getAllTiles())if(i.fadeEndTime>=r)return!0;return!1}(this._inViewTiles,this._rasterFadeDuration)}setRasterFadeDuration(t){this._rasterFadeDuration=t}setFeatureState(t,i,r){t||=m.s,this._state.updateState(t,i,r)}removeFeatureState(t,i,r){t||=m.s,this._state.removeFeatureState(t,i,r)}getFeatureState(t,i){return t||=m.s,this._state.getState(t,i)}setDependencies(t,i,r){let a=this._inViewTiles.getTileById(t);a&&a.setDependencies(i,r)}reloadTilesForDependencies(t,i){for(let r of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(r).hasDependency(t,i)&&this._reloadTile(r,"reloading");this._outOfViewCache.filter(r=>!r.hasDependency(t,i))}areTilesLoaded(){for(let t of this._inViewTiles.getAllTiles())if("loaded"!==t.state&&"errored"!==t.state)return!1;return!0}},e5=class{constructor(t,i){this.reset(t,i)}reset(t,i){this.points=t||[],this._distances=[0];for(let t=1;t<this.points.length;t++)this._distances[t]=this._distances[t-1]+this.points[t].dist(this.points[t-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(i||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(1===this.points.length)return this.points[0];t=(0,m.Bn)(t,0,1);let i=1,r=this._distances[i],a=t*this.paddedLength+this.padding;
1for(;r<a&&i<this._distances.length;)r=this._distances[++i];let o=i-1,s=this._distances[o],n=r-s,l=n>0?(a-s)/n:0;return this.points[o].mult(1-l).add(this.points[i].mult(l))}};function e6(t,i,r,a,o){return o?t?t(i,r)+a:0===a?void 0:a:a}function e8(t,i){let r=!0;return"always"===t||("never"===t||"never"===i)&&(r=!1),r}var e9=class{constructor(t,i,r){let a=this.boxCells=[],o=this.circleCells=[];this.xCellCount=Math.ceil(t/r),this.yCellCount=Math.ceil(i/r);for(let t=0;t<this.xCellCount*this.yCellCount;t++)a.push([]),o.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=t,this.height=i,this.xScale=this.xCellCount/t,this.yScale=this.yCellCount/i,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(t,i,r,a,o){this._forEachCell(i,r,a,o,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(a),this.bboxes.push(o)}insertCircle(t,i,r,a){this._forEachCell(i-a,r-a,i+a,r+a,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(i),this.circles.push(r),this.circles.push(a)}_insertBoxCell(t,i,r,a,o,s){this.boxCells[o].push(s)}_insertCircleCell(t,i,r,a,o,s){this.circleCells[o].push(s)}_query(t,i,r,a,o,s,n){if(r<0||t>this.width||a<0||i>this.height)return[];let l=[];if(t<=0&&i<=0&&this.width<=r&&this.height<=a){if(o)return[{key:null,x1:t,y1:i,x2:r,y2:a}];for(let t=0;t<this.boxKeys.length;t++)l.push({key:this.boxKeys[t],x1:this.bboxes[4*t],y1:this.bboxes[4*t+1],x2:this.bboxes[4*t+2],y2:this.bboxes[4*t+3]});for(let t=0;t<this.circleKeys.length;t++){let i=this.circles[3*t],r=this.circles[3*t+1],a=this.circles[3*t+2];l.push({key:this.circleKeys[t],x1:i-a,y1:r-a,x2:i+a,y2:r+a})}}else this._forEachCell(t,i,r,a,this._queryCell,l,{hitTest:o,overlapMode:s,seenUids:{box:{},circle:{}}},n);return l}query(t,i,r,a){return this._query(t,i,r,a,!1,null)}hitTest(t,i,r,a,o,s){return this._query(t,i,r,a,!0,o,s).length>0}hitTestCircle(t,i,r,a,o){let s=t-r,n=t+r,l=i-r,h=i+r;if(n<0||s>this.width||h<0||l>this.height)return!1;let c=[];return this._forEachCell(s,l,n,h,this._queryCellCircle,c,{hitTest:!0,overlapMode:a,circle:{x:t,y:i,radius:r},seenUids:{box:{},circle:{}}},o),c.length>0}_queryCell(t,i,r,a,o,s,n,l){let{seenUids:h,hitTest:c,overlapMode:u}=n,d=this.boxCells[o];if(null!==d){let o=this.bboxes;for(let n of d)if(!h.box[n]){h.box[n]=!0;let d=4*n,_=this.boxKeys[n];if(t<=o[d+2]+1e-6&&i<=o[d+3]+1e-6&&r>=o[d+0]-1e-6&&a>=o[d+1]-1e-6&&(!l||l(_))&&(!c||!e8(u,_.overlapMode))&&(s.push({key:_,x1:o[d],y1:o[d+1],x2:o[d+2],y2:o[d+3]}),c))return!0}}let _=this.circleCells[o];if(null!==_){let o=this.circles;for(let n of _)if(!h.circle[n]){h.circle[n]=!0;let d=3*n,_=this.circleKeys[n];if(this._circleAndRectCollide(o[d],o[d+1],o[d+2],t,i,r,a)&&(!l||l(_))&&(!c||!e8(u,_.overlapMode))){let t=o[d],i=o[d+1],r=o[d+2];if(s.push({key:_,x1:t-r,y1:i-r,x2:t+r,y2:i+r}),c)return!0}}}return!1}_queryCellCircle(t,i,r,a,o,s,n,l){let{circle:h,seenUids:c,overlapMode:u}=n,d=this.boxCells[o];if(null!==d){let t=this.bboxes;for(let i of d)if(!c.box[i]){c.box[i]=!0;let r=4*i,a=this.boxKeys[i];if(this._circleAndRectCollide(h.x,h.y,h.radius,t[r+0],t[r+1],t[r+2],t[r+3])&&(!l||l(a))&&!e8(u,a.overlapMode))return s.push(!0),!0}}let _=this.circleCells[o];if(null!==_){let t=this.circles;for(let i of _)if(!c.circle[i]){c.circle[i]=!0;let r=3*i,a=this.circleKeys[i];if(this._circlesCollide(t[r],t[r+1],t[r+2],h.x,h.y,h.radius)&&(!l||l(a))&&!e8(u,a.overlapMode))return s.push(!0),!0}}}_forEachCell(t,i,r,a,o,s,n,l){let h=this._convertToXCellCoord(t),c=this._convertToYCellCoord(i),u=this._convertToXCellCoord(r),d=this._convertToYCellCoord(a);for(let _=h;_<=u;_++)for(let h=c;h<=d;h++){let c=this.xCellCount*h+_;if(o.call(this,t,i,r,a,c,s,n,l))return}}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,i,r,a,o,s){let n=a-t,l=o-i,h=r+s;return h*h>n*n+l*l}_circleAndRectCollide(t,i,r,a,o,s,n){let l=(s-a)/2,h=Math.abs(t-(a+l));if(h>l+r)return!1;let c=(n-o)/2,u=Math.abs(i-(o+c));if(u>c+r)return!1;if(h<=l||u<=c)return!0;let d=h-l,_=u-c;return d*d+_*_<=r*r}};let e7=(0,m.vi)();function te(t,i,r){let a=(0,m.vi)();if(!t){var o,s,n,l,h;let{vecSouth:t,vecEast:r}=tt(i),c=f();c[0]=r[0],c[1]=r[1],c[2]=t[0],c[3]=t[1],o=c[0],s=c[1],n=c[2],(h=o*(l=c[3])-n*s)&&(h=1/h,c[0]=l*h,c[1]=-s*h,c[2]=-n*h,c[3]=o*h),a[0]=c[0],a[1]=c[1],a[4]=c[2],a[5]=c[3]}return(0,m.Ai)(a,a,[1/r,1/r,1]),a}function tt(t){let i=Math.cos(t.rollInRadians),r=Math.sin(t.rollInRadians),a=Math.cos(t.pitchInRadians),o=Math.cos(t.bearingInRadians),s=Math.sin(t.bearingInRadians),n=(0,m.Rr)();n[0]=-o*a*r-s*i,n[1]=-s*a*r+o*i;let l=(0,m.zr)(n);l<1e-9?(0,m.Hr)(n):(0,m.Br)(n,n,1/l);let h=(0,m.Rr)();h[0]=o*a*i-s*r,h[1]=s*a*i+o*r;
1let c=(0,m.zr)(h);return c<1e-9?(0,m.Hr)(h):(0,m.Br)(h,h,1/c),{vecEast:h,vecSouth:n}}function ti(t,i,r){return e6(t.getElevation,i,r,t.heightOffset??0,t.heightAnchorGround??!0)}function tr(t,i,r,a){let o;null==a?tf(o=[t,i,0,1],o,r):(o=[t,i,a,1],(0,m.Yr)(o,o,r));let s=o[3];return{point:new m.Li(o[0]/s,o[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}function ta(t,i,r,a,o,s,n,l){let h=s.glyphStartIndex+s.numGlyphs,c=s.lineStartIndex,u=s.lineStartIndex+s.lineLength,d=i.getoffsetX(s.glyphStartIndex),_=i.getoffsetX(h-1),p=t_(t*d,r,a,o,s.segment,c,u,l,n);if(!p)return null;let m=t_(t*_,r,a,o,s.segment,c,u,l,n);return!m||l.projectionCache.anyProjectionOccluded?null:{first:p,last:m}}function to(t,i,r,a){return 1===t&&Math.abs(r.y-i.y)>Math.abs(r.x-i.x)*a?{useVertical:!0}:(2===t?i.y<r.y:i.x>r.x)?{needsFlipping:!0}:null}function ts(t){let{projectionContext:i,pitchedLabelPlaneMatrixInverse:r,symbol:a,fontSize:o,flip:s,keepUpright:n,glyphOffsetArray:l,dynamicLayoutVertexArray:h,aspectRatio:c,rotateToLine:u}=t,d=o/24,_=a.lineOffsetX*d,p=a.lineOffsetY*d,f;if(a.numGlyphs>1){let t=a.glyphStartIndex+a.numGlyphs,o=a.lineStartIndex,h=a.lineStartIndex+a.lineLength,m=ta(d,l,_,p,s,a,u,i);if(!m)return{notEnoughRoom:!0};let g=tc(m.first.point.x,m.first.point.y,i,r),v=tc(m.last.point.x,m.last.point.y,i,r);if(n&&!s){let t=to(a.writingMode,g,v,c);if(t)return t}f=[m.first];for(let r=a.glyphStartIndex+1;r<t-1;r++){let t=t_(d*l.getoffsetX(r),_,p,s,a.segment,o,h,i,u);if(!t)return{notEnoughRoom:!0};f.push(t)}f.push(m.last)}else{if(n&&!s){let t=th(i.tileAnchorPoint.x,i.tileAnchorPoint.y,i).point,o=a.lineStartIndex+a.segment+1,s=new m.Li(i.lineVertexArray.getx(o),i.lineVertexArray.gety(o)),n=th(s.x,s.y,i),l=n.signedDistanceFromCamera>0?n.point:tn(i.tileAnchorPoint,s,t,1,i),h=tc(t.x,t.y,i,r),u=tc(l.x,l.y,i,r),d=to(a.writingMode,h,u,c);if(d)return d}let t=t_(d*l.getoffsetX(a.glyphStartIndex),_,p,s,a.segment,a.lineStartIndex,a.lineStartIndex+a.lineLength,i,u);if(!t||i.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};f=[t]}for(let t of f)(0,m.C)(h,t.point,t.angle);return{}}function tn(t,i,r,a,o){let s=t.add(t.sub(i)._unit()),n=th(s.x,s.y,o).point,l=r.sub(n);return r.add(l._mult(a/l.mag()))}function tl(t,i,r){let a=i.projectionCache;if(a.projections[t])return a.projections[t];let o=new m.Li(i.lineVertexArray.getx(t),i.lineVertexArray.gety(t)),s=th(o.x,o.y,i);if(s.signedDistanceFromCamera>0)return a.projections[t]=s.point,a.anyProjectionOccluded||=s.isOccluded,s.point;let n=t-r.direction,l=0===r.distanceFromAnchor?i.tileAnchorPoint:new m.Li(i.lineVertexArray.getx(n),i.lineVertexArray.gety(n)),h=r.absOffsetX-r.distanceFromAnchor+1;return tn(l,o,r.previousVertex,h,i)}function th(t,i,r){let a=t+r.translation[0],o=i+r.translation[1],s;return r.pitchWithMap?(s=tr(a,o,r.pitchedLabelPlaneMatrix,ti(r,a,o))).isOccluded=!1:((s=r.transform.projectTileCoordinates(a,o,r.unwrappedTileID,ti(r,a,o))).point.x=(.5*s.point.x+.5)*r.width,s.point.y=(-(.5*s.point.y)+.5)*r.height),s}function tc(t,i,r,a){if(r.pitchWithMap){let o=[t,i,0,1];(0,m.Yr)(o,o,a);let s=o[0]/o[3],n=o[1]/o[3];return r.transform.projectTileCoordinates(s,n,r.unwrappedTileID,ti(r,s,n)).point}return{x:t/r.width*2-1,y:1-i/r.height*2}}function tu(t,i,r){return r.transform.projectTileCoordinates(t,i,r.unwrappedTileID,ti(r,t,i))}function td(t,i,r){return t._unit()._perp()._mult(i*r)}function t_(t,i,r,a,o,s,n,l,h){let c=a?t-i:t+i,u=c>0?1:-1,d=0;a&&(u*=-1,d=Math.PI),u<0&&(d+=Math.PI);let _=u>0?s+o:s+o+1,p;l.projectionCache.cachedAnchorPoint?p=l.projectionCache.cachedAnchorPoint:(p=th(l.tileAnchorPoint.x,l.tileAnchorPoint.y,l).point,l.projectionCache.cachedAnchorPoint=p);let f=p,g=p,v,y,x=0,b=0,w=Math.abs(c),T=[],P;for(;x+b<=w;){if((_+=u)<s||_>=n)return null;x+=b,g=f,y=v;let t={absOffsetX:w,direction:u,distanceFromAnchor:x,previousVertex:g};if(f=tl(_,l,t),0===r)T.push(g),P=f.sub(g);else{let i,a=f.sub(g);i=0===a.mag()?td(tl(_+u,l,t).sub(f),r,u):td(a,r,u),y||=g.add(i),v=function(t,i,r,a,o,s,n,l,h){if(l.projectionCache.offsets[t])return l.projectionCache.offsets[t];let c=r.add(i);if(t+h.direction<a||t+h.direction>=o)return l.projectionCache.offsets[t]=c,c;let u=tl(t+h.direction,l,h),d=td(u.sub(r),n,h.direction),_=r.add(d),p=u.add(d);return l.projectionCache.offsets[t]=(0,m.nr)(s,c,_,p)||c,l.projectionCache.offsets[t]}(_,i,f,s,n,y,r,l,t),T.push(y),P=v.sub(y)}b=P.mag()}let M=(w-x)/b,I=P._mult(M)._add(y||g),C=d+Math.atan2(f.y-g.y,f.x-g.x);
1return T.push(I),{point:I,angle:h?C:0,path:T}}let tp=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function tm(t,i){for(let r=0;r<t;r++){let t=i.length;i.resize(t+4),i.float32.set(tp,3*t)}}function tf(t,i,r){let a=i[0],o=i[1];return t[0]=r[0]*a+r[4]*o+r[12],t[1]=r[1]*a+r[5]*o+r[13],t[3]=r[3]*a+r[7]*o+r[15],t}var tg=class{constructor(t,i=new e9(t.width+200,t.height+200,25),r=new e9(t.width+200,t.height+200,25)){this.transform=t,this.grid=i,this.ignoredGrid=r,this.pitchFactor=Math.cos(t.pitch*Math.PI/180)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+100,this.screenBottomBoundary=t.height+100,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(t,i,r,a,o,s,n,l,h,c,u,d,_=0,p=!0){let m=t.anchorPointX+l[0],f=t.anchorPointY+l[1],g=this.projectAndGetPerspectiveRatio(m,f,o,e6(c,m,f,_,p),d),v=r*g.perspectiveRatio,y;if(s||n)y=this._projectCollisionBox(t,v,a,o,s,n,l,g,c,u,d,_,p);else{let i=g.x+(u?u.x*v:0),r=g.y+(u?u.y*v:0);y={allPointsOccluded:!1,box:[i+t.x1*v,r+t.y1*v,i+t.x2*v,r+t.y2*v]}}let[x,b,w,T]=y.box,P=s?y.allPointsOccluded:g.isOccluded,M=P;return M||=g.perspectiveRatio<this.perspectiveRatioCutoff,(M||=!this.isInsideGrid(x,b,w,T))||"always"!==i&&this.grid.hitTest(x,b,w,T,i,h)?{box:[x,b,w,T],placeable:!1,offscreen:!1,occluded:P}:{box:[x,b,w,T],placeable:!0,offscreen:this.isOffscreen(x,b,w,T),occluded:P}}placeCollisionCircles(t,i,r,a,o,s,n,l,h,c,u,d,_,p){let f=[],g=new m.Li(i.anchorX,i.anchorY),v=this.getPerspectiveRatio(g.x,g.y,s,p?.(g.x,g.y)),y=(h?o*this.transform.getPitchedTextCorrection(i.anchorX,i.anchorY,s)/v:o*v)/24,x=i.lineOffsetX*y,b=i.lineOffsetY*y,w={getElevation:p,pitchedLabelPlaneMatrix:n,lineVertexArray:r,pitchWithMap:h,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:g,unwrappedTileID:s,width:this.transform.width,height:this.transform.height,translation:_},T=ta(y,a,x,b,!1,i,!1,w),P=!1,M=!1,I=!0;if(T){let i=.5*u*v+d,r=new m.Li(-100,-100),a=new m.Li(this.screenRightBoundary,this.screenBottomBoundary),o=new e5,s=T.first,n=T.last,_=[];for(let t=s.path.length-1;t>=1;t--)_.push(s.path[t]);for(let t=1;t<n.path.length;t++)_.push(n.path[t]);let p=2.5*i;if(h){let t=this.projectPathToScreenSpace(_,w);_=t.some(t=>t.signedDistanceFromCamera<=0)?[]:t.map(t=>t.point)}let g=[];if(_.length>0){let t=_[0].clone(),i=_[0].clone();for(let r=1;r<_.length;r++)t.x=Math.min(t.x,_[r].x),t.y=Math.min(t.y,_[r].y),i.x=Math.max(i.x,_[r].x),i.y=Math.max(i.y,_[r].y);g=t.x>=r.x&&i.x<=a.x&&t.y>=r.y&&i.y<=a.y?[_]:i.x<r.x||t.x>a.x||i.y<r.y||t.y>a.y?[]:(0,m.O)([_],r.x,r.y,a.x,a.y)}for(let r of g){o.reset(r,.25*i);let a=0;a=o.length<=.5*i?1:Math.ceil(o.paddedLength/p)+1;for(let r=0;r<a;r++){let s=r/Math.max(a-1,1),n=o.lerp(s),h=n.x+100,u=n.y+100;f.push(h,u,i,0);let d=h-i,_=u-i,p=h+i,m=u+i;if(I&&=this.isOffscreen(d,_,p,m),M||=this.isInsideGrid(d,_,p,m),"always"!==t&&this.grid.hitTestCircle(h,u,i,t,c)&&(P=!0,!l))return{circles:[],offscreen:!1,collisionDetected:P}}}}return{circles:!l&&P||!M||v<this.perspectiveRatioCutoff?[]:f,offscreen:I,collisionDetected:P}}projectPathToScreenSpace(t,i){var r;let a;return function(t){let i=0,r=0,a=0,o=0;for(let s=0;s<t.length;s++)t[s].isOccluded?(a=s+1,o=0):++o>r&&(r=o,i=a);return t.slice(i,i+r)}((a=1/((r=i.pitchedLabelPlaneMatrix)[0]*r[5]-r[1]*r[4]),e7[0]=r[5]*a,e7[1]=-r[1]*a,e7[2]=0,e7[3]=0,e7[4]=-r[4]*a,e7[5]=r[0]*a,e7[6]=0,e7[7]=0,e7[8]=0,e7[9]=0,e7[10]=1/r[10],e7[11]=0,e7[12]=0,e7[13]=0,e7[14]=0,e7[15]=1/r[15],t.map(t=>{let r=tr(t.x,t.y,e7,ti(i,t.x,t.y)),a=i.transform.projectTileCoordinates(r.point.x,r.point.y,i.unwrappedTileID,ti(i,r.point.x,r.point.y));return a.point.x=(.5*a.point.x+.5)*i.width,a.point.y=(-(.5*a.point.y)+.5)*i.height,a})))}queryRenderedSymbols(t){if(0===t.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};let i=[],r=new m.pt;for(let a of t){let t=new m.Li(a.x+100,a.y+100);r.extend(t),i.push(t)}let{minX:a,minY:o,maxX:s,maxY:n}=r,l=this.grid.query(a,o,s,n).concat(this.ignoredGrid.query(a,o,s,n)),h={},c={};for(let t of l){let r=t.key;if(void 0===h[r.bucketInstanceId]&&(h[r.bucketInstanceId]={}),h[r.bucketInstanceId][r.featureIndex])continue;let a=[new m.Li(t.x1,t.y1),new m.Li(t.x2,t.y1),new m.Li(t.x2,t.y2),new m.Li(t.x1,t.y2)];(0,m.kt)(i,a)&&(h[r.bucketInstanceId][r.featureIndex]=!0,void 0===c[r.bucketInstanceId]&&(c[r.bucketInstanceId]=[]),c[r.bucketInstanceId].push(r.featureIndex))}return c}insertCollisionBox(t,i,r,a,o,s){(r?this.ignoredGrid:this.grid).insert({bucketInstanceId:a,featureIndex:o,collisionGroupID:s,overlapMode:i}
1,t[0],t[1],t[2],t[3])}insertCollisionCircles(t,i,r,a,o,s){let n=r?this.ignoredGrid:this.grid,l={bucketInstanceId:a,featureIndex:o,collisionGroupID:s,overlapMode:i};for(let i=0;i<t.length;i+=4)n.insertCircle(l,t[i],t[i+1],t[i+2])}projectAndGetPerspectiveRatio(t,i,r,a,o){if(o){let r;null==a?tf(r=[t,i,0,1],r,o):(r=[t,i,a,1],(0,m.Yr)(r,r,o));let s=r[3];return{x:(r[0]/s+1)/2*this.transform.width+100,y:(-r[1]/s+1)/2*this.transform.height+100,perspectiveRatio:.5+.5*(this.transform.cameraToCenterDistance/s),isOccluded:!1,signedDistanceFromCamera:s}}{let o=this.transform.projectTileCoordinates(t,i,r,a);return{x:(o.point.x+1)/2*this.transform.width+100,y:(-o.point.y+1)/2*this.transform.height+100,perspectiveRatio:.5+.5*(this.transform.cameraToCenterDistance/o.signedDistanceFromCamera),isOccluded:o.isOccluded,signedDistanceFromCamera:o.signedDistanceFromCamera}}}getPerspectiveRatio(t,i,r,a){let o=this.transform.projectTileCoordinates(t,i,r,a);return .5+.5*(this.transform.cameraToCenterDistance/o.signedDistanceFromCamera)}isOffscreen(t,i,r,a){return r<100||t>=this.screenRightBoundary||a<100||i>this.screenBottomBoundary}isInsideGrid(t,i,r,a){return r>=0&&t<this.gridRightBoundary&&a>=0&&i<this.gridBottomBoundary}getViewportMatrix(){let t=(0,m.Si)([]);return(0,m.ji)(t,t,[-100,-100,0]),t}_projectCollisionBox(t,i,r,a,o,s,n,l,h,c,u,d=0,_=!0){let p=1,f=0,g=0,v=1,y=t.anchorPointX+n[0],x=t.anchorPointY+n[1];if(s&&!o){let t=this.projectAndGetPerspectiveRatio(y+1,x,a,e6(h,y+1,x,d,_),u),i=t.x-l.x,r=Math.atan((t.y-l.y)/i)+(i<0?Math.PI:0),o=Math.sin(r),s=Math.cos(r);p=s,f=o,g=-o,v=s}else if(!s&&o){let t=tt(this.transform);p=t.vecEast[0],f=t.vecEast[1],g=t.vecSouth[0],v=t.vecSouth[1]}let b=l.x,w=l.y,T=i;if(o&&(b=y,w=x,T=2**-(this.transform.zoom-r.overscaledZ)*this.transform.getPitchedTextCorrection(y,x,a),!c)){let t=l.signedDistanceFromCamera/this.transform.cameraToCenterDistance;T*=(0,m.Bn)(.5+.5*t,0,4)}c&&(b+=p*c.x*T+g*c.y*T,w+=f*c.x*T+v*c.y*T);let P=t.x1*T,M=t.x2*T,I=(P+M)/2,C=t.y1*T,S=t.y2*T,E=(C+S)/2,z=[];for(let{offsetX:t,offsetY:i}of[{offsetX:P,offsetY:C},{offsetX:I,offsetY:C},{offsetX:M,offsetY:C},{offsetX:M,offsetY:E},{offsetX:M,offsetY:S},{offsetX:I,offsetY:S},{offsetX:P,offsetY:S},{offsetX:P,offsetY:E}])z.push(new m.Li(b+p*t+g*i,w+f*t+v*i));let R=!1;if(o){let t=z.map(t=>this.projectAndGetPerspectiveRatio(t.x,t.y,a,e6(h,t.x,t.y,d,_),u));R=t.some(t=>!t.isOccluded),z=t.map(t=>new m.Li(t.x,t.y))}else R=!0;return{box:(0,m.rr)(z),allPointsOccluded:!R}}},tv=class{constructor(t,i,r,a){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?i:-i))):a&&r?1:0,this.placed=r}isHidden(){return 0===this.opacity&&!this.placed}},ty=class{constructor(t,i,r,a,o){this.text=new tv(t?t.text:null,i,r,o),this.icon=new tv(t?t.icon:null,i,a,o)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}},tx=class{constructor(t,i,r){this.text=t,this.icon=i,this.skipFade=r}},tb=class{constructor(t,i,r,a,o){this.bucketInstanceId=t,this.featureIndex=i,this.sourceLayerIndex=r,this.bucketIndex=a,this.tileID=o}},tw=class{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){let i=++this.maxGroupID;this.collisionGroups[t]={ID:i,predicate:t=>t.collisionGroupID===i}}return this.collisionGroups[t]}};function tT(t,i,r,a,o){let{horizontalAlign:s,verticalAlign:n}=(0,m.M)(t);return new m.Li(-(s-.5)*i+a[0]*o,-(n-.5)*r+a[1]*o)}var tP=class{constructor(t,i,r,a,o){this.transform=t.clone(),this.terrain=i,this.collisionIndex=new tg(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=r,this.retainedQueryData={},this.collisionGroups=new tw(a),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(t){let i=this.terrain;if(i)return(r,a)=>i.getElevation(t,r,a)}getBucketParts(t,i,r,a){let o=r.getBucket(i),s=r.latestFeatureIndex;if(!o||!s||i.id!==o.layerIds[0])return;let n=r.collisionBoxArray,l=o.layers[0].layout,h=o.layers[0].paint,c=2**(this.transform.zoom-r.tileID.overscaledZ
1),u=r.tileSize/m.Lr,d=r.tileID.toUnwrapped(),_="map"===l.get("text-rotation-alignment"),p=(0,m.Ir)(r,1,this.transform.zoom),f=(0,m.jr)(this.collisionIndex.transform,r,h.get("text-translate"),h.get("text-translate-anchor")),g=(0,m.jr)(this.collisionIndex.transform,r,h.get("icon-translate"),h.get("icon-translate-anchor")),v=te(_,this.transform,p);this.retainedQueryData[o.bucketInstanceId]=new tb(o.bucketInstanceId,s,o.sourceLayerIndex,o.index,r.tileID);let y={bucket:o,layout:l,translationText:f,translationIcon:g,unwrappedTileID:d,pitchedLabelPlaneMatrix:v,scale:c,textPixelRatio:u,holdingForFade:r.holdingForSymbolFade(),collisionBoxArray:n,partiallyEvaluatedTextSize:(0,m.A)(o.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(a)for(let i of o.sortKeyRanges){let{sortKey:r,symbolInstanceStart:a,symbolInstanceEnd:o}=i;t.push({sortKey:r,symbolInstanceStart:a,symbolInstanceEnd:o,parameters:y})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:y})}attemptAnchorPlacement(t,i,r,a,o,s,n,l,h,c,u,d,_,p,f,g,v,y,x,b,w,T){let P=m.E[t.textAnchor],M=[t.textOffset0,t.textOffset1],I=tT(P,r,a,M,o),C=this.collisionIndex.placeCollisionBox(i,d,l,h,c,n,s,g,u.predicate,x,I,b,w,T);if((!y||this.collisionIndex.placeCollisionBox(y,d,l,h,c,n,s,v,u.predicate,x,I,b,w,T).placeable)&&C.placeable){let t;if(this.prevPlacement?.variableOffsets[_.crossTileID]&&this.prevPlacement?.placements[_.crossTileID]?.text&&(t=this.prevPlacement.variableOffsets[_.crossTileID].anchor),0===_.crossTileID)throw Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[_.crossTileID]={textOffset:M,width:r,height:a,anchor:P,textBoxScale:o,prevAnchor:t},this.markUsedJustification(p,P,_,f),p.allowVerticalPlacement&&(this.markUsedOrientation(p,f,_),this.placedOrientations[_.crossTileID]=f),{shift:I,placedGlyphBoxes:C}}}placeLayerBucketPart(t,i,r){let{bucket:a,layout:o,translationText:s,translationIcon:n,unwrappedTileID:l,pitchedLabelPlaneMatrix:h,textPixelRatio:c,holdingForFade:u,collisionBoxArray:d,partiallyEvaluatedTextSize:_,collisionGroup:p}=t.parameters,f=o.get("text-optional"),g=o.get("icon-optional"),v=(0,m.w)(o,"text-overlap","text-allow-overlap"),y="always"===v,x=(0,m.w)(o,"icon-overlap","icon-allow-overlap"),b="always"===x,w="map"===o.get("text-rotation-alignment"),T="map"===o.get("text-pitch-alignment"),P="none"!==o.get("icon-text-fit"),M="viewport-y"===o.get("symbol-z-order"),I="ground"===o.get("symbol-height-anchor"),C=y&&(b||!a.hasIconData()||g),S=b&&(y||!a.hasTextData()||f);!a.collisionArrays&&d&&a.deserializeCollisionBoxes(d);let E=this.retainedQueryData[a.bucketInstanceId].tileID,z=this._getTerrainElevationFunc(E),R=this.transform.getFastPathSimpleProjectionMatrix(E),D=(t,d,b)=>{if(i[t.crossTileID])return;if(u){this.placements[t.crossTileID]=new tx(!1,!1,!1);return}let M=t.heightOffset,D=!1,L=!1,A=!0,F=null,k={box:null,placeable:!1,offscreen:null,occluded:!1},B={box:null,placeable:!1,offscreen:null},O=null,j=null,N=null,Z=0,U=0,G=0;d.textFeatureIndex?Z=d.textFeatureIndex:t.useRuntimeCollisionCircles&&(Z=t.featureIndex),d.verticalTextFeatureIndex&&(U=d.verticalTextFeatureIndex);let V=d.textBox;if(V){let i=i=>{let r=1;if(a.allowVerticalPlacement&&!i&&this.prevPlacement){let i=this.prevPlacement.placedOrientations[t.crossTileID];i&&(this.placedOrientations[t.crossTileID]=i,r=i,this.markUsedOrientation(a,r,t))}return r},o=(i,r)=>{if(a.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&d.verticalTextBox){for(let t of a.writingModes)if(2===t?B=k=r():k=i(),k?.placeable)break}else k=i()},h=t.textAnchorOffsetStartIndex,u=t.textAnchorOffsetEndIndex;if(u===h){let r=(i,r)=>{let o=this.collisionIndex.placeCollisionBox(i,v,c,E,l,T,w,s,p.predicate,z,void 0,R,M,I);return o?.placeable&&(this.markUsedOrientation(a,r,t),this.placedOrientations[t.crossTileID]=r),o};o(()=>r(V,1),()=>{let i=d.verticalTextBox;return a.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&i?r(i,2):{box:null,offscreen:null}}),i(k?.placeable)}else{let _=m.E[this.prevPlacement?.variableOffsets[t.crossTileID]?.anchor],f=(i,o,d)=>{let m=i.x2-i.x1,f=i.y2-i.y1,g=t.textBoxScale,y=P&&"never"===x?o:null,b=null,C="never"===v?1:2,S="never";_&&C++;for(let r=0;r<C;r++){for(let r=h;r<u;r++){let o=a.textAnchorOffsets.get(r);if(_&&o.textAnchor!==_)continue;let h=this.attemptAnchorPlacement(o,i,m,f,g,w,T,c,E,l,p,S,t,a,d,s,n,y,z,R,M,I);if(h&&(b=h.placedGlyphBoxes,b?.placeable))return D=!0,F=h.shift,b}_?_=null:S=v}return r&&!b&&(b={box:this.collisionIndex.placeCollisionBox(V,"always",c,E,l,T,w,s,p.predicate,z,void 0,R,M,I).box,offscreen:!1,placeable:!1,occluded:!1}),b};o(()=>f(V,d.iconBox,1),()=>{let i=d.verticalTextBox,r=k?.placeable;return a.allowVerticalPlacement&&!r&&t.numVerticalGlyphVertices>0&&i?f(i,d.verticalIconBox,2):{box:null,occluded:!0,offscreen:null}}),k&&(D=k.placeable,A=k.offscreen);let g=i(k?.placeable);if(!D&&this.prevPlacement){let i=this.prevPlacement.variableOffsets[t.crossTileID];i&&(this.variableOffsets[t.crossTileID]=i,this.markUsedJustification(a,i.anchor,t,g))}}}if(O=k,D=O?.placeable,A=O?.offscreen,t.useRuntimeCollisionCircles&&t.centerJustifiedTextSymbolIndex>=0){let i=a.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex),n=(0,m.k)(a.textSizeData,_,i),c=o.get("text-padding"),u=t.collisionCircleDiameter;(j=this.collisionIndex.placeCollisionCircles(v,i,a.lineVertexArray,a.glyphOffsetArray,n,l,h,r,T,p.predicate,u,c,s,z)).circles.length&&j.collisionDetected&&!r&&(0,m.Nr)("Collisions detected, but collision boxes are not shown"),D=y||j.circles.length>0&&!j.collisionDetected,A&&=j.offscreen}if(d.iconFeatureIndex&&(G=d.iconFeatureIndex),d.iconBox){let t=t=>this.collisionIndex.placeCollisionBox(t,x,c,E,l,T,w,n,p.predicate,z,P&&F?F:void 0,R,M,I);L=B&&B.placeable&&d.verticalIconBox?(N=t(d.verticalIconBox)).placeable:(N=t(d.iconBox)).placeable,A&&=N.offscreen}let q=f||0===t.numHorizontalGlyphVertices&&0===t.numVerticalGlyphVertices,W=g||0===t.numIconVertices;q||W?W?q||(L&&=D):D=L&&D:L=D=L&&D;let $=D&&O.placeable,H=L&&N.placeable;if($&&(B&&B.placeable&&U?this.collisionIndex.insertCollisionBox(O.box,v,o.get("text-ignore-placement"),a.bucketInstanceId,U,p.ID):this.collisionIndex.insertCollisionBox(O.box,v,o.get("text-ignore-placement"),a.bucketInstanceId,Z,p.ID)),H&&this.collisionIndex.insertCollisionBox(N.box,x,o.get("icon-ignore-placement"),a.bucketInstanceId,G,p.ID),j&&D&&this.collisionIndex.insertCollisionCircles(j.circles,v,o.get("text-ignore-placement"),a.bucketInstanceId,Z,p.ID),r&&this.storeCollisionData(a.bucketInstanceId,b,d,O,N,j),0===t.crossTileID)throw Error("symbolInstance.crossTileID can't be 0");if(0===a.bucketInstanceId)throw Error("bucket.bucketInstanceId can't be 0");let X=(D||C)&&!O?.occluded,Y=(L||S)&&!N?.occluded;this.placements[t.crossTileID]=new tx(X,Y,A||a.justReloaded),i[t.crossTileID]=!0};if(M){if(0!==t.symbolInstanceStart)throw Error("bucket.bucketInstanceId should be 0");
1let i=a.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let t=i.length-1;t>=0;--t){let r=i[t];D(a.symbolInstances.get(r),a.collisionArrays[r],r)}}else for(let i=t.symbolInstanceStart;i<t.symbolInstanceEnd;i++)D(a.symbolInstances.get(i),a.collisionArrays[i],i);a.justReloaded=!1}storeCollisionData(t,i,r,a,o,s){if(r.textBox||r.iconBox){let s,n;this.collisionBoxArrays.has(t)?s=this.collisionBoxArrays.get(t):(s=new Map,this.collisionBoxArrays.set(t,s)),s.has(i)?n=s.get(i):(n={text:null,icon:null},s.set(i,n)),r.textBox&&(n.text=a.box),r.iconBox&&(n.icon=o.box)}if(s){let i=this.collisionCircleArrays[t];void 0===i&&(i=this.collisionCircleArrays[t]=[]);for(let t=0;t<s.circles.length;t+=4)i.push(s.circles[t+0]-100),i.push(s.circles[t+1]-100),i.push(s.circles[t+2]),i.push(+!!s.collisionDetected)}}markUsedJustification(t,i,r,a){let o={left:r.leftJustifiedTextSymbolIndex,center:r.centerJustifiedTextSymbolIndex,right:r.rightJustifiedTextSymbolIndex},s;for(let n of(s=2===a?r.verticalPlacedTextSymbolIndex:o[(0,m.T)(i)],[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex,r.verticalPlacedTextSymbolIndex]))n>=0&&(s>=0&&n!==s?t.text.placedSymbolArray.get(n).crossTileID=0:t.text.placedSymbolArray.get(n).crossTileID=r.crossTileID)}markUsedOrientation(t,i,r){let a=1===i||3===i?i:0;for(let i of[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex])t.text.placedSymbolArray.get(i).placedOrientation=a;r.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=2===i?i:0)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;let i=this.prevPlacement,r=!1;this.prevZoomAdjustment=i?i.zoomAdjustment(this.transform.zoom):0;let a=i?i.symbolFadeChange(t):1,o=i?i.opacities:{},s=i?i.variableOffsets:{},n=i?i.placedOrientations:{};for(let t in this.placements){let i=this.placements[t],s=o[t];s?(this.opacities[t]=new ty(s,a,i.text,i.icon),r||=i.text!==s.text.placed,r||=i.icon!==s.icon.placed):(this.opacities[t]=new ty(null,a,i.text,i.icon,i.skipFade),r||=i.text||i.icon)}for(let t in o){let i=o[t];if(!this.opacities[t]){let o=new ty(i,a,!1,!1);o.isHidden()||(this.opacities[t]=o,r||=i.text.placed,r||=i.icon.placed)}}for(let t in s)this.variableOffsets[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.variableOffsets[t]=s[t]);for(let t in n)this.placedOrientations[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.placedOrientations[t]=n[t]);if(i&&void 0===i.lastPlacementChangeTime)throw Error("Last placement time for previous placement is not defined");r?this.lastPlacementChangeTime=t:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=i?i.lastPlacementChangeTime:t)}updateLayerOpacities(t,i){let r={};for(let a of i){let i=a.getBucket(t);i&&a.latestFeatureIndex&&t.id===i.layerIds[0]&&this.updateBucketOpacities(i,a.tileID,r,a.collisionBoxArray)}}updateBucketOpacities(t,i,r,a){t.hasTextData()&&(t.text.opacityVertexArray.clear(),t.text.hasVisibleVertices=!1),t.hasIconData()&&(t.icon.opacityVertexArray.clear(),t.icon.hasVisibleVertices=!1),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();let o=t.layers[0],s=o.layout,n=new ty(null,0,!1,!1,!0),l=s.get("text-allow-overlap"),h=s.get("icon-allow-overlap"),c=o._unevaluatedLayout.hasValue("text-variable-anchor")||o._unevaluatedLayout.hasValue("text-variable-anchor-offset"),u="map"===s.get("text-rotation-alignment"),d="map"===s.get("text-pitch-alignment"),_="none"!==s.get("icon-text-fit"),p=new ty(null,0,l&&(h||!t.hasIconData()||s.get("icon-optional")),h&&(l||!t.hasTextData()||s.get("text-optional")),!0);!t.collisionArrays&&a&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(a);let f=(t,i,r)=>{for(let a=0;a<i/4;a++)t.opacityVertexArray.emplaceBack(r);t.hasVisibleVertices||=r!==tC},g=this.collisionBoxArrays.get(t.bucketInstanceId);for(let i=0;i<t.symbolInstances.length;i++){let a=t.symbolInstances.get(i),{numHorizontalGlyphVertices:o,numVerticalGlyphVertices:s,crossTileID:l}=a,h=r[l],v=this.opacities[l];h?v=n:v||(v=p,this.opacities[l]=v),r[l]=!0;let y=o>0||s>0,x=a.numIconVertices>0,b=this.placedOrientations[a.crossTileID],w=2===b,T=1===b||3===b;if(y){let i=tI(v.text),r=w?tC:i;f(t.text,o,r);let n=T?tC:i;f(t.text,s,n);let l=v.text.isHidden();for(let i of[a.rightJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.leftJustifiedTextSymbolIndex])i>=0&&(t.text.placedSymbolArray.get(i).hidden=l||w?1:0);a.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(a.verticalPlacedTextSymbolIndex).hidden=l||T?1:0);let h=this.variableOffsets[a.crossTileID];h&&this.markUsedJustification(t,h.anchor,a,b);let c=this.placedOrientations[a.crossTileID];c&&(this.markUsedJustification(t,"left",a,c),this.markUsedOrientation(t,c,a))}if(x){let i=tI(v.icon),r=!(_&&a.verticalPlacedIconSymbolIndex&&w);if(a.placedIconSymbolIndex>=0){let o=r?i:tC;f(t.icon,a.numIconVertices,o),t.icon.placedSymbolArray.get(a.placedIconSymbolIndex).hidden=v.icon.isHidden()}
vendor: 13,851 bytes, lines 1-25
1if(a.verticalPlacedIconSymbolIndex>=0){let o=r?tC:i;f(t.icon,a.numVerticalIconVertices,o),t.icon.placedSymbolArray.get(a.verticalPlacedIconSymbolIndex).hidden=v.icon.isHidden()}}let P=g?.has(i)?g.get(i):{text:null,icon:null};if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){let r=t.collisionArrays[i];if(r){let i=new m.Li(0,0);if(r.textBox||r.verticalTextBox){let a=!0;if(c){let t=this.variableOffsets[l];t?(i=tT(t.anchor,t.width,t.height,t.textOffset,t.textBoxScale),u&&i._rotate(d?-this.transform.bearingInRadians:this.transform.bearingInRadians)):a=!1}if(r.textBox||r.verticalTextBox){let o;r.textBox&&(o=w),r.verticalTextBox&&(o=T),tM(t.textCollisionBox.collisionVertexArray,v.text.placed,!a||o,P.text,i.x,i.y)}}if(r.iconBox||r.verticalIconBox){let a=!(T||!r.verticalIconBox),o;r.iconBox&&(o=a),r.verticalIconBox&&(o=!a),tM(t.iconCollisionBox.collisionVertexArray,v.icon.placed,o,P.icon,_?i.x:0,_?i.y:0)}}}}if(t.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.text.opacityVertexArray.length!==t.text.layoutVertexArray.length/4)throw Error(`bucket.text.opacityVertexArray.length (= ${t.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${t.text.layoutVertexArray.length}) / 4`);if(t.icon.opacityVertexArray.length!==t.icon.layoutVertexArray.length/4)throw Error(`bucket.icon.opacityVertexArray.length (= ${t.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${t.icon.layoutVertexArray.length}) / 4`);t.bucketInstanceId in this.collisionCircleArrays&&(t.collisionCircleArray=this.collisionCircleArrays[t.bucketInstanceId],delete this.collisionCircleArrays[t.bucketInstanceId])}symbolFadeChange(t){return 0===this.fadeDuration?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(t,i){let r=this.zoomAtLastRecencyCheck===i?1-this.zoomAdjustment(i):1;return this.zoomAtLastRecencyCheck=i,this.commitTime+this.fadeDuration*r>t}setStale(){this.stale=!0}};function tM(t,i,r,a,o,s){a&&0!==a.length||(a=[0,0,0,0]);let n=a[0]-100,l=a[1]-100,h=a[2]-100,c=a[3]-100;t.emplaceBack(+!!i,+!!r,o||0,s||0,n,l),t.emplaceBack(+!!i,+!!r,o||0,s||0,h,l),t.emplaceBack(+!!i,+!!r,o||0,s||0,h,c),t.emplaceBack(+!!i,+!!r,o||0,s||0,n,c)}function tI(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 0xffffffff;let i=+!!t.placed,r=Math.floor(127*t.opacity);return 0x2000000*r+0x1000000*i+131072*r+65536*i+512*r+256*i+2*r+i}let tC=0;var tS=class{constructor(t){this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,i,r,a,o){let s=this._bucketParts;for(;this._currentTileIndex<t.length;){let r=t[this._currentTileIndex];if(i.getBucketParts(s,a,r,this._sortAcrossTiles),this._currentTileIndex++,o())return!0}for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,s.sort((t,i)=>t.sortKey-i.sortKey));this._currentPartIndex<s.length;){let t=s[this._currentPartIndex];if(i.placeLayerBucketPart(t,this._seenCrossTileIDs,r),this._currentPartIndex++,o())return!0}return!1}},tE=class{constructor(t,i,r,a,o,s,n,l){this.placement=new tP(t,i,s,n,l),this._currentPlacementIndex=r.length-1,this._forceFullPlacement=a,this._showCollisionBoxes=o,this._done=!1}isDone(){return this._done}continuePlacement(t,i,r){let a=y(),o=()=>!this._forceFullPlacement&&y()-a>2;for(;this._currentPlacementIndex>=0;){let a=i[t[this._currentPlacementIndex]],s=this.placement.collisionIndex.transform.zoom;if((0,m.x)(a)&&a.layout&&(!a.minzoom||a.minzoom<=s)&&(!a.maxzoom||a.maxzoom>s)){if(this._inProgressLayer||=new tS(a),this._inProgressLayer.continuePlacement(r[a.source],this.placement,this._showCollisionBoxes,a,o))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}};let tz=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],tR=new Uint32Array(96);var tD=class t{static from(i){if(!i||void 0===i.byteLength||i.buffer)throw Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");let[r,a]=new Uint8Array(i,0,2);if(219!==r)throw Error("Data does not appear to be in a KDBush format.");let o=a>>4;if(1!==o)throw Error(`Got v${o} data when expected v1.`);let s=tz[15&a];if(!s)throw Error("Unrecognized array type.");let[n]=new Uint16Array(i,2,1),[l]=new Uint32Array(i,4,1);return new t(l,n,s,void 0,i)}constructor(t,i=64,r=Float64Array,a=ArrayBuffer,o){if(isNaN(t)||t<0)throw Error(`Unexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+i,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;let s=tz.indexOf(this.ArrayType),n=2*t*this.ArrayType.BYTES_PER_ELEMENT,l=t*this.IndexArrayType.BYTES_PER_ELEMENT,h=(8-l%8)%8;if(s<0)throw Error(`Unexpected typed array class: ${r}.`);if(o)this.data=o,this.ids=new this.IndexArrayType(o,8,t),this.coords=new r(o,8+l+h,2*t),this._pos=2*t,this._finished=!0;else{let o=this.data=new a(8+n+l+h);this.ids=new this.IndexArrayType(o,8,t),this.coords=new r(o,8+l+h,2*t),this._pos=0,this._finished=!1,new Uint8Array(o,0,2).set([219,16+s]),new Uint16Array(o,2,1)[0]=i,new Uint32Array(o,4,1)[0]=t}}add(t,i){let r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=i,r}finish(){let t=this._pos>>1;if(t!==this.numItems)throw Error(`Added ${t} items when expected ${this.numItems}.`);return function t(i,r,a,o,s,n){if(s-o<=a)return;let l=o+s>>1;(function t(i,r,a,o,s,n){for(;s>o;){if(s-o>600){let l=s-o+1,h=a-o+1,c=Math.log(l),u=.5*Math.exp(2*c/3),d=.5*Math.sqrt(c*u*(l-u)/l)*(h-l/2<0?-1:1);t(i,r,a,Math.max(o,Math.floor(a-h*u/l+d)),Math.min(s,Math.floor(a+(l-h)*u/l+d)),n)}let l=r[2*a+n],h=o,c=s;for(tL(i,r,o,a),r[2*s+n]>l&&tL(i,r,o,s);h<c;){for(tL(i,r,h,c),h++,c--;r[2*h+n]<l;)h++;for(;r[2*c+n]>l;)c--}r[2*o+n]===l?tL(i,r,o,c):tL(i,r,++c,s),c<=a&&(o=c+1),a<=c&&(s=c-1)}})(i,r,l,o,s,n),t(i,r,a,o,l-1,1-n),t(i,r,a,l+1,s,1-n)}(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,i,r,a){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:o,coords:s,nodeSize:n}=this;tR[0]=0,tR[1]=o.length-1,tR[2]=0;let l=3,h=[];for(;l>0;){let c=tR[--l],u=tR[--l],d=tR[--l];if(u-d<=n){for(let n=d;n<=u;n++){let l=s[2*n],c=s[2*n+1];l>=t&&l<=r&&c>=i&&c<=a&&h.push(o[n])}continue}let _=d+u>>1,p=s[2*_],m=s[2*_+1];p>=t&&p<=r&&m>=i&&m<=a&&h.push(o[_]),(0===c?t<=p:i<=m)&&(tR[l++]=d,tR[l++]=_-1,tR[l++]=1-c),(0===c?r>=p:a>=m)&&(tR[l++]=_+1,tR[l++]=u,tR[l++]=1-c)}return h}within(t,i,r){let a=[];return this.withinInto(t,i,r,a),a}withinInto(t,i,r,a){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:o,coords:s,nodeSize:n}=this;tR[0]=0,tR[1]=o.length-1,tR[2]=0;let l=3,h=0,c=r*r;for(;l>0;){let u=tR[--l],d=tR[--l],_=tR[--l];if(d-_<=n){for(let r=_;r<=d;r++)tF(s[2*r],s[2*r+1],t,i)<=c&&(a[h++]=o[r]);continue}let p=_+d>>1,m=s[2*p],f=s[2*p+1];tF(m,f,t,i)<=c&&(a[h++]=o[p]),(0===u?t-r<=m:i-r<=f)&&(tR[l++]=_,tR[l++]=p-1,tR[l++]=1-u),(0===u?t+r>=m:i+r>=f)&&(tR[l++]=p+1,tR[l++]=d,tR[l++]=1-u)}return h}};function tL(t,i,r,a){tA(t,r,a),tA(i,2*r,2*a),tA(i,2*r+1,2*a+1)}function tA(t,i,r){let a=t[i];t[i]=t[r],t[r]=a}function tF(t,i,r,a){let o=t-r,s=i-a;return o*o+s*s}let tk=512/m.Lr/2;var tB=class{constructor(t,i,r){this.tileID=t,this.bucketInstanceId=r,this._symbolsByKey={};let a=new Map;for(let t=0;t<i.length;t++){let r=i.get(t),o=r.key,s=a.get(o);s?s.push(r):a.set(o,[r])}for(let[t,i]of a){let r={positions:i.map(t=>({x:Math.floor(t.anchorX*tk),y:Math.floor(t.anchorY*tk)})),crossTileIDs:i.map(t=>t.crossTileID)};if(r.positions.length>128){let t=new tD(r.positions.length,16,Uint16Array);for(let{x:i,y:a}of r.positions)t.add(i,a);t.finish(),delete r.positions,r.index=t}this._symbolsByKey[t]=r}}getScaledCoordinates(t,i){let{x:r,y:a,z:o}=this.tileID.canonical,{x:s,y:n,z:l}=i.canonical,h=tk/2**(l-o),c=(s*m.Lr+t.anchorX)*h,u=(n*m.Lr+t.anchorY)*h;return{x:Math.floor(c-r*m.Lr*tk),y:Math.floor(u-a*m.Lr*tk)}}findMatches(t,i,r){let a=this.tileID.canonical.z<i.canonical.z?1:2**(this.tileID.canonical.z-i.canonical.z);for(let o=0;o<t.length;o++){let s=t.get(o);if(s.crossTileID)continue;let n=this._symbolsByKey[s.key];if(!n)continue;let l=this.getScaledCoordinates(s,i);n.index?this.findMatchesForIndexedEntry(n,s,l,a,r):n.positions&&this.findMatchesForNonIndexedEntry(n,s,l,a,r)}}findMatchesForIndexedEntry(t,i,r,a,o){let s=t.index.range(r.x-a,r.y-a,r.x+a,r.y+a),n=1/0;for(let i of s)i<n&&!o[t.crossTileIDs[i]]&&(n=i);if(n!==1/0){let r=t.crossTileIDs[n];o[r]=!0,i.crossTileID=r}}findMatchesForNonIndexedEntry(t,i,r,a,o){for(let s=0;s<t.positions.length;s++){let n=t.positions[s],l=t.crossTileIDs[s];if(Math.abs(n.x-r.x)<=a&&Math.abs(n.y-r.y)<=a&&!o[l]){o[l]=!0,i.crossTileID=l;break}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map(({crossTileIDs:t})=>t)}},tO=class{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}},tj=class{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){let i=Math.round((t-this.lng)/360);if(0!==i)for(let t in this.indexes){let r=this.indexes[t],a={};for(let t in r){let o=r[t];o.tileID=o.tileID.unwrapTo(o.tileID.wrap+i),a[o.tileID.key]=o}this.indexes[t]=a}this.lng=t}addBucket(t,i,r){if(this.indexes[t.overscaledZ]?.[t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===i.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let t=0;t<i.symbolInstances.length;t++)i.symbolInstances.get(t).crossTileID=0;this.usedCrossTileIDs[t.overscaledZ]||={};let a=this.usedCrossTileIDs[t.overscaledZ];for(let r in this.indexes){let o=this.indexes[r];if(Number(r)>t.overscaledZ)for(let r in o){let s=o[r];s.tileID.isChildOf(t)&&s.findMatches(i.symbolInstances,t,a)}else{let s=o[t.scaledTo(Number(r)).key];s&&s.findMatches(i.symbolInstances,t,a)}}for(let t=0;t<i.symbolInstances.length;t++){let o=i.symbolInstances.get(t);o.crossTileID||(o.crossTileID=r.generate(),a[o.crossTileID]=!0)}return void 0===this.indexes[t.overscaledZ]&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new tB(t,i.symbolInstances,i.bucketInstanceId),!0}removeBucketCrossTileIDs(t,i){for(let r of i.getCrossTileIDsLists())for(let i of r)delete this.usedCrossTileIDs[t][i]}removeStaleBuckets(t){let i=!1;for(let r in this.indexes){let a=this.indexes[r];for(let o in a)t[a[o].bucketInstanceId]||(this.removeBucketCrossTileIDs(r,a[o]),delete a[o],i=!0)}return i}},tN=class{constructor(){this.layerIndexes={},this.crossTileIDs=new tO,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,i,r){let a=this.layerIndexes[t.id];void 0===a&&(a=this.layerIndexes[t.id]=new tj);let o=!1,s={};for(let n of(a.handleWrapJump(r),i)){let i=n.getBucket(t);t.id===i?.layerIds[0]&&(i.bucketInstanceId||=(this.maxBucketInstanceId+=1,this.maxBucketInstanceId),a.addBucket(n.tileID,i,this.crossTileIDs)&&(o=!0),s[i.bucketInstanceId]=!0)}return a.removeStaleBuckets(s)&&(o=!0),o}pruneUnusedLayers(t){let i={};for(let r of t)i[r]=!0;for(let t in this.layerIndexes)i[t]||delete this.layerIndexes[t]}},tZ=`uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;
2#ifdef OVERDRAW_INSPECTOR
3fragColor=vec4(1.0);
4#endif
5}`,tU=`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;in vec2 v_pos_a;in 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=texture(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=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;
6#ifdef OVERDRAW_INSPECTOR
7fragColor=vec4(1.0);
8#endif
9}`,tG=`in vec3 v_data;flat in float v_visibility;
10#pragma maplibre: define highp vec4 color
11#pragma maplibre: define mediump float radius
12#pragma maplibre: define lowp float blur
13#pragma maplibre: define lowp float opacity
14#pragma maplibre: define highp vec4 stroke_color
15#pragma maplibre: define mediump float stroke_width
16#pragma maplibre: define lowp float stroke_opacity
17void main() {
18#pragma maplibre: initialize highp vec4 color
19#pragma maplibre: initialize mediump float radius
20#pragma maplibre: initialize lowp float blur
21#pragma maplibre: initialize lowp float opacity
22#pragma maplibre: initialize highp vec4 stroke_color
23#pragma maplibre: initialize mediump float stroke_width
24#pragma maplibre: initialize lowp float stroke_opacity
25vec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;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
25/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}
26#ifdef OVERDRAW_INSPECTOR
27fragColor=vec4(1.0);
28#endif
29}`,tV=`uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform vec2 u_translate;layout(location=0) in ivec2 a_pos;out vec3 v_data;flat out float v_visibility;
30#pragma maplibre: define highp vec4 color
31#pragma maplibre: define mediump float radius
32#pragma maplibre: define lowp float blur
33#pragma maplibre: define lowp float opacity
34#pragma maplibre: define highp vec4 stroke_color
35#pragma maplibre: define mediump float stroke_width
36#pragma maplibre: define lowp float stroke_opacity
37void main(void) {
38#pragma maplibre: initialize highp vec4 color
39#pragma maplibre: initialize mediump float radius
40#pragma maplibre: initialize lowp float blur
41#pragma maplibre: initialize lowp float opacity
42#pragma maplibre: initialize highp vec4 stroke_color
43#pragma maplibre: initialize mediump float stroke_width
44#pragma maplibre: initialize lowp float stroke_opacity
45ivec2 pos_raw=a_pos+32768;vec2 extrude=vec2(pos_raw & 7)/7.0*2.0-1.0;vec2 circle_center=vec2(pos_raw >> 3)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {
46#ifdef GLOBE
47vec3 center_vector=projectToSphere(circle_center);
48#endif
49float angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {
50#ifdef GLOBE
51vec4 projected_center=interpolateProjection(circle_center,center_vector,ele);
52#else
53vec4 projected_center=projectTileWithElevation(circle_center,ele);
54#endif
55corner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}
56#ifdef GLOBE
57vec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);
58#else
59gl_Position=projectTileWithElevation(corner_position,ele);
60#endif
61} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}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;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}`,tq="void main() {fragColor=vec4(1.0);}";let tW={prelude:t$(`#ifdef GL_ES
62precision mediump float;
63#else
64#if !defined(lowp)
65#define lowp
66#endif
67#if !defined(mediump)
68#define mediump
69#endif
70#if !defined(highp)
71#define highp
72#endif
73#endif
74out highp vec4 fragColor;layout(std140) uniform ProjectionUBO {highp mat4 u_projection_matrix;highp mat4 u_projection_fallback_matrix;highp vec4 u_projection_tile_mercator_coords;highp vec4 u_projection_clipping_plane;highp float u_projection_transition;highp int u_projection_clip_antimeridian;};layout(std140) uniform FrameUBO {highp vec2 u_units_to_pixels;highp vec2 u_world_size;highp float u_camera_to_center_distance;highp float u_symbol_fade_change;highp float u_aspect_ratio;highp float u_device_pixel_ratio;highp vec2 u_viewport_size;highp vec2 u_pixel_extrude_scale;highp float u_pitch;};`,`#ifdef GL_ES
75precision highp float;
76#else
77#if !defined(lowp)
78#define lowp
79#endif
80#if !defined(mediump)
81#define mediump
82#endif
83#if !defined(highp)
84#define highp
85#endif
86#endif
87vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const uint packedOpacity) {return vec2(float(packedOpacity >> 1u)/127.0,float(packedOpacity & 1u));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0
88);}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);
88return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+      c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+    c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+    c
89);}
90#ifdef TERRAIN3D
91uniform sampler2D u_terrain;uniform highp sampler2D u_depth;layout(std140) uniform TerrainUBO {highp mat4 u_terrain_matrix;highp vec4 u_terrain_unpack;highp float u_terrain_dim;highp float u_terrain_exaggeration;};
92#endif
93const 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) {
94#ifdef TERRAIN3D
95highp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));
96#else
97return 1.0;
98#endif
99}float calculate_visibility(vec4 pos) {
100#ifdef TERRAIN3D
101vec3 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;
102#else
103return 1.0;
104#endif
105}float ele(ivec2 pos) {
106#ifdef TERRAIN3D
107vec4 rgb=(texelFetch(u_terrain,pos,0)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;
108#else
109return 0.0;
110#endif
111}float get_elevation(vec2 pos) {
112#ifdef TERRAIN3D
113#ifdef GLOBE
114if ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}
115#endif
116vec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.5;vec2 f=fract(coord);ivec2 c=ivec2(floor(coord));ivec2 hi=textureSize(u_terrain,0)-1;float tl=ele(clamp(c,ivec2(0),hi));float tr=ele(clamp(c+ivec2(1,0),ivec2(0),hi));float bl=ele(clamp(c+ivec2(0,1),ivec2(0),hi));float br=ele(clamp(c+ivec2(1,1),ivec2(0),hi));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;
117#else
118return 0.0;
119#endif
120}const float PI=3.141592653589793;
121#define PROJECTION_UBO
122layout(std140) uniform ProjectionUBO {highp mat4 u_projection_matrix;highp mat4 u_projection_fallback_matrix;highp vec4 u_projection_tile_mercator_coords;highp vec4 u_projection_clipping_plane;highp float u_projection_transition;highp int u_projection_clip_antimeridian;};layout(std140) uniform FrameUBO {highp vec2 u_units_to_pixels;highp vec2 u_world_size;highp float u_camera_to_center_distance;highp float u_symbol_fade_change;highp float u_aspect_ratio;highp float u_device_pixel_ratio;highp vec2 u_viewport_size;highp vec2 u_pixel_extrude_scale;highp float u_pitch;};`),projectionMercator:t$(`
123void clipAntimeridian() {}`,"float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:t$("in highp float v_projection_tile_x;void clipAntimeridian() {if (u_projection_clip_antimeridian !=0 && (v_projection_tile_x < 0.0 || v_projection_tile_x >=8192.0)) {discard;}}",`#define GLOBE_RADIUS 6371008.8
124#ifndef PROJECTION_UBO
125uniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;
126#endif
127out highp float v_projection_tile_x;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos
128);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float t=exp(PI-(mercator_pos_y*PI*2.0));return (2.0*t)/(t*t+1.0);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY);if (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;float spherical_x=mercator_pos.x*PI*2.0+PI;float t=exp(PI-(mercator_pos.y*PI*2.0));
128float t2=t*t;float denom=t2+1.0;float sin_sy=(t2-1.0)/denom;float cos_sy=(2.0*t)/denom;vec3 pos=vec3(sin(spherical_x)*cos_sy,sin_sy,cos(spherical_x)*cos_sy
129);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {v_projection_tile_x=posInTile.x;vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {v_projection_tile_x=posInTile.x;vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}`),background:t$(tZ,"layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:t$(tU,"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;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);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:t$(tG,tV),clippingMask:t$(tq,"layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:t$(`uniform highp float u_intensity;in vec2 v_extrude;
130#pragma maplibre: define highp float weight
131#define GAUSS_COEF 0.3989422804014327
132void main() {
133#pragma maplibre: initialize highp float weight
134float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);
135#ifdef OVERDRAW_INSPECTOR
136fragColor=vec4(1.0);
137#endif
138}`,`uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;layout(location=0) in ivec2 a_pos;out vec2 v_extrude;
139#pragma maplibre: define highp float weight
140#pragma maplibre: define mediump float radius
141const highp float ZERO=1.0/255.0/16.0;
142#define GAUSS_COEF 0.3989422804014327
143void main(void) {
144#pragma maplibre: initialize highp float weight
145#pragma maplibre: initialize mediump float radius
146ivec2 pos_raw=a_pos+32768;vec2 unscaled_extrude=vec2(pos_raw & 7)/7.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 circle_center=vec2(pos_raw >> 3);
147#ifdef GLOBE
148vec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);
149#else
150gl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));
151#endif
152}`),heatmapTexture:t$(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;
153#ifdef OVERDRAW_INSPECTOR
154fragColor=vec4(0.0);
155#endif
156}`,"uniform mat4 u_matrix;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world_size,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:t$("flat in float v_placed;flat in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","layout(location=0) in vec2 a_anchor_pos;layout(location=1) in vec2 a_placed;layout(location=2) in vec2 a_box_real;flat out float v_placed;flat out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:t$("flat in float v_radius;in vec2 v_extrude;flat in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;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);fragColor=color*alpha*opacity_t;}","layout(location=0) in vec2 a_pos;layout(location=1) in float a_radius;layout(location=2) in vec2 a_flags;flat out float v_radius;out vec2 v_extrude;flat out float v_collision;void main() {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;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:t$(`#ifdef GL_ES
157precision highp float;
158#endif
159uniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {vec4 data=texelFetch(u_elevation_stops,ivec2(stop,0),0)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else
160{l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0));
161#ifdef OVERDRAW_INSPECTOR
162fragColor=vec4(1.0);
163#endif
164}`,"uniform vec2 u_dimension;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=2.0/u_dimension;float scale=(u_dimension.x-4.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),debug:t$("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","layout(location=0) in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:t$(tq,`layout(location=0) in vec2 a_pos;void main() {
165#ifdef GLOBE
166gl_Position=projectTileFor3D(a_pos,0.0);
167#else
168gl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);
169#endif
170}`),fill:t$(`#pragma maplibre: define highp vec4 color
171#pragma maplibre: define lowp float opacity
172void main() {
173#pragma maplibre: initialize highp vec4 color
174#pragma maplibre: initialize lowp float opacity
175fragColor=color*opacity;
176#ifdef OVERDRAW_INSPECTOR
177fragColor=vec4(1.0);
178#endif
179}`,`uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;
180#pragma maplibre: define highp vec4 color
181#pragma maplibre: define lowp float opacity
182void main() {
183#pragma maplibre: initialize highp vec4 color
184#pragma maplibre: initialize lowp float opacity
185if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}gl_Position=projectTile(a_pos+u_fill_translate,a_pos);}`),fillOutline:t$(`in vec2 v_pos;
186#ifdef GLOBE
187in float v_depth;
188#endif
189#pragma maplibre: define highp vec4 outline_color
190#pragma maplibre: define lowp float opacity
191void main() {
192#pragma maplibre: initialize highp vec4 outline_color
193#pragma maplibre: initialize lowp float opacity
194float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);
195#ifdef GLOBE
196if (v_depth > 1.0) {discard;}
197#endif
198#ifdef OVERDRAW_INSPECTOR
199fragColor=vec4(1.0);
200#endif
201}`,`uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos;
202#ifdef GLOBE
203out float v_depth;
204#endif
205#pragma maplibre: define highp vec4 outline_color
206#pragma maplibre: define lowp float opacity
207void main() {
208#pragma maplibre: initialize highp vec4 outline_color
209#pragma maplibre: initialize lowp float opacity
210if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world_size;
211#ifdef GLOBE
212v_depth=gl_Position.z/gl_Position.w;
213#endif
214}`),fillOutlinePattern:t$(`uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;uniform bool u_sdf_pattern;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;
215#ifdef GLOBE
216in float v_depth;
217#endif
218#pragma maplibre: define lowp float opacity
219#pragma maplibre: define highp vec4 color
220#pragma maplibre: define lowp vec4 pattern_from
221#pragma maplibre: define lowp vec4 pattern_to
222void main() {
223#pragma maplibre: initialize lowp float opacity
224#pragma maplibre: initialize highp vec4 color
225#pragma maplibre: initialize mediump vec4 pattern_from
226#pragma maplibre: initialize mediump vec4 pattern_to
227vec2 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=texture(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=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);if (u_sdf_pattern) {highp float sdf_edge=(256.0-64.0)/256.0;highp float sdf_gamma_a=max(fwidth(color1.a)*0.5,1.0/255.0/16.0);highp float sdf_gamma_b=max(fwidth(color2.a)*0.5,1.0/255.0/16.0);float sdf_alpha_a=smoothstep(sdf_edge-sdf_gamma_a,sdf_edge+sdf_gamma_a,color1.a);float sdf_alpha_b=smoothstep(sdf_edge-sdf_gamma_b,sdf_edge+sdf_gamma_b,color2.a);fragColor=mix(color*sdf_alpha_a,color*sdf_alpha_b,u_fade)*alpha*opacity;} else {fragColor=mix(color1,color2,u_fade)*alpha*opacity;}
228#ifdef GLOBE
229if (v_depth > 1.0) {discard;}
230#endif
231#ifdef OVERDRAW_INSPECTOR
232fragColor=vec4(1.0);
233#endif
234}`,`uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;
235#ifdef GLOBE
236out float v_depth;
237#endif
238#pragma maplibre: define lowp float opacity
239#pragma maplibre: define highp vec4 color
240#pragma maplibre: define lowp vec4 pattern_from
241#pragma maplibre: define lowp vec4 pattern_to
242#pragma maplibre: define lowp float pixel_ratio_from
243#pragma maplibre: define lowp float pixel_ratio_to
244void main() {
245#pragma maplibre: initialize lowp float opacity
246#pragma maplibre: initialize highp vec4 color
247#pragma maplibre: initialize mediump vec4 pattern_from
248#pragma maplibre: initialize mediump vec4 pattern_to
249#pragma maplibre: initialize lowp float pixel_ratio_from
250#pragma maplibre: initialize lowp float pixel_ratio_to
251if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}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=projectTile(a_pos+u_fill_translate,a_pos);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_size;
252#ifdef GLOBE
253v_depth=gl_Position.z/gl_Position.w;
254#endif
255}`),fillPattern:t$(`#ifdef GL_ES
256precision highp float;
257#endif
258uniform vec2 u_texsize;uniform float u_fade;uniform bool u_sdf_pattern;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;
259#pragma maplibre: define lowp float opacity
260#pragma maplibre: define highp vec4 color
261#pragma maplibre: define lowp vec4 pattern_from
262#pragma maplibre: define lowp vec4 pattern_to
263void main() {
264#pragma maplibre: initialize lowp float opacity
265#pragma maplibre: initialize highp vec4 color
266#pragma maplibre: initialize mediump vec4 pattern_from
267#pragma maplibre: initialize mediump vec4 pattern_to
268vec2 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=texture(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=texture(u_image,pos2);if (u_sdf_pattern) {highp float sdf_edge=(256.0-64.0)/256.0;highp float sdf_gamma_a=max(fwidth(color1.a)*0.5,1.0/255.0/16.0);highp float sdf_gamma_b=max(fwidth(color2.a)*0.5,1.0/255.0/16.0);float sdf_alpha_a=smoothstep(sdf_edge-sdf_gamma_a,sdf_edge+sdf_gamma_a,color1.a);float sdf_alpha_b=smoothstep(sdf_edge-sdf_gamma_b,sdf_edge+sdf_gamma_b,color2.a);fragColor=mix(color*sdf_alpha_a,color*sdf_alpha_b,u_fade)*opacity;} else {fragColor=mix(color1,color2,u_fade)*opacity;}
269#ifdef OVERDRAW_INSPECTOR
270fragColor=vec4(1.0);
271#endif
272}`,`uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;
273#pragma maplibre: define lowp float opacity
274#pragma maplibre: define highp vec4 color
275#pragma maplibre: define lowp vec4 pattern_from
276#pragma maplibre: define lowp vec4 pattern_to
277#pragma maplibre: define lowp float pixel_ratio_from
278#pragma maplibre: define lowp float pixel_ratio_to
279void main() {
280#pragma maplibre: initialize lowp float opacity
281#pragma maplibre: initialize highp vec4 color
282#pragma maplibre: initialize mediump vec4 pattern_from
283#pragma maplibre: initialize mediump vec4 pattern_to
284#pragma maplibre: initialize lowp float pixel_ratio_from
285#pragma maplibre: initialize lowp float pixel_ratio_to
286if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}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 to
286Scale=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=projectTile(a_pos+u_fill_translate,a_pos);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:t$(`in vec4 v_color;void main() {fragColor=v_color;
287#ifdef OVERDRAW_INSPECTOR
288fragColor=vec4(1.0);
289#endif
290}`,`uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;layout(location=1) in ivec4 a_normal_ed;
291#ifdef TERRAIN3D
292layout(location=2) in vec2 a_centroid;
293#endif
294out vec4 v_color;
295#pragma maplibre: define highp float base
296#pragma maplibre: define highp float height
297#pragma maplibre: define highp vec4 color
298void main() {
299#pragma maplibre: initialize highp float base
300#pragma maplibre: initialize highp float height
301#pragma maplibre: initialize highp vec4 color
302vec3 normal=vec3(a_normal_ed.xyz);float gradient_base=max(0.0,base);float gradient_height=max(0.0,height);
303#ifdef TERRAIN3D
304float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
305#else
306float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
307#endif
308base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=float(a_normal_ed.x & 1);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;
309#ifdef GLOBE
310vec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);
311#else
312gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);
313#endif
314float 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;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);
315#ifdef GLOBE
316mat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);
317#endif
318directional=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+gradient_base)*pow(gradient_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:t$(`uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;
319#pragma maplibre: define lowp float base
320#pragma maplibre: define lowp float height
321#pragma maplibre: define lowp vec4 pattern_from
322#pragma maplibre: define lowp vec4 pattern_to
323#pragma maplibre: define lowp float pixel_ratio_from
324#pragma maplibre: define lowp float pixel_ratio_to
325void main() {
326#pragma maplibre: initialize lowp float base
327#pragma maplibre: initialize lowp float height
328#pragma maplibre: initialize mediump vec4 pattern_from
329#pragma maplibre: initialize mediump vec4 pattern_to
330#pragma maplibre: initialize lowp float pixel_ratio_from
331#pragma maplibre: initialize lowp float pixel_ratio_to
332vec2 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=texture(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=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;
333#ifdef OVERDRAW_INSPECTOR
334fragColor=vec4(1.0);
335#endif
336}`,`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 vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;layout(location=0) in vec2 a_pos;layout(location=1) in ivec4 a_normal_ed;
337#ifdef TERRAIN3D
338layout(location=2) in vec2 a_centroid;
339#endif
340#ifdef GLOBE
341out vec3 v_sphere_pos;
342#endif
343out vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;
344#pragma maplibre: define lowp float base
345#pragma maplibre: define lowp float height
346#pragma maplibre: define lowp vec4 pattern_from
347#pragma maplibre: define lowp vec4 pattern_to
348#pragma maplibre: define lowp float pixel_ratio_from
349#pragma maplibre: define lowp float pixel_ratio_to
350void main() {
351#pragma maplibre: initialize lowp float base
352#pragma maplibre: initialize lowp float height
353#pragma maplibre: initialize mediump vec4 pattern_from
354#pragma maplibre: initialize mediump vec4 pattern_to
355#pragma maplibre: initialize lowp float pixel_ratio_from
356#pragma maplibre: initialize lowp float pixel_ratio_to
357vec2 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=vec3(a_normal_ed.xyz);float edgedistance=float(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;float gradient_base=max(0.0,base);float gradient_height=max(0.0,height);
358#ifdef TERRAIN3D
359float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
360#else
361float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
362#endif
363base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=float(a_normal_ed.x & 1);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;
364#ifdef GLOBE
365vec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);
366#else
367gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);
368#endif
369vec2 pos=a_normal_ed.x==1 && a_normal_ed.y==0 && a_normal_ed.z==16384
370? a_pos
371: vec2(edgedistance,elevation*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+gradient_base)*pow(gradient_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:t$(`#ifdef GL_ES
372precision highp float;
373#endif
374uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(ivec2 texel) {vec4 data=texelFetch(u_image,texel,0)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {ivec2 pos=ivec2(gl_FragCoord.xy)+ivec2(1);float tileSize=u_dimension.x-4.0;float a=getElevation(pos+ivec2(-1,-1));float b=getElevation(pos+ivec2(0,-1));float c=getElevation(pos+ivec2(1,-1));float d=getElevation(pos+ivec2(-1,0));float e=getElevation(pos);float f=getElevation(pos+ivec2(1,0));float g=getElevation(pos+ivec2(-1,1));float h=getElevation(pos+ivec2(0,1));float i=getElevation(pos+ivec2(1,1));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))*tileSize/p
374ow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);
375#ifdef OVERDRAW_INSPECTOR
376fragColor=vec4(1.0);
377#endif
378}`,"uniform mat4 u_matrix;uniform vec2 u_dimension;layout(location=0) in vec2 a_pos;layout(location=1) in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:t$(`uniform sampler2D u_image;in highp vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];
379#define PI 3.141592653589793
380#define STANDARD 0
381#define COMBINED 1
382#define IGOR 2
383#define MULTIDIRECTIONAL 3
384#define BASIC 4
385float get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;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_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else
386{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else
387{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {highp vec2 size=vec2(textureSize(u_image,0));highp vec2 texturePos=(v_pos*(size-2.0)+1.0)/size;vec4 pixel=texture(u_image,texturePos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}
388#ifdef OVERDRAW_INSPECTOR
389fragColor=vec4(1.0);
390#endif
391}`,"uniform mat4 u_matrix;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:t$(`flat in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;
392#ifdef GLOBE
393in float v_depth;
394#endif
395#pragma maplibre: define highp vec4 color
396#pragma maplibre: define lowp float blur
397#pragma maplibre: define lowp float opacity
398void main() {
399#pragma maplibre: initialize highp vec4 color
400#pragma maplibre: initialize lowp float blur
401#pragma maplibre: initialize lowp float opacity
402clipAntimeridian();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);fragColor=color*(alpha*opacity);
403#ifdef GLOBE
404if (v_depth > 1.0) {discard;}
405#endif
406#ifdef OVERDRAW_INSPECTOR
407fragColor=vec4(1.0);
408#endif
409}`,`
410#define scale 0.015873016
411layout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;out vec2 v_normal;flat out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;
412#ifdef GLOBE
413out float v_depth;
414#endif
415#pragma maplibre: define highp vec4 color
416#pragma maplibre: define lowp float blur
417#pragma maplibre: define lowp float opacity
418#pragma maplibre: define mediump float gapwidth
419#pragma maplibre: define lowp float offset
420#pragma maplibre: define mediump float width
421void main() {
422#pragma maplibre: initialize highp vec4 color
423#pragma maplibre: initialize lowp float blur
424#pragma maplibre: initialize lowp float opacity
425#pragma maplibre: initialize mediump float gapwidth
426#pragma maplibre: initialize lowp float offset
427#pragma maplibre: initialize mediump float width
428if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);v_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*2.0;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);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);
428float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
429#ifdef GLOBE
430v_depth=gl_Position.z/gl_Position.w;
431#endif
432#ifdef TERRAIN3D
433v_gamma_scale=1.0;
434#else
435float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
436#endif
437v_width2=vec2(outset,inset);}`),lineGradient:t$(`uniform sampler2D u_image;flat in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;
438#ifdef GLOBE
439in float v_depth;
440#endif
441#pragma maplibre: define lowp float blur
442#pragma maplibre: define lowp float opacity
443void main() {
444#pragma maplibre: initialize lowp float blur
445#pragma maplibre: initialize lowp float opacity
446clipAntimeridian();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=texture(u_image,v_uv);fragColor=color*(alpha*opacity);
447#ifdef GLOBE
448if (v_depth > 1.0) {discard;}
449#endif
450#ifdef OVERDRAW_INSPECTOR
451fragColor=vec4(1.0);
452#endif
453}`,`
454#define scale 0.015873016
455layout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in float a_uv_x;layout(location=3) in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform float u_image_height;out vec2 v_normal;flat out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;
456#ifdef GLOBE
457out float v_depth;
458#endif
459#pragma maplibre: define lowp float blur
460#pragma maplibre: define lowp float opacity
461#pragma maplibre: define mediump float gapwidth
462#pragma maplibre: define lowp float offset
463#pragma maplibre: define mediump float width
464void main() {
465#pragma maplibre: initialize lowp float blur
466#pragma maplibre: initialize lowp float opacity
467#pragma maplibre: initialize mediump float gapwidth
468#pragma maplibre: initialize lowp float offset
469#pragma maplibre: initialize mediump float width
470if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);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=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
471#ifdef GLOBE
472v_depth=gl_Position.z/gl_Position.w;
473#endif
474#ifdef TERRAIN3D
475v_gamma_scale=1.0;
476#else
477float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
478#endif
479v_width2=vec2(outset,inset);}`),linePattern:t$(`#ifdef GL_ES
480precision highp float;
481#endif
482uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;flat in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;flat in float v_width;
483#ifdef GLOBE
484in float v_depth;
485#endif
486#pragma maplibre: define lowp vec4 pattern_from
487#pragma maplibre: define lowp vec4 pattern_to
488#pragma maplibre: define lowp float pixel_ratio_from
489#pragma maplibre: define lowp float pixel_ratio_to
490#pragma maplibre: define lowp float blur
491#pragma maplibre: define lowp float opacity
492void main() {
493#pragma maplibre: initialize mediump vec4 pattern_from
494#pragma maplibre: initialize mediump vec4 pattern_to
495#pragma maplibre: initialize lowp float pixel_ratio_from
496#pragma maplibre: initialize lowp float pixel_ratio_to
497#pragma maplibre: initialize lowp float blur
498#pragma maplibre: initialize lowp float opacity
499clipAntimeridian();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(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;
500#ifdef GLOBE
501if (v_depth > 1.0) {discard;}
502#endif
503#ifdef OVERDRAW_INSPECTOR
504fragColor=vec4(1.0);
505#endif
506}`,`
507#define scale 0.015873016
508#define LINE_DISTANCE_SCALE 2.0
509layout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;out vec2 v_normal;flat out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;flat out float v_width;
510#ifdef GLOBE
511out float v_depth;
512#endif
513#pragma maplibre: define lowp float blur
514#pragma maplibre: define lowp float opacity
515#pragma maplibre: define lowp float offset
516#pragma maplibre: define mediump float gapwidth
517#pragma maplibre: define mediump float width
518#pragma maplibre: define lowp float floorwidth
519#pragma maplibre: define lowp vec4 pattern_from
520#pragma maplibre: define lowp vec4 pattern_to
521#pragma maplibre: define lowp float pixel_ratio_from
522#pragma maplibre: define lowp float pixel_ratio_to
523void main() {
524#pragma maplibre: initialize lowp float blur
525#pragma maplibre: initialize lowp float opacity
526#pragma maplibre: initialize lowp float offset
527#pragma maplibre: initialize mediump float gapwidth
528#pragma maplibre: initialize mediump float width
529#pragma maplibre: initialize lowp float floorwidth
530#pragma maplibre: initialize mediump vec4 pattern_from
531#pragma maplibre: initialize mediump vec4 pattern_to
532#pragma maplibre: initialize lowp float pixel_ratio_from
533#pragma maplibre: initialize lowp float pixel_ratio_to
534if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);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);
534float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
535#ifdef GLOBE
536v_depth=gl_Position.z/gl_Position.w;
537#endif
538#ifdef TERRAIN3D
539v_gamma_scale=1.0;
540#else
541float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
542#endif
543v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}`),lineSDF:t$(`uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;flat in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;
544#ifdef GLOBE
545in float v_depth;
546#endif
547#pragma maplibre: define highp vec4 color
548#pragma maplibre: define lowp float blur
549#pragma maplibre: define lowp float opacity
550#pragma maplibre: define mediump float width
551#pragma maplibre: define lowp float floorwidth
552#pragma maplibre: define mediump vec4 dasharray_from
553#pragma maplibre: define mediump vec4 dasharray_to
554void main() {
555#pragma maplibre: initialize highp vec4 color
556#pragma maplibre: initialize lowp float blur
557#pragma maplibre: initialize lowp float opacity
558#pragma maplibre: initialize mediump float width
559#pragma maplibre: initialize lowp float floorwidth
560#pragma maplibre: initialize mediump vec4 dasharray_from
561#pragma maplibre: initialize mediump vec4 dasharray_to
562clipAntimeridian();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=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);
562float sdfgamma=(u_lineatlas_width/256.0/u_device_pixel_ratio)/min(dasharray_from.w,dasharray_to.w);alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);
563#ifdef GLOBE
564if (v_depth > 1.0) {discard;}
565#endif
566#ifdef OVERDRAW_INSPECTOR
567fragColor=vec4(1.0);
568#endif
569}`,`
570#define scale 0.015873016
571#define LINE_DISTANCE_SCALE 2.0
572layout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;flat out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;
573#ifdef GLOBE
574out float v_depth;
575#endif
576#pragma maplibre: define highp vec4 color
577#pragma maplibre: define lowp float blur
578#pragma maplibre: define lowp float opacity
579#pragma maplibre: define mediump float gapwidth
580#pragma maplibre: define lowp float offset
581#pragma maplibre: define mediump float width
582#pragma maplibre: define lowp float floorwidth
583#pragma maplibre: define mediump vec4 dasharray_from
584#pragma maplibre: define mediump vec4 dasharray_to
585void main() {
586#pragma maplibre: initialize highp vec4 color
587#pragma maplibre: initialize lowp float blur
588#pragma maplibre: initialize lowp float opacity
589#pragma maplibre: initialize mediump float gapwidth
590#pragma maplibre: initialize lowp float offset
591#pragma maplibre: initialize mediump float width
592#pragma maplibre: initialize lowp float floorwidth
593#pragma maplibre: initialize mediump vec4 dasharray_from
594#pragma maplibre: initialize mediump vec4 dasharray_to
595if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
596#ifdef GLOBE
597v_depth=gl_Position.z/gl_Position.w;
598#endif
599#ifdef TERRAIN3D
600v_gamma_scale=1.0;
601#else
602float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
603#endif
604float u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}`),lineGradientSDF:t$(`uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;flat in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;
605#ifdef GLOBE
606in float v_depth;
607#endif
608#pragma maplibre: define lowp float blur
609#pragma maplibre: define lowp float opacity
610#pragma maplibre: define mediump float width
611#pragma maplibre: define lowp float floorwidth
612#pragma maplibre: define mediump vec4 dasharray_from
613#pragma maplibre: define mediump vec4 dasharray_to
614void main() {
615#pragma maplibre: initialize lowp float blur
616#pragma maplibre: initialize lowp float opacity
617#pragma maplibre: initialize mediump float width
618#pragma maplibre: initialize lowp float floorwidth
619#pragma maplibre: initialize mediump vec4 dasharray_from
620#pragma maplibre: initialize mediump vec4 dasharray_to
621clipAntimeridian();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=texture(u_image,v_uv);float sdfdist_a=texture(u_image_dash,v_tex_a).a;float sdfdist_b=texture(u_image_dash,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);
621float sdfgamma=(u_lineatlas_width/256.0)/min(dasharray_from.w,dasharray_to.w);float dash_alpha=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*dash_alpha*opacity);
622#ifdef GLOBE
623if (v_depth > 1.0) {discard;}
624#endif
625#ifdef OVERDRAW_INSPECTOR
626fragColor=vec4(1.0);
627#endif
628}`,`
629#define scale 0.015873016
630#define LINE_DISTANCE_SCALE 2.0
631layout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in float a_uv_x;layout(location=3) in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;flat out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;
632#ifdef GLOBE
633out float v_depth;
634#endif
635#pragma maplibre: define lowp float blur
636#pragma maplibre: define lowp float opacity
637#pragma maplibre: define mediump float gapwidth
638#pragma maplibre: define lowp float offset
639#pragma maplibre: define mediump float width
640#pragma maplibre: define lowp float floorwidth
641#pragma maplibre: define mediump vec4 dasharray_from
642#pragma maplibre: define mediump vec4 dasharray_to
643void main() {
644#pragma maplibre: initialize lowp float blur
645#pragma maplibre: initialize lowp float opacity
646#pragma maplibre: initialize mediump float gapwidth
647#pragma maplibre: initialize lowp float offset
648#pragma maplibre: initialize mediump float width
649#pragma maplibre: initialize lowp float floorwidth
650#pragma maplibre: initialize mediump vec4 dasharray_from
651#pragma maplibre: initialize mediump vec4 dasharray_to
652if (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_direction=float(int(a_data.z & 3u)-1);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;float texel_height=1.0/u_image_height;float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
653#ifdef GLOBE
654v_depth=gl_Position.z/gl_Position.w;
655#endif
656#ifdef TERRAIN3D
657v_gamma_scale=1.0;
658#else
659float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
660#endif
661float u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}`),layerOpacity:t$(`uniform sampler2D u_image;uniform float u_opacity;in vec2 v_pos;void main() {fragColor=texture(u_image,v_pos)*u_opacity;
662#ifdef OVERDRAW_INSPECTOR
663fragColor=vec4(0.0);
664#endif
665}`,"layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos.x*2.0-1.0,1.0-a_pos.y*2.0,0.0,1.0);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),raster:t$(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec3 v_pos0;in vec3 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=texture(u_image0,v_pos0.xy/v_pos0.z);vec4 color1=texture(u_image1,v_pos1.xy/v_pos1.z);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);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);
666#ifdef OVERDRAW_INSPECTOR
667fragColor=vec4(1.0);
668#endif
669}`,`uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec3 u_image_warp;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;layout(location=0) in vec2 a_pos;out vec3 v_pos0;out vec3 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 topLeft=u_coords_top.xy;vec2 topRight=u_coords_top.zw;vec2 bottomLeft=u_coords_bottom.xy;vec2 bottomRight=u_coords_bottom.zw;
669vec2 bilinearPos=mix(mix(topLeft,topRight,fractionalPos.x),mix(bottomLeft,bottomRight,fractionalPos.x),fractionalPos.y);float denominator=dot(u_image_warp.xy,fractionalPos)+1.0;vec2 acrossTop=topRight-topLeft+u_image_warp.x*topRight;vec2 downLeft=bottomLeft-topLeft+u_image_warp.y*bottomLeft;vec2 projectivePos=(acrossTop*fractionalPos.x+downLeft*fractionalPos.y+topLeft)/denominator;vec2 position=mix(projectivePos,bilinearPos,u_image_warp.z);gl_Position=projectTile(position,position);vec2 texturePos=((fractionalPos-0.5)/u_buffer_scale)+0.5;
670#ifdef GLOBE
671if (a_pos.y <-32767.5) {texturePos.y=0.0;}if (a_pos.y > 32766.5) {texturePos.y=1.0;}
672#endif
673float perspectiveRatio=mix(1.0/denominator,1.0,u_image_warp.z);v_pos0=vec3(texturePos*perspectiveRatio,perspectiveRatio);vec2 parentPos=(texturePos*u_scale_parent)+u_tl_parent;v_pos1=vec3(parentPos*perspectiveRatio,perspectiveRatio);}`),symbolIcon:t$(`uniform sampler2D u_texture;in vec2 v_tex;flat in float v_total_opacity;void main() {fragColor=texture(u_texture,v_tex)*v_total_opacity;
674#ifdef OVERDRAW_INSPECTOR
675fragColor=vec4(1.0);
676#endif
677}`,`layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec4 a_pixeloffset;layout(location=3) in vec3 a_projected_pos;layout(location=4) in uint a_fade_opacity;layout(location=5) in float a_height_offset;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 bool u_rotate_symbol;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 bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;uniform bool u_is_offset;uniform bool u_height_anchor_ground;out vec2 v_tex;flat out float v_total_opacity;
678#pragma maplibre: define lowp float opacity
679void main() {
680#pragma maplibre: initialize lowp float opacity
681vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=a_height_offset+(u_height_anchor_ground ? get_elevation(a_pos) : 0.0);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;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_symbol_fade_change :-u_symbol_fade_change;float visibility=calculate_visibility(projectedPoint);v_total_opacity=opacity*max(0.0,min(visibility,fade_opacity[0]+fade_change));if (v_total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
682camera_to_anchor_distance/u_camera_to_center_distance :
683u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);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;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;
684#ifdef GLOBE
685if(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}
686#endif
687vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;}`),symbolSDF:t$(`#define SDF_PX 8.0
688uniform bool u_is_halo;uniform bool u_is_plain;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;
689#pragma maplibre: define highp vec4 fill_color
690#pragma maplibre: define highp vec4 halo_color
691#pragma maplibre: define lowp float halo_width
692#pragma maplibre: define lowp float halo_blur
693void main() {
694#pragma maplibre: initialize highp vec4 fill_color
695#pragma maplibre: initialize highp vec4 halo_color
696#pragma maplibre: initialize lowp float halo_width
697#pragma maplibre: initialize lowp float halo_blur
698float 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 total_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;lowp float dist=texture(u_texture,tex).a;lowp vec4 color_alpha_out_text,color_alpha_out_halo;if (u_is_plain){highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);color_alpha_out_text=total_opacity*alpha*fill_color;}if (u_is_halo) {float gamma_halo=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);float inner_edge_halo=inner_edge+gamma_halo*gamma_scale;highp float gamma_scaled_halo=gamma_halo*gamma_scale;highp float alpha_halo=smoothstep(inner_edge_halo-gamma_scaled_halo,inner_edge_halo+gamma_scaled_halo,dist);highp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha_halo= min(smoothstep(halo_edge-gamma_scaled_halo,halo_edge+gamma_scaled_halo,dist),1.0-alpha_halo);color_alpha_out_halo=total_opacity*alpha_halo*halo_color;}if (u_is_plain && u_is_halo) {fragColor=color_alpha_out_text+(1.-color_alpha_out_text.a)*color_alpha_out_halo;} else if (u_is_halo){fragColor=color_alpha_out_halo;} else {fragColor=color_alpha_out_text;}
699#ifdef OVERDRAW_INSPECTOR
700fragColor=vec4(1.0);
701#endif
702}`,`layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec4 a_pixeloffset;layout(location=3) in vec3 a_projected_pos;layout(location=4) in uint a_fade_opacity;layout(location=5) in float a_height_offset;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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform bool u_rotate_symbol;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;uniform bool u_is_offset;uniform bool u_height_anchor_ground;out vec2 v_data0;out vec3 v_data1;
703#pragma maplibre: define highp vec4 fill_color
704#pragma maplibre: define highp vec4 halo_color
705#pragma maplibre: define lowp float opacity
706#pragma maplibre: define lowp float halo_width
707#pragma maplibre: define lowp float halo_blur
708void main() {
709#pragma maplibre: initialize highp vec4 fill_color
710#pragma maplibre: initialize highp vec4 halo_color
711#pragma maplibre: initialize lowp float opacity
712#pragma maplibre: initialize lowp float halo_width
713#pragma maplibre: initialize lowp float halo_blur
714vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);vec2 a_pxoffset=a_pixeloffset.xy/16.0;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=a_height_offset+(u_height_anchor_ground ? get_elevation(a_pos) : 0.0);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;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_symbol_fade_change :-u_symbol_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));float total_opacity=opacity*interpolated_fade_opacity;if (total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
715camera_to_anchor_distance/u_camera_to_center_distance :
716u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);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;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;
717#ifdef GLOBE
718if(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}
719#endif
720vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,total_opacity);}`),symbolTextAndIcon:t$(`#define SDF_PX 8.0
721#define SDF 1.0
722#define ICON 0.0
723uniform bool u_is_halo;uniform bool u_is_text;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;in vec4 v_data0;in vec3 v_data1;flat in float v_is_sdf;
724#pragma maplibre: define highp vec4 fill_color
725#pragma maplibre: define highp vec4 halo_color
726#pragma maplibre: define lowp float halo_width
727#pragma maplibre: define lowp float halo_blur
728void main() {
729#pragma maplibre: initialize highp vec4 fill_color
730#pragma maplibre: initialize highp vec4 halo_color
731#pragma maplibre: initialize lowp float halo_width
732#pragma maplibre: initialize lowp float halo_blur
733float total_opacity=v_data1[2];if (v_is_sdf==ICON) {vec2 tex_icon=v_data0.zw;
733fragColor=texture(u_texture_icon,tex_icon)*total_opacity;
734#ifdef OVERDRAW_INSPECTOR
735fragColor=vec4(1.0);
736#endif
737return;}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;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;lowp float dist=texture(u_texture,tex).a;lowp vec4 color_alpha_out,color_alpha_out_halo;if (u_is_text) {highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);color_alpha_out=fill_color*(alpha*total_opacity);}if (u_is_halo) {highp float gamma_halo=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);lowp float buff_halo=(6.0-halo_width/fontScale)/SDF_PX;highp float gamma_scaled_halo=gamma_halo*gamma_scale;highp float alpha_halo=smoothstep(buff_halo-gamma_scaled_halo,buff_halo+gamma_scaled_halo,dist);color_alpha_out_halo=halo_color*(alpha_halo*total_opacity);}if (u_is_text && u_is_halo) {fragColor=color_alpha_out+(1.-color_alpha_out.a)*color_alpha_out_halo;} else if (u_is_halo) {fragColor=color_alpha_out_halo;} else {fragColor=color_alpha_out;}
738#ifdef OVERDRAW_INSPECTOR
739fragColor=vec4(1.0);
740#endif
741}`,`layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec3 a_projected_pos;layout(location=3) in uint a_fade_opacity;layout(location=4) in float a_height_offset;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_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 vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;uniform bool u_is_offset;uniform bool u_height_anchor_ground;out vec4 v_data0;out vec3 v_data1;flat out float v_is_sdf;
742#pragma maplibre: define highp vec4 fill_color
743#pragma maplibre: define highp vec4 halo_color
744#pragma maplibre: define lowp float opacity
745#pragma maplibre: define lowp float halo_width
746#pragma maplibre: define lowp float halo_blur
747void main() {
748#pragma maplibre: initialize highp vec4 fill_color
749#pragma maplibre: initialize highp vec4 halo_color
750#pragma maplibre: initialize lowp float opacity
751#pragma maplibre: initialize lowp float halo_width
752#pragma maplibre: initialize lowp float halo_blur
753vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);float is_sdf=float(a_data.z & 1u);float ele=a_height_offset+(u_height_anchor_ground ? get_elevation(a_pos) : 0.0);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;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_symbol_fade_change :-u_symbol_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));float total_opacity=opacity*interpolated_fade_opacity;if (total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
754camera_to_anchor_distance/u_camera_to_center_distance :
755u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);if (!u_is_offset) {size*=perspective_ratio;}float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);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;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;
756#ifdef GLOBE
757if(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}
758#endif
759vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec3(gamma_scale,size,total_opacity);v_is_sdf=is_sdf;}`),terrain:t$("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && u_fog_ground_blend_opacity > 0.0 && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);
759float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","layout(location=0) in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:t$("in 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() {fragColor=pack(v_depth);}","layout(location=0) in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),atmosphere:t$(`#ifdef GL_ES
760precision highp float;
761#endif
762in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758
763);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}`,"layout(location=0) in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:t$("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;in vec3 v_view_direction;const float ATMOSPHERE_HEIGHT_TO_GLOBE_RADIUS=100000.0/6371000.0;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;float opacity=1.0;if (u_sky_blend > 0.0) {vec3 ray=normalize(v_view_direction);float globe_distance=length(u_globe_position);float angle_to_globe_center=acos(clamp(dot(ray,u_globe_position)/globe_distance,-1.0,1.0));float horizon_angle=asin(min(u_globe_radius/globe_distance,1.0));blend=mix(blend,((angle_to_globe_center-horizon_angle)*u_camera_to_center_distance+1.0)*u_device_pixel_ratio,u_sky_blend);float closest_approach=max(dot(ray,u_globe_position),0.0);
763float lowest_altitude=sqrt(max(globe_distance*globe_distance-closest_approach*closest_approach,0.0))-u_globe_radius;float atmosphere_height=u_globe_radius*ATMOSPHERE_HEIGHT_TO_GLOBE_RADIUS;float inside_atmosphere=1.0-smoothstep(atmosphere_height,10.0*atmosphere_height,globe_distance-u_globe_radius);float through_atmosphere=1.0-smoothstep(0.0,atmosphere_height,lowest_altitude);opacity=inside_atmosphere*through_atmosphere*(1.0-u_atmosphere_blend);}if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor*=mix(1.0,opacity,u_sky_blend);}","layout(location=0) in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 v_view_direction;void main() {v_view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,1.0,1.0);}")};function t$(t,i){let r=/#pragma maplibre: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,a=i.match(/in ([\w]+) ([\w]+)/g),o=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=i.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),n=s?s.concat(o):o,l=a?a.length:0,h={};return{fragmentSource:t=t.replace(r,(t,i,r,a,o)=>(h[o]=!0,"define"===i?`
764#ifndef HAS_UNIFORM_u_${o}
765in ${r} ${a} ${o};
766#else
767uniform ${r} ${a} u_${o};
768#endif
769`:`
770#ifdef HAS_UNIFORM_u_${o}
771    ${r} ${a} ${o} = u_${o};
772#endif
773`)),vertexSource:i=i.replace(r,(t,i,r,a,o)=>{let s="float"===a?"vec2":"vec4",n=o.match(/color/)?"color":s;return h[o]?"define"===i?`
774#ifndef HAS_UNIFORM_u_${o}
775uniform lowp float u_${o}_t;
776layout(location = ${l++}) in ${r} ${s} a_${o};
777out ${r} ${a} ${o};
778#else
779uniform ${r} ${a} u_${o};
780#endif
781`:"vec4"===n?`
782#ifndef HAS_UNIFORM_u_${o}
783    ${o} = a_${o};
784#else
785    ${r} ${a} ${o} = u_${o};
786#endif
787`:`
788#ifndef HAS_UNIFORM_u_${o}
789    ${o} = unpack_mix_${n}(a_${o}, u_${o}_t);
790#else
791    ${r} ${a} ${o} = u_${o};
792#endif
793`:"define"===i?`
794#ifndef HAS_UNIFORM_u_${o}
795uniform lowp float u_${o}_t;
796layout(location = ${l++}) in ${r} ${s} a_${o};
797#else
798uniform ${r} ${a} u_${o};
799#endif
800`:"vec4"===n?`
801#ifndef HAS_UNIFORM_u_${o}
802    ${r} ${a} ${o} = a_${o};
803#else
804    ${r} ${a} ${o} = u_${o};
805#endif
806`:`
807#ifndef HAS_UNIFORM_u_${o}
808    ${r} ${a} ${o} = unpack_mix_${n}(a_${o}, u_${o}_t);
809#else
810    ${r} ${a} ${o} = u_${o};
811#endif
812`}),staticAttributes:a,staticUniforms:n}}let tH="#define PROJECTION_MERCATOR",tX="mercator";var tY=class{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return tX}get shaderDefine(){return tH}get shaderPreludeCode(){return tW.projectionMercator}get vertexShaderPreludeCode(){return tW.projectionMercator.vertexSource}get subdivisionGranularity(){return m.vt.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}destroy(){}getMeshFromTileID(t,i,r,a,o){if(this._cachedMesh)return this._cachedMesh;let s=new m.Gt;s.emplaceBack(0,0),s.emplaceBack(m.Lr,0),s.emplaceBack(0,m.Lr),s.emplaceBack(m.Lr,m.Lr);let n=t.createVertexBuffer(s,eD.members),l=m.Bt.simpleSegment(0,0,4,2),h=new m.Jt;h.emplaceBack(1,0,2),h.emplaceBack(1,2,3);let c=t.createIndexBuffer(h);return this._cachedMesh=new eR(n,c,l),this._cachedMesh}recalculate(){}hasTransition(){return!1}},tK=class t{constructor(t=0,i=0,r=0,a=0){if(isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<0||isNaN(a)||a<0)throw Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=i,this.left=r,this.right=a}interpolate(t,i,r){return null!=i.top&&null!=t.top&&(this.top=m.un.number(t.top,i.top,r)),null!=i.bottom&&null!=t.bottom&&(this.bottom=m.un.number(t.bottom,i.bottom,r)),null!=i.left&&null!=t.left&&(this.left=m.un.number(t.left,i.left,r)),null!=i.right&&null!=t.right&&(this.right=m.un.number(t.right,i.right,r)),this}getCenter(t,i){let r=(0,m.Bn)((this.left+t-this.right)/2,0,t),a=(0,m.Bn)((this.top+i-this.bottom)/2,0,i);return new m.Li(r,a)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new t(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}};function tJ(t,i){if(!t.renderWorldCopies||t.lngRange)return;let r=i.lng-t.center.lng;i.lng+=r>180?-360:360*(r<-180)}function tQ(t){return Math.max(0,Math.floor(t))}var t0=class{constructor(t,i){this.applyConstrain=(t,i)=>null===this._constrainOverride?this._callbacks.defaultConstrain(t,i):this._constrainOverride(t,i),this._callbacks=t,this._tileSize=512,this._renderWorldCopies=i?.renderWorldCopies===void 0||!!i?.renderWorldCopies,this._minZoom=i?.minZoom||0,this._maxZoom=i?.maxZoom||22,this._minPitch=i?.minPitch===void 0||i?.minPitch===null?0:i?.minPitch,this._maxPitch=i?.maxPitch===void 0||i?.maxPitch===null?60:i?.maxPitch,this._constrainOverride=i?.constrainOverride??null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new m.lt(0,0),this._elevation=0,this._zoom=0,this._tileZoom=tQ(this._zoom),this._scale=(0,m.Fr)(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new tK,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(t,i){this._constrainOverride=t.constrainOverride,this._latRange=t.latRange,this._lngRange=t.lngRange,this._width=t.width,this._height=t.height,this._center=t.center,this._elevation=t.elevation,this._minElevationForCurrentTile=t.minElevationForCurrentTile,this._zoom=t.zoom,this._tileZoom=tQ(this._zoom),this._scale=(0,m.Fr)(this._zoom),this._bearingInRadians=t.bearingInRadians,this._fovInRadians=t.fovInRadians,this._pitchInRadians=t.pitchInRadians,this._rollInRadians=t.rollInRadians,this._unmodified=t.unmodified,this._edgeInsets=new tK(t.padding.top,t.padding.bottom,t.padding.left,t.padding.right),this._minZoom=t.minZoom,this._maxZoom=t.maxZoom,this._minPitch=t.minPitch,this._maxPitch=t.maxPitch,this._renderWorldCopies=t.renderWorldCopies,this._cameraToCenterDistance=t.cameraToCenterDistance,this._nearZ=t.nearZ,this._farZ=t.farZ,this._autoCalculateNearFarZ=t.autoCalculateNearFarZ,i&&this.constrainInternal(),this._calcMatrices()}
812get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(t){this._minElevationForCurrentTile=t}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(t){if(this._minZoom===t)return;this._minZoom=t;let i=this._unmodified;this.setZoom(this.applyConstrain(this._center,this.zoom).zoom),this._unmodified=i}get maxZoom(){return this._maxZoom}setMaxZoom(t){if(this._maxZoom===t)return;this._maxZoom=t;let i=this._unmodified;this.setZoom(this.applyConstrain(this._center,this.zoom).zoom),this._unmodified=i}get minPitch(){return this._minPitch}setMinPitch(t){if(this._minPitch===t)return;this._minPitch=t;let i=this._unmodified;this.setPitch(Math.max(this.pitch,t)),this._unmodified=i}get maxPitch(){return this._maxPitch}setMaxPitch(t){if(this._maxPitch===t)return;this._maxPitch=t;let i=this._unmodified;this.setPitch(Math.min(this.pitch,t)),this._unmodified=i}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t}get constrainOverride(){return this._constrainOverride}setConstrainOverride(t){void 0===t&&(t=null),this._constrainOverride!==t&&(this._constrainOverride=t,this.constrainInternal(),this._calcMatrices())}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new m.Li(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(t){var i,r,a,o,s,n,l,h,c;let u=(0,m.Pr)(t,-180,180)*Math.PI/180;this._bearingInRadians!==u&&(this._unmodified=!1,this._bearingInRadians=u,this._calcMatrices(),this._rotationMatrix=f(),i=this._rotationMatrix,r=this._rotationMatrix,a=-this._bearingInRadians,o=r[0],s=r[1],n=r[2],l=r[3],h=Math.sin(a),c=Math.cos(a),i[0]=o*c+n*h,i[1]=s*c+l*h,i[2]=-(o*h)+n*c,i[3]=-(s*h)+l*c)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(t){let i=(0,m.Bn)(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==i&&(this._unmodified=!1,this._pitchInRadians=i,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(t){let i=t/180*Math.PI;this._rollInRadians!==i&&(this._unmodified=!1,this._rollInRadians=i,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return(0,m.xr)(this._fovInRadians)}setFov(t){t=(0,m.Bn)(t,.1,150),this.fov!==t&&(this._unmodified=!1,this._fovInRadians=(0,m.Yn)(t),this._calcMatrices())}get zoom(){return this._zoom}setZoom(t){let i=this.applyConstrain(this._center,t).zoom;this._zoom!==i&&(this._unmodified=!1,this._zoom=i,this._tileZoom=Math.max(0,Math.floor(i)),this._scale=(0,m.Fr)(i),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(t){(t.lat!==this._center.lat||t.lng!==this._center.lng)&&(this._unmodified=!1,this._center=t,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(t){t!==this._elevation&&(this._elevation=t,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(t,i){this._autoCalculateNearFarZ=!1,this._nearZ=t,this._farZ=i,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,i,r){this._unmodified=!1,this._edgeInsets.interpolate(t,i,r),this.constrainInternal(),this._calcMatrices()}resize(t,i,r=!0){this._width=t,this._height=i,r&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return this._latRange?.length!==2||this._lngRange?.length!==2?null:new ey([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]])}setMaxBounds(t){t?(this._lngRange=[t.getWest(),t.getEast()],this._latRange=[t.getSouth(),t.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-m.Fn,m.Fn])}getCameraQueryGeometry(t,i){if(1===i.length)return[i[0],t];{let{minX:r,minY:a,maxX:o,maxY:s}=m.pt.fromPoints(i).extend(t);return[new m.Li(r,a),new m.Li(o,a),new m.Li(o,s),new m.Li(r,s),new m.Li(r,a)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;let t=this._unmodified,{center:i,zoom:r}=this.applyConstrain(this.center,this.zoom);this.setCenter(i),this.setZoom(r),this._unmodified=t,this._constraining=!1}
812_calcMatrices(){if(this._pixelPerMeter=(0,m.ct)(1,this.center.lat)*this.worldSize,!this._width||!this._height)return;this._pixelsToGLUnits=[2/this._width,-2/this._height];let t=(0,m.Si)(new Float64Array(16));(0,m.Ai)(t,t,[this._width/2,-this._height/2,1]),(0,m.ji)(t,t,[1,-1,0]),this._clipSpaceToPixelsMatrix=t,t=(0,m.Si)(new Float64Array(16)),(0,m.Ai)(t,t,[1,-1,1]),(0,m.ji)(t,t,[-1,-1,0]),(0,m.Ai)(t,t,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=t;let i=this.fovInRadians/2;this._cameraToCenterDistance=.5/Math.tan(i)*this._height,this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(t,i,r,a){let o=void 0===r?this.bearing:r,s=a=void 0===a?this.pitch:a,{distanceToCenter:n,clampedElevation:l}=this._distanceToCenterFromAltElevationPitch(i,this.elevation,s),{x:h,y:c}=(0,m.J)(s,o),u=m.nt.fromLngLat(t,i),d=(0,m.rt)(1,u.y),_,p,f=0;do{if((f+=1)>10)break;let t=h*(p=n/d),i=c*p;d=1/(_=new m.nt(u.x+t,u.y+i)).meterInMercatorCoordinateUnits()}while(Math.abs(n-p*d)>1e-12);return{center:_.toLngLat(),elevation:l,zoom:(0,m.Dr)(this.height/2/Math.tan(this.fovInRadians/2)/p/this.tileSize)}}recalculateZoomAndCenter(t){if(this.elevation-t==0)return;let i=1/this.worldSize,r=(0,m.ct)(1,this.center.lat)*this.worldSize,a=m.nt.fromLngLat(this.center,this.elevation),o=a.x/i,s=a.y/i,n=a.z/i,l=this.pitch,h=this.bearing,{x:c,y:u,z:d}=(0,m.J)(l,h),_=this.cameraToCenterDistance,{distanceToCenter:p,clampedElevation:f}=this._distanceToCenterFromAltElevationPitch((n+_*d)/r,t,l),g=p*r,v=new m.nt((o+-(_*c)+c*g)*i,(s+-(_*u)+u*g)*i,0).toLngLat(),y=(0,m.ct)(1,v.lat),x=(0,m.Dr)(this.height/2/Math.tan(this.fovInRadians/2)/p/y/this.tileSize);this._elevation=f,this._center=v,this.setZoom(x)}_distanceToCenterFromAltElevationPitch(t,i,r){let a=-Math.cos((0,m.Yn)(r)),o=t-i,s,n=i;return a*o>=0||.1>Math.abs(a)?n=t+(s=1e4)*a:s=-o/a,{distanceToCenter:s,clampedElevation:n}}getCameraPoint(){let t=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new m.Li(t*Math.sin(this.rollInRadians),t*Math.cos(this.rollInRadians)))}getMercatorTileCoordinates(t){if(!t)return[0,0,1,1];let i=t.canonical.z>=0?1<<t.canonical.z:2**t.canonical.z;return[t.canonical.x/i,t.canonical.y/i,1/i/m.Lr,1/i/m.Lr]}},t1=class{distanceToTile2d(t,i,r,a){return Math.hypot(a.distanceX([t,i]),a.distanceY([t,i]))}getWrap(t,i,r){return r}getTileBoundingVolume(t,i,r,a){let o=Math.min(0,r),s=Math.max(0,r);if(a?.terrain){let r=new m.d(t.z,i,t.z,t.x,t.y),n=a.terrain.getMinMaxElevation(r);o=n.minElevation??o,s=n.maxElevation??s}let n=1<<t.z;return new e$([i+t.x/n,t.y/n,o],[i+(t.x+1)/n,(t.y+1)/n,s])}allowVariableZoom(t,i){let r=t.fov*(Math.abs(Math.cos(t.rollInRadians))*t.height+Math.abs(Math.sin(t.rollInRadians))*t.width)/t.height,a=(0,m.Bn)(78.5-r/2,0,60);return!!i.terrain||t.pitch>a}allowWorldCopies(){return!0}prepareNextFrame(){}};let t2=(0,m.Yt)([{name:"a_pos3d",type:"Int16",components:3}]);var t4=class extends m.vn{constructor(t){super(),this._lastTilesetChange=y(),this.tileManager=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=t._source.tileSize*2**this.deltaZoom,t.usedForTerrain=!0,t.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null,this.releaseAllRTT()}getSource(){return this.tileManager._source}update(t,i){this.tileManager.update(t,i),this._renderableTilesKeys=[];let r={},a=!1;for(let o of eQ(t,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i,calculateTileZoom:this.tileManager._source.calculateTileZoom}))r[o.key]=!0,this._renderableTilesKeys.push(o.key),this._tiles[o.key]||(o.terrainRttPosMatrix32f=new Float32Array(16),(0,m.Ti)(o.terrainRttPosMatrix32f,0,m.Lr,m.Lr,0,0,1),this._tiles[o.key]=new eV(o,this.tileSize),this._lastTilesetChange=y(),a=!0);for(let t in this._tiles)r[t]||(this._tiles[t].releaseRTT(this.tileManager.map.painter),delete this._tiles[t],a=!0);return a}releaseRTT(t){for(let i in this._tiles){let r=this._tiles[i];(r.tileID.equals(t)||r.tileID.isChildOf(t)||t.isChildOf(r.tileID))&&r.releaseRTT(this.tileManager.map.painter)}}releaseAllRTT(){for(let t in this._tiles)this._tiles[t].releaseRTT(this.tileManager.map.painter)}getRenderableTiles(){return this._renderableTilesKeys.map(t=>this.getTileByID(t))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t,i){return i?this._getTerrainCoordsForTileRanges(t,i):this._getTerrainCoordsForRegularTile(t)}_getTerrainCoordsForRegularTile(t){let i={};for(let r of this._renderableTilesKeys){let a=this._tiles[r].tileID,o=t.clone(),s=(0,m.Wn)();if(a.canonical.equals(t.canonical))(0,m.Ti)(s,0,m.Lr,m.Lr,0,0,1);else if(a.canonical.isChildOf(t.canonical)){let i=a.canonical.z-t.canonical.z,r=a.canonical.x-(a.canonical.x>>i<<i),o=a.canonical.y-(a.canonical.y>>i<<i),n=m.Lr>>i;(0,m.Ti)(s,0,n,n,0,0,1),(0,m.ji)(s,s,[-r*n,-o*n,0])}else{if(!t.canonical.isChildOf(a.canonical))continue;let i=t.canonical.z-a.canonical.z,r=t.canonical.x-(t.canonical.x>>i<<i),o=t.canonical.y-(t.canonical.y>>i<<i),n=m.Lr>>i;(0,m.Ti)(s,0,m.Lr,m.Lr,0,0,1),(0,m.ji)(s,s,[r*n,o*n,0]),(0,m.Ai)(s,s,[1/2**i,1/2**i,0])}o.terrainRttPosMatrix32f=new Float32Array(s),i[r]=o}return i}_getTerrainCoordsForTileRanges(t,i){let r={};for(let a of this._renderableTilesKeys){let o=this._tiles[a].tileID;if(!this._isWithinTileRanges(o,i))continue;let s=t.clone(),n=(0,m.Wn)();if(o.canonical.z===t.canonical.z){let i=t.canonical.x-o.canonical.x+t.wrap*(1<<t.canonical.z),r=t.canonical.y-o.canonical.y;(0,m.Ti)(n,0,m.Lr,m.Lr,0,0,1),(0,m.ji)(n,n,[i*m.Lr,r*m.Lr,0])}else if(o.canonical.z>t.canonical.z){let i=o.canonical.z-t.canonical.z,r=o.canonical.x-(o.canonical.x>>i<<i)+t.wrap*(1<<o.canonical.z),a=o.canonical.y-(o.canonical.y>>i<<i),s=t.canonical.x-(o.canonical.x>>i),l=t.canonical.y-(o.canonical.y>>i),h=m.Lr>>i;(0,m.Ti)(n,0,h,h,0,0,1),(0,m.ji)(n,n,[-r*h+s*m.Lr,-a*h+l*m.Lr,0])}else{let i=t.canonical.z-o.canonical.z,r=t.canonical.x-(t.canonical.x>>i<<i)+t.wrap*(1<<t.canonical.z),a=t.canonical.y-(t.canonical.y>>i<<i),s=(t.canonical.x>>i)-o.canonical.x,l=(t.canonical.y>>i)-o.canonical.y,h=m.Lr<<i;(0,m.Ti)(n,0,h,h,0,0,1),(0,m.ji)(n,n,[r*m.Lr+s*h,a*m.Lr+l*h,0])}s.terrainRttPosMatrix32f=new Float32Array(n),r[a]=s}return r}getSourceTile(t,i){let r=this.tileManager._source,a=t.overscaledZ-this.deltaZoom;if(a>r.maxzoom&&(a=r.maxzoom),a<r.minzoom)return;this._sourceTileCache[t.key]||=t.scaledTo(a).key;let o=this.findTileInCaches(this._sourceTileCache[t.key]);if(!o?.dem&&i)for(;a>=r.minzoom&&!o?.dem;)o=this.findTileInCaches(t.scaledTo(a--).key);return o}findTileInCaches(t){let i=this.tileManager.getTileByID(t);
812return i||(i=this.tileManager._outOfViewCache.getByKey(t))}anyTilesAfterTime(t=y()){return this._lastTilesetChange>=t}_isWithinTileRanges(t,i){let r=i[t.canonical.z];return!!r&&(t.wrap>r.minWrap||t.wrap<r.maxWrap||t.canonical.x>=r.minTileXWrapped&&t.canonical.x<=r.maxTileXWrapped&&t.canonical.y>=r.minTileY&&t.canonical.y<=r.maxTileY)}};let t3=m.Lr*(1-1e-12);var t5=class{constructor(t,i,r,a="auto"){this._meshCache={},this.painter=t,this.tileManager=new t4(i),this.options=r,this.exaggeration="number"==typeof r.exaggeration?r.exaggeration:1,this._terrainSkirtLength=a,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache=new Map,this._elevationSamplerCache=new Map}destroy(){for(let t in this._fbo&&=(this._fbo.destroy(),null),this._fboDepthTexture&&=(this._fboDepthTexture.destroy(),null),this._emptyDemTexture&&=(this._emptyDemTexture.destroy(),null),this._emptyDepthTexture&&=(this._emptyDepthTexture.destroy(),null),this._meshCache)this._meshCache[t].destroy();this._meshCache={},this.tileManager.destruct()}getDEMElevation(t,i,r,a=m.Lr){let o=t.normalizeCoordinates(i,r,a);if(!o)return 0;let s=this.getElevationSampler(o.tileID);return s?s(o.x,o.y,a):0}getElevationForLngLatZoom(t,i){if(!(0,m.h)(i,t.wrap()))return 0;let{tileID:r,mercatorX:a,mercatorY:o}=this._getOverscaledTileIDFromLngLatZoom(t,i);return this.getElevation(r,a%m.Lr,o%m.Lr,m.Lr)}getElevationForLngLat(t,i){let r=this.getCoverageIndex();if(r){let i=m.nt.fromLngLat(t),a=t8(r,this.exaggeration,i.x,i.y);if(a.demLoaded)return a.elevation}let a=eQ(i,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this}),o=0;for(let t of a)t.canonical.z>o&&(o=Math.min(t.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(t,o)}getElevation(t,i,r,a=m.Lr){return this.getDEMElevation(t,i,r,a)*this.exaggeration}resetElevationCache(){this._elevationSamplerCache.clear(),this._coverageIndex=void 0}getCoverageIndex(){return void 0===this._coverageIndex&&(this._coverageIndex=this._buildCoverageIndex()),this._coverageIndex}_buildCoverageIndex(){let t=[],i=new Map,r=0,a=0;for(let o of this.tileManager.getRenderableTiles()){if(!o)continue;let{canonical:s,wrap:n}=o.tileID;t.includes(s.z)||t.push(s.z);let l=this.getElevationSampler(o.tileID);i.set(`${n}/${s.z}/${s.x}/${s.y}`,l);let{minElevation:h,maxElevation:c}=this.getMinMaxElevation(o.tileID);r=Math.min(r,h??0),a=Math.max(a,c??0)}return 0===i.size?null:(t.sort((t,i)=>i-t),{zooms:t,samplerPerTile:i,minElevation:r-10,maxElevation:a+10})}getElevationSampler(t){let i=t.key,r=this._elevationSamplerCache.get(i);if(r)return r;let a=this.tileManager.getSourceTile(t,!0),o=a?.dem;if(!a||!o)return null;let s=this._getDEMTileMatrix(t,a),n=s[0]*o.dim,l=s[5]*o.dim,h=s[12]*o.dim+-.5,c=s[13]*o.dim+-.5,u=(t,i,r)=>{let a=8192===r?1:m.Lr/r;return o.sampleBilinear(t*a*n+h,i*a*l+c)};return this._elevationSamplerCache.set(i,u),u}_getDEMTileMatrix(t,i){let r=`${i.tileID.key}/${t.key}`,a=this._demMatrixCache.get(r);if(a)return a;let o=t.canonical.z-i.tileID.canonical.z,s=t.canonical.x-(t.canonical.x>>o<<o),n=t.canonical.y-(t.canonical.y>>o<<o),l=(0,m.xi)(new Float64Array(16),[1/(m.Lr<<o),1/(m.Lr<<o),0]);return(0,m.ji)(l,l,[s*m.Lr,n*m.Lr,0]),this._demMatrixCache.set(r,l),l}getTerrainData(t){if(!this._emptyDemTexture){let t=this.painter.context,i=new m.Dt({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new m.xt(t,i,t.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new m.xt(t,new m.Dt({width:1,height:1}),t.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=(0,m.Si)([])}let i=this.tileManager.getSourceTile(t,!0);if(i?.dem&&(!i.demTexture||i.needsTerrainPrepare)){let t=this.painter.context;i.demTexture||=this.painter.getTileTexture(i.dem.stride),i.demTexture?i.demTexture.update(i.dem.getPixels(),{premultiply:!1}):i.demTexture=new m.xt(t,i.dem.getPixels(),t.gl.RGBA,{premultiply:!1}),i.demTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),i.needsTerrainPrepare=!1}let r=i?this._getDEMTileMatrix(t,i):this._emptyDemMatrix;return{u_depth:2,u_terrain:3,u_terrain_dim:i?.dem?.dim||1,u_terrain_matrix:r,u_terrain_unpack:i?.dem?.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(i?.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:i}}getFramebuffer(){let t=this.painter,i=t.width/devicePixelRatio,r=t.height/devicePixelRatio;return this._fbo&&(this._fbo.width!==i||this._fbo.height!==r)&&(this._fbo.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture),this._fboDepthTexture||(this._fboDepthTexture=new m.xt(t.context,{width:i,height:r,data:null},t.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(t.context.gl.NEAREST,t.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=t.context.createFramebuffer(i,r,!0,!1),this._fbo.depthAttachment.set(t.context.createRenderbuffer(t.context.gl.DEPTH_COMPONENT16,i,r))),this._fbo.colorAttachment.set(this._fboDepthTexture.texture),this._fbo}getTerrainMesh(t){let i=this.painter.style.projection?.transitionState>0,r=i&&0===t.canonical.y,a=i&&t.canonical.y===(1<<t.canonical.z)-1,o=`m_${r?"n":""}_${a?"s":""}`;if(this._meshCache[o])return this._meshCache[o];let s=this.painter.context,n=new m.Wt,l=new m.Jt,h=this.meshSize,c=m.Lr/h,u=h*h;for(let t=0;t<=h;t++)for(let i=0;
812i<=h;i++)n.emplaceBack(i*c,t*c,0);for(let t=0;t<u;t+=h+1)for(let i=0;i<h;i++)l.emplaceBack(i+t,h+i+t+1,h+i+t+2),l.emplaceBack(i+t,h+i+t+2,i+t+1);"none"!==this._terrainSkirtLength&&this._buildSkirts(n,l,h,c,r,a);let d=new eR(s.createVertexBuffer(n,t2.members),s.createIndexBuffer(l),m.Bt.simpleSegment(0,0,n.length,l.length));return this._meshCache[o]=d,d}getSkirtLength(t){return 2*Math.PI*m.ut/2**Math.max(t,0)/5}getMinTileElevationForLngLatZoom(t,i){if(!(0,m.h)(i,t.wrap()))return 0;let{tileID:r}=this._getOverscaledTileIDFromLngLatZoom(t,i);return this.getMinMaxElevation(r).minElevation??0}getMinMaxElevation(t){let i=this.tileManager.getSourceTile(t,!0),r={minElevation:null,maxElevation:null};return i?.dem&&(r.minElevation=i.dem.min*this.exaggeration,r.maxElevation=i.dem.max*this.exaggeration),r}_getOverscaledTileIDFromLngLatZoom(t,i){let r=m.nt.fromLngLat(t.wrap()),a=(1<<i)*m.Lr,o=r.x*a,s=r.y*a,n=Math.floor(o/m.Lr),l=Math.floor(s/m.Lr);return{tileID:new m.d(i,0,i,n,l),mercatorX:o,mercatorY:s}}_buildSkirts(t,i,r,a,o,s){let n=t.length,l=n+(r+1),h=(r+1)*r,c=o?m.ht:0,u=+!o,d=s?m.gt:m.Lr,_=+!s;for(let i=0;i<=r;i++)t.emplaceBack(i*a,c,u);for(let i=0;i<=r;i++)t.emplaceBack(i*a,d,_);for(let t=0;t<r;t++)i.emplaceBack(h+t,l+t,l+t+1),i.emplaceBack(h+t,l+t+1,h+t+1),i.emplaceBack(0+t,n+t+1,n+t),i.emplaceBack(0+t,0+t+1,n+t+1);let p=t.length,f=p+(r+1)*2;for(let i of[0,1])for(let o=0;o<=r;o++)for(let r of[0,1])t.emplaceBack(i*m.Lr,o*a,r);for(let t=0;t<2*r;t+=2)i.emplaceBack(p+t,p+t+1,p+t+3),i.emplaceBack(p+t,p+t+3,p+t+2),i.emplaceBack(f+t,f+t+3,f+t+1),i.emplaceBack(f+t,f+t+2,f+t+3)}};let t6={covered:!1,demLoaded:!1,elevation:0};function t8(t,i,r,a){if(a<0||a>=1)return t6;let o=Math.floor(r),s=r-o;for(let r of t.zooms){let n=1<<r,l=s*n,h=a*n,c=Math.floor(l),u=Math.floor(h),d=`${o}/${r}/${c}/${u}`;if(!t.samplerPerTile.has(d))continue;let _=t.samplerPerTile.get(d);return _?{covered:!0,demLoaded:!0,elevation:_(Math.min((l-c)*m.Lr,t3),Math.min((h-u)*m.Lr,t3),m.Lr)*i}:{covered:!0,demLoaded:!1,elevation:0}}return t6}function t9(t,i){return t.covered&&i<=t.elevation+1e-6}function t7(t,i,r,a,o){for(let s=0;s<40&&a-r>o;s++){let o=(r+a)/2;i(t,o)?a=o:r=o}return{lo:r,hi:a}}var ie=class t{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,i,r){this._helper.interpolatePadding(t,i,r)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,i,r=!0){this._helper.resize(t,i,r)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,i){this._helper.overrideNearFarZ(t,i)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(t){}constructor(t,i){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(t,i)=>{i=(0,m.Bn)(+i,this.minZoom,this.maxZoom);let r={center:new m.lt(t.lng,t.lat),zoom:i},a=this._helper._lngRange;this._helper._renderWorldCopies||null!==a||(a=[-179.9999999999,180-1e-10]);let o=this.tileSize*(0,m.Fr)(r.zoom),s=0,n=o,l=0,h=o,c=0,u=0,{x:d,y:_}=this.size;if(this._helper._latRange){let t=this._helper._latRange;s=(0,m.st)(t[1])*o,(n=(0,m.st)(t[0])*o)-s<_&&(c=_/(n-s))}a&&(l=(0,m.Pr)((0,m.ot)(a[0])*o,0,o),(h=(0,m.Pr)((0,m.ot)(a[1])*o,0,o))<l&&(h+=o),h-l<d&&(u=d/(h-l)));let{x:p,y:f}=(0,m.$)(o,t),g,v,y=Math.max(u||0,c||0);if(y){let t=new m.Li(u?(h+l)/2:p,c?(n+s)/2:f);return r.center=(0,m.tt)(o,t).wrap(),r.zoom+=(0,m.Dr)(y),r}if(this._helper._latRange){let t=_/2;f-t<s&&(v=s+t),f+t>n&&(v=n-t)}if(a){let t=(l+h)/2,i=p;
812this._helper._renderWorldCopies&&(i=(0,m.Pr)(p,t-o/2,t+o/2));let r=d/2;i-r<l&&(g=l+r),i+r>h&&(g=h-r)}if(void 0!==g||void 0!==v){let t=new m.Li(g??p,v??f);r.center=(0,m.tt)(o,t).wrap()}return r},this.applyConstrain=(t,i)=>this._helper.applyConstrain(t,i),this._helper=i??new t0({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(t,i)=>this.defaultConstrain(t,i)},t),this._coveringTilesDetailsProvider=new t1}clone(){let i=new t;return i.apply(this,!1),i}apply(t,i){this._helper.apply(t,i)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(t){let i=[new m.f(0,t)];if(this._helper._renderWorldCopies){let r=this.screenPointToMercatorCoordinate(new m.Li(0,0)),a=this.screenPointToMercatorCoordinate(new m.Li(this._helper._width,0)),o=this.screenPointToMercatorCoordinate(new m.Li(this._helper._width,this._helper._height)),s=this.screenPointToMercatorCoordinate(new m.Li(0,this._helper._height)),n=Math.floor(Math.min(r.x,a.x,o.x,s.x)),l=Math.floor(Math.max(r.x,a.x,o.x,s.x));for(let r=n-1;r<=l+1;r++)0!==r&&i.push(new m.f(r,t))}return i}getCameraFrustum(){return eH.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){let i=this.screenPointToLocation(this.centerPoint,t),r=t?t.getElevationForLngLat(i,this):0;this._helper.recalculateZoomAndCenter(r)}setLocationAtPoint(t,i,r=this.elevation){let a=r-this.elevation,o=this.screenPointToMercatorCoordinateAtZ(i,a),s=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,0),n=m.nt.fromLngLat(t),l=new m.nt(n.x-(o.x-s.x),n.y-(o.y-s.y));this.setCenter(l?.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(t,i){return i?this.coordinatePoint(m.nt.fromLngLat(t),i.getElevationForLngLat(t,this),this._pixelMatrix3D):this.coordinatePoint(m.nt.fromLngLat(t))}screenPointToLocation(t,i){return this.screenPointToMercatorCoordinate(t,i)?.toLngLat()}screenPointToLocationAtElevation(t,i){return this.screenPointToMercatorCoordinateAtZ(t,i-this.elevation)?.toLngLat()}screenPointToMercatorCoordinate(t,i){if(i){let r=this.screenTerrainPointToMercatorCoordinate(t,i);if(null!=r)return r}return this.screenPointToMercatorCoordinateAtZ(t)}screenTerrainPointToMercatorCoordinate(t,i){let r=i.getCoverageIndex();if(!r)return null;let{near:a,far:o}=this.getRaySegmentFromPixel(t),s=this.worldSize,n=o[0]-a[0],l=o[1]-a[1],h=o[2]-a[2],c={index:r,exaggeration:i.exaggeration,near:a,dx:n,dy:l,dz:h,worldSize:s},u=0,d=1;if(0===h){if(a[2]>r.maxElevation||a[2]<r.minElevation)return null}else{let t=(r.maxElevation-a[2])/h,i=(r.minElevation-a[2])/h;if((u=Math.max(u,Math.min(t,i)))>(d=Math.min(d,Math.max(t,i))))return null}let _=Math.hypot(n,l),p=(0,m.Bn)(Math.ceil(_*(d-u)/4),1,512),f=0,g=!ii(c,0);for(let t=0;t<=p;t++){let i=u+(d-u)*t/p;if(g){if(ii(c,i)){let{lo:t,hi:r}=t7(c,ii,f,i,.001/_),o=it(c,t),u=it(c,r),d=a[2]+t*h-o.elevation,p=a[2]+r*h-u.elevation,g=o.covered&&d>p?(0,m.Bn)(t+d*(r-t)/(d-p),t,r):r;return new m.nt((a[0]+g*n)/s,(a[1]+g*l)/s,it(c,g).elevation)}}else g=!ii(c,i);f=i}return null}getRaySegmentFromPixel(t){let i=[t.x,t.y,0,1],r=[t.x,t.y,1,1];(0,m.Yr)(i,i,this._pixelMatrixInverse),(0,m.Yr)(r,r,this._pixelMatrixInverse);let a=i[3],o=r[3],s=this.elevation;return{near:[i[0]/a,i[1]/a,i[2]/a+s],far:[r[0]/o,r[1]/o,r[2]/o+s]}}screenPointToMercatorCoordinateAtZ(t,i){let r=i||0,{near:a,far:o}=this.getRaySegmentFromPixel(t),s=a[2]===o[2]?0:(r+this.elevation-a[2])/(o[2]-a[2]);return new m.nt(m.un.number(a[0],o[0],s)/this.worldSize,m.un.number(a[1],o[1],s)/this.worldSize,r)}coordinatePoint(t,i=0,r=this._pixelMatrix){let a=this._coordinateClipPoint(t,i,r),o=a[3];return o>0?new m.Li(a[0]/o,a[1]/o):this._offScreenPointBehindCamera(a[0],a[1],o)}_coordinateClipPoint(t,i,r){let a=[t.x*this.worldSize,t.y*this.worldSize,i,1];return(0,m.Yr)(a,a,r)}_offScreenPointBehindCamera(t,i,r){let a=this.width/2,o=this.height/2,s=t-a*r,n=i-o*r;0===s&&0===n&&(n=1);let l=a+this.width,h=o+this.height,c=Math.min(0===s?1/0:l/Math.abs(s),0===n?1/0:h/Math.abs(n));return new m.Li(a+s*c,o+n*c)}getBounds(){let t=Math.max(0,this._helper._height/2-(0,m.Z)(this));return new ey().extend(this.screenPointToLocation(new m.Li(0,t))).extend(this.screenPointToLocation(new m.Li(this._helper._width,t))).extend(this.screenPointToLocation(new m.Li(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new m.Li(0,this._helper._height)))}
812isPointOnMapSurface(t,i){return i?null!=this.screenTerrainPointToMercatorCoordinate(t,i):t.y>this.height/2-(0,m.Z)(this)}calculatePosMatrix(t,i=!1,r=!1){let a=t.key??(0,m.p)(t.wrap,t.canonical.z,t.canonical.z,t.canonical.x,t.canonical.y),o=i?this._alignedPosMatrixCache:this._posMatrixCache;if(o.has(a)){let t=o.get(a);return r?t.f32:t.f64}let s=(0,m.q)(t,this.worldSize);(0,m.wi)(s,i?this._alignedProjMatrix:this._viewProjMatrix,s);let n={f64:s,f32:new Float32Array(s)};return o.set(a,n),r?n.f32:n.f64}calculateFogMatrix(t){let i=t.key,r=this._fogMatrixCacheF32;if(r.has(i))return r.get(i);let a=(0,m.q)(t,this.worldSize);return(0,m.wi)(a,this._fogMatrix,a),r.set(i,new Float32Array(a)),r.get(i)}calculateCenterFromCameraLngLatAlt(t,i,r,a){return this._helper.calculateCenterFromCameraLngLatAlt(t,i,r,a)}calculateCameraOptionsFromTo(t,i,r,a){let o=m.nt.fromLngLat(t,i),s=m.nt.fromLngLat(r,a),n=s.x-o.x,l=s.y-o.y,h=s.z-o.z,c=Math.hypot(n,l,h);if(0===c)throw Error("Can't calculate camera options with same From and To");let u=Math.hypot(n,l),d=(0,m.Dr)(this.cameraToCenterDistance/c/this.tileSize),_=(0,m.xr)(Math.atan2(n,-l)),p=(0,m.xr)(Math.acos(u/c));return p=h<0?90-p:90+p,{center:s.toLngLat(),elevation:a,zoom:d,pitch:p,bearing:_}}_calculateNearFarZ(t,i,r){let a=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),o=t-a*this._helper._pixelPerMeter/Math.cos(i),s=a<0?o:t,n=Math.PI/2+this.pitchInRadians,l=(0,m.Yn)(this.fov)*(Math.abs(Math.cos((0,m.Yn)(this.roll)))*this.height+Math.abs(Math.sin((0,m.Yn)(this.roll)))*this.width)/this.height*(.5+r.y/this.height),h=Math.sin(l)*s/Math.sin((0,m.Bn)(Math.PI-n-l,.01,Math.PI-.01)),c=(0,m.Z)(this),u=Math.atan(c/this._helper.cameraToCenterDistance),d=(0,m.Yn)(90-m.Q),_=u>d?2*u*(.5+r.y/(2*c)):d,p=Math.min(h,Math.sin(_)*s/Math.sin((0,m.Bn)(Math.PI-n-_,.01,Math.PI-.01)));this._helper._farZ=(Math.cos(Math.PI/2-i)*p+s)*1.01,this._helper._nearZ=this._helper._height/50}_calcMatrices(t=this._helper.autoCalculateNearFarZ){var i,r;let a,o=this.centerOffset,s=(0,m.$)(this.worldSize,this.center),n=s.x,l=s.y,h=(0,m.Yn)(Math.min(this.pitch,m.Q)),c=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(h));t&&this._calculateNearFarZ(c,h,o),a=new Float64Array(16),(0,m.Ei)(a,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),i=this._invProjMatrix,r=a,i[0]=1/r[0],i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=1/r[5],i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=0,i[11]=1/r[14],i[12]=0,i[13]=0,i[14]=-1,i[15]=r[10]/r[14],a[8]=-(2*o.x)/this._helper._width,a[9]=2*o.y/this._helper._height,this._projectionMatrix=(0,m.gi)(a),(0,m.Ai)(a,a,[1,-1,1]),(0,m.ji)(a,a,[0,0,-this._helper.cameraToCenterDistance]),(0,m.ki)(a,a,-this.rollInRadians),(0,m.Di)(a,a,this.pitchInRadians),(0,m.ki)(a,a,-this.bearingInRadians),(0,m.ji)(a,a,[-n,-l,0]),this._mercatorMatrix=(0,m.Ai)([],a,[this.worldSize,this.worldSize,this.worldSize]),(0,m.Ai)(a,a,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=(0,m.wi)(new Float64Array(16),this.clipSpaceToPixelsMatrix,a),(0,m.ji)(a,a,[0,0,-this.elevation]),this._viewProjMatrix=a,this._invViewProjMatrix=(0,m.Ci)([],a);let u=[0,0,-1,1];(0,m.Yr)(u,u,this._invViewProjMatrix),this._cameraPosition=[u[0]/u[3],u[1]/u[3],u[2]/u[3]],this._fogMatrix=new Float64Array(16),(0,m.Ei)(this._fogMatrix,this.fovInRadians,this.width/this.height,c,this._helper._farZ),this._fogMatrix[8]=-(2*o.x)/this.width,this._fogMatrix[9]=2*o.y/this.height,(0,m.Ai)(this._fogMatrix,this._fogMatrix,[1,-1,1]),(0,m.ji)(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),(0,m.ki)(this._fogMatrix,this._fogMatrix,-this.rollInRadians),(0,m.Di)(this._fogMatrix,this._fogMatrix,this.pitchInRadians),(0,m.ki)(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),(0,m.ji)(this._fogMatrix,this._fogMatrix,[-n,-l,0]),(0,m.Ai)(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),(0,m.ji)(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=(0,m.wi)(new Float64Array(16),this.clipSpaceToPixelsMatrix,a);let d=this._helper._width%2/2,_=this._helper._height%2/2,p=Math.cos(this.bearingInRadians),f=Math.sin(-this.bearingInRadians),g=n-Math.round(n)+p*d+f*_,v=l-Math.round(l)+p*_+f*d,y=new Float64Array(a);if((0,m.ji)(y,y,[g>.5?g-1:g,v>.5?v-1:v,0]),this._alignedProjMatrix=y,!(a=(0,m.Ci)(new Float64Array(16),this._pixelMatrix)))throw Error("failed to invert matrix");this._pixelMatrixInverse=a,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;let t=this.screenPointToMercatorCoordinate(new m.Li(0,0)),i=[t.x*this.worldSize,t.y*this.worldSize,0,1];return(0,m.Yr)(i,i,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this.cameraToCenterDistance/this.pixelsPerMeter+this.elevation}getCameraLngLat(){let t=(0,m.ct)(1,this.center.lat)*this.worldSize,i=this._helper.cameraToCenterDistance/t;return(0,m.X)(this.center,this.elevation,this.pitch,this.bearing,i).toLngLat()}getProjectionData(t){let{overscaledTileID:i,aligned:r,applyTerrainMatrix:a}=t,o=this._helper.getMercatorTileCoordinates(i),s=i?this.calculatePosMatrix(i,r,!0):null,n;return{mainMatrix:n=i?.terrainRttPosMatrix32f&&a?i.terrainRttPosMatrix32f:s||(0,m.Hn)(),tileMercatorCoords:o,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:n,clipAntimeridian:!1}}isLocationOccluded(t,i,r){if(!i?.getCoverageIndex())return!1;let a=m.nt.fromLngLat(t);r??=i.getElevationForLngLat(t,this);let o=this._coordinateClipPoint(a,r,this._pixelMatrix3D),s=o[3];if(s<=0||o[2]>s)return!0;let n=new m.Li(o[0]/s,o[1]/s),l=this.screenTerrainPointToMercatorCoordinate(n,i);if(null==l)return!1;let h=this.getRaySegmentFromPixel(n),c=ir(h,a.x*this.worldSize,a.y*this.worldSize,r);return ir(h,l.x*this.worldSize,l.y*this.worldSize,l.z)<.99*c}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(t,i,r){return 1}transformLightDirection(t){return(0,m.Zr)(t)}getRayDirectionFromPixel(t){throw Error("Not implemented.")}projectTileCoordinates(t,i,r,a){let o=this.calculatePosMatrix(r),s;null==a?tf(s=[t,i,0,1],s,o):(s=[t,i,a,1],(0,m.Yr)(s,s,o));let n=s[3];return{point:new m.Li(s[0]/n,s[1]/n),signedDistanceFromCamera:n,isOccluded:!1}}populateCache(t){for(let i of t)this.calculatePosMatrix(i)}getProjectionDataForCustomLayer(t=!0){let i=new m.d(0,0,0,0,0),r=this.getProjectionData({overscaledTileID:i,applyGlobeMatrix:t}),a=(0,m.q)(i,this.worldSize);(0,m.wi)(a,this._viewProjMatrix,a);let o=[m.Lr,m.Lr,this.worldSize/this._helper.pixelsPerMeter],s=(0,m.Wn)();return(0,m.Ai)(s,a,o),{...r,tileMercatorCoords:[0,0,1,1],fallbackMatrix:s,mainMatrix:s}}getFastPathSimpleProjectionMatrix(t){return this.calculatePosMatrix(t)}};function it(t,i){return t8(t.index,t.exaggeration,(t.near[0]+i*t.dx)/t.worldSize,(t.near[1]+i*t.dy)/t.worldSize)}function ii(t,i){return t9(it(t,i),t.near[2]+i*t.dz)}function ir({near:t,far:i},r,a,o){let s=i[0]-t[0],n=i[1]-t[1],l=i[2]-t[2];return((r-t[0])*s+(a-t[1])*n+(o-t[2])*l)/(s*s+n*n+l*l)}function ia(){(0,m.Nr)("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function io(t){if(t.useSlerp)if(t.k<1){let i=(0,m.Er)(t.startEulerAngles.roll,t.startEulerAngles.pitch,t.startEulerAngles.bearing),r=(0,m.Er)(t.endEulerAngles.roll,t.endEulerAngles.pitch,t.endEulerAngles.bearing),a=new Float64Array(4);(0,m.Kr)(a,i,r,t.k);let o=(0,m.sr)(a);t.tr.setRoll(o.roll),t.tr.setPitch(o.pitch),t.tr.setBearing(o.bearing)}else t.tr.setRoll(t.endEulerAngles.roll),t.tr.setPitch(t.endEulerAngles.pitch),t.tr.setBearing(t.endEulerAngles.bearing);else t.tr.setRoll(m.un.number(t.startEulerAngles.roll,t.endEulerAngles.roll,t.k)),t.tr.setPitch(m.un.number(t.startEulerAngles.pitch,t.endEulerAngles.pitch,t.k)),t.tr.setBearing(m.un.number(t.startEulerAngles.bearing,t.endEulerAngles.bearing,t.k))}function is(t,i,r,a,o){let s=o.padding,n=(0,m.$)(o.worldSize,r.getNorthWest()),l=(0,m.$)(o.worldSize,r.getNorthEast()),h=(0,m.$)(o.worldSize,r.getSouthEast()),c=(0,m.$)(o.worldSize,r.getSouthWest
812()),u=(0,m.Yn)(-a),d=n.rotate(u),_=l.rotate(u),p=h.rotate(u),f=c.rotate(u),g=new m.Li(Math.max(d.x,_.x,f.x,p.x),Math.max(d.y,_.y,f.y,p.y)),v=new m.Li(Math.min(d.x,_.x,f.x,p.x),Math.min(d.y,_.y,f.y,p.y)),y=g.sub(v),x=o.width-(s.left+s.right+i.left+i.right),b=o.height-(s.top+s.bottom+i.top+i.bottom),w=x/y.x,T=b/y.y;if(T<0||w<0)return void ia();let P=Math.min((0,m.Dr)(o.scale*Math.min(w,T)),t.maxZoom),M=m.Li.convert(t.offset),I=(i.left-i.right)/2,C=(i.top-i.bottom)/2,S=new m.Li(I,C).rotate((0,m.Yn)(a)),E=M.add(S).mult(o.scale/(0,m.Fr)(P));return{center:(0,m.tt)(o.worldSize,n.add(h).div(2).sub(E)),zoom:P,bearing:a}}var il=class{get useGlobeControls(){return!1}handlePanInertia(t,i){let r=t.mag(),a=Math.abs((0,m.Z)(i));return{easingOffset:t.mult(Math.min(.75*a/r,1)),easingCenter:i.center}}handleMapControlsRollPitchBearingZoom(t,i){t.bearingDelta&&i.setBearing(i.bearing+t.bearingDelta),t.pitchDelta&&i.setPitch(i.pitch+t.pitchDelta),t.rollDelta&&i.setRoll(i.roll+t.rollDelta),t.zoomDelta&&i.setZoom(i.zoom+t.zoomDelta)}handleMapControlsPan(t,i,r){.01>t.around.distSqr(i.centerPoint)||i.setLocationAtPoint(r,t.around,t.aroundElevation)}cameraForBoxAndBearing(t,i,r,a,o){return is(t,i,r,a,o)}handleJumpToCenterZoom(t,i){let r=void 0===i.zoom?t.zoom:+i.zoom;t.zoom!==r&&t.setZoom(+i.zoom),void 0!==i.center&&t.setCenter(m.lt.convert(i.center))}handleEaseTo(t,i){let r=t.zoom,a=t.padding,o={roll:t.roll,pitch:t.pitch,bearing:t.bearing},s={roll:void 0===i.roll?t.roll:i.roll,pitch:void 0===i.pitch?t.pitch:i.pitch,bearing:void 0===i.bearing?t.bearing:i.bearing},n=void 0!==i.zoom,l=!t.isPaddingEqual(i.padding),h=!1,c=n?+i.zoom:t.zoom,u=t.centerPoint.add(i.offsetAsPoint),d=t.screenPointToLocation(u),{center:_,zoom:p}=t.applyConstrain(m.lt.convert(i.center||d),c??r);tJ(t,_);let f=(0,m.$)(t.worldSize,d),g=(0,m.$)(t.worldSize,_).sub(f),v=(0,m.Fr)(p-r);return{easeFunc:n=>{if(h&&t.setZoom(m.un.number(r,p,n)),(0,m.Tr)(o,s)||io({startEulerAngles:o,endEulerAngles:s,tr:t,k:n,useSlerp:o.roll!=s.roll}),l&&(t.interpolatePadding(a,i.padding,n),u=t.centerPoint.add(i.offsetAsPoint)),i.around)t.setLocationAtPoint(i.around,i.aroundPoint);else{let i=(0,m.Fr)(t.zoom-r),a=(p>r?Math.min(2,v):Math.max(.5,v))**(1-n),o=(0,m.tt)(t.worldSize,f.add(g.mult(n*a)).mult(i));t.setLocationAtPoint(t.renderWorldCopies?o.wrap():o,u)}},isZooming:h=p!==r,elevationCenter:_}}handleFlyTo(t,i){let r=void 0!==i.zoom,a=t.zoom,o=t.applyConstrain(m.lt.convert(i.center||i.locationAtOffset),r?+i.zoom:a),s=o.center,n=o.zoom;tJ(t,s);let l=t.worldSize,h=(0,m.$)(l,i.locationAtOffset),c=(0,m.$)(l,s).sub(h),u=c.mag(),d=(0,m.Fr)(n-a),_=Math.min(Math.max(void 0===i.minZoom?t.minZoom:+i.minZoom,t.minZoom),a,n),p=t.applyConstrain(s,_).zoom;return{easeFunc:(i,r,o,u)=>{t.setZoom(1===i?n:a+(0,m.Dr)(r));let d=1===i?s:(0,m.tt)(l,h.add(c.mult(o)));t.setLocationAtPoint(t.renderWorldCopies?d.wrap():d,u)},scaleOfZoom:d,targetCenter:s,scaleOfMinZoom:(0,m.Fr)(p-a),pixelPathLength:u}}};let ih=new m.vt({fill:new m._t(128,2),line:new m._t(512,0),tile:new m._t(128,32),stencil:new m._t(128,1),circle:3});var ic=class{constructor(){this._tileMeshCache={}}get name(){return"vertical-perspective"}get transitionState(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return"globe"}get shaderDefine(){return"#define GLOBE"}get shaderPreludeCode(){return tW.projectionGlobe}get vertexShaderPreludeCode(){return tW.projectionMercator.vertexSource}get subdivisionGranularity(){return ih}get useGlobeControls(){return!0}destroy(){}_getMeshKey(t){return`${t.granularity.toString(36)}_${t.generateBorders?"b":""}${t.extendToNorthPole?"n":""}${t.extendToSouthPole?"s":""}`}getMeshFromTileID(t,i,r,a,o){let s=("stencil"===o?ih.stencil:ih.tile).getGranularityForZoomLevel(i.z),n=0===i.y&&a,l=i.y===(1<<i.z)-1&&a;return this._getMesh(t,{granularity:s,generateBorders:r,extendToNorthPole:n,extendToSouthPole:l})}_getMesh(t,i){let r=this._getMeshKey(i);if(r in this._tileMeshCache)return this._tileMeshCache[r];let a=eA(t,i);return this._tileMeshCache[r]=a,a}recalculate(t){}hasTransition(){return!1}},iu=class extends m.vn{constructor(t,i){super(),this._transitionable=new m.$t(d||=new m.Qt({type:new m.Zt(m.hn.projection.type,"type")}),"projection",i),this.setProjection(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new m.en(0)),this._mercatorProjection=new tY,this._verticalPerspectiveProjection=new ic}get transitionState(){let t=this.properties.get("type");if("string"==typeof t&&"mercator"===t)return 0;if("string"==typeof t&&"vertical-perspective"===t)return 1;if(t instanceof m.dn){if(t.from===t.to)return+("mercator"!==t.from);if("vertical-perspective"===t.from&&"mercator"===t.to)return 1-t.transition;if("mercator"===t.from&&"vertical-perspective"===t.to)return t.transition}return 1}get useGlobeRendering(){return this.transitionState>0}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}getMeshFromTileID(t,i,r,a,o){return this.currentProjection.getMeshFromTileID(t,i,r,a,o)}setProjection(t){this._transitionable.setValue("type",t?.type||"mercator")}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}};function id(t){return 2*Math.PI*im(t.worldSize,t.center.lat)}function i_(t,i,r,a,o){let s=1/(1<<o),n=t/m.Lr*s+r*s,l=i/m.Lr*s+a*s,h=(0,m.gr)(n*Math.PI*2+Math.PI,2*Math.PI),c=2*Math.atan(Math.exp(Math.PI-l*Math.PI*2))-.5*Math.PI,u=Math.cos(c),d=new Float64Array(3);return d[0]=Math.sin(h)*u,d[1]=Math.sin(c),d[2]=Math.cos(h)*u,d}function ip(t){var i,r;let a,o;return i=t.lng*Math.PI/180,a=Math.cos(r=t.lat*Math.PI/180),(o=new Float64Array(3))[0]=Math.sin(i)*a,o[1]=Math.sin(r),o[2]=Math.cos(i)*a,o}function im(t,i){return t/(2*Math.PI)/Math.cos(i*Math.PI/180)}function ig(t){let i=(0,m.Yr)((0,m.Kn)(),[0,0,0,1],t.modelViewProjectionMatrix);return(0,m.Yr)(i,i,t.inverseProjectionMatrix),[i[0]/i[3],i[1]/i[3],i[2]/i[3]]}function iv(t){let i=Math.asin(t[1])/Math.PI*180,r=Math.sqrt(t[0]*t[0]+t[2]*t[2]);if(r>1e-6){let a=t[0]/r,o=Math.acos(t[2]/r),s=(a>0?o:-o)/Math.PI*180;return new m.lt((0,m.Pr)(s,-180,180),i)}return new m.lt(0,i)}let iy=.98*Math.PI;function ix(t,i){let r=t.cameraPosition,a=(0,m.ni)(r);if(a<=1)return t.screenPointToLocation(i);let o=(0,m.Gn)();(0,m.ii)(o,r);let s=t.getRayDirectionFromPixel(i),n=-(0,m.ei)(s,o),l=(0,m.Gn)();(0,m.li)(l,s,o,n);let h=(0,m.ni)(l);if(h<1e-9)return t.screenPointToLocation(i);let c=Math.atan2(h,n),u=.9*Math.asin(1/a);if(c<u)return t.screenPointToLocation(i);let d=a*Math.sin(u),_=Math.asin((0,m.Bn)(d,-1,1))-u,p=a*Math.cos(u)/Math.sqrt(Math.max(1-d*d,1e-12))-1,f=iy-_,g=c-u,v=_+p*g*f/(f+p*g),y=(0,m.Gn)();(0,m.ci)(y,l,1/h);let x=(0,m.Gn)();return(0,m.ci)(x,o,Math.cos((0,m.Bn)(v,0,iy))),(0,m.li)(x,x,y,Math.sin((0,m.Bn)(v,0,iy))),(0,m.ii)(x,x),iv(x)}function ib(t){return Math.cos(t*Math.PI/180)}function iw(t,i){let r=ib(t),a=ib(i);return(0,m.Dr)(a/r)}function iT(t){let i=.5*t,r=Math.sin(i),a=Math.cos(i);return Math.log(r+a)-Math.log(a-r)}function iP(t,i,r,a){let o=t.lat+r*a;if(Math.abs(r)>1){let s=(Math.sign(t.lat+r)===Math.sign(t.lat)?Math.abs(t.lat):-Math.abs(t.lat))*Math.PI/180,n=Math.abs(t.lat+r)*Math.PI/180,l=iT(s+a*(n-s)),h=iT(s),c=iT(n),u=t.lng+(l-h)/(c-h)*i;return new m.lt(u,o)}{let r=t.lng+i*a;return new m.lt(r,o)}}function iM(t,i,r=1){let a=(0,m.ei)(t,i),o=r*r,s=(0,m.Gn)(),n=(0,m.Gn)();(0,m.ci)(n,i,a),(0,m.ui)(s,t,n);let l=o-(0,m.ei)(s,s);if(l<0)return null;let h=(0,m.ei)(t,t)-o,c=-a+(a<0?1:-1)*Math.sqrt(l),u=h/c;return{tMin:Math.min(u,c),tMax:Math.max(u,c)}}var iI=class{constructor(t){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=t}swapBuffers(){if(!this._hadAnyChanges)return;let t=this._cachePrevious;this._cachePrevious=this._cache,this._cache=t,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(t,i,r,a){let o=`${t.z}_${t.x}_${t.y}_${a?.terrain?"t":""}_${Math.round(r)}`,s=this._cache.get(o);if(s)return s;let n=this._cachePrevious.get(o);if(n)return this._cache.set(o,n),n;let l=this._boundingVolumeFactory(t,i,r,a);return this._cache.set(o,l),this._hadAnyChanges=!0,l}},iC=class t{constructor(t,i,r,a){this.min=r,this.max=a,this.points=t,this.planes=i}static fromAabb(i,r){let a=[];for(let t=0;t<8;t++)a.push([((0|t)&1)==1?r[0]:i[0],(t>>1&1)==1?r[1]:i[1],(t>>2&1)==1?r[2]:i[2]]);return new t(a,[[-1,0,0,r[0]],[1,0,0,-i[0]],[0,-1,0,r[1]],[0,1,0,-i[1]],[0,0,-1,r[2]],[0,0,1,-i[2]]],i,r)}static fromCenterSizeAngles(i,r,a){let o=(0,m.Ur)([],a[0],a[1],a[2]),s=(0,m.mi)([],[r[0],0,0],o),n=(0,m.mi)([],[0,r[1],0],o),l=(0,m.mi)([],[0,0,r[2]],o),h=[...i],c=[...i];for(let t=0;t<8;t++)for(let r=0;r<3;r++){let a=i[r]+s[r]*(((0|t)&1)==1?1:-1)+n[r]*((t>>1&1)==1?1:-1)+l[r]*((t>>2&1)==1?1:-1);h[r]=Math.min(h[r],a),c[r]=Math.max(c[r],a)}let u=[];for(let t=0;t<8;t++){let r=[...i];(0,m.Xr)(r,r,(0,m.ci)([],s,((0|t)&1)==1?1:-1)),(0,m.Xr)(r,r,(0,m.ci)([],n,(t>>1&1)==1?1:-1)),(0,m.Xr)(r,r,(0,m.ci)([],l,(t>>2&1)==1?1:-1)),u.push(r)}return new t(u,[[...s,-(0,m.ei)(s,u[0])],[...n,-(0,m.ei)(n,u[0])],[...l,-(0,m.ei)(l,u[0])],[-s[0],-s[1],-s[2],-(0,m.ei)(s,u[7])],[-n[0],-n[1],-n[2],-(0,m.ei)(n,u[7])],[-l[0],-l[1],-l[2],-(0,m.ei)(l,u[7])]],h,c)}intersectsFrustum(t){let i=!0,r=this.points.length,a=this.planes.length,o=t.planes.length,s=t.points.length;for(let a=0;a<o;a++){let o=t.planes[a],s=0;for(let t=0;t<r;t++){let i=this.points[t];o[0]*i[0]+o[1]*i[1]+o[2]*i[2]+o[3]>=0&&s++}if(0===s)return 0;s<r&&(i=!1)}if(i)return 2;for(let i=0;i<a;i++){let r=this.planes[i],a=0;for(let i=0;i<s;i++){let o=t.points[i];r[0]*o[0]+r[1]*o[1]+r[2]*o[2]+r[3]>=0&&a++}if(0===a)return 0}return 1}intersectsPlane(t){let i=this.points.length,r=0;for(let a=0;a<i;a++){let i=this.points[a];t[0]*i[0]+t[1]*i[1]+t[2]*i[2]+t[3]>=0&&r++}return r===i?2:+(0!==r)}};function iS(t,i,r){let a=t-i;return a<0?-a:Math.max(0,a-r)}function iE(t,i,r,a,o){let s=t-r;return Math.max(s<0?Math.min(-s,1+s-o):s>o?Math.min(Math.max(s-o,0),1-s):0,iS(i,a,o))}var iz=class{constructor(){this._boundingVolumeCache=new iI(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(t,i,r,a){let o=1<<r.z,s=1/o,n=r.x/o,l=r.y/o;return Math.min(Math.min(Math.min(2,iE(t,i,n,l,s)),iE(t,i,n+.5,-l-s,s)),iE(t,i,n+.5,2-l-s,s))}getWrap(t,i,r){let a=1<<i.z,o=1/a,s=i.x/a,n=iS(t.x,s,o),l=iS(t.x,s-1,o),h=iS(t.x,s+1,o),c=Math.min(n,l,h);return c===h?1:c===l?-1:0}allowVariableZoom(t,i){return eJ(t,i)>4}allowWorldCopies(){return!1}getTileBoundingVolume(t,i,r,a){return this._boundingVolumeCache.getTileBoundingVolume(t,i,r,a)}_computeTileBoundingVolume(t,i,r,a){let o=Math.min(0,r),s=Math.max(0,r);if(a?.terrain){let r=new m.d(t.z,i,t.z,t.x,t.y),n=a.terrain.getMinMaxElevation(r);o=n.minElevation??o,s=Math.max(n.maxElevation??s,s)}if(o/=m.ut,s/=m.ut,o+=1,s+=1,t.z<=0)return iC.fromAabb([-s,-s,-s],[s,s,s]);if(1===t.z)return iC.fromAabb([0===t.x?-s:0,0===t.y?0:-s,-s],[0===t.x?0:s,0===t.y?s:0,s]);{let i=[i_(0,0,t.x,t.y,t.z),i_(m.Lr,0,t.x,t.y,t.z),i_(m.Lr,m.Lr,t.x,t.y,t.z),i_(0,m.Lr,t.x,t.y,t.z)],r=[];for(let t of i)r.push((0,m.ci)([],t,s));if(s!==o)for(let t of i)r.push((0,m.ci)([],t,o));0===t.y&&r.push([0,1,0]),t.y===(1<<t.z)-1&&r.push([0,-1,0]);let a=[1,1,1],n=[-1,-1,-1];for(let t of r)for(let i=0;i<3;i++)a[i]=Math.min(a[i],t[i]),n[i]=Math.max(n[i],t[i]);let l=i_(m.Lr/2,m.Lr/2,t.x,t.y,t.z),h=(0,m.Qr)([],[0,1,0],l);(0,m.ii)(h,h);let c=(0,m.Qr)([],l,h);(0,m.ii)(c,c);let u=(0,m.Qr)([],i[2],i[1]);(0,m.ii)(u,u);let d=(0,m.Qr)([],i[0],i[3]);(0,m.ii)(d,d),r.push((0,m.ci)([],l,s)),t.y>=(1<<t.z)/2&&r.push((0,m.ci)([],i_(m.Lr/2,0,t.x,t.y,t.z),s)),t.y<(1<<t.z)/2&&r.push((0,m.ci)([],i_(m.Lr/2,m.Lr,t.x,t.y,t.z),s));let _=iR(l,r),p=iR(c,r),f=[-l[0],-l[1],-l[2],_.max],g=[l[0],l[1],l[2],-_.min],v=[-c[0],-c[1],-c[2],p.max],y=[c[0],c[
8121],c[2],-p.min],x=[...u,0],b=[...d,0],w=[];return 0===t.y?w.push((0,m.Ar)(b,x,f),(0,m.Ar)(b,x,g)):w.push((0,m.Ar)(v,x,f),(0,m.Ar)(v,x,g),(0,m.Ar)(v,b,f),(0,m.Ar)(v,b,g)),t.y===(1<<t.z)-1?w.push((0,m.Ar)(b,x,f),(0,m.Ar)(b,x,g)):w.push((0,m.Ar)(y,x,f),(0,m.Ar)(y,x,g),(0,m.Ar)(y,b,f),(0,m.Ar)(y,b,g)),new iC(w,[f,g,v,y,x,b],a,n)}}};function iR(t,i){let r=1/0,a=-1/0;for(let o of i){let i=(0,m.ei)(t,o);r=Math.min(r,i),a=Math.max(a,i)}return{min:r,max:a}}var iD=class t{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,i,r){this._helper.interpolatePadding(t,i,r)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,i){this._helper.resize(t,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,i){this._helper.overrideNearFarZ(t,i)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(t){}constructor(t,i){this._cachedClippingPlane=(0,m.Kn)(),this._projectionMatrix=(0,m.Un)(),this._globeViewProjMatrix32f=(0,m.Hn)(),this._globeViewProjMatrixF64=(0,m.Un)(),this._globeViewProjMatrixF64Inverted=(0,m.Un)(),this._globeProjMatrixInverted=(0,m.Un)(),this._cameraPosition=(0,m.Gn)(),this.defaultConstrain=(t,i)=>{let r=(0,m.Bn)(t.lat,-m.Fn,m.Fn),a=(0,m.Bn)(+i,this.minZoom+iw(0,r),this.maxZoom);return{center:new m.lt(t.lng,r),zoom:a}},this.applyConstrain=(t,i)=>this._helper.applyConstrain(t,i),this._helper=i??new t0({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(t,i)=>this.defaultConstrain(t,i)},t),this._coveringTilesDetailsProvider=new iz}clone(){let i=new t;return i.apply(this,!1),i}apply(t,i){this._helper.apply(t,i)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixF64}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){let t=(0,m.Gn)();return t[0]=this._cameraPosition[0],t[1]=this._cameraPosition[1],t[2]=this._cameraPosition[2],t}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(t){let{overscaledTileID:i,applyGlobeMatrix:r}=t,a=this._helper.getMercatorTileCoordinates(i);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:a,clippingPlane:this._cachedClippingPlane,projectionTransition:+!!r,fallbackMatrix:this._globeViewProjMatrix32f,clipAntimeridian:i?.canonical.z===0}}_computeClippingPlane(t){let i=this.pitchInRadians,r=this.cameraToCenterDistance/t,a=Math.sin(i)*r,o=Math.cos(i)*r+1,s=1/Math.sqrt(a*a+o*o)*1,n=-a,l=o,h=Math.sqrt(n*n+l*l),c=[0,n/=h,l/=h];(0,m.si)(c,c,[0,0,0],-this.bearingInRadians),(0,m.ai)(c,c,[0,0,0],-1*this.center.lat*Math.PI/180),(0,m.oi)(c,c,[0,0,0],this.center.lng*Math.PI/180);let u=1/(0,m.ni)(c);return(0,m.ci)(c,c,u),[...c,-s*u]}isLocationOccluded(t,i,r){let a=i?.getCoverageIndex();r??=a?i.getElevationForLngLat(t,this):0;let o=iF(t,r);if(!this.isSurfacePointVisible(o))return!0;
812if(!a)return!1;let s=this._projectSurfacePointToScreen(o),n=this.cameraPosition,l=this.getRayDirectionFromPixel(s),h=ik(n,l,o);if(h<=0)return!0;let c=this.screenTerrainPointToMercatorCoordinate(s,i);return null!=c&&ik(n,l,iF(c.toLngLat(),c.z))<.99*h}transformLightDirection(t){let i=this._helper._center.lng*Math.PI/180,r=this._helper._center.lat*Math.PI/180,a=Math.cos(r),o=[Math.sin(i)*a,Math.sin(r),Math.cos(i)*a],s=[o[2],0,-o[0]],n=[0,0,0];(0,m.Qr)(n,s,o),(0,m.ii)(s,s),(0,m.ii)(n,n);let l=[s[0]*t[0]+n[0]*t[1]+o[0]*t[2],s[1]*t[0]+n[1]*t[1]+o[1]*t[2],s[2]*t[0]+n[2]*t[1]+o[2]*t[2]],h=[0,0,0];return(0,m.ii)(h,l),h}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(t,i,r){var a,o;let s=(0,m.et)(t,i,r.canonical),n=(a=s.x,o=s.y,[(0,m.gr)(a*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-o*Math.PI*2))-.5*Math.PI]);return this.getCircleRadiusCorrection()/Math.cos(n[1])}projectTileCoordinates(t,i,r,a){let o,s=r.canonical,n=i_(t,i,s.x,s.y,s.z),l=1+(a??0)/m.ut,h=n[0]*l,c=n[1]*l,u=n[2]*l,d=[h,c,u,1];if((0,m.Yr)(d,d,this._globeViewProjMatrixF64),l<=1){let t=this._cachedClippingPlane;o=t[0]*n[0]+t[1]*n[1]+t[2]*n[2]+t[3]<0}else o=this._isLineOfSightBlocked(h,c,u);return{point:new m.Li(d[0]/d[3],d[1]/d[3]),signedDistanceFromCamera:d[3],isOccluded:o}}_isLineOfSightBlocked(t,i,r){let a=this._cameraPosition,o=t-a[0],s=i-a[1],n=r-a[2],l=o*o+s*s+n*n;if(0===l)return!1;let h=(0,m.Bn)(-(a[0]*o+a[1]*s+a[2]*n)/l,0,1),c=a[0]+h*o,u=a[1]+h*s,d=a[2]+h*n;return c*c+u*u+d*d<1}_calcMatrices(t=this._helper.autoCalculateNearFarZ){let i=im(this.worldSize,this.center.lat),r=(0,m.Wn)();t&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*i),(0,m.Ei)(r,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);let a=this.centerOffset;r[8]=-(2*a.x)/this._helper._width,r[9]=2*a.y/this._helper._height,this._projectionMatrix=(0,m.gi)(r),this._globeProjMatrixInverted=(0,m.Wn)(),(0,m.Ci)(this._globeProjMatrixInverted,r),(0,m.ji)(r,r,[0,0,-this.cameraToCenterDistance]),(0,m.ki)(r,r,this.rollInRadians),(0,m.Di)(r,r,-this.pitchInRadians),(0,m.ki)(r,r,this.bearingInRadians),(0,m.ji)(r,r,[0,0,-i]);let o=(0,m.Gn)();o[0]=i,o[1]=i,o[2]=i,(0,m.Di)(r,r,this.center.lat*Math.PI/180),(0,m.Oi)(r,r,-this.center.lng*Math.PI/180),(0,m.Ai)(r,r,o),this._globeViewProjMatrixF64=r,this._globeViewProjMatrix32f=new Float32Array(r),this._globeViewProjMatrixF64Inverted=(0,m.Wn)(),(0,m.Ci)(this._globeViewProjMatrixF64Inverted,r);let s=(0,m.Gn)();this._cameraPosition=(0,m.Gn)(),this._cameraPosition[2]=this.cameraToCenterDistance/i,(0,m.si)(this._cameraPosition,this._cameraPosition,s,-this.rollInRadians),(0,m.ai)(this._cameraPosition,this._cameraPosition,s,this.pitchInRadians),(0,m.si)(this._cameraPosition,this._cameraPosition,s,-this.bearingInRadians),(0,m.Xr)(this._cameraPosition,this._cameraPosition,[0,0,1]),(0,m.ai)(this._cameraPosition,this._cameraPosition,s,-this.center.lat*Math.PI/180),(0,m.oi)(this._cameraPosition,this._cameraPosition,s,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(i);let n=(0,m.gi)(this._globeViewProjMatrixF64Inverted);(0,m.Ai)(n,n,[1,1,-1]),this._cachedFrustum=eH.fromInvProjectionMatrix(n,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(t){(0,m.Nr)("calculateFogMatrix is not supported on globe projection.");let i=(0,m.Wn)();return(0,m.Si)(i),i}getVisibleUnwrappedCoordinates(t){return[new m.f(0,t)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){if(t)return void(0,m.Nr)("terrain is not fully supported on vertical perspective projection.");this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return((0,m.ni)(this._cameraPosition)-1)*m.ut}getCameraLngLat(){let t=(0,m.Gn)();return(0,m.ii)(t,this._cameraPosition),iv(t)}populateCache(t){}getBounds(){let t=.5*this.width,i=.5*this.height,r=[new m.Li(0,0),new m.Li(t,0),new m.Li(this.width,0),new m.Li(this.width,i),new m.Li(this.width,this.height),new m.Li(t,this.height),new m.Li(0,this.height),new m.Li(0,i)],a=[];for(let t of r)a.push(this.unprojectScreenPoint(t));let o=0,s=0,n=0,l=0,h=this.center;for(let t of a){let i=(0,m.Xn)(h.lng,t.lng),r=(0,m.Xn)(h.lat,t.lat);
812i<s&&(s=i),i>o&&(o=i),r<l&&(l=r),r>n&&(n=r)}let c=[h.lng+s,h.lat+l,h.lng+o,h.lat+n];return this.isSurfacePointOnScreen([0,1,0])&&(c[3]=90,c[0]=-180,c[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(c[1]=-90,c[0]=-180,c[2]=180),new ey(c)}calculateCenterFromCameraLngLatAlt(t,i,r,a){return this._helper.calculateCenterFromCameraLngLatAlt(t,i,r,a)}calculateCameraOptionsFromTo(t,i,r,a){let o=m.lt.convert(r),s=ip(m.lt.convert(t));(0,m.ci)(s,s,1+i/m.ut);let n=ip(o),l=(0,m.ci)((0,m.Gn)(),n,1+a/m.ut),h=(0,m.di)((0,m.Gn)(),s,n),c=(0,m.ni)(h);if(c<1e-12||1e-12>(0,m.$r)(s,l))throw Error("Can't calculate camera options with same From and To");let u=(0,m.Gn)();(0,m.oi)(h,h,u,-(0,m.Yn)(o.lng)),(0,m.ai)(h,h,u,(0,m.Yn)(o.lat));let d=(0,m.xr)(Math.acos((0,m.Bn)(h[2]/c,-1,1))),_=Math.hypot(h[0],h[1])<1e-9*c?this.bearing:(0,m.xr)(Math.atan2(-h[0],-h[1]));return{center:o,elevation:a,zoom:(0,m.Dr)(this.cameraToCenterDistance/c/im(this.tileSize,o.lat)),pitch:d,bearing:_}}setLocationAtPoint(t,i,r){let a=ip(this.unprojectScreenPoint(i)),o=ip(t),s=(0,m.Gn)();(0,m.hi)(s);let n=(0,m.Gn)();(0,m.oi)(n,a,s,-this.center.lng*Math.PI/180),(0,m.ai)(n,n,s,this.center.lat*Math.PI/180);let l=o[0]*o[0]+o[2]*o[2],h=n[0]*n[0];if(l<h)return;let c=Math.sqrt(l-h),u=(0,m.In)(o[0],o[2],n[0],c),d=(0,m.In)(o[0],o[2],n[0],-c),_=(0,m.Gn)();(0,m.oi)(_,o,s,-u);let p=(0,m.In)(_[1],_[2],n[1],n[2]),f=(0,m.Gn)();(0,m.oi)(f,o,s,-d);let g=(0,m.In)(f[1],f[2],n[1],n[2]),v=.5*Math.PI,y=p>=-v&&p<=v,x=g>=-v&&g<=v,b,w;if(y&&x){let t=this.center.lng*Math.PI/180,i=this.center.lat*Math.PI/180;(0,m.Zn)(u,t)+(0,m.Zn)(p,i)<(0,m.Zn)(d,t)+(0,m.Zn)(g,i)?(b=u,w=p):(b=d,w=g)}else if(y)b=u,w=p;else{if(!x)return;b=d,w=g}let T=b/Math.PI*180,P=w/Math.PI*180,M=this.center.lat;this.setCenter(new m.lt(T,(0,m.Bn)(P,-90,90))),this.setZoom(this.zoom+iw(M,this.center.lat))}locationToScreenPoint(t,i){let r=ip(t);if(i){let a=i.getElevationForLngLatZoom(t,this._helper._tileZoom);(0,m.ci)(r,r,1+a/m.ut)}return this._projectSurfacePointToScreen(r)}_projectSurfacePointToScreen(t){let i=(0,m.Kn)();return(0,m.Yr)(i,[...t,1],this._globeViewProjMatrixF64),i[0]/=i[3],i[1]/=i[3],new m.Li((.5*i[0]+.5)*this.width,(-(.5*i[1])+.5)*this.height)}screenPointToMercatorCoordinate(t,i){if(i){let r=this.screenTerrainPointToMercatorCoordinate(t,i);if(r)return r}return m.nt.fromLngLat(this.unprojectScreenPoint(t))}screenTerrainPointToMercatorCoordinate(t,i){let r=i.getCoverageIndex();if(!r)return null;let a=this.cameraPosition,o=this.getRayDirectionFromPixel(t),s=iM(a,o,1+r.maxElevation/m.ut);if(!s)return null;let n=iM(a,o,1+r.minElevation/m.ut),l=Math.max(s.tMin,0),h=n?n.tMin:s.tMax;if(h<=l)return null;let c={index:r,exaggeration:i.exaggeration,origin:a,direction:o},u=0;for(let t=0;t<=256;t++){let i=l+(h-l)*t/256;if(iA(c,i)){let{hi:t}=t7(c,iA,u,i,1e-12),{sample:r,mercator:a}=iL(c,t);return new m.nt(a.x,a.y,r.elevation)}u=i}return null}screenPointToLocation(t,i){return this.screenPointToMercatorCoordinate(t,i)?.toLngLat()}screenPointToLocationAtElevation(t,i){return this.screenPointToLocation(t)}isPointOnMapSurface(t,i){return!!iM(this._cameraPosition,this.getRayDirectionFromPixel(t))}getRayDirectionFromPixel(t){let i=(0,m.Kn)();i[0]=t.x/this.width*2-1,i[1]=-((t.y/this.height*2-1)*1),i[2]=1,i[3]=1,(0,m.Yr)(i,i,this._globeViewProjMatrixF64Inverted),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3];let r=(0,m.Gn)();r[0]=i[0]-this._cameraPosition[0],r[1]=i[1]-this._cameraPosition[1],r[2]=i[2]-this._cameraPosition[2];let a=(0,m.Gn)();return(0,m.ii)(a,r),a}isSurfacePointVisible(t){let i=this._cachedClippingPlane;return i[0]*t[0]+i[1]*t[1]+i[2]*t[2]+i[3]>=0}isSurfacePointOnScreen(t){if(!this.isSurfacePointVisible(t))return!1;let i=(0,m.Kn)();return(0,m.Yr)(i,[...t,1],this._globeViewProjMatrixF64),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3],i[0]>-1&&i[0]<1&&i[1]>-1&&i[1]<1&&i[2]>-1&&i[2]<1}unprojectScreenPoint(t){var i,r;let a,o,s,n=this._cameraPosition,l=this.getRayDirectionFromPixel(t),h=iM(n,l);if(h){let t=(0,m.Gn)();(0,m.Xr)(t,n,[l[0]*h.tMin,l[1]*h.tMin,l[2]*h.tMin]);let i=(0,m.Gn)();return(0,m.ii)(i,t),iv(i)}let c=this._cachedClippingPlane,u=c[0]*l[0]+c[1]*l[1]+c[2]*l[2],d=-(0,m.br)(c,n)/u,_=(0,m.Gn)();if(d>
8120)(0,m.Xr)(_,n,[l[0]*d,l[1]*d,l[2]*d]);else{let t=(0,m.Gn)();(0,m.Xr)(t,n,[2*l[0],2*l[1],2*l[2]]);let i=(0,m.br)(this._cachedClippingPlane,t);(0,m.ui)(_,t,[this._cachedClippingPlane[0]*i,this._cachedClippingPlane[1]*i,this._cachedClippingPlane[2]*i])}let p=((a=(0,m.Gn)())[0]=-(c[0]*c[3]),a[1]=-(c[1]*c[3]),a[2]=-(c[2]*c[3]),{center:a,radius:Math.sqrt(1-c[3]*c[3])});return iv((i=p.center,r=p.radius,o=(0,m.Gn)(),(0,m.ui)(o,_,i),s=(0,m.Gn)(),(0,m.li)(s,i,o,r/(0,m.ti)(o)),s))}getProjectionDataForCustomLayer(t=!0){let i=this.getProjectionData({overscaledTileID:new m.d(0,0,0,0,0),applyGlobeMatrix:t});return i.tileMercatorCoords=[0,0,1,1],i}getFastPathSimpleProjectionMatrix(t){}};function iL(t,i){let r=(0,m.Gn)();(0,m.li)(r,t.origin,t.direction,i);let a=(0,m.ni)(r),o=(0,m.Gn)();(0,m.ci)(o,r,1/a);let s=iv(o),n=m.nt.fromLngLat(s),l=new m.nt(n.x,(0,m.Bn)(n.y,0,.999999999)),h=t8(t.index,t.exaggeration,l.x,l.y),c=Math.abs(s.lat)>85.051129?0:h.elevation;return{sample:{...h,elevation:c},radius:a,mercator:l}}function iA(t,i){let{sample:r,radius:a}=iL(t,i);return t9(r,(a-1)*m.ut)}function iF(t,i){let r=ip(t);return(0,m.ci)(r,r,1+i/m.ut)}function ik(t,i,r){let a=(0,m.di)((0,m.Gn)(),r,t);return(0,m.ei)(a,i)}var iB=class t{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,i,r){this._helper.interpolatePadding(t,i,r)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,i,r=!0){this._helper.resize(t,i,r)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,i){this._helper.overrideNearFarZ(t,i)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(t){this._globeness=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(t){this._globeness=1,this.defaultConstrain=(t,i)=>this.currentTransform.defaultConstrain(t,i),this.applyConstrain=(t,i)=>this._helper.applyConstrain(t,i),this._helper=new t0({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(t,i)=>this.defaultConstrain(t,i)},t),this._globeness=1,this._mercatorTransform=new ie(void 0,this._helper),this._verticalPerspectiveTransform=new iD(void 0,this._helper)}clone(){let i=new t;return i._globeness=this._globeness,i.apply(this,!1),i}apply(t,i){this._helper.apply(t,i)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(t){let i=this._mercatorTransform.getProjectionData(t),r=this._verticalPerspectiveTransform.getProjectionData(t);return{mainMatrix:this.isGlobeRendering?r.mainMatrix:i.mainMatrix,clippingPlane:r.clippingPlane,tileMercatorCoords:r.tileMercatorCoords,projectionTransition:t.applyGlobeMatrix?this._globeness:0,fallbackMatrix:i.fallbackMatrix,clipAntimeridian:r.clipAntimeridian}}isLocationOccluded(t,i,r){return this.currentTransform.isLocationOccluded(t,i,r)}transformLightDirection(t){return this.currentTransform.transformLightDirection(t)}getPixelScale(){return(0,m.mr)(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return(0,m.mr)(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(t,i,r){let a=this._mercatorTransform.getPitchedTextCorrection(t,i,r),o=this._verticalPerspectiveTransform.getPitchedTextCorrection(t,i,r);return(0,m.mr)(a,o,this._globeness)}projectTileCoordinates(t,i,r,a){return this.currentTransform.projectTileCoordinates(t,i,r,a)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform._calcMatrices(),this._mercatorTransform._calcMatrices(this.autoCalculateNearFarZ&&!this.isGlobeRendering))}calculateFogMatrix(t){return this.currentTransform.calculateFogMatrix(t)}getVisibleUnwrappedCoordinates(t){return this.currentTransform.getVisibleUnwrappedCoordinates(t)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(t){this.currentTransform.recalculateZoomAndCenter(t)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this.currentTransform.getCameraAltitude()}getCameraLngLat(){return this.currentTransform.getCameraLngLat()}populateCache(t){this._mercatorTransform.populateCache(t),this._verticalPerspectiveTransform.populateCache(t)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(t,i,r,a){return this._helper.calculateCenterFromCameraLngLatAlt(t,i,r,a)}calculateCameraOptionsFromTo(t,i,r,a){return this.currentTransform.calculateCameraOptionsFromTo(t,i,r,a)}setLocationAtPoint(t,i,r){this.currentTransform.setLocationAtPoint(t,i,r)}locationToScreenPoint(t,i){return this.currentTransform.locationToScreenPoint(t,i)}screenPointToMercatorCoordinate(t,i){return this.currentTransform.screenPointToMercatorCoordinate(t,i)}screenTerrainPointToMercatorCoordinate(t,i){return this.currentTransform.screenTerrainPointToMercatorCoordinate(t,i)}screenPointToLocation(t,i){return this.currentTransform.screenPointToLocation(t,i)}screenPointToLocationAtElevation(t,i){return this.currentTransform.screenPointToLocationAtElevation(t,i)}
812isPointOnMapSurface(t,i){return this.currentTransform.isPointOnMapSurface(t,i)}getRayDirectionFromPixel(t){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(t)}getProjectionDataForCustomLayer(t=!0){let i=this._mercatorTransform.getProjectionDataForCustomLayer(t);if(!this.isGlobeRendering)return i;let r=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(t);return r.fallbackMatrix=i.mainMatrix,r.projectionTransition=this._globeness,r}getFastPathSimpleProjectionMatrix(t){return this.currentTransform.getFastPathSimpleProjectionMatrix(t)}},iO=class t{get useGlobeControls(){return!0}handlePanInertia(t,i){let r,a,o,s,n=(r=t.rotate(i.bearingInRadians),a=i.zoom+iw(i.center.lat,0),o=(0,m.mr)(1/ib(i.center.lat),1/ib(Math.min(Math.abs(i.center.lat),60)),(0,m.wr)(a,7,3,0,1)),s=360/id({worldSize:i.worldSize,center:{lat:i.center.lat}}),new m.lt(i.center.lng-r.x*s*o,(0,m.Bn)(i.center.lat+r.y*s,-m.Fn,m.Fn)));return Math.abs(n.lng-i.center.lng)>180&&(n.lng=i.center.lng+179.5*Math.sign(n.lng-i.center.lng)),{easingCenter:n,easingOffset:new m.Li(0,0)}}handleMapControlsRollPitchBearingZoom(t,i){let r=t.around,a=i.screenPointToLocation(r);t.bearingDelta&&i.setBearing(i.bearing+t.bearingDelta),t.pitchDelta&&i.setPitch(i.pitch+t.pitchDelta),t.rollDelta&&i.setRoll(i.roll+t.rollDelta);let o=i.zoom;t.zoomDelta&&i.setZoom(i.zoom+t.zoomDelta);let s=i.zoom-o;if(0===s)return;let n=(0,m.Xn)(i.center.lng,a.lng),l=n/(Math.abs(n/180)+1),h=(0,m.Xn)(i.center.lat,a.lat),c=i.getRayDirectionFromPixel(r),u=i.cameraPosition,d=-1*(0,m.ei)(u,c),_=(0,m.Gn)();(0,m.Xr)(_,u,[c[0]*d,c[1]*d,c[2]*d]);let p=(0,m.ni)(_),f=Math.exp(-(.5*Math.max(p-1-.3,0))),g=(0,m.wr)(p,.95,.999,0,1),v=im(i.worldSize,i.center.lat)/Math.min(i.width,i.height),y=(0,m.wr)(v,.9,.5,1,.25),x=Math.min(f,(0,m.mr)(1,y,g)),b=(1-(0,m.Fr)(-s))*x,w=i.
812center.lat,T=i.zoom,P=new m.lt(i.center.lng+l*b,(0,m.Bn)(i.center.lat+h*b,-m.Fn,m.Fn));i.setLocationAtPoint(a,r);let M=i.center,I=Math.max((0,m.wr)(Math.abs(n),45,85,0,1),g)**.25,C=(0,m.Xn)(M.lng,P.lng),S=(0,m.Xn)(M.lat,P.lat);i.setCenter(new m.lt(M.lng+C*I,M.lat+S*I).wrap()),i.setZoom(T+iw(w,i.center.lat))}handleMapControlsPan(t,i,r){t.panDelta&&function(t,i,r,a,o=!0){var s,n,l,h,c,u,d;let _,p,f,g,v,y,x,b,w,T,P,M,I,C,S=ix(t,r),E=i;if(a)E=ix(t,r.sub(a));else if(!t.isPointOnMapSurface(r))return;let z=ip(S),R=ip(E),D=(s=t.center,n=t.bearing,(0,m.Ur)((0,m.Kn)(),-s.lng,-s.lat,n)),L=(0,m.Qr)((0,m.Gn)(),R,z),A=Math.sqrt((0,m.ei)(L,L)),F=Math.acos((0,m.Bn)((0,m.ei)(R,z),-1,1))/2,k=Math.sin(F),B=A?(0,m.Wr)(L[1]/A*k,-L[0]/A*k,L[2]/A*k,Math.cos(F)):(0,m.Wr)(0,0,0,1),{lng:O,lat:j,bearing:N}=(P=(l=(0,m.Gr)((0,m.Kn)(),D,B))[0],M=l[1],I=l[2],{lng:-(180*Math.atan2(2*((C=l[3])*P+M*I),1-2*(P*P+M*M)))/Math.PI,lat:-(180*Math.asin((0,m.Bn)(2*(C*M-I*P),-1,1)))/Math.PI,bearing:180*Math.atan2(2*(C*I+P*M),1-2*(M*M+I*I))/Math.PI}),Z=t.center.lat,U=t.zoom,G=(0,m.Bn)(j,-90,90),V=o?(h=t,c=r,u=a,d=O,_=h.center.lng,f=(p=h.center.lat)>=0?90:-90,g=h.locationToScreenPoint(new m.lt(0,f)),v=c.x-g.x,y=c.y-g.y,b=(x=(0,m.Bn)(1-(m.Fn-Math.abs(p))/12,0,1))*x*(3-2*x),w=(0,m.gr)(d-_+180,360)-180,T=0,b>0&&u&&(T=(f>0?1:-1)*((v*u.y-y*u.x)/Math.max(v*v+y*y,400))*180/Math.PI),_+(1-b)*w+b*T):O;t.setCenter(new m.lt((0,m.Pr)(V,-180,180),G)),o||t.setBearing(N),t.setZoom(U+iw(Z,t.center.lat))}(i,r,i.isPointOnMapSurface(t.around)?t.around:i.centerPoint,t.panDelta)}cameraForBoxAndBearing(i,r,a,o,s){let n=is(i,r,a,o,s),l=r.left/s.width*2-1,h=(s.width-r.right)/s.width*2-1,c=-(r.top/s.height*2)+1,u=-((s.height-r.bottom)/s.height*2)+1,d=0>(0,m.Xn)(a.getWest(),a.getEast()),_=d?a.getEast():a.getWest(),p=d?a.getWest():a.getEast(),f=Math.max(a.getNorth(),a.getSouth()),g=Math.min(a.getNorth(),a.getSouth()),v=_+.5*(0,m.Xn)(_,p),y=f+.5*(0,m.Xn)(f,g),x=s.clone();x.setCenter(n.center),x.setBearing(n.bearing),x.setPitch(0),x.setRoll(0),x.setZoom(n.zoom);let b=x.modelViewProjectionMatrix,w=[ip(a.getNorthWest()),ip(a.getNorthEast()),ip(a.getSouthWest
812()),ip(a.getSouthEast()),ip(new m.lt(p,y)),ip(new m.lt(_,y)),ip(new m.lt(v,f)),ip(new m.lt(v,g))],T=ip(n.center),P=1/0;for(let i of w)l<0&&(P=t.getLesserNonNegativeNonNull(P,t.solveVectorScale(i,T,b,"x",l))),h>0&&(P=t.getLesserNonNegativeNonNull(P,t.solveVectorScale(i,T,b,"x",h))),c>0&&(P=t.getLesserNonNegativeNonNull(P,t.solveVectorScale(i,T,b,"y",c))),u<0&&(P=t.getLesserNonNegativeNonNull(P,t.solveVectorScale(i,T,b,"y",u)));return Number.isFinite(P)&&0!==P?(n.zoom=Math.min(x.zoom+(0,m.Dr)(P),i.maxZoom),n):void ia()}handleJumpToCenterZoom(t,i){let r=t.center.lat,a=t.applyConstrain(i.center?m.lt.convert(i.center):t.center,t.zoom).center;t.setCenter(a.wrap());let o=void 0===i.zoom?t.zoom+iw(r,a.lat):+i.zoom;t.zoom!==o&&t.setZoom(o)}handleEaseTo(t,i){let r=t.zoom,a=t.center,o=t.padding,s={roll:t.roll,pitch:t.pitch,bearing:t.bearing},n={roll:void 0===i.roll?t.roll:i.roll,pitch:void 0===i.pitch?t.pitch:i.pitch,bearing:void 0===i.bearing?t.bearing:i.bearing},l=void 0!==i.zoom,h=!t.isPaddingEqual(i.padding),c=!1,u=i.center?m.lt.convert(i.center):a,d=t.applyConstrain(u,r).center;tJ(t,d);let _=t.clone();_.setCenter(d),_.setZoom(l?+i.zoom:r+iw(a.lat,u.lat)),_.setBearing(i.bearing);let p=new m.Li((0,m.Bn)(t.centerPoint.x+i.offsetAsPoint.x,0,t.width),(0,m.Bn)(t.centerPoint.y+i.offsetAsPoint.y,0,t.height));_.setLocationAtPoint(d,p);let f=(i.offset&&i.offsetAsPoint.mag())>0?_.center:d,g=l?+i.zoom:r+iw(a.lat,f.lat),v=r+iw(a.lat,0),y=g+iw(f.lat,0),x=(0,m.Xn)(a.lng,f.lng),b=(0,m.Xn)(a.lat,f.lat),w=(0,m.Fr)(y-v);return{easeFunc:r=>{if((0,m.Tr)(s,n)||io({startEulerAngles:s,endEulerAngles:n,tr:t,k:r,useSlerp:s.roll!=n.roll}),h&&t.interpolatePadding(o,i.padding,r),i.around)(0,m.Nr)("Easing around a point is not supported under globe projection."),t.setLocationAtPoint(i.around,i.aroundPoint);else{let i=iP(a,x,b,r*(y>v?Math.min(2,w):Math.max(.5,w))**(1-r));t.setCenter(i.wrap())}if(c){let i=m.un.number(v,y,r)+iw(0,t.center.lat);t.setZoom(i)}},isZooming:c=g!==r,elevationCenter:f}}handleFlyTo(t,i){let r,a,o=void 0!==i.zoom,s=t.center,n=t.zoom,l=t.padding,h=!t.isPaddingEqual(i.padding),c=t.applyConstrain(m.lt.convert(i.center||i.locationAtOffset),n).center,u=o?+i.zoom:t.zoom+iw(t.center.lat,c.lat),d=t.clone();d.setCenter(c),d.setZoom(u),d.setBearing(i.bearing);let _=new m.Li((0,m.Bn)(t.centerPoint.x+i.offsetAsPoint.x,0,t.width),(0,m.Bn)(t.centerPoint.y+i.offsetAsPoint.y,0,t.height));d.setLocationAtPoint(c,_);let p=d.center;tJ(t,p);let f=(r=ip(s),a=ip(p),Math.acos((0,m.ei)(r,a))/(2*Math.PI)*id(t)),g=n+iw(s.lat,0),v=u+iw(p.lat,0),y=(0,m.Fr)(v-g),x=Math.min(Math.max("number"==typeof i.minZoom?+i.minZoom:t.minZoom,t.minZoom)+iw(p.lat,0),g,v)+iw(0,p.lat),b=t.applyConstrain(p,x).zoom+iw(p.lat,0),w=(0,m.Fr)(b-g),T=(0,m.Xn)(s.lng,p.lng),P=(0,m.Xn)(s.lat,p.lat);return{easeFunc:(r,a,o,n)=>{let c=iP(s,T,P,o);h&&t.interpolatePadding(l,i.padding,r);let d=1===r?p:c;t.setCenter(d.wrap());let _=g+(0,m.Dr)(a);t.setZoom(1===r?u:_+iw(0,d.lat))},scaleOfZoom:y,targetCenter:p,scaleOfMinZoom:w,pixelPathLength:f}}static solveVectorScale(t,i,r,a,o){let s="x"===a?[r[0],r[4],r[8],r[12]]:[r[1],r[5],r[9],r[13]],n=[r[3],r[7],r[11],r[15]],l=t[0]*s[0]+t[1]*s[1]+t[2]*s[2],h=t[0]*n[0]+t[1]*n[1]+t[2]*n[2],c=i[0]*s[0]+i[1]*s[1]+i[2]*s[2],u=i[0]*n[0]+i[1]*n[1]+i[2]*n[2],d=(c+s[3]-o*u-o*n[3])/(c-l-o*u+o*h);return c+o*h===l+o*u||n[3]*(l-c)+s[3]*(u-h)+l*u==c*h?null:d}static getLesserNonNegativeNonNull(t,i){return null!==i&&i>=0&&i<t?i:t}},ij=class{constructor(t){this._globe=t,this._mercatorCameraHelper=new il,this._verticalPerspectiveCameraHelper=new iO}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(t,i){return this.currentHelper.handlePanInertia(t,i)}handleMapControlsRollPitchBearingZoom(t,i){this.currentHelper.handleMapControlsRollPitchBearingZoom(t,i)}handleMapControlsPan(t,i,r){this.currentHelper.handleMapControlsPan(t,i,r)}cameraForBoxAndBearing(t,i,r,a,o){return this.currentHelper.cameraForBoxAndBearing(t,i,r,a,o)}handleJumpToCenterZoom(t,i){this.currentHelper.handleJumpToCenterZoom(t,i)}handleEaseTo(t,i){return this.currentHelper.handleEaseTo(t,i)}handleFlyTo(t,i){return this.currentHelper.handleFlyTo(t,i)}};let iN=function(){let t={},i=m.hn.$version;for(let r in m.hn.$root){let a=m.hn.$root[r];if(a.required){let o=null;null!=(o="version"===r?i:"array"===a.type?[]:{})&&(t[r]=o)}}return t}();var iZ=class extends m.vn{constructor(t,i={}){super(),this._rtlPluginLoaded=()=>{for(let t in this.tileManagers){let i=this.tileManagers[t].getSource().type;("vector"===i||"geojson"===i)&&this.tileManagers[t].reload()}},this.map=t,this.dispatcher=new em(c||=new e_,t._getMapId()),this.dispatcher.registerMessageHandler("GG",(t,i)=>this.getGlyphs(t,i)),this.dispatcher.registerMessageHandler("GI",(t,i)=>this.getImages(t,i)),this.dispatcher.registerMessageHandler("GDA",(t,i)=>this.getDashes(t,i)),this.imageManager=new H,this.imageManager.setEventedParent(this),this.imageManager.setMissingImageResolver(t._missingStyleImageResolver),this.patternAtlas=new X(this.imageManager);let r=t._container?.lang||"u">typeof document&&document.documentElement?.lang||void 0;this.glyphManager=new es(t._requestManager,i.localIdeographFontFamily,r),this.lineAtlas=new eh(256,512),this.crossTileSymbolIndex=new tN,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",(0,m.Cn)()),eG().on(eN,this._rtlPluginLoaded),this.on("data",t=>{if("source"!==t.dataType||"metadata"!==t.sourceDataType)return;let i=this.tileManagers[t.sourceId];if(!i)return;let r=i.getSource();if(r?.vectorLayerIds)for(let t in this._layers){let i=this._layers[t];
812i.source===r.id&&this._validateLayer(i)}})}_setInitialValues(){this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new m.tn,this._imagesListDirty=!1,this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this._symbolPlacementTriggered=!1,this._placedProjectionTransition=void 0,this.crossTileSymbolIndex=new(this.crossTileSymbolIndex?.constructor||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(t,i){this._checkLoaded();let r=null===i?this.stylesheet.state?.[t]?.default??null:i;if((0,m.qn)(r,this._globalState[t]))return this;this._globalState[t]=r,this._applyGlobalStateChanges([t])}getGlobalState(){return this._globalState}setGlobalState(t){this._checkLoaded();let i=[];for(let r in t)(0,m.qn)(this._globalState[r],t[r].default)||(i.push(r),this._globalState[r]=t[r].default);this._applyGlobalStateChanges(i)}_applyGlobalStateChanges(t){if(0===t.length)return;let i=new Set,r={};for(let a of t)for(let t in r[a]=this._globalState[a],this._layers){let r=this._layers[t],o=r.getLayoutAffectingGlobalStateRefs(),s=r.getPaintAffectingGlobalStateRefs(),n=r.getVisibilityAffectingGlobalStateRefs();if(o.has(a)&&i.add(r.source),s.has(a))for(let{name:t,value:i}of s.get(a))this._updatePaintProperty(r,t,i);n?.has(a)&&(r.recalculateVisibility(),this._updateLayer(r))}for(let t in this.dispatcher.broadcast("UGS",r),this.tileManagers)i.has(t)&&(this._reloadSource(t),this._changed=!0)}async loadURL(t,i={},r){this.fire(new M("dataloading")),i.validate="boolean"!=typeof i.validate||i.validate,this._loadStyleRequest=new AbortController;let a=this._loadStyleRequest;try{let o=await this.map._requestManager.transformRequest(t,"Style");(0,m.Nn)(a.signal);let s=await (0,m.Sn)(o,a);this._loadStyleRequest===a&&(this._loadStyleRequest=null),this._load(s.data,i,r)}catch(t){this._loadStyleRequest===a&&(this._loadStyleRequest=null),t&&!a.signal.aborted&&this.fire(new m.gn((0,m.Qn)(t)))}}loadJSON(t,i={},r){this.fire(new M("dataloading")),this._frameRequest=new AbortController,g.frameAsync(this._frameRequest,this.map._ownerWindow).then(()=>{this._frameRequest=null,i.validate=!1!==i.validate,this._load(t,i,r)}).catch(()=>{})}loadEmpty(){this.fire(new M("dataloading")),this._load(iN,{validate:!1})}_load(t,i,r){let a=i.transformStyle?i.transformStyle(r,t):t;if(!(i.validate&&(0,m.sn)(this,a))){for(let t in a={...a},this._loaded=!0,this.stylesheet=a,a.sources)this.addSource(t,a.sources[t],{validate:!1});a.sprite?this._loadSprite(a.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(a.glyphs),this.glyphManager.setFontFaces(a["font-faces"]),this._createLayers(),this.light=new en(this.stylesheet.light??{},this._globalState),this._setProjectionInternal(this.stylesheet.projection?.type||"mercator"),this.sky=new el(this.stylesheet.sky,this._globalState),this.map.setTerrain(this.stylesheet.terrain??null,{validate:!1}),this.fire(new M("data")),this.fire(new P)}}_createLayers(){let t=F(this.stylesheet.layers);for(let i of(this.setGlobalState(this.stylesheet.state??null),this.dispatcher.broadcast("SL",t),this._order=t.map(t=>t.id),this._layers={},this._serializedLayers=null,t)){let t=(0,m._)(i,this._globalState);if(t.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=t,(0,m.Xt)(t)&&this.tileManagers[t.source]){let r=i.paint?.["raster-fade-duration"]??t.paint.get("raster-fade-duration");this.tileManagers[t.source].setRasterFadeDuration(r)}}}async _loadSprite(t,i=!1,r){let a;this.imageManager.setLoaded(!1);let o=new AbortController;this._spriteRequest=o;try{let r=await W(t,this.map._requestManager,this.map.getPixelRatio(),o);if(!r)return;for(let t in r){let{loaded:a,removed:o}=this.imageManager.setSpriteImages(t,r[t]);this._markImagesChanged(o),i&&this._markImagesChanged(a)}}catch(t){a=t,o.signal.aborted||this.fire(new m.gn(a))}finally{this._spriteRequest=null,this.imageManager.setLoaded(!0),i&&(this._changed=!0),this.dispatcher.broadcast("SI",this.imageManager.listImages()),this.fire(new M("data")),r?.(a)}}_unloadSprite(){this._markImagesChanged(this.imageManager.removeAllSpriteImages()),this._imagesListDirty=!0,this._changed=!0,this.fire(new M("data"))}_validateLayer(t){let i=this.tileManagers[t.source];if(!i)return;let r=t.sourceLayer;if(!r)return;let a=i.getSource();("geojson"===a.type||a.vectorLayerIds&&!a.vectorLayerIds.includes(r))&&this.fire(new m.gn(Error(`Source layer "${r}" does not exist on source "${a.id}" as specified by style layer "${t.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(let t in this.tileManagers)if(!this.tileManagers[t].loaded())return!1;return this.imageManager.isLoaded()}_serializeByIds(t,i=!1){let r=this._serializedAllLayers();if(!t||0===t.length)return Object.values(i?(0,m.Vn)(r):r);let a=[];for(let o of t)if(r[o]){let t=i?(0,m.Vn)(r[o]):r[o];a.push(t)}return a}_serializedAllLayers(){let t=this._serializedLayers;if(t)return t;for(let i of(t=this._serializedLayers={},Object.keys(this._layers))){let r=this._layers[i];"custom"!==r.type&&(t[i]=r.serialize())}return t}hasTransitions(){if(this.light?.hasTransition()||this.sky?.hasTransition()||this.projection?.hasTransition())return!0;for(let t in this.tileManagers)if(this.tileManagers[t].hasTransition())return!0;for(let t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw Error("Style is not done loading.")}update(t){if(!this._loaded)return;let i=this._changed;if(i){this._imagesListDirty&&=(this.dispatcher.broadcast("SI",this.imageManager.listImages()),!1);let i=Object.keys(this._updatedLayers),r=Object.keys(this._removedLayers);for(let t in(i.length||r.length)&&this._updateWorkerLayers(i,r),this._updatedSources){let i=this._updatedSources[t];if("reload"===i)this._reloadSource(t);else if("clear"===i)this._clearSource(t);else throw Error(`Invalid action ${i}`)}for(let i in this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs(),this._updatedPaintProps)this._layers[i].updateTransitions(t);this._resetUpdates()}let r={};for(let t in this.tileManagers){let i=this.tileManagers[t];r[t]=i.used,i.used=!1}let a=this.imageManager.listImages();for(let i of this._order){let r=this._layers[i];r.recalculate(t,a),!r.isHidden(t.zoom)&&r.source&&(this.tileManagers[r.source].used=!0)}for(let t in r){let i=this.tileManagers[t];!!r[t]!=!!i.used&&i.fire(new I("data",{sourceDataType:"visibility",sourceId:t}))}this.light.recalculate(t),this.sky.recalculate(t),this.projection.recalculate(t),this.z=t.zoom,i&&this.fire(new M("data"))}_updateTilesForChangedImages(){let t=Object.keys(this._changedImages);if(t.length){for(let i in this.tileManagers)this.tileManagers[i].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(let t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(t,i){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(t,!1),removedIds:i})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(t,i={}){this._checkLoaded();let r=this.serialize();if(t=i.transformStyle?i.transformStyle(r,t):t,(i.validate??!0)&&(0,m.sn)(this,t))return!1;(t=(0,m.Vn)(t)).layers=F(t.layers);let a=function(t,i){if(!t)return[{command:"setStyle",args:[i]}];let r=[];try{if(!k(t.version,i.version))return[{command:"setStyle",args:[i]}];k(t.center,i.center)||r.push({command:"setCenter",args:[i.center]}),k(t.state,i.state)||r.push({command:"setGlobalState",args:[i.state]}),k(t.centerAltitude,i.centerAltitude)||r.push({command:"setCenterAltitude",args:[i.centerAltitude]}),k(t.zoom,i.zoom)||r.push({command:"setZoom",args:[i.zoom]}),k(t.bearing,i.bearing)||r.push({command:"setBearing",args:[i.bearing]}),k(t.pitch,i.pitch)||r.push({command:"setPitch",args:[i.pitch]}),k(t.roll,i.roll)||r.push({command:"setRoll",args:[i.roll]}),k(t.sprite,i.sprite)||r.push({command:"setSprite",args:[i.sprite]}),k(t.glyphs,i.glyphs)||r.push({command:"setGlyphs",args:[i.glyphs]}),k(t["font-faces"],i["font-faces"])||r.push({command:"setFontFaces",args:[i["font-faces"]]}),k(t.transition,i.transition)||r.push({command:"setTransition",args:[i.transition]}),k(t.light,i.light)||r.push({command:"setLight",args:[i.light]});let a=!k(t.terrain,i.terrain);a&&!i.terrain&&r.push({command:"setTerrain",args:[void 0]}),k(t.sky,i.sky)||r.push({command:"setSky",args:[i.sky]}),k(t.projection,i.projection)||r.push({command:"setProjection",args:[i.projection]});let o={},s=[];!function(t,i,r,a){let o;for(o in t||={},i||={},t)Object.prototype.hasOwnProperty.call(t,o)&&(Object.prototype.hasOwnProperty.call(i,o)||j(o,r,a));for(o in i){var s;Object.prototype.hasOwnProperty.call(i,o)&&(Object.prototype.hasOwnProperty.call(t,o)?k(t[o],i[o])||("geojson"===t[o].type&&"geojson"===i[o].type&&function(t,i,r){let a;for(a in t[r])if(Object.prototype.hasOwnProperty.call(t[r],a)&&"data"!==a&&!k(t[r][a],i[r][a]))return!1;for(a in i[r])if(Object.prototype.hasOwnProperty.call(i[r],a)&&"data"!==a&&!k(t[r][a],i[r][a]))return!1;return!0}(t,i,o)?B(r,{command:"setGeoJSONSourceData",args:[o,i[o].data]}):(s=i,j(o,r,a),O(o,s,r))):O(o,i,r))}}(t.sources,i.sources,s,o);let n=[];
812t.layers&&t.layers.forEach(t=>{"source"in t&&o[t.source]?r.push({command:"removeLayer",args:[t.id]}):n.push(t)}),r=r.concat(s),function(t,i,r){t||=[],i||=[];let a=t.map(U),o=i.map(U),s=t.reduce(G,{}),n=i.reduce(G,{}),l=a.slice(),h=Object.create(null),c,u,d,_,p;for(let t=0,i=0;t<a.length;t++)c=a[t],Object.prototype.hasOwnProperty.call(n,c)?i++:(B(r,{command:"removeLayer",args:[c]}),l.splice(l.indexOf(c,i),1));for(let t=0,i=0;t<o.length;t++)c=o[o.length-1-t],l[l.length-1-t]!==c&&(Object.prototype.hasOwnProperty.call(s,c)?(B(r,{command:"removeLayer",args:[c]}),l.splice(l.lastIndexOf(c,l.length-i),1)):i++,_=l[l.length-t],B(r,{command:"addLayer",args:[n[c],_]}),l.splice(l.length-t,0,c),h[c]=!0);for(let t=0;t<o.length;t++)if(u=s[c=o[t]],d=n[c],!(h[c]||k(u,d))){if(!k(u.source,d.source)||!k(u["source-layer"],d["source-layer"])||!k(u.type,d.type)){B(r,{command:"removeLayer",args:[c]}),B(r,{command:"addLayer",args:[d,_=l[l.lastIndexOf(c)+1]]});continue}for(p in Z(u.layout,d.layout,r,c,"setLayoutProperty"),Z(u.paint,d.paint,r,c,"setPaintProperty"),k(u.filter,d.filter)||B(r,{command:"setFilter",args:[c,d.filter]}),k(u.minzoom,d.minzoom)&&k(u.maxzoom,d.maxzoom)||B(r,{command:"setLayerZoomRange",args:[c,d.minzoom,d.maxzoom]}),u)Object.prototype.hasOwnProperty.call(u,p)&&"layout"!==p&&"paint"!==p&&"filter"!==p&&"metadata"!==p&&"minzoom"!==p&&"maxzoom"!==p&&(0===p.indexOf("paint.")?Z(u[p],d[p],r,c,"setPaintProperty"):k(u[p],d[p])||B(r,{command:"setLayerProperty",args:[c,p,d[p]]}));for(p in d)Object.prototype.hasOwnProperty.call(d,p)&&!Object.prototype.hasOwnProperty.call(u,p)&&"layout"!==p&&"paint"!==p&&"filter"!==p&&"metadata"!==p&&"minzoom"!==p&&"maxzoom"!==p&&(0===p.indexOf("paint.")?Z(u[p],d[p],r,c,"setPaintProperty"):k(u[p],d[p])||B(r,{command:"setLayerProperty",args:[c,p,d[p]]}))}}(n,i.layers,r),a&&i.terrain&&r.push({command:"setTerrain",args:[i.terrain]})}catch(t){console.warn("Unable to compute style diff:",t),r=[{command:"setStyle",args:[i]}]}return r}(r,t),o=this._getOperationsToPerform(a);if(o.unimplemented.length>0)throw Error(`Unimplemented: ${o.unimplemented.join(", ")}.`);if(0===o.operations.length)return!1;for(let t of o.operations)t();return this.stylesheet=t,this._serializedLayers=null,this.fire(new P({style:this})),!0}_getOperationsToPerform(t){let i=[],r=[];for(let a of t)switch(a.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":{let[t,r]=a.args;i.push(()=>this.addLayer(t,r));break}case"removeLayer":{let[t]=a.args;i.push(()=>this.removeLayer(t));break}case"setPaintProperty":{let[t,r,o]=a.args;i.push(()=>this.setPaintProperty(t,r,o));break}case"setLayoutProperty":{let[t,r,o]=a.args;i.push(()=>this.setLayoutProperty(t,r,o));break}case"setFilter":{let[t,r]=a.args;i.push(()=>this.setFilter(t,r));break}case"addSource":{let[t,r]=a.args;i.push(()=>this.addSource(t,r));break}case"removeSource":{let[t]=a.args;i.push(()=>this.removeSource(t));break}case"setLayerZoomRange":{let[t,r,o]=a.args;i.push(()=>this.setLayerZoomRange(t,r,o));break}case"setLight":{let[t]=a.args;i.push(()=>this.setLight(t));break}case"setGeoJSONSourceData":{let[t,r]=a.args;i.push(()=>this.setGeoJSONSourceData(t,r));break}case"setGlyphs":{let[t]=a.args;i.push(()=>this.setGlyphs(t));break}case"setFontFaces":{let[t]=a.args;i.push(()=>this.setFontFaces(t));break}case"setSprite":{let[t]=a.args;i.push(()=>this.setSprite(t));break}case"setTerrain":{let[t]=a.args;i.push(()=>this.map.setTerrain(t));break}case"setSky":{let[t]=a.args;i.push(()=>this.setSky(t));break}case"setProjection":{let[t]=a.args;i.push(()=>this.setProjection(t));break}case"setGlobalState":{let[t]=a.args;i.push(()=>this.setGlobalState(t));break}case"setTransition":i.push(()=>{});break;default:r.push(a.command)}return{operations:i,unimplemented:r}}addImage(t,i){if(this.getImage(t))return void this.fire(new m.gn(Error(`An image named "${t}" already exists.`)));this.imageManager.addImage(t,i),this._afterImageUpdated(t)}updateImage(t,i){this.imageManager.updateImage(t,i)}getImage(t){return this.imageManager.getImage(t)}setMissingImageResolver(t){this.imageManager.setMissingImageResolver(t)}removeImage(t){if(!this.getImage(t))return void this.fire(new m.gn(Error(`An image named "${t}" does not exist.`)));this.imageManager.removeImage(t),this._afterImageUpdated(t)}_markImagesChanged(t){for(let i of t)this._changedImages[i]=!0}_afterImageUpdated(t){this._changedImages[t]=!0,this._imagesListDirty=!0,this._changed=!0,this.fire(new M("data"))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,i,r={}){if(this._checkLoaded(),void 0!==this.tileManagers[t])throw Error(`Source "${t}" already exists.`);if(!i.type)throw Error(`The type property must be defined, but only the following properties were given: ${Ob
812ject.keys(i).join(", ")}.`);if(m.rn.has(i.type)&&this._validate(m.on.source,`sources.${t}`,i,null,r))return;this.map?._collectResourceTiming&&(i.collectResourceTiming=!0);let a=this.tileManagers[t]=new e3(t,i,this.dispatcher);a.style=this,a.setEventedParent(this,()=>({isSourceLoaded:a.loaded(),source:a.serialize(),sourceId:t})),a.onAdd(this.map),this._changed=!0}removeSource(t){if(this._checkLoaded(),void 0===this.tileManagers[t])throw Error(`There is no source with this ID=${t}`);for(let i in this._layers)if(this._layers[i].source===t)return this.fire(new m.gn(Error(`Source "${t}" cannot be removed while layer "${i}" is using it.`)));let i=this.tileManagers[t];delete this.tileManagers[t],delete this._updatedSources[t],i.fire(new I("data",{sourceDataType:"metadata",sourceId:t})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,i){if(this._checkLoaded(),void 0===this.tileManagers[t])throw Error(`There is no source with this ID=${t}`);let r=this.tileManagers[t].getSource();if("geojson"!==r.type)throw Error(`geojsonSource.type is ${r.type}, which is !== 'geojson`);r.setData(i),this._changed=!0}getSource(t){return this.tileManagers[t]?.getSource()}addLayer(t,i,r={}){let a;this._checkLoaded();let o=t.id;if(this.getLayer(o))return void this.fire(new m.gn(Error(`Layer "${o}" already exists on this map.`)));if("custom"===t.type){if((0,m.in)(this,(0,m.y)(t)))return;a=(0,m._)(t,this._globalState)}else{if("source"in t&&"object"==typeof t.source&&(this.addSource(o,t.source),t=(0,m.Vn)(t),t=(0,m.er)(t,{source:o})),this._validate(m.on.layer,`layers.${o}`,t,{arrayIndex:-1},r))return;a=(0,m._)(t,this._globalState),this._validateLayer(a),a.setEventedParent(this,{layer:{id:o}})}let s=i?this._order.indexOf(i):this._order.length;if(i&&-1===s)return void this.fire(new m.gn(Error(`Cannot add layer "${o}" before non-existing layer "${i}".`)));if(this._order.splice(s,0,o),this._layerOrderChanged=!0,this._layers[o]=a,this._removedLayers[o]&&a.source&&"custom"!==a.type){let t=this._removedLayers[o];delete this._removedLayers[o],t.type===a.type?(this._updatedSources[a.source]="reload",this.tileManagers[a.source].pause()):this._updatedSources[a.source]="clear"}this._updateLayer(a),a.onAdd&&a.onAdd(this.map)}moveLayer(t,i){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new m.gn(Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===i)return;if(i&&!this._order.includes(i))return void this.fire(new m.gn(Error(`Cannot move layer "${t}" before non-existing layer "${i}".`)));let r=this._order.indexOf(t);this._order.splice(r,1);let a=i?this._order.indexOf(i):this._order.length;this._order.splice(a,0,t),this._layerOrderChanged=!0}removeLayer(t){this._checkLoaded();let i=this._layers[t];if(!i)return void this.fire(new m.gn(Error(`Cannot remove non-existing layer "${t}".`)));i.setEventedParent(null);let r=this._order.indexOf(t);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=i,delete this._layers[t],this._serializedLayers&&delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],"symbol"===i.type&&i.source&&this.tileManagers[i.source]?.resetMaxContentElevation(),i.onRemove&&i.onRemove(this.map)}getLayer(t){return this._layers[t]}getLayersOrder(){return[...this._order]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,i,r){this._checkLoaded();let a=this.getLayer(t);if(!a)return void this.fire(new m.gn(Error(`Cannot set the zoom range of non-existing layer "${t}".`)));(a.minzoom!==i||a.maxzoom!==r)&&(null!=i&&(a.minzoom=i),null!=r&&(a.maxzoom=r),this._updateLayer(a))}setFilter(t,i,r={}){this._checkLoaded();let a=this.getLayer(t);if(!a)return void this.fire(new m.gn(Error(`Cannot filter non-existing layer "${t}".`)));if(!(0,m.qn)(a.filter,i)){if(null==i){a.setFilter(void 0),this._updateLayer(a);return}
812this._validate(m.on.filter,`layers.${a.id}.filter`,i,null,r)||(a.setFilter((0,m.Vn)(i)),this._updateLayer(a))}}getFilter(t){return(0,m.Vn)(this.getLayer(t).filter)}setLayoutProperty(t,i,r,a={}){this._checkLoaded();let o=this.getLayer(t);if(!o)return void this.fire(new m.gn(Error(`Cannot style non-existing layer "${t}".`)));(0,m.qn)(o.getLayoutProperty(i),r)||(o.setLayoutProperty(i,r,a),this._updateLayer(o))}getLayoutProperty(t,i){let r=this.getLayer(t);return r?r.getLayoutProperty(i):void this.fire(new m.gn(Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,i,r,a={}){this._checkLoaded();let o=this.getLayer(t);if(!o)return void this.fire(new m.gn(Error(`Cannot style non-existing layer "${t}".`)));(0,m.qn)(o.getPaintProperty(i),r)||this._updatePaintProperty(o,i,r,a)}_updatePaintProperty(t,i,r,a={}){t.setPaintProperty(i,r,a)&&this._updateLayer(t),(0,m.Xt)(t)&&"raster-fade-duration"===i&&this.tileManagers[t.source].setRasterFadeDuration(r),this._changed=!0,this._updatedPaintProps[t.id]=!0,"symbol"===t.type&&this.triggerSymbolPlacement(),this._serializedLayers=null}getPaintProperty(t,i){return this.getLayer(t).getPaintProperty(i)}setFeatureState(t,i){this._checkLoaded();let r=t.source,a=t.sourceLayer,o=this.tileManagers[r];if(void 0===o)return void this.fire(new m.gn(Error(`The source '${r}' does not exist in the map's style.`)));let s=o.getSource().type;if("geojson"===s&&a)return void this.fire(new m.gn(Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!a)return void this.fire(new m.gn(Error("The sourceLayer parameter must be provided for vector source types.")));if(void 0===t.id)return void this.fire(new m.gn(Error("The feature id parameter must be provided.")));let n=["__proto__","constructor","prototype"];if(i&&Object.keys(i).some(t=>n.includes(t)))return void this.fire(new m.gn(Error(`The feature state should not include one of the following keys: ${n}`)));o.setFeatureState(a,t.id,i)}removeFeatureState(t,i){this._checkLoaded();let r=t.source,a=this.tileManagers[r];if(void 0===a)return void this.fire(new m.gn(Error(`The source '${r}' does not exist in the map's style.`)));let o=a.getSource().type,s="vector"===o?t.sourceLayer:void 0;return"vector"!==o||s?i&&"string"!=typeof t.id&&"number"!=typeof t.id?void this.fire(new m.gn(Error("A feature id is required to remove its specific state property."))):void a.removeFeatureState(s,t.id,i):void this.fire(new m.gn(Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(t){this._checkLoaded();let i=t.source,r=t.sourceLayer,a=this.tileManagers[i];return void 0===a?void this.fire(new m.gn(Error(`The source '${i}' does not exist in the map's style.`))):"vector"!==a.getSource().type||r?(void 0===t.id&&this.fire(new m.gn(Error("The feature id parameter must be provided."))),a.getFeatureState(r,t.id)):void this.fire(new m.gn(Error("The sourceLayer parameter must be provided for vector source types.")))}getTransition(){return(0,m.er)({duration:300,delay:0},this.stylesheet?.transition)}serialize(){if(!this._loaded)return;let t=(0,m.hr)(this.tileManagers,t=>t.serialize()),i=this._serializeByIds(this._order,!0),r=this.map.getTerrain()||void 0,a=this.stylesheet;return(0,m.tr)({version:a.version,name:a.name,metadata:a.metadata,light:a.light,sky:a.sky,center:a.center,zoom:a.zoom,bearing:a.bearing,pitch:a.pitch,sprite:a.sprite,glyphs:a.glyphs,"font-faces":a["font-faces"],transition:a.transition,projection:a.projection,state:a.state,sources:t,layers:i,terrain:r},t=>void 0!==t)}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&"raster"!==this.tileManagers[t.source].getSource().type&&(this._updatedSources[t.source]="reload",this.tileManagers[t.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(t){let i=t=>"fill-extrusion"===this._layers[t].type,r={},a=[];for(let o=this._order.length-1;o>=0;o--){let s=this._order[o];if(i(s))for(let i of(r[s]=o,t)){let t=i[s];if(t)for(let i of t)a.push(i)}}a.sort((t,i)=>i.intersectionZ-t.intersectionZ);let o=[];for(let s=this._order.length-1;s>=0;s--){let n=this._order[s];if(i(n))for(let t=a.length-1;t>=0;t--){let i=a[t].feature;if(r[i.layer.id]<s)break;o.push(i),a.pop()}else for(let i of t){let t=i[n];if(t)for(let i of t)o.push(i.feature)}}return o}
812queryRenderedFeatures(t,i,r){i?.filter&&this._validate(m.on.filter,"queryRenderedFeatures.filter",i.filter,null,i);let a={};if(i?.layers){if(!(Array.isArray(i.layers)||i.layers instanceof Set))return this.fire(new m.gn(Error("parameters.layers must be an Array or a Set of strings"))),[];for(let t of i.layers){let i=this._layers[t];if(!i)return this.fire(new m.gn(Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];a[i.source]=!0}}let o=[];i.availableImages=this.imageManager.listImages();let s=this._serializedAllLayers(),n=i.layers instanceof Set?i.layers:Array.isArray(i.layers)?new Set(i.layers):null,l={...i,layers:n,globalState:this._globalState};for(let n in this.tileManagers)(!i.layers||a[n])&&o.push(function(t,i,r,a,o,s,n){let l=function(t,i,r){if(t)for(let a of t){let t=i[a];if(t?.source===r&&"fill-extrusion"===t.type)return!0}else for(let t in i){let a=i[t];if(a.source===r&&"fill-extrusion"===a.type)return!0}return!1}(o?.layers??null,i,t.id),h=s.maxPitchScaleFactor(),c=t.tilesIn(a,h,l);c.sort(ef);let u=[];for(let a of c)u.push({wrappedTileID:a.tileID.wrapped().key,queryResults:a.tile.queryRenderedFeatures(i,r,t.getState(),a.queryGeometry,a.cameraQueryGeometry,a.scale,o,s,h,function(t,i){let r=(0,m.vi)();return(0,m.ji)(r,r,[1,1,0]),(0,m.Ai)(r,r,[.5*t.width,.5*t.height,1]),t.calculatePosMatrix?(0,m.wi)(r,r,t.calculatePosMatrix(i.toUnwrapped())):r}(s,a.tileID),n?(t,i)=>n(a.tileID,t,i):void 0)});var d=function(t){let i={},r={};for(let{queryResults:a,wrappedTileID:o}of t){r[o]||={};let t=r[o];for(let r in a){let o=a[r];t[r]||={};let s=t[r];for(let t of(i[r]||=[],o))s[t.featureIndex]||(s[t.featureIndex]=!0,i[r].push(t))}}return i}(u),_=t;for(let t in d)for(let i of d[t])eg(i,_);return d}(this.tileManagers[n],this._layers,s,t,l,r,this.map.terrain?(t,i,r)=>this.map.terrain.getElevation(t,i,r):void 0));return this.placement&&o.push(function(t,i,r,a,o,s,n){let l={},h=s.queryRenderedSymbols(a),c=[];for(let t of Object.keys(h).map(Number))c.push(n[t]);for(let r of(c.sort(ef),c)){let a=r.featureIndex.lookupSymbolFeatures(h[r.bucketInstanceId],i,r.bucketIndex,r.sourceLayerIndex,{filterSpec:o.filter,globalState:o.globalState},o.layers,o.availableImages,t);for(let t in a){l[t]||=[];let i=a[t];for(let a of(i.sort((t,i)=>{let a=r.featureSortOrder;if(a){let r=a.indexOf(t.featureIndex);return a.indexOf(i.featureIndex)-r}return i.featureIndex-t.featureIndex}),i))l[t].push(a)}}var u=l,d=t,_=r;for(let t in u)for(let i of u[t])eg(i,_[d[t].source]);return u}(this._layers,s,this.tileManagers,t,l,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(t,i){i?.filter&&this._validate(m.on.filter,"querySourceFeatures.filter",i.filter,null,i);let r=this.tileManagers[t];return r?function(t,i){let r=t.getRenderableIds().map(i=>t.getTileByID(i)),a=[],o={};for(let t of r){let r=t.tileID.canonical.key;o[r]||(o[r]=!0,t.querySourceFeatures(a,i))}return a}(r,i?{...i,globalState:this._globalState}:{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(t,i={}){this._checkLoaded();let r=this.light.getLight(),a=!1;for(let i in t)if(!(0,m.qn)(t[i],r[i])){a=!0;break}if(!a)return;let o={now:y(),transition:(0,m.er)({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,i),this.light.updateTransitions(o)}getProjection(){return this.stylesheet?.projection}setProjection(t){this._checkLoaded();let i=t??{type:"mercator"};if(this.stylesheet.projection=t,this.projection){if(this.projection.name===i.type)return;this.projection.destroy(),delete this.projection}this._setProjectionInternal(i.type)}getSky(){return this.stylesheet?.sky}setSky(t,i={}){this._checkLoaded();let r=this.getSky(),a=!1;if(!t&&!r)return;if(t&&!r)a=!0;else if(!t&&r)a=!0;else for(let i in t)if(!(0,m.qn)(t[i],r[i])){a=!0;break}if(!a)return;let o={now:y(),transition:(0,m.er)({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=t,this.sky.setSky(t,i),this.sky.updateTransitions(o)}_setProjectionInternal(t){let i=function(t,i,r){let a={constrainOverride:i};if(Array.isArray(t)){let i=new iu({type:t},r);return{projection:i,transform:new iB(a),cameraHelper:new ij(i)}}switch(t){case"mercator":return{projection:new tY,transform:new ie(a),cameraHelper:new il};case"globe":{let t=new iu({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]},{});return{projection:t,transform:new iB(a),cameraHelper:new ij(t)}}case"vertical-perspective":return{projection:new ic,transform:new iD(a),cameraHelper:new iO};default:return(0,m.Nr)(`Unknown projection name: ${t}. Falling back to mercator projection.`),{projection:new tY,transform:new ie(a),cameraHelper:new il}}}(t,this.map._camera?.transform.constrainOverride,this._globalState);for(let t in this.projection=i.projection,this.map.migrateProjection(i.transform,i.cameraHelper),this.tileManagers)this.tileManagers[t].reload()}_validate(t,i,r,a,o={}
vendor: 4,469 bytes, line 812
812){return!1!==o.validate&&(0,m.an)(this,t,{key:i,style:this.serialize(),value:r,...a},o)}_remove(t=!0){for(let t in this._frameRequest&&=(this._frameRequest.abort(),null),this._loadStyleRequest&&=(this._loadStyleRequest.abort(),null),this._spriteRequest&&=(this._spriteRequest.abort(),null),eG().off(eN,this._rtlPluginLoaded),this._layers)this._layers[t].setEventedParent(null);for(let t in this.tileManagers){let i=this.tileManagers[t];i.setEventedParent(null),i.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),t&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(t)}_clearSource(t){this.tileManagers[t].clearTiles()}_reloadSource(t){this.tileManagers[t].resume(),this.tileManagers[t].reload()}_updateSources(t){for(let i in this.tileManagers)this.tileManagers[i].update(t,this.map.terrain)}_generateCollisionBoxes(){for(let t in this.tileManagers)this._reloadSource(t)}triggerSymbolPlacement(){this._symbolPlacementTriggered=!0}_placementInputsChanged(t,i,r){let a=this.pauseablePlacement;return!a||this._symbolPlacementTriggered||this._placedProjectionTransition!==this.projection?.transitionState||a._showCollisionBoxes!==i||a.placement.collisionGroups.crossSourceCollisions!==r||a.placement.transform.renderWorldCopies!==t.renderWorldCopies||!(0,m.bi)(a.placement.transform.modelViewProjectionMatrix,t.modelViewProjectionMatrix)}_updatePlacement(t,i,r,a,o=!1){let s=!1,n=!1,l={};for(let i of this._order){let r=this._layers[i];if("symbol"!==r.type)continue;if(!l[r.source]){let t=this.tileManagers[r.source];l[r.source]=t.getRenderableIds(!0).map(i=>t.getTileByID(i)).sort((t,i)=>i.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(i.tileID)?-1:1))}let a=this.crossTileSymbolIndex.addLayer(r,l[r.source],t.center.lng);s||=a}this.crossTileSymbolIndex.pruneUnusedLayers(this._order),o||=this._layerOrderChanged||0===r;let h=s||this._placementInputsChanged(t,i,a),c=this.pauseablePlacement?.isDone()&&!this.placement.stillRecent(y(),t.zoom);if((o||!this.pauseablePlacement||c&&(h||this.placement.stale))&&(this._symbolPlacementTriggered=!1,this._placedProjectionTransition=this.projection?.transitionState,this.pauseablePlacement=new tE(t,this.map.terrain,this._order,o,i,r,a,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?h&&this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(y()),n=!0),s&&this.pauseablePlacement.placement.setStale()),n||s)for(let t of this._order){let i=this._layers[t];"symbol"===i.type&&this.placement.updateLayerOpacities(i,l[i.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(y())}_releaseSymbolFadeTiles(){for(let t in this.tileManagers)this.tileManagers[t].releaseSymbolFadeTiles()}async getImages(t,i){let r=await this.imageManager.getImages(i.icons);this._updateTilesForChangedImages();let a=this.tileManagers[i.source];return a&&a.setDependencies(i.tileID.key,i.type,i.icons),r}async getGlyphs(t,i){let r=await this.glyphManager.getGlyphs(i.stacks),a=this.tileManagers[i.source];return a&&a.setDependencies(i.tileID.key,i.type,[""]),r}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,i={}){this._checkLoaded(),t&&this._validate(m.on.glyphs,"glyphs",t,null,i)||(this._changed=!0,this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t))}getFontFaces(){return this.stylesheet["font-faces"]||null}setFontFaces(t){this._checkLoaded(),this._changed=!0,this._glyphsDidChange=!0,this.stylesheet["font-faces"]=t,this.glyphManager.setFontFaces(t)}async getDashes(t,i){let r={};for(let[t,a]of Object.entries(i.dashes))r[t]=this.lineAtlas.getDash(a.dasharray,a.round);return r}addSprite(t,i,r={},a){this._checkLoaded();let o=[{id:t,url:i}],s=[...V(this.stylesheet.sprite),...o];this._validate(m.on.sprite,"sprite",s,null,r)||(this.stylesheet.sprite=s,this._loadSprite(o,!0,a))}removeSprite(t){this._checkLoaded();let i=V(this.stylesheet.sprite);if(!i.find(i=>i.id===t))return void this.fire(new m.gn(Error(`Sprite "${t}" doesn't exists on this map.`)));let r=this.imageManager.removeSpriteImages(t);this._markImagesChanged(r),i.splice(i.findIndex(i=>i.id===t),1),this.stylesheet.sprite=i.length>0?i:void 0,this._imagesListDirty=!0,this._changed=!0,this.fire(new M("data"))}getSprite(){return V(this.stylesheet.sprite)}setSprite(t,i={}
812,r){this._checkLoaded(),!(t&&this._validate(m.on.sprite,"sprite",t,null,i))&&(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,r):(this._unloadSprite(),r&&r(null)))}destroy(){for(let t in this._frameRequest&&=(this._frameRequest.abort(),null),this._loadStyleRequest&&=(this._loadStyleRequest.abort(),null),this._spriteRequest&&=(this._spriteRequest.abort(),null),this.tileManagers){let i=this.tileManagers[t];i.setEventedParent(null),i.onRemove(this.map)}for(let t in this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this.patternAtlas.destroy()),this.glyphManager&&this.glyphManager.destroy(),this._layers){let i=this._layers[t];i.setEventedParent(null),i.onRemove&&i.onRemove(this.map)}this._setInitialValues(),this.setEventedParent(null),this.dispatcher.unregisterMessageHandler("GG"),this.dispatcher.unregisterMessageHandler("GI"),this.dispatcher.unregisterMessageHandler("GDA"),this.dispatcher.remove(!0),this._listeners={},this._oneTimeListeners={}}};let iU=(0,m.Yt)([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);var iG=class{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,i,r,a,o,s,n,l,h){this.context=t;let c=this.boundPaintVertexBuffers.length!==a.length;for(let t=0;!c&&t<a.length;t++)this.boundPaintVertexBuffers[t]!==a[t]&&(c=!0);!this.vao||this.boundProgram!==i||this.boundLayoutVertexBuffer!==r||c||this.boundIndexBuffer!==o||this.boundVertexOffset!==s||this.boundDynamicVertexBuffer!==n||this.boundDynamicVertexBuffer2!==l||this.boundDynamicVertexBuffer3!==h?this.freshBind(i,r,a,o,s,n,l,h):t.bindVertexArray.set(this.vao)}freshBind(t,i,r,a,o,s,n,l){let h=t.numAttributes,c=this.context,u=c.gl;for(let h of(this.vao&&this.destroy(),this.vao=c.createVertexArray(),c.bindVertexArray.set(this.vao),this.boundProgram=t,this.boundLayoutVertexBuffer=i,this.boundPaintVertexBuffers=r,this.boundIndexBuffer=a,this.boundVertexOffset=o,this.boundDynamicVertexBuffer=s,this.boundDynamicVertexBuffer2=n,this.boundDynamicVertexBuffer3=l,i.enableAttributes(u,t),r))h.enableAttributes(u,t);for(let a of(s&&s.enableAttributes(u,t),n&&n.enableAttributes(u,t),l&&l.enableAttributes(u,t),i.bind(),i.setVertexAttribPointers(u,t,o),r))a.bind(),a.setVertexAttribPointers(u,t,o);s&&(s.bind(),s.setVertexAttribPointers(u,t,o)),a&&a.bind(),n&&(n.bind(),n.setVertexAttribPointers(u,t,o)),l&&(l.bind(),l.setVertexAttribPointers(u,t,o)),c.currentNumAttributes=h}destroy(){this.vao&&=(this.context.deleteVertexArray(this.vao),null)}};let iV=(t,i,r,a,o)=>({u_texture:0,u_ele_delta:t,u_fog_matrix:i,u_fog_color:r?r.properties.get("fog-color"):m.fn.white,u_fog_ground_blend:r?r.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:o?0:r?r.calculateFogBlendOpacity(a):0,u_horizon_color:r?r.properties.get("horizon-color"):m.fn.white,u_horizon_fog_blend:r?r.properties.get("horizon-fog-blend"):1,u_is_globe_mode:+!!o}),iq=t=>({u_ele_delta:t}),iW={ProjectionUBO:0,TerrainUBO:1,FrameUBO:2},i$={float:[1,1],int:[1,1],vec2:[2,2],vec4:[4,4],mat4:[16,4]};function iH(t){let i={},r=0;for(let{name:a,type:o}of t){let[t,s]=i$[o];r=Math.ceil(r/s)*s,i[a]=r,r+=t}return{offsets:i,contentWords:r,sizeWords:4*Math.ceil(r/4)}}var iX=class{constructor(t,i,r){this.context=t,this.binding=i,this.contentWords=r.contentWords;let a=t.gl;this.buffer=a.createBuffer(),a.bindBuffer(a.UNIFORM_BUFFER,this.buffer),a.bufferData(a.UNIFORM_BUFFER,4*r.sizeWords,a.DYNAMIC_DRAW),a.bindBufferBase(a.UNIFORM_BUFFER,i,this.buffer),this.uploaded=new Float32Array(r.sizeWords),this.pending=new Float32Array(r.sizeWords),this.uploadedWords=new Uint32Array(this.uploaded.buffer),this.pendingWords=new Uint32Array(this.pending.buffer),this.hasData=!1,this.bindingDirty=!1}upload(){let t=this.context.gl,i=!this.hasData;if(!i){let t=this.pendingWords,r=this.uploadedWords;for(let a=0;a<this.contentWords;a++)if(t[a]!==r[a]){i=!0;break}}this.bind(),i&&(t.bindBufferBase(t.UNIFORM_BUFFER,this.binding,this.buffer),t.bufferSubData(t.UNIFORM_BUFFER,0,this.pending),this.uploaded.set(this.pending),this.hasData=!0)}bind(){if(!this.bindingDirty)return;let t=this.context.gl;t.bindBufferBase(t.UNIFORM_BUFFER,this.binding,this.buffer),this.bindingDirty=!1}destroy(){let t=this.context.gl;this.buffer&&(t.deleteBuffer(this.buffer),delete this.buffer)}};let iY=iH([{name:"u_projection_matrix",type:"mat4"},{name:"u_projection_fallback_matrix",type:"mat4"},{name:"u_projection_tile_mercator_coords",type:"vec4"},{name:"u_projection_clipping_plane",type:"vec4"},{name:"u_projection_transition",type:"float"},{name:"u_projection_clip_antimeridian",type:"int"}]),iK=iY.offsets,iJ=iH([{name:"u_terrain_matrix",type:"mat4"},{name:"u_terrain_unpack",type:"vec4"},{name:"u_terrain_dim",type:"float"},{name:"u_terrain_exaggeration",type:"float"}]),iQ=iJ.offsets;function i0(t){let i=[];for(let r of t){if(null===r)continue;let t=r.split(" ");i.push(t.pop())}return i}var i1=class{constructor(t,i,r,a,o,s,n,l,h=[]){let c=t.gl;this.program=c.createProgram();let u=i0(i.staticAttributes),d=r?r.getBinderAttributes():[],_=u.concat(d),p=tW.prelude.staticUniforms?i0(tW.prelude.staticUniforms):[],f=i.staticUniforms?i0(i.staticUniforms):[],g=r?r.getBinderUniforms():[],v=p.concat(f).concat(g),y=[];for(let t of v)y.includes(t)||y.push(t);let x=r?r.defines():[];x.unshift("#version 300 es"),o&&x.push("#define OVERDRAW_INSPECTOR;"),s&&x.push("#define TERRAIN3D;"),l&&x.push(l),h&&x.push(...h);let b=x.concat(tW.prelude.fragmentSource,n.fragmentSource,i.fragmentSource).join(`
813`),w=x.concat(tW.prelude.vertexSource,n.vertexSource,i.vertexSource).join(`
814`),T=c.createShader(c.FRAGMENT_SHADER);if(c.isContextLost()){this.failedToCreate=!0;return}c.shaderSource(T,b),c.compileShader(T),c.attachShader(this.program,T);let P=c.createShader(c.VERTEX_SHADER);if(c.isContextLost()){this.failedToCreate=!0;return}c.shaderSource(P,w),c.compileShader(P),c.attachShader(this.program,P),this.attributes={};let M={};if(this.numAttributes=_.length,c.linkProgram(this.program),!c.getProgramParameter(this.program,c.LINK_STATUS)){if
814(c.isContextLost()){this.failedToCreate=!0;return}throw c.getShaderParameter(T,c.COMPILE_STATUS)?c.getShaderParameter(P,c.COMPILE_STATUS)?Error(`Program failed to link: ${c.getProgramInfoLog(this.program)}`):Error(`Could not compile vertex shader: ${c.getShaderInfoLog(P)}`):Error(`Could not compile fragment shader: ${c.getShaderInfoLog(T)}`)}!function(t,i){for(let[r,a]of Object.entries(iW)){let o=t.getUniformBlockIndex(i,r);o!==t.INVALID_INDEX&&t.uniformBlockBinding(i,o,a)}}(c,this.program);let I=function(t,i){let r=new Set([t.INT,t.INT_VEC2,t.INT_VEC3,t.INT_VEC4,t.UNSIGNED_INT,t.UNSIGNED_INT_VEC2,t.UNSIGNED_INT_VEC3,t.UNSIGNED_INT_VEC4]),a=new Set,o=t.getProgramParameter(i,t.ACTIVE_ATTRIBUTES);for(let s=0;s<o;s++){let o=t.getActiveAttrib(i,s);o&&r.has(o.type)&&a.add(o.name)}return a}(c,this.program);for(let t of _){if(!t)continue;let i=c.getAttribLocation(this.program,t);i>=0&&(this.attributes[t]={location:i,isInteger:I.has(t)})}for(let t of(c.deleteShader(P),c.deleteShader(T),y))if(t&&!M[t]){let i=c.getUniformLocation(this.program,t);i&&(M[t]=i)}this.fixedUniforms=a(t,M),this.terrainUniforms=((t,i)=>({u_depth:new m.Mt(t,i.u_depth),u_terrain:new m.Mt(t,i.u_terrain)}))(t,M),this.binderUniforms=r?r.getUniforms(t,M):[]}draw(t,i,r,a,o,s,n,l,h,c,u,d,_,p,m,f,g,v,y){var x,b;let w,T=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.projectionUniformBuffer.bind(),t.terrainUniformBuffer.bind(),t.frameUniformBuffer.bind(),t.setDepthMode(r),t.setStencilMode(a),t.setColorMode(o),t.setCullFace(s),l){let i;for(let i in t.activeTexture.set(T.TEXTURE2),T.bindTexture(T.TEXTURE_2D,l.depthTexture),t.activeTexture.set(T.TEXTURE3),T.bindTexture(T.TEXTURE_2D,l.texture),this.terrainUniforms)this.terrainUniforms[i].set(l[i]);x=t.terrainUniformBuffer,(i=x.pending).set(l.u_terrain_matrix,iQ.u_terrain_matrix),i.set(l.u_terrain_unpack,iQ.u_terrain_unpack),i[iQ.u_terrain_dim]=l.u_terrain_dim,i[iQ.u_terrain_exaggeration]=l.u_terrain_exaggeration,x.upload()}if(h&&(b=t.projectionUniformBuffer,(w=b.pending).set(h.mainMatrix,iK.u_projection_matrix),w.set(h.fallbackMatrix,iK.u_projection_fallback_matrix),w.set(h.tileMercatorCoords,iK.u_projection_tile_mercator_coords),w.set(h.clippingPlane,iK.u_projection_clipping_plane),w[iK.u_projection_transition]=h.projectionTransition,b.pendingWords[iK.u_projection_clip_antimeridian]=+!!h.clipAntimeridian,b.upload()),n)for(let t in this.fixedUniforms)this.fixedUniforms[t].set(n[t]);f&&f.setUniforms(t,this.binderUniforms,p,{zoom:m});let P=0;switch(i){case T.LINES:P=2;break;case T.TRIANGLES:P=3;break;case T.LINE_STRIP:P=1}for(let r of _.get())r.vaos||={},r.vaos[c]||=new iG,r.vaos[c].bind(t,this,u,f?f.getPaintVertexBuffers():[],d,r.vertexOffset,g,v,y),T.drawElements(i,r.primitiveLength*P,T.UNSIGNED_SHORT,r.primitiveOffset*P*2)}};function i2(t,i,r){let a=1/(0,m.Ir)(r,1,i.transform.tileZoom),o=2**r.tileID.overscaledZ,s=r.tileSize*2**i.transform.tileZoom/o,n=s*(r.tileID.canonical.x+r.tileID.wrap*o),l=s*r.tileID.canonical.y;return{u_image:0,u_texsize:r.imageAtlasTexture.size,u_scale:[a,t.fromScale,t.toScale],u_fade:t.t,u_pixel_coord_upper:[n>>16,l>>16],u_pixel_coord_lower:[65535&n,65535&l]}}let i4=(t,i,r,a)=>{let o=t.style.light,s=o.getCartesianPosition(),n=(0,m.Mi)();"viewport"===o.properties.get("anchor")&&(0,m.Ni)(n,t.transform.bearingInRadians),(0,m.fi)(s,s,n);let l=t.transform.transformLightDirection(s),h=o.properties.get("color");return{u_lightpos:s,u_lightpos_globe:l,u_lightintensity:o.properties.get("intensity"),u_lightcolor:[h.r,h.g,h.b],u_vertical_gradient:+i,u_opacity:r,u_fill_translate:a}},i3=(t,i,r,a,o,s,n)=>(0,m.er)(i4(t,i,r,a),i2(s,t,n),{u_height_factor:-(2**o.overscaledZ)/n.tileSize/8}),i5=(t,i,r,a,o)=>(0,m.er)(i2(i,t,r),{u_fill_translate:a,u_sdf_pattern:+!!o}),i6=t=>({u_fill_translate:t}),i8=t=>({u_fill_translate:t}),i9=(t,i,r,a,o)=>i5(t,i,r,a,o),i7=(t,i,r,a,o)=>{let s=t.transform,n,l,h=0;if("map"===r.paint.get("circle-pitch-alignment")){let t=(0,m.Ir)(i,1,s.zoom);n=!0,l=[t,t],h=t/(m.Lr*2**i.tileID.overscaledZ)*2*Math.PI*o}else n=!1,l=s.pixelsToGLUnits;return{u_scale_with_map:+("map"===r.paint.get("circle-pitch-scale")),u_pitch_with_map:+n,u_extrude_scale:l,u_globe_extrude_scale:h,u_translate:a}},re=(t,i=1)=>({u_color:t,u_overlay:0,u_overlay_scale:i}),rt=(t,i,r,a)=>
814{let o=(0,m.Ir)(t,1,i)/(m.Lr*2**t.tileID.overscaledZ)*2*Math.PI*a;return{u_extrude_scale:(0,m.Ir)(t,1,i),u_intensity:r,u_globe_extrude_scale:o}},ri=(t,i,r,a)=>{let o=(0,m.vi)();return(0,m.Ti)(o,0,t.width,t.height,0,0,1),{u_matrix:o,u_image:r,u_color_ramp:a,u_opacity:i.paint.get("heatmap-opacity")}},rr=(t,i,r)=>{let a=r.paint.get("hillshade-accent-color"),o;switch(r.paint.get("hillshade-method")){case"basic":o=4;break;case"combined":o=1;break;case"igor":o=2;break;case"multidirectional":o=3;break;default:o=0}let s=r.getIlluminationProperties();for(let i=0;i<s.directionRadians.length;i++)"viewport"===r.paint.get("hillshade-illumination-anchor")&&(s.directionRadians[i]+=t.transform.bearingInRadians);return{u_image:0,u_latrange:function(t,i){let r=2**i.canonical.z,a=i.canonical.y;return[new m.nt(0,a/r).toLngLat().lat,new m.nt(0,(a+1)/r).toLngLat().lat]}(0,i.tileID),u_exaggeration:r.paint.get("hillshade-exaggeration"),u_altitudes:s.altitudeRadians,u_azimuths:s.directionRadians,u_accent:a,u_method:o,u_highlights:s.highlightColor,u_shadows:s.shadowColor}},ra=(t,i)=>{let r=i.stride,a=(0,m.vi)();return(0,m.Ti)(a,0,m.Lr,-m.Lr,0,0,1),(0,m.ji)(a,a,[0,-m.Lr,0]),{u_matrix:a,u_image:1,u_dimension:[r,r],u_zoom:t.overscaledZ,u_unpack:i.getUnpackVector()}},ro=(t,i,r=0)=>({u_image:0,u_unpack:i.getUnpackVector(),u_dimension:[i.stride,i.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:r,u_opacity:t.paint.get("color-relief-opacity")}),rs=(t,i,r,a)=>{let o=t.transform;return{u_translation:rd(t,i,r),u_ratio:a/(0,m.Ir)(i,1,o.zoom)}},rn=(t,i,r,a,o)=>(0,m.er)(rs(t,i,r,a),{u_image:0,u_image_height:o}),rl=(t,i,r,a,o)=>{let s=t.transform,n=ru(i,s);return{u_translation:rd(t,i,r),u_texsize:i.imageAtlasTexture.size,u_ratio:a/(0,m.Ir)(i,1,s.zoom),u_image:0,u_scale:[n,o.fromScale,o.toScale],u_fade:o.t}},rh=(t,i,r,a,o)=>{let s=ru(i,t.transform);return(0,m.er)(rs(t,i,r,a),{u_tileratio:s,u_crossfade_from:o.fromScale,u_crossfade_to:o.toScale,u_image:0,u_mix:o.t,u_lineatlas_width:t.lineAtlas.width,u_lineatlas_height:t.lineAtlas.height})},rc=(t,i,r,a,o,s)=>{let n=ru(i,t.transform);return(0,m.er)(rs(t,i,r,a),{u_image:0,u_image_height:s,u_tileratio:n,u_crossfade_from:o.fromScale,u_crossfade_to:o.toScale,u_image_dash:1,u_mix:o.t,u_lineatlas_width:t.lineAtlas.width,u_lineatlas_height:t.lineAtlas.height})};function ru(t,i){return 1/(0,m.Ir)(t,1,i.tileZoom)}function rd(t,i,r){return(0,m.jr)(t.transform,i,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}let r_=(t,i,r,a,o,s,n,l,h,c,u,d,_,p,m)=>({u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:i?i.uSizeT:0,u_size:i?i.uSize:0,u_rotate_symbol:+r,u_label_plane_matrix:l,u_coord_matrix:h,u_is_text:+u,u_pitch_with_map:+a,u_is_along_line:o,u_is_variable_anchor:s,u_texsize:d,u_texture:0,u_translation:c,u_pitched_scale:_,u_is_offset:p,u_height_anchor_ground:+m}),rp=(t,i,r,a,o,s,n,l,h,c,u,d,_,p,f,g)=>{let v=n.transform;return(0,m.er)(r_(t,i,r,a,o,s,n,l,h,c,u,d,p,f,g),{u_gamma_scale:a?Math.cos(v.pitch*Math.PI/180)*v.cameraToCenterDistance:1,u_is_halo:+!!_,u_is_plain:1})},rm=(t,i,r,a,o,s,n,l,h,c,u,d,_,p,f)=>(0,m.er)(rp(t,i,r,a,o,s,n,l,h,c,!0,u,!0,_,p,f),{u_texsize_icon:d,u_texture_icon:1}),rf=(t,i)=>({u_opacity:t,u_color:i}),rg=(t,i,r,a,o)=>(0,m.er)(function(t,i,r,a){let o=r.patternAtlas.getPattern(t.from.toString()),s=r.patternAtlas.getPattern(t.to.toString()),{width:n,height:l}=r.patternAtlas.getPixelSize(),h=2**a.tileID.overscaledZ,c=a.tileSize*2**r.transform.tileZoom/h,u=c*(a.tileID.canonical.x+a.tileID.wrap*h),d=c*a.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:o.tl,u_pattern_br_a:o.br,u_pattern_tl_b:s.tl,u_pattern_br_b:s.br,u_texsize:[n,l],u_mix:i.t,u_pattern_size_a:o.displaySize,u_pattern_size_b:s.displaySize,u_scale_a:i.fromScale,u_scale_b:i.toScale,u_tile_units_to_pixels:1/(0,m.Ir)(a,1,r.transform.tileZoom),u_pixel_coord_upper:[u>>16,d>>16],u_pixel_coord_lower:[65535&u,65535&d]}}(r,o,i,a),{u_opacity:t}),rv=(t,i)=>({}),ry={fillExtrusion:(t,i)=>({u_lightpos:new m.Pt(t,i.u_lightpos),u_lightpos_globe:new m.Pt(t,i.u_lightpos_globe),u_lightintensity:new m.jt(t,i.u_lightintensity),u_lightcolor:new m.Pt(t,i.u_lightcolor),u_vertical_gradient:new m.jt(t,i.u_vertical_gradient),u_opacity:new m.jt(t,i.u_opacity),u_fill_translate:new m.Nt(t,i.u_fill_translate)}),fillExtrusionPattern:(t,i)=>({u_lightpos:new m.Pt(t,i.u_lightpos),u_lightpos_globe:new m.Pt(t,i.u_lightpos_globe),u_lightintensity:new m.jt(t,i.u_lightintensity),u_lightcolor:new m.Pt(t,i.u_lightcolor),u_vertical_gradient:new m.jt(t,i.u_vertical_gradient),u_height_factor:new m.jt(t,i.u_height_factor),u_opacity:new m.jt(t,i.u_opacity),u_fill_translate:new m.Nt(t,i.u_fill_translate),u_image:new m.Mt(t,i.u_image),u_texsize:new m.Nt(t,i.u_texsize),u_pixel_coord_upper:new m.Nt(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new m.Nt(t,i.u_pixel_coord_lower),u_scale:new m.Pt(t,i.u_scale),u_fade:new m.jt(t,i.u_fade)}),fill:(t,i)=>({u_fill_translate:new m.Nt(t,i.u_fill_translate)}),fillPattern:(t,i)=>({u_image:new m.Mt(t,i.u_image),u_texsize:new m.Nt(t,i.u_texsize),u_pixel_coord_upper:new m.Nt(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new m.Nt(t,i.u_pixel_coord_lower),u_scale:new m.Pt(t,i.u_scale),u_fade:new m.jt(t,i.u_fade),u_sdf_pattern:new m.Mt(t,i.u_sdf_pattern),u_fill_translate:new m.Nt(t,i.u_fill_translate)}),fillOutline:(t,i)=>({u_fill_translate:new m.Nt(t,i.u_fill_translate)}),fillOutlinePattern:(t,i)=>({u_image:new m.Mt(t,i.u_image),u_texsize:new m.Nt(t,i.u_texsize),u_pixel_coord_upper:new m.Nt(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new m.Nt(t,i.u_pixel_coord_lower),u_scale:new m.Pt(t,i.u_scale),u_fade:new m.jt(t,i.u_fade),u_sdf_pattern:new m.Mt(t,i.u_sdf_pattern),u_fill_translate:new m.Nt(t,i.u_fill_translate)}),circle:(t,i)=>({u_scale_with_map:new m.Mt(t,i.u_scale_with_map),u_pitch_with_map:new m.Mt(t,i.u_pitch_with_map),u_extrude_scale:new m.Nt(t,i.u_extrude_scale),u_globe_extrude_scale:new m.jt(t,i.u_globe_extrude_scale),u_translate:new m.Nt(t,i.u_translate)}),collisionBox:rv,collisionCircle:rv,debug:(t,i)=>({u_color:new m.It(t,i.u_color),u_overlay:new m.Mt(t,i.u_overlay),u_overlay_scale:new m.jt(t,i.u_overlay_scale)}),depth:rv,clippingMask:rv,heatmap:(t,i)=>({u_extrude_scale:new m.jt(t,i.u_extrude_scale),u_intensity:new m.jt(t,i.u_intensity),u_globe_extrude_scale:new m.jt(t,i.u_globe_extrude_scale)}),heatmapTexture:(t,i)=>
814({u_matrix:new m.zt(t,i.u_matrix),u_image:new m.Mt(t,i.u_image),u_color_ramp:new m.Mt(t,i.u_color_ramp),u_opacity:new m.jt(t,i.u_opacity)}),hillshade:(t,i)=>({u_image:new m.Mt(t,i.u_image),u_latrange:new m.Nt(t,i.u_latrange),u_exaggeration:new m.jt(t,i.u_exaggeration),u_altitudes:new m.Rt(t,i.u_altitudes),u_azimuths:new m.Rt(t,i.u_azimuths),u_accent:new m.It(t,i.u_accent),u_method:new m.Mt(t,i.u_method),u_shadows:new m.Lt(t,i.u_shadows),u_highlights:new m.Lt(t,i.u_highlights)}),hillshadePrepare:(t,i)=>({u_matrix:new m.zt(t,i.u_matrix),u_image:new m.Mt(t,i.u_image),u_dimension:new m.Nt(t,i.u_dimension),u_zoom:new m.jt(t,i.u_zoom),u_unpack:new m.Ft(t,i.u_unpack)}),colorRelief:(t,i)=>({u_image:new m.Mt(t,i.u_image),u_unpack:new m.Ft(t,i.u_unpack),u_dimension:new m.Nt(t,i.u_dimension),u_elevation_stops:new m.Mt(t,i.u_elevation_stops),u_color_stops:new m.Mt(t,i.u_color_stops),u_color_ramp_size:new m.Mt(t,i.u_color_ramp_size),u_opacity:new m.jt(t,i.u_opacity)}),line:(t,i)=>({u_translation:new m.Nt(t,i.u_translation),u_ratio:new m.jt(t,i.u_ratio)}),lineGradient:(t,i)=>({u_translation:new m.Nt(t,i.u_translation),u_ratio:new m.jt(t,i.u_ratio),u_image:new m.Mt(t,i.u_image),u_image_height:new m.jt(t,i.u_image_height)}),linePattern:(t,i)=>({u_translation:new m.Nt(t,i.u_translation),u_texsize:new m.Nt(t,i.u_texsize),u_ratio:new m.jt(t,i.u_ratio),u_image:new m.Mt(t,i.u_image),u_scale:new m.Pt(t,i.u_scale),u_fade:new m.jt(t,i.u_fade)}),lineSDF:(t,i)=>({u_translation:new m.Nt(t,i.u_translation),u_ratio:new m.jt(t,i.u_ratio),u_image:new m.Mt(t,i.u_image),u_mix:new m.jt(t,i.u_mix),u_tileratio:new m.jt(t,i.u_tileratio),u_crossfade_from:new m.jt(t,i.u_crossfade_from),u_crossfade_to:new m.jt(t,i.u_crossfade_to),u_lineatlas_width:new m.jt(t,i.u_lineatlas_width),u_lineatlas_height:new m.jt(t,i.u_lineatlas_height)}),lineGradientSDF:(t,i)=>({u_translation:new m.Nt(t,i.u_translation),u_ratio:new m.jt(t,i.u_ratio),u_image:new m.Mt(t,i.u_image),u_image_height:new m.jt(t,i.u_image_height),u_tileratio:new m.jt(t,i.u_tileratio),u_crossfade_from:new m.jt(t,i.u_crossfade_from),u_crossfade_to:new m.jt(t,i.u_crossfade_to),u_image_dash:new m.Mt(t,i.u_image_dash),u_mix:new m.jt(t,i.u_mix),u_lineatlas_width:new m.jt(t,i.u_lineatlas_width),u_lineatlas_height:new m.jt(t,i.u_lineatlas_height)}),layerOpacity:(t,i)=>({u_image:new m.Mt(t,i.u_image),u_opacity:new m.jt(t,i.u_opacity)}),raster:(t,i)=>({u_tl_parent:new m.Nt(t,i.u_tl_parent),u_scale_parent:new m.jt(t,i.u_scale_parent),u_buffer_scale:new m.jt(t,i.u_buffer_scale),u_image_warp:new m.Pt(t,i.u_image_warp),u_fade_t:new m.jt(t,i.u_fade_t),u_opacity:new m.jt(t,i.u_opacity),u_image0:new m.Mt(t,i.u_image0),u_image1:new m.Mt(t,i.u_image1),u_brightness_low:new m.jt(t,i.u_brightness_low),u_brightness_high:new m.jt(t,i.u_brightness_high),u_saturation_factor:new m.jt(t,i.u_saturation_factor),u_contrast_factor:new m.jt(t,i.u_contrast_factor),u_spin_weights:new m.Pt(t,i.u_spin_weights),u_coords_top:new m.Ft(t,i.u_coords_top),u_coords_bottom:new m.Ft(t,i.u_coords_bottom)}),symbolIcon:(t,i)=>({u_is_size_zoom_constant:new m.Mt(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new m.Mt(t,i.u_is_size_feature_constant),u_size_t:new m.jt(t,i.u_size_t),u_size:new m.jt(t,i.u_size),u_rotate_symbol:new m.Mt(t,i.u_rotate_symbol),u_label_plane_matrix:new m.zt(t,i.u_label_plane_matrix),u_coord_matrix:new m.zt(t,i.u_coord_matrix),u_is_text:new m.Mt(t,i.u_is_text),u_pitch_with_map:new m.Mt(t,i.u_pitch_with_map),u_is_along_line:new m.Mt(t,i.u_is_along_line),u_is_variable_anchor:new m.Mt(t,i.u_is_variable_anchor),u_texsize:new m.Nt(t,i.u_texsize),u_texture:new m.Mt(t,i.u_texture),u_translation:new m.Nt(t,i.u_translation),u_pitched_scale:new m.jt(t,i.u_pitched_scale),u_is_offset:new m.Mt(t,i.u_is_offset),u_height_anchor_ground:new m.Mt(t,i.u_height_anchor_ground)}),symbolSDF:(t,i)=>({u_is_size_zoom_constant:new m.Mt(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new m.Mt(t,i.u_is_size_feature_constant),u_size_t:new m.jt(t,i.u_size_t),u_size:new m.jt(t,i.u_size),u_rotate_symbol:new m.Mt(t,i.u_rotate_symbol),u_label_plane_matrix:new m.zt(t,
814i.u_label_plane_matrix),u_coord_matrix:new m.zt(t,i.u_coord_matrix),u_is_text:new m.Mt(t,i.u_is_text),u_pitch_with_map:new m.Mt(t,i.u_pitch_with_map),u_is_along_line:new m.Mt(t,i.u_is_along_line),u_is_variable_anchor:new m.Mt(t,i.u_is_variable_anchor),u_texsize:new m.Nt(t,i.u_texsize),u_texture:new m.Mt(t,i.u_texture),u_gamma_scale:new m.jt(t,i.u_gamma_scale),u_is_halo:new m.Mt(t,i.u_is_halo),u_is_plain:new m.Mt(t,i.u_is_plain),u_translation:new m.Nt(t,i.u_translation),u_pitched_scale:new m.jt(t,i.u_pitched_scale),u_is_offset:new m.Mt(t,i.u_is_offset),u_height_anchor_ground:new m.Mt(t,i.u_height_anchor_ground)}),symbolTextAndIcon:(t,i)=>({u_is_size_zoom_constant:new m.Mt(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new m.Mt(t,i.u_is_size_feature_constant),u_size_t:new m.jt(t,i.u_size_t),u_size:new m.jt(t,i.u_size),u_rotate_symbol:new m.Mt(t,i.u_rotate_symbol),u_label_plane_matrix:new m.zt(t,i.u_label_plane_matrix),u_coord_matrix:new m.zt(t,i.u_coord_matrix),u_is_text:new m.Mt(t,i.u_is_text),u_pitch_with_map:new m.Mt(t,i.u_pitch_with_map),u_is_along_line:new m.Mt(t,i.u_is_along_line),u_is_variable_anchor:new m.Mt(t,i.u_is_variable_anchor),u_texsize:new m.Nt(t,i.u_texsize),u_texsize_icon:new m.Nt(t,i.u_texsize_icon),u_texture:new m.Mt(t,i.u_texture),u_texture_icon:new m.Mt(t,i.u_texture_icon),u_gamma_scale:new m.jt(t,i.u_gamma_scale),u_is_halo:new m.Mt(t,i.u_is_halo),u_translation:new m.Nt(t,i.u_translation),u_pitched_scale:new m.jt(t,i.u_pitched_scale),u_is_offset:new m.Mt(t,i.u_is_offset),u_height_anchor_ground:new m.Mt(t,i.u_height_anchor_ground)}),background:(t,i)=>({u_opacity:new m.jt(t,i.u_opacity),u_color:new m.It(t,i.u_color)}),backgroundPattern:(t,i)=>({u_opacity:new m.jt(t,i.u_opacity),u_image:new m.Mt(t,i.u_image),u_pattern_tl_a:new m.Nt(t,i.u_pattern_tl_a),u_pattern_br_a:new m.Nt(t,i.u_pattern_br_a),u_pattern_tl_b:new m.Nt(t,i.u_pattern_tl_b),u_pattern_br_b:new m.Nt(t,i.u_pattern_br_b),u_texsize:new m.Nt(t,i.u_texsize),u_mix:new m.jt(t,i.u_mix),u_pattern_size_a:new m.Nt(t,i.u_pattern_size_a),u_pattern_size_b:new m.Nt(t,i.u_pattern_size_b),u_scale_a:new m.jt(t,i.u_scale_a),u_scale_b:new m.jt(t,i.u_scale_b),u_pixel_coord_upper:new m.Nt(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new m.Nt(t,i.u_pixel_coord_lower),u_tile_units_to_pixels:new m.jt(t,i.u_tile_units_to_pixels)}),terrain:(t,i)=>({u_texture:new m.Mt(t,i.u_texture),u_ele_delta:new m.jt(t,i.u_ele_delta),u_fog_matrix:new m.zt(t,i.u_fog_matrix),u_fog_color:new m.It(t,i.u_fog_color),u_fog_ground_blend:new m.jt(t,i.u_fog_ground_blend),u_fog_ground_blend_opacity:new m.jt(t,i.u_fog_ground_blend_opacity),u_horizon_color:new m.It(t,i.u_horizon_color),u_horizon_fog_blend:new m.jt(t,i.u_horizon_fog_blend),u_is_globe_mode:new m.jt(t,i.u_is_globe_mode)}),terrainDepth:(t,i)=>({u_ele_delta:new m.jt(t,i.u_ele_delta)}),atmosphere:(t,i)=>({u_sun_pos:new m.Pt(t,i.u_sun_pos),u_atmosphere_blend:new m.jt(t,i.u_atmosphere_blend),u_globe_position:new m.Pt(t,i.u_globe_position),u_globe_radius:new m.jt(t,i.u_globe_radius),u_inv_proj_matrix:new m.zt(t,i.u_inv_proj_matrix)}),sky:(t,i)=>({u_sky_color:new m.It(t,i.u_sky_color),u_horizon_color:new m.It(t,i.u_horizon_color),u_horizon:new m.Nt(t,i.u_horizon),u_horizon_normal:new m.Nt(t,i.u_horizon_normal),u_sky_horizon_blend:new m.jt(t,i.u_sky_horizon_blend),u_sky_blend:new m.jt(t,i.u_sky_blend),u_inv_proj_matrix:new m.zt(t,i.u_inv_proj_matrix),u_globe_position:new m.Pt(t,i.u_globe_position),u_globe_radius:new m.jt(t,i.u_globe_radius),u_atmosphere_blend:new m.jt(t,i.u_atmosphere_blend)})};var rx=class{constructor(t,i,r){this.context=t;let a=t.gl;this.buffer=a.createBuffer(),this.dynamicDraw=!!r,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,i.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||i.freeBufferAfterUpload()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){let i=this.context.gl;if(!this.dynamicDraw)throw Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),i.bufferSubData(i.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){let t=this.context.gl;this.buffer&&(t.deleteBuffer(this.buffer),delete this.buffer)}};let rb={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};var rw=class{constructor(t,i,r,a){this.length=i.length,this.attributes=r,this.itemSize=i.bytesPerElement,this.dynamicDraw=a,this.context=t;let o=t.gl;this.buffer=o.createBuffer(),t.bindVertexBuffer.set(this.buffer),o.bufferData(o.ARRAY_BUFFER,i.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||i.freeBufferAfterUpload()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){if(t.length!==this.length)throw Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);let i=this.context.gl;this.bind(),i.bufferSubData(i.ARRAY_BUFFER,0,t.arrayBuffer)}
vendor: 7,090 bytes, line 814
814enableAttributes(t,i){for(let r of this.attributes){let a=i.attributes[r.name];void 0!==a&&t.enableVertexAttribArray(a.location)}}setVertexAttribPointers(t,i,r){for(let a of this.attributes){let o=i.attributes[a.name];if(void 0!==o){let i=a.offset+this.itemSize*(r||0);o.isInteger?t.vertexAttribIPointer(o.location,a.components,t[rb[a.type]],this.itemSize,i):t.vertexAttribPointer(o.location,a.components,t[rb[a.type]],!1,this.itemSize,i)}}}destroy(){let t=this.context.gl;this.buffer&&(t.deleteBuffer(this.buffer),delete this.buffer)}},rT=class{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}},rP=class extends rT{getDefault(){return m.fn.transparent}set(t){let i=this.current;(t.r!==i.r||t.g!==i.g||t.b!==i.b||t.a!==i.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}},rM=class extends rT{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}},rI=class extends rT{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}},rC=class extends rT{getDefault(){return[!0,!0,!0,!0]}set(t){let i=this.current;(t[0]!==i[0]||t[1]!==i[1]||t[2]!==i[2]||t[3]!==i[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}},rS=class extends rT{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}},rE=class extends rT{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}},rz=class extends rT{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){let i=this.current;(t.func!==i.func||t.ref!==i.ref||t.mask!==i.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}},rR=class extends rT{getDefault(){let t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){let i=this.current;(t[0]!==i[0]||t[1]!==i[1]||t[2]!==i[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}},rD=class extends rT{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let i=this.gl;t?i.enable(i.STENCIL_TEST):i.disable(i.STENCIL_TEST),this.current=t,this.dirty=!1}},rL=class extends rT{getDefault(){return[0,1]}set(t){let i=this.current;(t[0]!==i[0]||t[1]!==i[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}},rA=class extends rT{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let i=this.gl;t?i.enable(i.DEPTH_TEST):i.disable(i.DEPTH_TEST),this.current=t,this.dirty=!1}},rF=class extends rT{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}},rk=class extends rT{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let i=this.gl;t?i.enable(i.BLEND):i.disable(i.BLEND),this.current=t,this.dirty=!1}},rB=class extends rT{getDefault(){let t=this.gl;return[t.ONE,t.ZERO]}set(t){let i=this.current;(t[0]!==i[0]||t[1]!==i[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}},rO=class extends rT{getDefault(){return m.fn.transparent}set(t){let i=this.current;(t.r!==i.r||t.g!==i.g||t.b!==i.b||t.a!==i.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}},rj=class extends rT{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}},rN=class extends rT{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let i=this.gl;t?i.enable(i.CULL_FACE):i.disable(i.CULL_FACE),this.current=t,this.dirty=!1}},rZ=class extends rT{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}},rU=class extends rT{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}},rG=class extends rT{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}},rV=class extends rT{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}},rq=class extends rT{getDefault(){let t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){let i=this.current;(t[0]!==i[0]||t[1]!==i[1]||t[2]!==i[2]||t[3]!==i[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}},rW=class extends rT{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let i=this.gl;i.bindFramebuffer(i.FRAMEBUFFER,t),this.current=t,this.dirty=!1}},r$=class extends rT{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let i=this.gl;i.bindRenderbuffer(i.RENDERBUFFER,t),this.current=t,this.dirty=!1}},rH=class extends rT{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let i=this.gl;i.bindTexture(i.TEXTURE_2D,t),this.current=t,this.dirty=!1}},rX=class extends rT{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let i=this.gl;i.bindBuffer(i.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}},rY=class extends rT{getDefault(){return null}set(t){let i=this.gl;i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}},rK=class extends rT{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.bindVertexArray(t),this.current=t,this.dirty=!1)}},rJ=class extends rT{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;let i=this.gl;i.pixelStorei(i.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}},rQ=class extends rT{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let i=this.gl;i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}},r0=class extends rT{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let i=this.gl;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}},r1=class extends rT{constructor(t,i){super(t),this.context=t,this.parent=i}getDefault(){return null}},r2=class extends r1{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let i=this.gl;i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}},r4=class extends r1{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let i=this.gl;i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,t),this.current=t,this.dirty=!1}},r3=class extends r1{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let i=this.gl;i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,t),this.current=t,this.dirty=!1}},r5=class{constructor(t,i,r,a,o){this.context=t,this.width=i,this.height=r;let s=t.gl,n=this.framebuffer=s.createFramebuffer();
vendor: 6,959 bytes, line 814
814if(this.colorAttachment=new r2(t,n),a)this.depthAttachment=o?new r3(t,n):new r4(t,n);else if(o)throw Error("Stencil cannot be set without depth")}destroy(){let t=this.context.gl,i=this.colorAttachment.get();if(i&&t.deleteTexture(i),this.depthAttachment){let i=this.depthAttachment.get();i&&t.deleteRenderbuffer(i)}t.deleteFramebuffer(this.framebuffer)}};let r6=iH([{name:"u_units_to_pixels",type:"vec2"},{name:"u_world_size",type:"vec2"},{name:"u_camera_to_center_distance",type:"float"},{name:"u_symbol_fade_change",type:"float"},{name:"u_aspect_ratio",type:"float"},{name:"u_device_pixel_ratio",type:"float"},{name:"u_viewport_size",type:"vec2"},{name:"u_pixel_extrude_scale",type:"vec2"},{name:"u_pitch",type:"float"}]),r8=r6.offsets;var r9=class{constructor(t,i,r){this.blendFunction=t,this.blendColor=i,this.mask=r}};r9.Replace=[1,0],r9.disabled=new r9(r9.Replace,m.fn.transparent,[!1,!1,!1,!1]),r9.unblended=new r9(r9.Replace,m.fn.transparent,[!0,!0,!0,!0]),r9.alphaBlended=new r9([1,771],m.fn.transparent,[!0,!0,!0,!0]);var r7=class{constructor(t){this.gl=t,this.clearColor=new rP(this),this.clearDepth=new rM(this),this.clearStencil=new rI(this),this.colorMask=new rC(this),this.depthMask=new rS(this),this.stencilMask=new rE(this),this.stencilFunc=new rz(this),this.stencilOp=new rR(this),this.stencilTest=new rD(this),this.depthRange=new rL(this),this.depthTest=new rA(this),this.depthFunc=new rF(this),this.blend=new rk(this),this.blendFunc=new rB(this),this.blendColor=new rO(this),this.blendEquation=new rj(this),this.cullFace=new rN(this),this.cullFaceSide=new rZ(this),this.frontFace=new rU(this),this.program=new rG(this),this.activeTexture=new rV(this),this.viewport=new rq(this),this.bindFramebuffer=new rW(this),this.bindRenderbuffer=new r$(this),this.bindTexture=new rH(this),this.bindVertexBuffer=new rX(this),this.bindElementBuffer=new rY(this),this.bindVertexArray=new rK(this),this.pixelStoreUnpack=new rJ(this),this.pixelStoreUnpackPremultiplyAlpha=new rQ(this),this.pixelStoreUnpackFlipY=new r0(this),this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),t.getExtension("EXT_color_buffer_half_float"),t.getExtension("EXT_color_buffer_float"),this.projectionUniformBuffer=new iX(this,iW.ProjectionUBO,iY),this.terrainUniformBuffer=new iX(this,iW.TerrainUBO,iJ),this.frameUniformBuffer=new iX(this,iW.FrameUBO,r6)}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0,this.projectionUniformBuffer.bindingDirty=!0,this.terrainUniformBuffer.bindingDirty=!0,this.frameUniformBuffer.bindingDirty=!0}setCustomLayerDefaults(){this.unbindVAO(),this.cullFace.setDefault(),this.activeTexture.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}createIndexBuffer(t,i){return new rx(this,t,i)}createVertexBuffer(t,i,r){return new rw(this,t,i,r)}createRenderbuffer(t,i,r){let a=this.gl,o=a.createRenderbuffer();return this.bindRenderbuffer.set(o),a.renderbufferStorage(a.RENDERBUFFER,t,i,r),this.bindRenderbuffer.set(null),o}createFramebuffer(t,i,r,a){return new r5(this,t,i,r,a)}clear({color:t,depth:i,stencil:r}){let a=this.gl,o=0;t&&(o|=a.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),void 0!==i&&(o|=a.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(i),this.depthMask.set(!0)),void 0!==r&&(o|=a.STENCIL_BUFFER_BIT,this.clearStencil.set(r),this.stencilMask.set(255)),a.clear(o)}setCullFace(t){!1===t.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func!==this.gl.ALWAYS||t.mask?(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range)):this.depthTest.set(!1)}setStencilMode(t){t.test.func!==this.gl.ALWAYS||t.mask?(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask})):this.stencilTest.set(!1)}setColorMode(t){(0,m.qn)(t.blendFunction,r9.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor)),this.colorMask.set(t.mask)}createVertexArray(){return this.gl.createVertexArray()}deleteVertexArray(t){this.gl.deleteVertexArray(t)}unbindVAO(){this.bindVertexArray.set(null)}},ae=class{constructor(t,i,r){this.func=t,this.mask=i,this.range=r}};ae.ReadOnly=!1,ae.ReadWrite=!0,ae.disabled=new ae(519,ae.ReadOnly,[0,1]);var at=class{constructor(t,i,r,a,o,s){this.test=t,this.ref=i,this.mask=r,this.fail=a,this.depthFail=o,this.pass=s}};at.disabled=new at({func:519,mask:0},0,0,7680,7680,7680);var ai=class{constructor(t,i,r){this.enable=t,this.mode=i,this.frontFace=r}};function ar(t,i,r={}){return t.transform.getProjectionData({overscaledTileID:i,aligned:r.aligned,applyGlobeMatrix:!t.isRenderingToTexture,applyTerrainMatrix:r.applyTerrainMatrix??!0})}function aa(t,i){return t.isRenderingToTexture?null:t.terrain?.getTerrainData(i)??null}function ao(t,i,r,a,o,s){let n=t.context,l=n.gl,h=t.useProgram("collisionBox"),c=[],u=0,d=0;for(let _ of a){let a=i.getTile(_).getBucket(r);
814if(!a)continue;let p=o?a.textCollisionBox:a.iconCollisionBox,m=a.collisionCircleArray;m.length>0&&(c.push({circleArray:m,circleOffset:d,coord:_}),u+=m.length/4,d=u),p&&h.draw(n,l.LINES,ae.disabled,at.disabled,t.colorModeForRenderPass(),ai.disabled,null,aa(s,_),ar(s,_),r.id,p.layoutVertexBuffer,p.indexBuffer,p.segments,null,t.transform.zoom,null,null,p.collisionVertexBuffer)}if(!o||!c.length)return;let p=t.useProgram("collisionCircle"),f=new m.Ht;f.resize(4*u),f._trim();let g=0;for(let t of c)for(let i=0;i<t.circleArray.length/4;i++){let r=4*i,a=t.circleArray[r+0],o=t.circleArray[r+1],s=t.circleArray[r+2],n=t.circleArray[r+3];f.emplace(g++,a,o,s,n,0),f.emplace(g++,a,o,s,n,1),f.emplace(g++,a,o,s,n,2),f.emplace(g++,a,o,s,n,3)}(!_||_.length<2*u)&&(_=function(t){let i=2*t,r=new m.Kt;r.resize(i),r._trim();for(let t=0;t<i;t++){let i=6*t;r.uint16[i+0]=4*t+0,r.uint16[i+1]=4*t+1,r.uint16[i+2]=4*t+2,r.uint16[i+3]=4*t+2,r.uint16[i+4]=4*t+3,r.uint16[i+5]=4*t+0}return r}(u));let v=n.createIndexBuffer(_,!0),y=n.createVertexBuffer(f,m.U.members,!0);for(let i of c)p.draw(n,l.TRIANGLES,ae.disabled,at.disabled,t.colorModeForRenderPass(),ai.disabled,null,aa(s,i.coord),null,r.id,y,v,m.Bt.simpleSegment(0,2*i.circleOffset,i.circleArray.length,i.circleArray.length/2),null,t.transform.zoom,null,null,null);y.destroy(),v.destroy()}ai.disabled=new ai(!1,1029,2305),ai.backCCW=new ai(!0,1029,2305),ai.frontCCW=new ai(!0,1028,2305);let as=(0,m.Si)(new Float32Array(16));function an(t,i,r,a,o,s,n,l,h,c,u,d,_){let p=t.context,f=p.gl,g=t.transform,v="map"===l,y="map"===h,x="viewport"!==l&&"point"!==r.layout.get("symbol-placement"),b=v&&!y&&!x,w=!r.layout.get("symbol-sort-key").isConstant(),T=!1,P=t.getDepthModeForSublayer(0,ae.ReadOnly),M=r._unevaluatedLayout.hasValue("text-variable-anchor")||r._unevaluatedLayout.hasValue("text-variable-anchor-offset"),I=[],C=g.getCircleRadiusCorrection();for(let l of a){let a=i.getTile(l),h=a.getBucket(r);if(!h)continue;let u=o?h.text:h.icon;if(!u?.segments.get().length||!u.hasVisibleVertices)continue;let d=u.programConfigurations.get(r.id),p=o||h.sdfIcons,P=o?h.textSizeData:h.iconSizeData,S=y||0!==g.pitch,E=t.useProgram(h.iconsInText&&o?"symbolTextAndIcon":p?"symbolSDF":"symbolIcon",d),z=(0,m.A)(P,g.zoom),R=aa(_,l),D,L=[0,0],A,F,k=null,B;if(o){if(A=a.glyphAtlasTexture,F=f.LINEAR,D=a.glyphAtlasTexture.size,h.iconsInText){L=a.imageAtlasTexture.size,k=a.imageAtlasTexture;let i="composite"===P.kind||"camera"===P.kind;B=S||t.options.rotating||t.options.zooming||i?f.LINEAR:f.NEAREST}}else{let i=1!==r.layout.get("icon-size").constantOr(0)||h.iconsNeedLinear;A=a.imageAtlasTexture,F=p||t.options.rotating||t.options.zooming||i||S?f.LINEAR:f.NEAREST,D=a.imageAtlasTexture.size}let O=(0,m.Ir)(a,1,t.transform.zoom),j=te(v,t.transform,O),N=function(t,i,r,a){if(t){let t=(0,m.vi)();if(!i){let{vecSouth:i,vecEast:a}=tt(r);t[0]=a[0],t[1]=a[1],t[4]=i[0],t[5]=i[1]}return(0,m.Ai)(t,t,[a,a,1]),t}return r.pixelsToClipSpaceMatrix}(y,v,t.transform,O),Z=(0,m.jr)(g,a,s,n),U=ar(_,l),G=M&&h.hasTextData(),V="none"!==r.layout.get("icon-text-fit")&&G&&h.hasIconData(),q=r._unevaluatedLayout.hasValue("icon-offset"),W="ground"===r.layout.get("symbol-height-anchor");if(x){let i=(0,m.vi)();!function(t,i){let r=1/(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]),a=1/(i[8]*i[8]+i[9]*i[9]+i[10]*i[10]),o=i[0]*r,s=i[4]*r,n=i[8]*a,l=i[1]*r,h=i[5]*r,c=i[9]*a,u=i[2]*r,d=i[6]*r,_=i[10]*a;t[0]=o,t[1]=s,t[2]=n,t[4]=l,t[5]=h,t[6]=c,t[8]=u,t[9]=d,t[10]=_;let p=i[12],m=i[13],f=i[14];t[12]=-o*p-l*m-u*f,t[13]=-s*p-h*m-d*f,t[14]=-n*p-c*m-_*f,t[3]=0,t[7]=0,t[11]=0,t[15]=1}(i,j);let a=t.style.map.terrain?(i,r)=>t.style.map.terrain.getElevation(l,i,r):void 0;!function(t,i,r,a,o,s,n,l,h,c,u,d,_){let p=r?t.textSizeData:t.iconSizeData,f=(0,m.A)(p,i.transform.zoom),g=[256/i.width*2+1,256/i.height*2+1],v=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;v.clear();let y=t.lineVertexArray,x=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,b=i.transform.width/i.transform.height,w=!1;for(let r=0;r<x.length;r++){var T;let P=x.get(r);if(P.hidden||2===P.writingMode&&!w){tm(P.numGlyphs,v);continue}w=!1;let M=new m.Li(P.anchorX,P.anchorY),I={getElevation:_,pitchedLabelPlaneMatr
814ix:a,lineVertexArray:y,pitchWithMap:s,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:i.transform,tileAnchorPoint:M,unwrappedTileID:h,width:c,height:u,translation:d},C=tu(P.anchorX,P.anchorY,I);if(T=C.point,!(T.x>=-g[0]&&T.x<=g[0]&&T.y>=-g[1])||!(T.y<=g[1])){tm(P.numGlyphs,v);continue}let S=C.signedDistanceFromCamera,E=.5+i.transform.cameraToCenterDistance/S*.5,z=(0,m.k)(p,f,P),R=s?z*i.transform.getPitchedTextCorrection(P.anchorX,P.anchorY,h)/E:z*E,D=ts({projectionContext:I,pitchedLabelPlaneMatrixInverse:o,symbol:P,fontSize:R,flip:!1,keepUpright:n,glyphOffsetArray:t.glyphOffsetArray,dynamicLayoutVertexArray:v,aspectRatio:b,rotateToLine:l});w=D.useVertical,(D.notEnoughRoom||w||D.needsFlipping&&ts({projectionContext:I,pitchedLabelPlaneMatrixInverse:o,symbol:P,fontSize:R,flip:!0,keepUpright:n,glyphOffsetArray:t.glyphOffsetArray,dynamicLayoutVertexArray:v,aspectRatio:b,rotateToLine:l}).notEnoughRoom)&&tm(P.numGlyphs,v)}r?t.text.dynamicLayoutVertexBuffer.updateData(v):t.icon.dynamicLayoutVertexBuffer.updateData(v)}(h,t,o,j,i,y,c,"map"===r.layout.get("text-rotation-alignment"),l.toUnwrapped(),g.width,g.height,Z,a)}let $=o&&M||V,H=y?j:t.transform.clipSpaceToPixelsMatrix,X=x||$?as:H,Y=p&&0!==r.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1),K={program:E,buffers:u,uniformValues:p?h.iconsInText?rm(P.kind,z,b,y,x,$,t,X,N,Z,D,L,C,q,W):rp(P.kind,z,b,y,x,$,t,X,N,Z,o,D,Y,C,q,W):r_(P.kind,z,b,y,x,$,t,X,N,Z,o,D,C,q,W),projectionData:U,atlasTexture:A,atlasTextureIcon:k,atlasInterpolation:F,atlasInterpolationIcon:B,isSDF:p,hasHalo:Y};if(w&&h.canOverlap)for(let t of(T=!0,u.segments.get()))I.push({segments:new m.Bt([t]),sortKey:t.sortKey,state:K,terrainData:R});else I.push({segments:u.segments,sortKey:0,state:K,terrainData:R})}T&&I.sort((t,i)=>t.sortKey-i.sortKey);let S=r.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(null)??1/0,E=24*r.layout.get("text-letter-spacing").constantOr(0)<0||S>1;for(let i of I){let a=i.state;p.activeTexture.set(f.TEXTURE0),a.atlasTexture.bind(a.atlasInterpolation,f.CLAMP_TO_EDGE),a.atlasTextureIcon&&(p.activeTexture.set(f.TEXTURE1),a.atlasTextureIcon&&a.atlasTextureIcon.bind(a.atlasInterpolationIcon,f.CLAMP_TO_EDGE));let o=a.isSDF&&a.hasHalo;if(o){let o=a.uniformValues;o.u_is_halo=1,E&&(o.u_is_plain=0,al(a.buffers,i.segments,r,t,a.program,P,u,d,o,a.projectionData,i.terrainData),o.u_is_halo=0,o.u_is_plain=1)}al(a.buffers,i.segments,r,t,a.program,P,u,d,a.uniformValues,a.projectionData,i.terrainData),o&&!E&&(a.uniformValues.u_is_halo=0)}}function al(t,i,r,a,o,s,n,l,h,c,u){let d=a.context,_=d.gl;o.draw(d,_.TRIANGLES,s,n,l,ai.backCCW,h,u,c,r.id,t.layoutVertexBuffer,t.indexBuffer,i,r.paint,a.transform.zoom,t.programConfigurations.get(r.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer)}function ah(t,i,r){let a=t.gl,o=a.createTexture();a.bindTexture(a.TEXTURE_2D,o),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texStorage2D(a.TEXTURE_2D,1,a.RGBA16F,i,r);let s=t.createFramebuffer(i,r,!1,!1);return s.colorAttachment.set(o),s}function ac(t,i){return i.colorRampTexture||=new m.xt(t,i.colorRamp,t.gl.RGBA),i.colorRampTexture}function au(t,i,r){let a=t.context,o=a.bindFramebuffer.get(),s=a.viewport.get(),[,,n,l]=s;return function(t,i,r){let a=t.context.gl;if(!t.layerOpacityFbo){let o=t.context.createFramebuffer(i,r,!0,!0),s=a.createTexture();a.bindTexture(a.TEXTURE_2D,s),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,i,r,0,a.RGBA,a.UNSIGNED_BYTE,null),o.colorAttachment.set(s),o.depthAttachment.set(t.context.createRenderbuffer(a.DEPTH_STENCIL,i,r)),t.layerOpacityFbo=o,t.context.bindFramebuffer.set(t.layerOpacityFbo.framebuffer);return}if(t.layerOpacityFbo.width===i&&t.layerOpacityFbo.height===r)return t.context.bindFramebuffer.set(t.layerOpacityFbo.framebuffer);let o=t.layerOpacityFbo;a.bindTexture(a.TEXTURE_2D,o.colorAttachment.get()),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,i,r,0,a.RGBA,a.UNSIGNED_BYTE,null),t.context.bindRenderbuffer.set(o.depthAttachment.get()),a.renderbufferStorage(a.RENDERBUFFER,a.DEPTH_STENCIL,i,r),t.context.bindRenderbuffer.set(null),o.width=i,o.height=r,t.context.bindFramebuffer.set(o.framebuffer)}(t,n,l),a.viewport.set([0,0,n,l]),a.clear({color:m.fn.transparent,depth:1,stencil:0}),t.currentStencilSource=void 0,t.renderTileClippingMasks(i,r),{compositeTarget:o,compositeViewport:s}}function ad(t,i,r,a){let o=t.context,s=o.gl;o.bindFramebuffer.set(r.compositeTarget),o.viewport.set(r.compositeViewport),o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,t.layerOpacityFbo.colorAttachment.get()),t.useProgram("layerOpacity").draw(o,s.TRIANGLES,ae.disabled,at.disabled,t.colorModeForRenderPass(),ai.disabled,{u_image:0,u_opacity:i},null,null,a.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,a.paint,t.transform.zoom),t.currentStencilSource=void 0}function a_(t,i,r,a,o,s,n,l){let h=256;if(o.stepInterpolant){let a=i.getSource().maxzoom,o=n.canonical.z===a?Math.
814ceil(1<<t.transform.maxZoom-n.canonical.z):1,l=s.maxLineLength/m.Lr*1024*o;h=(0,m.Bn)((0,m._r)(l),256,r.maxTextureSize)}return l.gradient=(0,m.Tt)({expression:o.gradientExpression(),evaluationKey:"lineProgress",resolution:h,image:l.gradient||void 0,clips:s.lineClipsArray}),l.texture?l.texture.update(l.gradient):l.texture=new m.xt(r,l.gradient,a.RGBA),l.version=o.gradientVersion,l.texture}function ap(t,i,r,a,o){let s=t.getDepthModeForSublayer(0,ae.ReadOnly),n=t.colorModeForRenderPass(),l=r.paint.get("line-dasharray"),h=l.constantOr(1),c=r.paint.get("line-pattern"),u=c.constantOr(1),d=r.paint.get("line-gradient"),_=r.getCrossfadeParameters(),p;p=u?"linePattern":h&&d?"lineGradientSDF":h?"lineSDF":d?"lineGradient":"line";let m=t.context,f=m.gl,g=t.transform,v=!0;for(let y of a){let a=i.getTile(y);if(u&&!a.patternsLoaded())continue;let x=a.getBucket(r);if(!x)continue;let b=x.programConfigurations.get(r.id),w=t.context.program.get(),T=t.useProgram(p,b),P=v||T.program!==w,M=aa(o,y),I=c.constantOr(null),C=l?.constantOr(null);if(I&&a.imageAtlas){let t=a.imageAtlas,i=t.patternPositions[I.to.toString()],r=t.patternPositions[I.from.toString()];i&&r&&b.setConstantPatternPositions(i,r)}else if(C){let i="round"===r.layout.get("line-cap").constantOr(null),a=t.lineAtlas.getDash(C.to,i),o=t.lineAtlas.getDash(C.from,i);b.setConstantDashPositions(a,o)}let S=ar(o,y),E=g.getPixelScale(),z;u?(z=rl(t,a,r,E,_),m.activeTexture.set(f.TEXTURE0),a.imageAtlasTexture.bind(f.LINEAR,f.CLAMP_TO_EDGE),b.updatePaintBuffers(_)):h&&d?(z=rc(t,a,r,E,_,x.lineClipsArray.length),function(t,i,r,a,o,s,n,l,h){let c=s.gradients[o.id],u=c.texture;o.gradientVersion!==c.version&&(u=a_(t,i,r,a,o,s,n,c)),r.activeTexture.set(a.TEXTURE0),u.bind(o.stepInterpolant?a.NEAREST:a.LINEAR,a.CLAMP_TO_EDGE),r.activeTexture.set(a.TEXTURE1),t.lineAtlas.bind(r),l.updatePaintBuffers(h)}(t,i,m,f,r,x,y,b,_)):h?(z=rh(t,a,r,E,_),(P||t.lineAtlas.dirty)&&(m.activeTexture.set(f.TEXTURE0),t.lineAtlas.bind(m)),b.updatePaintBuffers(_)):d?(z=rn(t,a,r,E,x.lineClipsArray.length),function(t,i,r,a,o,s,n){let l=s.gradients[o.id],h=l.texture;o.gradientVersion!==l.version&&(h=a_(t,i,r,a,o,s,n,l)),r.activeTexture.set(a.TEXTURE0),h.bind(o.stepInterpolant?a.NEAREST:a.LINEAR,a.CLAMP_TO_EDGE)}(t,i,m,f,r,x,y)):z=rs(t,a,r,E);let R=t.stencilModeForClipping(y);T.draw(m,f.TRIANGLES,s,R,n,ai.disabled,z,M,S,r.id,x.layoutVertexBuffer,x.indexBuffer,x.segments,r.paint,t.transform.zoom,b,x.layoutVertexBuffer2),v=!1}}function am(t,i,r,a,o){if(!r||!a?.imageAtlas)return;let s=a.imageAtlas.patternPositions,n=s[r.to.toString()],l=s[r.from.toString()];if(!n&&l&&(n=l),!l&&n&&(l=n),!n||!l){let t=o.getPaintProperty(i);n=s[t],l=s[t]}n&&l&&t.setConstantPatternPositions(n,l)}function af(t,i,r,a,o){let s=t.colorModeForRenderPass();av(t,i,r,a,t.getDepthModeForSublayer(1,ae.ReadOnly),s,!1,o),ag(t,i,r,a,o)}function ag(t,i,r,a,o){if(!r.paint.get("fill-antialias"))return;let s=t.colorModeForRenderPass();av(t,i,r,a,t.getDepthModeForSublayer(2*!!r.getPaintProperty("fill-outline-color"),ae.ReadOnly),s,!0,o)}function av(t,i,r,a,o,s,n,l){let h=t.context.gl,c="fill-pattern",u=r.paint.get(c),d=u?.constantOr(1),_=r.getCrossfadeParameters(),p,f,g,v,y,x=t.transform,b=r.paint.get("fill-translate"),w=r.paint.get("fill-translate-anchor");n?(f=d&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",p=h.LINES):(f=d?"fillPattern":"fill",p=h.TRIANGLES);let T=u.constantOr(null);for(let u of a){let a=i.getTile(u);if(d&&!a.patternsLoaded())continue;let P=a.getBucket(r);if(!P)continue;let M=P.sdfPatterns[r.id]??!1,I=P.programConfigurations.get(r.id),C=t.useProgram(f,I),S=aa(l,u);d&&(t.context.activeTexture.set(h.TEXTURE0),a.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),I.updatePaintBuffers(_)),am(I,c,T,a,r);let E=ar(l,u),z=(0,m.jr)(x,a,b,w);n?(v=P.indexBuffer2,y=P.segments2,g="fillOutlinePattern"===f&&d?i9(t,_,a,z,M):i8(z)):(v=P.indexBuffer,y=P.segments,g=d?i5(t,_,a,z,M):i6(z));let R=t.stencilModeForClipping(u);C.draw(t.context,p,o,R,s,ai.backCCW,g,S,E,r.id,P.layoutVertexBuffer,v,y,r.paint,t.transform.zoom,I)}}function ay(t,i,r,a,o,s,n,l){let h=t.context,c=h.gl,u="fill-extrusion-pattern",d=r.paint.get(u),_=d.constantOr(1),p=r.getCrossfadeParameters(),f=r.paint.get("fill-extrusion-opacity"),g=d.constantOr(null),v=t.transform;
814for(let d of a){let a=i.getTile(d),y=a.getBucket(r);if(!y)continue;let x=aa(l,d),b=y.programConfigurations.get(r.id),w=t.useProgram(_?"fillExtrusionPattern":"fillExtrusion",b);_&&(t.context.activeTexture.set(c.TEXTURE0),a.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),b.updatePaintBuffers(p));let T=ar(l,d);am(b,u,g,a,r);let P=(0,m.jr)(v,a,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),M=r.paint.get("fill-extrusion-vertical-gradient"),I=_?i3(t,M,f,P,d,p,a):i4(t,M,f,P);w.draw(h,h.gl.TRIANGLES,o,s,n,ai.backCCW,I,x,T,r.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,r.paint,t.transform.zoom,b,t.style.map.terrain&&y.centroidVertexBuffer)}}function ax(t,i,r,a,o,s,n,l,h){let c=t.style.projection,u=t.context,d=u.gl,_=[`#define NUM_ILLUMINATION_SOURCES ${r.paint.get("hillshade-highlight-color").values.length}`],p=t.useProgram("hillshade",null,!1,_),m=!t.options.moving;for(let _ of a){let a=i.getTile(_),f=a.fbo;if(!f)continue;let g=c.getMeshFromTileID(u,_.canonical,l,!0,"raster"),v=aa(h,_);u.activeTexture.set(d.TEXTURE0),d.bindTexture(d.TEXTURE_2D,f.colorAttachment.get());let y=ar(h,_,{aligned:m});p.draw(u,d.TRIANGLES,s,o[_.overscaledZ],n,ai.backCCW,rr(t,a,r),v,y,r.id,g.vertexBuffer,g.indexBuffer,g.segments)}}let ab=0;function aw(t,i,r,a,o,s,n,l,h){let c=t.style.projection,u=t.context,d=u.gl,_=t.useProgram("colorRelief"),p=!t.options.moving,f="nearest"===r.paint.get("resampling")?d.NEAREST:d.LINEAR,g=!0,v=0;for(let y of a){let a=i.getTile(y),x=a.dem;if(!x?.data)continue;if(g){let t=ab||=d.getParameter(d.MAX_TEXTURE_SIZE),{elevationTexture:i,colorTexture:a}=r.getColorRampTextures(u,t,x.getUnpackVector());u.activeTexture.set(d.TEXTURE1),i.bind(d.NEAREST,d.CLAMP_TO_EDGE),u.activeTexture.set(d.TEXTURE4),a.bind(d.LINEAR,d.CLAMP_TO_EDGE),g=!1,v=i.size[0]}let b=x.stride;u.activeTexture.set(d.TEXTURE0),(!a.demTexture||a.needsColorReliefPrepare)&&(u.pixelStoreUnpackPremultiplyAlpha.set(!1),a.demTexture||=t.getTileTexture(b)??new m.xt(u,{width:b,height:b,data:null},d.RGBA),a.demTexture.update(x.getPixels(),{premultiply:!1}),a.needsColorReliefPrepare=!1),a.demTexture.bind(f,d.CLAMP_TO_EDGE);let w=c.getMeshFromTileID(u,y.canonical,l,!0,"raster"),T=aa(h,y),P=ar(h,y,{aligned:p});_.draw(u,d.TRIANGLES,s,o[y.overscaledZ],n,ai.backCCW,ro(r,a.dem,v),T,P,r.id,w.vertexBuffer,w.indexBuffer,w.segments)}}let aT=[new m.Li(0,0),new m.Li(m.Lr,0),new m.Li(m.Lr,m.Lr),new m.Li(0,m.Lr)];function aP(t,i,r,a,o,s,n,l,h,c=!1,u,d=null){let _=a[a.length-1].overscaledZ,p=t.context,f=p.gl,g=t.useProgram("raster"),v=t.style.projection,x=t.colorModeForRenderPass(),b=!t.options.moving,w=r.paint.get("raster-opacity"),T="nearest"===r.paint.get("resampling")||"nearest"===r.paint.get("raster-resampling")?f.NEAREST:f.LINEAR,P=r.paint.get("raster-fade-duration"),M=!!t.style.map.terrain;for(let I of a){let a=t.getDepthModeForSublayer(I.overscaledZ-_,1===w?ae.ReadWrite:ae.ReadOnly,f.LESS),C=i.getTile(I);p.activeTexture.set(f.TEXTURE0),C.texture.bind(T,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST),p.activeTexture.set(f.TEXTURE1);let{parentTile:S,parentScaleBy:E,parentTopLeft:z,fadeValues:R}=function(t,i,r,a){let o={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(0===r||a)return o;if(t.fadingParentID){let a=i.getLoadedTile(t.fadingParentID);if(!a)return o;let s=2**(a.tileID.overscaledZ-t.tileID.overscaledZ);return{parentTile:a,parentScaleBy:s,parentTopLeft:[t.tileID.canonical.x*s%1,t.tileID.canonical.y*s%1],fadeValues:function(t,i,r){let a=y(),o=(a-t.timeAdded)/r,s=(a-i.timeAdded)/r,n=1===t.fadingDirection,l=(0,m.Bn)(o,0,1),h=(0,m.Bn)(1-s,0,1),c=n?l:h;return{tileOpacity:c,parentTileOpacity:n?h:l,fadeMix:{opacity:1,mix:1-c}}}(t,a,r)}}return t.selfFading?{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:function(t,i){let r=(y()-t.timeAdded)/i,a=(0,m.Bn)(r,0,1);return{tileOpacity:a,fadeMix:{opacity:a,mix:0}}}(t,r)}:o}(C,i,P,M);C.fadeOpacity=R.tileOpacity,S?(S.fadeOpacity=R.parentTileOpacity,S.texture.bind(T,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST)):C.texture.bind(T,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST),C.texture.useMipmap&&p.extTextureFilterAnisotropic&&t.transform.pitch>t.options.anisotropicFilterPitch&&f.texParameterf(f.TEXTURE_2D,p.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,p.extTextureFilterAnisotropicMax);let D=aa(u,I),L=ar(u,I,{aligned:b}
814),A=ez(z,E,R.fadeMix,r,l,h),F=d??v.getMeshFromTileID(p,I.canonical,s,n,"raster"),k=o?o[I.overscaledZ]:at.disabled;g.draw(p,f.TRIANGLES,a,k,x,c?ai.frontCCW:ai.backCCW,A,D,L,r.id,F.vertexBuffer,F.indexBuffer,F.segments)}}let aM=new m.fn(1,0,0,1),aI=new m.fn(0,1,0,1),aC=new m.fn(0,0,1,1),aS=new m.fn(1,0,1,1),aE=new m.fn(0,1,1,1);function az(t,i,r,a){aD(t,0,i+r/2,t.transform.width,r,a)}function aR(t,i,r,a){aD(t,i-r/2,0,r,t.transform.height,a)}function aD(t,i,r,a,o,s){let n=t.context,l=n.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*t.pixelRatio,r*t.pixelRatio,a*t.pixelRatio,o*t.pixelRatio),n.clear({color:s}),l.disable(l.SCISSOR_TEST)}function aL(t,i){if(!i.mesh){let r=new m.Gt;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(1,1),r.emplaceBack(-1,1);let a=new m.Jt;a.emplaceBack(0,1,2),a.emplaceBack(0,2,3),i.mesh=new eR(t.createVertexBuffer(r,eD.members),t.createIndexBuffer(a),m.Bt.simpleSegment(0,0,r.length,a.length))}return i.mesh}let aA={symbol:function(t,i,r,a,o,s){if("translucent"!==s.currentPass)return;let n=at.disabled,l=t.colorModeForRenderPass();(r._unevaluatedLayout.hasValue("text-variable-anchor")||r._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(t,i,r,a,o,s,n,l,h){let c=i.transform,u=i.style.map.terrain,d="map"===o,_="map"===s;for(let o of t){let t=a.getTile(o),s=t.getBucket(r);if(!s?.text?.segments.get().length)continue;let p=s.textSizeData,f=(0,m.A)(p,c.zoom),g=(0,m.Ir)(t,1,i.transform.zoom),v=te(d,i.transform,g),y="none"!==r.layout.get("icon-text-fit")&&s.hasIconData();if(f){let i=2**(c.zoom-t.tileID.overscaledZ),a=u?(t,i)=>u.getElevation(o,t,i):void 0;!function(t,i,r,a,o,s,n,l,h,c,u,d,_){let p=t.text.placedSymbolArray,f=t.text.dynamicLayoutVertexArray,g=t.icon.dynamicLayoutVertexArray,v={};f.clear();for(let g=0;g<p.length;g++){let y=p.get(g),x=t.allowVerticalPlacement&&!y.placedOrientation,b=y.hidden||!y.crossTileID||x?null:a[y.crossTileID];if(b){let a=new m.Li(y.anchorX,y.anchorY),p={getElevation:d,heightOffset:y.heightOffset,heightAnchorGround:_,width:o.width,height:o.height,pitchedLabelPlaneMatrix:s,lineVertexArray:null,pitchWithMap:r,transform:o,projectionCache:null,tileAnchorPoint:a,translation:c,unwrappedTileID:u},g=r?tu(a.x,a.y,p):th(a.x,a.y,p),x=.5+o.cameraToCenterDistance/g.signedDistanceFromCamera*.5,w=(0,m.k)(t.textSizeData,l,y)*x/24;r&&(w*=t.tilePixelRatio/n);let{width:T,height:P,anchor:M,textOffset:I,textBoxScale:C}=b,S=function(t,i,r,a,o,s){let{horizontalAlign:n,verticalAlign:l}=(0,m.M)(t);return new m.Li((-(n-.5)*i/o+a[0])*s,(-(l-.5)*r/o+a[1])*s)}(M,T,P,I,C,w),E=o.getPitchedTextCorrection(a.x+c[0],a.y+c[1],u),z=function(t,i,r,a,o,s){let n=i.tileAnchorPoint.add(new m.Li(i.translation[0],i.translation[1]));if(i.pitchWithMap){let t=a.mult(s);r||(t=t.rotate(-o));let l=n.add(t);return tr(l.x,l.y,i.pitchedLabelPlaneMatrix,ti(i,l.x,l.y)).point}if(r){let r=th(i.tileAnchorPoint.x+1,i.tileAnchorPoint.y,i).point.sub(t),o=Math.atan(r.y/r.x)+(r.x<0?Math.PI:0);return t.add(a.rotate(o))}return t.add(a)}(g.point,p,i,S,-o.bearingInRadians,E),R=t.allowVerticalPlacement&&2===y.placedOrientation?Math.PI/2:0;for(let t=0;t<y.numGlyphs;t++)(0,m.C)(f,z,R);h&&y.associatedIconIndex>=0&&(v[y.associatedIconIndex]={shiftedAnchor:z,angle:R})}else tm(y.numGlyphs,f)}if(h){g.clear();let i=t.icon.placedSymbolArray;for(let t=0;t<i.length;t++){let r=i.get(t);if(r.hidden)tm(r.numGlyphs,g);else{let i=v[t];if(i)for(let t=0;t<r.numGlyphs;t++)(0,m.C)(g,i.shiftedAnchor,i.angle);else tm(r.numGlyphs,g)}}t.icon.dynamicLayoutVertexBuffer.updateData(g)}t.text.dynamicLayoutVertexBuffer.updateData(f)}(s,d,_,h,c,v,i,f,y,(0,m.jr)(c,t,n,l),o.toUnwrapped(),a,"ground"===r.layout.get("symbol-height-anchor"))}}}(a,t,r,i,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),o),0!==r.paint.get("icon-opacity").constantOr(1)&&an(t,i,r,a,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment").constantOr("viewport"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),n,l,s),0!==r.paint.get("text-opacity").constantOr(1)&&an(t,i,r,a,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright"),n,l,s),i.map.showCollisionBoxes&&(ao(t,i,r,a,!0,s),ao(t,i,r,a,!1,s))},circle:function(t,i,r,a,o){if("translucent"!==o.currentPass)return;let s=r.paint.get("circle-opacity"),n=r.paint.get("circle-stroke-width"),l=r.paint.get("circle-stroke-opacity"),h=!r.layout.get("
814circle-sort-key").isConstant();if(0===s.constantOr(1)&&(0===n.constantOr(1)||0===l.constantOr(1)))return;let c=t.context,u=c.gl,d=t.transform,_=t.getDepthModeForSublayer(0,ae.ReadOnly),p=at.disabled,f=t.colorModeForRenderPass(),g=[],v=d.getCircleRadiusCorrection();for(let s of a){let a=i.getTile(s),n=a.getBucket(r);if(!n)continue;let l=r.paint.get("circle-translate"),c=r.paint.get("circle-translate-anchor"),u=(0,m.jr)(d,a,l,c),_=n.programConfigurations.get(r.id),p=t.useProgram("circle",_),f=n.layoutVertexBuffer,y=n.indexBuffer,x=aa(o,s),b={programConfiguration:_,program:p,layoutVertexBuffer:f,indexBuffer:y,uniformValues:i7(t,a,r,u,v),terrainData:x,projectionData:ar(o,s)};if(h)for(let t of n.segments.get())g.push({segments:new m.Bt([t]),sortKey:t.sortKey,state:b});else g.push({segments:n.segments,sortKey:0,state:b})}for(let i of(h&&g.sort((t,i)=>t.sortKey-i.sortKey),g)){let{programConfiguration:a,program:o,layoutVertexBuffer:s,indexBuffer:n,uniformValues:l,terrainData:h,projectionData:d}=i.state,m=i.segments;o.draw(c,u.TRIANGLES,_,p,f,ai.backCCW,l,h,d,r.id,s,n,m,r.paint,t.transform.zoom,a)}},heatmap:function(t,i,r,a,o){if(0===r.paint.get("heatmap-opacity"))return;let s=t.context;if(t.style.map.terrain){for(let s of a){let a=i.getTile(s);i.hasRenderableParent(s)||("offscreen"===o.currentPass?function(t,i,r,a,o){let s=t.context,n=s.gl,l=at.disabled,h=new r9([n.ONE,n.ONE],m.fn.transparent,[!0,!0,!0,!0]),c=i.getBucket(r);if(!c)return;let u=a.key,d=r.heatmapFbos.get(u);d||(d=ah(s,i.tileSize,i.tileSize),r.heatmapFbos.set(u,d)),s.bindFramebuffer.set(d.framebuffer),s.viewport.set([0,0,i.tileSize,i.tileSize]),s.clear({color:m.fn.transparent});let _=c.programConfigurations.get(r.id),p=t.useProgram("heatmap",_,!o.isRenderingGlobe),f=ar(o,i.tileID),g=aa(o,a);p.draw(s,n.TRIANGLES,ae.disabled,l,h,ai.disabled,rt(i,t.transform.zoom,r.paint.get("heatmap-intensity"),1),g,f,r.id,c.layoutVertexBuffer,c.indexBuffer,c.segments,r.paint,t.transform.zoom,_)}(t,a,r,s,o):"translucent"===o.currentPass&&function(t,i,r,a){let o=t.context,s=o.gl,n=t.transform;o.setColorMode(t.colorModeForRenderPass());let l=ac(o,i),h=r.key,c=i.heatmapFbos.get(h);if(!c)return;o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,c.colorAttachment.get()),o.activeTexture.set(s.TEXTURE1),l.bind(s.LINEAR,s.CLAMP_TO_EDGE);let u=ar(a,r,{applyTerrainMatrix:a.isRenderingGlobe});t.useProgram("heatmapTexture").draw(o,s.TRIANGLES,ae.disabled,at.disabled,t.colorModeForRenderPass(),ai.disabled,ri(t,i,0,1),null,u,i.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments,i.paint,n.zoom),c.destroy(),i.heatmapFbos.delete(h)}(t,r,s,o))}s.viewport.set([0,0,t.width,t.height])}else{var n,l;let s,h,c;"offscreen"===o.currentPass?function(t,i,r,a,o){var s,n,l;let h,c,u=t.context,d=u.gl,_=t.transform,p=at.disabled,f=new r9([d.ONE,d.ONE],m.fn.transparent,[!0,!0,!0,!0]);for(let g of(s=u,n=t,l=r,h=s.gl,s.activeTexture.set(h.TEXTURE1),s.viewport.set([0,0,n.width/4,n.height/4]),(c=l.heatmapFbos.get(m.Ct))?(h.bindTexture(h.TEXTURE_2D,c.colorAttachment.get()),s.bindFramebuffer.set(c.framebuffer)):(c=ah(s,n.width/4,n.height/4),l.heatmapFbos.set(m.Ct,c)),u.clear({color:m.fn.transparent}),a)){if(i.hasRenderableParent(g))continue;let a=i.getTile(g),s=a.getBucket(r);if(!s)continue;let n=s.programConfigurations.get(r.id),l=t.useProgram("heatmap",n),h=ar(o,g,{applyTerrainMatrix:!1}),c=_.getCircleRadiusCorrection();l.draw(u,d.TRIANGLES,ae.disabled,p,f,ai.backCCW,rt(a,_.zoom,r.paint.get("heatmap-intensity"),c),null,h,r.id,s.layoutVertexBuffer,s.indexBuffer,s.segments,r.paint,_.zoom,n)}u.viewport.set([0,0,t.width,t.height])}(t,i,r,a,o):"translucent"===o.currentPass&&(n=t,l=r,h=(s=n.context).gl,s.setColorMode(n.colorModeForRenderPass()),(c=l.heatmapFbos.get(m.Ct))&&(s.activeTexture.set(h.TEXTURE0),h.bindTexture(h.TEXTURE_2D,c.colorAttachment.get()),s.activeTexture.set(h.TEXTURE1),ac(s,l).bind(h.LINEAR,h.CLAMP_TO_EDGE),n.useProgram("heatmapTexture").draw(s,h.TRIANGLES,ae.disabled,at.disabled,n.colorModeForRenderPass(),ai.disabled,ri(n,l,0,1),null,null,l.id,n.viewportBuffer,n.quadTriangleIndexBuffer,n.viewportSegments,l.paint,n.transform.zoom)))}},line:function(t,i,r,a,o){if("translucent"!==o.currentPass)return;let s=r.paint.get("line-opacity"),n=r.paint.get("line-width"),l=r.paint.get("line-layer-opacity");if(0!==s.constantOr(1)&&0!==n.constantOr(1)&&0!==l){if(l<1){let s=au(t,r,a);ap(t,i,r,a,o),ad(t,l,s,r);return}ap(t,i,r,a,o)}},fill:function(t,i,r,a,o){let s=r.paint.get("fill-color"),n=r.paint.get("fill-opacity"),l=r.paint.get("fill-layer
814-opacity");if(0===n.constantOr(1)||0===l)return;if(l<1){if("translucent"!==o.currentPass)return;let s=au(t,r,a);af(t,i,r,a,o),ad(t,l,s,r);return}let h=r.paint.get("fill-pattern"),c=t.opaquePassEnabledForLayer()&&!h.constantOr(1)&&1===s.constantOr(m.fn.transparent).a&&1===n.constantOr(0);if(c&&"opaque"===o.currentPass){let s=t.colorModeForRenderPass();av(t,i,r,a,t.getDepthModeForSublayer(1,ae.ReadWrite),s,!1,o);return}if(c&&"translucent"===o.currentPass)return void ag(t,i,r,a,o);"translucent"===o.currentPass&&af(t,i,r,a,o)},fillExtrusion:function(t,i,r,a,o){let s=r.paint.get("fill-extrusion-opacity");if(0!==s&&"translucent"===o.currentPass){let n=new ae(t.context.gl.LEQUAL,ae.ReadWrite,o.depthRangeFor3D);if(1!==s||r.paint.get("fill-extrusion-pattern").constantOr(1))ay(t,i,r,a,n,at.disabled,r9.disabled,o),ay(t,i,r,a,n,t.stencilModeFor3D(),t.colorModeForRenderPass(),o);else{let s=t.colorModeForRenderPass();ay(t,i,r,a,n,at.disabled,s,o)}}},hillshade:function(t,i,r,a,o){if("offscreen"!==o.currentPass&&"translucent"!==o.currentPass)return;let s=t.context,n=t.style.projection.useSubdivision,l=t.getDepthModeForSublayer(0,ae.ReadOnly),h=t.colorModeForRenderPass();if("offscreen"===o.currentPass)(function(t,i,r,a,o,s,n){let l=t.context,h=l.gl,c="nearest"===a.paint.get("resampling")?h.NEAREST:h.LINEAR;for(let u of r){let r=i.getTile(u),d=r.dem;if(!d?.data||!r.needsHillshadePrepare)continue;let _=d.dim+2,p=d.stride,f=d.getPixels();if(l.activeTexture.set(h.TEXTURE1),l.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture||=t.getTileTexture(p),r.demTexture){let t=r.demTexture;t.update(f,{premultiply:!1}),t.bind(h.NEAREST,h.CLAMP_TO_EDGE)}else r.demTexture=new m.xt(l,f,h.RGBA,{premultiply:!1}),r.demTexture.bind(h.NEAREST,h.CLAMP_TO_EDGE);l.activeTexture.set(h.TEXTURE0);let g=r.fbo;if(!g){let t=new m.xt(l,{width:_,height:_,data:null},h.RGBA);t.bind(c,h.CLAMP_TO_EDGE),(g=r.fbo=l.createFramebuffer(_,_,!0,!1)).colorAttachment.set(t.texture)}l.bindFramebuffer.set(g.framebuffer),l.viewport.set([0,0,_,_]),t.useProgram("hillshadePrepare").draw(l,h.TRIANGLES,o,s,n,ai.disabled,ra(r.tileID,d),null,null,a.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments),r.needsHillshadePrepare=!1}})(t,i,a,r,l,at.disabled,h),s.viewport.set([0,0,t.width,t.height]);else if("translucent"===o.currentPass)if(n){let[s,n,c]=t.stencilConfigForOverlapTwoPass(a);ax(t,i,r,c,s,l,h,!1,o),ax(t,i,r,c,n,l,h,!0,o)}else{let[s,n]=t.getStencilConfigForOverlapAndUpdateStencilID(a);ax(t,i,r,n,s,l,h,!1,o)}},colorRelief:function(t,i,r,a,o){if("translucent"!==o.currentPass||!a.length)return;let s=t.style.projection.useSubdivision,n=t.getDepthModeForSublayer(0,ae.ReadOnly),l=t.colorModeForRenderPass();if(s){let[s,h,c]=t.stencilConfigForOverlapTwoPass(a);aw(t,i,r,c,s,n,l,!1,o),aw(t,i,r,c,h,n,l,!0,o)}else{let[s,h]=t.getStencilConfigForOverlapAndUpdateStencilID(a);aw(t,i,r,h,s,n,l,!1,o)}},raster:function(t,i,r,a,o){if("translucent"!==o.currentPass||0===r.paint.get("raster-opacity")||!a.length)return;let s=i.getSource(),n=t.style.projection.useSubdivision;if(s instanceof eF)aP(t,i,r,a,null,!1,!1,s.tileCoords,s.imageWarp,s.flippedWindingOrder,o,s.getMesh(t.context,n));else if(n){let[s,n,l]=t.stencilConfigForOverlapTwoPass(a);aP(t,i,r,l,s,!1,!0,aT,eE,!1,o),aP(t,i,r,l,n,!0,!0,aT,eE,!1,o)}else{let[s,n]=t.getStencilConfigForOverlapAndUpdateStencilID(a);aP(t,i,r,n,s,!1,!0,aT,eE,!1,o)}},background:function(t,i,r,a,o){let s=r.paint.get("background-color"),n=r.paint.get("background-opacity");if(0===n)return;let l=t.context,h=l.gl,c=t.style.projection,u=t.transform,d=u.tileSize,_=r.paint.get("background-pattern");if(t.isPatternMissing(_))return;let p=!_&&1===s.a&&1===n&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(o.currentPass!==p)return;let m=at.disabled,f=t.getDepthModeForSublayer(0,"opaque"===p?ae.ReadWrite:ae.ReadOnly),g=t.colorModeForRenderPass(),v=t.useProgram(_?"backgroundPattern":"background"),y=a||eQ(u,{tileSize:d,terrain:t.style.map.terrain});_&&(l.activeTexture.set(h.TEXTURE0),t.patternAtlas.bind(t.context));let x=r.getCrossfadeParameters();for(let i of y){let a=ar(o,i),u=_?rg(n,t,_,{tileID:i,tileSize:d},x):rf(n,s),p=aa(o,i),y=c.getMeshFromTileID(l,i.canonical,!1,!0,"raster");v.draw(l,h.TRIANGLES,f,m,g,ai.backCCW,u,p,a,r.id,y.vertexBuffer,y.indexBuffer,y.segments)}},sky:function(t,i){var r,a;let o,s,n,l,h=t.context,c=h.gl,u=(r=t.transform,a=t.pixelRatio,o=Math.cos(r.rollInRadians),s=Math.sin(r.rollInRadians),n=(0,m.Z)(r),l=r.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition,{u_sky_color:i.properties.get("sky-color"),u_horizon_color:i.properties.get("horizon-color"),u_horizon:[(r.width/2-n*s)*a,(r.height/2+n*o)*a],u_horizon_normal:[-s,o],u_sky_horizon_blend:i.properties.get("sky-horizon-blend")*r.height/2*a,u_sky_blend:l,u_inv_proj_matrix:r.inverseProjectionMatrix,u_globe_position:ig(r),u_globe_radius:im(r.worldSize,r.center.lat),u_atmosphere_blend:i.properties.get("atmosphere-blend")}),d=new ae(c.LEQUAL,ae.ReadWrite,[0,1]),_=at.disabled,p=t.colorModeForRenderPass(),f=t.useProgram("sky"),g=aL(h,i);f.draw(h,c.TRIANGLES,d,_,p,ai.disabled,u,null,void 0,"sky",g.vertexBuffer,g.indexBuffer,g.segments)},atmosphere:function(t,i,r){var a;let o,s,n=t.context,l=n.gl,h=t.useProgram("atmosphere"),c=new ae(l.LEQUAL,ae.ReadOnly,[0,1]),u=t.transform,d=(a=t.transform,o=r.getCartesianPosition(),(0,m.ri)(o,o),s=(0,m.Si)(new Float64Array(16)),"map"===r.properties.get("anchor")&&((0,m.ki)(s,s,a.rollInRadians),(0,m.Di)(s,s,-a.pitchInRadians),(0,m.ki)(s,s,a.bearingInRadians),(0,m.Di)(s,s,a.center.lat*Math.PI/180),(0,m.Oi)(s,s,-a.center.lng*Math.PI/180)
814),(0,m.pi)(o,o,s),o),_=u.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),p=i.properties.get("atmosphere-blend")*_.projectionTransition;if(0===p)return;let f=im(u.worldSize,u.center.lat),g={u_sun_pos:d,u_atmosphere_blend:p,u_globe_position:ig(u),u_globe_radius:f,u_inv_proj_matrix:u.inverseProjectionMatrix},v=aL(n,i);h.draw(n,l.TRIANGLES,c,at.disabled,r9.alphaBlended,ai.disabled,g,null,null,"atmosphere",v.vertexBuffer,v.indexBuffer,v.segments)},custom:function(t,i,r,a){let{isRenderingGlobe:o}=a,s=t.context,n=r.implementation,l=t.style.projection,h=t.transform,c=h.getProjectionDataForCustomLayer(o),u={farZ:h.farZ,nearZ:h.nearZ,fov:h.fov*Math.PI/180,modelViewProjectionMatrix:h.modelViewProjectionMatrix,projectionMatrix:h.projectionMatrix,shaderData:{variantName:l.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;
815uniform mat4 u_projection_matrix;
816${l.shaderPreludeCode.vertexSource}`,define:l.shaderDefine},defaultProjectionData:c,getProjectionData:t=>h.getProjectionData({overscaledTileID:new m.d(t.tileID.canonical.z,t.tileID.wrap??0,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),aligned:t.aligned,applyGlobeMatrix:t.applyGlobeMatrix,applyTerrainMatrix:t.applyTerrainMatrix})},d=n.renderingMode?n.renderingMode:"2d";if("offscreen"===a.currentPass){let i=n.prerender;i&&(t.setCustomLayerDefaults(),s.setColorMode(t.colorModeForRenderPass()),i.call(n,s.gl,u),s.setDirty(),t.setBaseState())}else if("translucent"===a.currentPass){t.setCustomLayerDefaults(),s.setColorMode(t.colorModeForRenderPass()),s.setStencilMode(at.disabled);let i="3d"===d?t.getDepthModeFor3D():t.getDepthModeForSublayer(0,ae.ReadOnly);s.setDepthMode(i),n.render(s.gl,u),s.setDirty(),t.setBaseState(),s.bindFramebuffer.set(null)}},debug:function(t,i,r,a){for(let o of r)!function(t,i,r,a){let o=t.context,s=o.gl,n=t.useProgram("debug"),l=ae.disabled,h=at.disabled,c=t.colorModeForRenderPass(),u="$debug",d=aa(a,r);o.activeTexture.set(s.TEXTURE0);let _=Math.floor((i.getTileByID(r.key).latestRawTileData?.byteLength||0)/1024),p=512/Math.min(i.getTile(r).tileSize,512)*(r.overscaledZ/t.transform.zoom)*.5,f=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(f+=` => ${r.overscaledZ}`),function(t,i){t.initDebugOverlayCanvas();let r=t.debugOverlayCanvas,a=t.context.gl,o=t.debugOverlayCanvas.getContext("2d");o.clearRect(0,0,r.width,r.height),o.shadowColor="white",o.shadowBlur=2,o.lineWidth=1.5,o.strokeStyle="white",o.textBaseline="top",o.font="bold 36px Open Sans, sans-serif",o.fillText(i,5,5),o.strokeText(i,5,5),t.debugOverlayTexture.update(r),t.debugOverlayTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE)}(t,`${f} ${_}kB`);let g=ar(a,r);n.draw(o,s.TRIANGLES,l,h,r9.alphaBlended,ai.disabled,re(m.fn.transparent,p),null,g,u,t.debugBuffer,t.quadTriangleIndexBuffer,t.debugSegments),n.draw(o,s.LINE_STRIP,l,h,c,ai.disabled,re(m.fn.red),d,g,u,t.debugBuffer,t.tileBorderIndexBuffer,t.debugSegments)}(t,i,o,a)},debugPadding:function(t){var i,r,a,o;let s=t.transform.padding;az(t,t.transform.height-(s.top||0),3,aM),az(t,s.bottom||0,3,aI),aR(t,s.left||0,3,aC),aR(t,t.transform.width-(s.right||0),3,aS);let n=t.transform.centerPoint;i=t,r=n.x,a=t.transform.height-n.y,aD(i,r-1,a-10,2,20,o=aE),aD(i,r-10,a-1,20,2,o)},terrainDepth:function(t,i){let r=t.context,a=r.gl,o=t.transform,s=r9.unblended,n=new ae(a.LEQUAL,ae.ReadWrite,[0,1]),l=i.tileManager.getRenderableTiles(),h=t.useProgram("terrainDepth");for(let c of(r.bindFramebuffer.set(i.getFramebuffer().framebuffer),r.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),r.clear({color:m.fn.white,depth:1}),l)){let t=i.getTerrainMesh(c.tileID),l=i.getTerrainData(c.tileID),u=o.getProjectionData({overscaledTileID:c.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),d=iq(i.getSkirtLength(o.zoom));h.draw(r,a.TRIANGLES,n,at.disabled,s,ai.backCCW,d,l,u,"terrain",t.vertexBuffer,t.indexBuffer,t.segments)}r.bindFramebuffer.set(null),r.viewport.set([0,0,t.width,t.height])}};var aF=class t{constructor(t,i){this.drawFunctions=aA,this.context=new r7(t),this.transform=i,this.layerOpacityFbo=null,this._tileTextures={},this._rttObjectRecyclePool=[],this._rttSharedFbo=null,this.terrainFacilitator={depthDirty:!0,matrix:(0,m.Si)(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=e3.maxOverzooming+e3.maxUnderzooming+1,this.depthEpsilon=1/65536,this.crossTileSymbolIndex=new tN}resize(t,i,r){if(this.width=Math.floor(t*r),this.height=Math.floor(i*r),this.pixelRatio=r,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let t of this.style._order)this.style._layers[t].resize()}setup(){let t=this.context,i=new m.Gt;i.emplaceBack(0,0),i.emplaceBack(m.Lr,0),i.emplaceBack(0,m.Lr),i.emplaceBack(m.Lr,m.Lr),this.tileExtentBuffer=t.createVertexBuffer(i,eD.members),this.tileExtentSegments=m.Bt.simpleSegment(0,0,4,2);let r=new m.Gt;r.emplaceBack(0,0),r.emplaceBack(m.Lr,0),r.emplaceBack(0,m.Lr),r.emplaceBack(m.Lr,m.Lr),this.debugBuffer=t.createVertexBuffer(r,eD.members),this.debugSegments=m.Bt.simpleSegment(0,0,4,5);let a=new m.qt;a.emplaceBack(0,0,0,0),a.emplaceBack(m.Lr,0,m.Lr,0),a.emplaceBack(0,m.Lr,0,m.Lr),a.emplaceBack(m.Lr,m.Lr,m.Lr,m.Lr),this.rasterBoundsBuffer=t.createVertexBuffer(a,iU.members),this.rasterBoundsSegments=m.Bt.simpleSegment(0,0,4,2);let o=new m.Gt;o.emplaceBack(0,0),o.emplaceBack(m.Lr,0),o.emplaceBack(0,m.Lr),o.emplaceBack(m.Lr,m.Lr),this.rasterBoundsBufferPosOnly=t.createVertexBuffer(o,eD.members),this.rasterBoundsSegmentsPosOnly=m.Bt.simpleSegment(0,0,4,5);let s=new m.Gt;
816s.emplaceBack(0,0),s.emplaceBack(1,0),s.emplaceBack(0,1),s.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(s,eD.members),this.viewportSegments=m.Bt.simpleSegment(0,0,4,2);let n=new m.Ut;n.emplaceBack(0),n.emplaceBack(1),n.emplaceBack(3),n.emplaceBack(2),n.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(n);let l=new m.Jt;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(l);let h=this.context.gl;this.stencilClearMode=new at({func:h.ALWAYS,mask:0},0,255,h.ZERO,h.ZERO,h.ZERO),this.tileExtentMesh=new eR(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){let t=this.context,i=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let r=(0,m.vi)();(0,m.Ti)(r,0,this.width,this.height,0,0,1),(0,m.Ai)(r,r,[i.drawingBufferWidth,i.drawingBufferHeight,0]),this.useProgram("clippingMask",null,!0).draw(t,i.TRIANGLES,ae.disabled,this.stencilClearMode,r9.disabled,ai.disabled,null,null,{mainMatrix:r,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:r,clipAntimeridian:!1},"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}renderTileClippingMasks(t,i){if(this.currentStencilSource===t.source||!t.isTileClipped()||!i?.length)return;this.currentStencilSource=t.source,this.nextStencilID+i.length>256&&this.clearStencil();let r=this.context;r.setColorMode(r9.disabled),r.setDepthMode(ae.disabled);let a={};for(let t of i)a[t.key]=this.nextStencilID++;this.style.projection.useSubdivision&&this._renderTileMasks(a,i,!0),this._renderTileMasks(a,i,!1),this._tileClippingMaskIDs=a}_renderTileMasks(t,i,r){let a=this.context,o=a.gl,s=this.style.projection,n=this.renderContext,l=this.useProgram("clippingMask");for(let h of i){let i=t[h.key],c=aa(n,h),u=s.getMeshFromTileID(this.context,h.canonical,r,!0,"stencil"),d=ar(n,h);l.draw(a,o.TRIANGLES,ae.disabled,new at({func:o.ALWAYS,mask:0},i,255,o.KEEP,o.KEEP,o.REPLACE),r9.disabled,n.isRenderingToTexture?ai.disabled:ai.backCCW,null,c,d,"$clipping",u.vertexBuffer,u.indexBuffer,u.segments)}}_renderTilesDepthBuffer(){let t=this.context,i=t.gl,r=this.style.projection,a=this.transform,o=this.useProgram("depth"),s=this.getDepthModeFor3D();for(let n of eQ(a,{tileSize:a.tileSize})){let a=aa(this.renderContext,n),l=r.getMeshFromTileID(this.context,n.canonical,!0,!0,"raster"),h=ar(this.renderContext,n);o.draw(t,i.TRIANGLES,s,at.disabled,r9.disabled,ai.backCCW,null,a,h,"$clipping",l.vertexBuffer,l.indexBuffer,l.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let t=this.nextStencilID++,i=this.context.gl;return new at({func:i.NOTEQUAL,mask:255},t,255,i.KEEP,i.KEEP,i.REPLACE)}stencilModeForClipping(t){let i=this.context.gl;return new at({func:i.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,i.KEEP,i.KEEP,i.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(t){let i=this.context.gl,r=t.sort((t,i)=>i.overscaledZ-t.overscaledZ),a=r[r.length-1].overscaledZ,o=r[0].overscaledZ-a+1;if(o>1){this.currentStencilSource=void 0,this.nextStencilID+o>256&&this.clearStencil();let t={};for(let r=0;r<o;r++)t[r+a]=new at({func:i.GEQUAL,mask:255},r+this.nextStencilID,255,i.KEEP,i.KEEP,i.REPLACE);return this.nextStencilID+=o,[t,r]}return[{[a]:at.disabled},r]}stencilConfigForOverlapTwoPass(t){let i=this.context.gl,r=t.sort((t,i)=>i.overscaledZ-t.overscaledZ),a=r[r.length-1].overscaledZ,o=r[0].overscaledZ-a+1;if(this.clearStencil(),o>1){let t={},s={};for(let r=0;r<o;r++)t[r+a]=new at({func:i.GREATER,mask:255},o+1+r,255,i.KEEP,i.KEEP,i.REPLACE),s[r+a]=new at({func:i.GREATER,mask:255},1+r,255,i.KEEP,i.KEEP,i.REPLACE);return this.nextStencilID=2*o+1,[t,s,r]}return this.nextStencilID=3,[{[a]:new at({func:i.GREATER,mask:255},2,255,i.KEEP,i.KEEP,i.REPLACE)},{[a]:new at({func:i.GREATER,mask:255},1,255,i.KEEP,i.KEEP,i.REPLACE)},r]}colorModeForRenderPass(){let t=this.context.gl;if(this._showOverdrawInspector){let i=1/8;return new r9([t.CONSTANT_COLOR,t.ONE],new m.fn(i,i,i,0),[!0,!0,!0,!0])}return"opaque"===this.renderContext.currentPass?r9.unblended:r9.alphaBlended}getDepthModeForSublayer(t,i,r){if(!this.opaquePassEnabledForLayer())return ae.disabled;let a=1-((1+this.renderContext.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new ae(r||this.context.gl.LEQUAL,i,[a,a])}getDepthModeFor3D(){return new ae(this.context.gl.LEQUAL,ae.ReadWrite,this.renderContext.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.renderContext.currentLayer<this.renderContext.opaquePassCutoff}render(t,i){var r,a;let o;this.style=t,this.options=i;let s=this.renderContext=(r=this.transform,a=t.projection,{currentPass:"offscreen",currentLayer:0,opaquePassCutoff:1/0,depthRangeFor3D:[0,1],isRenderingToTexture:!1,transform:r,terrain:t.map.terrain??null,projectionTransition:o=a?.transitionState??0,isRenderingGlobe:o>0});this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.patternAtlas=t.patternAtlas,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(y()),function(t,i){let r=t.pending,{transform:a}=i,o=i.context.gl;r[r8.u_units_to_pixels]=1/a.pixelsToGLUnits[0],r[r8.u_units_to_pixels+1]=1/a.pixelsToGLUnits[1],r[r8.u_world_size]=o.drawingBufferWidth,r[r8.u_world_size+1]=o.drawingBufferHeight,r[r8.u_camera_to_center_distance]=a.cameraToCenterDistance,r[r8.u_symbol_fade_change]=i.options.fadeDuration?i.symbolFadeChange:1,r[r8.u_aspect_ratio]=a.width/a.height,r[r8.u_device_pixel_ratio]=i.pixelRatio,r[r8.u_viewport_size]=a.width,r[r8.u_viewport_size+1]=a.height,r[r8.u_pixel_extrude_scale]=1/a.width,r[r8.u_pixel_extrude_scale+1]=1/a.height,r[r8.u_pitch]=a.pitch/360*2*Math.PI,t.upload()}(this.context.frameUniformBuffer,this),this.imageManager.beginFrame();let n=this.style._order,l=this.style.tileManagers,h={},c={},u={};for(let t in l){let i=l[t];i.used&&i.prepare(this.context),h[t]=i.getVisibleCoordinates(!1),c[t]=h[t].slice().reverse(),u[t]=i.getVisibleCoordinates(!0).reverse()}s.opaquePassCutoff=1/0;for(let t=0;t<n.length;t++){let i=n[t];if(this.style._layers[i].is3D()){s.opaquePassCutoff=t;break}}for(let t of(this.maybeDrawDepth(),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),s.opaquePassCutoff=0),s.currentPass="offscreen",n)){let i=this.style._layers[t];
816if(!i.hasOffscreenPass()||i.isHidden(this.transform.zoom))continue;let r=c[i.source];("custom"===i.type||r.length)&&this.renderLayer(this,l[i.source],i,r,s)}if(this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?m.fn.black:m.fn.transparent,depth:1}),this.clearStencil(),this.style.sky&&this.drawFunctions.sky(this,this.style.sky),this._showOverdrawInspector=i.showOverdrawInspector,s.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(s.currentPass="opaque",s.currentLayer=n.length-1;s.currentLayer>=0;s.currentLayer--){let t=this.style._layers[n[s.currentLayer]];if(t.isHidden(this.transform.zoom))continue;let i=l[t.source],r=h[t.source];this.renderTileClippingMasks(t,r),this.renderLayer(this,i,t,r,s)}s.currentPass="translucent";let d=!1;for(s.currentLayer=0;s.currentLayer<n.length;s.currentLayer++){let t=this.style._layers[n[s.currentLayer]];if(t.isHidden(this.transform.zoom))continue;let i=l[t.source];if(this.renderToTexture?.renderLayer(t,s))continue;this.opaquePassEnabledForLayer()||d||(d=!0,s.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());let r=("symbol"===t.type?u:c)[t.source];this.renderTileClippingMasks(t,h[t.source]),this.renderLayer(this,i,t,r,s)}if(s.isRenderingGlobe&&this.drawFunctions.atmosphere(this,this.style.sky,this.style.light),this.options.showTileBoundaries){let t=function(t,i){let r=null,a=Object.values(t._layers).flatMap(r=>r.source&&!r.isHidden(i)?[t.tileManagers[r.source]]:[]),o=a.filter(t=>"vector"===t.getSource().type),s=a.filter(t=>"vector"!==t.getSource().type),n=t=>{(!r||r.getSource().maxzoom<t.getSource().maxzoom)&&(r=t)};for(let t of o)n(t);if(!r)for(let t of s)n(t);return r}(this.style,this.transform.zoom);t&&this.drawFunctions.debug(this,t,t.getVisibleCoordinates(),s)}this.options.showPadding&&this.drawFunctions.debugPadding(this),this.renderToTexture&&!this.options.moving&&this.clearRTTPool(),this.context.setDefault()}markTerrainDepthDirty(){this.terrainFacilitator.depthDirty=!0}maybeDrawDepth(){if(!this.style?.projection||!this.style.map?.terrain)return;let t=this.terrainFacilitator.matrix,i=this.transform.modelViewProjectionMatrix,r=this.terrainFacilitator.depthDirty;r||=!(0,m.yi)(t,i),(r||=this.style.map.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime))&&((0,m._i)(t,i),this.terrainFacilitator.renderTime=y(),this.terrainFacilitator.depthDirty=!1,this.drawFunctions.terrainDepth(this,this.style.map.terrain))}renderLayer(t,i,r,a,o){if(r.isHidden(this.transform.zoom)||"background"!==r.type&&"custom"!==r.type&&!(a||[]).length)return;this.id=r.id;let s=this.drawFunctions;(0,m.x)(r)?s.symbol(t,i,r,a,this.style.placement.variableOffsets,o):(0,m.Ot)(r)?s.circle(t,i,r,a,o):(0,m.wt)(r)?s.heatmap(t,i,r,a,o):(0,m.W)(r)?s.line(t,i,r,a,o):(0,m.mt)(r)?s.fill(t,i,r,a,o):(0,m.K)(r)?s.fillExtrusion(t,i,r,a,o):(0,m.St)(r)?s.hillshade(t,i,r,a,o):(0,m.yt)(r)?s.colorRelief(t,i,r,a,o):(0,m.Xt)(r)?s.raster(t,i,r,a,o):(0,m.b)(r)?s.background(t,i,r,a,o):(0,m.v)(r)&&s.custom(t,i,r,o)}static{this.MAX_TEXTURE_POOL_SIZE_PER_BUCKET=50}saveTileTexture(i){let r=this._tileTextures[i.size[0]];r?r.length<t.MAX_TEXTURE_POOL_SIZE_PER_BUCKET?r.push(i):i.destroy():this._tileTextures[i.size[0]]=[i]}getTileTexture(t){let i=this._tileTextures[t];return i&&i.length>0?i.pop():null}acquireRTT(t){let i=this.context.gl,r=this._rttObjectRecyclePool.pop();if(r)return r.size!==t&&(r.texture.update({width:t,height:t,data:null},{premultiply:!1,useMipmap:!0}),r.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE,i.LINEAR_MIPMAP_LINEAR),this.context.extTextureFilterAnisotropic&&i.texParameterf(i.TEXTURE_2D,this.context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this.context.extTextureFilterAnisotropicMax),r.size=t),r;let a=new m.xt(this.context,{width:t,height:t,data:null},i.RGBA,{premultiply:!1,useMipmap:!0});return a.bind(i.LINEAR,i.CLAMP_TO_EDGE,i.LINEAR_MIPMAP_LINEAR),this.context.extTextureFilterAnisotropic&&i.texParameterf(i.TEXTURE_2D,this.context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this.context.extTextureFilterAnisotropicMax),{texture:a,size:t}}bindRTT(t){let i=this.context.gl,r=t.size;if(!this._rttSharedFbo){let t=this.context.createFramebuffer(r,r,!0,!0),a=this.context.createRenderbuffer(i.DEPTH_STENCIL,r,r);t.depthAttachment.set(a),this._rttSharedFbo={fbo:t,depthRenderbuffer:a,size:r}}this._rttSharedFbo.size!==r&&(this.context.bindRenderbuffer.set(this._rttSharedFbo.depthRenderbuffer),i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,r,r),this.context.bindRenderbuffer.set(null),this._rttSharedFbo.fbo.width=r,this._rttSharedFbo.fbo.height=r,this._rttSharedFbo.size=r),this._rttSharedFbo.fbo.colorAttachment.set(t.texture.texture),this.context.bindFramebuffer.set(this._rttSharedFbo.fbo.framebuffer)}releaseRTT(t){this._rttObjectRecyclePool.push(t)}clearRTTPool(){for(let t of this._rttObjectRecyclePool)t.texture.destroy();this._rttObjectRecyclePool.length=0}destroyRTTResources(){if(this.clearRTTPool(),!this._rttSharedFbo)return;this._rttSharedFbo.fbo.colorAttachment.set(null),this._rttSharedFbo.fbo.depthAttachment.set(null);let t=this.context.gl;t.deleteRenderbuffer(this._rttSharedFbo.depthRenderbuffer),t.deleteFramebuffer(this._rttSharedFbo.fbo.framebuffer),this._rttSharedFbo=null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;let i=this.patternAtlas.getPattern(t.from.toString()),r=this.patternAtlas.getPattern(t.to.toString());return!i||!r}useProgram(t,i,r=!1,a=[]){this.cache||={};let o=!!this.style.map.terrain,s=this.style.projection,n=r?tW.projectionMercator:s.shaderPreludeCode,l=r?tH:s.shaderDefine,h=`/${r?tX:s.shaderVariantName}`,c=t+(i?i.cacheKey:"")+h+(this._showOverdrawInspector?"/overdraw":"")+(o?"/terrain":"")+(a?`/${a.join("/")}`:"");return this.cache[c]||=new i1(this.context,tW[t],i,ry[t],this._showOverdrawInspector,o,n,l,a),this.cache[c]}setCustomLayerDefaults(){this.context.setCustomLayerDefaults()}setBaseState(){let t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){if(null==this.debugOverlayCanvas){this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512;let t=this.context.gl;this.debugOverlayTexture=new m.xt(this.context,this.debugOverlayCanvas,t.RGBA)}}destroy(){if(this._tileTextures){for(let t in this._tileTextures){let i=this._tileTextures[t];
vendor: 5,109 bytes, line 816
816if(i)for(let t of i)t.destroy()}this._tileTextures={}}if(this.destroyRTTResources(),this.layerOpacityFbo?.destroy(),this.layerOpacityFbo=null,this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.rasterBoundsBufferPosOnly&&this.rasterBoundsBufferPosOnly.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&this.tileExtentMesh.vertexBuffer?.destroy(),this.tileExtentMesh&&this.tileExtentMesh.indexBuffer?.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.context.projectionUniformBuffer.destroy(),this.context.terrainUniformBuffer.destroy(),this.context.frameUniformBuffer.destroy(),this.cache){for(let t in this.cache){let i=this.cache[t];i?.program&&this.context.gl.deleteProgram(i.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){let{drawingBufferWidth:t,drawingBufferHeight:i}=this.context.gl;return this.width!==t||this.height!==i}},ak=class extends Error{constructor(t,i){super("WebGL2 is required to display this map. We are sorry, but it seems that your browser does not support WebGL2, a technology for rendering 3D graphics on the web. Read more on https://wiki.openstreetmap.org/wiki/This_map_requires_WebGL"),this.name="GPUInitializationError",this.requestedAttributes=t,this.statusMessage=i?.statusMessage??null}};function aB(t,i){let r=!1,a=null,o,s=()=>{a=null,r&&=(t(...o),a=setTimeout(s,i),!1)};return(...t)=>(r=!0,o=t,a||s(),a)}var aO=class{constructor(t){this._getHashParams=()=>new URLSearchParams(window.location.hash.replace("#","")),this._getCurrentHash=()=>{let t=this._getHashParams();return this._hashName?(t.get(this._hashName)||"").split("/"):([...t.keys()][0]??"").split("/")},this._onHashChange=()=>{let t=this._getCurrentHash();if(!this._isValidHash(t))return!1;let i=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(t[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:i,pitch:+(t[4]||0)}),!0},this._updateHashUnthrottled=()=>{let t=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,t)},this._removeHash=()=>{let t=this._getHashParams();if(this._hashName)t.delete(this._hashName);else{let i=Array.from(t.keys());i.length>0&&t.delete(i[0])}let i=decodeURIComponent(t.toString()).replace(/=&/g,"&").replace(/=$/g,""),r=i?`#${i}`:"",a=window.location.href.replace(/(#.+)?$/,r);a=a.replace("&&","&"),window.history.replaceState(window.history.state,null,a)},this._updateHash=aB(this._updateHashUnthrottled,300),this._hashName=t&&encodeURIComponent(t)}addTo(t){return this._map=t,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(t){let i=this._map.getCenter(),r=Math.round(100*this._map.getZoom())/100,a=10**Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.round(i.lng*a)/a,s=Math.round(i.lat*a)/a,n=this._map.getBearing(),l=this._map.getPitch(),h="";if(h+=t?`/${o}/${s}/${r}`:`${r}/${s}/${o}`,(n||l)&&(h+=`/${Math.round(10*n)/10}`),l&&(h+=`/${Math.round(l)}`),this._hashName){let t=this._getHashParams();return t.set(this._hashName,h),`#${decodeURIComponent(t.toString()).replace(/=&/g,"&").replace(/=$/g,"")}`}return`#${h}`}_isValidHash(t){if(t.length<3||t.some(t=>isNaN(+t)))return!1;try{new m.lt(+t[2],+t[1])}catch{return!1}let i=+t[0],r=+(t[3]||0),a=+(t[4]||0);return i>=this._map.getMinZoom()&&i<=this._map.getMaxZoom()&&r>=-180&&r<=180&&a>=this._map.getMinPitch()&&a<=this._map.getMaxPitch()}};let aj={linearity:.3,easing:(0,m.zn)(0,0,.3,1)},aN=(0,m.er)({deceleration:2500,maxSpeed:1400},aj),aZ=(0,m.er)({deceleration:20,maxSpeed:1400},aj),aU=(0,m.er)({deceleration:1e3,maxSpeed:360},aj),aG=(0,m.er)({deceleration:1e3,maxSpeed:90},aj),aV=(0,m.er)({deceleration:1e3,maxSpeed:360},aj);var aq=class{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:y(),settings:t})}_drainInertiaBuffer(){let t=this._inertiaBuffer,i=y();for(;t.length>0&&i-t[0].time>160;)t.shift()}_getVelocityEntries(){let t=this._inertiaBuffer,i=y()-60,r=Math.max(0,t.length-2);for(;r>0&&t[r-1].time>=i;)r--;return t.slice(r)}_onMoveEnd(t){this._drainInertiaBuffer();let i=this._getVelocityEntries();if(i.length<2)return void this.clear();let r={zoom:0,bearing:0,pitch:0,roll:0,pan:new m.Li(0,0),pinchAround:void 0,around:void 0};for(let{settings:t}of i)t.around&&(r.around=t.around),t.pinchAround&&(r.pinchAround=t.pinchAround);for(let{settings:t}of i.slice(1))r.zoom+=t.zoomDelta||0,r.bearing+=t.bearingDelta||0,r.pitch+=t.pitchDelta||0,r.roll+=t.rollDelta||0,t.panDelta&&r.pan._add(t.panDelta);
816if(!r.pan.mag()&&!r.zoom&&!r.bearing&&!r.pitch&&!r.roll)return void this.clear();let a=y()-i[0].time,o={};if(r.pan.mag()){let i=a$(r.pan.mag(),a,(0,m.er)({},aN,t||{})),s=r.pan.mult(i.amount/r.pan.mag()),n=this._map._camera.cameraHelper.handlePanInertia(s,this._map._camera.transform);o.center=n.easingCenter,o.offset=n.easingOffset,aW(o,i)}if(r.zoom){let t=a$(r.zoom,a,aZ);o.zoom=(0,m.$n)(this._map.getZoom()+t.amount,this._map.getZoomSnap(),t.amount),aW(o,t)}if(r.bearing){let t=a$(r.bearing,a,aU);o.bearing=this._map.getBearing()+(0,m.Bn)(t.amount,-179,179),aW(o,t)}if(r.pitch){let t=a$(r.pitch,a,aG);o.pitch=this._map.getPitch()+t.amount,aW(o,t)}if(r.roll){let t=a$(r.roll,a,aV);o.roll=this._map.getRoll()+(0,m.Bn)(t.amount,-179,179),aW(o,t)}if(o.zoom||o.bearing){let t=void 0===r.pinchAround?r.around:r.pinchAround;o.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),(0,m.er)(o,{noMoveStart:!0})}};function aW(t,i){(!t.duration||t.duration<i.duration)&&(t.duration=i.duration,t.easing=i.easing)}function a$(t,i,r){let{maxSpeed:a,linearity:o,deceleration:s}=r,n=(0,m.Bn)(t*o/(i/1e3),-a,a),l=Math.abs(n)/(s*o);return{easing:r.easing,duration:1e3*l,amount:l/2*n}}var aH=class{constructor(t,i){this._map=t,this._clickTolerance=i.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new E(this._map,t))}mousedown(t,i){return this._mousedownPos=i,this._firePreventable(new C(t.type,this._map,t))}mouseup(t){this._map.fire(new C(t.type,this._map,t))}click(t,i){this._mousedownPos&&this._mousedownPos.dist(i)>=this._clickTolerance||this._map.fire(new C(t.type,this._map,t))}dblclick(t){return this._firePreventable(new C(t.type,this._map,t))}mouseover(t){this._map.fire(new C(t.type,this._map,t))}mouseout(t){this._map.fire(new C(t.type,this._map,t))}touchstart(t){return this._firePreventable(new S(t.type,this._map,t))}touchmove(t){this._map.fire(new S(t.type,this._map,t))}touchend(t){this._map.fire(new S(t.type,this._map,t))}touchcancel(t){this._map.fire(new S(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},aX=class{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new C(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new C("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new C(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},aY=class{constructor(t,i,r){this._map=t,this._tr=r,this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=i.clickTolerance||1,i.boxZoom&&"object"==typeof i.boxZoom&&(this._boxZoomEnd=i.boxZoom.boxZoomEnd)}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,i){this.isEnabled()&&t.shiftKey&&0===t.button&&(x.disableDrag(),this._startPos=this._lastPos=i,this._active=!0)}mousemoveWindow(t,i){if(!this._active||this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)<this._clickTolerance)return;let r=this._startPos;this._lastPos=i,this._box||(this._box=x.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",t));let a=Math.min(r.x,i.x),o=Math.max(r.x,i.x),s=Math.min(r.y,i.y),n=Math.max(r.y,i.y);this._box.style.transform=`translate(${a}px,${s}px)`,this._box.style.width=`${o-a}px`,this._box.style.height=`${n-s}px`}mouseupWindow(t,i){if(!this._active||0!==t.button)return;let r=this._startPos;if(this.reset(),x.suppressClick(),r.x!==i.x||r.y!==i.y)return(this._map.fire(new z("boxzoomend",{originalEvent:t})),this._boxZoomEnd)?void this._boxZoomEnd(this._map,r,i,t):{cameraAnimation:t=>t.fitScreenCoordinates(r,i,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",t)}keydown(t){this._active&&27===t.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",t))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&=(this._box.remove(),null),x.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,i){return this._map.fire(new z(t,{originalEvent:i}))}};function aK(t,i){if(t.length!==i.length)throw Error(`The number of touches and points are not equal - touches ${t.length}, points ${i.length}`);let r={};for(let a=0;a<t.length;a++)r[t[a].identifier]=i[a];return r}var aJ=class{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(t,i,r){(this.centroid||r.length>this.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=t.timeStamp),r.length===this.numTouches&&(this.centroid=function(t){let i=new m.Li(0,0);for(let r of t)i._add(r);return i.div(t.length)}(i),this.touches=aK(r,i)))}touchmove(t,i,r){if(this.aborted||!this.centroid)return;let a=aK(r,i);for(let t in this.touches){let i=this.touches[t],r=a[t];(!r||r.dist(i)>30)&&(this.aborted=!0)}}touchend(t,i,r){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===r.length){let t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}},aQ=class{constructor(t){this.singleTap=new aJ(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,i,r){this.singleTap.touchstart(t,i,r)}touchmove(t,i,r){this.singleTap.touchmove(t,i,r)}touchend(t,i,r){let a=this.singleTap.touchend(t,i,r);
816if(a){let i=t.timeStamp-this.lastTime<500,r=!this.lastTap||30>this.lastTap.dist(a);if(i&&r||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=a,this.count===this.numTaps)return this.reset(),a}}},a0=class{constructor(t,i){this._tr=i,this._zoomIn=new aQ({numTouches:1,numTaps:2}),this._zoomOut=new aQ({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,i,r){this._zoomIn.touchstart(t,i,r),this._zoomOut.touchstart(t,i,r)}touchmove(t,i,r){this._zoomIn.touchmove(t,i,r),this._zoomOut.touchmove(t,i,r)}touchend(t,i,r){let a=this._zoomIn.touchend(t,i,r),o=this._zoomOut.touchend(t,i,r),s=this._tr;return a?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:i=>i.easeTo({duration:300,zoom:(0,m.$n)(s.zoom+1,i.getZoomSnap()),around:s.unproject(a)},{originalEvent:t})}):o?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:i=>i.easeTo({duration:300,zoom:(0,m.$n)(s.zoom-1,i.getZoomSnap()),around:s.unproject(o)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},a1=class{constructor(t){this._enabled=!!t.enable,this._moveStateManager=t.moveStateManager,this._clickTolerance=t.clickTolerance||1,this._moveFunction=t.move,this._activateOnStart=!!t.activateOnStart,t.assignEvents(this),this.reset()}reset(t){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(t)}_move(...t){let i=this._moveFunction(...t);if(i.bearingDelta||i.pitchDelta||i.rollDelta||i.around||i.panDelta)return this._active=!0,i}dragStart(t,i){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=Array.isArray(i)?i[0]:i,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,i){if(!this.isEnabled())return;let r=this._lastPoint;if(!r)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);let a=Array.isArray(i)?i[0]:i;if(!(!this._moved&&a.dist(r)<this._clickTolerance))return this._moved=!0,this._lastPoint=a,this._move(r,a)}dragEnd(t){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(t)&&(this._moved&&x.suppressClick(),this.reset(t))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}};let a2={0:1,2:2};var a4=class{constructor(t){this._correctEvent=t.checkCorrectEvent}startMove(t){this._eventButton=t.button}endMove(t){delete this._eventButton}isValidStartEvent(t){return this._correctEvent(t)}isValidMoveEvent(t){let i;return i=a2[this._eventButton],void 0!==t.buttons&&(t.buttons&i)===i}isValidEndEvent(t){return t.button===this._eventButton}},a3=class{constructor(){this._firstTouch=void 0}_isOneFingerTouch(t){return 1===t.targetTouches.length}_isSameTouchEvent(t){return t.targetTouches[0].identifier===this._firstTouch}startMove(t){this._firstTouch=t.targetTouches[0].identifier}endMove(t){delete this._firstTouch}isValidStartEvent(t){return this._isOneFingerTouch(t)}isValidMoveEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}isValidEndEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}},a5=class{constructor(t=new a4({checkCorrectEvent:()=>!0}),i=new a3){this.mouseMoveStateManager=t,this.oneFingerTouchMoveStateManager=i}_executeRelevantHandler(t,i,r){return t instanceof MouseEvent?i(t):"u">typeof TouchEvent&&t instanceof TouchEvent?r(t):void 0}startMove(t){this._executeRelevantHandler(t,t=>{this.mouseMoveStateManager.startMove(t)},t=>{this.oneFingerTouchMoveStateManager.startMove(t)})}endMove(t){this._executeRelevantHandler(t,t=>{this.mouseMoveStateManager.endMove(t)},t=>{this.oneFingerTouchMoveStateManager.endMove(t)})}isValidStartEvent(t){return!!this._executeRelevantHandler(t,t=>this.mouseMoveStateManager.isValidStartEvent(t),t=>this.oneFingerTouchMoveStateManager.isValidStartEvent(t))}isValidMoveEvent(t){return!!this._executeRelevantHandler(t,t=>this.mouseMoveStateManager.isValidMoveEvent(t),t=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(t))}isValidEndEvent(t){return!!this._executeRelevantHandler(t,t=>this.mouseMoveStateManager.isValidEndEvent(t),t=>this.oneFingerTouchMoveStateManager.isValidEndEvent(t))}};let a6=t=>{t.mousedown=t.dragStart,t.mousemoveWindow=t.dragMove,t.mouseup=t.dragEnd,t.contextmenu=t=>{t.preventDefault()}};var a8=class{constructor(t,i){this._clickTolerance=t.clickTolerance||1,this._map=i,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new m.Li(0,0)}_shouldBePrevented(t){return t<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(t,i,r){return this._calculateTransform(t,i,r)}touchmove(t,i,r){if(this._active)return this._shouldBePrevented(r.length)?void this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",t):(t.preventDefault(),this._calculateTransform(t,i,r))}touchend(t,i,r){this._calculateTransform(t,i,r),this._active&&this._shouldBePrevented(r.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,i,r){r.length>0&&(this._active=!0);let a=aK(r,i),o=new m.Li(0,0),s=new m.Li(0,0),n=0;for(let t in a){let i=a[t],r=this._touches[t];r&&(o._add(i),s._add(i.sub(r)),n++,a[t]=i)}if(this._touches=a,this._shouldBePrevented(n)||!s.mag())return;let l=s.div(n);if(this._sum._add(l),!(this._sum.mag()<this._clickTolerance))return{around:o.div(n),panDelta:l}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},a9=class{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(t,i,r){this._firstTwoTouches||r.length<2||(this._firstTwoTouches=[r[0].identifier,r[1].identifier],this._start([i[0],i[1]]))}touchmove(t,i,r){if(!this._firstTwoTouches)return;t.preventDefault();let[a,o]=this._firstTwoTouches,s=a7(r,i,a),n=a7(r,i,o);if(!s||!n)return;let l=this._aroundCenter?null:s.add(n).div(2);return this._move([s,n],l,t)}touchend(t,i,r){if(!this._firstTwoTouches)return;let[a,o]=this._firstTwoTouches,s=a7(r,i,a),n=a7(r,i,o);s&&n||(this._active&&x.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}};function a7(t,i,r){for(let a=0;a<t.length;a++)if(t[a].identifier===r)return i[a]}function oe(t,i){return Math.log(t/i)/Math.LN2}var ot=class extends a9{constructor(){super(),this._zoomRate=1,this._zoomThreshold=.1}setZoomRate(t){this._zoomRate=t??1}setZoomThreshold(t){this._zoomThreshold=t??.1}reset(){super.reset(),delete this._distance,delete this._startDistance}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,i){let r=this._distance;if(this._distance=t[0].dist(t[1]),!(!this._active&&Math.abs(oe(this._distance,this._startDistance))<this._zoomThreshold))return this._active=!0,{zoomDelta:oe(this._distance,r)*this._zoomRate,pinchAround:i}}};function oi(t,i){return 180*t.angleWith(i)/Math.PI}var or=class extends a9{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,i,r){let a=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:oi(this._vector,a),pinchAround:i}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());let i=25/(Math.PI*this._minDiameter)*360;return Math.abs(oi(t,this._startVector))<i}};function oa(t){return Math.abs(t.y)>Math.abs(t.x)}var oo=class extends a9{constructor(t){super(),this._currentTouchCount=0,this._map=t}
816reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,i,r){super.touchstart(t,i,r),this._currentTouchCount=r.length}_start(t){this._lastPoints=t,oa(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,i,r){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let a=t[0].sub(this._lastPoints[0]),o=t[1].sub(this._lastPoints[1]);if(this._valid=this.gestureBeginsVertically(a,o,r.timeStamp),this._valid)return this._lastPoints=t,this._active=!0,{pitchDelta:-((a.y+o.y)/2*.5)}}gestureBeginsVertically(t,i,r){if(void 0!==this._valid)return this._valid;let a=t.mag()>=2,o=i.mag()>=2;if(!a&&!o)return;if(!a||!o)return void 0===this._firstMove&&(this._firstMove=r),r-this._firstMove<100&&void 0;let s=t.y>0==i.y>0;return oa(t)&&oa(i)&&s}};let os={panStep:100,bearingStep:15,pitchStep:10};var on=class{constructor(t,i){this._tr=i,this._panStep=os.panStep,this._bearingStep=os.bearingStep,this._pitchStep=os.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let i=0,r=0,a=0,o=0,s=0;switch(t.keyCode){case 61:case 107:case 171:case 187:i=1;break;case 189:case 109:case 173:i=-1;break;case 37:t.shiftKey?r=-1:(t.preventDefault(),o=-1);break;case 39:t.shiftKey?r=1:(t.preventDefault(),o=1);break;case 38:t.shiftKey?a=1:(t.preventDefault(),s=-1);break;case 40:t.shiftKey?a=-1:(t.preventDefault(),s=1);break;default:return}return this._rotationDisabled&&(r=0,a=0),{cameraAnimation:n=>{let l=this._tr;n.easeTo({duration:300,easeId:"keyboardHandler",easing:ol,zoom:i?(0,m.$n)(l.zoom+i*(t.shiftKey?2:1),n.getZoomSnap()):l.zoom,bearing:l.bearing+r*this._bearingStep,pitch:l.pitch+a*this._pitchStep,offset:[-o*this._panStep,-s*this._panStep],center:l.center},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}};function ol(t){return t*(2-t)}var oh=class{constructor(t,i,r){this._onTimeout=t=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)},this._map=t,this._tr=r,this._triggerRenderFrame=i,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(t){return!!this._map.cooperativeGestures.isEnabled()&&!(t.ctrlKey||this._map.cooperativeGestures.isBypassed(t))}wheel(t){if(!this.isEnabled())return;if(this._shouldBePrevented(t))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",t);let i=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY,r=y(),a=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==i&&i%4.000244140625==0?this._type="wheel":0!==i&&4>Math.abs(i)?this._type="trackpad":a>400?(this._type=null,this._lastValue=i,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=200>Math.abs(a*i)?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),t.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=t,this._delta-=i,this._active||this._start(t)),t.preventDefault()}_start(t){if(!this._delta)return;this._needsRerender=!1,this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);let i=x.mousePos(this._map.getCanvas(),t),r=this._tr;this._aroundPoint=this._aroundCenter?r.transform.locationToScreenPoint(m.lt.convert(r.center)):i,this._needsRerender||(this._needsRerender=!0,this._triggerRenderFrame())}renderFrame(){if(!this._needsRerender||(this._needsRerender=!1,!this.isActive()))return;let t=this._tr.transform;if("number"==typeof this._lastExpectedZoom){let i=t.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=i),"number"==typeof this._targetZoom&&(this._targetZoom+=i)}if(0!==this._delta){let i="wheel"===this._type&&Math.abs(this._delta)>4.000244140625?this._wheelZoomRate:this._defaultZoomRate,r=2/(1+Math.exp(-Math.abs(this._delta*i)));this._delta<0&&0!==r&&(r=1/r);let a="number"==typeof this._targetZoom?(0,m.Fr)(this._targetZoom):t.scale,o=t.applyConstrain(t.getCameraLngLat(),(0,m.Dr)(a*r)).zoom,s=this._map.getZoomSnap();if("wheel"===this._type&&s>0){let i=(0,m.$n)(t.zoom,s);this._targetZoom=(0,m.$n)(o,s,o-i)}else this._targetZoom=o;"wheel"===this._type&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let i="number"==typeof this._targetZoom?this._targetZoom:t.zoom,r=this._startZoom,a=this._easing,o=!1,s;if("wheel"===this._type&&r&&a){let t=Math.min((y()-this._lastWheelEventTime+5)/200,1),n=a(t);s=m.un.number(r,i,n),t<1?this._needsRerender=!0:o=!0}else s=i,o=!0;return this._active=!0,o&&(this._active=!1,this._finishTimeout=setTimeout(()=>
vendor: 7,249 bytes, line 816
816{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout},200)),this._lastExpectedZoom=s,{noInertia:!0,needsRenderFrame:!o,zoomDelta:s-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=m.Jn;if(this._prevEase){let t=this._prevEase,r=(y()-t.start)/t.duration,a=t.easing(r+.01)-t.easing(r),o=.27/Math.sqrt(a*a+1e-4)*.01,s=Math.sqrt(.0729-o*o);i=(0,m.zn)(o,s,.25,1)}return this._prevEase={start:y(),duration:t,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}},oc=class{constructor(t,i){this._clickZoom=t,this._tapZoom=i}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()}},ou=class{constructor(t,i){this._tr=i,this.reset()}reset(){this._active=!1}dblclick(t,i){return t.preventDefault(),{cameraAnimation:r=>{r.easeTo({duration:300,zoom:(0,m.$n)(this._tr.zoom+(t.shiftKey?-1:1),r.getZoomSnap()),around:this._tr.unproject(i)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},od=class{constructor(){this._tap=new aQ({numTouches:1,numTaps:1}),this._zoomRate=1,this.reset()}setZoomRate(t){this._zoomRate=t??1}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(t,i,r){if(!this._swipePoint)if(this._tapTime){let a=i[0],o=t.timeStamp-this._tapTime<500,s=30>this._tapPoint.dist(a);o&&s?r.length>0&&(this._swipePoint=a,this._swipeTouch=r[0].identifier):this.reset()}else this._tap.touchstart(t,i,r)}touchmove(t,i,r){if(this._tapTime){if(this._swipePoint){if(r[0].identifier!==this._swipeTouch)return;let a=i[0],o=a.y-this._swipePoint.y;return this._swipePoint=a,t.preventDefault(),this._active=!0,{zoomDelta:o/128*this._zoomRate}}}else this._tap.touchmove(t,i,r)}touchend(t,i,r){if(this._tapTime)this._swipePoint&&0===r.length&&this.reset();else{let a=this._tap.touchend(t,i,r);a&&(this._tapTime=t.timeStamp,this._tapPoint=a)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},o_=class{constructor(t,i,r){this._el=t,this._mousePan=i,this._touchPan=r}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}},op=class{constructor(t,i,r,a){this._pitchWithRotate=t.pitchWithRotate,this._rollEnabled=t.rollEnabled,this._mouseRotate=i,this._mousePitch=r,this._mouseRoll=a}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}},om=class{constructor(t,i,r,a){this._el=t,this._touchZoom=i,this._touchRotate=r,this._tapDragZoom=a,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}setZoomRate(t){this._touchZoom.setZoomRate(t),this._tapDragZoom.setZoomRate(t)}setZoomThreshold(t){this._touchZoom.setZoomThreshold(t)}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}},of=class{constructor(t,i){this._bypassKey=navigator.userAgent.includes("Mac")?"metaKey":"ctrlKey",this._map=t,this._options=i,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;let t=this._map.getCanvasContainer();t.classList.add("maplibregl-cooperative-gestures"),this._container=x.create("div","maplibregl-cooperative-gesture-screen",t);let i=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(i=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));let r=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),a=document.createElement("div");a.className="maplibregl-desktop-message",a.textContent=i,this._container.appendChild(a);let o=document.createElement("div");o.className="maplibregl-mobile-message",o.textContent=r,this._container.appendChild(o),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(this._container.remove(),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(t){return t[this._bypassKey]}notifyGestureBlocked(t,i){this._enabled&&(this._map.fire(new w("cooperativegestureprevented",{gestureType:t,originalEvent:i})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}},og=class{constructor(t){this._camera=t}get transform(){return this._camera._requestedCameraState||this._camera.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(t){return this.transform.screenPointToLocation(m.Li.convert(t),this._camera.terrain)}};let ov=t=>t.zoom||t.drag||t.roll||t.pitch||t.rotate;var oy=class extends m._n{};function ox(t){return t.panDelta?.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta||t.rollDelta}var ob=class{get _ownerDocument(){return this._el?.ownerDocument||document}get _ownerWindow(){return this._el?.ownerDocument?.defaultView||window}constructor(t,i,r){this._terrainGestureAnchorElevation=null,this.handleWindowEvent=t=>{this.handleEvent(t,`${t.type}Window`)},this.handleEvent=(t,i)=>{if("blur"===t.type)return void this.stop(!0);this._updatingCamera=!0;let r="renderFrame"===t.type?void 0:t,a={needsRenderFrame:!1},o={},s={};for(let{handlerName:n,handler:l,allowed:h}of this._handlers){let c;
816if(l.isEnabled()){if(this._blockedByActive(s,h,n))l.reset();else if(l[i||t.type]){if((0,m.lr)(t,i||t.type)){let r=x.mousePos(this._map.getCanvas(),t);c=l[i||t.type](t,r)}else if((0,m.dr)(t,i||t.type)){let r=t.touches,a=this._getMapTouches(r),o=x.touchPos(this._map.getCanvas(),a);c=l[i||t.type](t,o,a)}else(0,m.fr)(i||t.type)||(c=l[i||t.type](t));this.mergeHandlerResult(a,o,c,n,r),c?.needsRenderFrame&&this._triggerRenderFrame()}(c||l.isActive())&&(s[n]=l)}}let n={};for(let t in this._previousActiveHandlers)s[t]||(n[t]=r);this._previousActiveHandlers=s,(Object.keys(n).length||ox(a))&&(this._changes.push([a,o,n]),this._triggerRenderFrame()),(Object.keys(s).length||ox(a))&&this._camera.stop(!0),this._updatingCamera=!1;let{cameraAnimation:l}=a;l&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],l(this._map))},this._map=t,this._camera=i,this._transformProvider=new og(this._camera),this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new aq(t),this._bearingSnap=r.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(r);let a=this._el;for(let[t,i,r]of(this._listeners=[[a,"touchstart",{passive:!0}],[a,"touchmove",{passive:!1}],[a,"touchend",void 0],[a,"touchcancel",void 0],[a,"mousedown",void 0],[a,"mousemove",void 0],[a,"mouseup",void 0],[this._ownerDocument,"mousemove",{capture:!0}],[this._ownerDocument,"mouseup",void 0],[a,"mouseover",void 0],[a,"mouseout",void 0],[a,"dblclick",void 0],[a,"click",void 0],[a,"keydown",{capture:!1}],[a,"keyup",void 0],[a,"wheel",{passive:!1}],[a,"contextmenu",void 0],[this._ownerWindow,"blur",void 0]],this._listeners))t.addEventListener(i,t===this._ownerDocument?this.handleWindowEvent:this.handleEvent,r)}destroy(){for(let[t,i,r]of this._listeners)t.removeEventListener(i,t===this._ownerDocument?this.handleWindowEvent:this.handleEvent,r)}_addDefaultHandlers(t){let i=this._map,r=i.getCanvasContainer();this._add("mapEvent",new aH(i,t));let a=i.boxZoom=new aY(i,t,this._transformProvider);this._add("boxZoom",a),t.interactive&&t.boxZoom&&a.enable();let o=i.cooperativeGestures=new of(i,t.cooperativeGestures);this._add("cooperativeGestures",o),t.cooperativeGestures&&o.enable();let s=new a0(i,this._transformProvider),n=new ou(i,this._transformProvider);i.doubleClickZoom=new oc(n,s),this._add("tapZoom",s),this._add("clickZoom",n),t.interactive&&t.doubleClickZoom&&i.doubleClickZoom.enable();let l=new od;this._add("tapDragZoom",l);let h=i.touchPitch=new oo(i);this._add("touchPitch",h),t.interactive&&t.touchPitch&&i.touchPitch.enable(t.touchPitch);let c=()=>i.project(i.getCenter()),u=function({enable:t,clickTolerance:i,aroundCenter:r=!0,minPixelCenterThreshold:a=100,rotateSpeed:o=.8},s){return new a1({clickTolerance:i,move:(t,i)=>{let n=s();if(r&&Math.abs(n.y-t.y)>a)return{bearingDelta:(0,m.ir)(new m.Li(t.x,i.y),i,n)};let l=(i.x-t.x)*o;return r&&i.y<n.y&&(l=-l),{bearingDelta:l}},moveStateManager:new a4({checkCorrectEvent:t=>0===t.button&&t.ctrlKey||2===t.button&&!t.ctrlKey}),enable:t,assignEvents:a6})}(t,c),d=function({enable:t,clickTolerance:i,pitchSpeed:r=-.5}){return new a1({clickTolerance:i,move:(t,i)=>({pitchDelta:(i.y-t.y)*r}),moveStateManager:new a4({checkCorrectEvent:t=>0===t.button&&t.ctrlKey||2===t.button}),enable:t,assignEvents:a6})}(t),_=function({enable:t,clickTolerance:i,rollDegreesPerPixelMoved:r=.3},a){return new a1({clickTolerance:i,move:(t,i)=>{let o=a(),s=(i.x-t.x)*r;return i.y<o.y&&(s=-s),{rollDelta:s}},moveStateManager:new a4({checkCorrectEvent:t=>2===t.button&&t.ctrlKey}),enable:t,assignEvents:a6})}(t,c);i.dragRotate=new op(t,u,d,_),this._add("mouseRotate",u,["mousePitch"]),this._add("mousePitch",d,["mouseRotate","mouseRoll"]),this._add("mouseRoll",_,["mousePitch"]),t.interactive&&t.dragRotate&&i.dragRotate.enable();let p=function({enable:t,clickTolerance:i}){return new a1({clickTolerance:i,move:(t,i)=>({around:i,panDelta:i.sub(t)}),activateOnStart:!0,moveStateManager:new a4({checkCorrectEvent:t=>0===t.button&&!t.ctrlKey}),enable:t,assignEvents:a6})}(t),f=new a8(t,i);i.dragPan=new o_(r,p,f),this._add("mousePan",p),this._add("touchPan",f,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&i.dragPan.enable(t.dragPan);let g=new or,v=new ot;i.touchZoomRotate=new om(r,v,g,l),this._add("touchRotate",g,["touchPan","touchZoom"]),this._add("touchZoom",v,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&i.touchZoomRotate.enable(t.touchZoomRotate),this._add("blockableMapEvent",new aX(i));let y=i.scrollZoom=new oh(i,()=>
816this._triggerRenderFrame(),this._transformProvider);this._add("scrollZoom",y,["mousePan"]),t.interactive&&t.scrollZoom&&i.scrollZoom.enable(t.scrollZoom);let x=i.keyboard=new on(i,this._transformProvider);this._add("keyboard",x),t.interactive&&t.keyboard&&i.keyboard.enable()}_add(t,i,r){this._handlers.push({handlerName:t,handler:i,allowed:r}),this._handlersById[t]=i}stop(t){if(!this._updatingCamera){for(let{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(let{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!ov(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,i,r){for(let a in t)if(a!==r&&!i?.includes(a))return!0;return!1}_getMapTouches(t){let i=[];for(let r of t){let t=r.target;this._el.contains(t)&&i.push(r)}return i}mergeHandlerResult(t,i,r,a,o){if(!r)return;(0,m.er)(t,r);let s={handlerName:a,originalEvent:r.originalEvent||o};void 0!==r.zoomDelta&&(i.zoom=s),void 0!==r.panDelta&&(i.drag=s),void 0!==r.rollDelta&&(i.roll=s),void 0!==r.pitchDelta&&(i.pitch=s),void 0!==r.bearingDelta&&(i.rotate=s)}_applyChanges(){let t={},i={},r={};for(let[a,o,s]of this._changes)a.panDelta&&(t.panDelta=(t.panDelta||new m.Li(0,0))._add(a.panDelta)),a.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+a.zoomDelta),a.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+a.bearingDelta),a.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+a.pitchDelta),a.rollDelta&&(t.rollDelta=(t.rollDelta||0)+a.rollDelta),void 0!==a.around&&(t.around=a.around),void 0!==a.pinchAround&&(t.pinchAround=a.pinchAround),a.noInertia&&(t.noInertia=a.noInertia),(0,m.er)(i,o),(0,m.er)(r,s);this._updateMapTransform(t,i,r),this._changes=[]}_updateMapTransform(t,i,r){let a=this._map,o=this._camera.getTransformForUpdate(),s=a.terrain;if(!ox(t)&&!(s&&this._terrainMovement))return void this._fireEvents(i,r,!0);this._camera.stop(!0);let{panDelta:n,zoomDelta:l,bearingDelta:h,pitchDelta:c,rollDelta:u}=t,{around:d,aroundOnSurface:_}=this._resolveAround(t,s,o),p=s?this._terrainGestureElevation(s,d,_,o,i):void 0,m={panDelta:n,zoomDelta:l,rollDelta:u,pitchDelta:c,bearingDelta:h,around:d,aroundElevation:p};this._camera.cameraHelper.useGlobeControls&&!o.isPointOnMapSurface(d)&&(d=o.centerPoint);let f=this._computePreZoomAroundLoc(o,d,n,p);this._handleMapControls({terrain:s,tr:o,deltasForHelper:m,preZoomAroundLoc:f,combinedEventsInProgress:i,panDelta:n}),this._camera.applyUpdatedTransform(o),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(i,r,!0)}_resolveAround(t,i,r){let a=void 0===t.pinchAround?t.around:t.pinchAround;return a||=this._camera.transform.centerPoint,i&&!r.isPointOnMapSurface(a)?{around:r.centerPoint,aroundOnSurface:!1}:{around:a,aroundOnSurface:!0}}_terrainGestureElevation(t,i,r,a,o){if(!r)return;if(!this._terrainMovement&&(o.drag||o.zoom)){let r=a.screenTerrainPointToMercatorCoordinate(i,t);this._terrainGestureAnchorElevation=r?r.z:null}if(null===this._terrainGestureAnchorElevation)return;let s=this._terrainGestureAnchorElevation;if(!(.01>i.distSqr(a.centerPoint))&&!(s-a.elevation>=.9*(a.getCameraAltitude()-a.elevation)))return s}_computePreZoomAroundLoc(t,i,r,a){if(.01>i.distSqr(t.centerPoint))return t.center;let o=r?i.sub(r):i;return void 0===a?t.screenPointToLocation(o):t.screenPointToLocationAtElevation(o,a)}_handleMapControls({terrain:t,tr:i,deltasForHelper:r,preZoomAroundLoc:a,combinedEventsInProgress:o,panDelta:s}){let n=this._camera.cameraHelper;if(n.handleMapControlsRollPitchBearingZoom(r,i),!t)return void n.handleMapControlsPan(r,i,a);if(n.useGlobeControls){!this._terrainMovement&&(o.drag||o.zoom)&&(this._terrainMovement=!0,this._camera.elevationFreeze=!0),n.handleMapControlsPan(r,i,a);return}if(!this._terrainMovement&&(o.drag||o.zoom)){this._terrainMovement=!0,this._camera.elevationFreeze=!0,n.handleMapControlsPan(r,i,a);return}if(void 0===r.aroundElevation&&o.drag&&this._terrainMovement&&s)return void i.setCenter(i.screenPointToLocation(i.centerPoint.sub(s)));
816n.handleMapControlsPan(r,i,a)}_fireEvents(t,i,r){let a=ov(this._eventsInProgress),o=ov(t),s={};for(let i in t){let{originalEvent:r}=t[i];this._eventsInProgress[i]||(s[`${i}start`]=r),this._eventsInProgress[i]=t[i]}for(let t in!a&&o&&this._fireEvent("movestart",o.originalEvent),s)this._fireEvent(t,s[t]);for(let i in o&&this._fireEvent("move",o.originalEvent),t){let{originalEvent:r}=t[i];this._fireEvent(i,r)}let n={},l;for(let t in this._eventsInProgress){let{handlerName:r,originalEvent:a}=this._eventsInProgress[t];this._handlersById[r].isActive()||(delete this._eventsInProgress[t],l=i[r]||a,n[`${t}end`]=l)}for(let t in n)this._fireEvent(t,n[t]);let h=ov(this._eventsInProgress),c=(a||o)&&!h;if(c&&this._terrainMovement){this._camera.elevationFreeze=!1,this._terrainMovement=!1,this._terrainGestureAnchorElevation=null;let t=this._camera.getTransformForUpdate();this._map.getCenterClampedToGround()&&t.recalculateZoomAndCenter(this._map.terrain),this._camera.applyUpdatedTransform(t)}if(r&&c){this._updatingCamera=!0;let t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=t=>0!==t&&-this._bearingSnap<t&&t<this._bearingSnap;t&&(t.essential||!g.prefersReducedMotion)?(i(t.bearing||this._map.getBearing())&&(t.bearing=0),t.freezeElevation=!0,this._map.easeTo(t,{originalEvent:l})):(this._map.fire(new T("moveend",{originalEvent:l})),i(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(t,i){this._map.fire(new T(t,i?{originalEvent:i}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(t=>{delete this._frameId,this.handleEvent(new oy("renderFrame",{timeStamp:t})),this._applyChanges()})}
816_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}},ow=class extends m.vn{constructor(t){super(),this._renderFrameCallback=()=>{let t=Math.min((y()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this.transform=new ie,this.cameraHelper=new il,void 0!==t.minZoom&&this.transform.setMinZoom(t.minZoom),void 0!==t.maxZoom&&this.transform.setMaxZoom(t.maxZoom),void 0!==t.minPitch&&this.transform.setMinPitch(t.minPitch),void 0!==t.maxPitch&&this.transform.setMaxPitch(t.maxPitch),void 0!==t.renderWorldCopies&&this.transform.setRenderWorldCopies(t.renderWorldCopies),null!==t.transformConstrain&&this.transform.setConstrainOverride(t.transformConstrain),this._moving=!1,this._zooming=!1,this._bearingSnap=t.bearingSnap,this._zoomSnap=t.zoomSnap,this._requestRenderFrame=t.requestRenderFrame,this._cancelRenderFrame=t.cancelRenderFrame,this.terrain=t.terrain,this._centerClampedToGround=t.centerClampedToGround??!0,this.transformCameraUpdate=t.transformCameraUpdate??null,this._stopHandlers=t.stopHandlers??(()=>{}),this.on("moveend",()=>{delete this._requestedCameraState})}migrateProjection(t,i){if(t.apply(this.transform,!0),this.transform=t,this.cameraHelper=i,this._requestedCameraState){let i=t.clone();i.apply(this._requestedCameraState,!0),this._requestedCameraState=i}}getCenter(){return new m.lt(this.transform.center.lng,this.transform.center.lat)}setCenter(t,i){return this.jumpTo({center:t},i)}getCenterElevation(){return this.transform.elevation}setCenterElevation(t,i){return this.jumpTo({elevation:t},i),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(t){this._centerClampedToGround=t}panBy(t,i,r){return t=m.Li.convert(t).mult(-1),this.panTo(this.transform.center,(0,m.er)({offset:t},i),r)}panTo(t,i,r){return this.easeTo((0,m.er)({center:t},i),r)}getZoom(){return this.transform.zoom}setZoom(t,i){return this.jumpTo({zoom:t},i),this}zoomTo(t,i,r){return this.easeTo((0,m.er)({zoom:t},i),r)}zoomIn(t,i){return this.zoomTo((0,m.$n)(this.getZoom()+1,this._zoomSnap),t,i),this}zoomOut(t,i){return this.zoomTo((0,m.$n)(this.getZoom()-1,this._zoomSnap),t,i),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(t,i){return t!=this.transform.fov&&(this.transform.setFov(t),this.fire(new T("movestart",i)).fire(new T("move",i)).fire(new T("moveend",i))),this}getBearing(){return this.transform.bearing}setZoomSnap(t){return this._zoomSnap=t,this}getZoomSnap(){return this._zoomSnap}setBearing(t,i){return this.jumpTo({bearing:t},i),this}getPadding(){return this.transform.padding}setPadding(t,i){return this.jumpTo({padding:t},i),this}rotateTo(t,i,r){return this.easeTo((0,m.er)({bearing:t},i),r)}resetNorth(t,i){return this.rotateTo(0,(0,m.er)({duration:1e3},t),i),this}resetNorthPitch(t,i){return this.easeTo((0,m.er)({bearing:0,pitch:0,roll:0,duration:1e3},t),i),this}snapToNorth(t,i){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,i):this}getPitch(){return this.transform.pitch}setPitch(t,i){return this.jumpTo({pitch:t},i),this}getRoll(){return this.transform.roll}setRoll(t,i){return this.jumpTo({roll:t},i),this}cameraForBounds(t,i){t=ey.convert(t).adjustAntiMeridian();let r=i?.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),r,i)}_cameraForBoxAndBearing(t,i,r,a){let o={top:0,bottom:0,right:0,left:0};if("number"==typeof(a=(0,m.er)({padding:o,offset:[0,0],maxZoom:this.transform.maxZoom},a)).padding){let t=a.padding;a.padding={top:t,bottom:t,right:t,left:t}}let s=(0,m.er)(o,a.padding);a.padding=s;let n=this.transform,l=new ey(t,i),h=this.cameraHelper.cameraForBoxAndBearing(a,s,l,r,n);return h&&this._zoomSnap&&(h.zoom=(0,m.$n)(h.zoom,this._zoomSnap,-1)),h}fitBounds(t,i,r){return this._fitInternal(this.cameraForBounds(t,i),i,r)}fitScreenCoordinates(t,i,r,a,o){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(m.Li.convert(t)),this.transform.screenPointToLocation(m.Li.convert(i)),r,a),a,o)}_fitInternal(t,i,r){return t?(i=(0,m.er)(t,i),delete i.padding,i.linear?this.easeTo(i,r):this.flyTo(i,r)):this}jumpTo(t,i){this.stop(),void 0!==t.zoom&&this._zoomSnap&&(t.zoom=(0,m.$n)(t.zoom,this._zoomSnap));let r=this.getTransformForUpdate(),a=!1,o=!1,s=!1,n=r.zoom;this.terrain&&r.setElevation(this.terrain.getElevationForLngLat(t.center?m.lt.convert(t.center):r.center,r)),this.cameraHelper.handleJumpToCenterZoom(r,t);let l=r.zoom!==n;return void 0!==t.elevation&&r.elevation!==+t.elevation&&r.setElevation(+t.elevation),void 0!==t.bearing&&r.bearing!==+t.bearing&&(a=!0,r.setBearing(+t.bearing)),void 0!==t.pitch&&r.pitch!==+t.pitch&&(o=!0,r.setPitch(+t.pitch)),void 0!==t.roll&&r.roll!==+t.roll&&(s=!0,r.setRoll(+t.roll)),null==t.padding||r.isPaddingEqual(t.padding)||r.setPadding(t.padding),this.applyUpdatedTransform(r),this.fire(new T("movestart",i)).fire(new T("move",i)),l&&this.fire(new T("zoomstart",i)).fire(new T("zoom",i)).fire(new T("zoomend",i)),a&&this.fire(new T("rotatestart",i)).fire(new T("rotate",i)).fire(new T("rotateend",i)),o&&this.fire(new T("pitchstart",i)).fire(new T("pitch",i)).fire(new T("pitchend",
816i)),s&&this.fire(new T("rollstart",i)).fire(new T("roll",i)).fire(new T("rollend",i)),this.fire(new T("moveend",i))}calculateCameraOptionsFromCameraLngLatAltRotation(t,i,r,a,o){let s=this.transform.calculateCenterFromCameraLngLatAlt(t,i,r,a);return{center:s.center,elevation:s.elevation,zoom:s.zoom,bearing:r,pitch:a,roll:o}}easeTo(t,i){this._stop(!1,t.easeId),void 0!==(t=(0,m.er)({offset:[0,0],duration:500,easing:m.Jn},t)).zoom&&this._zoomSnap&&(t.zoom=(0,m.$n)(t.zoom,this._zoomSnap)),(!1===t.animate||!t.essential&&g.prefersReducedMotion)&&(t.duration=0);let r=this.getTransformForUpdate(),a=this.getBearing(),o=r.pitch,s=r.roll,n=void 0===t.bearing?a:this._normalizeBearing(t.bearing,a),l=void 0===t.pitch?o:+t.pitch,h=void 0===t.roll?s:this._normalizeBearing(t.roll,s),c=void 0===t.padding?r.padding:t.padding,u=m.Li.convert(t.offset),d,_;t.around&&(d=m.lt.convert(t.around),_=r.locationToScreenPoint(d));let p={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},f=this.cameraHelper.handleEaseTo(r,{bearing:n,pitch:l,roll:h,padding:c,around:d,aroundPoint:_,offsetAsPoint:u,offset:t.offset,zoom:t.zoom,center:t.center});return this._rotating||=a!==n,this._pitching||=l!==o,this._rolling||=h!==s,this._padding=!r.isPaddingEqual(c),this._zooming||=f.isZooming,this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,p),this.terrain&&this._prepareElevation(f.elevationCenter),this._ease(a=>{f.easeFunc(a),this.terrain&&!t.freezeElevation&&this._updateElevation(a),this.applyUpdatedTransform(r),this._fireMoveEvents(i)},r=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(i,r)},t),this}_prepareEase(t,i,r={}){this._moving=!0,i||r.moving||this.fire(new T("movestart",t)),this._zooming&&!r.zooming&&this.fire(new T("zoomstart",t)),this._rotating&&!r.rotating&&this.fire(new T("rotatestart",t)),this._pitching&&!r.pitching&&this.fire(new T("pitchstart",t)),this._rolling&&!r.rolling&&this.fire(new T("rollstart",t))}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLat(t,this.transform),this.elevationFreeze=!0}_updateElevation(t){(void 0===this._elevationStart||void 0===this._elevationCenter)&&this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));let i=this.terrain.getElevationForLngLat(this._elevationCenter,this.transform);if(t<1&&i!==this._elevationTarget){let r=this._elevationTarget-this._elevationStart,a=(i-(r*t+this._elevationStart))/(1-t);this._elevationStart+=t*(r-a),this._elevationTarget=i}this.transform.setElevation(m.un.number(this._elevationStart,this._elevationTarget,t))}_finalizeElevation(){this.elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||=this.transform.clone(),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(t){if(!this.terrain&&t.elevation>=0&&t.pitch<=90)return{};let i=t.getCameraLngLat(),r=t.getCameraAltitude(),a=this.terrain?this.terrain.getElevationForLngLatZoom(i,t.zoom):0;if(r<a){let r=t.calculateCameraOptionsFromTo(i,a,t.center,t.elevation);return{pitch:r.pitch,zoom:r.zoom}}return{}}applyUpdatedTransform(t){let i=[];if(i.push(t=>this._elevateCameraIfInsideTerrain(t)),this.transformCameraUpdate&&i.push(t=>this.transformCameraUpdate(t)),!i.length)return;let r=t.clone();for(let t of i){let i=r.clone(),{center:a,zoom:o,roll:s,pitch:n,bearing:l,elevation:h}=t(i);a&&i.setCenter(a),void 0!==h&&i.setElevation(h),void 0!==o&&i.setZoom(o),void 0!==s&&i.setRoll(s),void 0!==n&&i.setPitch(n),void 0!==l&&i.setBearing(l),r.apply(i,!1)}this.transform.apply(r,!1)}_fireMoveEvents(t){this.fire(new T("move",t)),this._zooming&&this.fire(new T("zoom",t)),this._rotating&&this.fire(new T("rotate",t)),this._pitching&&this.fire(new T("pitch",t)),this._rolling&&this.fire(new T("roll",t))}
816_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;let r=this._zooming,a=this._rotating,o=this._pitching,s=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,r&&this.fire(new T("zoomend",t)),a&&this.fire(new T("rotateend",t)),o&&this.fire(new T("pitchend",t)),s&&this.fire(new T("rollend",t)),this.fire(new T("moveend",t))}flyTo(t,i){if(!t.essential&&g.prefersReducedMotion){let r=(0,m.yr)(t,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(r,i)}this.stop(),void 0!==(t=(0,m.er)({offset:[0,0],speed:1.2,curve:1.42,easing:m.Jn},t)).zoom&&this._zoomSnap&&(t.zoom=(0,m.$n)(t.zoom,this._zoomSnap));let r=this.getTransformForUpdate(),a=r.bearing,o=r.pitch,s=r.roll,n=r.padding,l=void 0===t.bearing?a:this._normalizeBearing(t.bearing,a),h=void 0===t.pitch?o:+t.pitch,c=void 0===t.roll?s:this._normalizeBearing(t.roll,s),u=void 0===t.padding?r.padding:t.padding,d=m.Li.convert(t.offset),_=r.centerPoint.add(d),p=r.screenPointToLocation(_),f=this.cameraHelper.handleFlyTo(r,{bearing:l,pitch:h,roll:c,padding:u,locationAtOffset:p,offsetAsPoint:d,center:t.center,minZoom:t.minZoom,zoom:t.zoom}),v=t.curve,y=Math.max(r.width,r.height),x=y/f.scaleOfZoom,b=f.pixelPathLength,w=y/f.scaleOfMinZoom,T=(v=M
816ath.min(v,Math.sqrt(w/b*2)))*v;function P(t){let i=(x*x-y*y+(t?-1:1)*T*T*b*b)/(2*(t?x:y)*T*b);return Math.log(Math.sqrt(i*i+1)-i)}function M(t){return(Math.exp(t)-Math.exp(-t))/2}function I(t){return(Math.exp(t)+Math.exp(-t))/2}let C=P(!1),S=function(t){return I(C)/I(C+v*t)},E=function(t){var i;return y*((I(C)*(M(i=C+v*t)/I(i))-M(C))/T)/b},z=(P(!0)-C)/v;if(2e-6>Math.abs(b)||!isFinite(z)){if(1e-6>Math.abs(y-x))return this.easeTo(t,i);let r=x<y?-1:1;z=Math.abs(Math.log(x/y))/v,E=()=>0,S=t=>Math.exp(r*v*t)}if(void 0!==t.duration)t.duration=+t.duration;else{let i=void 0===t.screenSpeed?+t.speed:t.screenSpeed/v;t.duration=1e3*z/i}return t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=a!==l,this._pitching=h!==o,this._rolling=c!==s,this._padding=!r.isPaddingEqual(u),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(f.targetCenter),this._ease(p=>{let g=p*z,v=1/S(g),y=E(g);this._rotating&&r.setBearing(m.un.number(a,l,p)),this._pitching&&r.setPitch(m.un.number(o,h,p)),this._rolling&&r.setRoll(m.un.number(s,c,p)),this._padding&&(r.interpolatePadding(n,u,p),_=r.centerPoint.add(d)),f.easeFunc(p,v,y,_),this.terrain&&!t.freezeElevation&&this._updateElevation(p),this.applyUpdatedTransform(r),this._fireMoveEvents(i)},()=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(i)},t),this}isEasing(){return!!this._easeFrameId}stop(t){return this._stop(t)}_stop(t,i){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let t=this._onEaseEnd;delete this._onEaseEnd,t.call(this,i)}return t||this._stopHandlers(),this}_ease(t,i,r){!1===r.animate||0===r.duration?(t(1),i()):(this._easeStart=y(),this._easeOptions=r,this._onEaseFrame=t,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,i){let r=Math.abs((t=(0,m.Pr)(t,-180,180))-i);return Math.abs(t-360-i)<r&&(t-=360),Math.abs(t+360-i)<r&&(t+=360),t}isMoving(){return this._moving}isZooming(){return this._zooming}isRotating(){return this._rotating}};let oT={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};var oP=class{constructor(t=oT){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=t=>{t&&("terrain"===t.type||"style"===t.dataType||"source"===t.dataType&&("metadata"===t.sourceDataType||"visibility"===t.sourceDataType))&&this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=t}getDefaultPosition(){return"bottom-right"}onAdd(t){return this._map=t,this._compact=this.options.compact,this._container=x.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=x.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=x.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(t,i){let r=this._map._getUIString(`AttributionControl.${i}`);t.title=r,t.setAttribute("aria-label",r)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map(t=>"string"==typeof t?t:"")):"string"==typeof this.options.customAttribution&&t.push(this.options.customAttribution)),this._map.style.stylesheet){let t=this._map.style.stylesheet;this.styleOwner=t.owner,this.styleId=t.id}let i=this._map.style.tileManagers;for(let r in i){let a=i[r];if(a.used||a.usedForTerrain){let i=a.getSource();i.attribution&&!t.includes(i.attribution)&&t.push(i.attribution)}}(t=t.filter(t=>String(t).trim())).sort((t,i)=>t.length-i.length);let r=(t=t.filter((i,r)=>{for(let a=r+1;a<t.length;a++)if(t[a].includes(i))return!1;return!0})).join(" | ");r!==this._attribHTML&&(this._attribHTML=r,t.length?(this._innerContainer.innerHTML=x.sanitize(r),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}},oM=class{constructor(t={}){this._updateCompact=()=>{let t=this._container.children;if(t.length){let i=t[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&i.classList.add("maplibregl-compact"):i.classList.remove("maplibregl-compact")}},this.options=t}getDefaultPosition(){return"bottom-left"}onAdd(t){this._map=t,this._compact=this.options?.compact,this._container=x.create("div","maplibregl-ctrl");let i=x.create("a","maplibregl-ctrl-logo");return i.target="_blank",i.rel="noopener nofollow",i.href="https://maplibre.org/",i.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),i.setAttribute("rel","noopener nofollow"),this._container.appendChild(i),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}},oI=class{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){let i=++this._id;return this._queue.push({callback:t,id:i,cancelled:!1}),i}remove(t){let i=this._currentlyRunning;for(let r of i?this._queue.concat(i):this._queue)if(r.id===t){r.cancelled=!0;return}}run(t=0){if(this._currentlyRunning)throw Error("Attempting to run(), but is already running.");let i=this._currentlyRunning=this._queue;this._queue=[];let r=!1,a;for(let o of i)if(!o.cancelled){try{o.callback(t)}catch(t){r||(r=!0,a=t)}if(this._cleared)break}if(this._cleared=!1,this._currentlyRunning=!1,r)throw a}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}};let oC=["none","zoom","sourceTiles","visibleLayers","revision"];var oS=class{constructor(t,i,r,a){this._tileKeys=t.map(t=>t.key).sort().join(),this._revision=i,this._zoom=r,this._visibleLayerIds=a}difference(t){return this._revision===t?._revision?this._visibleLayerIds===t._visibleLayerIds?this._tileKeys===t._tileKeys?this._zoom===t._zoom?"none":"zoom":"sourceTiles":"visibleLayers":"revision"}};let oE={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};var oz=class{constructor(t,i){this.needsFollowUpFrame=!1,this.painter=t,this.terrain=i,this.rttSize=i.tileManager.tileSize*i.qualityFactor}getTexture(t){return t.getRTT(this._stacks.length-1).texture}
816prepareForRender(t,i){let r=i!==this._lastPrepareZoom;this._lastPrepareZoom=i,this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=t._order.filter(r=>!t._layers[r].isHidden(i));let a=this._renderableLayerIds.join(),o=new Set;for(let i of this._renderableLayerIds){let r=t._layers[i],a=r.source;a&&oE[r.type]&&o.add(a)}for(let r of(this._coordsAscending={},this._rttFingerprints={},o)){let o=t.tileManagers[r];if(!o)continue;this._coordsAscending[r]={};let s=this._coordsAscending[r],n=o.getSource(),l=n instanceof eF?n.terrainTileRanges:null;for(let t of o.getVisibleCoordinates()){let i=this.terrain.tileManager.getTerrainCoords(t,l);for(let t in i)s[t]||=[],s[t].push(i[t])}this._rttFingerprints[r]={};let h=this._rttFingerprints[r],c=o.getState().revision;for(let t in s)h[t]=new oS(s[t],c,i,a)}this.needsFollowUpFrame=!1;let s=r||this.painter.options.moving,n=!1;for(let t of this._renderableTiles){let i=this._textureDifference(t);"none"!==i&&("zoom"===i&&s||"visibleLayers"===i&&r?this.needsFollowUpFrame=!0:"zoom"===i||"sourceTiles"===i?(n?this.needsFollowUpFrame=!0:t.releaseRTT(this.painter),n=!0):t.releaseRTT(this.painter))}}_textureDifference(t){let i="none";for(let r in this._rttFingerprints){let a=this._rttFingerprints[r][t.tileID.key];if(!a)continue;let o=a.difference(t.rttFingerprint[r]);oC.indexOf(o)>oC.indexOf(i)&&(i=o)}return i}renderLayer(t,i){if(t.isHidden(this.painter.transform.zoom))return!1;let r=t.type,a=this.painter,o=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(oE[r]&&(this._prevType&&oE[this._prevType]||this._stacks.push([]),this._prevType=r,this._stacks[this._stacks.length-1].push(t.id),!o))return!0;if(oE[this._prevType]||oE[r]&&o){this._prevType=r;let t=this._stacks.length-1,o=this._stacks[t]||[];for(let r of(i.isRenderingToTexture=!0,this._renderableTiles)){if(this._rttTiles.push(r),r.getRTT(t))continue;let s=r.acquireRTT(a,t,this.rttSize);for(let t of(a.bindRTT(s),a.context.clear({color:m.fn.transparent,stencil:0}),a.currentStencilSource=void 0,o)){let o=a.style._layers[t],s=o.source?this._coordsAscending[o.source][r.tileID.key]:[r.tileID];a.context.viewport.set([0,0,this.rttSize,this.rttSize]),a.renderTileClippingMasks(o,s),a.renderLayer(a,a.style.tileManagers[o.source],o,s,i),o.source&&(r.rttFingerprint[o.source]=this._rttFingerprints[o.source][r.tileID.key])}s.texture.generateMipmap()}return i.isRenderingToTexture=!1,function(t,i,r,a){let{isRenderingGlobe:o}=a,s=t.context,n=s.gl,l=t.transform,h=t.colorModeForRenderPass(),c=t.getDepthModeFor3D(),u=t.useProgram("terrain");for(let d of(s.bindFramebuffer.set(null),s.viewport.set([0,0,t.width,t.height]),r)){let r=i.getTerrainMesh(d.tileID),_=t.renderToTexture.getTexture(d),p=i.getTerrainData(d.tileID);s.activeTexture.set(n.TEXTURE0),_.bind(n.LINEAR,n.CLAMP_TO_EDGE,n.LINEAR_MIPMAP_LINEAR);let m=iV(i.getSkirtLength(l.zoom),l.calculateFogMatrix(d.tileID.toUnwrapped()),t.style.sky,l.pitch,o),f=ar(a,d.tileID,{applyTerrainMatrix:!1});u.draw(s,n.TRIANGLES,c,at.disabled,h,ai.backCCW,m,p,f,"terrain",r.vertexBuffer,r.indexBuffer,r.segments)}}(this.painter,this.terrain,this._rttTiles,i),this._rttTiles=[],oE[r]}return!1}};let oR={"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":"MapLibre logo","Map.Title":"Map","Marker.Title":"Map marker","NavigationControl.ResetBearing":"Drag to rotate map, click to reset north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","Popup.Close":"Close popup","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","GlobeControl.Enable":"Enable globe","GlobeControl.Disable":"Disable globe","TerrainControl.Enable":"Enable terrain","TerrainControl.Disable":"Disable terrain","CooperativeGesturesHandler.WindowsHelpText":"Use Ctrl + scroll to zoom the map","CooperativeGesturesHandler.MacHelpText":`Use ⌘ + scroll to zoom the map`,"CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},oD={hash:!1,interactive:!0,bearingSnap:7,zoomSnap:0,attributionControl:oT,maplibreLogo:!1,refreshExpiredTiles:!0,canvasContextAttributes:{antialias:!1,preserveDrawingBuffer:!1,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,desynchronized:!1,contextType:void 0},scrollZoom:!0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,trackResize:!0,center:[0,0],elevation:0,zoom:0,bearing:0,pitch:0,roll:0,renderWorldCopies:!0,maxTileC
816acheSize:null,maxTileCacheZoomLevels:m.An.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,transformConstrain:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,rollEnabled:!1,rotateSpeed:.8,pitchSpeed:-.5,reduceMotion:void 0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0,terrainSkirtLength:"auto",zoomLevelsToOverscale:4,anisotropicFilterPitch:20};var oL=class extends m.vn{get _ownerWindow(){return this._container?.ownerDocument?.defaultView||window}constructor(t){super(),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new oI,this._controls=[],this._mapId=(0,m.Mr)(),this._styleUrl=null,this._missingStyleImageResolver=null,this._lostContextStyle={style:null,images:null},this._contextLost=t=>{if(t.preventDefault(),this._frameRequest&&=(this._frameRequest.abort(),null),this.painter.destroy(),this._lostContextStyle=this._getStyleAndImages(),!this.style)return void this.fire(new L("webglcontextlost",{originalEvent:t}));for(let t of Object.values(this.style._layers))if("custom"===t.type&&console.warn(`Custom layer with id '${t.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),t._listeners)for(let[i]of Object.entries(t._listeners))console.warn(`Custom layer with id '${t.id}' had event listeners for event '${i}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this.style.destroy(),this.style=null,this.fire(new L("webglcontextlost",{originalEvent:t}))},this._contextRestored=t=>{if(this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&this.style)for(let t in this.style.imageManager.images=this._lostContextStyle.images,this._lostContextStyle.images){let i=this._lostContextStyle.images[t];i.isWebGLImage&&this.style.imageManager.updateImage(t,i,!1)}this._lostContextStyle={style:null,images:null};try{this._setupPainter()}catch(t){this.fire(new m.gn(t));return}this.resize(),this._update(),this._resizeInternal(),this.fire(new L("webglcontextrestored",{originalEvent:t}))},this._onMapScroll=t=>{if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()};let i={...oD,...t,canvasContextAttributes:{...oD.canvasContextAttributes,...t.canvasContextAttributes}};if(null!=i.minZoom&&null!=i.maxZoom&&i.minZoom>i.maxZoom)throw Error("maxZoom must be greater than or equal to minZoom");if(null!=i.minPitch&&null!=i.maxPitch&&i.minPitch>i.maxPitch)throw Error("maxPitch must be greater than or equal to minPitch");if(null!=i.minPitch&&i.minPitch<0)throw Error("minPitch must be greater than or equal to 0");if(null!=i.maxPitch&&i.maxPitch>180)throw Error("maxPitch must be less than or equal to 180");this._camera=new ow({minZoom:i.minZoom,maxZoom:i.maxZoom,minPitch:i.minPitch,maxPitch:i.maxPitch,bearingSnap:i.bearingSnap,zoomSnap:i.zoomSnap,renderWorldCopies:i.renderWorldCopies,centerClampedToGround:i.centerClampedToGround,terrain:this.terrain,transformConstrain:i.transformConstrain,requestRenderFrame:t=>this._requestRenderFrame(t),cancelRenderFrame:t=>this._cancelRenderFrame(t),transformCameraUpdate:i.transformCameraUpdate,stopHandlers:()=>this._handlers?.stop(!1)}),this._camera.setEventedParent(this),this._interactive=i.interactive,this._maxTileCacheSize=i.maxTileCacheSize,this._maxTileCacheZoomLevels=i.maxTileCacheZoomLevels,this._canvasContextAttributes={...i.canvasContextAttributes},this._trackResize=!0===i.trackResize,this._terrainSkirtLength=i.terrainSkirtLength,this._refreshExpiredTiles=!0===i.refreshExpiredTiles,this._fadeDuration=i.fadeDuration,this._crossSourceCollisions=!0===i.crossSourceCollisions,this._collectResourceTiming=!0===i.collectResourceTiming,this._locale={...oR,...i.locale},this._clickTolerance=i.clickTolerance,this._overridePixelRatio=i.pixelRatio,this._maxCanvasSize=i.maxCanvasSize,this._zoomLevelsToOverscale=i.zoomLevelsToOverscale,this.cancelPendingTileRequestsWhileZooming=!0===i.cancelPendingTileRequestsWhileZooming,this.setAnisotropicFilterPitch(i.anisotropicFilterPitch),void 0!==i.reduceMotion&&(g.prefersReducedMotion=i.reduceMotion),this._requestManager=new b(i.transformRequest),this._container=this._resolveContainer(i.container),i.maxBounds&&this.setMaxBounds(i.maxBounds),this._setupContainer();try{this._setupPainter()}catch(t){throw this._cleanupContainer(),t}this._imageQueueHandle=n.addThrottleControl(()=>this.isMoving()),this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this.on("terrain",()=>{this.painter.markTerrainDepthDirty(),this._update(!0)}),this.once("idle",()=>this._idleTriggered=!0),this._handlers=new ob(this,this._camera,i),"u">typeof window&&(this._ownerWindow.addEventListener("online",this._onWindowOnline,!1),this._setupResizeObserver());let r="string"==typeof i.hash&&i.hash||void 0;this._hash=i.hash?new aO(r).addTo(this):void 0,this._hash?._onHashChange()||(this.jumpTo({center:i.center,elevation:i.elevation,zoom:i.zoom,bearing:i.bearing,pitch:i.pitch,roll:i.roll}),i.bounds&&(this.resize(),this.fitBounds(i.bounds,(0,m.er)({},i.fitBoundsOptions,{duration:0}))));let a="string"==typeof i.style||i.style?.projection?.type!=="globe";this.resize(null,a),this._localIdeographFontFamily=i.localIdeographFontFamily,this._val
vendor: 4,113 bytes, line 816
816idateStyle=i.validateStyle,i.style&&this.setStyle(i.style,{localIdeographFontFamily:i.localIdeographFontFamily}),i.attributionControl&&this.addControl(new oP("boolean"==typeof i.attributionControl?void 0:i.attributionControl)),i.maplibreLogo&&this.addControl(new oM,i.logoPosition),this.on("style.load",()=>{if(a||this._resizeTransform(),this._camera.transform.unmodified){let t=(0,m.yr)(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(t)}}),this.on("data",t=>{this._update("style"===t.dataType),this.fire("style"===t.dataType?new M("styledata",t):new I("sourcedata",t))}),this.on("dataloading",t=>{this.fire("style"===t.dataType?new M("styledataloading",t):new I("sourcedataloading",t))}),this.on("dataabort",t=>{this.fire(new I("sourcedataabort",t))})}_getMapId(){return this._mapId}setGlobalStateProperty(t,i){return this.style.setGlobalStateProperty(t,i),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(t,i){if(void 0===i&&(i=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t?.onAdd)return this.fire(new m.gn(Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let r=t.onAdd(this);this._controls.push(t);let a=this._controlPositions[i];return i.includes("bottom")?a.insertBefore(r,a.firstChild):a.appendChild(r),this}removeControl(t){if(!t?.onRemove)return this.fire(new m.gn(Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));let i=this._controls.indexOf(t);return i>-1&&this._controls.splice(i,1),t.onRemove(this),this}hasControl(t){return this._controls.includes(t)}coveringTiles(t){return eQ(this._camera.transform,t)}setTransformCameraUpdate(t){this._camera.transformCameraUpdate=t}getCenter(){return new m.lt(this._camera.transform.center.lng,this._camera.transform.center.lat)}setCenter(t,i){return this._camera.setCenter(t,i),this}getCenterElevation(){return this._camera.transform.elevation}setCenterElevation(t,i){return this._camera.setCenterElevation(t,i),this}setCenterClampedToGround(t){this._camera.setCenterClampedToGround(t)}panBy(t,i,r){return this._camera.panBy(t,i,r),this}panTo(t,i,r){return this._camera.panTo(t,i,r),this}getZoom(){return this._camera.transform.zoom}setZoom(t,i){return this._camera.setZoom(t,i),this}zoomTo(t,i,r){return this._camera.zoomTo(t,i,r),this}zoomIn(t,i){return this._camera.zoomIn(t,i),this}zoomOut(t,i){return this._camera.zoomOut(t,i),this}getVerticalFieldOfView(){return this._camera.transform.fov}setVerticalFieldOfView(t,i){return this._camera.setVerticalFieldOfView(t,i),this}getBearing(){return this._camera.transform.bearing}setBearing(t,i){return this._camera.setBearing(t,i),this}getZoomSnap(){return this._camera.getZoomSnap()}setZoomSnap(t){return this._camera.setZoomSnap(t),this}getPadding(){return this._camera.transform.padding}setPadding(t,i){return this._camera.setPadding(t,i),this}rotateTo(t,i,r){return this._camera.rotateTo(t,i,r),this}resetNorth(t,i){return this._camera.resetNorth(t,i),this}resetNorthPitch(t,i){return this._camera.resetNorthPitch(t,i),this}snapToNorth(t,i){return this._camera.snapToNorth(t,i),this}getPitch(){return this._camera.transform.pitch}setPitch(t,i){return this._camera.setPitch(t,i),this}getRoll(){return this._camera.transform.roll}setRoll(t,i){return this._camera.setRoll(t,i),this}cameraForBounds(t,i){return this._camera.cameraForBounds(t,i)}fitBounds(t,i,r){return this._camera.fitBounds(t,i,r),this}fitScreenCoordinates(t,i,r,a,o){return this._camera.fitScreenCoordinates(t,i,r,a,o),this}jumpTo(t,i){return this._camera.jumpTo(t,i),this}calculateCameraOptionsFromCameraLngLatAltRotation(t,i,r,a,o){return this._camera.calculateCameraOptionsFromCameraLngLatAltRotation(t,i,r,a,o)}easeTo(t,i){return this._camera.easeTo(t,i),this}flyTo(t,i){return this._camera.flyTo(t,i),this}stop(){return this._camera.stop(),this}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLat(m.lt.convert(t),this._camera.transform):null}getCenterClampedToGround(){return this._camera.getCenterClampedToGroun
816d()}calculateCameraOptionsFromTo(t,i,r,a){return null==a&&this.terrain&&(a=this.terrain.getElevationForLngLat(r,this._camera.transform)),this._camera.transform.calculateCameraOptionsFromTo(t,i,r,a??0)}resize(t,i=!0){if(null!==this._lostContextStyle.style)return this;this._resizeInternal(i);let r=!this._camera._moving;return r&&(this.stop(),this.fire(new T("movestart",t)).fire(new T("move",t))),this.fire(new w("resize",t)),r&&this.fire(new T("moveend",t)),this}_resizeInternal(t=!0){let[i,r]=this._containerDimensions(),a=this._getClampedPixelRatio(i,r);if(this._resizeCanvas(i,r,a),this.painter.resize(i,r,a),this.painter.overLimit()){let t=this.painter.context.gl;this._maxCanvasSize=[t.drawingBufferWidth,t.drawingBufferHeight];let a=this._getClampedPixelRatio(i,r);this._resizeCanvas(i,r,a),this.painter.resize(i,r,a)}this._resizeTransform(t)}_resizeTransform(t=!0){let[i,r]=this._containerDimensions();this._camera.transform.resize(i,r,t),this._camera._requestedCameraState?.resize(i,r,t)}_getClampedPixelRatio(t,i){let{0:r,1:a}=this._maxCanvasSize,o=this.getPixelRatio(),s=t*o,n=i*o,l=Math.min(s>r?r/s:1,n>a?a/n:1);return l<1&&(0,m.Nr)("The canvas is larger than maxCanvasSize and is rendered at a lower pixel ratio to fit. Increase maxCanvasSize, within MAX_TEXTURE_SIZE, to render at full resolution."),l*o}getPixelRatio(){return this._overridePixelRatio??devicePixelRatio}setPixelRatio(t){this._overridePixelRatio=t,this.resize()}getBounds(){return this._camera.transform.getBounds()}getMaxBounds(){return this._camera.transform.getMaxBounds()}setMaxBounds(t){return this._camera.transform.setMaxBounds(ey.convert(t)),this._update()}setMinZoom(t){if((t??=-2)>=-2&&t<=this._camera.transform.maxZoom){let i=this._camera.transform.zoom,r=this._camera.getTransformForUpdate();return r.setMinZoom(t),this._camera.applyUpdatedTransform(r),this._update(),i!==this._camera.transform.zoom&&this.fire(new T("zoomstart")).fire(new T("zoom")).fire(new T("zoomend")).fire(new T("movestart")).fire(new T("move")).fire(new T("moveend")),this}throw Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(t=!1){let i=this._camera.transform;return t?i.applyConstrain(i.center,i.minZoom).zoom:i.minZoom}setMaxZoom(t){if((t??=22)>=this._camera.transform.minZoom){let i=this._camera.transform.zoom,r=this._camera.getTransformForUpdate();return r.setMaxZoom(t),this._camera.applyUpdatedTransform(r),this._update(),i!==this._camera.transform.zoom&&this.fire(new T("zoomstart")).fire(new T("zoom")).fire(new T("zoomend")).fire(new T("movestart")).fire(new T("move")).fire(new T("moveend")),this}throw Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this._camera.transform.maxZoom}setMinPitch(t){if((t??=0)<0)throw Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this._camera.transform.maxPitch){let i=this._camera.transform.pitch,r=this._camera.getTransformForUpdate();return r.setMinPitch(t),this._camera.applyUpdatedTransform(r),this._update(),i!==this._camera.transform.pitch&&this.fire(new T("pitchstart")).fire(new T("pitch")).fire(new T("pitchend")).fire(new T("movestart")).fire(new T("move")).fire(new T("moveend")),this}throw Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this._camera.transform.minPitch}setMaxPitch(t){if((t??=60)>180)throw Error("maxPitch must be less than or equal to 180");if(t>=this._camera.transform.minPitch){let i=this._camera.transform.pitch,r=this._camera.getTransformForUpdate();return r.setMaxPitch(t),this._camera.applyUpdatedTransform(r),this._update(),i!==this._camera.transform.pitch&&this.fire(new T("pitchstart")).fire(new T("pitch")).fire(new T("pitchend")).fire(new T("movestart")).fire(new T("move")).fire(new T("moveend")),this}throw Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this._camera.transform.maxPitch}getAnisotropicFilterPitch(){return this._anisotropicFilterPitch}setAnisotropicFilterPitch(t){if((t??=20)>180)throw Error("anisotropicFilterPitch must be less than or equal to 180");if(t<0)throw Error("anisotropicFilterPitch must be greater than or equal to 0");return this._anisotropicFilterPitch=t,this._update()}getRenderWorldCopies(){return this._camera.transform.renderWorldCopies}setRenderWorldCopies(t){return this._camera.transform.setRenderWorldCopies(t),this._update()}setTransformConstrain(t){return this._camera.transform.setConstrainOverride(t),this._update()}project(t){return this._camera.transform.locationToScreenPoint(m.lt.convert(t),this.style&&this.terrain)}unproject(t){return this._camera.transform.screenPointToLocation(m.Li.convert(t),this.terrain)}isMoving(){return this._camera.isMoving()||this._handlers?.isMoving()||!1}isZooming(){return this._camera.isZooming()||this._handlers?.isZooming()||!1}isRotating(){return this._camera.isRotating()||this._handlers?.isRotating()||!1}
816_createDelegatedListener(t,i,r){if("mouseenter"===t||"mouseover"===t){let a=!1;return{layers:i,listener:r,delegates:{mousemove:o=>{let s=i.filter(t=>this.getLayer(t)),n=0===s.length?[]:this.queryRenderedFeatures(o.point,{layers:s});n.length?a||(a=!0,r.call(this,new C(t,this,o.originalEvent,{features:n}))):a=!1},mouseout:()=>{a=!1}}}}if("mouseleave"===t||"mouseout"===t){let a=!1;return{layers:i,listener:r,delegates:{mousemove:o=>{let s=i.filter(t=>this.getLayer(t));(0===s.length?[]:this.queryRenderedFeatures(o.point,{layers:s})).length?a=!0:a&&(a=!1,r.call(this,new C(t,this,o.originalEvent)))},mouseout:i=>{a&&(a=!1,r.call(this,new C(t,this,i.originalEvent)))}}}}{let a=t=>{let a=i.filter(t=>this.getLayer(t)),o=0===a.length?[]:this.queryRenderedFeatures(t.point,{layers:a});o.length&&(t.features=o,r.call(this,t),delete t.features)};return{layers:i,listener:r,delegates:{[t]:a}}}}_saveDelegatedListener(t,i){this._delegatedListeners||={},this._delegatedListeners[t]||=[],this._delegatedListeners[t].push(i)}_removeDelegatedListener(t,i,r){if(!this._delegatedListeners?.[t])return;let a=this._delegatedListeners[t];for(let t=0;t<a.length;t++){let o=a[t];if(o.listener===r&&o.layers.length===i.length&&o.layers.every(t=>i.includes(t))){for(let t in o.delegates)this.off(t,o.delegates[t]);a.splice(t,1);return}}}on(t,i,r){if(void 0===r)return super.on(t,i);let a="string"==typeof i?[i]:i,o=this._createDelegatedListener(t,a,r);for(let i in this._saveDelegatedListener(t,o),o.delegates)this.on(i,o.delegates[i]);return{unsubscribe:()=>{this._removeDelegatedListener(t,a,r)}}}once(t,i,r){if(void 0===r)return super.once(t,i);let a="string"==typeof i?[i]:i,o=this._createDelegatedListener(t,a,r);for(let i in o.delegates){let s=o.delegates[i];o.delegates[i]=(...i)=>{this._removeDelegatedListener(t,a,r),s(...i)}}for(let i in this._saveDelegatedListener(t,o),o.delegates)this.once(i,o.delegates[i]);return this}off(t,i,r){if(void 0===r)return super.off(t,i);let a="string"==typeof i?[i]:i;return this._removeDelegatedListener(t,a,r),this}queryRenderedFeatures(t,i){if(!this.style)return[];let r,a=t instanceof m.Li||Array.isArray(t),o=a?t:[[0,0],[this._camera.transform.width,this._camera.transform.height]];if(i||=(a?{}:t)||{},o instanceof m.Li||"number"==typeof o[0])r=[m.Li.convert(o)];else{let t=m.Li.convert(o[0]),i=m.Li.convert(o[1]);r=[t,new m.Li(i.x,t.y),i,new m.Li(t.x,i.y),t]}return this.style.queryRenderedFeatures(r,i,this._camera.transform)}querySourceFeatures(t,i){return this.style.querySourceFeatures(t,i)}setStyle(t,i){return i=(0,m.er)({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._val
816idateStyle},i),this._styleUrl="string"==typeof t?t:null,!1!==i.diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&t?(this._diffStyle(t,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(t,i))}setTransformRequest(t){return this._requestManager.setTransformRequest(t),this}_getUIString(t){let i=this._locale[t];if(null==i)throw Error(`Missing UI string '${t}'`);return i}_updateStyle(t,i){if(this._diffStyleRequest?.abort(),this._diffStyleRequest=null,i.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(t,i));let r=this.style&&i.transformStyle?this.style.serialize():void 0;return(this.style&&(this.style.setEventedParent(null),this.style._remove(!t)),t)?(this.style=new iZ(this,i||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof t?this.style.loadURL(t,i,r):this.style.loadJSON(t,i,r)):(this._frameRequest&&=(this._frameRequest.abort(),null),this.style?.projection?.destroy(),delete this.style),this}_lazyInitEmptyStyle(){this.style||(this.style=new iZ(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}async _diffStyle(t,i){if(this._diffStyleRequest?.abort(),"string"==typeof t){this._diffStyleRequest=new AbortController;let r=this._diffStyleRequest;try{let a=await this._requestManager.transformRequest(t,"Style");if(r.signal.aborted){this._diffStyleRequest=null;return}let o=await (0,m.Sn)(a,r);this._diffStyleRequest=null,this._updateDiff(o.data,i)}catch(t){this._diffStyleRequest=null,(0,m.Mn)(t)||this.fire(new m.gn((0,m.Qn)(t)))}}else"object"==typeof t&&(this._diffStyleRequest=null,this._updateDiff(t,i))}_updateDiff(t,i){try{this.style.setState(t,i)&&this._update(!0)}catch(r){(0,m.Nr)(`Unable to perform style diff: ${(0,m.Qn)(r).message}.  Rebuilding the style from scratch.`),this._updateStyle(t,i)}}getStyle(){if(this.style)return this.style.serialize()}getStyleUrl(){return this._styleUrl}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){return this.style?this.style.loaded():void(0,m.Nr)("There is no style added to the map.")}addSource(t,i){return this._lazyInitEmptyStyle(),this.style.addSource(t,i),this._update(!0)}isSourceLoaded(t){let i=this.style?.tileManagers[t];return void 0===i?void this.fire(new m.gn(Error(`There is no tile manager with ID '${t}'`))):i.loaded()}setTerrain(t,i={}){if(this.style._checkLoaded(),t&&(0,m.an)(this,m.on.terrain,{value:t},i))return this;if(this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),t){let i=this.style.tileManagers[t.source];if(!i)throw Error(`cannot load terrain, because there exists no source with ID: ${t.source}`);for(let r in null===this.terrain&&i.reload(),this.style._layers){let i=this.style._layers[r];"hillshade"===i.type&&i.source===t.source&&(0,m.Nr)("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),"color-relief"===i.type&&i.source===t.source&&(0,m.Nr)("You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain&&this.terrain.destroy(),this.terrain=new t5(this.painter,i,t,this._terrainSkirtLength),this.painter.renderToTexture=new oz(this.painter,this.terrain),this._camera.terrain=this.terrain,this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),this._camera.transform.setElevation(this.terrain.getElevationForLngLat(this._camera.transform.center,this._camera.transform)),this._terrainDataCallback=i=>this._handleTerrainDataEvent(i,t.source),this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.destroy(),this.terrain=null,this.painter.renderToTexture=null,this.painter.destroyRTTResources(),this._camera.terrain=null,this._camera.transform.setMinElevationForCurrentTile(0),this.getCenterClampedToGroun
816d()&&this._camera.transform.setElevation(0);return this.style.triggerSymbolPlacement(),this.fire(new R({terrain:t})),this}_handleTerrainDataEvent(t,i){if("style"===t.dataType)return void this.terrain.tileManager.releaseAllRTT();let r=t.sourceId===i;if(r&&(this.terrain.resetElevationCache(),this.style.triggerSymbolPlacement()),r&&t.tile&&this.painter.markTerrainDepthDirty(),r&&t.tile&&!this._camera.elevationFreeze&&(this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),this.getCenterClampedToGround()&&this._camera.transform.setElevation(this.terrain.getElevationForLngLat(this._camera.transform.center,this._camera.transform))),t.tile){if(t.source?.type==="image")return void this.terrain.tileManager.releaseAllRTT();this.terrain.tileManager.releaseRTT(t.tile.tileID)}}getTerrain(){return this.terrain?.options??null}areTilesLoaded(){for(let t of Object.values(this.style?.tileManagers))if(!t.areTilesLoaded())return!1;return!0}removeSource(t){return this.style.removeSource(t),this._update(!0)}getSource(t){return this.style?.getSource(t)}setSourceTileLodParams(t,i,r){if(r){let a=this.getSource(r);if(!a)throw Error(`There is no source with ID "${r}", cannot set LOD parameters`);a.calculateTileZoom=eY(Math.max(1,t),Math.max(1,i))}else for(let r in this.style.tileManagers)this.style.tileManagers[r].getSource().calculateTileZoom=eY(Math.max(1,t),Math.max(1,i));return this._update(!0),this}refreshTiles(t,i){let r=this.style.tileManagers[t];if(!r)throw Error(`There is no tile manager with ID "${t}", cannot refresh tile`);void 0===i?r.reload(!0):r.refreshTiles(i.map(t=>new m.u(t.z,t.x,t.y)))}addImage(t,i,r={}){this._lazyInitEmptyStyle();let a=this._createStyleImage(i,r);return a&&(this.style.addImage(t,a),a.userImage?.onAdd&&a.userImage.onAdd(this,t)),this}setMissingStyleImageResolver(t){return this._missingStyleImageResolver=t,this.style?.setMissingImageResolver(t),this}_createStyleImage(t,i={}){let{pixelRatio:r=1,sdf:a=!1,stretchX:o,stretchY:s,content:n,textFitWidth:l,textFitHeight:h}=i;if(t instanceof HTMLImageElement||(0,m.cr)(t)){let{width:i,height:c,data:u}=g.getImageData(t);return{data:new m.Dt({width:i,height:c},u),pixelRatio:r,stretchX:o,stretchY:s,content:n,textFitWidth:l,textFitHeight:h,sdf:a,version:0}}if(void 0===t.width||void 0===t.height)return this.fire(new m.gn(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`"))),null;{let{width:i,height:c,data:u}=t,d=(0,m.I)(t.data);return{data:d?new m.Dt({width:i,height:c}):new m.Dt({width:i,height:c},new Uint8Array(u)),pixelRatio:r,stretchX:o,stretchY:s,content:n,textFitWidth:l,textFitHeight:h,sdf:a,version:0,isWebGLImage:d,userImage:t}}}updateImage(t,i){let r=this.style.getImage(t);if(!r)return this.fire(new m.gn(Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let{width:a,height:o,data:s}=i instanceof HTMLImageElement||(0,m.cr)(i)?g.getImageData(i):i;if(void 0===a||void 0===o)return this.fire(new m.gn(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(a!==r.data.width||o!==r.data.height)return this.fire(new m.gn(Error("The width and height of the updated image must be that same as the previous version of the image")));if(r.isWebGLImage=(0,m.I)(s),r.isWebGLImage)r.userImage=i;else{let t=!(i instanceof HTMLImageElement||(0,m.cr)(i));r.data.replace(s,t)}return this.style.updateImage(t,r),this}getImage(t){return this.style.getImage(t)}hasImage(t){return t?!!this.style.getImage(t):(this.fire(new m.gn(Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t)}async loadImage(t){let i=await n.getImage(await this._requestManager.transformRequest(t,"Image"),new AbortController);if(!i.data)throw Error(`Could not load image ${t}: the response is empty`);return i}listImages(){return this.style?.listImages()??[]}
vendor: 12,922 bytes, line 816
816addLayer(t,i){return this._lazyInitEmptyStyle(),this.style.addLayer(t,i),this._update(!0)}moveLayer(t,i){return this.style.moveLayer(t,i),this._update(!0)}removeLayer(t){return this.style.removeLayer(t),this._update(!0)}getLayer(t){return this.style?.getLayer(t)}getLayersOrder(){return this.style?.getLayersOrder()??[]}setLayerZoomRange(t,i,r){return this.style.setLayerZoomRange(t,i,r),this._update(!0)}setFilter(t,i,r={}){return this.style?.setFilter(t,i,r),this._update(!0)}getFilter(t){return this.style.getFilter(t)}setPaintProperty(t,i,r,a={}){return this.style?.setPaintProperty(t,i,r,a),this._update(!0)}getPaintProperty(t,i){return this.style.getPaintProperty(t,i)}setLayoutProperty(t,i,r,a={}){return this.style.setLayoutProperty(t,i,r,a),this._update(!0)}getLayoutProperty(t,i){return this.style.getLayoutProperty(t,i)}setGlyphs(t,i={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(t,i),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}setFontFaces(t){return this._lazyInitEmptyStyle(),this.style.setFontFaces(t),this._update(!0)}getFontFaces(){return this.style.getFontFaces()}addSprite(t,i,r={}){return this._lazyInitEmptyStyle(),this.style.addSprite(t,i,r,t=>{t||this._update(!0)}),this}removeSprite(t){return this._lazyInitEmptyStyle(),this.style.removeSprite(t),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(t,i={}){return this._lazyInitEmptyStyle(),this.style.setSprite(t,i,t=>{t||this._update(!0)}),this}setLight(t,i={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,i),this._update(!0)}getLight(){return this.style.getLight()}setSky(t,i={}){return this._lazyInitEmptyStyle(),this.style.setSky(t,i),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(t,i){return this.style.setFeatureState(t,i),this._update()}removeFeatureState(t,i){return this.style.removeFeatureState(t,i),this._update()}getFeatureState(t){return this.style.getFeatureState(t)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let t=0,i=0;return this._container&&(t=this._container.clientWidth||400,i=this._container.clientHeight||300),[t,i]}_shouldHandleInitialResize(){if(!this._container?.clientWidth||!this._container.clientHeight)return!1;let[t,i]=this._containerDimensions();return t!==this._camera.transform.width||i!==this._camera.transform.height}_setupResizeObserver(){let t=!1,i=aB(t=>{this._trackResize&&!this._removed&&(this.resize(t),this.redraw())},50),r=this._ownerWindow.ResizeObserver??ResizeObserver;this._resizeObserver=new r(r=>{(t||(t=!0,this._shouldHandleInitialResize()))&&i(r)}),this._resizeObserver.observe(this._container)}_resolveContainer(t){if("string"==typeof t){let i=document.getElementById(t);if(!i)throw Error(`Container '${t}' not found.`);return i}if(t instanceof HTMLElement||t&&"object"==typeof t&&1===t.nodeType)return t;throw Error("Invalid type: 'container' must be a String or HTMLElement.")}_setupContainer(){let t=this._containerDimensions(),i=this._getClampedPixelRatio(t[0],t[1]),r=this._container;r.classList.add("maplibregl-map");let a=this._canvasContainer=x.create("div","maplibregl-canvas-container",r);this._interactive&&a.classList.add("maplibregl-interactive"),this._canvas=x.create("canvas","maplibregl-canvas",a),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._resizeCanvas(t[0],t[1],i);let o=this._controlContainer=x.create("div","maplibregl-control-container",r),s=this._controlPositions={};for(let t of["top-left","top-right","bottom-left","bottom-right"])s[t]=x.create("div",`maplibregl-ctrl-${t} `,o);this._container.addEventListener("scroll",this._onMapScroll,!1)}_cleanupContainer(){this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map")}_resizeCanvas(t,i,r){this._canvas.width=Math.floor(r*t),this._canvas.height=Math.floor(r*i),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${i}px`}_setupPainter(){let t={...this._canvasContextAttributes,alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0},i=null;this._canvas.addEventListener("webglcontextcreationerror",t=>{i=t},{once:!0});let r=this._canvas.getContext("webgl2",t);if(!r)throw new ak(t,i);this.painter=new aF(r,this._camera.transform)}migrateProjection(t,i){this._camera.migrateProjection(t,i),this.painter.transform=t,this.fire(new D({newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(t){return this.style?._loaded&&(this._styleDirty||=t,this._sourcesDirty=!0,this.triggerRepaint()),this}_requestRenderFrame(t){return this._update(),this._renderTaskQueue.add(t)}_cancelRenderFrame(t){this._renderTaskQueue.remove(t)}_render(t){let i=this._idleTriggered?this._fadeDuration:0,r=this.style.projection?.transitionState>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(t),this._removed)return;let a=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let t=this._camera.transform.zoom,r=y();this.style.zoomHistory.update(t,r);let o=new m.en(t,{now:r,fadeDuration:i,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),s=o.crossFadingFactor();(1!==s||s!==this._crossFadingFactor)&&(a=!0,this._crossFadingFactor=s),this.style.update(o)}let o=this.style.projection?.transitionState>0!==r;this._camera.transform.setTransitionState(this.style.projection?.transitionState),this.style&&(this._sourcesDirty||o)&&(this._sourcesDirty=!1,this.style._updateSources(this._camera.transform)),this.terrain?(this.terrain.tileManager.update(this._camera.transform,this.terrain)&&this.terrain.resetElevationCache(),this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),!this._camera.elevationFreeze&&this.getCenterClampedToGround()&&this._camera.transform.setElevation(this.terrain.getElevationForLngLat(this._camera.transform.center,this._camera.transform))):(this._camera.transform.setMinElevationForCurrentTile(0),this.getCenterClampedToGround()&&this._camera.transform.setElevation(0)),this._placementDirty=this.style?._updatePlacement(this._camera.transform,this.showCollisionBoxes,i,this._crossSourceCollisions,o),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:i,showPadding:this.showPadding,anisotropicFilterPitch:this.getAnisotropicFilterPitch()}),this.fire(new w("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new w("load"))),this.style&&(this.style.hasTransitions()||a)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let s=this._sourcesDirty||this._styleDirty||this._placementDirty||this.painter.renderToTexture?.needsFollowUpFrame;return s||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new w("idle")),!this._loaded||this._fullyLoaded||s||(this._fullyLoaded=!0),this}redraw(){return this.style&&(this._frameRequest&&=(this._frameRequest.abort(),null),this._render(0)),this}remove(){for(let t of(this._hash&&this._hash.remove(),this._controls))t.onRemove(this);this._controls=[],this._frameRequest&&=(this._frameRequest.abort(),null),this._renderTaskQueue.clear(),this._diffStyleRequest?.abort(),this.painter.destroy(),this._handlers.destroy(),this.setStyle(null),"u">typeof window&&this._ownerWindow.removeEventListener("online",this._onWindowOnline,!1),n.removeThrottleControl(this._imageQueueHandle),this._resizeObserver?.disconnect();let t=this.painter.context.gl.getExtension("WEBGL_lose_context");t?.loseContext&&t.loseContext(),this._cleanupContainer(),this._removed=!0,this.fire(new w("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,g.frame(this._frameRequest,t=>{this._frameRequest=null;try{this._render(t)}catch(t){if(!(0,m.Mn)(t))throw t}},()=>{},this._ownerWindow))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update())}get showPadding(){return!!this._showPadding}set showPadding(t){this._showPadding!==t&&(this._showPadding=t,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,t?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update())}get repaint(){return!!this._repaint}set repaint(t){this._repaint!==t&&(this._repaint=t,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(t){this._vertices=t,this._update()}get version(){return"6.10.0"}getCameraTargetElevation(){return this._camera.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(t){return this._lazyInitEmptyStyle(),this.style.setProjection(t),this._update(!0)}};let oA={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};var oF=class{constructor(t){this._updateZoomButtons=()=>{let t=this._map.getZoom(),i=t===this._map.getMaxZoom(),r=t===this._map.getMinZoom(!0);this._zoomInButton.disabled=i,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",r.toString())},this._rotateCompassArrow=()=>{let t=this._map.getPitch(),i=this._map.getRoll(),r=this._map.getBearing(),a=1/Math.cos((0,m.Yn)(t))**.5;if(this.options.visualizePitch&&this.options.visualizeRoll){this._compassIcon.style.transform=`scale(${a}) rotateZ(${-i}deg) rotateX(${t}deg) rotateZ(${-r}deg)`;return}if(this.options.visualizePitch){this._compassIcon.style.transform=`scale(${a}) rotateX(${t}deg) rotateZ(${-r}deg)`;return}if(this.options.visualizeRoll){this._compassIcon.style.transform=`rotate(${-r-i}deg)`;return}this._compassIcon.style.transform=`rotate(${-r}deg)`},this._setButtonTitle=(t,i)=>{let r=this._map._getUIString(`NavigationControl.${i}`);t.title=r,t.setAttribute("aria-label",r)},this.options=(0,m.er)({},oA,t),this._container=x.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",t=>t.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",t=>this._map.zoomIn({},{originalEvent:t})),x.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",t=>this._map.zoomOut({},{originalEvent:t})),x.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})}),this._compassIcon=x.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(t){return this._map=t,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("move",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new ok(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off("move",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(t,i){let r=x.create("button",t,this._container);return r.type="button",r.addEventListener("click",i),r}},ok=class{constructor(t,i,r=!1){this.mousedown=t=>
816{this.startMove(t,x.mousePos(this.element,t)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)},this.mousemove=t=>{this.move(t,x.mousePos(this.element,t))},this.mouseup=t=>{this._rotatePitchHandler.dragEnd(t),this.offTemp()},this.touchstart=t=>{1===t.targetTouches.length?(this._startPos=this._lastPos=x.touchPos(this.element,t.targetTouches)[0],this.startMove(t,this._startPos),window.addEventListener("touchmove",this.touchmove,{passive:!1}),window.addEventListener("touchend",this.touchend)):this.reset()},this.touchmove=t=>{1===t.targetTouches.length?(this._lastPos=x.touchPos(this.element,t.targetTouches)[0],this.move(t,this._lastPos)):this.reset()},this.touchend=t=>{0===t.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp()},this.reset=()=>{this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=i;let a=new a5;this._rotatePitchHandler=new a1({clickTolerance:3,move:(t,a)=>{let o=i.getBoundingClientRect(),s=new m.Li((o.bottom-o.top)/2,(o.right-o.left)/2);return{bearingDelta:(0,m.ir)(new m.Li(t.x,a.y),a,s),pitchDelta:r?-((a.y-t.y)*.5):void 0}},moveStateManager:a,enable:!0,assignEvents:()=>{}}),this.map=t,i.addEventListener("mousedown",this.mousedown),i.addEventListener("touchstart",this.touchstart,{passive:!1}),i.addEventListener("touchcancel",this.reset)}startMove(t,i){this._rotatePitchHandler.dragStart(t,i),x.disableDrag()}move(t,i){let r=this.map,{bearingDelta:a,pitchDelta:o}=this._rotatePitchHandler.dragMove(t,i)||{};a&&r.setBearing(r.getBearing()+a),o&&r.setPitch(r.getPitch()+o)}off(){let t=this.element;t.removeEventListener("mousedown",this.mousedown),t.removeEventListener("touchstart",this.touchstart),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend),t.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){x.enableDrag(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend)}};let oB={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%)"},oO={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]},oj="#3FB1CE";function oN(t,i,r=[]){let a=x.createNS("http://www.w3.org/2000/svg",t);for(let t in i)a.setAttributeNS(null,t,i[t]);for(let t of r)a.appendChild(t);return a}var oZ=class extends m._n{},oU=class extends m._n{},oG=class extends m.vn{constructor(t){if(super(),this._onClick=t=>{this.fire(new oU("click",{originalEvent:t}))},this._onKeyPress=t=>{("Space"===t.code||"Enter"===t.code)&&this.togglePopup()},this._onKeyDown=t=>{if(!this._defaultMarker||!this._draggable||!this._map||!this._lngLat||t.composedPath()[0]!==this._element||t.altKey||t.ctrlKey||t.metaKey)return;let i=oO[t.key];if(!i)return;t.preventDefault(),t.stopPropagation();let r=t.shiftKey?10:1,a=this._map.project(this._lngLat);this.setLngLat(this._map.unproject(new m.Li(a.x+i[0]*r,a.y+i[1]*r))),this._keyboardDragActive||(this._keyboardDragActive=!0,this.fire(new oZ("dragstart"))),this.fire(new oZ("drag"))},this._onKeyUp=t=>{oO[t.key]&&this._endKeyboardDrag()},this._onBlur=()=>{this._endKeyboardDrag()},this._onMapClick=t=>{let i=t.originalEvent.target,r=this._element;this._popup&&(i===r||r.contains(i))&&this.togglePopup()},this._updateCoveredUnthrottled=()=>{let t=this._map?.terrain;if(!t||!this._isInViewport())return;let i=this._isCovered(t);i&&this._popup?.isOpen()&&this._popup.remove(),this._element.style.opacity=i?this._opacityWhenCovered:this._opacity,this._element.classList.toggle("maplibregl-marker-covered",i)}
816,this._updateCovered=aB(this._updateCoveredUnthrottled,100),this._update=t=>{if(!this._map)return;let i=this._map.loaded()&&!this._map.isMoving();t?.type!=="terrain"&&(t?.type!=="render"||i)||this._map.once("render",this._update),this._lngLat=function(t,i,r,a=!1){if(a||!r.getCoveringTilesDetailsProvider().allowWorldCopies())return t?.wrap();let o=new m.lt(t.lng,t.lat);if(t=new m.lt(t.lng,t.lat),i){let a=new m.lt(t.lng-360,t.lat),o=new m.lt(t.lng+360,t.lat),s=r.locationToScreenPoint(t).distSqr(i);r.locationToScreenPoint(a).distSqr(i)<s?t=a:r.locationToScreenPoint(o).distSqr(i)<s&&(t=o)}for(;Math.abs(t.lng-r.center.lng)>180;){let i=r.locationToScreenPoint(t);if(i.x>=0&&i.y>=0&&i.x<=r.width&&i.y<=r.height)break;t.lng>r.center.lng?t.lng-=360:t.lng+=360}return t.lng!==o.lng&&r.isPointOnMapSurface(r.locationToScreenPoint(t))?t:o}(this._lngLat,this._flatPos,this._map._camera.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map._camera.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let r="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?r=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(r=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let a="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?a="rotateX(0deg)":"map"===this._pitchAlignment&&(a=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||t&&"moveend"!==t.type||(this._pos=this._pos.round()),this._element.style.transform=`${oB[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${a} ${r}`,g.frameAsync(new AbortController,this._map._ownerWindow).then(()=>{this._updateOpacity()}).catch(()=>{})},this._onMove=t=>{if(!this._isDragging){let i=this._clickTolerance||this._map._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=i}this._isDragging&&(this._pos=t.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new oZ("dragstart"))),this.fire(new oZ("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new oZ("dragend")),this._state="inactive"},this._addDragHandler=t=>{this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos).add(this._offset),this._pointerdownPos=t.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=t?.anchor||"center",this._color=t?.color||oj,this._scale=t?.scale||1,this._draggable=t?.draggable||!1,this._clickTolerance=t?.clickTolerance||0,this._subpixelPositioning=t?.subpixelPositioning||!1,this._isDragging=!1,this._roleManaged=!1,this._tabIndexManaged=!1,this._keyboardDragActive=!1,this._state="inactive",this._rotation=t?.rotation||0,this._rotationAlignment=t?.rotationAlignment||"auto",this._pitchAlignment=t?.pitchAlignment&&"auto"!==t.pitchAlignment?t.pitchAlignment:this._rotationAlignment,this.setOpacity(t?.opacity,t?.opacityWhenCovered),t?.element)this._element=t.element,this._offset=m.Li.convert(t?.offset||[0,0]);else{this._defaultMarker=!0,this._element=x.create("div");let i=(p||(p=oN("svg",{display:"block",height:"41px",width:"27px",viewBox:"0 0 27 41"},[oN("g",{"fill-rule":"nonzero"},[oN("g",{transform:"translate(3.0, 29.0)",fill:"#000000"},[["10.5","5.25002273"],["10.5","5.25002273"],["9.5","4.77275007"],["8.5","4.29549936"],["7.5","3.81822308"],["6.5","3.34094679"],["5.5","2.86367051"],["4.5","2.38636864"]].map(([t,i])=>oN("ellipse",{opacity:"0.04",cx:"10.5",cy:"5.80029008",rx:t,ry:i}))),oN("g",{fill:oj},[oN("path",{d:"M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"})]),oN("g",{opacity:"0.25",fill:"#000000"},[oN("path",{d:"M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"})]),oN("g",{transform:"translate(6.0, 7.0)",fill:"#FFFFFF"}),oN("g",{transform:"translate(8.0, 8.0)"},[oN("circle",{fill:"#000000",opacity:"0.25",cx:"5.5",cy:"5.5",r:"5.4999962"}),oN("circle",{fill:"#FFFFFF",cx:"5.5",cy:"5.5",r:"5.4999962"})])])]))).cloneNode(!0);i.setAttributeNS(null,"height",`${41*this._scale}px`),i.setAttributeNS(null,"width",`${27*this._scale}px`),i.firstElementChild.children[1].setAttributeNS(null,"fill",this._color),this._element.appendChild(i),this._offset=m.Li.convert(t?.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",t=>{t.preventDefault()}),this._element.addEventListener("mousedown",t=>{t.preventDefault()}),function(t,i,r){let a=t.classList;for(let t in oB)a.remove(`maplibregl-${r}-anchor-${t}`);a.add(`maplibregl-${r}-anchor-${i}`)}(this._element,this._anchor,"marker"),t?.className)for(let i of t.className.split(" "))this._element.classList.add(i);this._popup=null}addTo(t){return this.remove(),this._map=t,this._defaultMarker&&!this._element.hasAttribute("aria-label")&&this._element.setAttribute("aria-label",t._getUIString("Marker.Title")),this._updateAccessibilityRole(),t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",this._update),t.on("terrain",this._update),t.on("projectiontransition",this._update),this._element.addEventListener("click",this._onClick),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",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),this._element.removeEventListener("click",this._onClick),this._element.removeEventListener("keydown",this._onKeyDown),this._element.removeEventListener("keyup",this._onKeyUp),this._element.removeEventListener("blur",this._onBlur),this._element.removeEventListener("keypress",this._onKeyPress),this._keyboardDragActive=!1,this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=m.lt.convert(t),this._pos=null,this._update(),this._popup&&this._popup.setLngLat(this._lngLat),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress)),t){if(!("offset"in t.options)){let i=13.5/Math.SQRT2;t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[
8160,-38.1],"bottom-left":[i,-((24.6+i)*1)],"bottom-right":[-i,-((24.6+i)*1)],left:[13.5,-24.6],right:[-13.5,-24.6]}:this._offset}this._popup=t,this._element.addEventListener("keypress",this._onKeyPress)}return this._updateTabIndex(),this._updateAccessibilityRole(),this}setSubpixelPositioning(t){return this._subpixelPositioning=t,this}_endKeyboardDrag(){this._keyboardDragActive&&(this._keyboardDragActive=!1,this.fire(new oZ("dragend")))}getPopup(){return this._popup}togglePopup(){let t=this._popup;return this._element.style.opacity===this._opacityWhenCovered||t&&(t.isOpen()?t.remove():(t.setLngLat(this._lngLat),t.addTo(this._map))),this}_updateOpacity(){if(!this._isInViewport())return;let t=this._map?.terrain,i=this._map._camera.transform.isLocationOccluded(this._lngLat);if(!t||i){let t=i?this._opacityWhenCovered:this._opacity;this._element.style.opacity!==t&&(this._element.style.opacity=t,this._element.classList.toggle("maplibregl-marker-covered",i));return}this._updateCovered()}_isInViewport(){let{width:t,height:i}=this._map._camera.transform;return!!this._pos&&this._pos.x>=0&&this._pos.y>=0&&this._pos.x<=t&&this._pos.y<=i}_isCovered(t){let i=this._map._camera.transform,r=t.getElevationForLngLat(this._lngLat,i),a=Math.max(0,-this._offset.y)/i.pixelsPerMeter,o=Math.sin(this._map.getPitch()*Math.PI/180)*a;return i.isLocationOccluded(this._lngLat,t,r+o)}getOffset(){return this._offset}setOffset(t){return this._offset=m.Li.convert(t),this._update(),this}addClassName(t){this._element.classList.add(t)}removeClassName(t){this._element.classList.remove(t)}toggleClassName(t){return this._element.classList.toggle(t)}setDraggable(t){return this._draggable=!!t,this._element.classList.toggle("maplibregl-marker-draggable",this._draggable),this._map&&(t?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this._defaultMarker&&(this._draggable?(this._element.addEventListener("keydown",this._onKeyDown),this._element.addEventListener("keyup",this._onKeyUp),this._element.addEventListener("blur",this._onBlur)):(this._element.removeEventListener("keydown",this._onKeyDown),this._element.removeEventListener("keyup",this._onKeyUp),this._element.removeEventListener("blur",this._onBlur),this._endKeyboardDrag())),this._updateTabIndex(),this._updateAccessibilityRole(),this}isDraggable(){return this._draggable}_updateTabIndex(){this._popup||this._defaultMarker&&this._draggable?this._element.hasAttribute("tabindex")||(this._element.setAttribute("tabindex","0"),this._tabIndexManaged=!0):this._tabIndexManaged&&=("0"===this._element.getAttribute("tabindex")&&this._element.removeAttribute("tabindex"),!1)}_updateAccessibilityRole(){if(!this._defaultMarker||this._element.hasAttribute("role")&&!this._roleManaged)return;let t=this._draggable||this._popup?"button":"img";this._element.setAttribute("role",t),this._roleManaged=!0}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&"auto"!==t?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(t,i){return(void 0===this._opacity||void 0===t&&void 0===i)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==t&&(this._opacity=String(t)),void 0!==i&&(this._opacityWhenCovered=String(i)),this._map&&this._updateOpacity(),this}};m._n,m._n,m._n,m.vn,m._n,m.vn;function oV(t){m.An.WORKER_URL=t}m._n,m.vn}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.