aviation-chart 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).navMap={})}(this,function(e){"use strict";function t(e,t){return t.forEach(function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach(function(i){if("default"!==i&&!(i in e)){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})}})}),Object.freeze(e)}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n={exports:{}};!function(e){e.exports=function(){var e={},t={};function i(i,n,r){if(t[i]=r,"index"===i){var o="var sharedModule = {}; ("+t.shared+")(sharedModule); ("+t.worker+")(sharedModule);",s={};return t.shared(s),t.index(e,s),"undefined"!=typeof window&&e.setWorkerUrl(window.URL.createObjectURL(new Blob([o],{type:"text/javascript"}))),e}}return i("shared",["exports"],function(e){function t(e,t,i,n){return new(i||(i=Promise))(function(r,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,a)}l((n=n.apply(e,t||[])).next())})}function i(e,t){this.x=e,this.y=t}function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var r,o;i.prototype={clone(){return new i(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){const t=e.x-this.x,i=e.y-this.y;return t*t+i*i},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){const t=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=t,this},_add(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){const e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){const t=Math.cos(e),i=Math.sin(e),n=i*this.x+t*this.y;return this.x=t*this.x-i*this.y,this.y=n,this},_rotateAround(e,t){const i=Math.cos(e),n=Math.sin(e),r=t.y+n*(this.x-t.x)+i*(this.y-t.y);return this.x=t.x+i*(this.x-t.x)-n*(this.y-t.y),this.y=r,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:i},i.convert=function(e){if(e instanceof i)return e;if(Array.isArray(e))return new i(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new i(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};var s=function(){if(o)return r;function e(e,t,i,n){this.cx=3*e,this.bx=3*(i-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(n-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=n}return o=1,r=e,e.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(void 0===t&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var i=e,n=0;n<8;n++){var r=this.sampleCurveX(i)-e;if(Math.abs(r)<t)return i;var o=this.sampleCurveDerivativeX(i);if(Math.abs(o)<1e-6)break;i-=r/o}var s=0,a=1;for(i=e,n=0;n<20&&(r=this.sampleCurveX(i),!(Math.abs(r-e)<t));n++)e>r?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},r}(),a=n(s);let l,c;function u(){return null!=l||(l="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),l}function h(){if(null==c&&(c=!1,u())){const e=5,t=new OffscreenCanvas(e,e).getContext("2d",{willReadFrequently:!0});if(t){for(let i=0;i<e*e;i++){const n=4*i;t.fillStyle=`rgb(${n},${n+1},${n+2})`,t.fillRect(i%e,Math.floor(i/e),1,1)}const i=t.getImageData(0,0,e,e).data;for(let t=0;t<e*e*4;t++)if(t%4!=3&&i[t]!==t){c=!0;break}}}return c||!1}var d=1e-6,p="undefined"!=typeof Float32Array?Float32Array:Array;function f(){var e=new p(9);return p!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function m(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function g(){var e=new p(3);return p!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function y(e){var t=e[0],i=e[1],n=e[2];return Math.sqrt(t*t+i*i+n*n)}function _(e,t,i){var n=new p(3);return n[0]=e,n[1]=t,n[2]=i,n}function v(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e}function x(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function b(e,t,i){var n=t[0],r=t[1],o=t[2],s=i[0],a=i[1],l=i[2];return e[0]=r*l-o*a,e[1]=o*s-n*l,e[2]=n*a-r*s,e}var w,E=y;function T(e,t,i){var n=t[0],r=t[1],o=t[2],s=t[3];return e[0]=i[0]*n+i[4]*r+i[8]*o+i[12]*s,e[1]=i[1]*n+i[5]*r+i[9]*o+i[13]*s,e[2]=i[2]*n+i[6]*r+i[10]*o+i[14]*s,e[3]=i[3]*n+i[7]*r+i[11]*o+i[15]*s,e}function S(){var e=new p(4);return p!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function I(e,t,i,n){var r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"zyx",o=Math.PI/360;t*=o,n*=o,i*=o;var s=Math.sin(t),a=Math.cos(t),l=Math.sin(i),c=Math.cos(i),u=Math.sin(n),h=Math.cos(n);switch(r){case"xyz":e[0]=s*c*h+a*l*u,e[1]=a*l*h-s*c*u,e[2]=a*c*u+s*l*h,e[3]=a*c*h-s*l*u;break;case"xzy":e[0]=s*c*h-a*l*u,e[1]=a*l*h-s*c*u,e[2]=a*c*u+s*l*h,e[3]=a*c*h+s*l*u;break;case"yxz":e[0]=s*c*h+a*l*u,e[1]=a*l*h-s*c*u,e[2]=a*c*u-s*l*h,e[3]=a*c*h+s*l*u;break;case"yzx":e[0]=s*c*h+a*l*u,e[1]=a*l*h+s*c*u,e[2]=a*c*u-s*l*h,e[3]=a*c*h-s*l*u;break;case"zxy":e[0]=s*c*h-a*l*u,e[1]=a*l*h+s*c*u,e[2]=a*c*u+s*l*h,e[3]=a*c*h-s*l*u;break;case"zyx":e[0]=s*c*h-a*l*u,e[1]=a*l*h+s*c*u,e[2]=a*c*u-s*l*h,e[3]=a*c*h+s*l*u;break;default:throw new Error("Unknown angle order "+r)}return e}function k(){var e=new p(2);return p!=Float32Array&&(e[0]=0,e[1]=0),e}function M(e,t){var i=new p(2);return i[0]=e,i[1]=t,i}g(),w=new p(4),p!=Float32Array&&(w[0]=0,w[1]=0,w[2]=0,w[3]=0),g(),_(1,0,0),_(0,1,0),S(),S(),f(),k();const C=8192;function P(e,t,i){return t*(C/(e.tileSize*Math.pow(2,i-e.tileID.overscaledZ)))}function A(e){return e instanceof Error?e:new Error("string"==typeof e?e:String(e))}function L(e,t){return(e%t+t)%t}function D(e,t,i){return e*(1-i)+t*i}function R(e){if(e<=0)return 0;if(e>=1)return 1;const t=e*e,i=t*e;return 4*(e<.5?i:3*(e-t)+i-.75)}function z(e,t,i,n){const r=new a(e,t,i,n);return e=>r.solve(e)}const F=z(.25,.1,.25,1);function O(e,t,i){return Math.min(i,Math.max(t,e))}function N(e,t,i){const n=i-t,r=((e-t)%n+n)%n+t;return r===t?i:r}function B(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}let G=1;function j(e,t,i){const n={};for(const i in e)n[i]=t.call(this,e[i],i,e);return n}function V(e,t,i){const n={};for(const i in e)t.call(this,e[i],i,e)&&(n[i]=e[i]);return n}function U(e){return Array.isArray(e)?e.map(U):"object"==typeof e&&e?j(e,U):e}function q(e){}function Z(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function $(e){return"undefined"!=typeof WorkerGlobalScope&&void 0!==e&&e instanceof WorkerGlobalScope}let H=null;function W(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap}const X="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function Y(e,i,n,r,o){return t(this,void 0,void 0,function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const t=new VideoFrame(e,{timestamp:0});try{const s=null==t?void 0:t.format;if(!s||!s.startsWith("BGR")&&!s.startsWith("RGB"))throw new Error(`Unrecognized format ${s}`);const a=s.startsWith("BGR"),l=new Uint8ClampedArray(r*o*4);if(yield t.copyTo(l,function(e,t,i,n,r){const o=4*Math.max(-t,0),s=(Math.max(0,i)-i)*n*4+o,a=4*n,l=Math.max(0,t),c=Math.max(0,i);return{rect:{x:l,y:c,width:Math.min(e.width,t+n)-l,height:Math.min(e.height,i+r)-c},layout:[{offset:s,stride:a}]}}(e,i,n,r,o)),a)for(let e=0;e<l.length;e+=4){const t=l[e];l[e]=l[e+2],l[e+2]=t}return l}finally{t.close()}})}let J,K;function Q(e,t,i,n){return e.addEventListener(t,i,n),{unsubscribe:()=>{e.removeEventListener(t,i,n)}}}function ee(e){return e*Math.PI/180}function te(e){return e/Math.PI*180}const ie={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},ne={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},re="AbortError";class oe extends Error{constructor(e=re){super(e instanceof Error?e.message:e),this.name=re,e instanceof Error&&e.stack&&(this.stack=e.stack)}}function se(e){return e instanceof Error&&e.name===re}function ae(e){if(e.aborted)throw new oe(e.reason)}const le={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function ce(e){return le.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf("://"))]}const ue="global-dispatcher";class he extends Error{constructor(e,t,i,n){super(`AJAXError: ${t} (${e}): ${i}`),this.status=e,this.statusText=t,this.url=i,this.body=n}}const de=()=>{var e;return $(self)?null===(e=self.worker)||void 0===e?void 0:e.referrer:("blob:"===window.location.protocol?window.parent:window).location.href},pe=function(e,i){return t(this,void 0,void 0,function*(){var n,r;if(e.url.includes("://")&&!/^https?:|^file:/.test(e.url)){const t=ce(e.url);if(t){const n=yield t(e,i);return n.data||"arrayBuffer"!==e.type?n:B(n,{data:new ArrayBuffer(0)})}if($(self)&&(null===(n=self.worker)||void 0===n?void 0:n.actor))return self.worker.actor.sendAsync({type:"GR",data:e,targetMapId:ue},i)}if(!(e=>{var t;return e.startsWith("file:")||(null===(t=de())||void 0===t?void 0:t.startsWith("file:"))&&!/^\w+:/.test(e)})(e.url)){if(fetch&&Request&&AbortController&&Object.hasOwn(Request.prototype,"signal"))return function(e,i){return t(this,void 0,void 0,function*(){const t=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,cache:e.cache,referrer:de(),referrerPolicy:e.referrerPolicy,signal:i.signal});let n,r;"json"!==e.type||t.headers.has("Accept")||t.headers.set("Accept","application/json");try{n=yield fetch(t)}catch(t){if(se(t))throw t;throw new he(0,A(t).message,e.url,new Blob)}if(!n.ok){const t=yield n.blob();throw new he(n.status,n.statusText,e.url,t)}r="arrayBuffer"===e.type||"image"===e.type?n.arrayBuffer():"json"===e.type?n.json():n.text();const o=yield r;return ae(i.signal),{data:o,cacheControl:n.headers.get("Cache-Control"),expires:n.headers.get("Expires"),etag:n.headers.get("ETag")}})}(e,i);if($(self)&&(null===(r=self.worker)||void 0===r?void 0:r.actor))return self.worker.actor.sendAsync({type:"GR",data:e,mustQueue:!0,targetMapId:ue},i)}return function(e,t){return new Promise((i,n)=>{var r;const o=new XMLHttpRequest;o.open(e.method||"GET",e.url,!0),"arrayBuffer"!==e.type&&"image"!==e.type||(o.responseType="arraybuffer");for(const t in e.headers)o.setRequestHeader(t,e.headers[t]);"json"===e.type&&(o.responseType="text",(null===(r=e.headers)||void 0===r?void 0:r.Accept)||o.setRequestHeader("Accept","application/json")),o.withCredentials="include"===e.credentials,o.onerror=()=>{n(new Error(o.statusText))},o.onload=()=>{if(!t.signal.aborted)if((o.status>=200&&o.status<300||0===o.status)&&null!==o.response){let t=o.response;if("json"===e.type)try{t=JSON.parse(o.response)}catch(e){return void n(e)}i({data:t,cacheControl:o.getResponseHeader("Cache-Control"),expires:o.getResponseHeader("Expires"),etag:o.getResponseHeader("ETag")})}else{const t=new Blob([o.response],{type:o.getResponseHeader("Content-Type")});n(new he(o.status,o.statusText,e.url,t))}},t.signal.addEventListener("abort",()=>{o.abort(),n(new oe(t.signal.reason))}),o.send(e.body)})}(e,i)})};function fe(e){if(!e||e.indexOf("://")<=0||e.startsWith("data:image/")||e.startsWith("blob:"))return!0;const t=new URL(e),i=window.location;return t.protocol===i.protocol&&t.host===i.host}function me(e,t,i){var n;(null===(n=i[e])||void 0===n?void 0:n.includes(t))||(i[e]||(i[e]=[]),i[e].push(t))}function ge(e,t,i){if(null==i?void 0:i[e]){const n=i[e].indexOf(t);-1!==n&&i[e].splice(n,1)}}class ye{constructor(e,t={}){B(this,t),this.type=e}}class _e extends ye{constructor(e,t={}){super("error",B({error:e},t))}}class ve{on(e,t){return this._listeners||(this._listeners={}),me(e,t,this._listeners),{unsubscribe:()=>{this.off(e,t)}}}off(e,t){return ge(e,t,this._listeners),ge(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners||(this._oneTimeListeners={}),me(e,t,this._oneTimeListeners),this):new Promise(t=>this.once(e,t))}fire(e,t){var i,n;"string"==typeof e&&(e=new ye(e,t||{}));const r=e.type;if(this.listens(r)){e.target=this;const t=(null===(i=this._listeners)||void 0===i?void 0:i[r])?this._listeners[r].slice():[];for(const i of t)i.call(this,e);const o=(null===(n=this._oneTimeListeners)||void 0===n?void 0:n[r])?this._oneTimeListeners[r].slice():[];for(const t of o)ge(r,t,this._oneTimeListeners),t.call(this,e);const s=this._eventedParent;s&&(B(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),s.fire(e))}return this}listens(e){var t,i,n,r,o;return(null===(i=null===(t=this._listeners)||void 0===t?void 0:t[e])||void 0===i?void 0:i.length)>0||(null===(r=null===(n=this._oneTimeListeners)||void 0===n?void 0:n[e])||void 0===r?void 0:r.length)>0||(null===(o=this._eventedParent)||void 0===o?void 0:o.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}var xe={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number",length:2},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},"font-faces":{type:"fontFaces"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},encoding:{type:"enum",values:{mvt:{},mlt:{}},default:"mvt"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},_mbx:{},custom:{}},default:"_mbx"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"filter"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},filter:{type:"boolean",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"expression_name",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}},interpolation:{type:"array",value:"interpolation_name",minimum:1},interpolation_name:{type:"enum",values:{linear:{syntax:{overloads:[{parameters:[],"output-type":"interpolation"}],parameters:[]}},exponential:{syntax:{overloads:[{parameters:["base"],"output-type":"interpolation"}],parameters:[{name:"base",type:"number literal"}]}},"cubic-bezier":{syntax:{overloads:[{parameters:["x1","y1","x2","y2"],"output-type":"interpolation"}],parameters:[{name:"x1",type:"number literal"},{name:"y1",type:"number literal"},{name:"x2",type:"number literal"},{name:"y2",type:"number literal"}]}}}}};const be=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function we(e,t){const i={};for(const t in e)"ref"!==t&&(i[t]=e[t]);return be.forEach(e=>{e in t&&(i[e]=t[e])}),i}function Ee(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!Ee(e[i],t[i]))return!1;return!0}if("object"==typeof e&&null!==e&&null!==t){if("object"!=typeof t)return!1;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const i in e)if(!Ee(e[i],t[i]))return!1;return!0}return e===t}function Te(e,t){e.push(t)}function Se(e,t,i){Te(i,{command:"addSource",args:[e,t[e]]})}function Ie(e,t,i){Te(t,{command:"removeSource",args:[e]}),i[e]=!0}function ke(e,t,i,n){Ie(e,i,n),Se(e,t,i)}function Me(e,t,i){let n;for(n in e[i])if(Object.prototype.hasOwnProperty.call(e[i],n)&&"data"!==n&&!Ee(e[i][n],t[i][n]))return!1;for(n in t[i])if(Object.prototype.hasOwnProperty.call(t[i],n)&&"data"!==n&&!Ee(e[i][n],t[i][n]))return!1;return!0}function Ce(e,t,i,n,r,o){e=e||{},t=t||{};for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(Ee(e[s],t[s])||i.push({command:o,args:[n,s,t[s],r]}));for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&!Object.prototype.hasOwnProperty.call(e,s)&&(Ee(e[s],t[s])||i.push({command:o,args:[n,s,t[s],r]}))}function Pe(e){return e.id}function Ae(e,t){return e[t.id]=t,e}class Le{constructor(e,t,i,n){this.message=(e?`${e}: `:"")+i,n&&(this.identifier=n),null!=t&&t.__line__&&(this.line=t.__line__)}}function De(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}class Re extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}class ze{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,i]of t)this.bindings[e]=i}concat(e){return new ze(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}const Fe={kind:"null"},Oe={kind:"number"},Ne={kind:"string"},Be={kind:"boolean"},Ge={kind:"color"},je={kind:"projectionDefinition"},Ve={kind:"object"},Ue={kind:"value"},qe={kind:"collator"},Ze={kind:"formatted"},$e={kind:"padding"},He={kind:"colorArray"},We={kind:"numberArray"},Xe={kind:"resolvedImage"},Ye={kind:"variableAnchorOffsetCollection"};function Je(e,t){return{kind:"array",itemType:e,N:t}}function Ke(e){if("array"===e.kind){const t=Ke(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const Qe=[Fe,Oe,Ne,Be,Ge,je,Ze,Ve,Je(Ue),$e,We,He,Xe,Ye];function et(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!et(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if("value"===e.kind)for(const e of Qe)if(!et(e,t))return null}return`Expected ${Ke(e)} but found ${Ke(t)} instead.`}function tt(e,t){return t.some(t=>t.kind===e.kind)}function it(e,t){return t.some(t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e)}function nt(e,t){return"array"===e.kind&&"array"===t.kind?e.itemType.kind===t.itemType.kind&&"number"==typeof e.N:e.kind===t.kind}const rt=.96422,ot=.82521,st=4/29,at=6/29,lt=3*at*at,ct=at*at*at,ut=Math.PI/180,ht=180/Math.PI;function dt(e){return(e%=360)<0&&(e+=360),e}function pt([e,t,i,n]){let r,o;const s=mt((.2225045*(e=ft(e))+.7168786*(t=ft(t))+.0606169*(i=ft(i)))/1);e===t&&t===i?r=o=s:(r=mt((.4360747*e+.3850649*t+.1430804*i)/rt),o=mt((.0139322*e+.0971045*t+.7141733*i)/ot));const a=116*s-16;return[a<0?0:a,500*(r-s),200*(s-o),n]}function ft(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function mt(e){return e>ct?Math.pow(e,1/3):e/lt+st}function gt([e,t,i,n]){let r=(e+16)/116,o=isNaN(t)?r:r+t/500,s=isNaN(i)?r:r-i/200;return r=1*_t(r),o=rt*_t(o),s=ot*_t(s),[yt(3.1338561*o-1.6168667*r-.4906146*s),yt(-.9787684*o+1.9161415*r+.033454*s),yt(.0719453*o-.2289914*r+1.4052427*s),n]}function yt(e){return(e=e<=.00304?12.92*e:1.055*Math.pow(e,1/2.4)-.055)<0?0:e>1?1:e}function _t(e){return e>at?e*e*e:lt*(e-st)}const vt=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};function xt(e,t){return vt(e,t)?e[t]:void 0}function bt(e){return parseInt(e.padEnd(2,e),16)/255}function wt(e,t){return Et(t?e/100:e,0,1)}function Et(e,t,i){return Math.min(Math.max(t,e),i)}function Tt(e){return!e.some(Number.isNaN)}const St={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function It(e,t,i){return e+i*(t-e)}function kt(e,t,i){return e.map((e,n)=>It(e,t[n],i))}class Mt{constructor(e,t,i,n=1,r=!0){this.r=e,this.g=t,this.b=i,this.a=n,r||(this.r*=n,this.g*=n,this.b*=n,n||this.overwriteGetter("rgb",[e,t,i,n]))}static parse(e){if(e instanceof Mt)return e;if("string"!=typeof e)return;const t=function(e){if("transparent"===(e=e.toLowerCase().trim()))return[0,0,0,0];const t=xt(St,e);if(t){const[e,i,n]=t;return[e/255,i/255,n/255,1]}if(e.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){const t=e.length<6?1:2;let i=1;return[bt(e.slice(i,i+=t)),bt(e.slice(i,i+=t)),bt(e.slice(i,i+=t)),bt(e.slice(i,i+t)||"ff")]}if(e.startsWith("rgb")){const t=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(t){const[e,i,n,r,o,s,a,l,c,u,h,d]=t,p=[r||" ",a||" ",u].join("");if(" "===p||" /"===p||",,"===p||",,,"===p){const e=[n,s,c].join(""),t="%%%"===e?100:""===e?255:0;if(t){const e=[Et(+i/t,0,1),Et(+o/t,0,1),Et(+l/t,0,1),h?wt(+h,d):1];if(Tt(e))return e}}return}}const i=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(i){const[e,t,n,r,o,s,a,l,c]=i,u=[n||" ",o||" ",a].join("");if(" "===u||" /"===u||",,"===u||",,,"===u){const e=[+t,Et(+r,0,100),Et(+s,0,100),l?wt(+l,c):1];if(Tt(e))return function([e,t,i,n]){function r(n){const r=(n+e/30)%12,o=t*Math.min(i,1-i);return i-o*Math.max(-1,Math.min(r-3,9-r,1))}return e=dt(e),t/=100,i/=100,[r(0),r(8),r(4),n]}(e)}}}(e);return t?new Mt(...t,!1):void 0}get rgb(){const{r:e,g:t,b:i,a:n}=this,r=n||1/0;return this.overwriteGetter("rgb",[e/r,t/r,i/r,n])}get hcl(){return this.overwriteGetter("hcl",function(e){const[t,i,n,r]=pt(e),o=Math.sqrt(i*i+n*n);return[Math.round(1e4*o)?dt(Math.atan2(n,i)*ht):NaN,o,t,r]}(this.rgb))}get lab(){return this.overwriteGetter("lab",pt(this.rgb))}overwriteGetter(e,t){return Object.defineProperty(this,e,{value:t}),t}toString(){const[e,t,i,n]=this.rgb;return`rgba(${[e,t,i].map(e=>Math.round(255*e)).join(",")},${n})`}static interpolate(e,t,i,n="rgb"){switch(n){case"rgb":{const[n,r,o,s]=kt(e.rgb,t.rgb,i);return new Mt(n,r,o,s,!1)}case"hcl":{const[n,r,o,s]=e.hcl,[a,l,c,u]=t.hcl;let h,d;if(isNaN(n)||isNaN(a))isNaN(n)?isNaN(a)?h=NaN:(h=a,1!==o&&0!==o||(d=l)):(h=n,1!==c&&0!==c||(d=r));else{let e=a-n;a>n&&e>180?e-=360:a<n&&n-a>180&&(e+=360),h=n+i*e}const[p,f,m,g]=function([e,t,i,n]){return e=isNaN(e)?0:e*ut,gt([i,Math.cos(e)*t,Math.sin(e)*t,n])}([h,null!=d?d:It(r,l,i),It(o,c,i),It(s,u,i)]);return new Mt(p,f,m,g,!1)}case"lab":{const[n,r,o,s]=gt(kt(e.lab,t.lab,i));return new Mt(n,r,o,s,!1)}}}}Mt.black=new Mt(0,0,0,1),Mt.white=new Mt(1,1,1,1),Mt.transparent=new Mt(0,0,0,0),Mt.red=new Mt(1,0,0,1);class Ct{constructor(e,t,i){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const Pt=["bottom","center","top"];class At{constructor(e,t,i,n,r,o){this.text=e,this.image=t,this.scale=i,this.fontStack=n,this.textColor=r,this.verticalAlign=o}}class Lt{constructor(e){this.sections=e}static fromString(e){return new Lt([new At(e,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||e.image&&0!==e.image.name.length)}static factory(e){return e instanceof Lt?e:Lt.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}}class Dt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Dt)return e;if("number"==typeof e)return new Dt([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const t of e)if("number"!=typeof t)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new Dt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i){return new Dt(kt(e.values,t.values,i))}}class Rt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Rt)return e;if("number"==typeof e)return new Rt([e]);if(Array.isArray(e)){for(const t of e)if("number"!=typeof t)return;return new Rt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i){return new Rt(kt(e.values,t.values,i))}}class zt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof zt)return e;if("string"==typeof e){const t=Mt.parse(e);if(!t)return;return new zt([t])}if(!Array.isArray(e))return;const t=[];for(const i of e){if("string"!=typeof i)return;const e=Mt.parse(i);if(!e)return;t.push(e)}return new zt(t)}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i,n="rgb"){const r=[];if(e.values.length!=t.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${t.values.length}), cannot interpolate.`);for(let o=0;o<e.values.length;o++)r.push(Mt.interpolate(e.values[o],t.values[o],i,n));return new zt(r)}}class Ft extends Error{constructor(e){super(e),this.name="RuntimeError"}toJSON(){return this.message}}const Ot=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class Nt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Nt)return e;if(Array.isArray(e)&&!(e.length<1)&&e.length%2==0){for(let t=0;t<e.length;t+=2){const i=e[t],n=e[t+1];if("string"!=typeof i||!Ot.has(i))return;if(!Array.isArray(n)||2!==n.length||"number"!=typeof n[0]||"number"!=typeof n[1])return}return new Nt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i){const n=e.values,r=t.values;if(n.length!==r.length)throw new Ft(`Cannot interpolate values of different length. from: ${e.toString()}, to: ${t.toString()}`);const o=[];for(let e=0;e<n.length;e+=2){if(n[e]!==r[e])throw new Ft(`Cannot interpolate values containing mismatched anchors. from[${e}]: ${n[e]}, to[${e}]: ${r[e]}`);o.push(n[e]);const[t,s]=n[e+1],[a,l]=r[e+1];o.push([It(t,a,i),It(s,l,i)])}return new Nt(o)}}class Bt{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new Bt({name:e,available:!1}):null}}class Gt{constructor(e,t,i){this.from=e,this.to=t,this.transition=i}static interpolate(e,t,i){return new Gt(e,t,i)}static parse(e){return e instanceof Gt?e:Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]?new Gt(e[0],e[1],e[2]):"object"==typeof e&&"string"==typeof e.from&&"string"==typeof e.to&&"number"==typeof e.transition?new Gt(e.from,e.to,e.transition):"string"==typeof e?new Gt(e,e,1):void 0}}function jt(e,t,i,n){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[e,t,i,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[e,t,i,n]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Vt(e){if(null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||e instanceof Gt||e instanceof Mt||e instanceof Ct||e instanceof Lt||e instanceof Dt||e instanceof Rt||e instanceof zt||e instanceof Nt||e instanceof Bt)return!0;if(Array.isArray(e)){for(const t of e)if(!Vt(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!Vt(e[t]))return!1;return!0}return!1}function Ut(e){if(null===e)return Fe;if("string"==typeof e)return Ne;if("boolean"==typeof e)return Be;if("number"==typeof e)return Oe;if(e instanceof Mt)return Ge;if(e instanceof Gt)return je;if(e instanceof Ct)return qe;if(e instanceof Lt)return Ze;if(e instanceof Dt)return $e;if(e instanceof Rt)return We;if(e instanceof zt)return He;if(e instanceof Nt)return Ye;if(e instanceof Bt)return Xe;if(Array.isArray(e)){const t=e.length;let i;for(const t of e){const e=Ut(t);if(i){if(i===e)continue;i=Ue;break}i=e}return Je(i||Ue,t)}return Ve}function qt(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Mt||e instanceof Gt||e instanceof Lt||e instanceof Dt||e instanceof Rt||e instanceof zt||e instanceof Nt||e instanceof Bt?e.toString():JSON.stringify(e)}class Zt{constructor(e,t){this.type=e,this.value=t}static parse(e,t){if(2!==e.length)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Vt(e[1]))return t.error("invalid value");const i=e[1];let n=Ut(i);const r=t.expectedType;return"array"!==n.kind||0!==n.N||!r||"array"!==r.kind||"number"==typeof r.N&&0!==r.N||(n=r),new Zt(n,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const $t={string:Ne,number:Oe,boolean:Be,object:Ve};class Ht{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let i,n=1;const r=e[0];if("array"===r){let r,o;if(e.length>2){const i=e[1];if("string"!=typeof i||!(i in $t)||"object"===i)return t.error('The item type argument of "array" must be one of string, number, boolean',1);r=$t[i],n++}else r=Ue;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);o=e[2],n++}i=Je(r,o)}else{if(!$t[r])throw new Error(`Types doesn't contain name = ${r}`);i=$t[r]}const o=[];for(;n<e.length;n++){const i=t.parse(e[n],n,Ue);if(!i)return null;o.push(i)}return new Ht(i,o)}evaluate(e){for(let t=0;t<this.args.length;t++){const i=this.args[t].evaluate(e);if(!et(this.type,Ut(i)))return i;if(t===this.args.length-1)throw new Ft(`Expected value to be of type ${Ke(this.type)}, but found ${Ke(Ut(i))} instead.`)}throw new Error}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}const Wt={"to-boolean":Be,"to-color":Ge,"to-number":Oe,"to-string":Ne};class Xt{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[0];if(!Wt[i])throw new Error(`Can't parse ${i} as it is not part of the known types`);if(("to-boolean"===i||"to-string"===i)&&2!==e.length)return t.error("Expected one argument.");const n=Wt[i],r=[];for(let i=1;i<e.length;i++){const n=t.parse(e[i],i,Ue);if(!n)return null;r.push(n)}return new Xt(n,r)}evaluate(e){switch(this.type.kind){case"boolean":return Boolean(this.args[0].evaluate(e));case"color":{let t,i;for(const n of this.args){if(t=n.evaluate(e),i=null,t instanceof Mt)return t;if("string"==typeof t){const i=e.parseColor(t);if(i)return i}else if(Array.isArray(t)&&(i=t.length<3||t.length>4?`Invalid rgba value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:jt(t[0],t[1],t[2],t[3]),!i))return new Mt(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Ft(i||`Could not parse color from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"padding":{let t;for(const i of this.args){t=i.evaluate(e);const n=Dt.parse(t);if(n)return n}throw new Ft(`Could not parse padding from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"numberArray":{let t;for(const i of this.args){t=i.evaluate(e);const n=Rt.parse(t);if(n)return n}throw new Ft(`Could not parse numberArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"colorArray":{let t;for(const i of this.args){t=i.evaluate(e);const n=zt.parse(t);if(n)return n}throw new Ft(`Could not parse colorArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"variableAnchorOffsetCollection":{let t;for(const i of this.args){t=i.evaluate(e);const n=Nt.parse(t);if(n)return n}throw new Ft(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"number":{let t=null;for(const i of this.args){if(t=i.evaluate(e),null===t)return 0;const n=Number(t);if(!isNaN(n))return n}throw new Ft(`Could not convert ${JSON.stringify(t)} to number.`)}case"formatted":return Lt.fromString(qt(this.args[0].evaluate(e)));case"resolvedImage":return Bt.fromString(qt(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return qt(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}const Yt=["Unknown","Point","LineString","Polygon"];class Jt{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Yt[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(e){let t=this._parseColorCache.get(e);return t||(t=Mt.parse(e),this._parseColorCache.set(e,t)),t}}class Kt{constructor(e,t,i=[],n,r=new ze,o=[]){this.registry=e,this.path=i,this.key=i.map(e=>`[${e}]`).join(""),this.scope=r,this.errors=o,this.expectedType=n,this._isConstant=t}parse(e,t,i,n,r={}){return t?this.concat(t,i,n)._parse(e,r):this._parse(e,r)}_parse(e,t){function i(e,t,i){return"assert"===i?new Ht(t,[e]):"coerce"===i?new Xt(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n=e[0];if("string"!=typeof n)return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const r=this.registry[n];if(r){let n=r.parse(e,this);if(!n)return null;if(this.expectedType){const e=this.expectedType,r=n.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==r.kind){if("projectionDefinition"===e.kind&&["string","array"].includes(r.kind)||["color","formatted","resolvedImage"].includes(e.kind)&&["value","string"].includes(r.kind)||["padding","numberArray"].includes(e.kind)&&["value","number","array"].includes(r.kind)||"colorArray"===e.kind&&["value","string","array"].includes(r.kind)||"variableAnchorOffsetCollection"===e.kind&&["value","array"].includes(r.kind))n=i(n,e,t.typeAnnotation||"coerce");else if(this.checkSubtype(e,r))return null}else n=i(n,e,t.typeAnnotation||"assert")}if(!(n instanceof Zt)&&"resolvedImage"!==n.type.kind&&this._isConstant(n)){const t=new Jt;try{n=new Zt(n.type,n.evaluate(t))}catch(e){return this.error(e.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,t,i){const n="number"==typeof e?this.path.concat(e):this.path,r=i?this.scope.concat(i):this.scope;return new Kt(this.registry,this._isConstant,n,t||null,r,this.errors)}error(e,...t){const i=`${this.key}${t.map(e=>`[${e}]`).join("")}`;this.errors.push(new Re(i,e))}checkSubtype(e,t){const i=et(e,t);return i&&this.error(i),i}}class Qt{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result)}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const i=[];for(let n=1;n<e.length-1;n+=2){const r=e[n];if("string"!=typeof r)return t.error(`Expected string, but found ${typeof r} instead.`,n);if(/[^a-zA-Z0-9_]/.test(r))return t.error("Variable names must contain only alphanumeric characters or '_'.",n);const o=t.parse(e[n+1],n+1);if(!o)return null;i.push([r,o])}const n=t.parse(e[e.length-1],e.length-1,t.expectedType,i);return n?new Qt(i,n):null}outputDefined(){return this.result.outputDefined()}}class ei{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t}static parse(e,t){if(2!==e.length||"string"!=typeof e[1])return t.error("'var' expression requires exactly one string literal argument.");const i=e[1];return t.scope.has(i)?new ei(i,t.scope.get(i)):t.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}}class ti{constructor(e,t,i){this.type=e,this.index=t,this.input=i}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Oe),n=t.parse(e[2],2,Je(t.expectedType||Ue));return i&&n?new ti(n.type.itemType,i,n):null}evaluate(e){const t=this.index.evaluate(e),i=this.input.evaluate(e);if(t<0)throw new Ft(`Array index out of bounds: ${t} < 0.`);if(t>=i.length)throw new Ft(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t!==Math.floor(t))throw new Ft(`Array index must be an integer, but found ${t} instead.`);return i[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class ii{constructor(e,t){this.type=Be,this.needle=e,this.haystack=t}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Ue),n=t.parse(e[2],2,Ue);return i&&n?tt(i.type,[Be,Ne,Oe,Fe,Ue])?new ii(i,n):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(i.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!i)return!1;if(!it(t,["boolean","string","number","null"]))throw new Ft(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(Ut(t))} instead.`);if(!it(i,["string","array"]))throw new Ft(`Expected second argument to be of type array or string, but found ${Ke(Ut(i))} instead.`);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class ni{constructor(e,t,i){this.type=Oe,this.needle=e,this.haystack=t,this.fromIndex=i}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Ue),n=t.parse(e[2],2,Ue);if(!i||!n)return null;if(!tt(i.type,[Be,Ne,Oe,Fe,Ue]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(i.type)} instead`);if(4===e.length){const r=t.parse(e[3],3,Oe);return r?new ni(i,n,r):null}return new ni(i,n)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!it(t,["boolean","string","number","null"]))throw new Ft(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(Ut(t))} instead.`);let n;if(this.fromIndex&&(n=this.fromIndex.evaluate(e)),it(i,["string"])){const e=i.indexOf(t,n);return-1===e?-1:[...i.slice(0,e)].length}if(it(i,["array"]))return i.indexOf(t,n);throw new Ft(`Expected second argument to be of type array or string, but found ${Ke(Ut(i))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class ri{constructor(e,t,i,n,r,o){this.inputType=e,this.type=t,this.input=i,this.cases=n,this.outputs=r,this.otherwise=o}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let i,n;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);const r={},o=[];for(let s=2;s<e.length-1;s+=2){let a=e[s];const l=e[s+1];Array.isArray(a)||(a=[a]);const c=t.concat(s);if(0===a.length)return c.error("Expected at least one branch label.");for(const e of a){if("number"!=typeof e&&"string"!=typeof e)return c.error("Branch labels must be numbers or strings.");if("number"==typeof e&&Math.abs(e)>Number.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,Ut(e)))return null}else i=Ut(e);if(void 0!==r[String(e)])return c.error("Branch labels must be unique.");r[String(e)]=o.length}const u=t.parse(l,s,n);if(!u)return null;n=n||u.type,o.push(u)}const s=t.parse(e[1],1,Ue);if(!s)return null;const a=t.parse(e[e.length-1],e.length-1,n);return a?"value"!==s.type.kind&&t.concat(1).checkSubtype(i,s.type)?null:new ri(i,n,s,r,o,a):null}evaluate(e){const t=this.input.evaluate(e);return(Ut(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}}class oi{constructor(e,t,i){this.type=e,this.branches=t,this.otherwise=i}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let i;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);const n=[];for(let r=1;r<e.length-1;r+=2){const o=t.parse(e[r],r,Be);if(!o)return null;const s=t.parse(e[r+1],r+1,i);if(!s)return null;n.push([o,s]),i=i||s.type}const r=t.parse(e[e.length-1],e.length-1,i);if(!r)return null;if(!i)throw new Error("Can't infer output type");return new oi(i,n,r)}evaluate(e){for(const[t,i]of this.branches)if(t.evaluate(e))return i.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[t,i]of this.branches)e(t),e(i);e(this.otherwise)}outputDefined(){return this.branches.every(([e,t])=>t.outputDefined())&&this.otherwise.outputDefined()}}class si{constructor(e,t,i,n){this.type=e,this.input=t,this.beginIndex=i,this.endIndex=n}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Ue),n=t.parse(e[2],2,Oe);if(!i||!n)return null;if(!tt(i.type,[Je(Ue),Ne,Ue]))return t.error(`Expected first argument to be of type array or string, but found ${Ke(i.type)} instead`);if(4===e.length){const r=t.parse(e[3],3,Oe);return r?new si(i.type,i,n,r):null}return new si(i.type,i,n)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);let n;if(this.endIndex&&(n=this.endIndex.evaluate(e)),it(t,["string"]))return[...t].slice(i,n).join("");if(it(t,["array"]))return t.slice(i,n);throw new Ft(`Expected first argument to be of type array or string, but found ${Ke(Ut(t))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function ai(e,t){const i=e.length-1;let n,r,o=0,s=i,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),n=e[a],r=e[a+1],n<=t){if(a===i||t<r)return a;o=a+1}else{if(!(n>t))throw new Ft("Input is not a number.");s=a-1}return 0}class li{constructor(e,t,i){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[e,t]of i)this.labels.push(e),this.outputs.push(t)}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const i=t.parse(e[1],1,Oe);if(!i)return null;const n=[];let r=null;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);for(let i=1;i<e.length;i+=2){const o=1===i?-1/0:e[i],s=e[i+1],a=i,l=i+1;if("number"!=typeof o)return t.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',a);if(n.length&&n[n.length-1][0]>=o)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=t.parse(s,l,r);if(!c)return null;r=r||c.type,n.push([o,c])}return new li(r,i,n)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return i[0].evaluate(e);const r=t.length;return n>=t[r-1]?i[r-1].evaluate(e):i[ai(t,n)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function ci(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ui,hi,di=function(){if(hi)return ui;function e(e,t,i,n){this.cx=3*e,this.bx=3*(i-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(n-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=n}return hi=1,ui=e,e.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(void 0===t&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var i=e,n=0;n<8;n++){var r=this.sampleCurveX(i)-e;if(Math.abs(r)<t)return i;var o=this.sampleCurveDerivativeX(i);if(Math.abs(o)<1e-6)break;i-=r/o}var s=0,a=1;for(i=e,n=0;n<20&&(r=this.sampleCurveX(i),!(Math.abs(r-e)<t));n++)e>r?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},ui}(),pi=ci(di);class fi{constructor(e,t,i,n,r){this.type=e,this.operator=t,this.interpolation=i,this.input=n,this.labels=[],this.outputs=[];for(const[e,t]of r)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,i,n){let r=0;if("exponential"===e.name)r=mi(t,e.base,i,n);else if("linear"===e.name)r=mi(t,1,i,n);else if("cubic-bezier"===e.name){const o=e.controlPoints;r=new pi(o[0],o[1],o[2],o[3]).solve(mi(t,1,i,n))}return r}static parse(e,t){let[i,n,r,...o]=e;if(!Array.isArray(n)||0===n.length)return t.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const e=n[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:e}}else{if("cubic-bezier"!==n[0])return t.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const e=n.slice(1);if(4!==e.length||e.some(e=>"number"!=typeof e||e<0||e>1))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(r=t.parse(r,2,Oe),!r)return null;const s=[];let a=null;"interpolate-hcl"!==i&&"interpolate-lab"!==i||t.expectedType==He?t.expectedType&&"value"!==t.expectedType.kind&&(a=t.expectedType):a=Ge;for(let e=0;e<o.length;e+=2){const i=o[e],n=o[e+1],r=e+3,l=e+4;if("number"!=typeof i)return t.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',r);if(s.length&&s[s.length-1][0]>=i)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',r);const c=t.parse(n,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return nt(a,Oe)||nt(a,je)||nt(a,Ge)||nt(a,$e)||nt(a,We)||nt(a,He)||nt(a,Ye)||nt(a,Je(Oe))?new fi(a,i,n,r,s):t.error(`Type ${Ke(a)} is not interpolatable.`)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return i[0].evaluate(e);const r=t.length;if(n>=t[r-1])return i[r-1].evaluate(e);const o=ai(t,n),s=fi.interpolationFactor(this.interpolation,n,t[o],t[o+1]),a=i[o].evaluate(e),l=i[o+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return It(a,l,s);case"color":return Mt.interpolate(a,l,s);case"padding":return Dt.interpolate(a,l,s);case"colorArray":return zt.interpolate(a,l,s);case"numberArray":return Rt.interpolate(a,l,s);case"variableAnchorOffsetCollection":return Nt.interpolate(a,l,s);case"array":return kt(a,l,s);case"projectionDefinition":return Gt.interpolate(a,l,s)}case"interpolate-hcl":switch(this.type.kind){case"color":return Mt.interpolate(a,l,s,"hcl");case"colorArray":return zt.interpolate(a,l,s,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Mt.interpolate(a,l,s,"lab");case"colorArray":return zt.interpolate(a,l,s,"lab")}}}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function mi(e,t,i,n){const r=n-i,o=e-i;return 0===r?0:1===t?o/r:(Math.pow(t,o)-1)/(Math.pow(t,r)-1)}const gi={color:Mt.interpolate,number:It,padding:Dt.interpolate,numberArray:Rt.interpolate,colorArray:zt.interpolate,variableAnchorOffsetCollection:Nt.interpolate,array:kt};class yi{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let i=null;const n=t.expectedType;n&&"value"!==n.kind&&(i=n);const r=[];for(const n of e.slice(1)){const e=t.parse(n,1+r.length,i,void 0,{typeAnnotation:"omit"});if(!e)return null;i=i||e.type,r.push(e)}if(!i)throw new Error("No output type");const o=n&&r.some(e=>et(n,e.type));return new yi(o?Ue:i,r)}evaluate(e){let t,i=null,n=0;for(const r of this.args)if(n++,i=r.evaluate(e),i&&i instanceof Bt&&!i.available&&(t||(t=i.name),i=null,n===this.args.length&&(i=t)),null!==i)break;return i}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}function _i(e,t){return"=="===e||"!="===e?"boolean"===t.kind||"string"===t.kind||"number"===t.kind||"null"===t.kind||"value"===t.kind:"string"===t.kind||"number"===t.kind||"value"===t.kind}function vi(e,t,i,n){return 0===n.compare(t,i)}function xi(e,t,i){const n="=="!==e&&"!="!==e;return class r{constructor(e,t,i){this.type=Be,this.lhs=e,this.rhs=t,this.collator=i,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind}static parse(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");const i=e[0];let o=t.parse(e[1],1,Ue);if(!o)return null;if(!_i(i,o.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${Ke(o.type)}'.`);let s=t.parse(e[2],2,Ue);if(!s)return null;if(!_i(i,s.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${Ke(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error(`Cannot compare types '${Ke(o.type)}' and '${Ke(s.type)}'.`);n&&("value"===o.type.kind&&"value"!==s.type.kind?o=new Ht(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new Ht(o.type,[s])));let a=null;if(4===e.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error("Cannot use collator to compare non-string types.");if(a=t.parse(e[3],3,qe),!a)return null}return new r(o,s,a)}evaluate(r){const o=this.lhs.evaluate(r),s=this.rhs.evaluate(r);if(n&&this.hasUntypedArgument){const t=Ut(o),i=Ut(s);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new Ft(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${i.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const e=Ut(o),i=Ut(s);if("string"!==e.kind||"string"!==i.kind)return t(r,o,s)}return this.collator?i(r,o,s,this.collator.evaluate(r)):t(r,o,s)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}const bi=xi("==",function(e,t,i){return t===i},vi),wi=xi("!=",function(e,t,i){return t!==i},function(e,t,i,n){return!vi(0,t,i,n)}),Ei=xi("<",function(e,t,i){return t<i},function(e,t,i,n){return n.compare(t,i)<0}),Ti=xi(">",function(e,t,i){return t>i},function(e,t,i,n){return n.compare(t,i)>0}),Si=xi("<=",function(e,t,i){return t<=i},function(e,t,i,n){return n.compare(t,i)<=0}),Ii=xi(">=",function(e,t,i){return t>=i},function(e,t,i,n){return n.compare(t,i)>=0});class ki{constructor(e,t,i){this.type=qe,this.locale=i,this.caseSensitive=e,this.diacriticSensitive=t}static parse(e,t){if(2!==e.length)return t.error("Expected one argument.");const i=e[1];if("object"!=typeof i||Array.isArray(i))return t.error("Collator options argument must be an object.");const n=t.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,Be);if(!n)return null;const r=t.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,Be);if(!r)return null;let o=null;return i.locale&&(o=t.parse(i.locale,1,Ne),!o)?null:new ki(n,r,o)}evaluate(e){return new Ct(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}class Mi{constructor(e,t,i,n,r,o){this.type=Ne,this.number=e,this.locale=t,this.currency=i,this.unit=n,this.minFractionDigits=r,this.maxFractionDigits=o}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,Oe);if(!i)return null;const n=e[2];if("object"!=typeof n||Array.isArray(n))return t.error("NumberFormat options argument must be an object.");let r=null;if(n.locale&&(r=t.parse(n.locale,1,Ne),!r))return null;let o=null;if(n.currency&&(o=t.parse(n.currency,1,Ne),!o))return null;let s=null;if(n.unit&&(s=t.parse(n.unit,1,Ne),!s))return null;if(o&&s)return t.error("NumberFormat options `currency` and `unit` are mutually exclusive");let a=null;if(n["min-fraction-digits"]&&(a=t.parse(n["min-fraction-digits"],1,Oe),!a))return null;let l=null;return n["max-fraction-digits"]&&(l=t.parse(n["max-fraction-digits"],1,Oe),!l)?null:new Mi(i,r,o,s,a,l)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":this.unit?"unit":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class Ci{constructor(e){this.type=Ze,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[1];if(!Array.isArray(i)&&"object"==typeof i)return t.error("First argument must be an image or text section.");const n=[];let r=!1;for(let i=1;i<=e.length-1;++i){const o=e[i];if(r&&"object"==typeof o&&!Array.isArray(o)){r=!1;let e=null;if(o["font-scale"]&&(e=t.parse(o["font-scale"],1,Oe),!e))return null;let i=null;if(o["text-font"]&&(i=t.parse(o["text-font"],1,Je(Ne)),!i))return null;let s=null;if(o["text-color"]&&(s=t.parse(o["text-color"],1,Ge),!s))return null;let a=null;if(o["vertical-align"]){if("string"==typeof o["vertical-align"]&&!Pt.includes(o["vertical-align"]))return t.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${o["vertical-align"]}' instead.`);if(a=t.parse(o["vertical-align"],1,Ne),!a)return null}const l=n[n.length-1];l.scale=e,l.font=i,l.textColor=s,l.verticalAlign=a}else{const o=t.parse(e[i],1,Ue);if(!o)return null;const s=o.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");r=!0,n.push({content:o,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Ci(n)}evaluate(e){return new Lt(this.sections.map(t=>{const i=t.content.evaluate(e);return Ut(i)===Xe?new At("",i,null,null,null,t.verticalAlign?t.verticalAlign.evaluate(e):null):new At(qt(i),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null,t.verticalAlign?t.verticalAlign.evaluate(e):null)}))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor),t.verticalAlign&&e(t.verticalAlign)}outputDefined(){return!1}}class Pi{constructor(e){this.type=Xe,this.input=e}static parse(e,t){if(2!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,Ne);return i?new Pi(i):t.error("No image name provided.")}evaluate(e){const t=this.input.evaluate(e),i=Bt.fromString(t);return i&&e.availableImages&&(i.available=e.availableImages.indexOf(t)>-1),i}eachChild(e){e(this.input)}outputDefined(){return!1}}class Ai{constructor(e){this.type=Oe,this.input=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=t.parse(e[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?t.error(`Expected argument of type string or array, but found ${Ke(i.type)} instead.`):new Ai(i):null}evaluate(e){const t=this.input.evaluate(e);if("string"==typeof t)return[...t].length;if(Array.isArray(t))return t.length;throw new Ft(`Expected value to be of type string or array, but found ${Ke(Ut(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const Li=8192;function Di(e,t){const i=(180+e[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,r=Math.pow(2,t.z);return[Math.round(i*r*Li),Math.round(n*r*Li)]}function Ri(e,t){const i=Math.pow(2,t.z);return[(r=(e[0]/Li+t.x)/i,360*r-180),(n=(e[1]/Li+t.y)/i,360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90)];var n,r}function zi(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.max(e[2],t[0]),e[3]=Math.max(e[3],t[1])}function Fi(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function Oi(e,t,i){const n=e[0]-t[0],r=e[1]-t[1],o=e[0]-i[0],s=e[1]-i[1];return n*s-o*r==0&&n*o<=0&&r*s<=0}function Ni(e,t,i,n){return 0!=(r=[n[0]-i[0],n[1]-i[1]])[0]*(o=[t[0]-e[0],t[1]-e[1]])[1]-r[1]*o[0]&&!(!qi(e,t,i,n)||!qi(i,n,e,t));var r,o}function Bi(e,t,i){for(const n of i)for(let i=0;i<n.length-1;++i)if(Ni(e,t,n[i],n[i+1]))return!0;return!1}function Gi(e,t,i=!1){let n=!1;for(const a of t)for(let t=0;t<a.length-1;t++){if(Oi(e,a[t],a[t+1]))return i;(o=a[t])[1]>(r=e)[1]!=(s=a[t+1])[1]>r[1]&&r[0]<(s[0]-o[0])*(r[1]-o[1])/(s[1]-o[1])+o[0]&&(n=!n)}var r,o,s;return n}function ji(e,t){for(const i of t)if(Gi(e,i))return!0;return!1}function Vi(e,t){for(const i of e)if(!Gi(i,t))return!1;for(let i=0;i<e.length-1;++i)if(Bi(e[i],e[i+1],t))return!1;return!0}function Ui(e,t){for(const i of t)if(Vi(e,i))return!0;return!1}function qi(e,t,i,n){const r=n[0]-i[0],o=n[1]-i[1],s=(e[0]-i[0])*o-r*(e[1]-i[1]),a=(t[0]-i[0])*o-r*(t[1]-i[1]);return s>0&&a<0||s<0&&a>0}function Zi(e,t,i){const n=[];for(let r=0;r<e.length;r++){const o=[];for(let n=0;n<e[r].length;n++){const s=Di(e[r][n],i);zi(t,s),o.push(s)}n.push(o)}return n}function $i(e,t,i){const n=[];for(let r=0;r<e.length;r++){const o=Zi(e[r],t,i);n.push(o)}return n}function Hi(e,t,i,n){if(e[0]<i[0]||e[0]>i[2]){const t=.5*n;let r=e[0]-i[0]>t?-n:i[0]-e[0]>t?n:0;0===r&&(r=e[0]-i[2]>t?-n:i[2]-e[0]>t?n:0),e[0]+=r}zi(t,e)}function Wi(e,t,i,n){const r=Math.pow(2,n.z)*Li,o=[n.x*Li,n.y*Li],s=[];for(const n of e)for(const e of n){const n=[e.x+o[0],e.y+o[1]];Hi(n,t,i,r),s.push(n)}return s}function Xi(e,t,i,n){const r=Math.pow(2,n.z)*Li,o=[n.x*Li,n.y*Li],s=[];for(const i of e){const e=[];for(const n of i){const i=[n.x+o[0],n.y+o[1]];zi(t,i),e.push(i)}s.push(e)}if(t[2]-t[0]<=r/2){(a=t)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const e of s)for(const n of e)Hi(n,t,i,r)}var a;return s}class Yi{constructor(e,t){this.type=Be,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Vt(e[1])){const t=e[1];if("FeatureCollection"===t.type){const e=[];for(const i of t.features){const{type:t,coordinates:n}=i.geometry;"Polygon"===t&&e.push(n),"MultiPolygon"===t&&e.push(...n)}if(e.length)return new Yi(t,{type:"MultiPolygon",coordinates:e})}else if("Feature"===t.type){const e=t.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new Yi(t,t.geometry)}else if("Polygon"===t.type||"MultiPolygon"===t.type)return new Yi(t,t)}return t.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,t){const i=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],r=e.canonicalID();if("Polygon"===t.type){const o=Zi(t.coordinates,n,r),s=Wi(e.geometry(),i,n,r);if(!Fi(i,n))return!1;for(const e of s)if(!Gi(e,o))return!1}if("MultiPolygon"===t.type){const o=$i(t.coordinates,n,r),s=Wi(e.geometry(),i,n,r);if(!Fi(i,n))return!1;for(const e of s)if(!ji(e,o))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const i=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],r=e.canonicalID();if("Polygon"===t.type){const o=Zi(t.coordinates,n,r),s=Xi(e.geometry(),i,n,r);if(!Fi(i,n))return!1;for(const e of s)if(!Vi(e,o))return!1}if("MultiPolygon"===t.type){const o=$i(t.coordinates,n,r),s=Xi(e.geometry(),i,n,r);if(!Fi(i,n))return!1;for(const e of s)if(!Ui(e,o))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let Ji=class{constructor(e=[],t=(e,t)=>e<t?-1:e>t?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:i}=this,n=t[e];for(;e>0;){const r=e-1>>1,o=t[r];if(i(n,o)>=0)break;t[e]=o,e=r}t[e]=n}_down(e){const{data:t,compare:i}=this,n=this.length>>1,r=t[e];for(;e<n;){let n=1+(e<<1);const o=n+1;if(o<this.length&&i(t[o],t[n])<0&&(n=o),i(t[n],r)>=0)break;t[e]=t[n],e=n}t[e]=r}};function Ki(e,t,i=0,n=e.length-1,r=en){for(;n>i;){if(n-i>600){const o=n-i+1,s=t-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);Ki(e,t,Math.max(i,Math.floor(t-s*l/o+c)),Math.min(n,Math.floor(t+(o-s)*l/o+c)),r)}const o=e[t];let s=i,a=n;for(Qi(e,i,t),r(e[n],o)>0&&Qi(e,i,n);s<a;){for(Qi(e,s,a),s++,a--;r(e[s],o)<0;)s++;for(;r(e[a],o)>0;)a--}0===r(e[i],o)?Qi(e,i,a):(a++,Qi(e,a,n)),a<=t&&(i=a+1),t<=a&&(n=a-1)}}function Qi(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function en(e,t){return e<t?-1:e>t?1:0}function tn(e,t){if(e.length<=1)return[e];const i=[];let n,r;for(const t of e){const e=rn(t);0!==e&&(t.area=Math.abs(e),void 0===r&&(r=e<0),r===e<0?(n&&i.push(n),n=[t]):n.push(t))}if(n&&i.push(n),t>1)for(let e=0;e<i.length;e++)i[e].length<=t||(Ki(i[e],t,1,i[e].length-1,nn),i[e]=i[e].slice(0,t));return i}function nn(e,t){return t.area-e.area}function rn(e){let t=0;for(let i,n,r=0,o=e.length,s=o-1;r<o;s=r++)i=e[r],n=e[s],t+=(n.x-i.x)*(i.y+n.y);return t}const on=1/298.257223563,sn=on*(2-on),an=Math.PI/180;class ln{constructor(e){const t=6378.137*an*1e3,i=Math.cos(e*an),n=1/(1-sn*(1-i*i)),r=Math.sqrt(n);this.kx=t*r*i,this.ky=t*r*n*(1-sn)}distance(e,t){const i=this.wrap(e[0]-t[0])*this.kx,n=(e[1]-t[1])*this.ky;return Math.sqrt(i*i+n*n)}pointOnLine(e,t){let i,n,r,o,s=1/0;for(let a=0;a<e.length-1;a++){let l=e[a][0],c=e[a][1],u=this.wrap(e[a+1][0]-l)*this.kx,h=(e[a+1][1]-c)*this.ky,d=0;0===u&&0===h||(d=(this.wrap(t[0]-l)*this.kx*u+(t[1]-c)*this.ky*h)/(u*u+h*h),d>1?(l=e[a+1][0],c=e[a+1][1]):d>0&&(l+=u/this.kx*d,c+=h/this.ky*d)),u=this.wrap(t[0]-l)*this.kx,h=(t[1]-c)*this.ky;const p=u*u+h*h;p<s&&(s=p,i=l,n=c,r=a,o=d)}return{point:[i,n],index:r,t:Math.max(0,Math.min(1,o))}}wrap(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}}function cn(e,t){return t[0]-e[0]}function un(e){return e[1]-e[0]+1}function hn(e,t){return e[1]>=e[0]&&e[1]<t}function dn(e,t){if(e[0]>e[1])return[null,null];const i=un(e);if(t){if(2===i)return[e,null];const t=Math.floor(i/2);return[[e[0],e[0]+t],[e[0]+t,e[1]]]}if(1===i)return[e,null];const n=Math.floor(i/2)-1;return[[e[0],e[0]+n],[e[0]+n+1,e[1]]]}function pn(e,t){if(!hn(t,e.length))return[1/0,1/0,-1/0,-1/0];const i=[1/0,1/0,-1/0,-1/0];for(let n=t[0];n<=t[1];++n)zi(i,e[n]);return i}function fn(e){const t=[1/0,1/0,-1/0,-1/0];for(const i of e)for(const e of i)zi(t,e);return t}function mn(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function gn(e,t,i){if(!mn(e)||!mn(t))return NaN;let n=0,r=0;return e[2]<t[0]&&(n=t[0]-e[2]),e[0]>t[2]&&(n=e[0]-t[2]),e[1]>t[3]&&(r=e[1]-t[3]),e[3]<t[1]&&(r=t[1]-e[3]),i.distance([0,0],[n,r])}function yn(e,t,i){const n=i.pointOnLine(t,e);return i.distance(e,n.point)}function _n(e,t,i,n,r){const o=Math.min(yn(e,[i,n],r),yn(t,[i,n],r)),s=Math.min(yn(i,[e,t],r),yn(n,[e,t],r));return Math.min(o,s)}function vn(e,t,i,n,r){if(!hn(t,e.length)||!hn(n,i.length))return 1/0;let o=1/0;for(let s=t[0];s<t[1];++s){const t=e[s],a=e[s+1];for(let e=n[0];e<n[1];++e){const n=i[e],s=i[e+1];if(Ni(t,a,n,s))return 0;o=Math.min(o,_n(t,a,n,s,r))}}return o}function xn(e,t,i,n,r){if(!hn(t,e.length)||!hn(n,i.length))return NaN;let o=1/0;for(let s=t[0];s<=t[1];++s)for(let t=n[0];t<=n[1];++t)if(o=Math.min(o,r.distance(e[s],i[t])),0===o)return o;return o}function bn(e,t,i){if(Gi(e,t,!0))return 0;let n=1/0;for(const r of t){const t=r[0],o=r[r.length-1];if(t!==o&&(n=Math.min(n,yn(e,[o,t],i)),0===n))return n;const s=i.pointOnLine(r,e);if(n=Math.min(n,i.distance(e,s.point)),0===n)return n}return n}function wn(e,t,i,n){if(!hn(t,e.length))return NaN;for(let n=t[0];n<=t[1];++n)if(Gi(e[n],i,!0))return 0;let r=1/0;for(let o=t[0];o<t[1];++o){const t=e[o],s=e[o+1];for(const e of i)for(let i=0,o=e.length,a=o-1;i<o;a=i++){const o=e[a],l=e[i];if(Ni(t,s,o,l))return 0;r=Math.min(r,_n(t,s,o,l,n))}}return r}function En(e,t){for(const i of e)for(const e of i)if(Gi(e,t,!0))return!0;return!1}function Tn(e,t,i,n=1/0){const r=fn(e),o=fn(t);if(n!==1/0&&gn(r,o,i)>=n)return n;if(Fi(r,o)){if(En(e,t))return 0}else if(En(t,e))return 0;let s=1/0;for(const n of e)for(let e=0,r=n.length,o=r-1;e<r;o=e++){const r=n[o],a=n[e];for(const e of t)for(let t=0,n=e.length,o=n-1;t<n;o=t++){const n=e[o],l=e[t];if(Ni(r,a,n,l))return 0;s=Math.min(s,_n(r,a,n,l,i))}}return s}function Sn(e,t,i,n,r,o){if(!o)return;const s=gn(pn(n,o),r,i);s<t&&e.push([s,o,[0,0]])}function In(e,t,i,n,r,o,s){if(!o||!s)return;const a=gn(pn(n,o),pn(r,s),i);a<t&&e.push([a,o,s])}function kn(e,t,i,n,r=1/0){let o=Math.min(n.distance(e[0],i[0][0]),r);if(0===o)return o;const s=new Ji([[0,[0,e.length-1],[0,0]]],cn),a=fn(i);for(;s.length>0;){const r=s.pop();if(r[0]>=o)continue;const l=r[1],c=t?50:100;if(un(l)<=c){if(!hn(l,e.length))return NaN;if(t){const t=wn(e,l,i,n);if(isNaN(t)||0===t)return t;o=Math.min(o,t)}else for(let t=l[0];t<=l[1];++t){const r=bn(e[t],i,n);if(o=Math.min(o,r),0===o)return 0}}else{const i=dn(l,t);Sn(s,o,n,e,a,i[0]),Sn(s,o,n,e,a,i[1])}}return o}function Mn(e,t,i,n,r,o=1/0){let s=Math.min(o,r.distance(e[0],i[0]));if(0===s)return s;const a=new Ji([[0,[0,e.length-1],[0,i.length-1]]],cn);for(;a.length>0;){const o=a.pop();if(o[0]>=s)continue;const l=o[1],c=o[2],u=t?50:100,h=n?50:100;if(un(l)<=u&&un(c)<=h){if(!hn(l,e.length)&&hn(c,i.length))return NaN;let o;if(t&&n)o=vn(e,l,i,c,r),s=Math.min(s,o);else if(t&&!n){const t=e.slice(l[0],l[1]+1);for(let e=c[0];e<=c[1];++e)if(o=yn(i[e],t,r),s=Math.min(s,o),0===s)return s}else if(!t&&n){const t=i.slice(c[0],c[1]+1);for(let i=l[0];i<=l[1];++i)if(o=yn(e[i],t,r),s=Math.min(s,o),0===s)return s}else o=xn(e,l,i,c,r),s=Math.min(s,o)}else{const o=dn(l,t),u=dn(c,n);In(a,s,r,e,i,o[0],u[0]),In(a,s,r,e,i,o[0],u[1]),In(a,s,r,e,i,o[1],u[0]),In(a,s,r,e,i,o[1],u[1])}}return s}function Cn(e){return"MultiPolygon"===e.type?e.coordinates.map(e=>({type:"Polygon",coordinates:e})):"MultiLineString"===e.type?e.coordinates.map(e=>({type:"LineString",coordinates:e})):"MultiPoint"===e.type?e.coordinates.map(e=>({type:"Point",coordinates:e})):[e]}class Pn{constructor(e,t){this.type=Oe,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Vt(e[1])){const t=e[1];if("FeatureCollection"===t.type)return new Pn(t,t.features.map(e=>Cn(e.geometry)).flat());if("Feature"===t.type)return new Pn(t,Cn(t.geometry));if("type"in t&&"coordinates"in t)return new Pn(t,Cn(t))}return t.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,t){const i=e.geometry(),n=i.flat().map(t=>Ri([t.x,t.y],e.canonical));if(0===i.length)return NaN;const r=new ln(n[0][1]);let o=1/0;for(const e of t){switch(e.type){case"Point":o=Math.min(o,Mn(n,!1,[e.coordinates],!1,r,o));break;case"LineString":o=Math.min(o,Mn(n,!1,e.coordinates,!0,r,o));break;case"Polygon":o=Math.min(o,kn(n,!1,e.coordinates,r,o))}if(0===o)return o}return o}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const i=e.geometry(),n=i.flat().map(t=>Ri([t.x,t.y],e.canonical));if(0===i.length)return NaN;const r=new ln(n[0][1]);let o=1/0;for(const e of t){switch(e.type){case"Point":o=Math.min(o,Mn(n,!0,[e.coordinates],!1,r,o));break;case"LineString":o=Math.min(o,Mn(n,!0,e.coordinates,!0,r,o));break;case"Polygon":o=Math.min(o,kn(n,!0,e.coordinates,r,o))}if(0===o)return o}return o}(e,this.geometries);if("Polygon"===e.geometryType())return function(e,t){const i=e.geometry();if(0===i.length||0===i[0].length)return NaN;const n=tn(i,0).map(t=>t.map(t=>t.map(t=>Ri([t.x,t.y],e.canonical)))),r=new ln(n[0][0][0][1]);let o=1/0;for(const e of t)for(const t of n){switch(e.type){case"Point":o=Math.min(o,kn([e.coordinates],!1,t,r,o));break;case"LineString":o=Math.min(o,kn(e.coordinates,!0,t,r,o));break;case"Polygon":o=Math.min(o,Tn(t,e.coordinates,r,o))}if(0===o)return o}return o}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class An{constructor(e){this.type=Ue,this.key=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=e[1];return null==i?t.error("Global state property must be defined."):"string"!=typeof i?t.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new An(i)}evaluate(e){var t;const i=null===(t=e.globals)||void 0===t?void 0:t.globalState;return i&&0!==Object.keys(i).length?xt(i,this.key):null}eachChild(){}outputDefined(){return!1}}const Ln={"==":bi,"!=":wi,">":Ti,"<":Ei,">=":Ii,"<=":Si,array:Ht,at:ti,boolean:Ht,case:oi,coalesce:yi,collator:ki,format:Ci,image:Pi,in:ii,"index-of":ni,interpolate:fi,"interpolate-hcl":fi,"interpolate-lab":fi,length:Ai,let:Qt,literal:Zt,match:ri,number:Ht,"number-format":Mi,object:Ht,slice:si,step:li,string:Ht,"to-boolean":Xt,"to-color":Xt,"to-number":Xt,"to-string":Xt,var:ei,within:Yi,distance:Pn,"global-state":An};class Dn{constructor(e,t,i,n){this.name=e,this.type=t,this._evaluate=i,this.args=n}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,t){const i=e[0],n=Dn.definitions[i];if(!n)return t.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const r=Array.isArray(n)?n[0]:n.type,o=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,s=o.filter(([t])=>!Array.isArray(t)||t.length===e.length-1);let a=null;for(const[n,o]of s){a=new Kt(t.registry,Nn,t.path,null,t.scope);const s=[];let l=!1;for(let t=1;t<e.length;t++){const i=e[t],r=Array.isArray(n)?n[t-1]:n.type,o=a.parse(i,1+s.length,r);if(!o){l=!0;break}s.push(o)}if(!l)if(Array.isArray(n)&&n.length!==s.length)a.error(`Expected ${n.length} arguments, but found ${s.length} instead.`);else{for(let e=0;e<s.length;e++){const t=Array.isArray(n)?n[e]:n.type,i=s[e];a.concat(e+1).checkSubtype(t,i.type)}if(0===a.errors.length)return new Dn(i,r,o,s)}}if(1===s.length)t.errors.push(...a.errors);else{const i=(s.length?s:o).map(([e])=>{return t=e,Array.isArray(t)?`(${t.map(Ke).join(", ")})`:`(${Ke(t.type)}...)`;var t}).join(" | "),n=[];for(let i=1;i<e.length;i++){const r=t.parse(e[i],1+n.length);if(!r)return null;n.push(Ke(r.type))}t.error(`Expected arguments of type ${i}, but found (${n.join(", ")}) instead.`)}return null}static register(e,t){Dn.definitions=t;for(const i in t)e[i]=Dn}}function Rn(e,[t,i,n,r]){t=t.evaluate(e),i=i.evaluate(e),n=n.evaluate(e);const o=r?r.evaluate(e):1,s=jt(t,i,n,o);if(s)throw new Ft(s);return new Mt(t/255,i/255,n/255,o,!1)}function zn(e,t){return e in t}function Fn(e,t){const i=t[e];return void 0===i?null:i}function On(e){return{type:e}}function Nn(e){if(e instanceof ei)return Nn(e.boundExpression);if(e instanceof Dn&&"error"===e.name)return!1;if(e instanceof ki)return!1;if(e instanceof Yi)return!1;if(e instanceof Pn)return!1;if(e instanceof An)return!1;const t=e instanceof Xt||e instanceof Ht;let i=!0;return e.eachChild(e=>{i=t?i&&Nn(e):i&&e instanceof Zt}),!!i&&Bn(e)&&jn(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function Bn(e){if(e instanceof Dn){if("get"===e.name&&1===e.args.length)return!1;if("feature-state"===e.name)return!1;if("has"===e.name&&1===e.args.length)return!1;if("properties"===e.name||"geometry-type"===e.name||"id"===e.name)return!1;if(/^filter-/.test(e.name))return!1}if(e instanceof Yi)return!1;if(e instanceof Pn)return!1;let t=!0;return e.eachChild(e=>{t&&!Bn(e)&&(t=!1)}),t}function Gn(e){if(e instanceof Dn&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild(e=>{t&&!Gn(e)&&(t=!1)}),t}function jn(e,t){if(e instanceof Dn&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild(e=>{i&&!jn(e,t)&&(i=!1)}),i}function Vn(e){return{result:"success",value:e}}function Un(e){return{result:"error",value:e}}function qn(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function Zn(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function $n(e){return!!e.expression&&e.expression.interpolated}function Hn(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function Wn(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&Ut(e)===Ve}function Xn(e){return e}function Yn(e,t){const i=e.stops&&"object"==typeof e.stops[0][0],n=i||!(i||void 0!==e.property),r=e.type||($n(t)?"exponential":"interval"),o=function(e){switch(e.type){case"color":return Mt.parse;case"padding":return Dt.parse;case"numberArray":return Rt.parse;case"colorArray":return zt.parse;default:return null}}(t);if(o&&((e=De({},e)).stops&&(e.stops=e.stops.map(e=>[e[0],o(e[1])])),e.default=o(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==(s=e.colorSpace)&&"hcl"!==s&&"lab"!==s)throw new Error(`Unknown color space: "${e.colorSpace}"`);var s;const a=function(e){switch(e){case"exponential":return er;case"interval":return Qn;case"categorical":return Kn;case"identity":return tr;default:throw new Error(`Unknown function type "${e}"`)}}(r);let l,c;if("categorical"===r){l=Object.create(null);for(const t of e.stops)l[t[0]]=t[1];c=typeof e.stops[0][0]}if(i){const i={},n=[];for(let t=0;t<e.stops.length;t++){const r=e.stops[t],o=r[0].zoom;void 0===i[o]&&(i[o]={zoom:o,type:e.type,property:e.property,default:e.default,stops:[]},n.push(o)),i[o].stops.push([r[0].value,r[1]])}const r=[];for(const e of n)r.push([i[e].zoom,Yn(i[e],t)]);const o={name:"linear"};return{kind:"composite",interpolationType:o,interpolationFactor:fi.interpolationFactor.bind(void 0,o),zoomStops:r.map(e=>e[0]),evaluate:({zoom:i},n)=>er({stops:r,base:e.base},t,i).evaluate(i,n)}}if(n){const i="exponential"===r?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:fi.interpolationFactor.bind(void 0,i),zoomStops:e.stops.map(e=>e[0]),evaluate:({zoom:i})=>a(e,t,i,l,c)}}return{kind:"source",evaluate(i,n){const r=n&&n.properties?n.properties[e.property]:void 0;return void 0===r?Jn(e.default,t.default):a(e,t,r,l,c)}}}function Jn(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function Kn(e,t,i,n,r){return Jn(typeof i===r?n[i]:void 0,e.default,t.default)}function Qn(e,t,i){if("number"!==Hn(i))return Jn(e.default,t.default);const n=e.stops.length;if(1===n)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[n-1][0])return e.stops[n-1][1];const r=ai(e.stops.map(e=>e[0]),i);return e.stops[r][1]}function er(e,t,i){const n=void 0!==e.base?e.base:1;if("number"!==Hn(i))return Jn(e.default,t.default);const r=e.stops.length;if(1===r)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[r-1][0])return e.stops[r-1][1];const o=ai(e.stops.map(e=>e[0]),i),s=function(e,t,i,n){const r=n-i,o=e-i;return 0===r?0:1===t?o/r:(Math.pow(t,o)-1)/(Math.pow(t,r)-1)}(i,n,e.stops[o][0],e.stops[o+1][0]),a=e.stops[o][1],l=e.stops[o+1][1],c=gi[t.type]||Xn;return"function"==typeof a.evaluate?{evaluate(...t){const i=a.evaluate.apply(void 0,t),n=l.evaluate.apply(void 0,t);if(void 0!==i&&void 0!==n)return c(i,n,s,e.colorSpace)}}:c(a,l,s,e.colorSpace)}function tr(e,t,i){switch(t.type){case"color":i=Mt.parse(i);break;case"formatted":i=Lt.fromString(i.toString());break;case"resolvedImage":i=Bt.fromString(i.toString());break;case"padding":i=Dt.parse(i);break;case"colorArray":i=zt.parse(i);break;case"numberArray":i=Rt.parse(i);break;default:Hn(i)===t.type||"enum"===t.type&&t.values[i]||(i=void 0)}return Jn(i,e.default,t.default)}Dn.register(Ln,{error:[{kind:"error"},[Ne],(e,[t])=>{throw new Ft(t.evaluate(e))}],typeof:[Ne,[Ue],(e,[t])=>Ke(Ut(t.evaluate(e)))],"to-rgba":[Je(Oe,4),[Ge],(e,[t])=>{const[i,n,r,o]=t.evaluate(e).rgb;return[255*i,255*n,255*r,o]}],rgb:[Ge,[Oe,Oe,Oe],Rn],rgba:[Ge,[Oe,Oe,Oe,Oe],Rn],has:{type:Be,overloads:[[[Ne],(e,[t])=>zn(t.evaluate(e),e.properties())],[[Ne,Ve],(e,[t,i])=>zn(t.evaluate(e),i.evaluate(e))]]},get:{type:Ue,overloads:[[[Ne],(e,[t])=>Fn(t.evaluate(e),e.properties())],[[Ne,Ve],(e,[t,i])=>Fn(t.evaluate(e),i.evaluate(e))]]},"feature-state":[Ue,[Ne],(e,[t])=>Fn(t.evaluate(e),e.featureState||{})],properties:[Ve,[],e=>e.properties()],"geometry-type":[Ne,[],e=>e.geometryType()],id:[Ue,[],e=>e.id()],zoom:[Oe,[],e=>e.globals.zoom],"heatmap-density":[Oe,[],e=>e.globals.heatmapDensity||0],elevation:[Oe,[],e=>e.globals.elevation||0],"line-progress":[Oe,[],e=>e.globals.lineProgress||0],accumulated:[Ue,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[Oe,On(Oe),(e,t)=>{let i=0;for(const n of t)i+=n.evaluate(e);return i}],"*":[Oe,On(Oe),(e,t)=>{let i=1;for(const n of t)i*=n.evaluate(e);return i}],"-":{type:Oe,overloads:[[[Oe,Oe],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[Oe],(e,[t])=>-t.evaluate(e)]]},"/":[Oe,[Oe,Oe],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[Oe,[Oe,Oe],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[Oe,[],()=>Math.LN2],pi:[Oe,[],()=>Math.PI],e:[Oe,[],()=>Math.E],"^":[Oe,[Oe,Oe],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[Oe,[Oe],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[Oe,[Oe],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[Oe,[Oe],(e,[t])=>Math.log(t.evaluate(e))],log2:[Oe,[Oe],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[Oe,[Oe],(e,[t])=>Math.sin(t.evaluate(e))],cos:[Oe,[Oe],(e,[t])=>Math.cos(t.evaluate(e))],tan:[Oe,[Oe],(e,[t])=>Math.tan(t.evaluate(e))],asin:[Oe,[Oe],(e,[t])=>Math.asin(t.evaluate(e))],acos:[Oe,[Oe],(e,[t])=>Math.acos(t.evaluate(e))],atan:[Oe,[Oe],(e,[t])=>Math.atan(t.evaluate(e))],min:[Oe,On(Oe),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[Oe,On(Oe),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[Oe,[Oe],(e,[t])=>Math.abs(t.evaluate(e))],round:[Oe,[Oe],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[Oe,[Oe],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[Oe,[Oe],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[Be,[Ne,Ue],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[Be,[Ue],(e,[t])=>e.id()===t.value],"filter-type-==":[Be,[Ne],(e,[t])=>e.geometryType()===t.value],"filter-<":[Be,[Ne,Ue],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n<r}],"filter-id-<":[Be,[Ue],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i<n}],"filter->":[Be,[Ne,Ue],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n>r}],"filter-id->":[Be,[Ue],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i>n}],"filter-<=":[Be,[Ne,Ue],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n<=r}],"filter-id-<=":[Be,[Ue],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i<=n}],"filter->=":[Be,[Ne,Ue],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n>=r}],"filter-id->=":[Be,[Ue],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i>=n}],"filter-has":[Be,[Ue],(e,[t])=>t.value in e.properties()],"filter-has-id":[Be,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[Be,[Je(Ne)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[Be,[Je(Ue)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[Be,[Ne,Je(Ue)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[Be,[Ne,Je(Ue)],(e,[t,i])=>function(e,t,i,n){for(;i<=n;){const r=i+n>>1;if(t[r]===e)return!0;t[r]>e?n=r-1:i=r+1}return!1}(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:Be,overloads:[[[Be,Be],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[On(Be),(e,t)=>{for(const i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:Be,overloads:[[[Be,Be],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[On(Be),(e,t)=>{for(const i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[Be,[Be],(e,[t])=>!t.evaluate(e)],"is-supported-script":[Be,[Ne],(e,[t])=>{const i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[Ne,[Ne],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[Ne,[Ne],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[Ne,On(Ue),(e,t)=>t.map(t=>qt(t.evaluate(e))).join("")],split:[Je(Ne),[Ne,Ne],(e,[t,i])=>t.evaluate(e).split(i.evaluate(e))],join:[Ne,[Je(Ne),Ne],(e,[t,i])=>t.evaluate(e).join(i.evaluate(e))],"resolved-locale":[Ne,[qe],(e,[t])=>t.evaluate(e).resolvedLocale()]});class ir{constructor(e,t,i){this.expression=e,this._warningHistory={},this._evaluator=new Jt,this._defaultValue=t?function(e){if("color"===e.type&&Wn(e.default))return new Mt(0,0,0,0);switch(e.type){case"color":return Mt.parse(e.default)||null;case"padding":return Dt.parse(e.default)||null;case"numberArray":return Rt.parse(e.default)||null;case"colorArray":return zt.parse(e.default)||null;case"variableAnchorOffsetCollection":return Nt.parse(e.default)||null;case"projectionDefinition":return Gt.parse(e.default)||null;default:return void 0===e.default?null:e.default}}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null,this._globalState=i}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._globalState&&(e=hr(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=n,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=o,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,n,r,o){this._globalState&&(e=hr(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=n,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=o||null;try{const e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new Ft(`Expected value to be one of ${Object.keys(this._enumValues).map(e=>JSON.stringify(e)).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0),this._defaultValue}}}function nr(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in Ln}function rr(e,t,i){const n=new Kt(Ln,Nn,[],t?function(e){const t={color:Ge,string:Ne,number:Oe,enum:Ne,boolean:Be,formatted:Ze,padding:$e,numberArray:We,colorArray:He,projectionDefinition:je,resolvedImage:Xe,variableAnchorOffsetCollection:Ye};return"array"===e.type?Je(t[e.value]||Ue,e.length):t[e.type]}(t):void 0),r=n.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return r?Vn(new ir(r,t,i)):Un(n.errors)}class or{constructor(e,t,i){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!Gn(t.expression),this.globalStateRefs=ur(t.expression),this._globalState=i}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._globalState&&(e=hr(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,i,n,r,o)}evaluate(e,t,i,n,r,o){return this._globalState&&(e=hr(e,this._globalState)),this._styleExpression.evaluate(e,t,i,n,r,o)}}class sr{constructor(e,t,i,n,r){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!Gn(t.expression),this.globalStateRefs=ur(t.expression),this.interpolationType=n,this._globalState=r}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._globalState&&(e=hr(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,i,n,r,o)}evaluate(e,t,i,n,r,o){return this._globalState&&(e=hr(e,this._globalState)),this._styleExpression.evaluate(e,t,i,n,r,o)}interpolationFactor(e,t,i){return this.interpolationType?fi.interpolationFactor(this.interpolationType,e,t,i):0}}function ar(e,t,i){const n=rr(e,t,i);if("error"===n.result)return n;const r=n.value.expression,o=Bn(r);if(!o&&!qn(t))return Un([new Re("","data expressions not supported")]);const s=jn(r,["zoom"]);if(!s&&!Zn(t))return Un([new Re("","zoom expressions not supported")]);const a=cr(r);return a||s?a instanceof Re?Un([a]):a instanceof fi&&!$n(t)?Un([new Re("",'"interpolate" expressions cannot be used with this property')]):Vn(a?new sr(o?"camera":"composite",n.value,a.labels,a instanceof fi?a.interpolation:void 0,i):new or(o?"constant":"source",n.value,i)):Un([new Re("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class lr{constructor(e,t){this._parameters=e,this._specification=t,De(this,Yn(this._parameters,this._specification))}static deserialize(e){return new lr(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function cr(e){let t=null;if(e instanceof Qt)t=cr(e.result);else if(e instanceof yi){for(const i of e.args)if(t=cr(i),t)break}else(e instanceof li||e instanceof fi)&&e.input instanceof Dn&&"zoom"===e.input.name&&(t=e);return t instanceof Re||e.eachChild(e=>{const i=cr(e);i instanceof Re?t=i:!t&&i?t=new Re("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&i&&t!==i&&(t=new Re("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}function ur(e,t=new Set){return e instanceof An&&t.add(e.key),e.eachChild(e=>{ur(e,t)}),t}function hr(e,t){const{zoom:i,heatmapDensity:n,elevation:r,lineProgress:o,isSupportedScript:s,accumulated:a}=null!=e?e:{};return{zoom:i,heatmapDensity:n,elevation:r,lineProgress:o,isSupportedScript:s,accumulated:a,globalState:t}}function dr(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const t of e.slice(1))if(!dr(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}const pr={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function fr(e,t){if(null==e)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};dr(e)||(e=yr(e));const i=rr(e,pr,t);if("error"===i.result)throw new Error(i.value.map(e=>`${e.key}: ${e.message}`).join(", "));return{filter:(e,t,n)=>i.value.evaluate(e,t,{},n),needGeometry:gr(e),getGlobalStateRefs:()=>ur(i.value.expression)}}function mr(e,t){return e<t?-1:e>t?1:0}function gr(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let t=1;t<e.length;t++)if(gr(e[t]))return!0;return!1}function yr(e){if(!e)return!0;const t=e[0];return e.length<=1?"any"!==t:"=="===t?_r(e[1],e[2],"=="):"!="===t?br(_r(e[1],e[2],"==")):"<"===t||">"===t||"<="===t||">="===t?_r(e[1],e[2],t):"any"===t?(i=e.slice(1),["any"].concat(i.map(yr))):"all"===t?["all"].concat(e.slice(1).map(yr)):"none"===t?["all"].concat(e.slice(1).map(yr).map(br)):"in"===t?vr(e[1],e.slice(2)):"!in"===t?br(vr(e[1],e.slice(2))):"has"===t?xr(e[1]):"!has"!==t||br(xr(e[1]));var i}function _r(e,t,i){switch(e){case"$type":return[`filter-type-${i}`,t];case"$id":return[`filter-id-${i}`,t];default:return[`filter-${i}`,e,t]}}function vr(e,t){if(0===t.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some(e=>typeof e!=typeof t[0])?["filter-in-large",e,["literal",t.sort(mr)]]:["filter-in-small",e,["literal",t]]}}function xr(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function br(e){return["!",e]}function wr(e){const t=typeof e;if("number"===t||"boolean"===t||"string"===t||null==e)return JSON.stringify(e);if(Array.isArray(e)){let t="[";for(const i of e)t+=`${wr(i)},`;return`${t}]`}const i=Object.keys(e).sort();let n="{";for(let t=0;t<i.length;t++)n+=`${JSON.stringify(i[t])}:${wr(e[i[t]])},`;return`${n}}`}function Er(e){let t="";for(const i of be)t+=`/${wr(e[i])}`;return t}function Tr(e){const t=e.value;return t?[new Le(e.key,t,"constants have been deprecated as of v8")]:[]}function Sr(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function Ir(e){if(Array.isArray(e))return e.map(Ir);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const i in e)t[i]=Ir(e[i]);return t}return Sr(e)}function kr(e){const t=e.key,i=e.value,n=e.valueSpec||{},r=e.objectElementValidators||{},o=e.style,s=e.styleSpec,a=e.validateSpec;let l=[];const c=Hn(i);if("object"!==c)return[new Le(t,i,`object expected, ${c} found`)];for(const e in i){const c=e.split(".")[0],u=xt(n,c)||n["*"];let h;if(xt(r,c))h=r[c];else if(xt(n,c)){if(void 0===i[e])continue;h=a}else if(r["*"])h=r["*"];else{if(!n["*"]){l.push(new Le(t,i[e],`unknown property "${e}"`));continue}h=a}l=l.concat(h({key:(t?`${t}.`:t)+e,value:i[e],valueSpec:u,style:o,styleSpec:s,object:i,objectKey:e,validateSpec:a},i))}for(const e in n)r[e]||n[e].required&&void 0===n[e].default&&void 0===i[e]&&l.push(new Le(t,i,`missing required property "${e}"`));return l}function Mr(e){const t=e.value,i=e.valueSpec,n=e.style,r=e.styleSpec,o=e.key,s=e.arrayElementValidator||e.validateSpec;if("array"!==Hn(t))return[new Le(o,t,`array expected, ${Hn(t)} found`)];if(i.length&&t.length!==i.length)return[new Le(o,t,`array length ${i.length} expected, length ${t.length} found`)];let a={type:i.value,values:i.values};r.$version<7&&(a.function=i.function),"object"===Hn(i.value)&&(a=i.value);let l=[];for(let i=0;i<t.length;i++)l=l.concat(s({array:t,arrayIndex:i,value:t[i],valueSpec:a,validateSpec:e.validateSpec,style:n,styleSpec:r,key:`${o}[${i}]`}));return l}function Cr(e){const t=e.key,i=e.value,n=e.valueSpec;let r=Hn(i);return"number"===r&&i!=i&&(r="NaN"),"number"!==r?[new Le(t,i,`number expected, ${r} found`)]:"minimum"in n&&i<n.minimum?[new Le(t,i,`${i} is less than the minimum value ${n.minimum}`)]:"maximum"in n&&i>n.maximum?[new Le(t,i,`${i} is greater than the maximum value ${n.maximum}`)]:[]}function Pr(e){const t=e.valueSpec,i=Sr(e.value.type);let n,r,o,s={};const a="categorical"!==i&&void 0===e.value.property,l=!a,c="array"===Hn(e.value.stops)&&"array"===Hn(e.value.stops[0])&&"object"===Hn(e.value.stops[0][0]),u=kr({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===i)return[new Le(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const n=e.value;return t=t.concat(Mr({key:e.key,value:n,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:h})),"array"===Hn(n)&&0===n.length&&t.push(new Le(e.key,n,"array must have at least one stop")),t},default:function(e){return e.validateSpec({key:e.key,value:e.value,valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===i&&a&&u.push(new Le(e.key,e.value,'missing required property "property"')),"identity"===i||e.value.stops||u.push(new Le(e.key,e.value,'missing required property "stops"')),"exponential"===i&&e.valueSpec.expression&&!$n(e.valueSpec)&&u.push(new Le(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!qn(e.valueSpec)?u.push(new Le(e.key,e.value,"property functions not supported")):a&&!Zn(e.valueSpec)&&u.push(new Le(e.key,e.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==e.value.property||u.push(new Le(e.key,e.value,'"property" property is required')),u;function h(e){let i=[];const n=e.value,a=e.key;if("array"!==Hn(n))return[new Le(a,n,`array expected, ${Hn(n)} found`)];if(2!==n.length)return[new Le(a,n,`array length 2 expected, length ${n.length} found`)];if(c){if("object"!==Hn(n[0]))return[new Le(a,n,`object expected, ${Hn(n[0])} found`)];if(void 0===n[0].zoom)return[new Le(a,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new Le(a,n,"object stop key must have value")];if(o&&o>Sr(n[0].zoom))return[new Le(a,n[0].zoom,"stop zoom values must appear in ascending order")];Sr(n[0].zoom)!==o&&(o=Sr(n[0].zoom),r=void 0,s={}),i=i.concat(kr({key:`${a}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:Cr,value:d}}))}else i=i.concat(d({key:`${a}[0]`,value:n[0],validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},n));return nr(Ir(n[1]))?i.concat([new Le(`${a}[1]`,n[1],"expressions are not allowed in function stops.")]):i.concat(e.validateSpec({key:`${a}[1]`,value:n[1],valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function d(e,o){const a=Hn(e.value),l=Sr(e.value),c=null!==e.value?e.value:o;if(n){if(a!==n)return[new Le(e.key,c,`${a} stop domain type must match previous stop domain type ${n}`)]}else n=a;if("number"!==a&&"string"!==a&&"boolean"!==a)return[new Le(e.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==i){let n=`number expected, ${a} found`;return qn(t)&&void 0===i&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Le(e.key,c,n)]}return"categorical"!==i||"number"!==a||isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===a&&void 0!==r&&l<r?[new Le(e.key,c,"stop domain values must appear in ascending order")]:(r=l,"categorical"===i&&l in s?[new Le(e.key,c,"stop domain values must be unique")]:(s[l]=!0,[])):[new Le(e.key,c,`integer expected, found ${l}`)]}}function Ar(e){const t=("property"===e.expressionContext?ar:rr)(Ir(e.value),e.valueSpec);if("error"===t.result)return t.value.map(t=>new Le(`${e.key}${t.key}`,e.value,t.message));const i=t.value.expression||t.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!i.outputDefined())return[new Le(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===e.expressionContext&&"layout"===e.propertyType&&!Gn(i))return[new Le(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext&&!Gn(i))return[new Le(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!jn(i,["zoom","feature-state"]))return[new Le(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!Bn(i))return[new Le(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Lr(e){const t=e.key,i=e.value,n=Hn(i);return"string"!==n?[new Le(t,i,`color expected, ${n} found`)]:Mt.parse(String(i))?[]:[new Le(t,i,`color expected, "${i}" found`)]}function Dr(e){const t=e.key,i=e.value,n=e.valueSpec,r=[];return Array.isArray(n.values)?-1===n.values.indexOf(Sr(i))&&r.push(new Le(t,i,`expected one of [${n.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(n.values).indexOf(Sr(i))&&r.push(new Le(t,i,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(i)} found`)),r}function Rr(e){return dr(Ir(e.value))?Ar(De({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}})):zr(e)}function zr(e){const t=e.value,i=e.key;if("array"!==Hn(t))return[new Le(i,t,`array expected, ${Hn(t)} found`)];const n=e.styleSpec;let r,o=[];if(t.length<1)return[new Le(i,t,"filter array must have at least 1 element")];switch(o=o.concat(Dr({key:`${i}[0]`,value:t[0],valueSpec:n.filter_operator,style:e.style,styleSpec:e.styleSpec})),Sr(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&"$type"===Sr(t[1])&&o.push(new Le(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":3!==t.length&&o.push(new Le(i,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(r=Hn(t[1]),"string"!==r&&o.push(new Le(`${i}[1]`,t[1],`string expected, ${r} found`)));for(let s=2;s<t.length;s++)r=Hn(t[s]),"$type"===Sr(t[1])?o=o.concat(Dr({key:`${i}[${s}]`,value:t[s],valueSpec:n.geometry_type,style:e.style,styleSpec:e.styleSpec})):"string"!==r&&"number"!==r&&"boolean"!==r&&o.push(new Le(`${i}[${s}]`,t[s],`string, number, or boolean expected, ${r} found`));break;case"any":case"all":case"none":for(let n=1;n<t.length;n++)o=o.concat(zr({key:`${i}[${n}]`,value:t[n],style:e.style,styleSpec:e.styleSpec}));break;case"has":case"!has":r=Hn(t[1]),2!==t.length?o.push(new Le(i,t,`filter array for "${t[0]}" operator must have 2 elements`)):"string"!==r&&o.push(new Le(`${i}[1]`,t[1],`string expected, ${r} found`))}return o}function Fr(e,t){const i=e.key,n=e.validateSpec,r=e.style,o=e.styleSpec,s=e.value,a=e.objectKey,l=o[`${t}_${e.layerType}`];if(!l)return[];const c=a.match(/^(.*)-transition$/);if("paint"===t&&c&&l[c[1]]&&l[c[1]].transition)return n({key:i,value:s,valueSpec:o.transition,style:r,styleSpec:o});const u=e.valueSpec||l[a];if(!u)return[new Le(i,s,`unknown property "${a}"`)];let h;if("string"===Hn(s)&&qn(u)&&!u.tokens&&(h=/^{([^}]+)}$/.exec(s)))return[new Le(i,s,`"${a}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(h[1])} }\`.`)];const d=[];return"symbol"===e.layerType&&"text-font"===a&&Wn(Ir(s))&&"identity"===Sr(s.type)&&d.push(new Le(i,s,'"text-font" does not support identity functions')),d.concat(n({key:e.key,value:s,valueSpec:u,style:r,styleSpec:o,expressionContext:"property",propertyType:t,propertyKey:a}))}function Or(e){return Fr(e,"paint")}function Nr(e){return Fr(e,"layout")}function Br(e){var t,i;let n=[];const r=e.value,o=e.key,s=e.style,a=e.styleSpec;if("object"!==Hn(r))return[new Le(o,r,`object expected, ${Hn(r)} found`)];r.type||r.ref||n.push(new Le(o,r,'either "type" or "ref" is required'));let l=Sr(r.type);const c=Sr(r.ref);if(r.id){const t=Sr(r.id);for(let i=0;i<e.arrayIndex;i++){const e=s.layers[i];Sr(e.id)===t&&n.push(new Le(o,r.id,`duplicate layer id "${r.id}", previously used at line ${e.id.__line__}`))}}if("ref"in r){let e;["type","source","source-layer","filter","layout"].forEach(e=>{e in r&&n.push(new Le(o,r[e],`"${e}" is prohibited for ref layers`))}),s.layers.forEach(t=>{Sr(t.id)===c&&(e=t)}),e?e.ref?n.push(new Le(o,r.ref,"ref cannot reference another ref layer")):l=Sr(e.type):n.push(new Le(o,r.ref,`ref layer "${c}" not found`))}else if("background"!==l)if(r.source){const e=s.sources&&s.sources[r.source],t=e&&Sr(e.type);e?"vector"===t&&"raster"===l?n.push(new Le(o,r.source,`layer "${r.id}" requires a raster source`)):"raster-dem"!==t&&"hillshade"===l||"raster-dem"!==t&&"color-relief"===l?n.push(new Le(o,r.source,`layer "${r.id}" requires a raster-dem source`)):"raster"===t&&"raster"!==l?n.push(new Le(o,r.source,`layer "${r.id}" requires a vector source`)):"vector"!==t||r["source-layer"]?"raster-dem"===t&&"hillshade"!==l&&"color-relief"!==l?n.push(new Le(o,r.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"!==l||!r.paint||!r.paint["line-gradient"]||"geojson"===t&&e.lineMetrics||n.push(new Le(o,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):n.push(new Le(o,r,`layer "${r.id}" must specify a "source-layer"`)):n.push(new Le(o,r.source,`source "${r.source}" not found`))}else n.push(new Le(o,r,'missing required property "source"'));return"raster"===l&&(null===(t=r.paint)||void 0===t?void 0:t.resampling)&&(null===(i=r.paint)||void 0===i?void 0:i["raster-resampling"])&&n.push(new Le(o,r.paint,`layer "${r.id}" redundantly specifies "resampling" and "raster-resampling" paint properties, but only one is allowed. It is advised to use "resampling".`)),n=n.concat(kr({key:o,value:r,valueSpec:a.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${o}.type`,value:r.type,valueSpec:a.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:r,objectKey:"type"}),filter:Rr,layout:e=>kr({layer:r,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>Nr(De({layerType:l},e))}}),paint:e=>kr({layer:r,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>Or(De({layerType:l},e))}})}})),n}function Gr(e){const t=e.value,i=e.key,n=Hn(t);return"string"!==n?[new Le(i,t,`string expected, ${n} found`)]:[]}const jr={promoteId:function({key:e,value:t}){if("string"===Hn(t))return Gr({key:e,value:t});{const i=[];for(const n in t)i.push(...Gr({key:`${e}.${n}`,value:t[n]}));return i}}};function Vr(e){const t=e.value,i=e.key,n=e.styleSpec,r=e.style,o=e.validateSpec;if(!t.type)return[new Le(i,t,'"type" is required')];const s=Sr(t.type);let a;switch(s){case"vector":case"raster":return a=kr({key:i,value:t,valueSpec:n[`source_${s.replace("-","_")}`],style:e.style,styleSpec:n,objectElementValidators:jr,validateSpec:o}),a;case"raster-dem":return a=function(e){var t;const i=null!==(t=e.sourceName)&&void 0!==t?t:"",n=e.value,r=e.styleSpec,o=r.source_raster_dem,s=e.style;let a=[];const l=Hn(n);if(void 0===n)return a;if("object"!==l)return a.push(new Le("source_raster_dem",n,`object expected, ${l} found`)),a;const c="custom"===Sr(n.encoding),u=["redFactor","greenFactor","blueFactor","baseShift"],h=e.value.encoding?`"${e.value.encoding}"`:"Default";for(const t in n)!c&&u.includes(t)?a.push(new Le(t,n[t],`In "${i}": "${t}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):o[t]?a=a.concat(e.validateSpec({key:t,value:n[t],valueSpec:o[t],validateSpec:e.validateSpec,style:s,styleSpec:r})):a.push(new Le(t,n[t],`unknown property "${t}"`));return a}({sourceName:i,value:t,style:e.style,styleSpec:n,validateSpec:o}),a;case"geojson":if(a=kr({key:i,value:t,valueSpec:n.source_geojson,style:r,styleSpec:n,validateSpec:o,objectElementValidators:jr}),t.cluster)for(const e in t.clusterProperties){const[n,r]=t.clusterProperties[e],o="string"==typeof n?[n,["accumulated"],["get",e]]:n;a.push(...Ar({key:`${i}.${e}.map`,value:r,expressionContext:"cluster-map"})),a.push(...Ar({key:`${i}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return a;case"video":return kr({key:i,value:t,valueSpec:n.source_video,style:r,validateSpec:o,styleSpec:n});case"image":return kr({key:i,value:t,valueSpec:n.source_image,style:r,validateSpec:o,styleSpec:n});case"canvas":return[new Le(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Dr({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Ur(e){const t=e.value,i=e.styleSpec,n=i.light,r=e.style;let o=[];const s=Hn(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new Le("light",t,`object expected, ${s} found`)]),o;for(const s in t){const a=s.match(/^(.*)-transition$/);o=o.concat(a&&n[a[1]]&&n[a[1]].transition?e.validateSpec({key:s,value:t[s],valueSpec:i.transition,validateSpec:e.validateSpec,style:r,styleSpec:i}):n[s]?e.validateSpec({key:s,value:t[s],valueSpec:n[s],validateSpec:e.validateSpec,style:r,styleSpec:i}):[new Le(s,t[s],`unknown property "${s}"`)])}return o}function qr(e){const t=e.value,i=e.styleSpec,n=i.sky,r=e.style,o=Hn(t);if(void 0===t)return[];if("object"!==o)return[new Le("sky",t,`object expected, ${o} found`)];let s=[];for(const o in t)s=s.concat(n[o]?e.validateSpec({key:o,value:t[o],valueSpec:n[o],style:r,styleSpec:i}):[new Le(o,t[o],`unknown property "${o}"`)]);return s}function Zr(e){const t=e.value,i=e.styleSpec,n=i.terrain,r=e.style;let o=[];const s=Hn(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new Le("terrain",t,`object expected, ${s} found`)]),o;for(const s in t)o=o.concat(n[s]?e.validateSpec({key:s,value:t[s],valueSpec:n[s],validateSpec:e.validateSpec,style:r,styleSpec:i}):[new Le(s,t[s],`unknown property "${s}"`)]);return o}function $r(e){let t=[];const i=e.value,n=e.key;if(Array.isArray(i)){const r=[],o=[];for(const s in i)i[s].id&&r.includes(i[s].id)&&t.push(new Le(n,i,`all the sprites' ids must be unique, but ${i[s].id} is duplicated`)),r.push(i[s].id),i[s].url&&o.includes(i[s].url)&&t.push(new Le(n,i,`all the sprites' URLs must be unique, but ${i[s].url} is duplicated`)),o.push(i[s].url),t=t.concat(kr({key:`${n}[${s}]`,value:i[s],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return t}return Gr({key:n,value:i})}function Hr(e){return Boolean(e)&&e.constructor===Object}function Wr(e){return Hr(e.value)?[]:[new Le(e.key,e.value,`object expected, ${Hn(e.value)} found`)]}const Xr={"*":()=>[],array:Mr,boolean:function(e){const t=e.value,i=e.key,n=Hn(t);return"boolean"!==n?[new Le(i,t,`boolean expected, ${n} found`)]:[]},number:Cr,color:Lr,constants:Tr,enum:Dr,filter:Rr,function:Pr,layer:Br,object:kr,source:Vr,light:Ur,sky:qr,terrain:Zr,projection:function(e){const t=e.value,i=e.styleSpec,n=i.projection,r=e.style,o=Hn(t);if(void 0===t)return[];if("object"!==o)return[new Le("projection",t,`object expected, ${o} found`)];let s=[];for(const o in t)s=s.concat(n[o]?e.validateSpec({key:o,value:t[o],valueSpec:n[o],style:r,styleSpec:i}):[new Le(o,t[o],`unknown property "${o}"`)]);return s},projectionDefinition:function(e){const t=e.key;let i=e.value;i=i instanceof String?i.valueOf():i;const n=Hn(i);return"array"!==n||function(e){return Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]}(i)||function(e){return!!["interpolate","step","literal"].includes(e[0])}(i)?["array","string"].includes(n)?[]:[new Le(t,i,`projection expected, invalid type "${n}" found`)]:[new Le(t,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:Gr,formatted:function(e){return 0===Gr(e).length?[]:Ar(e)},resolvedImage:function(e){return 0===Gr(e).length?[]:Ar(e)},padding:function(e){const t=e.key,i=e.value;if("array"===Hn(i)){if(i.length<1||i.length>4)return[new Le(t,i,`padding requires 1 to 4 values; ${i.length} values found`)];const n={type:"number"};let r=[];for(let o=0;o<i.length;o++)r=r.concat(e.validateSpec({key:`${t}[${o}]`,value:i[o],validateSpec:e.validateSpec,valueSpec:n}));return r}return Cr({key:t,value:i,valueSpec:{}})},numberArray:function(e){const t=e.key,i=e.value;if("array"===Hn(i)){const n={type:"number"};if(i.length<1)return[new Le(t,i,"array length at least 1 expected, length 0 found")];let r=[];for(let o=0;o<i.length;o++)r=r.concat(e.validateSpec({key:`${t}[${o}]`,value:i[o],validateSpec:e.validateSpec,valueSpec:n}));return r}return Cr({key:t,value:i,valueSpec:{}})},colorArray:function(e){const t=e.key,i=e.value;if("array"===Hn(i)){if(i.length<1)return[new Le(t,i,"array length at least 1 expected, length 0 found")];let e=[];for(let n=0;n<i.length;n++)e=e.concat(Lr({key:`${t}[${n}]`,value:i[n]}));return e}return Lr({key:t,value:i})},variableAnchorOffsetCollection:function(e){const t=e.key,i=e.value,n=Hn(i),r=e.styleSpec;if("array"!==n||i.length<1||i.length%2!=0)return[new Le(t,i,"variableAnchorOffsetCollection requires a non-empty array of even length")];let o=[];for(let n=0;n<i.length;n+=2)o=o.concat(Dr({key:`${t}[${n}]`,value:i[n],valueSpec:r.layout_symbol["text-anchor"]})),o=o.concat(Mr({key:`${t}[${n+1}]`,value:i[n+1],valueSpec:{length:2,value:"number"},validateSpec:e.validateSpec,style:e.style,styleSpec:r}));return o},sprite:$r,state:Wr,fontFaces:function(e){const t=e.key,i=e.value,n=e.validateSpec,r=e.styleSpec,o=e.style;if(!Hr(i))return[new Le(t,i,`object expected, ${Hn(i)} found`)];const s=[];for(const e in i){const a=i[e],l=Hn(a);if("string"===l)s.push(...Gr({key:`${t}.${e}`,value:a}));else if("array"===l){const i={url:{type:"string",required:!0},"unicode-range":{type:"array",value:"string"}};for(const[l,c]of a.entries())s.push(...kr({key:`${t}.${e}[${l}]`,value:c,valueSpec:i,styleSpec:r,style:o,validateSpec:n}))}else s.push(new Le(`${t}.${e}`,a,`string or array expected, ${l} found`))}return s}};function Yr(e){const t=e.value,i=e.valueSpec,n=e.styleSpec;return e.validateSpec=Yr,i.expression&&Wn(Sr(t))?Pr(e):i.expression&&nr(Ir(t))?Ar(e):i.type&&Xr[i.type]?Xr[i.type](e):kr(De({},e,{valueSpec:i.type?n[i.type]:i}))}function Jr(e){const t=e.value,i=e.key,n=Gr(e);return n.length||(-1===t.indexOf("{fontstack}")&&n.push(new Le(i,t,'"glyphs" url must include a "{fontstack}" token')),-1===t.indexOf("{range}")&&n.push(new Le(i,t,'"glyphs" url must include a "{range}" token'))),n}function Kr(e,t=xe){let i=[];return i=i.concat(Yr({key:"",value:e,valueSpec:t.$root,styleSpec:t,style:e,validateSpec:Yr,objectElementValidators:{glyphs:Jr,"*":()=>[]}})),e.constants&&(i=i.concat(Tr({key:"constants",value:e.constants}))),eo(i)}function Qr(e){return function(t){return e(Object.assign({},t,{validateSpec:Yr}))}}function eo(e){return[].concat(e).sort((e,t)=>e.line-t.line)}function to(e){return function(...t){return eo(e.apply(this,t))}}Kr.source=to(Qr(Vr)),Kr.sprite=to(Qr($r)),Kr.glyphs=to(Qr(Jr)),Kr.light=to(Qr(Ur)),Kr.sky=to(Qr(qr)),Kr.terrain=to(Qr(Zr)),Kr.state=to(Qr(Wr)),Kr.layer=to(Qr(Br)),Kr.filter=to(Qr(Rr)),Kr.paintProperty=to(Qr(Or)),Kr.layoutProperty=to(Qr(Nr));const io={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"};class no{constructor(e,t){this._globalState=t,this.setValue(e)}evaluate(){var e;return null!==(e=this._literalValue)&&void 0!==e?e:this._compiledValue.evaluate({})}setValue(e){if(null==e||"visible"===e||"none"===e)return this._literalValue="none"===e?"none":"visible",this._compiledValue=void 0,void(this._globalStateRefs=new Set);const t=rr(e,io,this._globalState);if("error"===t.result)throw this._literalValue="visible",this._compiledValue=void 0,new Error(t.value.map(e=>`${e.key}: ${e.message}`).join(", "));this._literalValue=void 0,this._compiledValue=t.value,this._globalStateRefs=ur(t.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}}const ro=xe,oo=Kr,so=oo.light,ao=oo.sky,lo=oo.paintProperty,co=oo.layoutProperty;function uo(e,t){let i=!1;if(null==t?void 0:t.length)for(const n of t)e.fire(new _e(new Error(n.message))),i=!0;return i}class ho{constructor(e,t,i){const n=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const r=new Int32Array(this.arrayBuffer);e=r[0],this.d=(t=r[1])+2*(i=r[2]);for(let e=0;e<this.d*this.d;e++){const t=r[3+e],i=r[3+e+1];n.push(t===i?null:r.subarray(t,i))}const o=r[3+n.length+1];this.keys=r.subarray(r[3+n.length],o),this.bboxes=r.subarray(o),this.insert=this._insertReadonly}else{this.d=t+2*i;for(let e=0;e<this.d*this.d;e++)n.push([]);this.keys=[],this.bboxes=[]}this.n=t,this.extent=e,this.padding=i,this.scale=t/e,this.uid=0;const r=i/t*e;this.min=-r,this.max=e+r}insert(e,t,i,n,r){this._forEachCell(t,i,n,r,this._insertCell,this.uid++,void 0,void 0),this.keys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(n),this.bboxes.push(r)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(e,t,i,n,r,o){this.cells[r].push(o)}query(e,t,i,n,r){const o=this.min,s=this.max;if(e<=o&&t<=o&&s<=i&&s<=n&&!r)return[...this.keys];{const o=[];return this._forEachCell(e,t,i,n,this._queryCell,o,{},r),o}}_queryCell(e,t,i,n,r,o,s,a){const l=this.cells[r];if(null!==l){const r=this.keys,c=this.bboxes;for(const u of l)if(void 0===s[u]){const l=4*u;(a?a(c[l+0],c[l+1],c[l+2],c[l+3]):e<=c[l+2]&&t<=c[l+3]&&i>=c[l+0]&&n>=c[l+1])?(s[u]=!0,o.push(r[u])):s[u]=!1}}}_forEachCell(e,t,i,n,r,o,s,a){const l=this._convertToCellCoord(e),c=this._convertToCellCoord(t),u=this._convertToCellCoord(i),h=this._convertToCellCoord(n);for(let d=l;d<=u;d++)for(let l=c;l<=h;l++){const c=this.d*l+d;if((!a||a(this._convertFromCellCoord(d),this._convertFromCellCoord(l),this._convertFromCellCoord(d+1),this._convertFromCellCoord(l+1)))&&r.call(this,e,t,i,n,c,o,s,a))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const e=this.cells,t=3+this.cells.length+1+1;let i=0;for(const e of this.cells)i+=e.length;const n=new Int32Array(t+i+this.keys.length+this.bboxes.length);n[0]=this.extent,n[1]=this.n,n[2]=this.padding;let r=t;for(let t=0;t<e.length;t++){const i=e[t];n[3+t]=r,n.set(i,r),r+=i.length}return n[3+e.length]=r,n.set(this.keys,r),r+=this.keys.length,n[3+e.length+1]=r,n.set(this.bboxes,r),r+=this.bboxes.length,n.buffer}static serialize(e,t){const i=e.toArrayBuffer();return t&&t.push(i),{buffer:i}}static deserialize(e){return new ho(e.buffer)}}const po={};function fo(e,t,i={}){if(po[e])throw new Error(`${e} is already registered.`);Object.defineProperty(t,"_classRegistryKey",{value:e,writeable:!1}),po[e]={klass:t,omit:i.omit||[],shallow:i.shallow||[]}}fo("Object",Object),fo("Set",Set),fo("TransferableGridIndex",ho),fo("Color",Mt),fo("Error",Error),fo("AJAXError",he),fo("ResolvedImage",Bt),fo("StylePropertyFunction",lr),fo("StyleExpression",ir,{omit:["_evaluator"]}),fo("ZoomDependentExpression",sr),fo("ZoomConstantExpression",or),fo("CompoundExpression",Dn,{omit:["_evaluate"]});for(const e in Ln)Ln[e]._classRegistryKey||fo(`Expression_${e}`,Ln[e]);function mo(e){var t;return e&&"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||"ArrayBuffer"===(null===(t=e.constructor)||void 0===t?void 0:t.name))}function go(e){return e.$name||e.constructor._classRegistryKey}function yo(e){return!function(e){if(null===e||"object"!=typeof e)return!1;const t=go(e);return t&&"Object"!==t}(e)&&(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||e instanceof Blob||e instanceof Error||mo(e)||W(e)||ArrayBuffer.isView(e)||e instanceof ImageData)}function _o(e,t){if(yo(e))return(mo(e)||W(e))&&t&&t.push(e),ArrayBuffer.isView(e)&&t&&t.push(e.buffer),e instanceof ImageData&&t&&t.push(e.data.buffer),e;if(Array.isArray(e)){const i=[];for(const n of e)i.push(_o(n,t));return i}if("object"!=typeof e)throw new Error("can't serialize object of type "+typeof e);const i=go(e);if(!i)throw new Error(`can't serialize object of unregistered class ${e.constructor.name}`);if(!po[i])throw new Error(`${i} is not registered.`);const{klass:n}=po[i],r=n.serialize?n.serialize(e,t):{};if(n.serialize){if(r===(null==t?void 0:t[t.length-1]))throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const n in e){if(!e.hasOwnProperty(n))continue;if(po[i].omit.includes(n))continue;const o=e[n];r[n]=po[i].shallow.includes(n)?o:_o(o,t)}e instanceof Error&&(r.message=e.message)}if(r.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==i&&(r.$name=i),r}function vo(e){if(yo(e))return e;if(Array.isArray(e))return e.map(vo);if("object"!=typeof e)throw new Error("can't deserialize object of type "+typeof e);const t=go(e)||"Object";if(!po[t])throw new Error(`can't deserialize unregistered class ${t}`);const{klass:i}=po[t];if(!i)throw new Error(`can't deserialize unregistered class ${t}`);if(i.deserialize)return i.deserialize(e);const n=Object.create(i.prototype);for(const i of Object.keys(e)){if("$name"===i)continue;const r=e[i];n[i]=po[t].shallow.includes(i)?r:vo(r)}return n}class xo{constructor(){this.first=!0}update(e,t){const i=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=t):this.lastFloorZoom<i&&(this.lastIntegerZoom=i,this.lastIntegerZoomTime=t),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=i,!0))}}function bo(e){return/[\u02EA\u02EB\u2E80-\u2FDF\u2FF0-\u303F\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FD-\u30FF\u3105-\u312F\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))}function wo(e){return/[\u02EA\u02EB\u1100-\u11FF\u1400-\u167F\u18B0-\u18F5\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303F\u3041-\u3096\u309D-\u30FB\u30FD-\u30FF\u3105-\u312F\u3131-\u318E\u3190-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE48\uFE50-\uFE57\uFE5F-\uFE62\uFE67-\uFE6F\uFF00-\uFF07\uFF0A-\uFF0C\uFF0E-\uFF19\uFF1F-\uFF3A\uFF3C\uFF3E\uFF40-\uFF5A\uFFE0-\uFFE2\uFFE4-\uFFE7]|\uD802[\uDD80-\uDD9F]|\uD805[\uDD80-\uDDFF]|\uD806[\uDE00-\uDEBF]|\uD811[\uDC00-\uDE7F]|\uD81B[\uDFE0-\uDFE4\uDFF0-\uDFF6]|[\uD81C-\uD822\uD83D\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD30-\uDEFB]|\uD833[\uDEC0-\uDFCF]|\uD834[\uDC00-\uDDFF\uDEE0-\uDF7F]|\uD836[\uDC00-\uDEAF]|\uD83C[\uDC00-\uDE00\uDF00-\uDFFF]|\uD83E[\uDD00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))}function Eo(e){return/\s/u.test(String.fromCodePoint(e))}function To(e){for(const t of e)if(wo(t.codePointAt(0)))return!0;return!1}function So(e){for(const t of e)if(!Mo(t.codePointAt(0)))return!1;return!0}function Io(e){const t=e.map(e=>{try{return new RegExp(`\\p{sc=${e}}`,"u").source}catch(e){return null}}).filter(e=>e);return new RegExp(t.join("|"),"u")}const ko=Io(["Arab","Dupl","Mong","Ougr","Syrc"]);function Mo(e){return!ko.test(String.fromCodePoint(e))}function Co(e){return!(wo(e)||(t=e,/[\xA7\xA9\xAE\xB1\xBC-\xBE\xD7\xF7\u2016\u2020\u2021\u2030\u2031\u203B\u203C\u2042\u2047-\u2049\u2051\u2100-\u218F\u221E\u2234\u2235\u2300-\u2307\u230C-\u231F\u2324-\u2328\u232B\u237D-\u239A\u23BE-\u23CD\u23CF\u23D1-\u23DB\u23E2-\u2422\u2424-\u24FF\u25A0-\u2619\u2620-\u2767\u2776-\u2793\u2B12-\u2B2F\u2B50-\u2B59\u2BB8-\u2BEB\u3000-\u303F\u30A0-\u30FF\uE000-\uF8FF\uFE30-\uFE6F\uFF00-\uFFEF\uFFFC\uFFFD]|[\uDB80-\uDBFF][\uDC00-\uDFFF]/gim.test(String.fromCodePoint(t))));var t}const Po=Io(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function Ao(e){return Po.test(String.fromCodePoint(e))}function Lo(e,t){return!(!t&&Ao(e)||/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(e)))}function Do(e){for(const t of e)if(Ao(t.codePointAt(0)))return!0;return!1}const Ro=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(e){this.pluginStatus=e.pluginStatus,this.pluginURL=e.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(e){if(Ro.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=e.applyArabicShaping,this.processBidirectionalText=e.processBidirectionalText,this.processStyledBidirectionalText=e.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}syncState(e,i){return t(this,void 0,void 0,function*(){if(this.isParsed())return this.getState();if("loading"!==e.pluginStatus)return this.setState(e),e;const t=e.pluginURL,n=new Promise(e=>{this.loadScriptResolve=e});i(t);const r=new Promise(e=>setTimeout(()=>e(),this.TIMEOUT));if(yield Promise.race([n,r]),this.isParsed()){const e={pluginStatus:"loaded",pluginURL:t};return this.setState(e),e}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${t}`)})}};class zo{constructor(e,t){this.isSupportedScript=Fo,this.zoom=e,t?(this.now=t.now||0,this.fadeDuration=t.fadeDuration||0,this.zoomHistory=t.zoomHistory||new xo,this.transition=t.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new xo,this.transition={})}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,t=e-Math.floor(e),i=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:t+(1-t)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*t}}}function Fo(e){return function(e,t){for(const i of e)if(!Lo(i.codePointAt(0),t))return!1;return!0}(e,"loaded"===Ro.getRTLTextPluginStatus())}const Oo="-transition";class No{constructor(e,t,i){this.property=e,this.value=t,this.expression=function(e,t,i){if(Wn(e))return new lr(e,t);if(nr(e)){const n=ar(e,t,i);if("error"===n.result)throw new Error(n.value.map(e=>`${e.key}: ${e.message}`).join(", "));return n.value}{let i=e;return"color"===t.type&&"string"==typeof e?i=Mt.parse(e):"padding"!==t.type||"number"!=typeof e&&!Array.isArray(e)?"numberArray"!==t.type||"number"!=typeof e&&!Array.isArray(e)?"colorArray"!==t.type||"string"!=typeof e&&!Array.isArray(e)?"variableAnchorOffsetCollection"===t.type&&Array.isArray(e)?i=Nt.parse(e):"projectionDefinition"===t.type&&"string"==typeof e&&(i=Gt.parse(e)):i=zt.parse(e):i=Rt.parse(e):i=Dt.parse(e),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>i}}}(void 0===t?e.specification.default:t,e.specification,i)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(e,t,i){return this.property.possiblyEvaluate(this,e,t,i)}}class Bo{constructor(e,t){this.property=e,this.value=new No(e,void 0,t)}transitioned(e,t){return new jo(this.property,this.value,t,B({},e.transition,this.transition),e.now)}untransitioned(){return new jo(this.property,this.value,null,{},0)}}class Go{constructor(e,t){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=t}hasProperty(e){return e in this._properties.defaultTransitionablePropertyValues}getValue(e){return U(this._values[e].value.value)}setValue(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new Bo(this._values[e].property,this._globalState)),this._values[e].value=new No(this._values[e].property,null===t?void 0:U(t),this._globalState)}getTransition(e){return U(this._values[e].transition)}setTransition(e,t){Object.hasOwn(this._values,e)||(this._values[e]=new Bo(this._values[e].property,this._globalState)),this._values[e].transition=U(t)||void 0}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i);const n=this.getTransition(t);void 0!==n&&(e[`${t}${Oo}`]=n)}return e}transitioned(e,t){const i=new Vo(this._properties);for(const n of Object.keys(this._values))i._values[n]=this._values[n].transitioned(e,t._values[n]);return i}untransitioned(){const e=new Vo(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class jo{constructor(e,t,i,n,r){this.property=e,this.value=t,this.begin=r+n.delay||0,this.end=this.begin+n.duration||0,e.specification.transition&&(n.delay||n.duration)&&(this.prior=i)}possiblyEvaluate(e,t,i){const n=e.now||0,r=this.value.possiblyEvaluate(e,t,i),o=this.prior;if(o){if(n>this.end)return this.prior=null,r;if(this.value.isDataDriven())return this.prior=null,r;if(n<this.begin)return o.possiblyEvaluate(e,t,i);{const s=(n-this.begin)/(this.end-this.begin);return this.property.interpolate(o.possiblyEvaluate(e,t,i),r,R(s))}}return r}}class Vo{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,t,i){const n=new Zo(this._properties);for(const r of Object.keys(this._values))n._values[r]=this._values[r].possiblyEvaluate(e,t,i);return n}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class Uo{constructor(e,t){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._globalState=t}hasValue(e){return void 0!==this._values[e].value}hasProperty(e){return e in this._properties.defaultPropertyValues}getValue(e){return U(this._values[e].value)}setValue(e,t){this._values[e]=new No(this._values[e].property,null===t?void 0:U(t),this._globalState)}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i)}return e}possiblyEvaluate(e,t,i){const n=new Zo(this._properties);for(const r of Object.keys(this._values))n._values[r]=this._values[r].possiblyEvaluate(e,t,i);return n}}class qo{constructor(e,t,i){this.property=e,this.value=t,this.parameters=i}isConstant(){return"constant"===this.value.kind}constantOr(e){return"constant"===this.value.kind?this.value.value:e}evaluate(e,t,i,n){return this.property.evaluate(this.value,this.parameters,e,t,i,n)}}class Zo{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class $o{constructor(e){this.specification=e}possiblyEvaluate(e,t){if(e.isDataDriven())throw new Error("Value should not be data driven");return e.expression.evaluate(t)}interpolate(e,t,i){const n=gi[this.specification.type];return n?n(e,t,i):e}}class Ho{constructor(e,t){this.specification=e,this.overrides=t}possiblyEvaluate(e,t,i,n){return new qo(this,"constant"===e.expression.kind||"camera"===e.expression.kind?{kind:"constant",value:e.expression.evaluate(t,null,{},i,n)}:e.expression,t)}interpolate(e,t,i){if("constant"!==e.value.kind||"constant"!==t.value.kind)return e;if(void 0===e.value.value||void 0===t.value.value)return new qo(this,{kind:"constant",value:void 0},e.parameters);const n=gi[this.specification.type];if(n){const r=n(e.value.value,t.value.value,i);return new qo(this,{kind:"constant",value:r},e.parameters)}return e}evaluate(e,t,i,n,r,o){return"constant"===e.kind?e.value:e.evaluate(t,i,n,r,o)}}class Wo extends Ho{possiblyEvaluate(e,t,i,n){if(void 0===e.value)return new qo(this,{kind:"constant",value:void 0},t);if("constant"===e.expression.kind){const r=e.expression.evaluate(t,null,{},i,n),o="resolvedImage"===e.property.specification.type&&"string"!=typeof r?r.name:r,s=this._calculate(o,o,o,t);return new qo(this,{kind:"constant",value:s},t)}if("camera"===e.expression.kind){const i=this._calculate(e.expression.evaluate({zoom:t.zoom-1}),e.expression.evaluate({zoom:t.zoom}),e.expression.evaluate({zoom:t.zoom+1}),t);return new qo(this,{kind:"constant",value:i},t)}return new qo(this,e.expression,t)}evaluate(e,t,i,n,r,o){if("source"===e.kind){const s=e.evaluate(t,i,n,r,o);return this._calculate(s,s,s,t)}return"composite"===e.kind?this._calculate(e.evaluate({zoom:Math.floor(t.zoom)-1},i,n),e.evaluate({zoom:Math.floor(t.zoom)},i,n),e.evaluate({zoom:Math.floor(t.zoom)+1},i,n),t):e.value}_calculate(e,t,i,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}}class Xo{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,n){if(void 0!==e.value){if("constant"===e.expression.kind){const r=e.expression.evaluate(t,null,{},i,n);return this._calculate(r,r,r,t)}return this._calculate(e.expression.evaluate(new zo(Math.floor(t.zoom-1),t)),e.expression.evaluate(new zo(Math.floor(t.zoom),t)),e.expression.evaluate(new zo(Math.floor(t.zoom+1),t)),t)}}_calculate(e,t,i,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}}class Yo{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,n){return!!e.expression.evaluate(t,null,{},i,n)}interpolate(){return!1}}class Jo{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const t in e){const i=e[t];i.specification.overridable&&this.overridableProperties.push(t);const n=this.defaultPropertyValues[t]=new No(i,void 0,void 0),r=this.defaultTransitionablePropertyValues[t]=new Bo(i,void 0);this.defaultTransitioningPropertyValues[t]=r.untransitioned(),this.defaultPossiblyEvaluatedValues[t]=n.possiblyEvaluate({})}}}fo("DataDrivenProperty",Ho),fo("DataConstantProperty",$o),fo("CrossFadedDataDrivenProperty",Wo),fo("CrossFadedProperty",Xo),fo("ColorRampProperty",Yo);const Ko=" is a PAINT property not a LAYOUT property. Use get/setPaintProperty instead?",Qo=" is a LAYOUT property not a PAINT property. Use get/setLayoutProperty instead?";class es extends ve{constructor(e,t,i){if(super(),this.id=e.id,this.type=e.type,this._globalState=i,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},this._visibilityExpression=function(e,t){return new no(e,t)}(this.visibility,i),"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter,this._featureFilter=fr(e.filter,i)),t.layout&&(this._unevaluatedLayout=new Uo(t.layout,i)),t.paint)){this._transitionablePaint=new Go(t.paint,i);for(const t in e.paint)this.setPaintProperty(t,e.paint[t],{validate:!1});for(const t in e.layout)this.setLayoutProperty(t,e.layout[t],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Zo(t.paint)}}setFilter(e){this.filter=e,this._featureFilter=fr(e,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){var t;if("visibility"===e)return this.visibility;if(null===(t=this._transitionablePaint)||void 0===t?void 0:t.hasProperty(e))throw new Error(e+Ko);if(!this._unevaluatedLayout)throw new Error(`Cannot get layout property "${e}" on layer type "${this.type}" which has no layout properties.`);return this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){const e=new Set;for(const t of this._visibilityExpression.getGlobalStateRefs())e.add(t);if(this._unevaluatedLayout)for(const t in this._unevaluatedLayout._values){const i=this._unevaluatedLayout._values[t];for(const t of i.getGlobalStateRefs())e.add(t)}for(const t of this._featureFilter.getGlobalStateRefs())e.add(t);return e}getPaintAffectingGlobalStateRefs(){var e;const t=new globalThis.Map;if(this._transitionablePaint)for(const i in this._transitionablePaint._values){const n=this._transitionablePaint._values[i].value;for(const r of n.getGlobalStateRefs()){const o=null!==(e=t.get(r))&&void 0!==e?e:[];o.push({name:i,value:n.value}),t.set(r,o)}}return t}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(e,t,i={}){var n;if("visibility"===e)return this.visibility=t,this._visibilityExpression.setValue(t),void this.recalculateVisibility();(null===(n=this._transitionablePaint)||void 0===n?void 0:n.hasProperty(e))?this.fire(new _e(new Error(e+Ko))):null!=t&&this._validate(co,`layers.${this.id}.layout.${e}`,e,t,i)||this._unevaluatedLayout.setValue(e,t)}getPaintProperty(e){var t,i;if(e.endsWith(Oo)){const i=e.slice(0,-11);if("visibility"===i||(null===(t=this._unevaluatedLayout)||void 0===t?void 0:t.hasProperty(i)))throw new Error(e+Qo);return this._transitionablePaint.getTransition(i)}if("visibility"===e||(null===(i=this._unevaluatedLayout)||void 0===i?void 0:i.hasProperty(e)))throw new Error(e+Qo);return this._transitionablePaint.getValue(e)}setPaintProperty(e,t,i={}){var n;if("visibility"===e||(null===(n=this._unevaluatedLayout)||void 0===n?void 0:n.hasProperty(e)))return this.fire(new _e(new Error(e+Qo))),!1;if(null!=t&&this._validate(lo,`layers.${this.id}.paint.${e}`,e,t,i))return!1;if(e.endsWith(Oo))return this._transitionablePaint.setTransition(e.slice(0,-11),t||void 0),!1;{const i=this._transitionablePaint._values[e],n="cross-faded-data-driven"===i.property.specification["property-type"],r=i.value.isDataDriven(),o=i.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);const s=this._transitionablePaint._values[e].value;return s.isDataDriven()||r||n||this._handleOverridablePaintPropertyUpdate(e,o,s)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,t,i){return!1}isHidden(e=this.minzoom,t=!1){return!!(this.minzoom&&e<(t?Math.floor(this.minzoom):this.minzoom))||!!(this.maxzoom&&e>=this.maxzoom)||"none"===this._evaluatedVisibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculateVisibility(){this._evaluatedVisibility=this._visibilityExpression.evaluate()}recalculate(e,t){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){var e,t;const i={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:null===(e=this._unevaluatedLayout)||void 0===e?void 0:e.serialize(),paint:null===(t=this._transitionablePaint)||void 0===t?void 0:t.serialize()};return this.visibility&&(i.layout||(i.layout={}),i.layout.visibility=this.visibility),V(i,(e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length))}_validate(e,t,i,n,r={}){return!1!==(null==r?void 0:r.validate)&&uo(this,e.call(oo,{key:t,layerType:this.type,objectKey:i,value:n,styleSpec:xe,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof qo&&qn(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}}let ts;var is={get paint(){return ts=ts||new Jo({"raster-opacity":new $o(xe.paint_raster["raster-opacity"]),"raster-hue-rotate":new $o(xe.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new $o(xe.paint_raster["raster-brightness-min"]),"raster-brightness-max":new $o(xe.paint_raster["raster-brightness-max"]),"raster-saturation":new $o(xe.paint_raster["raster-saturation"]),"raster-contrast":new $o(xe.paint_raster["raster-contrast"]),resampling:new $o(xe.paint_raster.resampling),"raster-resampling":new $o(xe.paint_raster["raster-resampling"]),"raster-fade-duration":new $o(xe.paint_raster["raster-fade-duration"])})}};class ns extends es{constructor(e,t){super(e,is,t)}}const rs={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class os{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class ss{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,t._refreshViews(),t}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}freeBufferAfterUpload(){this.arrayBuffer=new ArrayBuffer(0),this._refreshViews()}}function as(e,t=1){let i=0,n=0;return{members:e.map(e=>{const r=rs[e.type].BYTES_PER_ELEMENT,o=i=ls(i,Math.max(t,r)),s=e.components||1;return n=Math.max(n,r),i+=r*s,{name:e.name,type:e.type,components:s,offset:o}}),size:ls(i,Math.max(n,t)),alignment:t}}function ls(e,t){return Math.ceil(e/t)*t}class cs extends ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const n=2*e;return this.int16[n+0]=t,this.int16[n+1]=i,e}}cs.prototype.bytesPerElement=4,fo("StructArrayLayout2i4",cs);class us extends ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.int16[r+0]=t,this.int16[r+1]=i,this.int16[r+2]=n,e}}us.prototype.bytesPerElement=6,fo("StructArrayLayout3i6",us);class hs extends ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=i,this.int16[o+2]=n,this.int16[o+3]=r,e}}hs.prototype.bytesPerElement=8,fo("StructArrayLayout4i8",hs);class ds extends ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=n,this.int16[a+3]=r,this.int16[a+4]=o,this.int16[a+5]=s,e}}ds.prototype.bytesPerElement=12,fo("StructArrayLayout2i4i12",ds);class ps extends ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=4*e,l=8*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.uint8[l+4]=n,this.uint8[l+5]=r,this.uint8[l+6]=o,this.uint8[l+7]=s,e}}ps.prototype.bytesPerElement=8,fo("StructArrayLayout2i4ub8",ps);class fs extends ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const n=2*e;return this.float32[n+0]=t,this.float32[n+1]=i,e}}fs.prototype.bytesPerElement=8,fo("StructArrayLayout2f8",fs);class ms extends ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,t,i,n,r,o,s,a,l,c)}emplace(e,t,i,n,r,o,s,a,l,c,u){const h=10*e;return this.uint16[h+0]=t,this.uint16[h+1]=i,this.uint16[h+2]=n,this.uint16[h+3]=r,this.uint16[h+4]=o,this.uint16[h+5]=s,this.uint16[h+6]=a,this.uint16[h+7]=l,this.uint16[h+8]=c,this.uint16[h+9]=u,e}}ms.prototype.bytesPerElement=20,fo("StructArrayLayout10ui20",ms);class gs extends ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,t,i,n,r,o,s,a)}emplace(e,t,i,n,r,o,s,a,l){const c=8*e;return this.uint16[c+0]=t,this.uint16[c+1]=i,this.uint16[c+2]=n,this.uint16[c+3]=r,this.uint16[c+4]=o,this.uint16[c+5]=s,this.uint16[c+6]=a,this.uint16[c+7]=l,e}}gs.prototype.bytesPerElement=16,fo("StructArrayLayout8ui16",gs);class ys extends ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c,u,h){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,i,n,r,o,s,a,l,c,u,h)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,d){const p=12*e;return this.int16[p+0]=t,this.int16[p+1]=i,this.int16[p+2]=n,this.int16[p+3]=r,this.uint16[p+4]=o,this.uint16[p+5]=s,this.uint16[p+6]=a,this.uint16[p+7]=l,this.int16[p+8]=c,this.int16[p+9]=u,this.int16[p+10]=h,this.int16[p+11]=d,e}}ys.prototype.bytesPerElement=24,fo("StructArrayLayout4i4ui4i24",ys);class _s extends ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.float32[r+0]=t,this.float32[r+1]=i,this.float32[r+2]=n,e}}_s.prototype.bytesPerElement=12,fo("StructArrayLayout3f12",_s);class vs extends ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint32[1*e+0]=t,e}}vs.prototype.bytesPerElement=4,fo("StructArrayLayout1ul4",vs);class xs extends ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,t,i,n,r,o,s,a,l)}emplace(e,t,i,n,r,o,s,a,l,c){const u=10*e,h=5*e;return this.int16[u+0]=t,this.int16[u+1]=i,this.int16[u+2]=n,this.int16[u+3]=r,this.int16[u+4]=o,this.int16[u+5]=s,this.uint32[h+3]=a,this.uint16[u+8]=l,this.uint16[u+9]=c,e}}xs.prototype.bytesPerElement=20,fo("StructArrayLayout6i1ul2ui20",xs);class bs extends ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=n,this.int16[a+3]=r,this.int16[a+4]=o,this.int16[a+5]=s,e}}bs.prototype.bytesPerElement=12,fo("StructArrayLayout2i2i2i12",bs);class ws extends ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,n,r)}emplace(e,t,i,n,r,o){const s=4*e,a=8*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=n,this.int16[a+6]=r,this.int16[a+7]=o,e}}ws.prototype.bytesPerElement=16,fo("StructArrayLayout2f1f2i16",ws);class Es extends ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=16*e,l=4*e,c=8*e;return this.uint8[a+0]=t,this.uint8[a+1]=i,this.float32[l+1]=n,this.float32[l+2]=r,this.int16[c+6]=o,this.int16[c+7]=s,e}}Es.prototype.bytesPerElement=16,fo("StructArrayLayout2ub2f2i16",Es);class Ts extends ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.uint16[r+0]=t,this.uint16[r+1]=i,this.uint16[r+2]=n,e}}Ts.prototype.bytesPerElement=6,fo("StructArrayLayout3ui6",Ts);class Ss extends ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g){const y=this.length;return this.resize(y+1),this.emplace(y,e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,y){const _=24*e,v=12*e,x=48*e;return this.int16[_+0]=t,this.int16[_+1]=i,this.uint16[_+2]=n,this.uint16[_+3]=r,this.uint32[v+2]=o,this.uint32[v+3]=s,this.uint32[v+4]=a,this.uint16[_+10]=l,this.uint16[_+11]=c,this.uint16[_+12]=u,this.float32[v+7]=h,this.float32[v+8]=d,this.uint8[x+36]=p,this.uint8[x+37]=f,this.uint8[x+38]=m,this.uint32[v+10]=g,this.int16[_+22]=y,e}}Ss.prototype.bytesPerElement=48,fo("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",Ss);class Is extends ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,y,_,v,x,b,w,E,T,S,I,k){const M=this.length;return this.resize(M+1),this.emplace(M,e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,y,_,v,x,b,w,E,T,S,I,k)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,y,_,v,x,b,w,E,T,S,I,k,M){const C=32*e,P=16*e;return this.int16[C+0]=t,this.int16[C+1]=i,this.int16[C+2]=n,this.int16[C+3]=r,this.int16[C+4]=o,this.int16[C+5]=s,this.int16[C+6]=a,this.int16[C+7]=l,this.uint16[C+8]=c,this.uint16[C+9]=u,this.uint16[C+10]=h,this.uint16[C+11]=d,this.uint16[C+12]=p,this.uint16[C+13]=f,this.uint16[C+14]=m,this.uint16[C+15]=g,this.uint16[C+16]=y,this.uint16[C+17]=_,this.uint16[C+18]=v,this.uint16[C+19]=x,this.uint16[C+20]=b,this.uint16[C+21]=w,this.uint16[C+22]=E,this.uint32[P+12]=T,this.float32[P+13]=S,this.float32[P+14]=I,this.uint16[C+30]=k,this.uint16[C+31]=M,e}}Is.prototype.bytesPerElement=64,fo("StructArrayLayout8i15ui1ul2f2ui64",Is);class ks extends ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.float32[1*e+0]=t,e}}ks.prototype.bytesPerElement=4,fo("StructArrayLayout1f4",ks);class Ms extends ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.uint16[6*e+0]=t,this.float32[r+1]=i,this.float32[r+2]=n,e}}Ms.prototype.bytesPerElement=12,fo("StructArrayLayout1ui2f12",Ms);class Cs extends ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=4*e;return this.uint32[2*e+0]=t,this.uint16[r+2]=i,this.uint16[r+3]=n,e}}Cs.prototype.bytesPerElement=8,fo("StructArrayLayout1ul2ui8",Cs);class Ps extends ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const n=2*e;return this.uint16[n+0]=t,this.uint16[n+1]=i,e}}Ps.prototype.bytesPerElement=4,fo("StructArrayLayout2ui4",Ps);class As extends ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint16[1*e+0]=t,e}}As.prototype.bytesPerElement=2,fo("StructArrayLayout1ui2",As);class Ls extends ss{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=n,this.float32[o+3]=r,e}}Ls.prototype.bytesPerElement=16,fo("StructArrayLayout4f16",Ls);class Ds extends os{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new i(this.anchorPointX,this.anchorPointY)}}Ds.prototype.size=20;class Rs extends xs{get(e){return new Ds(this,e)}}fo("CollisionBoxArray",Rs);class zs extends os{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}zs.prototype.size=48;class Fs extends Ss{get(e){return new zs(this,e)}}fo("PlacedSymbolArray",Fs);class Os extends os{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}Os.prototype.size=64;class Ns extends Is{get(e){return new Os(this,e)}}fo("SymbolInstanceArray",Ns);class Bs extends ks{getoffsetX(e){return this.float32[1*e+0]}}fo("GlyphOffsetArray",Bs);class Gs extends us{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}fo("SymbolLineVertexArray",Gs);class js extends os{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}js.prototype.size=12;class Vs extends Ms{get(e){return new js(this,e)}}fo("TextAnchorOffsetArray",Vs);class Us extends os{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}}Us.prototype.size=8;class qs extends Cs{get(e){return new Us(this,e)}}fo("FeatureIndexArray",qs);class Zs extends cs{}class $s extends cs{}class Hs extends cs{}class Ws extends ds{}class Xs extends ps{}class Ys extends fs{}class Js extends ms{}class Ks extends gs{}class Qs extends ys{}class ea extends _s{}class ta extends vs{}class ia extends bs{}class na extends Es{}class ra extends Ts{}class oa extends Ps{}const sa=as([{name:"a_pos",components:2,type:"Int16"}],4),{members:aa}=sa;class la{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,t,i,n){const r=this.segments[this.segments.length-1];return this._forceNewSegmentOnNextPrepare||!r||r.vertexLength+e>la.MAX_VERTEX_ARRAY_LENGTH||r.sortKey!==n?this.createNewSegment(t,i,n):r}createNewSegment(e,t,i){const n={vertexOffset:e.length,primitiveOffset:t.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==i&&(n.sortKey=i),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(n),n}getOrCreateLatestSegment(e,t,i){return this.prepareSegment(0,e,t,i)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy()}static simpleSegment(e,t,i,n){return new la([{vertexOffset:e,primitiveOffset:t,vertexLength:i,primitiveLength:n,vaos:{},sortKey:0}])}}function ca(e,t){return 256*(e=O(Math.floor(e),0,255))+O(Math.floor(t),0,255)}la.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,fo("SegmentVector",la);const ua=as([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]),ha=as([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var da,pa,fa,ma={exports:{}},ga={exports:{}},ya={exports:{}},_a=function(){if(fa)return ma.exports;fa=1;var e=(da||(da=1,ga.exports=function(e,t){var i,n,r,o,s,a,l,c;for(n=e.length-(i=3&e.length),r=t,s=3432918353,a=461845907,c=0;c<n;)l=255&e.charCodeAt(c)|(255&e.charCodeAt(++c))<<8|(255&e.charCodeAt(++c))<<16|(255&e.charCodeAt(++c))<<24,++c,r=27492+(65535&(o=5*(65535&(r=(r^=l=(65535&(l=(l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|r>>>19))+((5*(r>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&e.charCodeAt(c+2))<<16;case 2:l^=(255&e.charCodeAt(c+1))<<8;case 1:r^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(c)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return r^=e.length,r=2246822507*(65535&(r^=r>>>16))+((2246822507*(r>>>16)&65535)<<16)&4294967295,r=3266489909*(65535&(r^=r>>>13))+((3266489909*(r>>>16)&65535)<<16)&4294967295,(r^=r>>>16)>>>0}),ga.exports),t=(pa||(pa=1,ya.exports=function(e,t){for(var i,n=e.length,r=t^n,o=0;n>=4;)i=1540483477*(65535&(i=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(i>>>16)&65535)<<16),r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),n-=4,++o;switch(n){case 3:r^=(255&e.charCodeAt(o+2))<<16;case 2:r^=(255&e.charCodeAt(o+1))<<8;case 1:r=1540483477*(65535&(r^=255&e.charCodeAt(o)))+((1540483477*(r>>>16)&65535)<<16)}return r=1540483477*(65535&(r^=r>>>13))+((1540483477*(r>>>16)&65535)<<16),(r^=r>>>15)>>>0}),ya.exports);return ma.exports=e,ma.exports.murmur3=e,ma.exports.murmur2=t,ma.exports}(),va=n(_a);class xa{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,i,n){this.ids.push(ba(e)),this.positions.push(t,i,n)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const t=ba(e);let i=0,n=this.ids.length-1;for(;i<n;){const e=i+n>>1;this.ids[e]>=t?n=e:i=e+1}const r=[];for(;this.ids[i]===t;)r.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return r}static serialize(e,t){const i=new Float64Array(e.ids),n=new Uint32Array(e.positions);return wa(i,n,0,i.length-1),t&&t.push(i.buffer,n.buffer),{ids:i,positions:n}}static deserialize(e){const t=new xa;return t.ids=e.ids,t.positions=e.positions,t.indexed=!0,t}}function ba(e){const t=+e;return!isNaN(t)&&t<=Number.MAX_SAFE_INTEGER?t:va(String(e))}function wa(e,t,i,n){for(;i<n;){const r=e[i+n>>1];let o=i-1,s=n+1;for(;;){do{o++}while(e[o]<r);do{s--}while(e[s]>r);if(o>=s)break;Ea(e,o,s),Ea(t,3*o,3*s),Ea(t,3*o+1,3*s+1),Ea(t,3*o+2,3*s+2)}s-i<n-s?(wa(e,t,i,s),i=s+1):(wa(e,t,s+1,n),n=s)}}function Ea(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}fo("FeaturePositionMap",xa);class Ta{constructor(e,t){this.gl=e.gl,this.location=t}}class Sa extends Ta{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}}class Ia extends Ta{constructor(e,t){super(e,t),this.current=[0,0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]&&e[3]===this.current[3]||(this.current=e,this.gl.uniform4f(this.location,e[0],e[1],e[2],e[3]))}}class ka extends Ta{constructor(e,t){super(e,t),this.current=Mt.transparent}set(e){e.r===this.current.r&&e.g===this.current.g&&e.b===this.current.b&&e.a===this.current.a||(this.current=e,this.gl.uniform4f(this.location,e.r,e.g,e.b,e.a))}}const Ma=new Float32Array(16);function Ca(e){return[ca(255*e.r,255*e.g),ca(255*e.b,255*e.a)]}class Pa{constructor(e,t,i){this.value=e,this.uniformNames=t.map(e=>`u_${e}`),this.type=i}setUniform(e,t,i){e.set(i.constantOr(this.value))}getBinding(e,t,i){return"color"===this.type?new ka(e,t):new Sa(e,t)}}class Aa{constructor(e,t){this.uniformNames=t.map(e=>`u_${e}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,t){this.pixelRatioFrom=t.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=t.tlbr,this.patternTo=e.tlbr}setConstantDashPositions(e,t){this.dashTo=[0,e.y,e.height,e.width],this.dashFrom=[0,t.y,t.height,t.width]}setUniform(e,t,i,n){let r=null;"u_pattern_to"===n?r=this.patternTo:"u_pattern_from"===n?r=this.patternFrom:"u_dasharray_to"===n?r=this.dashTo:"u_dasharray_from"===n?r=this.dashFrom:"u_pixel_ratio_to"===n?r=this.pixelRatioTo:"u_pixel_ratio_from"===n&&(r=this.pixelRatioFrom),null!==r&&e.set(r)}getBinding(e,t,i){return i.startsWith("u_pattern")||i.startsWith("u_dasharray_")?new Ia(e,t):new Sa(e,t)}}class La{constructor(e,t,i,n){this.expression=e,this.type=i,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===i?2:1,offset:0})),this.paintVertexArray=new n}populatePaintArray(e,t,i){const n=this.paintVertexArray.length,r=this.expression.evaluate(new zo(0,i),t,{},i.canonical,[],i.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(n,e,r)}updatePaintArray(e,t,i,n,r){const o=this.expression.evaluate(new zo(0,r),i,n);this._setPaintValue(e,t,o)}_setPaintValue(e,t,i){if("color"===this.type){const n=Ca(i);for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,n[0],n[1])}else{for(let n=e;n<t;n++)this.paintVertexArray.emplace(n,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}upload(e){var t,i;(null===(t=this.paintVertexArray)||void 0===t?void 0:t.arrayBuffer.byteLength)&&((null===(i=this.paintVertexBuffer)||void 0===i?void 0:i.buffer)?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Da{constructor(e,t,i,n,r,o){this.expression=e,this.uniformNames=t.map(e=>`u_${e}_t`),this.type=i,this.useIntegerZoom=n,this.zoom=r,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===i?4:2,offset:0})),this.paintVertexArray=new o}populatePaintArray(e,t,i){const n=this.expression.evaluate(new zo(this.zoom,i),t,{},i.canonical,[],i.formattedSection),r=this.expression.evaluate(new zo(this.zoom+1,i),t,{},i.canonical,[],i.formattedSection),o=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(o,e,n,r)}updatePaintArray(e,t,i,n,r){const o=this.expression.evaluate(new zo(this.zoom,r),i,n),s=this.expression.evaluate(new zo(this.zoom+1,r),i,n);this._setPaintValue(e,t,o,s)}_setPaintValue(e,t,i,n){if("color"===this.type){const r=Ca(i),o=Ca(n);for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,r[0],r[1],o[0],o[1])}else{for(let r=e;r<t;r++)this.paintVertexArray.emplace(r,i,n);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(n))}}upload(e){var t,i;(null===(t=this.paintVertexArray)||void 0===t?void 0:t.arrayBuffer.byteLength)&&((null===(i=this.paintVertexBuffer)||void 0===i?void 0:i.buffer)?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,t){const i=this.useIntegerZoom?Math.floor(t.zoom):t.zoom,n=O(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);e.set(n)}getBinding(e,t,i){return new Sa(e,t)}}class Ra{constructor(e,t,i,n,r,o){this.expression=e,this.type=t,this.useIntegerZoom=i,this.zoom=n,this.layerId=o,this.zoomInPaintVertexArray=new r,this.zoomOutPaintVertexArray=new r}populatePaintArray(e,t,i){const n=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(n,e,this.getPositionIds(t),i)}updatePaintArray(e,t,i,n,r){this._setPaintValues(e,t,this.getPositionIds(i),r)}_setPaintValues(e,t,i,n){const r=this.getPositions(n);if(!r||!i)return;const o=r[i.min],s=r[i.mid],a=r[i.max];if(o&&s&&a)for(let i=e;i<t;i++)this.emplace(this.zoomInPaintVertexArray,i,s,o),this.emplace(this.zoomOutPaintVertexArray,i,s,a)}upload(e){var t,i;if((null===(t=this.zoomInPaintVertexArray)||void 0===t?void 0:t.arrayBuffer.byteLength)&&(null===(i=this.zoomOutPaintVertexArray)||void 0===i?void 0:i.arrayBuffer.byteLength)){const t=this.getVertexAttributes();this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,t,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,t,this.expression.isStateDependent)}}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class za extends Ra{getPositions(e){return e.imagePositions}getPositionIds(e){var t;return null===(t=e.patterns)||void 0===t?void 0:t[this.layerId]}getVertexAttributes(){return ua.members}emplace(e,t,i,n){e.emplace(t,i.tlbr[0],i.tlbr[1],i.tlbr[2],i.tlbr[3],n.tlbr[0],n.tlbr[1],n.tlbr[2],n.tlbr[3],i.pixelRatio,n.pixelRatio)}}class Fa extends Ra{getPositions(e){return e.dashPositions}getPositionIds(e){var t;return null===(t=e.dashes)||void 0===t?void 0:t[this.layerId]}getVertexAttributes(){return ha.members}emplace(e,t,i,n){e.emplace(t,0,i.y,i.height,i.width,0,n.y,n.height,n.width)}}class Oa{constructor(e,t,i){this.binders={},this._buffers=[];const n=[];for(const r in e.paint._values){if(!i(r))continue;const o=e.paint.get(r);if(!(o instanceof qo&&qn(o.property.specification)))continue;const s=Ba(r,e.type),a=o.value,l=o.property.specification.type,c=o.property.useIntegerZoom,u=o.property.specification["property-type"],h="cross-faded"===u||"cross-faded-data-driven"===u;if("constant"===a.kind)this.binders[r]=h?new Aa(a.value,s):new Pa(a.value,s,l),n.push(`/u_${r}`);else if("source"===a.kind||h){const i=Ga(r,l,"source");this.binders[r]=h?"line-dasharray"===r?new Fa(a,l,c,t,i,e.id):new za(a,l,c,t,i,e.id):new La(a,s,l,i),n.push(`/a_${r}`)}else{const e=Ga(r,l,"composite");this.binders[r]=new Da(a,s,l,c,t,e),n.push(`/z_${r}`)}}this.cacheKey=n.sort().join("")}getMaxValue(e){const t=this.binders[e];return t instanceof La||t instanceof Da?t.maxValue:0}populatePaintArrays(e,t,i){for(const n in this.binders){const r=this.binders[n];(r instanceof La||r instanceof Da||r instanceof Ra)&&r.populatePaintArray(e,t,i)}}setConstantPatternPositions(e,t){for(const i in this.binders){const n=this.binders[i];n instanceof Aa&&n.setConstantPatternPositions(e,t)}}setConstantDashPositions(e,t){for(const i in this.binders){const n=this.binders[i];n instanceof Aa&&n.setConstantDashPositions(e,t)}}updatePaintArrays(e,t,i,n,r){let o=!1;for(const s in e){const a=t.getPositions(s);for(const t of a){const a=i.feature(t.index);for(const i in this.binders){const l=this.binders[i];if((l instanceof La||l instanceof Da||l instanceof Ra)&&!0===l.expression.isStateDependent){const c=n.paint.get(i);l.expression=c.value,l.updatePaintArray(t.start,t.end,a,e[s],r),o=!0}}}}return o}defines(){const e=[];for(const t in this.binders){const i=this.binders[t];(i instanceof Pa||i instanceof Aa)&&e.push(...i.uniformNames.map(e=>`#define HAS_UNIFORM_${e}`))}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof La||i instanceof Da)for(const t of i.paintVertexAttributes)e.push(t.name);else if(i instanceof Ra){const t=i.getVertexAttributes();for(const i of t)e.push(i.name)}}return e}getBinderUniforms(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof Pa||i instanceof Aa||i instanceof Da)for(const t of i.uniformNames)e.push(t)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,t){const i=[];for(const n in this.binders){const r=this.binders[n];if(r instanceof Pa||r instanceof Aa||r instanceof Da)for(const o of r.uniformNames)if(t[o]){const s=r.getBinding(e,t[o],o);i.push({name:o,property:n,binding:s})}}return i}setUniforms(e,t,i,n){for(const{name:e,property:r,binding:o}of t)this.binders[r].setUniform(o,n,i.get(r),e)}updatePaintBuffers(e){this._buffers=[];for(const t in this.binders){const i=this.binders[t];if(e&&i instanceof Ra){const t=2===e.fromScale?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;t&&this._buffers.push(t)}else(i instanceof La||i instanceof Da)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(e){for(const t in this.binders){const i=this.binders[t];(i instanceof La||i instanceof Da||i instanceof Ra)&&i.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const t=this.binders[e];(t instanceof La||t instanceof Da||t instanceof Ra)&&t.destroy()}}}class Na{constructor(e,t,i=()=>!0){this.programConfigurations={};for(const n of e)this.programConfigurations[n.id]=new Oa(n,t,i);this.needsUpload=!1,this._featureMap=new xa,this._bufferOffset=0}populatePaintArrays(e,t,i,n){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(e,t,n);void 0!==t.id&&this._featureMap.add(t.id,i,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,i,n){for(const r of i)this.needsUpload=this.programConfigurations[r.id].updatePaintArrays(e,this._featureMap,t,r,n)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}function Ba(e,t){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-dasharray":["dasharray_to","dasharray_from"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}function Ga(e,t,i){const n={color:{source:fs,composite:Ls},number:{source:ks,composite:fs}},r=function(e){return{"line-pattern":{source:Js,composite:Js},"fill-pattern":{source:Js,composite:Js},"fill-extrusion-pattern":{source:Js,composite:Js},"line-dasharray":{source:Ks,composite:Ks}}[e]}(e);return(null==r?void 0:r[i])||n[t][i]}fo("ConstantBinder",Pa),fo("CrossFadedConstantBinder",Aa),fo("SourceExpressionBinder",La),fo("CrossFadedPatternBinder",za),fo("CrossFadedDasharrayBinder",Fa),fo("CompositeExpressionBinder",Da),fo("ProgramConfiguration",Oa,{omit:["_buffers"]}),fo("ProgramConfigurationSet",Na);const ja=Math.pow(2,14)-1,Va=-ja-1;function Ua(e){const t=C/e.extent,i=e.loadGeometry();for(const e of i)for(const i of e){const e=Math.round(i.x*t),n=Math.round(i.y*t);i.x=O(e,Va,ja),i.y=O(n,Va,ja)}return i}function qa(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Ua(e):[]}}const Za=-32768;function $a(e,t,i,n,r){e.emplaceBack(Za+8*t+n,Za+8*i+r)}class Ha{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new $s,this.indexArray=new ra,this.segments=new la,this.programConfigurations=new Na(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){const n=this.layers[0],r=[];let o=null,s=!1,a="heatmap"===n.type;if("circle"===n.type){const e=n;o=e.layout.get("circle-sort-key"),s=!o.isConstant(),a||(a="map"===e.paint.get("circle-pitch-alignment"))}const l=a?t.subdivisionGranularity.circle:1;for(const{feature:t,id:n,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=qa(t,e);if(!this.layers[0]._featureFilter.filter(new zo(this.zoom),c,i))continue;const u=s?o.evaluate(c,{},i):void 0,h={id:n,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Ua(t),patterns:{},sortKey:u};r.push(h)}s&&r.sort((e,t)=>e.sortKey-t.sortKey);for(const n of r){const{geometry:r,index:o,sourceLayerIndex:s}=n,a=e[o].feature;this.addFeature(n,r,o,i,l),t.featureIndex.insert(a,r,o,s,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,aa),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,t,i,n,r=1){let o;switch(r){case 1:o=[0,7];break;case 3:o=[0,2,5,7];break;case 5:o=[0,1,3,4,6,7];break;case 7:o=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${r}; valid values are 1, 3, 5, 7.`)}const s=o.length;for(const i of t)for(const t of i){const i=t.x,n=t.y;if(i<0||i>=C||n<0||n>=C)continue;const r=this.segments.prepareSegment(s*s,this.layoutVertexArray,this.indexArray,e.sortKey),a=r.vertexLength;for(let e=0;e<s;e++)for(let t=0;t<s;t++)$a(this.layoutVertexArray,i,n,o[t],o[e]);for(let e=0;e<s-1;e++)for(let t=0;t<s-1;t++){const i=a+e*s+t,n=a+(e+1)*s+t;this.indexArray.emplaceBack(i,n+1,i+1),this.indexArray.emplaceBack(i,n,n+1)}r.vertexLength+=s*s,r.primitiveLength+=(s-1)*(s-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:{},canonical:n})}}function Wa(e,t){for(const i of e)if(nl(t,i))return!0;for(const i of t)if(nl(e,i))return!0;return Ka(e,t)}function Xa(e,t,i){return!!nl(e,t)||el(t,e,i)}function Ya(e,t){if(1===e.length)return il(t,e[0]);for(const i of t)for(const t of i)if(nl(e,t))return!0;for(const i of e)if(il(t,i))return!0;for(const i of t)if(Ka(e,i))return!0;return!1}function Ja(e,t,i){if(e.length>1){if(Ka(e,t))return!0;for(const n of t)if(el(n,e,i))return!0}for(const n of e)if(el(n,t,i))return!0;return!1}function Ka(e,t){if(0===e.length||0===t.length)return!1;for(let i=0;i<e.length-1;i++){const n=e[i],r=e[i+1];for(let e=0;e<t.length-1;e++)if(Qa(n,r,t[e],t[e+1]))return!0}return!1}function Qa(e,t,i,n){return Z(e,i,n)!==Z(t,i,n)&&Z(e,t,i)!==Z(e,t,n)}function el(e,t,i){const n=i*i;if(1===t.length)return e.distSqr(t[0])<n;for(let i=1;i<t.length;i++)if(tl(e,t[i-1],t[i])<n)return!0;return!1}function tl(e,t,i){const n=t.distSqr(i);if(0===n)return e.distSqr(t);const r=((e.x-t.x)*(i.x-t.x)+(e.y-t.y)*(i.y-t.y))/n;return e.distSqr(r<0?t:r>1?i:i.sub(t)._mult(r)._add(t))}function il(e,t){let i,n,r,o=!1;for(const s of e){i=s;for(let e=0,s=i.length-1;e<i.length;s=e++)n=i[e],r=i[s],n.y>t.y!=r.y>t.y&&t.x<(r.x-n.x)*(t.y-n.y)/(r.y-n.y)+n.x&&(o=!o)}return o}function nl(e,t){let i=!1;for(let n=0,r=e.length-1;n<e.length;r=n++){const o=e[n],s=e[r];o.y>t.y!=s.y>t.y&&t.x<(s.x-o.x)*(t.y-o.y)/(s.y-o.y)+o.x&&(i=!i)}return i}function rl(e,t,i){const n=i[0],r=i[2];if(e.x<n.x&&t.x<n.x||e.x>r.x&&t.x>r.x||e.y<n.y&&t.y<n.y||e.y>r.y&&t.y>r.y)return!1;const o=Z(e,t,i[0]);return o!==Z(e,t,i[1])||o!==Z(e,t,i[2])||o!==Z(e,t,i[3])}function ol(e,t,i){const n=t.paint.get(e).value;return"constant"===n.kind?n.value:i.programConfigurations.get(t.id).getMaxValue(e)}function sl(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function al(e,t,n,r,o){if(!t[0]&&!t[1])return e;const s=i.convert(t)._mult(o);"viewport"===n&&s._rotate(-r);const a=[];for(const t of e)a.push(t.sub(s));return a}function ll(e){const t=[];for(let i=0;i<e.length;i++){const n=e[i],r=t.at(-1);(0===i||r&&!n.equals(r))&&t.push(n)}return t}function cl({queryGeometry:e,size:t},i){return Xa(e,i,t)}function ul({queryGeometry:e,size:t,transform:i,unwrappedTileID:n,getElevation:r},o){return Xa(e,o,t*(i.projectTileCoordinates(o.x,o.y,n,r).signedDistanceFromCamera/i.cameraToCenterDistance))}function hl({queryGeometry:e,size:t,transform:i,unwrappedTileID:n,getElevation:r},o){const s=i.projectTileCoordinates(o.x,o.y,n,r).signedDistanceFromCamera,a=t*(i.cameraToCenterDistance/s);return Xa(e,fl(o,i,n,r),a)}function dl({queryGeometry:e,size:t,transform:i,unwrappedTileID:n,getElevation:r},o){return Xa(e,fl(o,i,n,r),t)}function pl({queryGeometry:e,size:t,transform:i,unwrappedTileID:n,getElevation:r,pitchAlignment:o="map",pitchScale:s="map"},a){const l="map"===o?"map"===s?cl:ul:"map"===s?hl:dl,c={queryGeometry:e,size:t,transform:i,unwrappedTileID:n,getElevation:r};for(const e of a)for(const t of e)if(l(c,t))return!0;return!1}function fl(e,t,n,r){const o=t.projectTileCoordinates(e.x,e.y,n,r).point;return new i((.5*o.x+.5)*t.width,(.5*-o.y+.5)*t.height)}let ml,gl;fo("CircleBucket",Ha,{omit:["layers"]});var yl={get paint(){return gl=gl||new Jo({"circle-radius":new Ho(xe.paint_circle["circle-radius"]),"circle-color":new Ho(xe.paint_circle["circle-color"]),"circle-blur":new Ho(xe.paint_circle["circle-blur"]),"circle-opacity":new Ho(xe.paint_circle["circle-opacity"]),"circle-translate":new $o(xe.paint_circle["circle-translate"]),"circle-translate-anchor":new $o(xe.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new $o(xe.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new $o(xe.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Ho(xe.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Ho(xe.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Ho(xe.paint_circle["circle-stroke-opacity"])})},get layout(){return ml=ml||new Jo({"circle-sort-key":new Ho(xe.layout_circle["circle-sort-key"])})}};class _l extends es{constructor(e,t){super(e,yl,t)}createBucket(e){return new Ha(e)}queryRadius(e){const t=e;return ol("circle-radius",this,t)+ol("circle-stroke-width",this,t)+sl(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:n,transform:r,pixelsToTileUnits:o,unwrappedTileID:s,getElevation:a}){const l=al(e,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-r.bearingInRadians,o),c=this.paint.get("circle-radius").evaluate(t,i)+this.paint.get("circle-stroke-width").evaluate(t,i),u=this.paint.get("circle-pitch-scale"),h=this.paint.get("circle-pitch-alignment");let d,p;return"map"===h?(d=l,p=c*o):(d=function(e,t,i,n){return e.map(e=>fl(e,t,i,n))}(l,r,s,a),p=c),pl({queryGeometry:d,size:p,transform:r,unwrappedTileID:s,getElevation:a,pitchAlignment:h,pitchScale:u},n)}}class vl extends Ha{}let xl;fo("HeatmapBucket",vl,{omit:["layers"]});var bl={get paint(){return xl=xl||new Jo({"heatmap-radius":new Ho(xe.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Ho(xe.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new $o(xe.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Yo(xe.paint_heatmap["heatmap-color"]),"heatmap-opacity":new $o(xe.paint_heatmap["heatmap-opacity"])})}};function wl(e,{width:t,height:i},n,r){if(r){if(r instanceof Uint8ClampedArray)r=new Uint8Array(r.buffer);else if(r.length!==t*i*n)throw new RangeError(`mismatched image size. expected: ${r.length} but got: ${t*i*n}`)}else r=new Uint8Array(t*i*n);return e.width=t,e.height=i,e.data=r,e}function El(e,{width:t,height:i},n){if(t===e.width&&i===e.height)return;const r=wl({},{width:t,height:i},n);Tl(e,r,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,t),height:Math.min(e.height,i)},n),e.width=t,e.height=i,e.data=r.data}function Tl(e,t,i,n,r,o){if(0===r.width||0===r.height)return t;if(r.width>e.width||r.height>e.height||i.x>e.width-r.width||i.y>e.height-r.height)throw new RangeError("out of range source coordinates for image copy");if(r.width>t.width||r.height>t.height||n.x>t.width-r.width||n.y>t.height-r.height)throw new RangeError("out of range destination coordinates for image copy");const s=e.data,a=t.data;if(s===a)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l<r.height;l++){const c=((i.y+l)*e.width+i.x)*o,u=((n.y+l)*t.width+n.x)*o;for(let e=0;e<r.width*o;e++)a[u+e]=s[c+e]}return t}class Sl{constructor(e,t){wl(this,e,1,t)}resize(e){El(this,e,1)}clone(){return new Sl({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,n,r){Tl(e,t,i,n,r,1)}}class Il{constructor(e,t){wl(this,e,4,t)}resize(e){El(this,e,4)}replace(e,t){t?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new Il({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,n,r){Tl(e,t,i,n,r,4)}setPixel(e,t,i){const n=4*(e*this.width+t);this.data[n+0]=Math.round(255*i.r/i.a),this.data[n+1]=Math.round(255*i.g/i.a),this.data[n+2]=Math.round(255*i.b/i.a),this.data[n+3]=Math.round(255*i.a)}}function kl(e){const t=new Uint8Array(e.length);for(let i=0;i<e.length;i+=4){const n=e[i+3];t[i+0]=Math.round(e[i+0]*n/255),t[i+1]=Math.round(e[i+1]*n/255),t[i+2]=Math.round(e[i+2]*n/255),t[i+3]=n}return t}function Ml(e){const t={},i=e.resolution||256,n=e.clips?e.clips.length:1,r=e.image||new Il({width:i,height:n});if(Math.log(i)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${i}`);const o=(n,o,s)=>{t[e.evaluationKey]=s;const a=e.expression.evaluate(t);r.setPixel(n/4/i,o/4,a)};if(e.clips)for(let t=0,r=0;t<n;++t,r+=4*i)for(let n=0,s=0;n<i;n++,s+=4){const a=n/(i-1),{start:l,end:c}=e.clips[t];o(r,s,l*(1-a)+c*a)}else for(let e=0,t=0;e<i;e++,t+=4)o(0,t,e/(i-1));return r}fo("AlphaImage",Sl),fo("RGBAImage",Il);const Cl="big-fb";class Pl extends es{createBucket(e){return new vl(e)}constructor(e,t){super(e,bl,t),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Ml({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(Cl)&&this.heatmapFbos.delete(Cl)}queryRadius(e){return ol("heatmap-radius",this,e)}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:n,transform:r,pixelsToTileUnits:o,unwrappedTileID:s,getElevation:a}){return pl({queryGeometry:e,size:this.paint.get("heatmap-radius").evaluate(t,i)*o,transform:r,unwrappedTileID:s,getElevation:a},n)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&!this.isHidden()}}let Al;var Ll={get paint(){return Al=Al||new Jo({"hillshade-illumination-direction":new $o(xe.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-altitude":new $o(xe.paint_hillshade["hillshade-illumination-altitude"]),"hillshade-illumination-anchor":new $o(xe.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new $o(xe.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new $o(xe.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new $o(xe.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new $o(xe.paint_hillshade["hillshade-accent-color"]),"hillshade-method":new $o(xe.paint_hillshade["hillshade-method"]),resampling:new $o(xe.paint_hillshade.resampling)})}};class Dl extends es{constructor(e,t){super(e,Ll,t),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let e=this.paint.get("hillshade-illumination-direction").values,t=this.paint.get("hillshade-illumination-altitude").values,i=this.paint.get("hillshade-highlight-color").values,n=this.paint.get("hillshade-shadow-color").values;const r=Math.max(e.length,t.length,i.length,n.length);e=e.concat(Array(r-e.length).fill(e.at(-1))),t=t.concat(Array(r-t.length).fill(t.at(-1))),i=i.concat(Array(r-i.length).fill(i.at(-1))),n=n.concat(Array(r-n.length).fill(n.at(-1)));const o=t.map(ee);return{directionRadians:e.map(ee),altitudeRadians:o,shadowColor:n,highlightColor:i}}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&!this.isHidden()}}let Rl;var zl={get paint(){return Rl=Rl||new Jo({"color-relief-opacity":new $o(xe["paint_color-relief"]["color-relief-opacity"]),"color-relief-color":new Yo(xe["paint_color-relief"]["color-relief-color"]),resampling:new $o(xe["paint_color-relief"].resampling)})}};function Fl(e){return"data"in e}class Ol{constructor(e,t,i,n){this.context=e,this.format=i,this.texture=e.gl.createTexture(),this._ownedHandle=this.texture,this.update(t,n)}update(e,t,i){var n;const{width:r,height:o}=e,s=((null===(n=this.size)||void 0===n?void 0:n[0])!==r||this.size[1]!==o)&&!i,{context:a}=this,{gl:l}=a;this.useMipmap=Boolean(null==t?void 0:t.useMipmap),l.bindTexture(l.TEXTURE_2D,this.texture),a.pixelStoreUnpackFlipY.set(!1),a.pixelStoreUnpack.set(1);const c=this.format===l.RGBA&&!1!==(null==t?void 0:t.premultiply);if(s)this.size=[r,o],Fl(e)?(a.pixelStoreUnpackPremultiplyAlpha.set(!1),this._uploadRawData(e,c,r,o,l)):(a.pixelStoreUnpackPremultiplyAlpha.set(c),this._uploadDomImage(e,l));else{const{x:t,y:n}=i||{x:0,y:0};Fl(e)?(a.pixelStoreUnpackPremultiplyAlpha.set(!1),this._updateRawData(e,c,t,n,r,o,l)):(a.pixelStoreUnpackPremultiplyAlpha.set(c),this._updateDomImage(e,t,n,l))}this.useMipmap&&this.isSizePowerOfTwo()&&l.generateMipmap(l.TEXTURE_2D),a.pixelStoreUnpackFlipY.setDefault(),a.pixelStoreUnpack.setDefault(),a.pixelStoreUnpackPremultiplyAlpha.setDefault()}_uploadDomImage(e,t){t.texImage2D(t.TEXTURE_2D,0,this.format,this.format,t.UNSIGNED_BYTE,e)}_uploadRawData(e,t,i,n,r){let{data:o}=e;t&&o&&(o=kl(o)),r.texImage2D(r.TEXTURE_2D,0,this.format,i,n,0,this.format,r.UNSIGNED_BYTE,o)}_updateDomImage(e,t,i,n){n.texSubImage2D(n.TEXTURE_2D,0,t,i,n.RGBA,n.UNSIGNED_BYTE,e)}_updateRawData(e,t,i,n,r,o,s){let{data:a}=e;t&&a&&(a=kl(a)),s.texSubImage2D(s.TEXTURE_2D,0,i,n,r,o,s.RGBA,s.UNSIGNED_BYTE,a)}bind(e,t,i){const{context:n}=this,{gl:r}=n;this.texture!==this._ownedHandle&&(this.texture=this._ownedHandle),r.bindTexture(r.TEXTURE_2D,this.texture),i!==r.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(i=r.LINEAR),e!==this.filter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,i||e),this.filter=e),t!==this.wrap&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,t),this.wrap=t)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null,this._ownedHandle=null}}class Nl{constructor(e,t,i,n=1,r=1,o=1,s=0){if(this.uid=e,t.height!==t.width)throw new RangeError("DEM tiles must be square");if(i&&!["_mbx","terrarium","custom"].includes(i))return void q();this.stride=t.height;const a=this.dim=t.height-2;switch(this.data=new Uint32Array(t.data.buffer),i){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=n,this.greenFactor=r,this.blueFactor=o,this.baseShift=s;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let e=0;e<a;e++)this.data[this._idx(-1,e)]=this.data[this._idx(0,e)],this.data[this._idx(a,e)]=this.data[this._idx(a-1,e)],this.data[this._idx(e,-1)]=this.data[this._idx(e,0)],this.data[this._idx(e,a)]=this.data[this._idx(e,a-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(a,-1)]=this.data[this._idx(a-1,0)],this.data[this._idx(-1,a)]=this.data[this._idx(0,a-1)],this.data[this._idx(a,a)]=this.data[this._idx(a-1,a-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let e=0;e<a;e++)for(let t=0;t<a;t++){const i=this.get(e,t);i>this.max&&(this.max=i),i<this.min&&(this.min=i)}}get(e,t){const i=new Uint8Array(this.data.buffer),n=4*this._idx(e,t);return this.unpack(i[n],i[n+1],i[n+2])}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(e,t){if(e<-1||e>=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError(`Out of range source coordinates for DEM data. x: ${e}, y: ${t}, dim: ${this.dim}`);return(t+1)*this.stride+(e+1)}unpack(e,t,i){return e*this.redFactor+t*this.greenFactor+i*this.blueFactor-this.baseShift}pack(e){return Bl(e,this.getUnpackVector())}getPixels(){return new Il({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,t,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let n=t*this.dim,r=t*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(t){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-t*this.dim,l=-i*this.dim;for(let t=o;t<s;t++)for(let i=n;i<r;i++)this.data[this._idx(i,t)]=e.data[this._idx(i+a,t+l)]}}function Bl(e,t){const i=t[0],n=t[1],r=t[2],o=t[3],s=Math.min(i,n,r),a=Math.round((e+o)/s);return{r:Math.floor(a*s/i)%256,g:Math.floor(a*s/n)%256,b:Math.floor(a*s/r)%256}}fo("DEMData",Nl);class Gl extends es{constructor(e,t){super(e,zl,t)}_createColorRamp(e){const t={elevationStops:[],colorStops:[]},i=this._transitionablePaint._values["color-relief-color"].value.expression;if(i instanceof or&&i._styleExpression.expression instanceof fi){this.colorRampExpression=i;const e=i._styleExpression.expression;t.elevationStops=e.labels,t.colorStops=[];for(const i of t.elevationStops)t.colorStops.push(e.evaluate({globals:{elevation:i}}))}if(t.elevationStops.length<1&&(t.elevationStops=[0],t.colorStops=[Mt.transparent]),t.elevationStops.length<2&&(t.elevationStops.push(t.elevationStops[0]+1),t.colorStops.push(t.colorStops[0])),t.elevationStops.length<=e)return t;const n={elevationStops:[],colorStops:[]},r=(t.elevationStops.length-1)/(e-1);for(let e=0;e<t.elevationStops.length-.5;e+=r)n.elevationStops.push(t.elevationStops[Math.round(e)]),n.colorStops.push(t.colorStops[Math.round(e)]);return n}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values["color-relief-color"].value.expression}getColorRampTextures(e,t,i){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;const n=this._createColorRamp(t),r=new Il({width:n.colorStops.length,height:1}),o=new Il({width:n.colorStops.length,height:1});for(let e=0;e<n.elevationStops.length;e++){const t=Bl(n.elevationStops[e],i);o.setPixel(0,e,new Mt(t.r/255,t.g/255,t.b/255,1)),r.setPixel(0,e,n.colorStops[e])}return this.colorRampTextures={elevationTexture:new Ol(e,o,e.gl.RGBA),colorTexture:new Ol(e,r,e.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return!this.isHidden()&&!!this.colorRampTextures}}const jl=as([{name:"a_pos",components:2,type:"Int16"}],4),{members:Vl}=jl;function Ul(e,t,i){const n=i.patternDependencies;let r=!1;for(const i of t){const t=i.paint.get(`${e}-pattern`);t.isConstant()||(r=!0);const o=t.constantOr(null);o&&(r=!0,n[o.to]=!0,n[o.from]=!0)}return r}function ql(e,t,i,n,r){const{zoom:o}=n,s=r.patternDependencies;for(const n of t){const t=n.paint.get(`${e}-pattern`).value;if("constant"!==t.kind){let e=t.evaluate({zoom:o-1},i,{},r.availableImages),a=t.evaluate({zoom:o},i,{},r.availableImages),l=t.evaluate({zoom:o+1},i,{},r.availableImages);e=(null==e?void 0:e.name)?e.name:e,a=(null==a?void 0:a.name)?a.name:a,l=(null==l?void 0:l.name)?l.name:l,s[e]=!0,s[a]=!0,s[l]=!0,i.patterns[n.id]={min:e,mid:a,max:l}}}return i}function Zl(e,t,i,n,r){let o;if(r===function(e,t,i,n){let r=0;for(let o=t,s=i-n;o<i;o+=n)r+=(e[s]-e[o])*(e[o+1]+e[s+1]),s=o;return r}(e,t,i,n)>0)for(let r=t;r<i;r+=n)o=pc(r/n|0,e[r],e[r+1],o);else for(let r=i-n;r>=t;r-=n)o=pc(r/n|0,e[r],e[r+1],o);return o&&ac(o,o.next)&&(fc(o),o=o.next),o}function $l(e,t){if(!e)return e;t||(t=e);let i,n=e;do{if(i=!1,n.steiner||!ac(n,n.next)&&0!==sc(n.prev,n,n.next))n=n.next;else{if(fc(n),n=t=n.prev,n===n.next)break;i=!0}}while(i||n!==t);return t}function Hl(e,t,i,n,r,o,s){if(!e)return;!s&&o&&function(e,t,i,n){let r=e;do{0===r.z&&(r.z=tc(r.x,r.y,t,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,i=1;do{let n,r=e;e=null;let o=null;for(t=0;r;){t++;let s=r,a=0;for(let e=0;e<i&&(a++,s=s.nextZ,s);e++);let l=i;for(;a>0||l>0&&s;)0!==a&&(0===l||!s||r.z<=s.z)?(n=r,r=r.nextZ,a--):(n=s,s=s.nextZ,l--),o?o.nextZ=n:e=n,n.prevZ=o,o=n;r=s}o.nextZ=null,i*=2}while(t>1)}(r)}(e,n,r,o);let a=e;for(;e.prev!==e.next;){const l=e.prev,c=e.next;if(o?Xl(e,n,r,o):Wl(e))t.push(l.i,e.i,c.i),fc(e),e=c.next,a=c.next;else if((e=c)===a){s?1===s?Hl(e=Yl($l(e),t),t,i,n,r,o,2):2===s&&Jl(e,t,i,n,r,o):Hl($l(e),t,i,n,r,o,1);break}}}function Wl(e){const t=e.prev,i=e,n=e.next;if(sc(t,i,n)>=0)return!1;const r=t.x,o=i.x,s=n.x,a=t.y,l=i.y,c=n.y,u=Math.min(r,o,s),h=Math.min(a,l,c),d=Math.max(r,o,s),p=Math.max(a,l,c);let f=n.next;for(;f!==t;){if(f.x>=u&&f.x<=d&&f.y>=h&&f.y<=p&&rc(r,a,o,l,s,c,f.x,f.y)&&sc(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Xl(e,t,i,n){const r=e.prev,o=e,s=e.next;if(sc(r,o,s)>=0)return!1;const a=r.x,l=o.x,c=s.x,u=r.y,h=o.y,d=s.y,p=Math.min(a,l,c),f=Math.min(u,h,d),m=Math.max(a,l,c),g=Math.max(u,h,d),y=tc(p,f,t,i,n),_=tc(m,g,t,i,n);let v=e.prevZ,x=e.nextZ;for(;v&&v.z>=y&&x&&x.z<=_;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==r&&v!==s&&rc(a,u,l,h,c,d,v.x,v.y)&&sc(v.prev,v,v.next)>=0)return!1;if(v=v.prevZ,x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&rc(a,u,l,h,c,d,x.x,x.y)&&sc(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;v&&v.z>=y;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==r&&v!==s&&rc(a,u,l,h,c,d,v.x,v.y)&&sc(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;x&&x.z<=_;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&rc(a,u,l,h,c,d,x.x,x.y)&&sc(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Yl(e,t){let i=e;do{const n=i.prev,r=i.next.next;!ac(n,r)&&lc(n,i,i.next,r)&&hc(n,r)&&hc(r,n)&&(t.push(n.i,i.i,r.i),fc(i),fc(i.next),i=e=r),i=i.next}while(i!==e);return $l(i)}function Jl(e,t,i,n,r,o){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&oc(s,e)){let a=dc(s,e);return s=$l(s,s.next),a=$l(a,a.next),Hl(s,t,i,n,r,o,0),void Hl(a,t,i,n,r,o,0)}e=e.next}s=s.next}while(s!==e)}function Kl(e,t){let i=e.x-t.x;return 0===i&&(i=e.y-t.y,0===i)&&(i=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)),i}function Ql(e,t){const i=function(e,t){let i=t;const n=e.x,r=e.y;let o,s=-1/0;if(ac(e,i))return i;do{if(ac(e,i.next))return i.next;if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const e=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=n&&e>s&&(s=e,o=i.x<i.next.x?i:i.next,e===n))return o}i=i.next}while(i!==t);if(!o)return null;const a=o,l=o.x,c=o.y;let u=1/0;i=o;do{if(n>=i.x&&i.x>=l&&n!==i.x&&nc(r<c?n:s,r,l,c,r<c?s:n,r,i.x,i.y)){const t=Math.abs(r-i.y)/(n-i.x);hc(i,e)&&(t<u||t===u&&(i.x>o.x||i.x===o.x&&ec(o,i)))&&(o=i,u=t)}i=i.next}while(i!==a);return o}(e,t);if(!i)return t;const n=dc(i,e);return $l(n,n.next),$l(i,i.next)}function ec(e,t){return sc(e.prev,e,t.prev)<0&&sc(t.next,e,e.next)<0}function tc(e,t,i,n,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function ic(e){let t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next}while(t!==e);return i}function nc(e,t,i,n,r,o,s,a){return(r-s)*(t-a)>=(e-s)*(o-a)&&(e-s)*(n-a)>=(i-s)*(t-a)&&(i-s)*(o-a)>=(r-s)*(n-a)}function rc(e,t,i,n,r,o,s,a){return!(e===s&&t===a)&&nc(e,t,i,n,r,o,s,a)}function oc(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&lc(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(hc(e,t)&&hc(t,e)&&function(e,t){let i=e,n=!1;const r=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==e);return n}(e,t)&&(sc(e.prev,e,t.prev)||sc(e,t.prev,t))||ac(e,t)&&sc(e.prev,e,e.next)>0&&sc(t.prev,t,t.next)>0)}function sc(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function ac(e,t){return e.x===t.x&&e.y===t.y}function lc(e,t,i,n){const r=uc(sc(e,t,i)),o=uc(sc(e,t,n)),s=uc(sc(i,n,e)),a=uc(sc(i,n,t));return r!==o&&s!==a||!(0!==r||!cc(e,i,t))||!(0!==o||!cc(e,n,t))||!(0!==s||!cc(i,e,n))||!(0!==a||!cc(i,t,n))}function cc(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function uc(e){return e>0?1:e<0?-1:0}function hc(e,t){return sc(e.prev,e,e.next)<0?sc(e,t,e.next)>=0&&sc(e,e.prev,t)>=0:sc(e,t,e.prev)<0||sc(e,e.next,t)<0}function dc(e,t){const i=mc(e.i,e.x,e.y),n=mc(t.i,t.x,t.y),r=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,n.next=i,i.prev=n,o.next=n,n.prev=o,n}function pc(e,t,i,n){const r=mc(e,t,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function fc(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function mc(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class gc{constructor(e,t){if(t>e)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=e,this._minGranularity=t}getGranularityForZoomLevel(e){return Math.max(Math.floor(this._baseZoomGranularity/(1<<e)),this._minGranularity,1)}}class yc{constructor(e){this.fill=e.fill,this.line=e.line,this.tile=e.tile,this.stencil=e.stencil,this.circle=e.circle}}yc.noSubdivision=new yc({fill:new gc(0,0),line:new gc(0,0),tile:new gc(0,0),stencil:new gc(0,0),circle:1}),fo("SubdivisionGranularityExpression",gc),fo("SubdivisionGranularitySetting",yc);const _c=-32768,vc=32767;class xc{constructor(e,t){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=e,this._granularityCellSize=C/e,this._canonical=t}_getKey(e,t){return(e+=32768)<<16|t+32768}_vertexToIndex(e,t){if(e<-32768||t<-32768||e>32767||t>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const i=0|Math.round(e),n=0|Math.round(t),r=this._getKey(i,n);if(this._vertexDictionary.has(r))return this._vertexDictionary.get(r);const o=this._vertexBuffer.length/2;return this._vertexDictionary.set(r,o),this._vertexBuffer.push(i,n),o}_subdivideTrianglesScanline(e){if(this._granularity<2)return function(e,t){const i=[];for(let n=0;n<t.length;n+=3){const r=t[n],o=t[n+1],s=t[n+2],a=e[2*r],l=e[2*r+1];(e[2*o]-a)*(e[2*s+1]-l)-(e[2*o+1]-l)*(e[2*s]-a)>0?(i.push(r),i.push(s),i.push(o)):(i.push(r),i.push(o),i.push(s))}return i}(this._vertexBuffer,e);const t=[],i=e.length;for(let n=0;n<i;n+=3){const i=[e[n+0],e[n+1],e[n+2]],r=[this._vertexBuffer[2*e[n+0]+0],this._vertexBuffer[2*e[n+0]+1],this._vertexBuffer[2*e[n+1]+0],this._vertexBuffer[2*e[n+1]+1],this._vertexBuffer[2*e[n+2]+0],this._vertexBuffer[2*e[n+2]+1]];let o=1/0,s=1/0,a=-1/0,l=-1/0;for(let e=0;e<3;e++){const t=r[2*e],i=r[2*e+1];o=Math.min(o,t),a=Math.max(a,t),s=Math.min(s,i),l=Math.max(l,i)}if(o===a||s===l)continue;const c=Math.floor(o/this._granularityCellSize),u=Math.ceil(a/this._granularityCellSize),h=Math.floor(s/this._granularityCellSize),d=Math.ceil(l/this._granularityCellSize);if(c!==u||h!==d)for(let e=h;e<d;e++){const n=this._scanlineGenerateVertexRingForCellRow(e,r,i);Ec(this._vertexBuffer,n,t)}else t.push(...i)}return t}_scanlineGenerateVertexRingForCellRow(e,t,i){const n=e*this._granularityCellSize,r=n+this._granularityCellSize,o=[];for(let e=0;e<3;e++){const s=t[2*e],a=t[2*e+1],l=t[2*(e+1)%6],c=t[(2*(e+1)+1)%6],u=t[2*(e+2)%6],h=t[(2*(e+2)+1)%6],d=l-s,p=c-a,f=0===d,m=0===p,g=(n-a)/p,y=(r-a)/p,_=Math.min(g,y),v=Math.max(g,y);if(!m&&(_>=1||v<=0)||m&&(a<n||a>r)){c>=n&&c<=r&&o.push(i[(e+1)%3]);continue}!m&&_>0&&o.push(this._vertexToIndex(s+d*_,a+p*_));const x=s+d*Math.max(_,0),b=s+d*Math.min(v,1);f||this._generateIntraEdgeVertices(o,s,a,l,c,x,b),!m&&v<1&&o.push(this._vertexToIndex(s+d*v,a+p*v)),(m||c>=n&&c<=r)&&o.push(i[(e+1)%3]),!m&&(c<=n||c>=r)&&this._generateInterEdgeVertices(o,s,a,l,c,u,h,b,n,r)}return o}_generateIntraEdgeVertices(e,t,i,n,r,o,s){const a=n-t,l=r-i,c=0===l,u=c?Math.min(t,n):Math.min(o,s),h=c?Math.max(t,n):Math.max(o,s),d=Math.floor(u/this._granularityCellSize)+1,p=Math.ceil(h/this._granularityCellSize)-1;if(c?t<n:o<s)for(let n=d;n<=p;n++){const r=n*this._granularityCellSize;e.push(this._vertexToIndex(r,i+l*(r-t)/a))}else for(let n=p;n>=d;n--){const r=n*this._granularityCellSize;e.push(this._vertexToIndex(r,i+l*(r-t)/a))}}_generateInterEdgeVertices(e,t,i,n,r,o,s,a,l,c){const u=r-i,h=o-n,d=s-r,p=(l-r)/d,f=(c-r)/d,m=Math.min(p,f),g=Math.max(p,f),y=n+h*m;let _=Math.floor(Math.min(y,a)/this._granularityCellSize)+1,v=Math.ceil(Math.max(y,a)/this._granularityCellSize)-1,x=a<y;const b=0===d;if(b&&(s===l||s===c))return;if(b||m>=1||g<=0){const e=i-s,n=o+(t-o)*Math.min((l-s)/e,(c-s)/e);_=Math.floor(Math.min(n,a)/this._granularityCellSize)+1,v=Math.ceil(Math.max(n,a)/this._granularityCellSize)-1,x=a<n}const w=u>0?c:l;if(x)for(let t=_;t<=v;t++)e.push(this._vertexToIndex(t*this._granularityCellSize,w));else for(let t=v;t>=_;t--)e.push(this._vertexToIndex(t*this._granularityCellSize,w))}_generateOutline(e){const t=[];for(const i of e){const e=wc(i,this._granularity,!0),n=this._pointArrayToIndices(e),r=[];for(let e=1;e<n.length;e++)r.push(n[e-1]),r.push(n[e]);t.push(r)}return t}_handlePoles(e){let t=!1,i=!1;this._canonical&&(0===this._canonical.y&&(t=!0),this._canonical.y===(1<<this._canonical.z)-1&&(i=!0)),(t||i)&&this._fillPoles(e,t,i)}_ensureNoPoleVertices(){const e=this._vertexBuffer;for(let t=0;t<e.length;t+=2){const i=e[t+1];i===_c&&(e[t+1]=-32767),i===vc&&(e[t+1]=32766)}}_generatePoleQuad(e,t,i,n,r,o){n>r!=(o===_c)?(e.push(t),e.push(i),e.push(this._vertexToIndex(n,o)),e.push(i),e.push(this._vertexToIndex(r,o)),e.push(this._vertexToIndex(n,o))):(e.push(i),e.push(t),e.push(this._vertexToIndex(n,o)),e.push(this._vertexToIndex(r,o)),e.push(i),e.push(this._vertexToIndex(n,o)))}_fillPoles(e,t,i){const n=this._vertexBuffer,r=C,o=e.length;for(let s=2;s<o;s+=3){const o=e[s-2],a=e[s-1],l=e[s],c=n[2*o],u=n[2*o+1],h=n[2*a],d=n[2*a+1],p=n[2*l],f=n[2*l+1];t&&(0===u&&0===d&&this._generatePoleQuad(e,o,a,c,h,_c),0===d&&0===f&&this._generatePoleQuad(e,a,l,h,p,_c),0===f&&0===u&&this._generatePoleQuad(e,l,o,p,c,_c)),i&&(u===r&&d===r&&this._generatePoleQuad(e,o,a,c,h,vc),d===r&&f===r&&this._generatePoleQuad(e,a,l,h,p,vc),f===r&&u===r&&this._generatePoleQuad(e,l,o,p,c,vc))}}_initializeVertices(e){for(let t=0;t<e.length;t+=2)this._vertexToIndex(e[t],e[t+1])}subdividePolygonInternal(e,t){if(this._used)throw new Error("Subdivision: multiple use not allowed.");this._used=!0;const{flattened:i,holeIndices:n}=function(e){const t=[],i=[];for(const n of e)if(0!==n.length){n!==e[0]&&t.push(i.length/2);for(const e of n)i.push(e.x),i.push(e.y)}return{flattened:i,holeIndices:t}}(e);let r;this._initializeVertices(i);try{const e=function(e,t,i=2){const n=t&&t.length,r=n?t[0]*i:e.length;let o=Zl(e,0,r,i,!0);const s=[];if(!o||o.next===o.prev)return s;let a,l,c;if(n&&(o=function(e,t,i,n){const r=[];for(let i=0,o=t.length;i<o;i++){const s=Zl(e,t[i]*n,i<o-1?t[i+1]*n:e.length,n,!1);s===s.next&&(s.steiner=!0),r.push(ic(s))}r.sort(Kl);for(let e=0;e<r.length;e++)i=Ql(r[e],i);return i}(e,t,o,i)),e.length>80*i){a=e[0],l=e[1];let t=a,n=l;for(let o=i;o<r;o+=i){const i=e[o],r=e[o+1];i<a&&(a=i),r<l&&(l=r),i>t&&(t=i),r>n&&(n=r)}c=Math.max(t-a,n-l),c=0!==c?32767/c:0}return Hl(o,s,i,a,l,c,0),s}(i,n),t=this._convertIndices(i,e);r=this._subdivideTrianglesScanline(t)}catch(e){}let o=[];return t&&(o=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(r),{verticesFlattened:this._vertexBuffer,indicesTriangles:r,indicesLineList:o}}_convertIndices(e,t){const i=[];for(const n of t)i.push(this._vertexToIndex(e[2*n],e[2*n+1]));return i}_pointArrayToIndices(e){const t=[];for(const i of e)t.push(this._vertexToIndex(i.x,i.y));return t}}function bc(e,t,i,n=!0){return new xc(i,t).subdividePolygonInternal(e,n)}function wc(e,t,n=!1){if(!e||e.length<1)return[];if(e.length<2)return[];const r=e[0],o=e[e.length-1],s=n&&(r.x!==o.x||r.y!==o.y);if(t<2)return s?[...e,e[0]]:[...e];const a=Math.floor(C/t),l=[];l.push(new i(e[0].x,e[0].y));const c=e.length,u=s?c:c-1;for(let t=0;t<u;t++){const n=e[t],r=t<c-1?e[t+1]:e[0],o=n.x,s=n.y,u=r.x,h=r.y,d=o!==u,p=s!==h;if(!d&&!p)continue;const f=u-o,m=h-s,g=Math.abs(f),y=Math.abs(m);let _=o,v=s;for(;;){const e=f>0?(Math.floor(_/a)+1)*a:(Math.ceil(_/a)-1)*a,t=m>0?(Math.floor(v/a)+1)*a:(Math.ceil(v/a)-1)*a,n=Math.abs(_-e),r=Math.abs(v-t),o=Math.abs(_-u),s=Math.abs(v-h),c=d?n/g:Number.POSITIVE_INFINITY,x=p?r/y:Number.POSITIVE_INFINITY;if((o<=n||!d)&&(s<=r||!p))break;if(c<x&&d||!p){_=e,v+=m*c;const t=new i(_,Math.round(v));l[l.length-1].x===t.x&&l[l.length-1].y===t.y||l.push(t)}else{_+=f*x,v=t;const e=new i(Math.round(_),v);l[l.length-1].x===e.x&&l[l.length-1].y===e.y||l.push(e)}}const x=new i(u,h);l[l.length-1].x===x.x&&l[l.length-1].y===x.y||l.push(x)}return l}function Ec(e,t,i){if(0===t.length)throw new Error("Subdivision vertex ring is empty.");let n=0,r=e[2*t[0]];for(let i=1;i<t.length;i++){const o=e[2*t[i]];o<r&&(r=o,n=i)}const o=t.length;let s=n,a=(s+1)%o;for(;;){const n=s-1>=0?s-1:o-1,r=(a+1)%o,l=e[2*t[n]],c=e[2*t[r]],u=e[2*t[s]],h=e[2*t[s]+1],d=e[2*t[a]+1];let p=!1;if(l<c)p=!0;else if(l>c)p=!1;else{const i=d-h,o=-(e[2*t[a]]-u),s=h<d?1:-1;((l-u)*i+(e[2*t[n]+1]-h)*o)*s>((c-u)*i+(e[2*t[r]+1]-h)*o)*s&&(p=!0)}if(p){const e=t[n],r=t[s],l=t[a];e!==r&&e!==l&&r!==l&&i.push(l,r,e),s--,s<0&&(s=o-1)}else{const e=t[r],n=t[s],l=t[a];e!==n&&e!==l&&n!==l&&i.push(l,n,e),a++,a>=o&&(a=0)}if(n===r)break}}function Tc(e,t,i,n,r,o,s,a,l){const c=r.length/2,u=s&&a&&l;if(c<la.MAX_VERTEX_ARRAY_LENGTH){const h=t.prepareSegment(c,i,n),d=h.vertexLength;for(let e=0;e<o.length;e+=3)n.emplaceBack(d+o[e],d+o[e+1],d+o[e+2]);let p,f;h.vertexLength+=c,h.primitiveLength+=o.length/3,u&&(f=s.prepareSegment(c,i,a),p=f.vertexLength,f.vertexLength+=c);for(let t=0;t<r.length;t+=2)e(r[t],r[t+1]);if(u)for(const e of l){for(let t=1;t<e.length;t+=2)a.emplaceBack(p+e[t-1],p+e[t]);f.primitiveLength+=e.length/2}}else!function(e,t,i,n,r,o){const s=[];for(let e=0;e<n.length/2;e++)s.push(-1);const a={count:0};let l=0,c=e.getOrCreateLatestSegment(t,i),u=c.vertexLength;for(let h=2;h<r.length;h+=3){const d=r[h-2],p=r[h-1],f=r[h];let m=s[d]<l,g=s[p]<l,y=s[f]<l;c.vertexLength+((m?1:0)+(g?1:0)+(y?1:0))>la.MAX_VERTEX_ARRAY_LENGTH&&(c=e.createNewSegment(t,i),l=a.count,m=!0,g=!0,y=!0,u=0);const _=Sc(s,n,o,a,d,m,c),v=Sc(s,n,o,a,p,g,c),x=Sc(s,n,o,a,f,y,c);i.emplaceBack(u+_-l,u+v-l,u+x-l),c.primitiveLength++}}(t,i,n,r,o,e),u&&function(e,t,i,n,r,o){const s=[];for(let e=0;e<n.length/2;e++)s.push(-1);const a={count:0};let l=0,c=e.getOrCreateLatestSegment(t,i),u=c.vertexLength;for(const h of r)for(let r=1;r<h.length;r+=2){const d=h[r-1],p=h[r];let f=s[d]<l,m=s[p]<l;c.vertexLength+((f?1:0)+(m?1:0))>la.MAX_VERTEX_ARRAY_LENGTH&&(c=e.createNewSegment(t,i),l=a.count,f=!0,m=!0,u=0);const g=Sc(s,n,o,a,d,f,c),y=Sc(s,n,o,a,p,m,c);i.emplaceBack(u+g-l,u+y-l),c.primitiveLength++}}(s,i,a,r,l,e),t.forceNewSegmentOnNextPrepare(),null==s||s.forceNewSegmentOnNextPrepare()}function Sc(e,t,i,n,r,o,s){if(o){const o=n.count;return i(t[2*r],t[2*r+1]),e[r]=n.count,n.count++,s.vertexLength++,o}return e[r]}class Ic{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new Hs,this.indexArray=new ra,this.indexArray2=new oa,this.programConfigurations=new Na(e.layers,e.zoom),this.segments=new la,this.segments2=new la,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.hasDependencies=Ul("fill",this.layers,t);const n=this.layers[0].layout.get("fill-sort-key"),r=!n.isConstant(),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=qa(s,e);if(!this.layers[0]._featureFilter.filter(new zo(this.zoom),u,i))continue;const h=r?n.evaluate(u,{},i,t.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:Ua(s),patterns:{},sortKey:h};o.push(d)}r&&o.sort((e,t)=>e.sortKey-t.sortKey);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(this.hasDependencies){const e=ql("fill",this.layers,n,{zoom:this.zoom},t);this.patternFeatures.push(e)}else this.addFeature(n,r,o,i,{},t.subdivisionGranularity);t.featureIndex.insert(e[o].feature,r,o,s,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}addFeatures(e,t,i){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,t,i,e.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Vl),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,t,i,n,r,o){for(const e of tn(t,500)){const t=bc(e,n,o.fill.getGranularityForZoomLevel(n.z)),i=this.layoutVertexArray;Tc((e,t)=>{i.emplaceBack(e,t)},this.segments,this.layoutVertexArray,this.indexArray,t.verticesFlattened,t.indicesTriangles,this.segments2,this.indexArray2,t.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:r,canonical:n})}}let kc,Mc;fo("FillBucket",Ic,{omit:["layers","patternFeatures"]});var Cc={get paint(){return Mc=Mc||new Jo({"fill-antialias":new $o(xe.paint_fill["fill-antialias"]),"fill-opacity":new Ho(xe.paint_fill["fill-opacity"]),"fill-color":new Ho(xe.paint_fill["fill-color"]),"fill-outline-color":new Ho(xe.paint_fill["fill-outline-color"]),"fill-translate":new $o(xe.paint_fill["fill-translate"]),"fill-translate-anchor":new $o(xe.paint_fill["fill-translate-anchor"]),"fill-pattern":new Wo(xe.paint_fill["fill-pattern"])})},get layout(){return kc=kc||new Jo({"fill-sort-key":new Ho(xe.layout_fill["fill-sort-key"])})}};class Pc extends es{constructor(e,t){super(e,Cc,t)}recalculate(e,t){super.recalculate(e,t);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new Ic(e)}queryRadius(){return sl(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:t,transform:i,pixelsToTileUnits:n}){return Ya(al(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-i.bearingInRadians,n),t)}isTileClipped(){return!0}}const Ac=as([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Lc=as([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Dc}=Ac;class Rc{constructor(e,t,i,n,r){this.properties={},this.extent=i,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=n,this._values=r,e.readFields(zc,this,t)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos,n=[];let r,o=1,s=0,a=0,l=0;for(;e.pos<t;){if(s<=0){const t=e.readVarint();o=7&t,s=t>>3}if(s--,1===o||2===o)a+=e.readSVarint(),l+=e.readSVarint(),1===o&&(r&&n.push(r),r=[]),r&&r.push(new i(a,l));else{if(7!==o)throw new Error(`unknown command ${o}`);r&&r.push(r[0].clone())}}return r&&n.push(r),n}bbox(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let i=1,n=0,r=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;for(;e.pos<t;){if(n<=0){const t=e.readVarint();i=7&t,n=t>>3}if(n--,1===i||2===i)r+=e.readSVarint(),o+=e.readSVarint(),r<s&&(s=r),r>a&&(a=r),o<l&&(l=o),o>c&&(c=o);else if(7!==i)throw new Error(`unknown command ${i}`)}return[s,l,a,c]}toGeoJSON(e,t,i){const n=this.extent*Math.pow(2,i),r=this.extent*e,o=this.extent*t,s=this.loadGeometry();function a(e){return[360*(e.x+r)/n-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+o)/n)*Math.PI))-90]}function l(e){return e.map(a)}let c;if(1===this.type){const e=[];for(const t of s)e.push(t[0]);const t=l(e);c=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t}}else if(2===this.type){const e=s.map(l);c=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e}}else{if(3!==this.type)throw new Error("unknown feature type");{const e=Fc(s),t=[];for(const i of e)t.push(i.map(l));c=1===t.length?{type:"Polygon",coordinates:t[0]}:{type:"MultiPolygon",coordinates:t}}}const u={type:"Feature",geometry:c,properties:this.properties};return null!=this.id&&(u.id=this.id),u}}function zc(e,t,i){1===e?t.id=i.readVarint():2===e?function(e,t){const i=e.readVarint()+e.pos;for(;e.pos<i;){const i=t._keys[e.readVarint()],n=t._values[e.readVarint()];t.properties[i]=n}}(i,t):3===e?t.type=i.readVarint():4===e&&(t._geometry=i.pos)}function Fc(e){const t=e.length;if(t<=1)return[e];const i=[];let n,r;for(let o=0;o<t;o++){const t=Oc(e[o]);0!==t&&(void 0===r&&(r=t<0),r===t<0?(n&&i.push(n),n=[e[o]]):n&&n.push(e[o]))}return n&&i.push(n),i}function Oc(e){let t=0;for(let i,n,r=0,o=e.length,s=o-1;r<o;s=r++)i=e[r],n=e[s],t+=(n.x-i.x)*(i.y+n.y);return t}Rc.types=["Unknown","Point","LineString","Polygon"];class Nc{constructor(e,t){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(Bc,this,t),this.length=this._features.length}feature(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const t=this._pbf.readVarint()+this._pbf.pos;return new Rc(this._pbf,t,this.extent,this._keys,this._values)}}function Bc(e,t,i){15===e?t.version=i.readVarint():1===e?t.name=i.readString():5===e?t.extent=i.readVarint():2===e?t._features.push(i.pos):3===e?t._keys.push(i.readString()):4===e&&t._values.push(function(e){let t=null;const i=e.readVarint()+e.pos;for(;e.pos<i;){const i=e.readVarint()>>3;t=1===i?e.readString():2===i?e.readFloat():3===i?e.readDouble():4===i?e.readVarint64():5===i?e.readVarint():6===i?e.readSVarint():7===i?e.readBoolean():null}if(null==t)throw new Error("unknown feature value");return t}(i))}class Gc{constructor(e,t){this.layers=e.readFields(jc,{},t)}}function jc(e,t,i){if(3===e){const e=new Nc(i,i.readVarint()+i.pos);e.length&&(t[e.name]=e)}}const Vc=Math.pow(2,13);function Uc(e,t,i,n,r,o,s,a){e.emplaceBack(t,i,2*Math.floor(n*Vc)+s,r*Vc*2,o*Vc*2,Math.round(a))}class qc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new Ws,this.centroidVertexArray=new Zs,this.indexArray=new ra,this.programConfigurations=new Na(e.layers,e.zoom),this.segments=new la,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.features=[],this.hasDependencies=Ul("fill-extrusion",this.layers,t);for(const{feature:n,id:r,index:o,sourceLayerIndex:s}of e){const e=this.layers[0]._featureFilter.needGeometry,a=qa(n,e);if(!this.layers[0]._featureFilter.filter(new zo(this.zoom),a,i))continue;const l={id:r,sourceLayerIndex:s,index:o,geometry:e?a.geometry:Ua(n),properties:n.properties,type:n.type,patterns:{}};this.hasDependencies?this.features.push(ql("fill-extrusion",this.layers,l,{zoom:this.zoom},t)):this.addFeature(l,l.geometry,o,i,{},t.subdivisionGranularity),t.featureIndex.insert(n,l.geometry,o,s,this.index,!0)}}addFeatures(e,t,i){for(const n of this.features){const{geometry:r}=n;this.addFeature(n,r,n.index,t,i,e.subdivisionGranularity)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Dc),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Lc.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,t,i,n,r,o){for(const i of tn(t,500)){const t={x:0,y:0,sampleCount:0},r=this.layoutVertexArray.length;this.processPolygon(t,n,e,i,o);const s=this.layoutVertexArray.length-r,a=Math.floor(t.x/t.sampleCount),l=Math.floor(t.y/t.sampleCount);for(let e=0;e<s;e++)this.centroidVertexArray.emplaceBack(a,l)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:r,canonical:n})}processPolygon(e,t,i,n,r){if(n.length<1)return;if(Hc(n[0]))return;for(const t of n)0!==t.length&&Zc(e,t);const o={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},s=r.fill.getGranularityForZoomLevel(t.z),a="Polygon"===Rc.types[i.type];for(const e of n){if(0===e.length)continue;if(Hc(e))continue;const t=wc(e,s,a);this._generateSideFaces(t,o)}if(!a)return;const l=bc(n,t,s,!1),c=this.layoutVertexArray;Tc((e,t)=>{Uc(c,e,t,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles)}_generateSideFaces(e,t){let i=0;for(let n=1;n<e.length;n++){const r=e[n],o=e[n-1];if($c(r,o))continue;t.segment.vertexLength+4>la.MAX_VERTEX_ARRAY_LENGTH&&(t.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const s=r.sub(o)._perp()._unit(),a=o.dist(r);i+a>32768&&(i=0),Uc(this.layoutVertexArray,r.x,r.y,s.x,s.y,0,0,i),Uc(this.layoutVertexArray,r.x,r.y,s.x,s.y,0,1,i),i+=a,Uc(this.layoutVertexArray,o.x,o.y,s.x,s.y,0,0,i),Uc(this.layoutVertexArray,o.x,o.y,s.x,s.y,0,1,i);const l=t.segment.vertexLength;this.indexArray.emplaceBack(l,l+2,l+1),this.indexArray.emplaceBack(l+1,l+2,l+3),t.segment.vertexLength+=4,t.segment.primitiveLength+=2}}}function Zc(e,t){for(let i=0;i<t.length;i++){const n=t[i];i===t.length-1&&t[0].x===n.x&&t[0].y===n.y||(e.x+=n.x,e.y+=n.y,e.sampleCount++)}}function $c(e,t){return e.x===t.x&&(e.x<0||e.x>C)||e.y===t.y&&(e.y<0||e.y>C)}function Hc(e){return e.every(e=>e.x<0)||e.every(e=>e.x>C)||e.every(e=>e.y<0)||e.every(e=>e.y>C)}let Wc;fo("FillExtrusionBucket",qc,{omit:["layers","features"]});var Xc={get paint(){return Wc=Wc||new Jo({"fill-extrusion-opacity":new $o(xe["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Ho(xe["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new $o(xe["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new $o(xe["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Wo(xe["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Ho(xe["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Ho(xe["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new $o(xe["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class Yc extends es{constructor(e,t){super(e,Xc,t)}createBucket(e){return new qc(e)}queryRadius(){return sl(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:n,geometry:r,transform:o,pixelsToTileUnits:s,pixelPosMatrix:a}){const l=al(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-o.bearingInRadians,s),c=this.paint.get("fill-extrusion-height").evaluate(t,n),u=this.paint.get("fill-extrusion-base").evaluate(t,n),h=function(e,t){const n=[];for(const r of e){const e=[r.x,r.y,0,1];T(e,e,t),n.push(new i(e[0]/e[3],e[1]/e[3]))}return n}(l,a),d=function(e,t,n,r){const o=[],s=[],a=r[8]*t,l=r[9]*t,c=r[10]*t,u=r[11]*t,h=r[8]*n,d=r[9]*n,p=r[10]*n,f=r[11]*n;for(const t of e){const e=[],n=[];for(const o of t){const t=o.x,s=o.y,m=r[0]*t+r[4]*s+r[12],g=r[1]*t+r[5]*s+r[13],y=r[2]*t+r[6]*s+r[14],_=r[3]*t+r[7]*s+r[15],v=y+c,x=_+u,b=m+h,w=g+d,E=y+p,T=_+f,S=new i((m+a)/x,(g+l)/x);S.z=v/x,e.push(S);const I=new i(b/T,w/T);I.z=E/T,n.push(I)}o.push(e),s.push(n)}return[o,s]}(r,u,c,a);return function(e,t,i){let n=1/0;Ya(i,t)&&(n=Kc(i,t[0]));for(let r=0;r<t.length;r++){const o=t[r],s=e[r];for(let e=0;e<o.length-1;e++){const t=o[e],r=[t,o[e+1],s[e+1],s[e],t];Wa(i,r)&&(n=Math.min(n,Kc(i,r)))}}return n!==1/0&&n}(d[0],d[1],h)}}function Jc(e,t){return e.x*t.x+e.y*t.y}function Kc(e,t){if(1===e.length){let i=0;const n=t[i++];let r;for(;!r||n.equals(r);)if(r=t[i++],!r)return 1/0;for(;i<t.length;i++){const o=t[i],s=e[0],a=r.sub(n),l=o.sub(n),c=s.sub(n),u=Jc(a,a),h=Jc(a,l),d=Jc(l,l),p=Jc(c,a),f=Jc(c,l),m=u*d-h*h,g=(d*p-h*f)/m,y=(u*f-h*p)/m,_=n.z*(1-g-y)+r.z*g+o.z*y;if(isFinite(_))return _}return 1/0}{let e=1/0;for(const i of t)e=Math.min(e,i.z);return e}}const Qc=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class eu{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[t,i]=new Uint8Array(e,0,2);if(219!==t)throw new Error("Data does not appear to be in a KDBush format.");const n=i>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=Qc[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[s]=new Uint32Array(e,4,1);return new eu(s,o,r,e)}constructor(e,t=64,i=Float64Array,n){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=i,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const r=Qc.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-s%8)%8;if(r<0)throw new Error(`Unexpected typed array class: ${i}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+o+s+a),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+r]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=e,this.coords[this._pos++]=t,i}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return tu(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,u=a.pop()||0,h=a.pop()||0;if(u-h<=s){for(let s=h;s<=u;s++){const a=o[2*s],c=o[2*s+1];a>=e&&a<=i&&c>=t&&c<=n&&l.push(r[s])}continue}const d=h+u>>1,p=o[2*d],f=o[2*d+1];p>=e&&p<=i&&f>=t&&f<=n&&l.push(r[d]),(0===c?e<=p:t<=f)&&(a.push(h),a.push(d-1),a.push(1-c)),(0===c?i>=p:n>=f)&&(a.push(d+1),a.push(u),a.push(1-c))}return l}within(e,t,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,u=s.pop()||0,h=s.pop()||0;if(u-h<=o){for(let i=h;i<=u;i++)ou(r[2*i],r[2*i+1],e,t)<=l&&a.push(n[i]);continue}const d=h+u>>1,p=r[2*d],f=r[2*d+1];ou(p,f,e,t)<=l&&a.push(n[d]),(0===c?e-i<=p:t-i<=f)&&(s.push(h),s.push(d-1),s.push(1-c)),(0===c?e+i>=p:t+i>=f)&&(s.push(d+1),s.push(u),s.push(1-c))}return a}}function tu(e,t,i,n,r,o){if(r-n<=i)return;const s=n+r>>1;iu(e,t,s,n,r,o),tu(e,t,i,n,s-1,1-o),tu(e,t,i,s+1,r,1-o)}function iu(e,t,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);iu(e,t,i,Math.max(n,Math.floor(i-a*c/s+u)),Math.min(r,Math.floor(i+(s-a)*c/s+u)),o)}const s=t[2*i+o];let a=n,l=r;for(nu(e,t,n,i),t[2*r+o]>s&&nu(e,t,n,r);a<l;){for(nu(e,t,a,l),a++,l--;t[2*a+o]<s;)a++;for(;t[2*l+o]>s;)l--}t[2*n+o]===s?nu(e,t,n,l):(l++,nu(e,t,l,r)),l<=i&&(n=l+1),i<=l&&(r=l-1)}}function nu(e,t,i,n){ru(e,i,n),ru(t,2*i,2*n),ru(t,2*i+1,2*n+1)}function ru(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function ou(e,t,i,n){const r=e-i,o=t-n;return r*r+o*o}function su(e,t,i,n){let r=n;const o=t+(i-t>>1);let s,a=i-t;const l=e[t],c=e[t+1],u=e[i],h=e[i+1];for(let n=t+3;n<i;n+=3){const t=au(e[n],e[n+1],l,c,u,h);if(t>r)s=n,r=t;else if(t===r){const e=Math.abs(n-o);e<a&&(s=n,a=e)}}r>n&&(s-t>3&&su(e,t,s,n),e[s+2]=r,i-s>3&&su(e,s,i,n))}function au(e,t,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((e-i)*s+(t-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=e-i,a=t-n,s*s+a*a}function lu(e,t,i,n){const r={type:t,geom:i},o={id:null==e?null:e,type:r.type,geometry:r.geom,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};switch(r.type){case"Point":case"MultiPoint":uu(o,r.geom);break;case"LineString":uu(o,r.geom.points);break;case"Polygon":uu(o,r.geom[0].points);break;case"MultiLineString":for(const e of r.geom)uu(o,e.points);break;case"MultiPolygon":for(const e of r.geom)uu(o,e[0].points)}return o}function cu(e){e.points.length>64&&(e.points=new Float64Array(e.points))}function uu(e,t){for(let i=0;i<t.length;i+=3)e.minX=Math.min(e.minX,t[i]),e.minY=Math.min(e.minY,t[i+1]),e.maxX=Math.max(e.maxX,t[i]),e.maxY=Math.max(e.maxY,t[i+1])}function hu(e,t){const i=[];switch(e.type){case"FeatureCollection":for(let n=0;n<e.features.length;n++)du(i,e.features[n],t,n);break;case"Feature":du(i,e,t);break;default:du(i,{geometry:e,properties:void 0},t)}return i}function du(e,t,i,n){if(!t.geometry)return;if("GeometryCollection"===t.geometry.type)return void function(e,t,i,n,r){for(const o of i.geometries)du(e,{id:t.id,geometry:o,properties:t.properties},n,r)}(e,t,t.geometry,i,n);const r=t.geometry.coordinates;if(!r?.length)return;const o=function(e,t,i){return t.promoteId?e.properties?.[t.promoteId]:t.generateId?i||0:e.id}(t,i,n),s=Math.pow(i.tolerance/((1<<i.maxZoom)*i.extent),2);switch(t.geometry.type){case"Point":return void function(e,t,i,n){const r=[];r.push(mu(i.coordinates[0]),gu(i.coordinates[1]),0),e.push(lu(t,"Point",r,n))}(e,o,t.geometry,t.properties);case"MultiPoint":return void function(e,t,i,n){const r=[];for(const e of i.coordinates)r.push(mu(e[0]),gu(e[1]),0);e.push(lu(t,"MultiPoint",r,n))}(e,o,t.geometry,t.properties);case"LineString":return void function(e,t,i,n,r){const o={points:[]};pu(i.coordinates,o,n,!1),e.push(lu(t,"LineString",o,r))}(e,o,t.geometry,s,t.properties);case"MultiLineString":return void function(e,t,i,n,r,o){if(r.lineMetrics)for(const r of i.coordinates){const i={points:[]};pu(r,i,n,!1),e.push(lu(t,"LineString",i,o))}else{const r=[];fu(i.coordinates,r,n,!1),e.push(lu(t,"MultiLineString",r,o))}}(e,o,t.geometry,s,i,t.properties);case"Polygon":return void function(e,t,i,n,r){const o=[];fu(i.coordinates,o,n,!0),e.push(lu(t,"Polygon",o,r))}(e,o,t.geometry,s,t.properties);case"MultiPolygon":return void function(e,t,i,n,r){const o=[];for(const e of i.coordinates){const t=[];fu(e,t,n,!0),o.push(t)}e.push(lu(t,"MultiPolygon",o,r))}(e,o,t.geometry,s,t.properties);default:throw new Error("Input data is not a valid GeoJSON object.")}}function pu(e,t,i,n){let r,o,s=0;for(let i=0;i<e.length;i++){const a=mu(e[i][0]),l=gu(e[i][1]);t.points.push(a,l,0),i>0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=t.points.length-3;t.points[2]=1,i>0&&su(t.points,0,a,i),t.points[a+2]=1,cu(t),t.size=Math.abs(s),t.start=0,t.end=t.size}function fu(e,t,i,n){for(let r=0;r<e.length;r++){const o={points:[]};pu(e[r],o,i,n),t.push(o)}}function mu(e){return e/360+.5}function gu(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function yu(e){const t={type:"Feature",geometry:_u(e),properties:e.tags};return null!=e.id&&(t.id=e.id),t}function _u(e){const{type:t,geometry:i}=e;switch(t){case"Point":return{type:t,coordinates:xu(i[0],i[1])};case"MultiPoint":return{type:t,coordinates:vu(i)};case"LineString":return{type:t,coordinates:vu(i.points)};case"MultiLineString":case"Polygon":return{type:t,coordinates:i.map(e=>vu(e.points))};case"MultiPolygon":return{type:t,coordinates:i.map(e=>e.map(e=>vu(e.points)))}}}function vu(e){const t=[];for(let i=0;i<e.length;i+=3)t.push(xu(e[i],e[i+1]));return t}function xu(e,t){return[bu(e),wu(t)]}function bu(e){return 360*(e-.5)}function wu(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}var Eu;function Tu(e,t,i,n,r,o,s,a){if(n/=t,o>=(i/=t)&&s<n)return e;if(s<i||o>=n)return null;const l=[];for(const t of e){const e=r===Eu.X?t.minX:t.minY,o=r===Eu.X?t.maxX:t.maxY;if(e>=i&&o<n)l.push(t);else if(!(o<i||e>=n))switch(t.type){case"Point":case"MultiPoint":Su(t,l,i,n,r);continue;case"LineString":Iu(t,l,i,n,r,a);continue;case"MultiLineString":ku(t,l,i,n,r);continue;case"Polygon":Mu(t,l,i,n,r);continue;case"MultiPolygon":Cu(t,l,i,n,r);continue}}return l.length?l:null}function Su(e,t,i,n,r){const o=[];(function(e,t,i,n,r){for(let o=0;o<e.length;o+=3){const s=e[o+r];s>=i&&s<=n&&Du(t,e[o],e[o+1],e[o+2])}})(e.geometry,o,i,n,r),o.length&&t.push(lu(e.id,3===o.length?"Point":"MultiPoint",o,e.tags))}function Iu(e,t,i,n,r,o){const s=[];if(Pu(e.geometry,s,i,n,r,!1,o.lineMetrics),s.length)if(o.lineMetrics)for(const i of s)t.push(lu(e.id,"LineString",i,e.tags));else t.push(s.length>1?lu(e.id,"MultiLineString",s,e.tags):lu(e.id,"LineString",s[0],e.tags))}function ku(e,t,i,n,r){const o=[];Lu(e.geometry,o,i,n,r,!1),o.length&&t.push(1!==o.length?lu(e.id,"MultiLineString",o,e.tags):lu(e.id,"LineString",o[0],e.tags))}function Mu(e,t,i,n,r){const o=[];Lu(e.geometry,o,i,n,r,!0),o.length&&t.push(lu(e.id,"Polygon",o,e.tags))}function Cu(e,t,i,n,r){const o=[];for(const t of e.geometry){const e=[];Lu(t,e,i,n,r,!0),e.length&&o.push(e)}o.length&&t.push(lu(e.id,"MultiPolygon",o,e.tags))}function Pu(e,t,i,n,r,o,s){let a=Au(e);const l=r===Eu.X?Ru:zu;let c,u,h=e.start;for(let d=0;d<e.points.length-3;d+=3){const p=e.points[d],f=e.points[d+1],m=e.points[d+2],g=e.points[d+3],y=e.points[d+4],_=r===Eu.X?p:f,v=r===Eu.X?g:y;let x=!1;s&&(c=Math.sqrt(Math.pow(p-g,2)+Math.pow(f-y,2))),_<i?v>i&&(u=l(a,p,f,g,y,i),s&&(a.start=h+c*u)):_>n?v<n&&(u=l(a,p,f,g,y,n),s&&(a.start=h+c*u)):Du(a.points,p,f,m),v<i&&_>=i&&(u=l(a,p,f,g,y,i),x=!0),v>n&&_<=n&&(u=l(a,p,f,g,y,n),x=!0),!o&&x&&(s&&(a.end=h+c*u),t.push(a),a=Au(e)),s&&(h+=c)}let d=e.points.length-3;const p=e.points[d],f=e.points[d+1],m=r===Eu.X?p:f;m>=i&&m<=n&&Du(a.points,p,f,e.points[d+2]),d=a.points.length-3,o&&d>=3&&(a.points[d]!==a.points[0]||a.points[d+1]!==a.points[1])&&Du(a.points,a.points[0],a.points[1],a.points[2]),a.points.length&&(cu(a),t.push(a))}function Au(e){return{points:[],size:e.size,start:e.start,end:e.end}}function Lu(e,t,i,n,r,o){for(const s of e)Pu(s,t,i,n,r,o,!1)}function Du(e,t,i,n){e.push(t,i,n)}function Ru(e,t,i,n,r,o){const s=(o-t)/(n-t);return Du(e.points,o,i+(r-i)*s,1),s}function zu(e,t,i,n,r,o){const s=(o-i)/(r-i);return Du(e.points,t+(n-t)*s,o,1),s}function Fu(e,t){const i=t.buffer/t.extent;let n=e;const r=Tu(e,1,-1-i,i,Eu.X,-1,2,t),o=Tu(e,1,1-i,2+i,Eu.X,-1,2,t);return r||o?(n=Tu(e,1,-i,1+i,Eu.X,-1,2,t)||[],r&&(n=Ou(r,1).concat(n)),o&&(n=n.concat(Ou(o,-1))),n):n}function Ou(e,t){const i=[];for(const n of e)switch(n.type){case"Point":case"MultiPoint":{const e=Nu(n.geometry,t);i.push(lu(n.id,n.type,e,n.tags));continue}case"LineString":{const e=Bu(n.geometry,t);i.push(lu(n.id,n.type,e,n.tags));continue}case"MultiLineString":case"Polygon":{const e=[];for(const i of n.geometry)e.push(Bu(i,t));i.push(lu(n.id,n.type,e,n.tags));continue}case"MultiPolygon":{const e=[];for(const i of n.geometry){const n=[];for(const e of i)n.push(Bu(e,t));e.push(n)}i.push(lu(n.id,n.type,e,n.tags));continue}}return i}function Nu(e,t){const i=[];for(let n=0;n<e.length;n+=3)i.push(e[n]+t,e[n+1],e[n+2]);return i}function Bu(e,t){const i={points:[],size:e.size};void 0!==e.start&&(i.start=e.start,i.end=e.end);for(let n=0;n<e.points.length;n+=3)i.points.push(e.points[n]+t,e.points[n+1],e.points[n+2]);return cu(i),i}function Gu(e,t,i){const n=!!t.newGeometry,r=t.removeAllProperties||t.removeProperties?.length>0||t.addOrUpdateProperties?.length>0;if(n){const n=e[0];let o=hu({type:"FeatureCollection",features:[{type:"Feature",id:n.id,geometry:t.newGeometry,properties:r?ju(n.tags,t):n.tags}]},i);return o=Fu(o,i),o}if(r){const i=[];for(const n of e){const e={...n};e.tags=ju(e.tags,t),i.push(e)}return i}return e}function ju(e,t){if(t.removeAllProperties)return{};const i={...e||{}};if(t.removeProperties)for(const e of t.removeProperties)delete i[e];if(t.addOrUpdateProperties)for(const{key:e,value:n}of t.addOrUpdateProperties)i[e]=n;return i}!function(e){e[e.X=0]="X",e[e.Y=1]="Y"}(Eu||(Eu={}));const Vu={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e};class Uu{constructor(e){this.options=Object.assign(Object.create(Vu),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[],this.points=[]}load(e){const t=[];for(const i of e){if(!i.geometry)continue;const[e,n]=i.geometry.coordinates,[r,o]=[mu(e),gu(n)];t.push({id:i.id,type:"Point",geometry:[r,o],tags:i.properties})}this.createIndex(t)}initialize(e){const t=[];for(const i of e)"Point"===i.type&&t.push(i);this.createIndex(t)}updateIndex(e,t,i){this.options=Object.assign(Object.create(Vu),i.clusterOptions),this.initialize(e)}createIndex(e){const{log:t,minZoom:i,maxZoom:n}=this.options;e.length,this.points=e;const r=[];for(let t=0;t<e.length;t++){const i=e[t];if(!i?.geometry)continue;let[n,o]=i.geometry;n=Math.fround(n),o=Math.fround(o),r.push(n,o,1/0,t,-1,1),this.options.reduce&&r.push(0)}let o=this.trees[n+1]=this.createTree(r);for(let e=n;e>=i;e--)o=this.trees[e]=this.createTree(this.cluster(o,e))}getClusters(e,t){return this.getClustersInternal(e,t).map(e=>yu(e))}getClustersInternal(e,t){let i=((e[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,e[1]));let r=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)i=-180,r=180;else if(i>r){const e=this.getClustersInternal([i,n,180,o],t),s=this.getClustersInternal([-180,n,r,o],t);return e.concat(s)}const s=this.trees[this.limitZoom(t)],a=s.range(mu(i),gu(o),mu(r),gu(n)),l=s.flatData,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+5]>1?qu(l,t,this.clusterProps):this.points[l[t+3]])}return c}getChildren(e){const t=this.getOriginId(e),i=this.getOriginZoom(e),n=new Error("No cluster with the specified id: "+e),r=this.trees[i];if(!r)throw n;const o=r.flatData;if(t*this.stride>=o.length)throw n;const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[t*this.stride],o[t*this.stride+1],s),l=[];for(const t of a){const i=t*this.stride;o[i+4]===e&&l.push(o[i+5]>1?Zu(o,i,this.clusterProps):yu(this.points[o[i+3]]))}if(0===l.length)throw n;return l}getLeaves(e,t,i){const n=[];return this.appendLeaves(n,e,t=t||10,i=i||0,0),n}getTile(e,t,i){const n=this.trees[this.limitZoom(e)];if(!n)return null;const r=Math.pow(2,e),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,u={transformed:!0,features:[],source:null,x:t,y:i,z:e};return this.addTileFeatures(n.range((t-a)/r,l,(t+1+a)/r,c),n.flatData,t,i,r,u),0===t&&this.addTileFeatures(n.range(1-a/r,l,1,c),n.flatData,r,i,r,u),t===r-1&&this.addTileFeatures(n.range(0,l,a/r,c),n.flatData,-1,i,r,u),u}getClusterExpansionZoom(e){return this.getOriginZoom(e)}appendLeaves(e,t,i,n,r){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o?.cluster?r+o.point_count<=n?r+=o.point_count:r=this.appendLeaves(e,o.cluster_id,i,n,r):r<n?r++:e.push(t),e.length===i)break}return r}createTree(e){const t=new eu(e.length/this.stride|0,this.options.nodeSize,Float32Array);for(let i=0;i<e.length;i+=this.stride)t.add(e[i],e[i+1]);return t.finish(),t.flatData=e,t.data=null,t}addTileFeatures(e,t,i,n,r,o){for(const s of e){const e=s*this.stride,a=t[e+5]>1;let l,c,u;if(a)l=$u(t,e,this.clusterProps),c=t[e],u=t[e+1];else{const i=this.points[t[e+3]];l=i.tags,[c,u]=i.geometry}const h={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(u*r-n))]],tags:l};let d;d=a||this.options.generateId?t[e+3]:this.points[t[e+3]].id,void 0!==d&&(h.id=d),o.features.push(h)}}limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}cluster(e,t){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,t)),a=e.flatData,l=[],c=this.stride;for(let i=0;i<a.length;i+=c){if(a[i+2]<=t)continue;a[i+2]=t;const n=a[i],u=a[i+1],h=e.within(a[i],a[i+1],s),d=a[i+5];let p=d;for(const e of h){const i=e*c;a[i+2]>t&&(p+=a[i+5])}if(p>d&&p>=o){let e,o=n*d,s=u*d,f=-1;const m=(i/c<<5)+(t+1)+this.points.length;for(const n of h){const l=n*c;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+5];o+=a[l]*u,s+=a[l+1]*u,a[l+4]=m,r&&(e||(e=this.map(a,i,!0),f=this.clusterProps.length,this.clusterProps.push(e)),r(e,this.map(a,l)))}a[i+4]=m,l.push(o/p,s/p,1/0,m,-1,p),r&&l.push(f)}else{for(let e=0;e<c;e++)l.push(a[i+e]);if(p>1)for(const e of h){const i=e*c;if(!(a[i+2]<=t)){a[i+2]=t;for(let e=0;e<c;e++)l.push(a[i+e])}}}}return l}getOriginId(e){return e-this.points.length>>5}getOriginZoom(e){return(e-this.points.length)%32}map(e,t,i){if(e[t+5]>1){const n=this.clusterProps[e[t+6]];return i?Object.assign({},n):n}const n=this.points[e[t+3]].tags,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function qu(e,t,i){return{id:e[t+3],type:"Point",tags:$u(e,t,i),geometry:[e[t],e[t+1]]}}function Zu(e,t,i){return{type:"Feature",id:e[t+3],properties:$u(e,t,i),geometry:{type:"Point",coordinates:[bu(e[t]),wu(e[t+1])]}}}function $u(e,t,i){const n=e[t+5],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=e[t+6],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:e[t+3],point_count:n,point_count_abbreviated:r})}const Hu="geojsonvt_clip_start",Wu="geojsonvt_clip_end";function Xu(e,t,i,n,r){const o=t===r.maxZoom?0:r.tolerance/((1<<t)*r.extent),s={transformed:!1,features:[],source:null,x:i,y:n,z:t,minX:2,minY:1,maxX:-1,maxY:0,numPoints:0,numSimplified:0,numFeatures:e.length};for(const t of e)Yu(s,t,o,r);return s}function Yu(e,t,i,n){switch(e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),t.type){case"Point":case"MultiPoint":return void function(e,t){const i=[];for(let n=0;n<t.geometry.length;n+=3)i.push(t.geometry[n],t.geometry[n+1]),e.numPoints++,e.numSimplified++;if(!i.length)return;const n={type:1,tags:t.tags||null,geometry:i};null!==t.id&&(n.id=t.id),e.features.push(n)}(e,t);case"LineString":return void function(e,t,i,n){const r=[];if(Ju(r,t.geometry,e,i,!1,!1),!r.length)return;let o=t.tags||null;if(n.lineMetrics){o={};for(const e in t.tags)o[e]=t.tags[e];o[Hu]=t.geometry.start/t.geometry.size,o[Wu]=t.geometry.end/t.geometry.size}const s={type:2,tags:o,geometry:r};null!==t.id&&(s.id=t.id),e.features.push(s)}(e,t,i,n);case"MultiLineString":case"Polygon":return void function(e,t,i){const n=[];for(let r=0;r<t.geometry.length;r++)Ju(n,t.geometry[r],e,i,"Polygon"===t.type,0===r);if(!n.length)return;const r={type:"Polygon"===t.type?3:2,tags:t.tags||null,geometry:n};null!==t.id&&(r.id=t.id),e.features.push(r)}(e,t,i);case"MultiPolygon":return void function(e,t,i){const n=[];for(let r=0;r<t.geometry.length;r++){const o=t.geometry[r];for(let t=0;t<o.length;t++)Ju(n,o[t],e,i,!0,0===t)}if(!n.length)return;const r={type:3,tags:t.tags||null,geometry:n};null!==t.id&&(r.id=t.id),e.features.push(r)}(e,t,i)}}function Ju(e,t,i,n,r,o){const s=n*n;if(n>0&&t.size<(r?s:n))return void(i.numPoints+=t.points.length/3);const a=[];for(let e=0;e<t.points.length;e+=3)(0===n||t.points[e+2]>s)&&(i.numSimplified++,a.push(t.points[e],t.points[e+1])),i.numPoints++;r&&function(e,t){let i=0;for(let t=0,n=e.length,r=n-2;t<n;r=t,t+=2)i+=(e[t]-e[r])*(e[t+1]+e[r+1]);if(i>0===t)for(let t=0,i=e.length;t<i/2;t+=2){const n=e[t],r=e[t+1];e[t]=e[i-2-t],e[t+1]=e[i-1-t],e[i-2-t]=n,e[i-1-t]=r}}(a,o),e.push(a)}function Ku(e,t){if(e.transformed)return e;const i=1<<e.z,n=e.x,r=e.y;for(const o of e.features)1===o.type?Qu(o,t,i,n,r):eh(o,t,i,n,r);return e.transformed=!0,e}function Qu(e,t,i,n,r){const o=e,s=e.geometry,a=[];for(let e=0;e<s.length;e+=2)a.push(th(s[e],s[e+1],t,i,n,r));return o.geometry=a,o}function eh(e,t,i,n,r){const o=e,s=e.geometry,a=[];for(const e of s){const o=[];for(let s=0;s<e.length;s+=2)o.push(th(e[s],e[s+1],t,i,n,r));a.push(o)}return o.geometry=a,o}function th(e,t,i,n,r,o){return[Math.round(i*(e*n-r)),Math.round(i*(t*n-o))]}class ih{constructor(e){this.options=e,this.total=0,this.stats={},this.tiles={},this.tileCoords=[],this.stats={},this.total=0}initialize(e){this.splitTile(e,0,0,0),this.options.debug}updateIndex(e,t,i){i.debug,this.invalidateTiles(t),i.debug;const[n,r,o]=[0,0,0],s=Xu(e,n,r,o,i);s.source=e;const a=nh(n,r,o);if(this.tiles[a]=s,this.tileCoords.push({z:n,x:r,y:o,id:a}),i.debug){const e=`z${n}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}}getClusterExpansionZoom(e){return null}getChildren(e){return null}getLeaves(e,t,i){return null}getTile(e,t,i){const{extent:n,debug:r}=this.options,o=1<<e,s=nh(e,t=t+o&o-1,i);if(this.tiles[s])return Ku(this.tiles[s],n);let a,l=e,c=t,u=i;for(;!a&&l>0;)l--,c>>=1,u>>=1,a=this.tiles[nh(l,c,u)];return a?.source?(this.splitTile(a.source,l,c,u,e,t,i),this.tiles[s]?Ku(this.tiles[s],n):null):null}splitTile(e,t,i,n,r,o,s){const a=[e,t,i,n],l=this.options,c=l.debug;for(;a.length;){n=a.pop(),i=a.pop(),t=a.pop(),e=a.pop();const u=1<<t,h=nh(t,i,n);let d=this.tiles[h];if(!d&&(d=this.tiles[h]=Xu(e,t,i,n,l),this.tileCoords.push({z:t,x:i,y:n,id:h}),c)){const e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}if(d.source=e,null==r){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else{if(t===l.maxZoom||t===r)continue;if(null!=r){const e=r-t;if(i!==o>>e||n!==s>>e)continue}}if(d.source=null,!e.length)continue;const p=.5*l.buffer/l.extent,f=.5-p,m=.5+p,g=1+p;let y=null,_=null,v=null,x=null;const b=Tu(e,u,i-p,i+m,Eu.X,d.minX,d.maxX,l),w=Tu(e,u,i+f,i+g,Eu.X,d.minX,d.maxX,l);b&&(y=Tu(b,u,n-p,n+m,Eu.Y,d.minY,d.maxY,l),_=Tu(b,u,n+f,n+g,Eu.Y,d.minY,d.maxY,l)),w&&(v=Tu(w,u,n-p,n+m,Eu.Y,d.minY,d.maxY,l),x=Tu(w,u,n+f,n+g,Eu.Y,d.minY,d.maxY,l)),a.push(y||[],t+1,2*i,2*n),a.push(_||[],t+1,2*i,2*n+1),a.push(v||[],t+1,2*i+1,2*n),a.push(x||[],t+1,2*i+1,2*n+1)}}invalidateTiles(e){if(!e.length)return;const t=this.options,{debug:i}=t;let n=1/0,r=-1/0,o=1/0,s=-1/0;for(const t of e)n=Math.min(n,t.minX),r=Math.max(r,t.maxX),o=Math.min(o,t.minY),s=Math.max(s,t.maxY);const a=t.buffer/t.extent,l=new Set;for(const t in this.tiles){const c=this.tiles[t],u=1<<c.z,h=(c.x-a)/u,d=(c.x+1+a)/u,p=(c.y-a)/u,f=(c.y+1+a)/u;if(r<h||n>=d||s<p||o>=f)continue;let m=!1;for(const t of e)if(t.maxX>=h&&t.minX<d&&t.maxY>=p&&t.minY<f){m=!0;break}if(m){if(i){const e=`z${c.z}`;this.stats[e]=(this.stats[e]||0)-1,this.total--}delete this.tiles[t],l.add(t)}}l.size&&(this.tileCoords=this.tileCoords.filter(e=>!l.has(e.id)))}}function nh(e,t,i){return 32*((1<<e)*i+t)+e}const rh={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,updateable:!1,cluster:!1,clusterOptions:Vu,debug:0},oh=as([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:sh}=oh,ah=as([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:lh}=ah,ch=Math.cos(Math.PI/180*37.5),uh=Math.pow(2,14)/.5;class hh{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={};for(const e of this.layers)this.gradients[e.id]={};this.layoutVertexArray=new Xs,this.layoutVertexArray2=new Ys,this.indexArray=new ra,this.programConfigurations=new Na(e.layers,e.zoom),this.segments=new la,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.hasDependencies=Ul("line",this.layers,t)||this.hasLineDasharray(this.layers);const n=this.layers[0].layout.get("line-sort-key"),r=!n.isConstant(),o=[];for(const{feature:t,id:s,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=qa(t,e);if(!this.layers[0]._featureFilter.filter(new zo(this.zoom),c,i))continue;const u=r?n.evaluate(c,{},i):void 0,h={id:s,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Ua(t),patterns:{},dashes:{},sortKey:u};o.push(h)}r&&o.sort((e,t)=>e.sortKey-t.sortKey);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;this.hasDependencies?(Ul("line",this.layers,t)?ql("line",this.layers,n,{zoom:this.zoom},t):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,n,this.zoom,t),this.patternFeatures.push(n)):this.addFeature(n,r,o,i,{},{},t.subdivisionGranularity),t.featureIndex.insert(e[o].feature,r,o,s,this.index)}}update(e,t,i,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i,dashPositions:n})}addFeatures(e,t,i,n){for(const r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,t,i,n,e.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,lh)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,sh),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.hasOwn(e.properties,Hu)&&Object.hasOwn(e.properties,Wu))return{start:+e.properties[Hu],end:+e.properties[Wu]}}addFeature(e,t,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(e,{}),c=a.get("line-cap").evaluate(e,{}),u=a.get("line-miter-limit").evaluate(e,{}),h=a.get("line-round-limit").evaluate(e,{});this.lineClips=this.lineFeatureClips(e);for(const i of t)this.addLine(i,e,l,c,u,h,n,s);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:r,dashPositions:o,canonical:n})}addLine(e,t,i,n,r,o,s,a){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=wc(e,s?a.line.getGranularityForZoomLevel(s.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t<e.length-1;t++)this.totalDistance+=e[t].dist(e[t+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const l="Polygon"===Rc.types[t.type];let c=e.length;for(;c>=2&&e[c-1].equals(e[c-2]);)c--;let u=0;for(;u<c-1&&e[u].equals(e[u+1]);)u++;if(c<(l?3:2))return;"bevel"===i&&(r=1.05);const h=this.overscaling<=16?122880/(512*this.overscaling):0,d=this.segments.prepareSegment(10*c,this.layoutVertexArray,this.indexArray);let p,f,m,g,y;this.e1=this.e2=-1,l&&(p=e[c-2],y=e[u].sub(p)._unit()._perp());for(let t=u;t<c;t++){if(m=t===c-1?l?e[u+1]:void 0:e[t+1],m&&e[t].equals(m))continue;y&&(g=y),p&&(f=p),p=e[t],y=m?m.sub(p)._unit()._perp():g,g||(g=y);let s=g.add(y);0===s.x&&0===s.y||s._unit();const a=g.x*y.x+g.y*y.y,_=s.x*y.x+s.y*y.y,v=0!==_?1/_:1/0,x=2*Math.sqrt(2-2*_),b=_<ch&&f&&m,w=g.x*y.y-g.y*y.x>0;if(b&&t>u){const e=p.dist(f);if(e>2*h){const t=p.sub(p.sub(f)._mult(h/e)._round());this.updateDistance(f,t),this.addCurrentVertex(t,g,0,0,d),f=t}}const E=f&&m;let T=E?i:l?"butt":n;if(E&&"round"===T&&(v<o?T="miter":v<=2&&(T="fakeround")),"miter"===T&&v>r&&(T="bevel"),"bevel"===T&&(v>2&&(T="flipbevel"),v<r&&(T="miter")),f&&this.updateDistance(f,p),"miter"===T)s._mult(v),this.addCurrentVertex(p,s,0,0,d);else if("flipbevel"===T){if(v>100)s=y.mult(-1);else{const e=v*g.add(y).mag()/g.sub(y).mag();s._perp()._mult(e*(w?-1:1))}this.addCurrentVertex(p,s,0,0,d),this.addCurrentVertex(p,s.mult(-1),0,0,d)}else if("bevel"===T||"fakeround"===T){const e=-Math.sqrt(v*v-1),t=w?e:0,i=w?0:e;if(f&&this.addCurrentVertex(p,g,t,i,d),"fakeround"===T){const e=Math.round(180*x/Math.PI/20);for(let t=1;t<e;t++){let i=t/e;if(.5!==i){const e=i-.5;i+=i*e*(i-1)*((1.0904+a*(a*(3.55645-1.43519*a)-3.2452))*e*e+(.848013+a*(.215638*a-1.06021)))}const n=y.sub(g)._mult(i)._add(g)._unit()._mult(w?-1:1);this.addHalfVertex(p,n.x,n.y,!1,w,0,d)}}m&&this.addCurrentVertex(p,y,-t,-i,d)}else if("butt"===T)this.addCurrentVertex(p,s,0,0,d);else if("square"===T){const e=f?1:-1;this.addCurrentVertex(p,s,e,e,d)}else"round"===T&&(f&&(this.addCurrentVertex(p,g,0,0,d),this.addCurrentVertex(p,g,1,1,d,!0)),m&&(this.addCurrentVertex(p,y,-1,-1,d,!0),this.addCurrentVertex(p,y,0,0,d)));if(b&&t<c-1){const e=p.dist(m);if(e>2*h){const t=p.add(m.sub(p)._mult(h/e)._round());this.updateDistance(p,t),this.addCurrentVertex(t,y,0,0,d),p=t}}}}addCurrentVertex(e,t,i,n,r,o=!1){const s=t.y*n-t.x,a=-t.y-t.x*n;this.addHalfVertex(e,t.x+t.y*i,t.y-t.x*i,o,!1,i,r),this.addHalfVertex(e,s,a,o,!0,-n,r),this.distance>uh/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,t,i,n,r,o))}addHalfVertex({x:e,y:t},i,n,r,o,s,a){const l=.5*(this.lineClips?this.scaledDistance*(uh-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(r?1:0),(t<<1)+(o?1:0),Math.round(63*i)+128,Math.round(63*n)+128,1+(0===s?0:s<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const c=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,c,this.e2),a.primitiveLength++),o?this.e2=c:this.e1=c}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}hasLineDasharray(e){for(const t of e){const e=t.paint.get("line-dasharray");if(e&&!e.isConstant())return!0}return!1}addLineDashDependencies(e,t,i,n){for(const r of e){const e=r.paint.get("line-dasharray");if(!e||"constant"===e.value.kind)continue;const o="round"===r.layout.get("line-cap").evaluate(t,{}),s={dasharray:e.value.evaluate({zoom:i-1},t,{}),round:o},a={dasharray:e.value.evaluate({zoom:i},t,{}),round:o},l={dasharray:e.value.evaluate({zoom:i+1},t,{}),round:o},c=`${s.dasharray.join(",")},${s.round}`,u=`${a.dasharray.join(",")},${a.round}`,h=`${l.dasharray.join(",")},${l.round}`;n.dashDependencies[c]=s,n.dashDependencies[u]=a,n.dashDependencies[h]=l,t.dashes[r.id]={min:c,mid:u,max:h}}}}let dh,ph;fo("LineBucket",hh,{omit:["layers","patternFeatures"]});var fh={get paint(){return ph=ph||new Jo({"line-opacity":new Ho(xe.paint_line["line-opacity"]),"line-color":new Ho(xe.paint_line["line-color"]),"line-translate":new $o(xe.paint_line["line-translate"]),"line-translate-anchor":new $o(xe.paint_line["line-translate-anchor"]),"line-width":new Ho(xe.paint_line["line-width"]),"line-gap-width":new Ho(xe.paint_line["line-gap-width"]),"line-offset":new Ho(xe.paint_line["line-offset"]),"line-blur":new Ho(xe.paint_line["line-blur"]),"line-dasharray":new Wo(xe.paint_line["line-dasharray"]),"line-pattern":new Wo(xe.paint_line["line-pattern"]),"line-gradient":new Yo(xe.paint_line["line-gradient"])})},get layout(){return dh=dh||new Jo({"line-cap":new Ho(xe.layout_line["line-cap"]),"line-join":new Ho(xe.layout_line["line-join"]),"line-miter-limit":new Ho(xe.layout_line["line-miter-limit"]),"line-round-limit":new Ho(xe.layout_line["line-round-limit"]),"line-sort-key":new Ho(xe.layout_line["line-sort-key"])})}};class mh extends Ho{possiblyEvaluate(e,t){return t=new zo(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,n){return t=B({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,n)}}let gh;class yh extends es{constructor(e,t){super(e,fh,t),this.gradientVersion=0,gh||(gh=new mh(fh.paint.properties["line-width"].specification),gh.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this.gradientExpression();this.stepInterpolant=!!function(e){return void 0!==e._styleExpression}(e)&&e._styleExpression.expression instanceof li,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=gh.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new hh(e)}queryRadius(e){const t=e,i=_h(ol("line-width",this,t),ol("line-gap-width",this,t)),n=ol("line-offset",this,t);return i/2+Math.abs(n)+sl(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:n,geometry:r,transform:o,pixelsToTileUnits:s}){const a=al(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-o.bearingInRadians,s),l=s/2*_h(this.paint.get("line-width").evaluate(t,n),this.paint.get("line-gap-width").evaluate(t,n)),c=this.paint.get("line-offset").evaluate(t,n);return c&&(r=function(e,t){const n=[];for(const r of e){const e=ll(r),o=[];for(let n=0;n<e.length;n++){const r=e[n],s=e[n-1],a=e[n+1],l=0===n?new i(0,0):r.sub(s)._unit()._perp(),c=n===e.length-1?new i(0,0):a.sub(r)._unit()._perp(),u=l._add(c)._unit(),h=u.x*c.x+u.y*c.y;0!==h&&u._mult(1/h),o.push(u._mult(t)._add(r))}n.push(o)}return n}(r,c*s)),function(e,t,i){for(const n of t){if(e.length>=3)for(const t of n)if(nl(e,t))return!0;if(Ja(e,n,i))return!0}return!1}(a,r,l)}isTileClipped(){return!0}}function _h(e,t){return t>0?t+2*e:e}const vh=as([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),xh=as([{name:"a_projected_pos",components:3,type:"Float32"}],4);as([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const bh=as([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);as([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const wh=as([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Eh=as([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Th(e,t,i){const n=t.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?e=e.toLocaleUpperCase():"lowercase"===n&&(e=e.toLocaleLowerCase()),Ro.applyArabicShaping&&(e=Ro.applyArabicShaping(e)),e}function Sh(e,t,i){for(const n of e.sections)n.text=Th(n.text,t,i);return e}as([{name:"triangle",components:3,type:"Uint16"}]),as([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),as([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),as([{type:"Float32",name:"offsetX"}]),as([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),as([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);var Ih=24;const kh={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},Mh={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},Ch={40:!0};function Ph(e,t,i,n,r,o){if("fontStack"in t){const n=i[t.fontStack],o=null==n?void 0:n[e];return o?o.metrics.advance*t.scale+r:0}{const e=n[t.imageName];return e?e.displaySize[0]*t.scale*Ih/o+r:0}}function Ah(e,t,i,n){const r=Math.pow(e-t,2);return n?e<t?r/2:2*r:r+Math.abs(i)*i}function Lh(e,t,i){let n=0;return 10===e&&(n-=1e4),i&&(n+=150),40!==e&&65288!==e||(n+=50),41!==t&&65289!==t||(n+=50),n}function Dh(e,t,i,n,r,o){let s=null,a=Ah(t,i,r,o);for(const e of n){const n=Ah(t-e.x,i,r,o)+e.badness;n<=a&&(s=e,a=n)}return{index:e,x:t,priorBreak:s,badness:a}}function Rh(e){return e?Rh(e.priorBreak).concat(e.index):[]}class zh{constructor(e="",t=[],i=[]){this.text=e,this.sections=t,this.sectionIndex=i,this.imageSectionID=null}static fromFeature(e,t){const i=new zh;for(const n of e.sections)n.image?i.addImageSection(n):i.addTextSection(n,t);return i}length(){return[...this.text].length}getSection(e){return this.sections[this.sectionIndex[e]]}getSectionIndex(e){return this.sectionIndex[e]}verticalizePunctuation(){this.text=function(e){let t="",i={premature:!0,value:void 0};const n=e[Symbol.iterator]();let r=n.next();const o=e[Symbol.iterator]();o.next();let s=o.next();for(;!r.done;)t+=!s.done&&Co(s.value.codePointAt(0))&&!kh[s.value]||!i.premature&&Co(i.value.codePointAt(0))&&!kh[i.value]||!kh[r.value]?r.value:kh[r.value],i={value:r.value,premature:!1},r=n.next(),s=o.next();return t}(this.text)}hasZeroWidthSpaces(){return this.text.includes("​")}trim(){const e=this.text.match(/^\s*/),t=e?e[0].length:0,i=this.text.match(/\S\s*$/),n=i?i[0].length-1:0;this.text=this.text.substring(t,this.text.length-n),this.sectionIndex=this.sectionIndex.slice(t,this.sectionIndex.length-n)}substring(e,t){const i=[...this.text].slice(e,t).join(""),n=this.sectionIndex.slice(e,t);return new zh(i,this.sections,n)}toCodeUnitIndex(e){return[...this.text].slice(0,e).join("").length}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,t)=>Math.max(e,this.sections[t].scale),0)}getMaxImageSize(e){let t=0,i=0;for(let n=0;n<this.length();n++){const r=this.getSection(n);if("imageName"in r){const n=e[r.imageName];if(!n)continue;const o=n.displaySize;t=Math.max(t,o[0]),i=Math.max(i,o[1])}}return{maxImageWidth:t,maxImageHeight:i}}addTextSection(e,t){this.text+=e.text,this.sections.push({scale:e.scale||1,verticalAlign:e.verticalAlign||"bottom",fontStack:e.fontStack||t});const i=this.sections.length-1;this.sectionIndex.push(...[...e.text].map(()=>i))}addImageSection(e){const t=e.image?e.image.name:"";if(0===t.length)return void q();const i=this.getNextImageSectionCharCode();i?(this.text+=String.fromCharCode(i),this.sections.push({scale:1,verticalAlign:e.verticalAlign||"bottom",imageName:t}),this.sectionIndex.push(this.sections.length-1)):q()}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(e,t,i,n,r){const o=[],s=this.determineAverageLineWidth(e,t,i,n,r),a=this.hasZeroWidthSpaces();let l=0,c=0;const u=this.text[Symbol.iterator]();let h=u.next();const d=this.text[Symbol.iterator]();d.next();let p=d.next();const f=this.text[Symbol.iterator]();f.next(),f.next();let m=f.next();for(;!h.done;){const t=this.getSection(c),g=h.value.codePointAt(0);if(Eo(g)||(l+=Ph(g,t,i,n,e,r)),!p.done){const e=bo(g),i=p.value.codePointAt(0);(Mh[g]||e||"imageName"in t||!m.done&&Ch[i])&&o.push(Dh(c+1,l,s,o,Lh(g,i,e&&a),!1))}c++,h=u.next(),p=d.next(),m=f.next()}return Rh(Dh(this.length(),l,s,o,0,!0))}determineAverageLineWidth(e,t,i,n,r){let o=0,s=0;for(const t of this.text){const a=this.getSection(s);o+=Ph(t.codePointAt(0),a,i,n,e,r),s++}return o/Math.max(1,Math.ceil(o/t))}}const Fh=4294967296,Oh=1/Fh,Nh="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class Bh{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,t,i=this.length){for(;this.pos<i;){const i=this.readVarint(),n=i>>3,r=this.pos;this.type=7&i,e(n,t,this),this.pos===r&&this.skip(i)}return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Fh;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Fh;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const t=this.buf;let i,n;return n=t[this.pos++],i=127&n,n<128?i:(n=t[this.pos++],i|=(127&n)<<7,n<128?i:(n=t[this.pos++],i|=(127&n)<<14,n<128?i:(n=t[this.pos++],i|=(127&n)<<21,n<128?i:(n=t[this.pos],i|=(15&n)<<28,function(e,t,i){const n=i.buf;let r,o;if(o=n[i.pos++],r=(112&o)>>4,o<128)return Gh(e,r,t);if(o=n[i.pos++],r|=(127&o)<<3,o<128)return Gh(e,r,t);if(o=n[i.pos++],r|=(127&o)<<10,o<128)return Gh(e,r,t);if(o=n[i.pos++],r|=(127&o)<<17,o<128)return Gh(e,r,t);if(o=n[i.pos++],r|=(127&o)<<24,o<128)return Gh(e,r,t);if(o=n[i.pos++],r|=(1&o)<<31,o<128)return Gh(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(i,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return Boolean(this.readVarint())}readString(){const e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&Nh?Nh.decode(this.buf.subarray(t,e)):function(e,t,i){let n="",r=t;for(;r<i;){const t=e[r];let o,s,a,l=null,c=t>239?4:t>223?3:t>191?2:1;if(r+c>i)break;1===c?t<128&&(l=t):2===c?(o=e[r+1],128==(192&o)&&(l=(31&t)<<6|63&o,l<=127&&(l=null))):3===c?(o=e[r+1],s=e[r+2],128==(192&o)&&128==(192&s)&&(l=(15&t)<<12|(63&o)<<6|63&s,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(o=e[r+1],s=e[r+2],a=e[r+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&t)<<18|(63&o)<<12|(63&s)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,n+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),n+=String.fromCharCode(l),r+=c}return n}(this.buf,t,e)}readBytes(){const e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){const i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readVarint(t));return e}readPackedSVarint(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSVarint());return e}readPackedBoolean(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readBoolean());return e}readPackedFloat(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFloat());return e}readPackedDouble(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readDouble());return e}readPackedFixed32(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed32());return e}readPackedSFixed32(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed32());return e}readPackedFixed64(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed64());return e}readPackedSFixed64(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed64());return e}readPackedEnd(){return 2===this.type?this.readVarint()+this.pos:this.pos+1}skip(e){const t=7&e;if(0===t)for(;this.buf[this.pos++]>127;);else if(2===t)this.pos=this.readVarint()+this.pos;else if(5===t)this.pos+=4;else{if(1!==t)throw new Error(`Unimplemented type: ${t}`);this.pos+=8}}writeTag(e,t){this.writeVarint(e<<3|t)}realloc(e){let t=this.length||16;for(;t<this.pos+e;)t*=2;if(t!==this.length){const e=new Uint8Array(t);e.set(this.buf),this.buf=e,this.dataView=new DataView(e.buffer),this.length=t}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeSFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,-1&e,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*Oh),!0),this.pos+=8}writeSFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,-1&e,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*Oh),!0),this.pos+=8}writeVarint(e){(e=+e||0)>268435455||e<0?function(e,t){let i,n;if(e>=0?(i=e%4294967296|0,n=e/4294967296|0):(i=~(-e%4294967296),n=~(-e/4294967296),4294967295^i?i=i+1|0:(i=0,n=n+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,i){i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,i.buf[i.pos]=127&(e>>>=7)}(i,0,t),function(e,t){const i=(7&e)<<4;t.buf[t.pos++]|=i|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))))}(n,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))}writeSVarint(e){this.writeVarint(e<0?2*-e-1:2*e)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;const t=this.pos;this.pos=function(e,t,i){for(let n,r,o=0;o<t.length;o++){if(n=t.charCodeAt(o),n>55295&&n<57344){if(!r){n>56319||o+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):r=n;continue}if(n<56320){e[i++]=239,e[i++]=191,e[i++]=189,r=n;continue}n=r-55296<<10|n-56320|65536,r=null}else r&&(e[i++]=239,e[i++]=191,e[i++]=189,r=null);n<128?e[i++]=n:(n<2048?e[i++]=n>>6|192:(n<65536?e[i++]=n>>12|224:(e[i++]=n>>18|240,e[i++]=n>>12&63|128),e[i++]=n>>6&63|128),e[i++]=63&n|128)}return i}(this.buf,e,this.pos);const i=this.pos-t;i>=128&&jh(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){const t=e.length;this.writeVarint(t),this.realloc(t);for(let i=0;i<t;i++)this.buf[this.pos++]=e[i]}writeRawMessage(e,t){this.pos++;const i=this.pos;e(t,this);const n=this.pos-i;n>=128&&jh(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n}writeMessage(e,t,i){this.writeTag(e,2),this.writeRawMessage(t,i)}writePackedVarint(e,t){t.length&&this.writeMessage(e,Vh,t)}writePackedSVarint(e,t){t.length&&this.writeMessage(e,Uh,t)}writePackedBoolean(e,t){t.length&&this.writeMessage(e,$h,t)}writePackedFloat(e,t){t.length&&this.writeMessage(e,qh,t)}writePackedDouble(e,t){t.length&&this.writeMessage(e,Zh,t)}writePackedFixed32(e,t){t.length&&this.writeMessage(e,Hh,t)}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,Wh,t)}writePackedFixed64(e,t){t.length&&this.writeMessage(e,Xh,t)}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,Yh,t)}writeBytesField(e,t){this.writeTag(e,2),this.writeBytes(t)}writeFixed32Field(e,t){this.writeTag(e,5),this.writeFixed32(t)}writeSFixed32Field(e,t){this.writeTag(e,5),this.writeSFixed32(t)}writeFixed64Field(e,t){this.writeTag(e,1),this.writeFixed64(t)}writeSFixed64Field(e,t){this.writeTag(e,1),this.writeSFixed64(t)}writeVarintField(e,t){this.writeTag(e,0),this.writeVarint(t)}writeSVarintField(e,t){this.writeTag(e,0),this.writeSVarint(t)}writeStringField(e,t){this.writeTag(e,2),this.writeString(t)}writeFloatField(e,t){this.writeTag(e,5),this.writeFloat(t)}writeDoubleField(e,t){this.writeTag(e,1),this.writeDouble(t)}writeBooleanField(e,t){this.writeVarintField(e,+t)}}function Gh(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function jh(e,t,i){const n=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(n);for(let t=i.pos-1;t>=e;t--)i.buf[t+n]=i.buf[t]}function Vh(e,t){for(let i=0;i<e.length;i++)t.writeVarint(e[i])}function Uh(e,t){for(let i=0;i<e.length;i++)t.writeSVarint(e[i])}function qh(e,t){for(let i=0;i<e.length;i++)t.writeFloat(e[i])}function Zh(e,t){for(let i=0;i<e.length;i++)t.writeDouble(e[i])}function $h(e,t){for(let i=0;i<e.length;i++)t.writeBoolean(e[i])}function Hh(e,t){for(let i=0;i<e.length;i++)t.writeFixed32(e[i])}function Wh(e,t){for(let i=0;i<e.length;i++)t.writeSFixed32(e[i])}function Xh(e,t){for(let i=0;i<e.length;i++)t.writeFixed64(e[i])}function Yh(e,t){for(let i=0;i<e.length;i++)t.writeSFixed64(e[i])}function Jh(e,t,i){1===e&&i.readMessage(Kh,t)}function Kh(e,t,i){if(3===e){const{id:e,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(Qh,{});t.push({id:e,bitmap:new Sl({width:r+6,height:o+6},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}}function Qh(e,t,i){1===e?t.id=i.readVarint():2===e?t.bitmap=i.readBytes():3===e?t.width=i.readVarint():4===e?t.height=i.readVarint():5===e?t.left=i.readSVarint():6===e?t.top=i.readSVarint():7===e&&(t.advance=i.readVarint())}function ed(e){let t=0,i=0;for(const n of e)t+=n.w*n.h,i=Math.max(i,n.w);e.sort((e,t)=>t.h-e.h);const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let r=0,o=0;for(const t of e)for(let e=n.length-1;e>=0;e--){const i=n[e];if(!(t.w>i.w||t.h>i.h)){if(t.x=i.x,t.y=i.y,o=Math.max(o,t.y+t.h),r=Math.max(r,t.x+t.w),t.w===i.w&&t.h===i.h){const t=n.pop();t&&e<n.length&&(n[e]=t)}else t.h===i.h?(i.x+=t.w,i.w-=t.w):t.w===i.w?(i.y+=t.h,i.h-=t.h):(n.push({x:i.x+t.w,y:i.y,w:i.w-t.w,h:t.h}),i.y+=t.h,i.h-=t.h);break}}return{w:r,h:o,fill:t/(r*o)||0}}class td{constructor(e,{pixelRatio:t,version:i,stretchX:n,stretchY:r,content:o,textFitWidth:s,textFitHeight:a}){this.paddedRect=e,this.pixelRatio=t,this.stretchX=n,this.stretchY=r,this.content=o,this.version=i,this.textFitWidth=s,this.textFitHeight=a}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class id{constructor(e,t){const i={},n={};this.haveRenderCallbacks=[];const r=[];this.addImages(e,i,r),this.addImages(t,n,r);const{w:o,h:s}=ed(r),a=new Il({width:o||1,height:s||1});for(const t in e){const n=e[t],r=i[t].paddedRect;Il.copy(n.data,a,{x:0,y:0},{x:r.x+1,y:r.y+1},n.data)}for(const e in t){const i=t[e],r=n[e].paddedRect,o=r.x+1,s=r.y+1,l=i.data.width,c=i.data.height;Il.copy(i.data,a,{x:0,y:0},{x:o,y:s},i.data),Il.copy(i.data,a,{x:0,y:c-1},{x:o,y:s-1},{width:l,height:1}),Il.copy(i.data,a,{x:0,y:0},{x:o,y:s+c},{width:l,height:1}),Il.copy(i.data,a,{x:l-1,y:0},{x:o-1,y:s},{width:1,height:c}),Il.copy(i.data,a,{x:0,y:0},{x:o+l,y:s},{width:1,height:c})}this.image=a,this.iconPositions=i,this.patternPositions=n}addImages(e,t,i){for(const n in e){const r=e[n],o={x:0,y:0,w:r.data.width+2,h:r.data.height+2};i.push(o),t[n]=new td(o,r),r.hasRenderCallback&&this.haveRenderCallbacks.push(n)}}patchUpdatedImages(e,t){e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const i in e.updatedImages)this.patchUpdatedImage(this.iconPositions[i],e.getImage(i),t),this.patchUpdatedImage(this.patternPositions[i],e.getImage(i),t)}patchUpdatedImage(e,t,i){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[n,r]=e.tl;i.update(t.data,void 0,{x:n,y:r})}}var nd;function rd(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m){const g=zh.fromFeature(t,o);let y;d===e.ax.vertical&&g.verticalizePunctuation();let _=g.determineLineBreaks(u,s,i,r,f);const{processBidirectionalText:v,processStyledBidirectionalText:x}=Ro;if(v&&1===g.sections.length){y=[],_=_.map(e=>g.toCodeUnitIndex(e));const e=v(g.toString(),_);for(const t of e){const e=[...t].map(()=>0);y.push(new zh(t,g.sections,e))}}else if(x){y=[],_=_.map(e=>g.toCodeUnitIndex(e));let e=0;const t=[];for(const i of g.text)t.push(...Array(i.length).fill(g.sectionIndex[e])),e++;const i=x(g.text,t,_);for(const e of i){const t=[];let i="";for(const n of e[0])t.push(e[1][i.length]),i+=n;y.push(new zh(e[0],g.sections,t))}}else y=function(e,t){const i=[];let n=0;for(const r of t)i.push(e.substring(n,r)),n=r;return n<e.length()&&i.push(e.substring(n,e.length())),i}(g,_);const b=[],w={positionedLines:b,text:g.toString(),top:h[1],bottom:h[1],left:h[0],right:h[0],writingMode:d,iconsInText:!1,verticalizable:!1};return function(e,t,i,n,r,o,s,a,l,c,u,h){let d=0,p=0,f=0,m=0;const g="right"===a?1:"left"===a?0:.5,y=Ih/h;let _=0;for(const s of r){s.trim();const r=s.getMaxScale(),a={positionedGlyphs:[],lineOffset:0};e.positionedLines[_]=a;const h=a.positionedGlyphs;let v=0;if(!s.length()){p+=o,++_;continue}const x=sd(n,s,y);let b=0;for(const o of s.text){const a=s.getSection(b),f=o.codePointAt(0),m=ld(l,u,f),g={glyph:f,imageName:null,x:d,y:p+-17,vertical:m,scale:1,fontStack:"",sectionIndex:s.getSectionIndex(b),metrics:null,rect:null};let _;if("fontStack"in a){if(_=cd(a,f,m,x,t,i),!_)continue;g.fontStack=a.fontStack}else{if(e.iconsInText=!0,a.scale*=y,_=ud(a,m,r,x,n),!_)continue;v=Math.max(v,_.imageOffset),g.imageName=a.imageName}const{rect:w,metrics:E,baselineOffset:T}=_;g.y+=T,g.scale=a.scale,g.metrics=E,g.rect=w,h.push(g),m?(e.verticalizable=!0,d+=("imageName"in a?E.advance:Ih)*a.scale+c):d+=E.advance*a.scale+c,b++}0!==h.length&&(f=Math.max(d-c,f),hd(h,0,h.length-1,g)),d=0,a.lineOffset=Math.max(v,(r-1)*Ih);const w=o*r+v;p+=w,m=Math.max(w,m),++_}const{horizontalAlign:v,verticalAlign:x}=od(s);(function(e,t,i,n,r,o,s,a,l){const c=(t-i)*r;let u=0;u=o!==s?-a*n- -17:-n*l*s+.5*s;for(const t of e)for(const e of t.positionedGlyphs)e.x+=c,e.y+=u})(e.positionedLines,g,v,x,f,m,o,p,r.length),e.top+=-x*p,e.bottom=e.top+p,e.left+=-v*f,e.right=e.left+f}(w,i,n,r,y,a,l,c,d,u,p,m),!function(e){for(const t of e)if(0!==t.positionedGlyphs.length)return!1;return!0}(b)&&w}function od(e){let t=.5,i=.5;switch(e){case"right":case"top-right":case"bottom-right":t=1;break;case"left":case"top-left":case"bottom-left":t=0}switch(e){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:t,verticalAlign:i}}function sd(e,t,i){const n=t.getMaxScale()*Ih,{maxImageWidth:r,maxImageHeight:o}=t.getMaxImageSize(e),s=Math.max(n,o*i);return{verticalLineContentWidth:Math.max(n,r*i),horizontalLineContentHeight:s}}function ad(e){switch(e){case"top":return 0;case"center":return.5;default:return 1}}function ld(t,i,n){return!(t===e.ax.horizontal||!i&&!wo(n)||i&&(Eo(n)||(r=n,/\p{sc=Arab}/u.test(String.fromCodePoint(r)))));var r}function cd(e,t,i,n,r,o){const s=o[e.fontStack],a=function(e,t,i,n){if(null==e?void 0:e.rect)return e;const r=t[i.fontStack],o=null==r?void 0:r[n];return o?{rect:null,metrics:o.metrics}:null}(null==s?void 0:s[t],r,e,t);if(null===a)return null;let l;if(i)l=n.verticalLineContentWidth-e.scale*Ih;else{const t=ad(e.verticalAlign);l=(n.horizontalLineContentHeight-e.scale*Ih)*t}return{rect:a.rect,metrics:a.metrics,baselineOffset:l}}function ud(e,t,i,n,r){const o=r[e.imageName];if(!o)return null;const s=o.paddedRect,a=o.displaySize,l={width:a[0],height:a[1],left:1,top:-3,advance:t?a[1]:a[0]};let c;if(t)c=n.verticalLineContentWidth-a[1]*e.scale;else{const t=ad(e.verticalAlign);c=(n.horizontalLineContentHeight-a[1]*e.scale)*t}return{rect:s,metrics:l,baselineOffset:c,imageOffset:(t?a[0]:a[1])*e.scale-Ih*i}}function hd(e,t,i,n){if(0===n)return;const r=e[i],o=(e[i].x+r.metrics.advance*r.scale)*n;for(let n=t;n<=i;n++)e[n].x-=o}function dd(e,t,i){const{horizontalAlign:n,verticalAlign:r}=od(i),o=t[0]-e.displaySize[0]*n,s=t[1]-e.displaySize[1]*r;return{image:e,top:s,bottom:s+e.displaySize[1],left:o,right:o+e.displaySize[0]}}function pd(e){var t,i;let n=e.left,r=e.top,o=e.right-n,s=e.bottom-r;const a=null!==(t=e.image.textFitWidth)&&void 0!==t?t:"stretchOrShrink",l=null!==(i=e.image.textFitHeight)&&void 0!==i?i:"stretchOrShrink",c=(e.image.content[2]-e.image.content[0])/(e.image.content[3]-e.image.content[1]);if("proportional"===l){if("stretchOnly"===a&&o/s<c||"proportional"===a){const e=Math.ceil(s*c);n*=e/o,o=e}}else if("proportional"===a&&"stretchOnly"===l&&0!==c&&o/s>c){const e=Math.ceil(o/c);r*=e/s,s=e}return{x1:n,y1:r,x2:n+o,y2:r+s}}function fd(e,t,i,n,r,o){const s=e.image;let a;if(s.content){const e=s.content,t=s.pixelRatio||1;a=[e[0]/t,e[1]/t,s.displaySize[0]-e[2]/t,s.displaySize[1]-e[3]/t]}const l=t.left*o,c=t.right*o;let u,h,d,p;"width"===i||"both"===i?(p=r[0]+l-n[3],h=r[0]+c+n[1]):(p=r[0]+(l+c-s.displaySize[0])/2,h=p+s.displaySize[0]);const f=t.top*o,m=t.bottom*o;return"height"===i||"both"===i?(u=r[1]+f-n[0],d=r[1]+m+n[2]):(u=r[1]+(f+m-s.displaySize[1])/2,d=u+s.displaySize[1]),{image:s,top:u,right:h,bottom:d,left:p,collisionPadding:a}}fo("ImagePosition",td),fo("ImageAtlas",id),e.ax=void 0,(nd=e.ax||(e.ax={}))[nd.none=0]="none",nd[nd.horizontal=1]="horizontal",nd[nd.vertical=2]="vertical",nd[nd.horizontalOnly=3]="horizontalOnly";const md=128,gd=32640;function yd(e,t){const{expression:i}=t;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new zo(e+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:n}=i;let r=0;for(;r<t.length&&t[r]<=e;)r++;r=Math.max(0,r-1);let o=r;for(;o<t.length&&t[o]<e+1;)o++;o=Math.min(t.length-1,o);const s=t[r],a=t[o];return"composite"===i.kind?{kind:"composite",minZoom:s,maxZoom:a,interpolationType:n}:{kind:"camera",minZoom:s,maxZoom:a,minSize:i.evaluate(new zo(s)),maxSize:i.evaluate(new zo(a)),interpolationType:n}}}function _d(e,t,i){let n="never";const r=e.get(t);return r?n=r:e.get(i)&&(n="always"),n}const vd=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function xd(e,t,i,n,r,o,s,a,l,c,u,h,d){const p=a?Math.min(gd,Math.round(a[0])):0,f=a?Math.min(gd,Math.round(a[1])):0;e.emplaceBack(t,i,Math.round(32*n),Math.round(32*r),o,s,(p<<1)+(l?1:0),f,16*c,16*u,256*h,256*d)}function bd(e,t,i){e.emplaceBack(t.x,t.y,i),e.emplaceBack(t.x,t.y,i),e.emplaceBack(t.x,t.y,i),e.emplaceBack(t.x,t.y,i)}function wd(e){for(const t of e.sections)if(Do(t.text))return!0;return!1}class Ed{constructor(e){this.layoutVertexArray=new Qs,this.indexArray=new ra,this.programConfigurations=e,this.segments=new la,this.dynamicLayoutVertexArray=new ea,this.opacityVertexArray=new ta,this.hasVisibleVertices=!1,this.placedSymbolArray=new Fs}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(e,t,i,n){this.isEmpty()||(i&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,vh.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,xh.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,vd,!0),this.opacityVertexBuffer.itemSize=1),(i||n)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}fo("SymbolBuffers",Ed);class Td{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new la,this.collisionVertexArray=new na}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,bh.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}fo("CollisionBuffers",Td);class Sd{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(e=>e.id),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=yd(this.zoom,i["text-size"]),this.iconSizeData=yd(this.zoom,i["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),o=n.get("symbol-z-order");this.canOverlap="never"!==_d(n,"text-overlap","text-allow-overlap")||"never"!==_d(n,"icon-overlap","icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&!r.isConstant(),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===n.get("symbol-placement")&&(this.writingModes=n.get("text-writing-mode").map(t=>e.ax[t])),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=t.sourceID}createArrays(){this.text=new Ed(new Na(this.layers,this.zoom,e=>e.startsWith("text"))),this.icon=new Ed(new Na(this.layers,this.zoom,e=>e.startsWith("icon"))),this.glyphOffsetArray=new Bs,this.lineVertexArray=new Gs,this.symbolInstances=new Ns,this.textAnchorOffsets=new Vs}calculateGlyphDependencies(e,t,i,n,r){for(const o of e)if(t[o.codePointAt(0)]=!0,(i||n)&&r){const e=kh[o];e&&(t[e.codePointAt(0)]=!0)}}populate(t,i,n){var r;const o=this.layers[0],s=o.layout,a=s.get("text-font"),l=s.get("text-field"),c=s.get("icon-image"),u=("constant"!==l.value.kind||l.value.value instanceof Lt&&!l.value.value.isEmpty()||l.value.value.toString().length>0)&&("constant"!==a.value.kind||a.value.value.length>0),h="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,d=s.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const p=i.iconDependencies,f=i.glyphDependencies,m=i.availableImages,g=new zo(this.zoom);for(const{feature:i,id:l,index:c,sourceLayerIndex:y}of t){const t=o._featureFilter.needGeometry,_=qa(i,t);if(!o._featureFilter.filter(g,_,n))continue;let v,x;if(t||(_.geometry=Ua(i)),u){const e=o.getValueAndResolveTokens("text-field",_,n,m),t=Lt.factory(e);this.hasRTLText||(this.hasRTLText=wd(t)),(!this.hasRTLText||"unavailable"===Ro.getRTLTextPluginStatus()||this.hasRTLText&&Ro.isParsed())&&(v=Sh(t,o,_))}if(h){const e=o.getValueAndResolveTokens("icon-image",_,n,m);x=e instanceof Bt?e:Bt.fromString(e)}if(!v&&!x)continue;const b=this.sortFeaturesByKey?d.evaluate(_,{},n):void 0;if(this.features.push({id:l,text:v,icon:x,index:c,sourceLayerIndex:y,geometry:_.geometry,properties:i.properties,type:Rc.types[i.type],sortKey:b}),x&&(p[x.name]=!0),v){const t=a.evaluate(_,{},n).join(","),i="viewport"!==s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement");this.allowVerticalPlacement=null===(r=this.writingModes)||void 0===r?void 0:r.includes(e.ax.vertical);for(const e of v.sections)if(e.image)p[e.image.name]=!0;else{const n=To(v.toString()),r=e.fontStack||t;f[r]||(f[r]={}),this.calculateGlyphDependencies(e.text,f[r],i,this.allowVerticalPlacement,n)}}}"line"===s.get("symbol-placement")&&(this.features=function(e){const t={},i={},n=[];let r=0;function o(t){n.push(e[t]),r++}function s(e,t,r){const o=i[e];return delete i[e],i[t]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(e,i,r){const o=t[i];return delete t[i],t[e]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(e,t,i){const n=i?t[0][t[0].length-1]:t[0][0];return`${e}:${n.x}:${n.y}`}for(let c=0;c<e.length;c++){const u=e[c],h=u.geometry,d=u.text?u.text.toString():null;if(!d){o(c);continue}const p=l(d,h),f=l(d,h,!0);if(p in i&&f in t&&i[p]!==t[f]){const e=a(p,f,h),r=s(p,f,n[e].geometry);delete t[p],delete i[f],i[l(d,n[r].geometry,!0)]=r,n[e].geometry=null}else p in i?s(p,f,h):f in t?a(p,f,h):(o(c),t[p]=r-1,i[f]=r-1)}return n.filter(e=>e.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((e,t)=>e.sortKey-t.sortKey)}update(e,t,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:i}),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:i}))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const i=this.lineVertexArray.length;if(void 0!==e.segment){let i=e.dist(t[e.segment+1]),n=e.dist(t[e.segment]);const r={};for(let n=e.segment+1;n<t.length;n++)r[n]={x:t[n].x,y:t[n].y,tileUnitDistanceFromAnchor:i},n<t.length-1&&(i+=t[n+1].dist(t[n]));for(let i=e.segment||0;i>=0;i--)r[i]={x:t[i].x,y:t[i].y,tileUnitDistanceFromAnchor:n},i>0&&(n+=t[i-1].dist(t[i]));for(let e=0;e<t.length;e++){const t=r[e];this.lineVertexArray.emplaceBack(t.x,t.y,t.tileUnitDistanceFromAnchor)}}return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,i,n,r,o,s,a,l,c,u,h,d){const p=t.indexArray,f=t.layoutVertexArray,m=t.segments.prepareSegment(4*i.length,f,p,this.canOverlap?s.sortKey:void 0),g=this.glyphOffsetArray.length,y=m.vertexLength,_=this.allowVerticalPlacement&&a===e.ax.vertical?Math.PI/2:0,v=s.text&&s.text.sections;for(let e=0;e<i.length;e++){const{tl:r,tr:o,bl:a,br:c,tex:u,pixelOffsetTL:h,pixelOffsetBR:g,minFontScaleX:y,minFontScaleY:x,glyphOffset:b,isSDF:w,sectionIndex:E}=i[e],T=m.vertexLength,S=b[1];xd(f,l.x,l.y,r.x,S+r.y,u.x,u.y,n,w,h.x,h.y,y,x),xd(f,l.x,l.y,o.x,S+o.y,u.x+u.w,u.y,n,w,g.x,h.y,y,x),xd(f,l.x,l.y,a.x,S+a.y,u.x,u.y+u.h,n,w,h.x,g.y,y,x),xd(f,l.x,l.y,c.x,S+c.y,u.x+u.w,u.y+u.h,n,w,g.x,g.y,y,x),bd(t.dynamicLayoutVertexArray,l,_),p.emplaceBack(T,T+2,T+1),p.emplaceBack(T+1,T+2,T+3),m.vertexLength+=4,m.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(b[0]),e!==i.length-1&&E===i[e+1].sectionIndex||t.programConfigurations.populatePaintArrays(f.length,s,s.index,{imagePositions:{},canonical:d,formattedSection:null==v?void 0:v[E]})}t.placedSymbolArray.emplaceBack(l.x,l.y,g,this.glyphOffsetArray.length-g,y,c,u,l.segment,n?n[0]:0,n?n[1]:0,r[0],r[1],a,0,!1,0,h)}_addCollisionDebugVertex(e,t,i,n,r,o){return t.emplaceBack(0,0),e.emplaceBack(i.x,i.y,n,r,Math.round(o.x),Math.round(o.y))}addCollisionDebugVertices(e,t,n,r,o,s,a){const l=o.segments.prepareSegment(4,o.layoutVertexArray,o.indexArray),c=l.vertexLength,u=o.layoutVertexArray,h=o.collisionVertexArray,d=a.anchorX,p=a.anchorY;this._addCollisionDebugVertex(u,h,s,d,p,new i(e,t)),this._addCollisionDebugVertex(u,h,s,d,p,new i(n,t)),this._addCollisionDebugVertex(u,h,s,d,p,new i(n,r)),this._addCollisionDebugVertex(u,h,s,d,p,new i(e,r)),l.vertexLength+=4;const f=o.indexArray;f.emplaceBack(c,c+1),f.emplaceBack(c+1,c+2),f.emplaceBack(c+2,c+3),f.emplaceBack(c+3,c),l.primitiveLength+=4}addDebugCollisionBoxes(e,t,i,n){for(let r=e;r<t;r++){const e=this.collisionBoxArray.get(r);this.addCollisionDebugVertices(e.x1,e.y1,e.x2,e.y2,n?this.textCollisionBox:this.iconCollisionBox,e.anchorPoint,i)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Td(ia,wh.members,oa),this.iconCollisionBox=new Td(ia,wh.members,oa);for(let e=0;e<this.symbolInstances.length;e++){const t=this.symbolInstances.get(e);this.addDebugCollisionBoxes(t.textBoxStartIndex,t.textBoxEndIndex,t,!0),this.addDebugCollisionBoxes(t.verticalTextBoxStartIndex,t.verticalTextBoxEndIndex,t,!0),this.addDebugCollisionBoxes(t.iconBoxStartIndex,t.iconBoxEndIndex,t,!1),this.addDebugCollisionBoxes(t.verticalIconBoxStartIndex,t.verticalIconBoxEndIndex,t,!1)}}_deserializeCollisionBoxesForSymbol(e,t,i,n,r,o,s,a,l){const c={};for(let n=t;n<i;n++){const t=e.get(n);c.textBox={x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,anchorPointX:t.anchorPointX,anchorPointY:t.anchorPointY},c.textFeatureIndex=t.featureIndex;break}for(let t=n;t<r;t++){const i=e.get(t);c.verticalTextBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},c.verticalTextFeatureIndex=i.featureIndex;break}for(let t=o;t<s;t++){const i=e.get(t);c.iconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},c.iconFeatureIndex=i.featureIndex;break}for(let t=a;t<l;t++){const i=e.get(t);c.verticalIconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},c.verticalIconFeatureIndex=i.featureIndex;break}return c}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let t=0;t<this.symbolInstances.length;t++){const i=this.symbolInstances.get(t);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,i.textBoxStartIndex,i.textBoxEndIndex,i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i.iconBoxStartIndex,i.iconBoxEndIndex,i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,t){const i=e.placedSymbolArray.get(t),n=i.vertexStartIndex+4*i.numGlyphs;for(let t=i.vertexStartIndex;t<n;t+=4)e.indexArray.emplaceBack(t,t+2,t+1),e.indexArray.emplaceBack(t+1,t+2,t+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const t=Math.sin(e),i=Math.cos(e),n=[],r=[],o=[];for(let e=0;e<this.symbolInstances.length;++e){o.push(e);const s=this.symbolInstances.get(e);n.push(0|Math.round(t*s.anchorX+i*s.anchorY)),r.push(s.featureIndex)}return o.sort((e,t)=>n[e]-n[t]||r[t]-r[e]),o}addToSortKeyRanges(e,t){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];(null==i?void 0:i.sortKey)===t?i.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);const i=[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex];for(let e=0;e<i.length;e++){const t=i[e];t>=0&&i.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t)}t.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,t.verticalPlacedTextSymbolIndex),t.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.placedIconSymbolIndex),t.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Id,kd;fo("SymbolBucket",Sd,{omit:["layers","collisionBoxArray","features","compareText"]}),Sd.MAX_GLYPHS=65535,Sd.addDynamicAttributes=bd;var Md={get paint(){return kd=kd||new Jo({"icon-opacity":new Ho(xe.paint_symbol["icon-opacity"]),"icon-color":new Ho(xe.paint_symbol["icon-color"]),"icon-halo-color":new Ho(xe.paint_symbol["icon-halo-color"]),"icon-halo-width":new Ho(xe.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Ho(xe.paint_symbol["icon-halo-blur"]),"icon-translate":new $o(xe.paint_symbol["icon-translate"]),"icon-translate-anchor":new $o(xe.paint_symbol["icon-translate-anchor"]),"text-opacity":new Ho(xe.paint_symbol["text-opacity"]),"text-color":new Ho(xe.paint_symbol["text-color"],{runtimeType:Ge,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Ho(xe.paint_symbol["text-halo-color"]),"text-halo-width":new Ho(xe.paint_symbol["text-halo-width"]),"text-halo-blur":new Ho(xe.paint_symbol["text-halo-blur"]),"text-translate":new $o(xe.paint_symbol["text-translate"]),"text-translate-anchor":new $o(xe.paint_symbol["text-translate-anchor"])})},get layout(){return Id=Id||new Jo({"symbol-placement":new $o(xe.layout_symbol["symbol-placement"]),"symbol-spacing":new $o(xe.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new $o(xe.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Ho(xe.layout_symbol["symbol-sort-key"]),"symbol-z-order":new $o(xe.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new $o(xe.layout_symbol["icon-allow-overlap"]),"icon-overlap":new $o(xe.layout_symbol["icon-overlap"]),"icon-ignore-placement":new $o(xe.layout_symbol["icon-ignore-placement"]),"icon-optional":new $o(xe.layout_symbol["icon-optional"]),"icon-rotation-alignment":new $o(xe.layout_symbol["icon-rotation-alignment"]),"icon-size":new Ho(xe.layout_symbol["icon-size"]),"icon-text-fit":new $o(xe.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new $o(xe.layout_symbol["icon-text-fit-padding"]),"icon-image":new Ho(xe.layout_symbol["icon-image"]),"icon-rotate":new Ho(xe.layout_symbol["icon-rotate"]),"icon-padding":new Ho(xe.layout_symbol["icon-padding"]),"icon-keep-upright":new $o(xe.layout_symbol["icon-keep-upright"]),"icon-offset":new Ho(xe.layout_symbol["icon-offset"]),"icon-anchor":new Ho(xe.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new $o(xe.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new $o(xe.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new $o(xe.layout_symbol["text-rotation-alignment"]),"text-field":new Ho(xe.layout_symbol["text-field"]),"text-font":new Ho(xe.layout_symbol["text-font"]),"text-size":new Ho(xe.layout_symbol["text-size"]),"text-max-width":new Ho(xe.layout_symbol["text-max-width"]),"text-line-height":new $o(xe.layout_symbol["text-line-height"]),"text-letter-spacing":new Ho(xe.layout_symbol["text-letter-spacing"]),"text-justify":new Ho(xe.layout_symbol["text-justify"]),"text-radial-offset":new Ho(xe.layout_symbol["text-radial-offset"]),"text-variable-anchor":new $o(xe.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Ho(xe.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Ho(xe.layout_symbol["text-anchor"]),"text-max-angle":new $o(xe.layout_symbol["text-max-angle"]),"text-writing-mode":new $o(xe.layout_symbol["text-writing-mode"]),"text-rotate":new Ho(xe.layout_symbol["text-rotate"]),"text-padding":new $o(xe.layout_symbol["text-padding"]),"text-keep-upright":new $o(xe.layout_symbol["text-keep-upright"]),"text-transform":new Ho(xe.layout_symbol["text-transform"]),"text-offset":new Ho(xe.layout_symbol["text-offset"]),"text-allow-overlap":new $o(xe.layout_symbol["text-allow-overlap"]),"text-overlap":new $o(xe.layout_symbol["text-overlap"]),"text-ignore-placement":new $o(xe.layout_symbol["text-ignore-placement"]),"text-optional":new $o(xe.layout_symbol["text-optional"])})}};class Cd{constructor(e){if(void 0===e.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:Fe,this.defaultValue=e}evaluate(e){if(e.formattedSection){const t=this.defaultValue.property.overrides;if(null==t?void 0:t.hasOverride(e.formattedSection))return t.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}fo("FormatSectionOverride",Cd,{omit:["defaultValue"]});class Pd extends es{constructor(e,t){super(e,Md,t)}recalculate(e,t){if(super.recalculate(e,t),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const e=this.layout.get("text-writing-mode");if(e){const t=[];for(const i of e)t.includes(i)||t.push(i);this.layout._values["text-writing-mode"]=t}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,t,i,n){const r=this.layout.get(e).evaluate(t,{},i,n),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||nr(o.value)||!r?r:function(e,t){return t.replace(/{([^{}]+)}/g,(t,i)=>e&&i in e?String(e[i]):"")}(t.properties,r)}createBucket(e){return new Sd(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of Md.paint.overridableProperties){if(!Pd.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),i=new Cd(t),n=new ir(i,t.property.specification);let r=null;r="constant"===t.value.kind||"source"===t.value.kind?new or("source",n):new sr("composite",n,t.value.zoomStops),this.paint._values[e]=new qo(t.property,r,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.isDataDriven())&&Pd.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const i=e.get("text-field"),n=Md.paint.properties[t];let r=!1;const o=e=>{var t;for(const i of e)if(null===(t=n.overrides)||void 0===t?void 0:t.hasOverride(i))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof Lt)o(i.value.value.sections);else if("source"===i.value.kind||"composite"===i.value.kind){const e=t=>{r||(t instanceof Zt&&Ut(t.value)===Ze?o(t.value.sections):t instanceof Ci?o(t.sections):t.eachChild(e))},t=i.value;t._styleExpression&&e(t._styleExpression.expression)}return r}}let Ad;var Ld={get paint(){return Ad=Ad||new Jo({"background-color":new $o(xe.paint_background["background-color"]),"background-pattern":new Xo(xe.paint_background["background-pattern"]),"background-opacity":new $o(xe.paint_background["background-opacity"])})}};class Dd extends es{constructor(e,t){super(e,Ld,t)}}class Rd extends es{constructor(e,t){super(e,{},t),this.onAdd=e=>{this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)},this.onRemove=e=>{this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)},this.implementation=e}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class zd{constructor(e){this._methodToThrottle=e,this._triggered=!1,this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()}}trigger(){var e;this._triggered||(this._triggered=!0,null===(e=this._channel)||void 0===e||e.port1.postMessage(!0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const Fd={once:!0},Od=6371008.8;class Nd{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Nd(N(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const t=Math.PI/180,i=this.lat*t,n=e.lat*t,r=Math.sin(i)*Math.sin(n)+Math.cos(i)*Math.cos(n)*Math.cos((e.lng-this.lng)*t);return Od*Math.acos(Math.min(r,1))}static convert(e){if(e instanceof Nd)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new Nd(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new Nd(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}const Bd=2*Math.PI*Od;function Gd(e){return Bd*Math.cos(e*Math.PI/180)}function jd(e){return(180+e)/360}function Vd(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Ud(e,t){return e/Gd(t)}function qd(e){return 360*e-180}function Zd(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function $d(e,t){return e*Gd(Zd(t))}class Hd{constructor(e,t,i=0){this.x=+e,this.y=+t,this.z=+i}static fromLngLat(e,t=0){const i=Nd.convert(e);return new Hd(jd(i.lng),Vd(i.lat),Ud(t,i.lat))}toLngLat(){return new Nd(qd(this.x),Zd(this.y))}toAltitude(){return $d(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Bd*(e=Zd(this.y),1/Math.cos(e*Math.PI/180));var e}}function Wd(e,t,i){var n=2*Math.PI*6378137/256/Math.pow(2,i);return[e*n-2*Math.PI*6378137/2,t*n-2*Math.PI*6378137/2]}class Xd{constructor(e,t,i){if(!function(e,t,i){return!(e<0||e>25||i<0||i>=Math.pow(2,e)||t<0||t>=Math.pow(2,e))}(e,t,i))throw new Error(`x=${t}, y=${i}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=t,this.y=i,this.key=Kd(0,e,e,t,i)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t,i){const n=(o=this.y,s=this.z,a=Wd(256*(r=this.x),256*(o=Math.pow(2,s)-o-1),s),l=Wd(256*(r+1),256*(o+1),s),a[0]+","+a[1]+","+l[0]+","+l[1]);var r,o,s,a,l;const c=function(e,t,i){let n="";for(let r=e;r>0;r--){const e=1<<r-1;n+=(t&e?1:0)+(i&e?2:0)}return n}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String("tms"===i?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,t>1?"@2x":"").replace(/{quadkey}/g,c).replace(/{bbox-epsg-3857}/g,n)}isChildOf(e){const t=this.z-e.z;return t>0&&e.x===this.x>>t&&e.y===this.y>>t}getTilePoint(e){const t=Math.pow(2,this.z);return new i((e.x*t-this.x)*C,(e.y*t-this.y)*C)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Yd{constructor(e,t){this.wrap=e,this.canonical=t,this.key=Kd(e,t.z,t.z,t.x,t.y)}}class Jd{constructor(e,t,i,n,r){if(this.terrainRttPosMatrix32f=null,e<i)throw new Error(`overscaledZ should be >= z; overscaledZ = ${e}; z = ${i}`);this.overscaledZ=e,this.wrap=t,this.canonical=new Xd(i,+n,+r),this.key=Kd(t,e,i,n,r)}clone(){return new Jd(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const t=this.canonical.z-e;return e>this.canonical.z?new Jd(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Jd(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(e,t){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const i=this.canonical.z-e;return e>this.canonical.z?Kd(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y):Kd(this.wrap*+t,e,e,this.canonical.x>>i,this.canonical.y>>i)}isChildOf(e){if(e.wrap!==this.wrap)return!1;if(this.overscaledZ-e.overscaledZ<=0)return!1;if(0===e.overscaledZ)return this.overscaledZ>0;const t=this.canonical.z-e.canonical.z;return!(t<0)&&e.canonical.x===this.canonical.x>>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new Jd(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,i=2*this.canonical.x,n=2*this.canonical.y;return[new Jd(t,this.wrap,t,i,n),new Jd(t,this.wrap,t,i+1,n),new Jd(t,this.wrap,t,i,n+1),new Jd(t,this.wrap,t,i+1,n+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new Jd(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new Jd(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Yd(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(e){return this.canonical.getTilePoint(new Hd(e.x-this.wrap,e.y))}normalizeCoordinates(e,t,i=8192){if(e>=0&&e<i&&t>=0&&t<i)return{tileID:this,x:e,y:t};const n=Math.floor(e/i),r=Math.floor(t/i),o=e-n*i,s=t-r*i,a=this.canonical.z,l=1<<a,c=this.canonical.y+r;if(c<0||c>=l)return null;let u=this.canonical.x+n,h=this.wrap;return u<0?(h-=Math.ceil(-u/l),u=(u%l+l)%l):u>=l&&(h+=Math.floor(u/l),u%=l),{tileID:new Jd(this.overscaledZ,h,a,u,c),x:o,y:s}}}function Kd(e,t,i,n,r){(e*=2)<0&&(e=-1*e-1);const o=1<<i;return(o*o*e+o*r+n).toString(36)+i.toString(36)+t.toString(36)}fo("CanonicalTileID",Xd),fo("OverscaledTileID",Jd,{omit:["terrainRttPosMatrix32f"]});class Qd{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(e){return this.minX=Math.min(this.minX,e.x),this.minY=Math.min(this.minY,e.y),this.maxX=Math.max(this.maxX,e.x),this.maxY=Math.max(this.maxY,e.y),this}expandBy(e){return this.minX-=e,this.minY-=e,this.maxX+=e,this.maxY+=e,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(e){return this.expandBy(-e)}map(e){const t=new Qd;return t.extend(e(new i(this.minX,this.minY))),t.extend(e(new i(this.maxX,this.minY))),t.extend(e(new i(this.minX,this.maxY))),t.extend(e(new i(this.maxX,this.maxY))),t}static fromPoints(e){const t=new Qd;for(const i of e)t.extend(i);return t}contains(e){return e.x>=this.minX&&e.x<=this.maxX&&e.y>=this.minY&&e.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(e){return!this.empty()&&!e.empty()&&e.minX>=this.minX&&e.maxX<=this.maxX&&e.minY>=this.minY&&e.maxY<=this.maxY}intersects(e){return!this.empty()&&!e.empty()&&e.minX<=this.maxX&&e.maxX>=this.minX&&e.minY<=this.maxY&&e.maxY>=this.minY}}class ep{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t<e.length;t++){const i=e[t];this._stringToNumber[i]=t,this._numberToString[t]=i}}encode(e){return this._stringToNumber[e]}decode(e){if(e>=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class tp{constructor(e,t,i,n,r){this.type="Feature",this._vectorTileFeature=e,this._x=i,this._y=n,this._z=t,this.properties=e.properties,this.id=r}projectPoint(e,t,i,n){return[360*(e.x+t)/n-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+i)/n)*Math.PI))-90]}projectLine(e,t,i,n){return e.map(e=>this.projectPoint(e,t,i,n))}get geometry(){if(this._geometry)return this._geometry;const e=this._vectorTileFeature,t=e.extent*Math.pow(2,this._z),i=e.extent*this._x,n=e.extent*this._y,r=e.loadGeometry();switch(e.type){case 1:{const e=[];for(const t of r)e.push(t[0]);const o=this.projectLine(e,i,n,t);this._geometry=1===e.length?{type:"Point",coordinates:o[0]}:{type:"MultiPoint",coordinates:o};break}case 2:{const e=r.map(e=>this.projectLine(e,i,n,t));this._geometry=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e};break}case 3:{const e=Fc(r),o=[];for(const r of e)o.push(r.map(e=>this.projectLine(e,i,n,t)));this._geometry=1===o.length?{type:"Polygon",coordinates:o[0]}:{type:"MultiPolygon",coordinates:o};break}default:throw new Error(`unknown feature type: ${e.type}`)}return this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const t in this)"_geometry"!==t&&"_vectorTileFeature"!==t&&"_x"!==t&&"_y"!==t&&"_z"!==t&&(e[t]=this[t]);return e}}class ip{constructor(e,t,i){this._name=e,this.dataBuffer=t,"number"==typeof i?this._size=i:(this.nullabilityBuffer=i,this._size=i.size())}getValue(e){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(e)?null:this.getValueFromBuffer(e)}has(e){return this.nullabilityBuffer?.get(e)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}}class np extends ip{}class rp extends np{getValueFromBuffer(e){return this.dataBuffer[e]}}class op extends np{getValueFromBuffer(e){return this.dataBuffer[e]}}class sp extends ip{constructor(e,t,i,n){super(e,t,n),this.delta=i}}class ap extends sp{constructor(e,t,i,n){super(e,Int32Array.of(t),i,n)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}}class lp extends ip{constructor(e,t,i,n){super(e,n?Int32Array.of(t):Uint32Array.of(t),i)}getValueFromBuffer(e){return this.dataBuffer[0]}}class cp{constructor(e,t,i,n,r=4096){this._name=e,this._geometryVector=t,this._idVector=i,this._propertyVectors=n,this._extent=r}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors}getPropertyVector(e){return this.propertyVectorsMap||(this.propertyVectorsMap=new Map(this._propertyVectors.map(e=>[e.name,e]))),this.propertyVectorsMap.get(e)}get numFeatures(){return this.geometryVector.numGeometries}get extent(){return this._extent}getFeatures(){const e=[],t=this.geometryVector.getGeometries();for(let i=0;i<this.numFeatures;i++){let n;if(this.idVector){const e=this.idVector.getValue(i);n=this.containsMaxSafeIntegerValues(this.idVector)&&null!==e?Number(e):e}const r={coordinates:t[i],type:this.geometryVector.geometryType(i)},o={};for(const e of this.propertyVectors){if(!e)continue;const t=e.name,n=e.getValue(i);null!==n&&(o[t]=n)}e.push({id:n,geometry:r,properties:o})}return e}containsMaxSafeIntegerValues(e){return e instanceof rp||e instanceof lp||e instanceof ap||e instanceof op}}class up{constructor(e){this.value=e}get(){return this.value}set(e){this.value=e}increment(){return this.value++}add(e){this.value+=e}}var hp,dp;!function(e){e.NONE="NONE",e.DELTA="DELTA",e.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",e.RLE="RLE",e.MORTON="MORTON",e.PDE="PDE"}(hp||(hp={})),function(e){e.NONE="NONE",e.FAST_PFOR="FAST_PFOR",e.VARINT="VARINT",e.ALP="ALP"}(dp||(dp={}));const pp=new Uint32Array(33);pp[0]=0;for(let e=1;e<=32;e++)pp[e]=32===e?4294967295:4294967295>>>32-e;const fp=pp,mp=256;function gp(e,t){return e-e%t}function yp(e){const t=e>>>0;return((255&t)<<24|(65280&t)<<8|t>>>8&65280|t>>>24&255)>>>0}const _p=function(){if(!Number.isFinite(65536))return 65536;const e=gp(Math.floor(65536),mp);return 0===e?mp:e}(),vp=3*_p/mp+_p|0;function xp(){const e=new Uint8Array(vp);return{dataToBePacked:new Array(33),dataPointers:new Int32Array(33),byteContainer:e,byteContainerI32:new Int32Array(e.buffer,e.byteOffset,e.byteLength>>>2),exceptionSizes:new Int32Array(33)}}function bp(e,t,i,n,r){switch(r){case 1:!function(e,t,i,n){let r=n,o=t;for(let t=0;t<8;t++){const t=e[o++]>>>0;i[r++]=t>>>0&1,i[r++]=t>>>1&1,i[r++]=t>>>2&1,i[r++]=t>>>3&1,i[r++]=t>>>4&1,i[r++]=t>>>5&1,i[r++]=t>>>6&1,i[r++]=t>>>7&1,i[r++]=t>>>8&1,i[r++]=t>>>9&1,i[r++]=t>>>10&1,i[r++]=t>>>11&1,i[r++]=t>>>12&1,i[r++]=t>>>13&1,i[r++]=t>>>14&1,i[r++]=t>>>15&1,i[r++]=t>>>16&1,i[r++]=t>>>17&1,i[r++]=t>>>18&1,i[r++]=t>>>19&1,i[r++]=t>>>20&1,i[r++]=t>>>21&1,i[r++]=t>>>22&1,i[r++]=t>>>23&1,i[r++]=t>>>24&1,i[r++]=t>>>25&1,i[r++]=t>>>26&1,i[r++]=t>>>27&1,i[r++]=t>>>28&1,i[r++]=t>>>29&1,i[r++]=t>>>30&1,i[r++]=t>>>31&1}}(e,t,i,n);break;case 2:!function(e,t,i,n){let r=n,o=t;for(let t=0;t<8;t++){const t=e[o++]>>>0,n=e[o++]>>>0;i[r++]=t>>>0&3,i[r++]=t>>>2&3,i[r++]=t>>>4&3,i[r++]=t>>>6&3,i[r++]=t>>>8&3,i[r++]=t>>>10&3,i[r++]=t>>>12&3,i[r++]=t>>>14&3,i[r++]=t>>>16&3,i[r++]=t>>>18&3,i[r++]=t>>>20&3,i[r++]=t>>>22&3,i[r++]=t>>>24&3,i[r++]=t>>>26&3,i[r++]=t>>>28&3,i[r++]=t>>>30&3,i[r++]=n>>>0&3,i[r++]=n>>>2&3,i[r++]=n>>>4&3,i[r++]=n>>>6&3,i[r++]=n>>>8&3,i[r++]=n>>>10&3,i[r++]=n>>>12&3,i[r++]=n>>>14&3,i[r++]=n>>>16&3,i[r++]=n>>>18&3,i[r++]=n>>>20&3,i[r++]=n>>>22&3,i[r++]=n>>>24&3,i[r++]=n>>>26&3,i[r++]=n>>>28&3,i[r++]=n>>>30&3}}(e,t,i,n);break;case 3:!function(e,t,i,n){let r=n,o=t;for(let t=0;t<8;t++){const t=e[o++]>>>0,n=e[o++]>>>0,s=e[o++]>>>0;i[r++]=t>>>0&7,i[r++]=t>>>3&7,i[r++]=t>>>6&7,i[r++]=t>>>9&7,i[r++]=t>>>12&7,i[r++]=t>>>15&7,i[r++]=t>>>18&7,i[r++]=t>>>21&7,i[r++]=t>>>24&7,i[r++]=t>>>27&7,i[r++]=7&(t>>>30|(1&n)<<2),i[r++]=n>>>1&7,i[r++]=n>>>4&7,i[r++]=n>>>7&7,i[r++]=n>>>10&7,i[r++]=n>>>13&7,i[r++]=n>>>16&7,i[r++]=n>>>19&7,i[r++]=n>>>22&7,i[r++]=n>>>25&7,i[r++]=n>>>28&7,i[r++]=7&(n>>>31|(3&s)<<1),i[r++]=s>>>2&7,i[r++]=s>>>5&7,i[r++]=s>>>8&7,i[r++]=s>>>11&7,i[r++]=s>>>14&7,i[r++]=s>>>17&7,i[r++]=s>>>20&7,i[r++]=s>>>23&7,i[r++]=s>>>26&7,i[r++]=s>>>29&7}}(e,t,i,n);break;case 4:!function(e,t,i,n){let r=n,o=t;for(let t=0;t<8;t++){const t=e[o++]>>>0,n=e[o++]>>>0,s=e[o++]>>>0,a=e[o++]>>>0;i[r++]=t>>>0&15,i[r++]=t>>>4&15,i[r++]=t>>>8&15,i[r++]=t>>>12&15,i[r++]=t>>>16&15,i[r++]=t>>>20&15,i[r++]=t>>>24&15,i[r++]=t>>>28&15,i[r++]=n>>>0&15,i[r++]=n>>>4&15,i[r++]=n>>>8&15,i[r++]=n>>>12&15,i[r++]=n>>>16&15,i[r++]=n>>>20&15,i[r++]=n>>>24&15,i[r++]=n>>>28&15,i[r++]=s>>>0&15,i[r++]=s>>>4&15,i[r++]=s>>>8&15,i[r++]=s>>>12&15,i[r++]=s>>>16&15,i[r++]=s>>>20&15,i[r++]=s>>>24&15,i[r++]=s>>>28&15,i[r++]=a>>>0&15,i[r++]=a>>>4&15,i[r++]=a>>>8&15,i[r++]=a>>>12&15,i[r++]=a>>>16&15,i[r++]=a>>>20&15,i[r++]=a>>>24&15,i[r++]=a>>>28&15}}(e,t,i,n);break;case 5:!function(e,t,i,n){let r=n,o=t;for(let t=0;t<8;t++){const t=e[o++]>>>0,n=e[o++]>>>0,s=e[o++]>>>0,a=e[o++]>>>0,l=e[o++]>>>0;i[r++]=t>>>0&31,i[r++]=t>>>5&31,i[r++]=t>>>10&31,i[r++]=t>>>15&31,i[r++]=t>>>20&31,i[r++]=t>>>25&31,i[r++]=31&(t>>>30|(7&n)<<2),i[r++]=n>>>3&31,i[r++]=n>>>8&31,i[r++]=n>>>13&31,i[r++]=n>>>18&31,i[r++]=n>>>23&31,i[r++]=31&(n>>>28|(1&s)<<4),i[r++]=s>>>1&31,i[r++]=s>>>6&31,i[r++]=s>>>11&31,i[r++]=s>>>16&31,i[r++]=s>>>21&31,i[r++]=s>>>26&31,i[r++]=31&(s>>>31|(15&a)<<1),i[r++]=a>>>4&31,i[r++]=a>>>9&31,i[r++]=a>>>14&31,i[r++]=a>>>19&31,i[r++]=a>>>24&31,i[r++]=31&(a>>>29|(3&l)<<3),i[r++]=l>>>2&31,i[r++]=l>>>7&31,i[r++]=l>>>12&31,i[r++]=l>>>17&31,i[r++]=l>>>22&31,i[r++]=l>>>27&31}}(e,t,i,n);break;case 6:!function(e,t,i,n){let r=n,o=t;for(let t=0;t<8;t++){const t=e[o++]>>>0,n=e[o++]>>>0,s=e[o++]>>>0,a=e[o++]>>>0,l=e[o++]>>>0,c=e[o++]>>>0;i[r++]=t>>>0&63,i[r++]=t>>>6&63,i[r++]=t>>>12&63,i[r++]=t>>>18&63,i[r++]=t>>>24&63,i[r++]=63&(t>>>30|(15&n)<<2),i[r++]=n>>>4&63,i[r++]=n>>>10&63,i[r++]=n>>>16&63,i[r++]=n>>>22&63,i[r++]=63&(n>>>28|(3&s)<<4),i[r++]=s>>>2&63,i[r++]=s>>>8&63,i[r++]=s>>>14&63,i[r++]=s>>>20&63,i[r++]=s>>>26&63,i[r++]=a>>>0&63,i[r++]=a>>>6&63,i[r++]=a>>>12&63,i[r++]=a>>>18&63,i[r++]=a>>>24&63,i[r++]=63&(a>>>30|(15&l)<<2),i[r++]=l>>>4&63,i[r++]=l>>>10&63,i[r++]=l>>>16&63,i[r++]=l>>>22&63,i[r++]=63&(l>>>28|(3&c)<<4),i[r++]=c>>>2&63,i[r++]=c>>>8&63,i[r++]=c>>>14&63,i[r++]=c>>>20&63,i[r++]=c>>>26&63}}(e,t,i,n);break;case 7:!function(e,t,i,n){let r=n,o=t;for(let t=0;t<8;t++){const t=e[o++]>>>0,n=e[o++]>>>0,s=e[o++]>>>0,a=e[o++]>>>0,l=e[o++]>>>0,c=e[o++]>>>0,u=e[o++]>>>0;i[r++]=t>>>0&127,i[r++]=t>>>7&127,i[r++]=t>>>14&127,i[r++]=t>>>21&127,i[r++]=127&(t>>>28|(7&n)<<4),i[r++]=n>>>3&127,i[r++]=n>>>10&127,i[r++]=n>>>17&127,i[r++]=n>>>24&127,i[r++]=127&(n>>>31|(63&s)<<1),i[r++]=s>>>6&127,i[r++]=s>>>13&127,i[r++]=s>>>20&127,i[r++]=127&(s>>>27|(3&a)<<5),i[r++]=a>>>2&127,i[r++]=a>>>9&127,i[r++]=a>>>16&127,i[r++]=a>>>23&127,i[r++]=127&(a>>>30|(31&l)<<2),i[r++]=l>>>5&127,i[r++]=l>>>12&127,i[r++]=l>>>19&127,i[r++]=127&(l>>>26|(1&c)<<6),i[r++]=c>>>1&127,i[r++]=c>>>8&127,i[r++]=c>>>15&127,i[r++]=c>>>22&127,i[r++]=127&(c>>>29|(15&u)<<3),i[r++]=u>>>4&127,i[r++]=u>>>11&127,i[r++]=u>>>18&127,i[r++]=u>>>25&127}}(e,t,i,n);break;case 8:!function(e,t,i,n){let r=n,o=t;for(let t=0;t<8;t++){const t=e[o++]>>>0,n=e[o++]>>>0,s=e[o++]>>>0,a=e[o++]>>>0,l=e[o++]>>>0,c=e[o++]>>>0,u=e[o++]>>>0,h=e[o++]>>>0;i[r++]=t>>>0&255,i[r++]=t>>>8&255,i[r++]=t>>>16&255,i[r++]=t>>>24&255,i[r++]=n>>>0&255,i[r++]=n>>>8&255,i[r++]=n>>>16&255,i[r++]=n>>>24&255,i[r++]=s>>>0&255,i[r++]=s>>>8&255,i[r++]=s>>>16&255,i[r++]=s>>>24&255,i[r++]=a>>>0&255,i[r++]=a>>>8&255,i[r++]=a>>>16&255,i[r++]=a>>>24&255,i[r++]=l>>>0&255,i[r++]=l>>>8&255,i[r++]=l>>>16&255,i[r++]=l>>>24&255,i[r++]=c>>>0&255,i[r++]=c>>>8&255,i[r++]=c>>>16&255,i[r++]=c>>>24&255,i[r++]=u>>>0&255,i[r++]=u>>>8&255,i[r++]=u>>>16&255,i[r++]=u>>>24&255,i[r++]=h>>>0&255,i[r++]=h>>>8&255,i[r++]=h>>>16&255,i[r++]=h>>>24&255}}(e,t,i,n);break;case 16:!function(e,t,i,n){let r=n,o=t;for(let t=0;t<128;t++){const t=e[o++]>>>0;i[r++]=65535&t,i[r++]=t>>>16&65535}}(e,t,i,n);break;default:!function(e,t,i,n,r){const o=fp[r]>>>0;let s=t,a=0,l=e[s]>>>0,c=n;for(let t=0;t<8;t++){for(let t=0;t<32;t++)if(a+r<=32)i[c+t]=l>>>a&o,a+=r,32===a&&(a=0,s++,31!==t&&(l=e[s]>>>0));else{const n=32-a,u=l>>>a;s++,l=e[s]>>>0;const h=r-n;i[c+t]=(u|(l&-1>>>32-h>>>0)<<n)&o,a=h}c+=32,a=0,t<7&&(l=e[s]>>>0)}}(e,t,i,n,r)}return t+(r<<3)|0}function wp(e,t,i,n){if(i+2>t)throw new Error(`FastPFOR decode: byteContainer underflow at block=${n} (need 2 bytes for [bitWidth, exceptionCount], bytePos=${i}, byteSize=${t})`);const r=e[i++],o=e[i++];if(r>32)throw new Error(`FastPFOR decode: invalid bitWidth=${r} at block=${n} (expected 0..32). This likely indicates corrupted or truncated input.`);return{bitWidth:r,exceptionCount:o,bytePosIn:i}}function Ep(e,t,i,n,r,o,s,a,l){const{maxBits:c,exceptionBitWidth:u,bytePosIn:h}=function(e,t,i,n,r,o){if(i+1>t)throw new Error(`FastPFOR decode: exception header underflow at block=${o} (need 1 byte for maxBits, bytePos=${i}, byteSize=${t})`);const s=e[i++];if(s<n||s>32)throw new Error(`FastPFOR decode: invalid maxBits=${s} at block=${o} (bitWidth=${n}, expected ${n}..32)`);const a=s-n|0;if(a<1||a>32)throw new Error(`FastPFOR decode: invalid exceptionBitWidth=${a} at block=${o} (bitWidth=${n}, maxBits=${s})`);if(i+r>t)throw new Error(`FastPFOR decode: exception positions underflow at block=${o} (need=${r}, have=${t-i})`);return{maxBits:s,exceptionBitWidth:a,bytePosIn:i}}(r,o,s,i,n,l);if(s=h,1===u){const o=1<<i;for(let i=0;i<n;i=i+1|0)e[r[s++]+t|0]|=o;return s}const d=a.dataToBePacked[u];if(!d)throw new Error(`FastPFOR decode: missing exception stream for exceptionBitWidth=${u} (bitWidth=${i}, maxBits=${c}) at block ${l}`);const p=a.dataPointers;let f=0|p[u];const m=0|a.exceptionSizes[u];if(f+n>m)throw new Error(`FastPFOR decode: exception stream overflow for exceptionBitWidth=${u} (ptr=${f}, need ${n}, size=${m}) at block ${l}`);for(let o=0;o<n;o=o+1|0){const n=r[s++],o=0|d[f++];e[n+t|0]|=o<<i}return p[u]=f,s}function Tp(e,t,i,n,r,o){const s=0|i,a=0|e[s];if(a<=0||s+a>e.length-1)throw new Error(`FastPFOR decode: invalid whereMeta=${a} at pageStart=${s} (expected > 0 and pageStart+whereMeta < encoded.length=${e.length})`);const l=s+1|0,c=s+a|0,u=e[c]>>>0,h=u+3>>>2,d=c+1,p=d+h;if(p>=e.length)throw new Error(`FastPFOR decode: invalid byteSize=${u} (metaInts=${h}, pageStart=${s}, packedEnd=${c}, byteContainerStart=${d}) causes bitmapPos=${p} out of bounds (encoded.length=${e.length})`);const f=function(e,t,i,n){n.byteContainer.length<i&&(n.byteContainer=new Uint8Array(2*i),n.byteContainerI32=void 0);const r=n.byteContainer,o=i>>>2;if(3&r.byteOffset)for(let i=0;i<o;i=i+1|0){const n=0|e[t+i|0],o=i<<2;r[o]=255&n,r[o+1|0]=n>>>8&255,r[o+2|0]=n>>>16&255,r[o+3|0]=n>>>24&255}else{let i=n.byteContainerI32;(!i||i.buffer!==r.buffer||i.byteOffset!==r.byteOffset||i.length<o)&&(i=n.byteContainerI32=new Int32Array(r.buffer,r.byteOffset,r.byteLength>>>2)),i.set(e.subarray(t,t+o))}const s=3&i;if(s>0){const i=0|e[t+o|0],n=o<<2;for(let e=0;e<s;e=e+1|0)r[n+e|0]=i>>>(e<<3)&255}return r}(e,d,u,o),m=u,g=function(e,t,i){const n=0|e[t++],r=i.dataToBePacked;for(let o=2;o<=32;o=o+1|0){if(!(n>>>o-1&1))continue;if(t>=e.length)throw new Error(`FastPFOR decode: truncated exception stream header (bitWidth=${o}, streamWordIndex=${t}, needWords=1, availableWords=${e.length-t}, encodedWords=${e.length})`);const s=e[t++]>>>0,a=gp(s+31,32),l=s*o+31>>>5;if(t+l>e.length)throw new Error(`FastPFOR decode: truncated exception stream (bitWidth=${o}, size=${s}, streamWordIndex=${t}, needWords=${l}, availableWords=${e.length-t}, encodedWords=${e.length})`);let c=r[o];(!c||c.length<a)&&(c=r[o]=new Uint32Array(a));let u=0;for(;u<s;u=u+32|0)Sp(e,t,c,u,o),t=t+o|0;t=t-((u-s|0)*o>>>5)|0,i.exceptionSizes[o]=s}return t}(e,p,o);return o.dataPointers.fill(0),function(e,t,i,n,r,o,s,a,l,c){let u=0|i,h=0;for(let t=0;t<s;t=t+1|0){const i=wp(a,l,h,t);h=i.bytePosIn;const n=i.bitWidth,s=i.exceptionCount,d=o+t*mp|0;switch(n){case 0:r.fill(0,d,d+mp);break;case 32:for(let t=0;t<mp;t=t+1|0)r[d+t|0]=0|e[u+t|0];u=u+mp|0;break;default:u=bp(e,u,r,d,n)}s>0&&(h=Ep(r,d,n,s,a,l,h,c,t))}if(u!==n)throw new Error(`FastPFOR decode: packed region mismatch (pageStart=${t}, packedStart=${i}, consumedPackedEnd=${u}, expectedPackedEnd=${n}, packedWords=${n-i}, encoded.length=${e.length})`)}(e,s,l,c,t,0|n,r/mp|0,f,m,o),g}function Sp(e,t,i,n,r){switch(r){case 2:return void function(e,t,i,n){let r=n;const o=e[t]>>>0,s=e[t+1]>>>0;i[r++]=o>>>0&3,i[r++]=o>>>2&3,i[r++]=o>>>4&3,i[r++]=o>>>6&3,i[r++]=o>>>8&3,i[r++]=o>>>10&3,i[r++]=o>>>12&3,i[r++]=o>>>14&3,i[r++]=o>>>16&3,i[r++]=o>>>18&3,i[r++]=o>>>20&3,i[r++]=o>>>22&3,i[r++]=o>>>24&3,i[r++]=o>>>26&3,i[r++]=o>>>28&3,i[r++]=o>>>30&3,i[r++]=s>>>0&3,i[r++]=s>>>2&3,i[r++]=s>>>4&3,i[r++]=s>>>6&3,i[r++]=s>>>8&3,i[r++]=s>>>10&3,i[r++]=s>>>12&3,i[r++]=s>>>14&3,i[r++]=s>>>16&3,i[r++]=s>>>18&3,i[r++]=s>>>20&3,i[r++]=s>>>22&3,i[r++]=s>>>24&3,i[r++]=s>>>26&3,i[r++]=s>>>28&3,i[r]=s>>>30&3}(e,t,i,n);case 3:return void function(e,t,i,n){let r=n;const o=e[t]>>>0,s=e[t+1]>>>0,a=e[t+2]>>>0;i[r++]=o>>>0&7,i[r++]=o>>>3&7,i[r++]=o>>>6&7,i[r++]=o>>>9&7,i[r++]=o>>>12&7,i[r++]=o>>>15&7,i[r++]=o>>>18&7,i[r++]=o>>>21&7,i[r++]=o>>>24&7,i[r++]=o>>>27&7,i[r++]=7&(o>>>30|(1&s)<<2),i[r++]=s>>>1&7,i[r++]=s>>>4&7,i[r++]=s>>>7&7,i[r++]=s>>>10&7,i[r++]=s>>>13&7,i[r++]=s>>>16&7,i[r++]=s>>>19&7,i[r++]=s>>>22&7,i[r++]=s>>>25&7,i[r++]=s>>>28&7,i[r++]=7&(s>>>31|(3&a)<<1),i[r++]=a>>>2&7,i[r++]=a>>>5&7,i[r++]=a>>>8&7,i[r++]=a>>>11&7,i[r++]=a>>>14&7,i[r++]=a>>>17&7,i[r++]=a>>>20&7,i[r++]=a>>>23&7,i[r++]=a>>>26&7,i[r]=a>>>29&7}(e,t,i,n);case 4:return void function(e,t,i,n){let r=n;const o=e[t]>>>0,s=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0;i[r++]=o>>>0&15,i[r++]=o>>>4&15,i[r++]=o>>>8&15,i[r++]=o>>>12&15,i[r++]=o>>>16&15,i[r++]=o>>>20&15,i[r++]=o>>>24&15,i[r++]=o>>>28&15,i[r++]=s>>>0&15,i[r++]=s>>>4&15,i[r++]=s>>>8&15,i[r++]=s>>>12&15,i[r++]=s>>>16&15,i[r++]=s>>>20&15,i[r++]=s>>>24&15,i[r++]=s>>>28&15,i[r++]=a>>>0&15,i[r++]=a>>>4&15,i[r++]=a>>>8&15,i[r++]=a>>>12&15,i[r++]=a>>>16&15,i[r++]=a>>>20&15,i[r++]=a>>>24&15,i[r++]=a>>>28&15,i[r++]=l>>>0&15,i[r++]=l>>>4&15,i[r++]=l>>>8&15,i[r++]=l>>>12&15,i[r++]=l>>>16&15,i[r++]=l>>>20&15,i[r++]=l>>>24&15,i[r]=l>>>28&15}(e,t,i,n);case 5:return void function(e,t,i,n){let r=n;const o=e[t]>>>0,s=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0;i[r++]=o>>>0&31,i[r++]=o>>>5&31,i[r++]=o>>>10&31,i[r++]=o>>>15&31,i[r++]=o>>>20&31,i[r++]=o>>>25&31,i[r++]=31&(o>>>30|(7&s)<<2),i[r++]=s>>>3&31,i[r++]=s>>>8&31,i[r++]=s>>>13&31,i[r++]=s>>>18&31,i[r++]=s>>>23&31,i[r++]=31&(s>>>28|(1&a)<<4),i[r++]=a>>>1&31,i[r++]=a>>>6&31,i[r++]=a>>>11&31,i[r++]=a>>>16&31,i[r++]=a>>>21&31,i[r++]=a>>>26&31,i[r++]=31&(a>>>31|(15&l)<<1),i[r++]=l>>>4&31,i[r++]=l>>>9&31,i[r++]=l>>>14&31,i[r++]=l>>>19&31,i[r++]=l>>>24&31,i[r++]=31&(l>>>29|(3&c)<<3),i[r++]=c>>>2&31,i[r++]=c>>>7&31,i[r++]=c>>>12&31,i[r++]=c>>>17&31,i[r++]=c>>>22&31,i[r]=c>>>27&31}(e,t,i,n);case 6:return void function(e,t,i,n){let r=n;const o=e[t]>>>0,s=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0,u=e[t+5]>>>0;i[r++]=o>>>0&63,i[r++]=o>>>6&63,i[r++]=o>>>12&63,i[r++]=o>>>18&63,i[r++]=o>>>24&63,i[r++]=63&(o>>>30|(15&s)<<2),i[r++]=s>>>4&63,i[r++]=s>>>10&63,i[r++]=s>>>16&63,i[r++]=s>>>22&63,i[r++]=63&(s>>>28|(3&a)<<4),i[r++]=a>>>2&63,i[r++]=a>>>8&63,i[r++]=a>>>14&63,i[r++]=a>>>20&63,i[r++]=a>>>26&63,i[r++]=l>>>0&63,i[r++]=l>>>6&63,i[r++]=l>>>12&63,i[r++]=l>>>18&63,i[r++]=l>>>24&63,i[r++]=63&(l>>>30|(15&c)<<2),i[r++]=c>>>4&63,i[r++]=c>>>10&63,i[r++]=c>>>16&63,i[r++]=c>>>22&63,i[r++]=63&(c>>>28|(3&u)<<4),i[r++]=u>>>2&63,i[r++]=u>>>8&63,i[r++]=u>>>14&63,i[r++]=u>>>20&63,i[r]=u>>>26&63}(e,t,i,n);case 7:return void function(e,t,i,n){let r=n;const o=e[t]>>>0,s=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0,u=e[t+5]>>>0,h=e[t+6]>>>0;i[r++]=o>>>0&127,i[r++]=o>>>7&127,i[r++]=o>>>14&127,i[r++]=o>>>21&127,i[r++]=127&(o>>>28|(7&s)<<4),i[r++]=s>>>3&127,i[r++]=s>>>10&127,i[r++]=s>>>17&127,i[r++]=s>>>24&127,i[r++]=127&(s>>>31|(63&a)<<1),i[r++]=a>>>6&127,i[r++]=a>>>13&127,i[r++]=a>>>20&127,i[r++]=127&(a>>>27|(3&l)<<5),i[r++]=l>>>2&127,i[r++]=l>>>9&127,i[r++]=l>>>16&127,i[r++]=l>>>23&127,i[r++]=127&(l>>>30|(31&c)<<2),i[r++]=c>>>5&127,i[r++]=c>>>12&127,i[r++]=c>>>19&127,i[r++]=127&(c>>>26|(1&u)<<6),i[r++]=u>>>1&127,i[r++]=u>>>8&127,i[r++]=u>>>15&127,i[r++]=u>>>22&127,i[r++]=127&(u>>>29|(15&h)<<3),i[r++]=h>>>4&127,i[r++]=h>>>11&127,i[r++]=h>>>18&127,i[r]=h>>>25&127}(e,t,i,n);case 8:return void function(e,t,i,n){let r=n;const o=e[t]>>>0,s=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0,u=e[t+5]>>>0,h=e[t+6]>>>0,d=e[t+7]>>>0;i[r++]=o>>>0&255,i[r++]=o>>>8&255,i[r++]=o>>>16&255,i[r++]=o>>>24&255,i[r++]=s>>>0&255,i[r++]=s>>>8&255,i[r++]=s>>>16&255,i[r++]=s>>>24&255,i[r++]=a>>>0&255,i[r++]=a>>>8&255,i[r++]=a>>>16&255,i[r++]=a>>>24&255,i[r++]=l>>>0&255,i[r++]=l>>>8&255,i[r++]=l>>>16&255,i[r++]=l>>>24&255,i[r++]=c>>>0&255,i[r++]=c>>>8&255,i[r++]=c>>>16&255,i[r++]=c>>>24&255,i[r++]=u>>>0&255,i[r++]=u>>>8&255,i[r++]=u>>>16&255,i[r++]=u>>>24&255,i[r++]=h>>>0&255,i[r++]=h>>>8&255,i[r++]=h>>>16&255,i[r++]=h>>>24&255,i[r++]=d>>>0&255,i[r++]=d>>>8&255,i[r++]=d>>>16&255,i[r]=d>>>24&255}(e,t,i,n);case 9:return void function(e,t,i,n){let r=n;const o=e[t]>>>0,s=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0,u=e[t+5]>>>0,h=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0;i[r++]=o>>>0&511,i[r++]=o>>>9&511,i[r++]=o>>>18&511,i[r++]=511&(o>>>27|(15&s)<<5),i[r++]=s>>>4&511,i[r++]=s>>>13&511,i[r++]=s>>>22&511,i[r++]=511&(s>>>31|(255&a)<<1),i[r++]=a>>>8&511,i[r++]=a>>>17&511,i[r++]=511&(a>>>26|(7&l)<<6),i[r++]=l>>>3&511,i[r++]=l>>>12&511,i[r++]=l>>>21&511,i[r++]=511&(l>>>30|(127&c)<<2),i[r++]=c>>>7&511,i[r++]=c>>>16&511,i[r++]=511&(c>>>25|(3&u)<<7),i[r++]=u>>>2&511,i[r++]=u>>>11&511,i[r++]=u>>>20&511,i[r++]=511&(u>>>29|(63&h)<<3),i[r++]=h>>>6&511,i[r++]=h>>>15&511,i[r++]=511&(h>>>24|(1&d)<<8),i[r++]=d>>>1&511,i[r++]=d>>>10&511,i[r++]=d>>>19&511,i[r++]=511&(d>>>28|(31&p)<<4),i[r++]=p>>>5&511,i[r++]=p>>>14&511,i[r]=p>>>23&511}(e,t,i,n);case 10:return void function(e,t,i,n){let r=n;const o=e[t]>>>0,s=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0,u=e[t+5]>>>0,h=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0,f=e[t+9]>>>0;i[r++]=o>>>0&1023,i[r++]=o>>>10&1023,i[r++]=o>>>20&1023,i[r++]=1023&(o>>>30|(255&s)<<2),i[r++]=s>>>8&1023,i[r++]=s>>>18&1023,i[r++]=1023&(s>>>28|(63&a)<<4),i[r++]=a>>>6&1023,i[r++]=a>>>16&1023,i[r++]=1023&(a>>>26|(15&l)<<6),i[r++]=l>>>4&1023,i[r++]=l>>>14&1023,i[r++]=1023&(l>>>24|(3&c)<<8),i[r++]=c>>>2&1023,i[r++]=c>>>12&1023,i[r++]=c>>>22&1023,i[r++]=u>>>0&1023,i[r++]=u>>>10&1023,i[r++]=u>>>20&1023,i[r++]=1023&(u>>>30|(255&h)<<2),i[r++]=h>>>8&1023,i[r++]=h>>>18&1023,i[r++]=1023&(h>>>28|(63&d)<<4),i[r++]=d>>>6&1023,i[r++]=d>>>16&1023,i[r++]=1023&(d>>>26|(15&p)<<6),i[r++]=p>>>4&1023,i[r++]=p>>>14&1023,i[r++]=1023&(p>>>24|(3&f)<<8),i[r++]=f>>>2&1023,i[r++]=f>>>12&1023,i[r]=f>>>22&1023}(e,t,i,n);case 11:return void function(e,t,i,n){let r=n;const o=e[t]>>>0,s=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0,u=e[t+5]>>>0,h=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0,f=e[t+9]>>>0,m=e[t+10]>>>0;i[r++]=o>>>0&2047,i[r++]=o>>>11&2047,i[r++]=2047&(o>>>22|(1&s)<<10),i[r++]=s>>>1&2047,i[r++]=s>>>12&2047,i[r++]=2047&(s>>>23|(3&a)<<9),i[r++]=a>>>2&2047,i[r++]=a>>>13&2047,i[r++]=2047&(a>>>24|(7&l)<<8),i[r++]=l>>>3&2047,i[r++]=l>>>14&2047,i[r++]=2047&(l>>>25|(15&c)<<7),i[r++]=c>>>4&2047,i[r++]=c>>>15&2047,i[r++]=2047&(c>>>26|(31&u)<<6),i[r++]=u>>>5&2047,i[r++]=u>>>16&2047,i[r++]=2047&(u>>>27|(63&h)<<5),i[r++]=h>>>6&2047,i[r++]=h>>>17&2047,i[r++]=2047&(h>>>28|(127&d)<<4),i[r++]=d>>>7&2047,i[r++]=d>>>18&2047,i[r++]=2047&(d>>>29|(255&p)<<3),i[r++]=p>>>8&2047,i[r++]=p>>>19&2047,i[r++]=2047&(p>>>30|(511&f)<<2),i[r++]=f>>>9&2047,i[r++]=f>>>20&2047,i[r++]=2047&(f>>>31|(1023&m)<<1),i[r++]=m>>>10&2047,i[r]=m>>>21&2047}(e,t,i,n);case 12:return void function(e,t,i,n){let r=n;const o=e[t]>>>0,s=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0,u=e[t+5]>>>0,h=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0,f=e[t+9]>>>0,m=e[t+10]>>>0,g=e[t+11]>>>0;i[r++]=o>>>0&4095,i[r++]=o>>>12&4095,i[r++]=4095&(o>>>24|(15&s)<<8),i[r++]=s>>>4&4095,i[r++]=s>>>16&4095,i[r++]=4095&(s>>>28|(255&a)<<4),i[r++]=a>>>8&4095,i[r++]=a>>>20&4095,i[r++]=l>>>0&4095,i[r++]=l>>>12&4095,i[r++]=4095&(l>>>24|(15&c)<<8),i[r++]=c>>>4&4095,i[r++]=c>>>16&4095,i[r++]=4095&(c>>>28|(255&u)<<4),i[r++]=u>>>8&4095,i[r++]=u>>>20&4095,i[r++]=h>>>0&4095,i[r++]=h>>>12&4095,i[r++]=4095&(h>>>24|(15&d)<<8),i[r++]=d>>>4&4095,i[r++]=d>>>16&4095,i[r++]=4095&(d>>>28|(255&p)<<4),i[r++]=p>>>8&4095,i[r++]=p>>>20&4095,i[r++]=f>>>0&4095,i[r++]=f>>>12&4095,i[r++]=4095&(f>>>24|(15&m)<<8),i[r++]=m>>>4&4095,i[r++]=m>>>16&4095,i[r++]=4095&(m>>>28|(255&g)<<4),i[r++]=g>>>8&4095,i[r]=g>>>20&4095}(e,t,i,n);case 16:return void function(e,t,i,n){let r=n;const o=e[t]>>>0,s=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0,u=e[t+5]>>>0,h=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0,f=e[t+9]>>>0,m=e[t+10]>>>0,g=e[t+11]>>>0,y=e[t+12]>>>0,_=e[t+13]>>>0,v=e[t+14]>>>0,x=e[t+15]>>>0;i[r++]=o>>>0&65535,i[r++]=o>>>16&65535,i[r++]=s>>>0&65535,i[r++]=s>>>16&65535,i[r++]=a>>>0&65535,i[r++]=a>>>16&65535,i[r++]=l>>>0&65535,i[r++]=l>>>16&65535,i[r++]=c>>>0&65535,i[r++]=c>>>16&65535,i[r++]=u>>>0&65535,i[r++]=u>>>16&65535,i[r++]=h>>>0&65535,i[r++]=h>>>16&65535,i[r++]=d>>>0&65535,i[r++]=d>>>16&65535,i[r++]=p>>>0&65535,i[r++]=p>>>16&65535,i[r++]=f>>>0&65535,i[r++]=f>>>16&65535,i[r++]=m>>>0&65535,i[r++]=m>>>16&65535,i[r++]=g>>>0&65535,i[r++]=g>>>16&65535,i[r++]=y>>>0&65535,i[r++]=y>>>16&65535,i[r++]=_>>>0&65535,i[r++]=_>>>16&65535,i[r++]=v>>>0&65535,i[r++]=v>>>16&65535,i[r++]=x>>>0&65535,i[r]=x>>>16&65535}(e,t,i,n);case 32:for(let r=0;r<32;r=r+1|0)i[n+r|0]=0|e[t+r|0];return}const o=fp[r]>>>0;let s=t,a=0,l=e[s]>>>0;for(let t=0;t<32;t++)if(a+r<=32)i[n+t]=l>>>a&o,a+=r,32===a&&(a=0,s++,31!==t&&(l=e[s]>>>0));else{const c=32-a,u=l>>>a;s++,l=e[s]>>>0,i[n+t]=(u|(l&fp[r-c]>>>0)<<c)&o,a=r-c}}function Ip(e,t,i){const n=new Uint32Array(i);let r=0,o=t.get();for(let t=0;t<n.length;t++){let t=e[o++],i=127&t;t<128||(t=e[o++],i|=(127&t)<<7,t<128||(t=e[o++],i|=(127&t)<<14,t<128||(t=e[o++],i|=(127&t)<<21,t<128||(t=e[o++],i|=(15&t)<<28)))),n[r++]=i}return t.set(o),n}function kp(e,t,i){const n=new BigUint64Array(i);for(let i=0;i<n.length;i++)n[i]=Mp(e,t);return n}function Mp(e,t){let i=0n,n=0,r=t.get();for(;r<e.length;){const t=e[r++];if(i|=BigInt(127&t)<<BigInt(n),!(128&t))break;if(n+=7,n>=64)throw new Error("Varint too long")}return t.set(r),i}function Cp(e,t){let i,n;return n=e[t.get()],t.increment(),i=127&n,n<128?i:(n=e[t.get()],t.increment(),i|=(127&n)<<7,n<128?i:(n=e[t.get()],t.increment(),i|=(127&n)<<14,n<128?i:(n=e[t.get()],t.increment(),i|=(127&n)<<21,n<128?i:(n=e[t.get()],i|=(15&n)<<28,function(e,t,i){let n,r;if(r=t[i.get()],i.increment(),n=(112&r)>>4,r<128)return 4294967296*n+(e>>>0);if(r=t[i.get()],i.increment(),n|=(127&r)<<3,r<128)return 4294967296*n+(e>>>0);if(r=t[i.get()],i.increment(),n|=(127&r)<<10,r<128)return 4294967296*n+(e>>>0);if(r=t[i.get()],i.increment(),n|=(127&r)<<17,r<128)return 4294967296*n+(e>>>0);if(r=t[i.get()],i.increment(),n|=(127&r)<<24,r<128)return 4294967296*n+(e>>>0);if(r=t[i.get()],i.increment(),n|=(1&r)<<31,r<128)return 4294967296*n+(e>>>0);throw new Error("Expected varint not more than 10 bytes")}(i,e,t)))))}function Pp(e){return e>>>1^-(1&e)}function Ap(e){return e>>1n^-(1n&e)}function Lp(e){return e%2==1?(e+1)/-2:e/2}function Dp(e,t,i){if(void 0===i){i=0;for(let n=0;n<t;n++)i+=e[n]}const n=new Uint32Array(i);let r=0;for(let i=0;i<t;i++){const o=e[i];n.fill(e[i+t],r,r+o),r+=o}return n}function Rp(e,t,i){if(void 0===i){i=0;for(let n=0;n<t;n++)i+=Number(e[n])}const n=new BigUint64Array(i);let r=0;for(let i=0;i<t;i++){const o=Number(e[i]);n.fill(e[i+t],r,r+o),r+=o}return n}function zp(e,t,i){const n=new Float64Array(i);let r=0;for(let i=0;i<t;i++){const o=e[i];n.fill(e[i+t],r,r+o),r+=o}return n}function Fp(e){const t=new Int32Array(e.length);t[0]=Pp(e[0]);const i=e.length/4*4;let n=1;if(i>=4)for(;n<i-4;n+=4){const i=e[n+1],r=e[n+2],o=e[n+3];t[n]=Pp(e[n])+t[n-1],t[n+1]=Pp(i)+t[n],t[n+2]=Pp(r)+t[n+1],t[n+3]=Pp(o)+t[n+2]}for(;n!==e.length;++n)t[n]=Pp(e[n])+t[n-1];return t}function Op(e){const t=new BigInt64Array(e.length);t[0]=Ap(e[0]);const i=e.length/4*4;let n=1;if(i>=4)for(;n<i-4;n+=4){const i=e[n+1],r=e[n+2],o=e[n+3];t[n]=Ap(e[n])+t[n-1],t[n+1]=Ap(i)+t[n],t[n+2]=Ap(r)+t[n+1],t[n+3]=Ap(o)+t[n+2]}for(;n!==t.length;++n)t[n]=Ap(e[n])+t[n-1];return t}function Np(e){const t=e.length/4*4;let i=1;if(t>=4)for(let n=e[0];i<t-4;i+=4)n=e[i]+=n,n=e[i+1]+=n,n=e[i+2]+=n,n=e[i+3]+=n;for(;i!==e.length;)e[i]+=e[i-1],++i}var Bp,Gp,jp,Vp,Up,qp,Zp,$p;function Hp(e,t){const i=function(e,t){const i=e[t.get()],n=Object.values(Bp)[i>>4];let r=null;switch(n){case Bp.DATA:r={dictionaryType:Object.values(Gp)[15&i]};break;case Bp.OFFSET:r={offsetType:Object.values(jp)[15&i]};break;case Bp.LENGTH:r={lengthType:Object.values(Vp)[15&i]}}t.increment();const o=e[t.get()],s=Object.values(hp)[o>>5],a=Object.values(hp)[o>>2&7],l=Object.values(dp)[3&o];t.increment();const c=Ip(e,t,2),u=c[0];return{physicalStreamType:n,logicalStreamType:r,logicalLevelTechnique1:s,logicalLevelTechnique2:a,physicalLevelTechnique:l,numValues:u,byteLength:c[1],decompressedCount:u}}(e,t);return i.logicalLevelTechnique1===hp.MORTON?function(e,t,i){const n=Ip(t,i,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:e.decompressedCount,numBits:n[0],coordinateShift:n[1]}}(i,e,t):hp.RLE!==i.logicalLevelTechnique1&&hp.RLE!==i.logicalLevelTechnique2||dp.NONE===i.physicalLevelTechnique?i:function(e,t,i){const n=Ip(t,i,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:n[1],runs:n[0],numRleValues:n[1]}}(i,e,t)}!function(e){e.PRESENT="PRESENT",e.DATA="DATA",e.OFFSET="OFFSET",e.LENGTH="LENGTH"}(Bp||(Bp={})),function(e){e.NONE="NONE",e.SINGLE="SINGLE",e.SHARED="SHARED",e.VERTEX="VERTEX",e.MORTON="MORTON",e.FSST="FSST"}(Gp||(Gp={})),function(e){e.VERTEX="VERTEX",e.INDEX="INDEX",e.STRING="STRING",e.KEY="KEY"}(jp||(jp={})),function(e){e.VAR_BINARY="VAR_BINARY",e.GEOMETRIES="GEOMETRIES",e.PARTS="PARTS",e.RINGS="RINGS",e.TRIANGLES="TRIANGLES",e.SYMBOL="SYMBOL",e.DICTIONARY="DICTIONARY"}(Vp||(Vp={})),function(e){e[e.FLAT=0]="FLAT",e[e.CONST=1]="CONST",e[e.SEQUENCE=2]="SEQUENCE",e[e.DICTIONARY=3]="DICTIONARY",e[e.FSST_DICTIONARY=4]="FSST_DICTIONARY"}(Up||(Up={}));class Wp{constructor(e,t){this.values=e,this._size=t}get(e){const t=Math.floor(e/8);return 1==(this.values[t]>>e%8&1)}set(e,t){const i=Math.floor(e/8);this.values[i]=this.values[i]|(t?1:0)<<e%8}getInt(e){const t=Math.floor(e/8);return this.values[t]>>e%8&1}size(){return this._size}getBuffer(){return this.values}}function Xp(e,t,i){if(!t)return e;const n=t.size(),r=new e.constructor(n);let o=0;for(let s=0;s<n;s++)r[s]=t.get(s)?e[o++]:i;return r}function Yp(e,t,i,n,r){return function(e,t,i,n){let r;switch(t.logicalLevelTechnique1){case hp.DELTA:if(t.logicalLevelTechnique2===hp.RLE){const i=t;if(!n)return function(e,t,i){const n=new Int32Array(i);let r=0,o=0;for(let i=0;i<t;i++){const s=e[i],a=Pp(e[i+t]);for(let e=0;e<s;e++)o+=a,n[r++]=o}return n}(e,i.runs,i.numRleValues);r=Fp(e=Dp(e,i.runs,i.numRleValues))}else r=Fp(e);break;case hp.RLE:r=function(e,t,i){if(void 0===i){i=0;for(let n=0;n<t;n++)i+=e[n]}const n=new Int32Array(i);let r=0;for(let i=0;i<t;i++){const o=e[i];let s=e[i+t];s=Pp(s),n.fill(s,r,r+o),r+=o}return n}(e,t.runs,t.numRleValues);break;case hp.MORTON:Np(e),r=new Int32Array(e);break;case hp.COMPONENTWISE_DELTA:r=function(e){if(e.length<2)return new Int32Array(e);const t=new Int32Array(e.length);t[0]=Pp(e[0]),t[1]=Pp(e[1]);const i=e.length/4*4;let n=2;if(i>=4)for(;n<i-4;n+=4){const i=e[n+1],r=e[n+2],o=e[n+3];t[n]=Pp(e[n])+t[n-2],t[n+1]=Pp(i)+t[n-1],t[n+2]=Pp(r)+t[n],t[n+3]=Pp(o)+t[n+1]}for(;n!==e.length;n+=2)t[n]=Pp(e[n])+t[n-2],t[n+1]=Pp(e[n+1])+t[n-1];return t}(e);break;case hp.NONE:r=function(e){const t=new Int32Array(e.length);for(let i=0;i<e.length;i++)t[i]=Pp(e[i]);return t}(e);break;default:throw new Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return n?Xp(r,n,0):r}(Qp(e,t,i),i,0,r)}function Jp(e,t,i,n,r){return function(e,t,i,n){let r;switch(t.logicalLevelTechnique1){case hp.DELTA:r=function(e){const t=new Uint32Array(e.length);t[0]=Pp(e[0])>>>0;for(let i=1;i<e.length;i++)t[i]=t[i-1]+Pp(e[i])>>>0;return t}(t.logicalLevelTechnique2===hp.RLE?Dp(e,t.runs,t.numRleValues):e);break;case hp.RLE:r=Dp(e,t.runs,t.numRleValues);break;case hp.MORTON:Np(e),r=e;break;case hp.COMPONENTWISE_DELTA:r=function(e){if(e.length<2)return new Uint32Array(e);const t=new Uint32Array(e.length);t[0]=Pp(e[0])>>>0,t[1]=Pp(e[1])>>>0;for(let i=2;i<e.length;i+=2)t[i]=t[i-2]+Pp(e[i])>>>0,t[i+1]=t[i-1]+Pp(e[i+1])>>>0;return t}(e);break;case hp.NONE:r=e;break;default:throw new Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return n?Xp(r,n,0):r}(Qp(e,t,i),i,0,r)}function Kp(e,t,i){return function(e,t){if(t.logicalLevelTechnique1===hp.DELTA&&t.logicalLevelTechnique2===hp.NONE)return function(e){const t=new Int32Array(e.length+1);t[0]=0,t[1]=Pp(e[0]);let i=t[1];for(let n=2;n!==t.length;++n)i+=Pp(e[n-1]),t[n]=t[n-1]+i;return new Uint32Array(t)}(e);if(t.logicalLevelTechnique1===hp.RLE&&t.logicalLevelTechnique2===hp.NONE)return function(e,t,i){const n=new Uint32Array(i+1);n[0]=0;let r=1,o=n[0];for(let i=0;i<t;i++){const s=e[i],a=e[i+t];for(let e=r;e<r+s;e++)n[e]=a+o,o=n[e];r+=s}return n}(e,t.runs,t.numRleValues);if(t.logicalLevelTechnique1===hp.NONE&&t.logicalLevelTechnique2===hp.NONE){!function(e){let t=0;for(let i=0;i<e.length;i++)e[i]+=t,t=e[i]}(e);const i=new Uint32Array(t.numValues+1);return i[0]=0,i.set(e,1),i}if(t.logicalLevelTechnique1===hp.DELTA&&t.logicalLevelTechnique2===hp.RLE){const i=function(e,t,i){const n=new Int32Array(i+1);n[0]=0;let r=1,o=n[0];for(let i=0;i<t;i++){const s=e[i];let a=e[i+t];a=Pp(a);for(let e=r;e<r+s;e++)n[e]=a+o,o=n[e];r+=s}return n}(e,t.runs,t.numRleValues);return Np(i),new Uint32Array(i)}throw new Error("Only delta encoding is supported for transforming length to offset streams yet.")}(Qp(e,t,i),i)}function Qp(e,t,i){const n=i.physicalLevelTechnique;switch(n){case dp.FAST_PFOR:return function(e,t,i,n){return function(e,t,i,n,r){const o=n.get();if(3&i)throw new Error(`FastPFOR: invalid encodedByteLength=${i} at offset=${o} (encodedBytes.length=${e.length}; expected a multiple of 4 bytes for an int32 big-endian word stream)`);const s=i>>>2,a=function(e,t){if(t<=e.encodedWords.length)return e.encodedWords;const i=new Uint32Array(Math.max(16,2*t));return e.encodedWords=i,i}(r,s);!function(e,t,i,n){if(t<0||i<0||t+i>e.length)throw new RangeError(`decodeBigEndianInt32sInto: out of bounds (offset=${t}, byteLength=${i}, bytes.length=${e.length})`);const r=Math.floor(i/4),o=i%4!=0,s=o?r+1:r;if(n.length<s)throw new RangeError(`decodeBigEndianInt32sInto: out.length=${n.length} < ${s}`);if(r>0){const i=e.byteOffset+t;if(3&i)for(let i=0;i<r;i++){const r=t+4*i;n[i]=e[r]<<24|e[r+1]<<16|e[r+2]<<8|e[r+3]}else{const t=new Uint32Array(e.buffer,i,r);for(let e=0;e<r;e++)n[e]=0|yp(t[e])}}if(o){const o=t+4*r,s=i-4*r;let a=0;for(let t=0;t<s;t++)a|=e[o+t]<<24-8*t;n[r]=0|a}}(e,o,i,a);const l=function(e,t,i){let n=0,r=0;const o=new Uint32Array(t),s=i??xp();if(e.length>0){const t=0|e[n];if(n=n+1|0,255&t)throw new Error(`FastPFOR decode: invalid alignedLength=${t} (expected multiple of 256)`);if(r+t>o.length)throw new Error(`FastPFOR decode: output buffer too small (outPos=${r}, alignedLength=${t}, out.length=${o.length})`);n=function(e,t,i,n,r,o){const s=n+gp(r,mp);let a=n,l=i;for(;a!==s;){const i=Math.min(_p,s-a);l=Tp(e,t,l,a,i,o),a=a+i|0}return l}(e,o,n,r,t,s),r=r+t|0}return function(e,t,i,n,r,o){if(0===o)return t;let s=0,a=t;const l=t+i,c=r;let u=r;const h=r+o;let d=0,p=0;for(;a<l&&u<h;){const t=e[a]>>>s&255;if(s+=8,a+=s>>>5,s&=31,d|=(127&t)<<p,128&t)n[u++]=0|d,d=0,p=0;else if(p+=7,p>28)throw new Error(`FastPFOR VByte: unterminated value (expected MSB=1 terminator within 5 bytes; shift=${p}, partial=${d}, decoded=${u-c}/${o}, inPos=${a}, inEnd=${l})`)}if(u!==h)throw new Error(`FastPFOR VByte: truncated stream (decoded=${u-c}, expected=${o}, consumedWords=${a-t}/${i}, vbyteStart=${t}, vbyteEnd=${l})`)}(e,n,e.length-n|0,o,r,t-r|0),o}(a.subarray(0,s),t,r.decoderWorkspace);return n.add(i),l}(e,t,i,n,function(e=16){if(e<0)throw new RangeError(`initialEncodedWordCapacity must be >= 0, got ${e}`);const t=Math.max(16,0|e);return{encodedWords:new Uint32Array(t),decoderWorkspace:xp()}}(i>>>2))}(e,i.numValues,i.byteLength,t);case dp.VARINT:return Ip(e,t,i.numValues);case dp.NONE:{const n=t.get();t.add(i.byteLength);const r=e.subarray(n,t.get());return new Uint32Array(r)}default:throw new Error(`Specified physicalLevelTechnique ${n} is not supported (yet).`)}}function ef(e,t,i){const n=Qp(e,t,i);return 1===n.length?n[0]:function(e){return e[1]}(n)}function tf(e,t,i){return function(e){if(2===e.length){const t=Pp(e[1]);return[t,t]}return[Pp(e[2]),Pp(e[3])]}(Qp(e,t,i))}function nf(e,t,i){return function(e){if(2===e.length){const t=Ap(e[1]);return[t,t]}return[Ap(e[2]),Ap(e[3])]}(kp(e,t,i.numValues))}function rf(e,t,i,n){return function(e,t,i){let n;switch(t.logicalLevelTechnique1){case hp.DELTA:n=function(e){const t=new BigUint64Array(e.length);t[0]=BigInt.asUintN(64,Ap(e[0]));for(let i=1;i<e.length;i++)t[i]=BigInt.asUintN(64,t[i-1]+Ap(e[i]));return t}(t.logicalLevelTechnique2===hp.RLE?Rp(e,t.runs,t.numRleValues):e);break;case hp.RLE:n=Rp(e,t.runs,t.numRleValues);break;case hp.NONE:n=e;break;default:throw new Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return i?Xp(n,i,0n):n}(kp(e,t,i.numValues),i,n)}function of(e,t,i){const n=kp(e,t,i.numValues);return 1===n.length?n[0]:function(e){return e[1]}(n)}function sf(e,t,i,n,r="int32"){const o=e.logicalLevelTechnique1;if(o===hp.RLE)return 1===e.runs?Up.CONST:Up.FLAT;if(o!==hp.DELTA||e.logicalLevelTechnique2!==hp.RLE)return 1===e.numValues?Up.CONST:Up.FLAT;const s=t instanceof Wp?t.size():t;if(e.numRleValues!==s)return Up.FLAT;if(1===e.runs)return Up.SEQUENCE;if(2!==e.runs)return 1===e.numValues?Up.CONST:Up.FLAT;const a=n.get();if(e.physicalLevelTechnique===dp.VARINT)return function(e,t,i){const n=new up(t.get());if("int64"===i){const t=kp(e,n,4);return 2n===t[2]&&2n===t[3]}const r=Ip(e,n,4);return 2===r[2]&&2===r[3]}(i,n,r)?Up.SEQUENCE:1===e.numValues?Up.CONST:Up.FLAT;const l=n.get(),c=new Int32Array(i.buffer,i.byteOffset+l,4);return n.set(a),2===c[2]&&2===c[3]?Up.SEQUENCE:1===e.numValues?Up.CONST:Up.FLAT}class af extends np{getValueFromBuffer(e){return this.dataBuffer[e]}}class lf extends sp{constructor(e,t,i,n){super(e,BigInt64Array.of(t),i,n)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}}function cf(e,t,i){return{x:uf(e,t)-i,y:uf(e>>1,t)-i}}function uf(e,t){let i=0;for(let n=0;n<t;n++)i|=(e&1<<2*n)>>n;return i}function hf(e,t,n,r,o,s,a){return e===$p.MORTON?function(e,t,n,r,o,s){const a=new Array(o?r+1:r);for(let o=0;o<r;o++){const r=cf(e[t[n+o]],s.numBits,s.coordinateShift);a[o]=new i(r.x,r.y)}return o&&(a[a.length-1]=a[0]),a}(t,n,r,o,s,a):function(e,t,n,r,o){const s=new Array(o?r+1:r);for(let o=0;o<2*r;o+=2){const r=2*t[n+o/2];s[o/2]=new i(e[r],e[r+1])}return o&&(s[s.length-1]=s[0]),s}(t,n,r,o,s)}function df(e,t,n,r){const o=new Array(r?n+1:n);for(let r=0;r<2*n;r+=2)o[r/2]=new i(e[t+r],e[t+r+1]);return r&&(o[o.length-1]=o[0]),o}!function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON",e[e.MULTIPOINT=3]="MULTIPOINT",e[e.MULTILINESTRING=4]="MULTILINESTRING",e[e.MULTIPOLYGON=5]="MULTIPOLYGON"}(qp||(qp={})),function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON"}(Zp||(Zp={})),function(e){e[e.MORTON=0]="MORTON",e[e.VEC_2=1]="VEC_2",e[e.VEC_3=2]="VEC_3"}($p||($p={}));class pf{constructor(e,t,i,n,r){this._vertexBufferType=e,this._topologyVector=t,this._vertexOffsets=i,this._vertexBuffer=n,this._mortonSettings=r}get vertexBufferType(){return this._vertexBufferType}get topologyVector(){return this._topologyVector}get vertexOffsets(){return this._vertexOffsets}get vertexBuffer(){return this._vertexBuffer}getSimpleEncodedVertex(e){const t=this.vertexOffsets?2*this.vertexOffsets[e]:2*e;return[this.vertexBuffer[t],this.vertexBuffer[t+1]]}getVertex(e){if(this.vertexOffsets&&this.mortonSettings){const t=cf(this.vertexBuffer[this.vertexOffsets[e]],this.mortonSettings.numBits,this.mortonSettings.coordinateShift);return[t.x,t.y]}const t=this.vertexOffsets?2*this.vertexOffsets[e]:2*e;return[this.vertexBuffer[t],this.vertexBuffer[t+1]]}getGeometries(){return function(e){const t=new Array(e.numGeometries);let n=1,r=1,o=1,s=0,a=0,l=0;const c=e.mortonSettings,u=e.topologyVector,h=u.geometryOffsets,d=u.partOffsets,p=u.ringOffsets,f=e.vertexOffsets,m=!f||0===f.length,g=e.containsPolygonGeometry(),y=e.vertexBuffer;for(let u=0;u<e.numGeometries;u++)switch(e.geometryType(u)){case qp.POINT:{let u,g;if(m)u=y[a++],g=y[a++];else if(e.vertexBufferType===$p.MORTON){const e=cf(y[f[l++]],c.numBits,c.coordinateShift);u=e.x,g=e.y}else{const e=2*f[l++];u=y[e],g=y[e+1]}t[s++]=[[new i(u,g)]],h&&o++,d&&n++,p&&r++}break;case qp.MULTIPOINT:{const e=h[o]-h[o-1];o++;const c=new Array(e);if(m)for(let t=0;t<e;t++){const e=y[a++],n=y[a++];c[t]=new i(e,n)}else for(let t=0;t<e;t++){const e=2*f[l++];c[t]=new i(y[e],y[e+1])}t[s++]=c.map(e=>[e]),n+=e,r+=e}break;case qp.LINESTRING:{let i,u;g?(i=p[r]-p[r-1],r++):i=d[n]-d[n-1],n++,m?(u=df(y,a,i,!1),a+=2*i):(u=hf(e.vertexBufferType,y,f,l,i,!1,c),l+=i),t[s++]=[u],h&&o++}break;case qp.POLYGON:{const i=d[n]-d[n-1];n++;const u=new Array(i-1);let g,_=p[r]-p[r-1];if(r++,m){g=df(y,a,_,!0),a+=2*_;for(let e=0;e<u.length;e++)_=p[r]-p[r-1],r++,u[e]=df(y,a,_,!0),a+=2*_}else{g=hf(e.vertexBufferType,y,f,l,_,!0,c),l+=_;for(let t=0;t<u.length;t++)_=p[r]-p[r-1],r++,u[t]=hf(e.vertexBufferType,y,f,l,_,!0,c),l+=_}t[s++]=[g].concat(u),h&&o++}break;case qp.MULTILINESTRING:{const i=h[o]-h[o-1];o++;const u=new Array(i);for(let t=0;t<i;t++){let i;if(g?(i=p[r]-p[r-1],r++):i=d[n]-d[n-1],n++,m)u[t]=df(y,a,i,!1),a+=2*i;else{const n=hf(e.vertexBufferType,y,f,l,i,!1,c);u[t]=n,l+=i}}t[s++]=u}break;case qp.MULTIPOLYGON:{const i=h[o]-h[o-1];o++;const u=new Array(i);for(let t=0;t<i;t++){const i=d[n]-d[n-1];let o;n++;const s=new Array(i-1),h=p[r]-p[r-1];r++,m?(o=df(y,a,h,!0),a+=2*h):(o=hf(e.vertexBufferType,y,f,l,h,!0,c),l+=h);for(let t=0;t<s.length;t++){const i=p[r]-p[r-1];r++,m?(s[t]=df(y,a,i,!0),a+=2*i):(s[t]=hf(e.vertexBufferType,y,f,l,i,!0,c),l+=i)}u[t]=[o].concat(s)}t[s++]=u.flat()}break;default:throw new Error("The specified geometry type is currently not supported.")}return t}(this)}get mortonSettings(){return this._mortonSettings}}class ff extends pf{constructor(e,t,i,n,r,o,s){super(i,n,r,o,s),this._numGeometries=e,this._geometryType=t}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsPolygonGeometry(){return this._geometryType===qp.POLYGON||this._geometryType===qp.MULTIPOLYGON}containsSingleGeometryType(){return!0}}class mf extends pf{constructor(e,t,i,n,r,o){super(e,i,n,r,o),this._geometryTypes=t}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsPolygonGeometry(){for(let e=0;e<this.numGeometries;e++)if(this.geometryType(e)===qp.POLYGON||this.geometryType(e)===qp.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}}class gf{constructor(e,t,i,n){this._triangleOffsets=e,this._indexBuffer=t,this._vertexBuffer=i,this._topologyVector=n}get triangleOffsets(){return this._triangleOffsets}get indexBuffer(){return this._indexBuffer}get vertexBuffer(){return this._vertexBuffer}get topologyVector(){return this._topologyVector}getGeometries(){if(!this._topologyVector)throw new Error("Cannot convert GpuVector to coordinates without topology information");const e=new Array(this.numGeometries),t=this._topologyVector,n=t.partOffsets,r=t.ringOffsets,o=t.geometryOffsets;let s=0,a=1,l=1,c=1;for(let t=0;t<this.numGeometries;t++)switch(this.geometryType(t)){case qp.POLYGON:{const u=n[a]-n[a-1];a++;const h=[];for(let e=0;e<u;e++){const e=r[l]-r[l-1];l++;const t=[];for(let n=0;n<e;n++){const e=this._vertexBuffer[s++],n=this._vertexBuffer[s++];t.push(new i(e,n))}t.length>0&&t.push(t[0]),h.push(t)}e[t]=h,o&&c++}break;case qp.MULTIPOLYGON:{const u=o[c]-o[c-1];c++;const h=[];for(let e=0;e<u;e++){const e=n[a]-n[a-1];a++;for(let t=0;t<e;t++){const e=r[l]-r[l-1];l++;const t=[];for(let n=0;n<e;n++){const e=this._vertexBuffer[s++],n=this._vertexBuffer[s++];t.push(new i(e,n))}t.length>0&&t.push(t[0]),h.push(t)}}e[t]=h}}return e}[Symbol.iterator](){return null}}function yf(e,t,i,n,r,o){return new _f(e,t,i,n,r,o)}class _f extends gf{constructor(e,t,i,n,r,o){super(i,n,r,o),this._numGeometries=e,this._geometryType=t}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}}function vf(e,t,i,n,r){return new xf(e,t,i,n,r)}class xf extends gf{constructor(e,t,i,n,r){super(t,i,n,r),this._geometryTypes=e}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}}function bf(e,t,i,n,r){const o=Hp(e,i);let s,a,l,c;if(sf(o,n,e,i)===Up.CONST){const r=ef(e,i,o);let u,h,d,p;for(let n=0;n<t-1;n++){const t=Hp(e,i);switch(t.physicalStreamType){case Bp.LENGTH:switch(t.logicalStreamType.lengthType){case Vp.GEOMETRIES:u=Kp(e,i,t);break;case Vp.PARTS:h=Kp(e,i,t);break;case Vp.RINGS:d=Kp(e,i,t);break;case Vp.TRIANGLES:p=Kp(e,i,t)}break;case Bp.OFFSET:switch(t.logicalStreamType.offsetType){case jp.VERTEX:s=Jp(e,i,t);break;case jp.INDEX:c=Jp(e,i,t)}break;case Bp.DATA:Gp.VERTEX===t.logicalStreamType.dictionaryType?a=Yp(e,i,t):(l={numBits:t.numBits,coordinateShift:t.coordinateShift},a=Jp(e,i,t))}}return c?void 0!==u||void 0!==h?yf(n,r,p,c,a,{geometryOffsets:u,partOffsets:h,ringOffsets:d}):yf(n,r,p,c,a):void 0===l?function(e,t,i,n,r){return new ff(e,t,$p.VEC_2,i,n,r)}(n,r,{geometryOffsets:u,partOffsets:h,ringOffsets:d},s,a):function(e,t,i,n,r,o){return new ff(e,t,$p.MORTON,i,n,r,o)}(n,r,{geometryOffsets:u,partOffsets:h,ringOffsets:d},s,a,l)}const u=Jp(e,i,o);let h,d,p,f,m,g,y;for(let n=0;n<t-1;n++){const t=Hp(e,i);switch(t.physicalStreamType){case Bp.LENGTH:switch(t.logicalStreamType.lengthType){case Vp.GEOMETRIES:h=Jp(e,i,t);break;case Vp.PARTS:d=Jp(e,i,t);break;case Vp.RINGS:p=Jp(e,i,t);break;case Vp.TRIANGLES:f=Kp(e,i,t)}break;case Bp.OFFSET:switch(t.logicalStreamType.offsetType){case jp.VERTEX:s=Jp(e,i,t);break;case jp.INDEX:c=Jp(e,i,t)}break;case Bp.DATA:Gp.VERTEX===t.logicalStreamType.dictionaryType?a=Yp(e,i,t):(l={numBits:t.numBits,coordinateShift:t.coordinateShift},a=Jp(e,i,t))}}return h?(m=wf(u,h,2),d&&p?(g=Ef(u,m,d,!1),y=function(e,t,i,n){const r=new Uint32Array(i[i.length-1]+1);let o=0;r[0]=o;let s=1,a=1,l=0;for(let c=0;c<e.length;c++){const u=e[c],h=t[c+1]-t[c];if(0!==u&&3!==u)for(let e=0;e<h;e++){const e=i[s]-i[s-1];s++;for(let t=0;t<e;t++)o=r[a++]=o+n[l++]}else for(let e=0;e<h;e++)r[a++]=++o,s++}return r}(u,m,g,p)):d&&(g=function(e,t,i){const n=new Uint32Array(t[t.length-1]+1);let r=0;n[0]=r;let o=1,s=0;for(let a=0;a<e.length;a++){const l=e[a],c=t[a+1]-t[a];if(4===l||1===l)for(let e=0;e<c;e++)r=n[o++]=r+i[s++];else for(let e=0;e<c;e++)n[o++]=++r}return n}(u,m,d))):d&&p?(g=wf(u,d,1),y=Ef(u,g,p,!0)):d&&(g=wf(u,d,0)),c&&!g?vf(u,f,c,a):c?vf(u,f,c,a,{geometryOffsets:m,partOffsets:g,ringOffsets:y}):void 0===l?function(e,t,i,n){return new mf($p.VEC_2,e,t,i,n)}(u,{geometryOffsets:m,partOffsets:g,ringOffsets:y},s,a):function(e,t,i,n,r){return new mf($p.MORTON,e,t,i,n,r)}(u,{geometryOffsets:m,partOffsets:g,ringOffsets:y},s,a,l)}function wf(e,t,i){const n=new Uint32Array(e.length+1);let r=0;n[0]=r;let o=0;for(let s=0;s<e.length;s++)r=n[s+1]=r+(e[s]>i?t[o++]:1);return n}function Ef(e,t,i,n){const r=new Uint32Array(t[t.length-1]+1);let o=0;r[0]=o;let s=1,a=0;for(let l=0;l<e.length;l++){const c=e[l],u=t[l+1]-t[l];if(5===c||2===c||n&&(4===c||1===c))for(let e=0;e<u;e++)o=r[s++]=o+i[a++];else for(let e=0;e<u;e++)r[s++]=++o}return r}class Tf extends ip{constructor(e,t,i){super(e,t.getBuffer(),i),this.dataVector=t}getValueFromBuffer(e){return this.dataVector.get(e)}}class Sf extends np{getValueFromBuffer(e){return this.dataBuffer[e]}}class If extends ip{constructor(e,t,i,n){super(e,n?BigInt64Array.of(t):BigUint64Array.of(t),i)}getValueFromBuffer(e){return this.dataBuffer[0]}}function kf(e,t,i,n,r){const o=function(e,t,i,n){const r=new Uint8Array(t);let o=0;const s=n.get()+i;for(;o<t&&!(n.get()>=s);){const i=e[n.increment()];if(i<=127){const s=i+3,a=e[n.increment()],l=Math.min(o+s,t);r.fill(a,o,l),o=l}else{const s=256-i;for(let i=0;i<s&&o<t;i++)r[o++]=e[n.increment()]}}return n.set(s),r}(e,Math.ceil(t/8),i,n);return r?function(e,t,i){if(!i)return e;const n=i.size(),r=new Wp(e,t),o=new Wp(new Uint8Array(Math.ceil(n/8)),n);let s=0;for(let e=0;e<n;e++){const t=!!i.get(e)&&r.get(s++);o.set(e,t)}return o.getBuffer()}(o,t,r):o}const Mf=new TextDecoder;function Cf(e,t,i){return i-t>=12?Mf.decode(e.subarray(t,i)):function(e,t,i){let n="",r=t;for(;r<i;){const t=e[r];let o,s,a,l=null,c=t>239?4:t>223?3:t>191?2:1;if(r+c>i)break;1===c?t<128&&(l=t):2===c?(o=e[r+1],128==(192&o)&&(l=(31&t)<<6|63&o,l<=127&&(l=null))):3===c?(o=e[r+1],s=e[r+2],128==(192&o)&&128==(192&s)&&(l=(15&t)<<12|(63&o)<<6|63&s,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(o=e[r+1],s=e[r+2],a=e[r+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&t)<<18|(63&o)<<12|(63&s)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,n+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),n+=String.fromCharCode(l),r+=c}return n}(e,t,i)}class Pf extends ip{constructor(e,t,i,n){super(e,i,n),this.offsetBuffer=t}}class Af extends Pf{constructor(e,t,i,n){super(e,t,i,n??t.length-1)}getValueFromBuffer(e){return Cf(this.dataBuffer,this.offsetBuffer[e],this.offsetBuffer[e+1])}}class Lf extends Pf{constructor(e,t,i,n,r){super(e,i,n,r??t.length),this.indexBuffer=t,this.indexBuffer=t}getValueFromBuffer(e){const t=this.indexBuffer[e];return Cf(this.dataBuffer,this.offsetBuffer[t],this.offsetBuffer[t+1])}}class Df extends Pf{constructor(e,t,i,n,r,o,s){super(e,i,n,s),this.indexBuffer=t,this.symbolOffsetBuffer=r,this.symbolTableBuffer=o}getValueFromBuffer(e){null==this.decodedDictionary&&(null==this.symbolLengthBuffer&&(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer)),this.decodedDictionary=function(e,t,i){const n=[],r=new Array(t.length).fill(0);for(let e=1;e<t.length;e++)r[e]=r[e-1]+t[e-1];for(let o=0;o<i.length;o++)if(255===i[o])n.push(i[++o]);else{const s=t[i[o]],a=r[i[o]];for(let t=0;t<s;t++)n.push(e[a+t])}return new Uint8Array(n)}(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer));const t=this.indexBuffer[e];return Cf(this.decodedDictionary,this.offsetBuffer[t],this.offsetBuffer[t+1])}offsetToLengthBuffer(e){const t=new Uint32Array(e.length-1);let i=e[0];for(let n=1;n<e.length;n++){const r=e[n];t[n-1]=r-i,i=r}return t}}function Rf(e,t,i,n,r,o){return"scalarType"===i.type?function(e,t,i,n,r,o){let s=null;if(0===e)return null;if(o.nullable){const e=Hp(t,i),n=e.numValues,r=i.get(),o=kf(t,n,e.byteLength,i);i.set(r+e.byteLength),s=new Wp(o,e.numValues)}const a=s??n;switch(r.physicalType){case 4:case 3:return function(e,t,i,n,r){const o=Hp(e,t),s=sf(o,r,e,t),a=3===n.physicalType;if(s===Up.FLAT){const n=zf(r)?r:void 0,s=a?Yp(e,t,o,0,n):Jp(e,t,o,0,n);return new rp(i.name,s,r)}if(s===Up.SEQUENCE){const n=tf(e,t,o);return new ap(i.name,n[0],n[1],o.numRleValues)}const l=a?function(e,t,i){const n=Qp(e,t,i);return 1===n.length?Pp(n[0]):function(e){return Pp(e[1])}(n)}(e,t,o):ef(e,t,o);return new lp(i.name,l,r,a)}(t,i,o,r,a);case 9:return function(e,t,i,n,r){let o=null,s=null,a=null,l=null,c=null,u=r??null,h=null,d=null;for(let e=0;e<n;e++){const e=Hp(t,i);switch(e.physicalStreamType){case Bp.PRESENT:{const n=kf(t,e.numValues,e.byteLength,i),o=new Wp(n,e.numValues);u=r??o;break}case Bp.OFFSET:s=Jp(t,i,e,0,u);break;case Bp.LENGTH:{const n=Kp(t,i,e);Vp.DICTIONARY===e.logicalStreamType.lengthType?o=n:Vp.SYMBOL===e.logicalStreamType.lengthType?l=n:h=n;break}case Bp.DATA:{const n=t.subarray(i.get(),i.get()+e.byteLength);i.add(e.byteLength);const r=e.logicalStreamType.dictionaryType;Gp.FSST===r?c=n:Gp.SINGLE===r||Gp.SHARED===r?a=n:Gp.NONE===r&&(d=n);break}}}return function(e,t,i,n,r,o,s){return t?new Df(e,i,n,r,o,t,s):null}(e,c,s,o,a,l,u)??function(e,t,i,n,r){return t?r?new Lf(e,i,n,t,r):new Lf(e,i,n,t):null}(e,a,s,o,u)??function(e,t,i,n,r){if(!t||!i)return null;if(n)return r?new Lf(e,n,t,i,r):new Lf(e,n,t,i);if(r&&r.size()!==t.length-1){const n=new Uint32Array(r.size());let o=0;for(let e=0;e<r.size();e++)n[e]=r.get(e)?o++:0;return new Lf(e,n,t,i,r)}return r?new Af(e,t,i,r):new Af(e,t,i)}(e,h,d,s,u)}(o.name,t,i,o.nullable?e-1:e,s);case 0:return function(e,t,i,n,r){const o=Hp(e,t),s=o.numValues,a=t.get(),l=zf(r)?r:void 0,c=kf(e,s,o.byteLength,t,l);t.set(a+o.byteLength);const u=new Wp(c,s);return new Tf(i.name,u,r)}(t,i,o,0,a);case 6:case 5:return function(e,t,i,n,r){const o=Hp(e,t),s=sf(o,n,e,t,"int64"),a=5===r.physicalType;if(s===Up.FLAT){const r=zf(n)?n:void 0,s=a?function(e,t,i,n){return function(e,t,i){let n;switch(t.logicalLevelTechnique1){case hp.DELTA:if(t.logicalLevelTechnique2===hp.RLE){const r=t;if(!i)return function(e,t,i){const n=new BigInt64Array(i);let r=0,o=0n;for(let i=0;i<t;i++){const s=Number(e[i]),a=Ap(e[i+t]);for(let e=0;e<s;e++)o+=a,n[r++]=o}return n}(e,r.runs,r.numRleValues);n=Op(e=Rp(e,r.runs,r.numRleValues))}else n=Op(e);break;case hp.RLE:n=function(e,t,i){if(void 0===i){i=0;for(let n=0;n<t;n++)i+=Number(e[n])}const n=new BigInt64Array(i);let r=0;for(let i=0;i<t;i++){const o=Number(e[i]);let s=e[i+t];s=Ap(s),n.fill(s,r,r+o),r+=o}return n}(e,t.runs,t.numRleValues);break;case hp.NONE:n=function(e){const t=new BigInt64Array(e.length);for(let i=0;i<e.length;i++)t[i]=Ap(e[i]);return t}(e);break;default:throw new Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return i?Xp(n,i,0n):n}(kp(e,t,i.numValues),i,n)}(e,t,o,r):rf(e,t,o,r);return new af(i.name,s,n)}if(s===Up.SEQUENCE){const n=nf(e,t,o);return new lf(i.name,n[0],n[1],o.numRleValues)}const l=a?function(e,t,i){const n=kp(e,t,i.numValues);return 1===n.length?Ap(n[0]):function(e){return Ap(e[1])}(n)}(e,t,o):of(e,t,o);return new If(i.name,l,n,a)}(t,i,o,a,r);case 7:return function(e,t,i,n){const r=Hp(e,t),o=zf(n)?n:void 0,s=function(e,t,i,n){const r=t.get(),o=r+i*Float32Array.BYTES_PER_ELEMENT,s=new Uint8Array(e.subarray(r,o)).buffer,a=new Float32Array(s);return t.set(o),n?Xp(a,n,0):a}(e,t,r.numValues,o);return new Sf(i.name,s,n)}(t,i,o,a);case 8:return function(e,t,i,n){const r=Hp(e,t),o=zf(n)?n:void 0,s=function(e,t,i,n){const r=t.get(),o=r+i*Float64Array.BYTES_PER_ELEMENT,s=new Uint8Array(e.subarray(r,o)).buffer,a=new Float64Array(s);return t.set(o),n?Xp(a,n,0):a}(e,t,r.numValues,o);return new op(i.name,s,n)}(t,i,o,a);default:throw new Error(`The specified data type for the field is currently not supported: ${r}`)}}(n,e,t,r,i.scalarType,i):0===n?null:function(e,t,i,n){let r=null,o=null,s=null,a=null,l=!1;for(;!l;){const i=Hp(e,t);switch(i.physicalStreamType){case Bp.LENGTH:Vp.DICTIONARY===i.logicalStreamType.lengthType?r=Kp(e,t,i):s=Kp(e,t,i);break;case Bp.DATA:Gp.SINGLE===i.logicalStreamType.dictionaryType||Gp.SHARED===i.logicalStreamType.dictionaryType?(o=e.subarray(t.get(),t.get()+i.byteLength),l=!0):a=e.subarray(t.get(),t.get()+i.byteLength),t.add(i.byteLength)}}const c=i.complexType.children,u=[];let h=0;for(const l of c){const c=Ip(e,t,1)[0];if(0===c)continue;const d=l.name?`${i.name}${l.name}`:i.name;if(2!==c||"scalarField"!==l.type||9!==l.scalarField.physicalType)throw new Error("Currently only optional string fields are implemented for a struct.");const p=Hp(e,t),f=kf(e,p.numValues,p.byteLength,t),m=Hp(e,t),g=Jp(e,t,m,0,m.decompressedCount!==n?new Wp(f,p.numValues):void 0);u[h++]=a?new Df(d,g,r,o,s,a,new Wp(f,p.numValues)):new Lf(d,g,r,o,new Wp(f,p.numValues))}return u}(e,t,i,r)}function zf(e){return e instanceof Wp}function Ff(e){switch(e){case 0:case 1:case 2:case 3:{const t={};t.nullable=!!(1&e),t.columnScope=0;const i={type:"logicalType",logicalType:0};return i.longID=!!(2&e),t.scalarType=i,t.type="scalarType",t}case 4:{const e={nullable:!1,columnScope:0},t={type:"physicalType",physicalType:0};return e.type="complexType",e.complexType=t,e}case 30:{const e={nullable:!1,columnScope:0},t={type:"physicalType",physicalType:1};return e.type="complexType",e.complexType=t,e}default:return function(e){let t;switch(e){case 10:case 11:t=0;break;case 12:case 13:t=1;break;case 14:case 15:t=2;break;case 16:case 17:t=3;break;case 18:case 19:t=4;break;case 20:case 21:t=5;break;case 22:case 23:t=6;break;case 24:case 25:t=7;break;case 26:case 27:t=8;break;case 28:case 29:t=9;break;default:return null}const i={};i.nullable=!!(1&e),i.columnScope=0;const n={type:"physicalType"};return n.physicalType=t,i.type="scalarType",i.scalarType=n,i}(e)}}function Of(e){return e>=10}function Nf(e){return 30===e}function Bf(e){if("scalarType"===e.type){const t=e.scalarType;if("physicalType"===t.type)switch(t.physicalType){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:default:return!1;case 9:return!0}if("logicalType"===t.type)return!1}else if("complexType"===e.type){const t=e.complexType;if("physicalType"===t.type)switch(t.physicalType){case 0:case 1:return!0;default:return!1}}return!1}function Gf(e){return"complexType"===e.type&&"physicalType"===e.complexType?.type&&0===e.complexType.physicalType}const jf=new TextDecoder;function Vf(e,t){const i=Ip(e,t,1)[0];if(0===i)return"";const n=t.get(),r=e.subarray(n,n+i);return t.add(i),jf.decode(r)}function Uf(e,t){const i=Ip(e,t,1)[0]>>>0;if(i<10||i>30)throw new Error(`Unsupported field type code ${i}. Supported: 10-29(scalars), 30(STRUCT)`);const n=Ff(i);if(Of(i)&&(n.name=Vf(e,t)),Nf(i)){const i=Ip(e,t,1)[0]>>>0;n.complexType.children=new Array(i);for(let r=0;r<i;r++)n.complexType.children[r]=Uf(e,t)}return function(e){return{name:e.name,nullable:e.nullable,scalarField:e.scalarType,complexField:e.complexType,type:"scalarType"===e.type?"scalarField":"complexField"}}(n)}function qf(e,t){const i=Ip(e,t,1)[0]>>>0,n=Ff(i);if(!n)throw new Error(`Unsupported column type code ${i}. Supported: 0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT)`);if(Of(i)?n.name=Vf(e,t):i>=0&&i<=3?n.name="id":4===i&&(n.name="geometry"),Nf(i)){const i=Ip(e,t,1)[0]>>>0,r=n.complexType;r.children=new Array(i);for(let n=0;n<i;n++)r.children[n]=Uf(e,t)}return n}function Zf(e,t){const i={featureTables:[]},n={};n.name=Vf(e,t);const r=Ip(e,t,1)[0]>>>0,o=Ip(e,t,1)[0]>>>0;n.columns=new Array(o);for(let i=0;i<o;i++)n.columns[i]=qf(e,t);return i.featureTables.push(n),[i,r]}function $f(e,t,i,n,r,o,s=!1){const a=t.scalarType;if(!a||"logicalType"!==a.type||0!==a.logicalType)throw new Error(`ID column must be a logical ID scalar type: ${n}`);const l=a.longID?6:4,c="number"==typeof o?void 0:o,u=sf(r,o,e,i,6===l?"int64":"int32");if(4===l)switch(u){case Up.FLAT:{const t=Jp(e,i,r,0,c);return new rp(n,t,o)}case Up.SEQUENCE:{const t=tf(e,i,r);return new ap(n,t[0],t[1],r.numRleValues)}case Up.CONST:{const t=ef(e,i,r);return new lp(n,t,o,!1)}}switch(u){case Up.FLAT:{if(s){const t=function(e,t,i){const n=function(e,t,i){const n=new Float64Array(i);for(let r=0;r<i;r++)n[r]=Cp(e,t);return n}(e,t,i.numValues);return function(e,t){switch(t.logicalLevelTechnique1){case hp.DELTA:return t.logicalLevelTechnique2===hp.RLE&&(e=zp(e,t.runs,t.numRleValues)),function(e){e[0]=Lp(e[0]);const t=e.length/4*4;let i=1;if(t>=4)for(;i<t-4;i+=4){const t=e[i+1],n=e[i+2],r=e[i+3];e[i]=Lp(e[i])+e[i-1],e[i+1]=Lp(t)+e[i],e[i+2]=Lp(n)+e[i+1],e[i+3]=Lp(r)+e[i+2]}for(;i!==e.length;++i)e[i]=Lp(e[i])+e[i-1]}(e),e;case hp.RLE:return function(e,t){return zp(e,t.runs,t.numRleValues)}(e,t);case hp.NONE:return e;default:throw new Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}}(n,i)}(e,i,r);return new op(n,t,o)}const t=rf(e,i,r,c);return new af(n,t,o)}case Up.SEQUENCE:{const t=nf(e,i,r);return new lf(n,t[0],t[1],r.numRleValues)}case Up.CONST:{const t=of(e,i,r);return new If(n,t,o,!1)}}throw new Error("Vector type not supported for id column.")}class Hf{constructor(e,t){var i;switch(this._featureData=e,this.properties=this._featureData.properties||{},null===(i=this._featureData.geometry)||void 0===i?void 0:i.type){case qp.POINT:case qp.MULTIPOINT:this.type=1;break;case qp.LINESTRING:case qp.MULTILINESTRING:this.type=2;break;case qp.POLYGON:case qp.MULTIPOLYGON:this.type=3;break;default:this.type=0}this.extent=t,this.id=Number(this._featureData.id)}loadGeometry(){const e=[];for(const t of this._featureData.geometry.coordinates){const n=[];for(const e of t)n.push(new i(e.x,e.y));e.push(n)}return e}}class Wf{constructor(e){this.features=[],this.featureTable=e,this.name=e.name,this.extent=e.extent,this.version=2,this.features=e.getFeatures(),this.length=this.features.length}feature(e){return new Hf(this.features[e],this.extent)}}class Xf{constructor(e){this.layers={};const t=function(e,t,i=!0){const n=new up(0),r=[];for(;n.get()<e.length;){const t=Ip(e,n,1)[0]>>>0,s=n.get()+t;if(s>e.length)throw new Error(`Block overruns tile: ${s} > ${e.length}`);if(1!=Ip(e,n,1)[0]>>>0){n.set(s);continue}const[a,l]=Zf(e,n),c=a.featureTables[0];let u=null,h=null;const d=[];let p=0;for(const t of c.columns){const r=t.name;if("scalarType"===(o=t).type&&"logicalType"===o.scalarType?.type&&0===o.scalarType.logicalType){let o=null;if(t.nullable){const t=Hp(e,n),i=n.get(),r=kf(e,t.numValues,t.byteLength,n);n.set(i+t.byteLength),o=new Wp(r,t.numValues)}const s=Hp(e,n);p=o?o.size():s.decompressedCount,u=$f(e,t,n,r,s,o??p,i)}else if(Gf(t)){const t=Ip(e,n,1)[0];if(0===p){const t=n.get();p=Hp(e,n).decompressedCount,n.set(t)}h=bf(e,t,n,p)}else{const i=Bf(t)?Ip(e,n,1)[0]:1;if(0===i)continue;const r=Rf(e,n,t,i,p);if(r)if(Array.isArray(r))for(const e of r)d.push(e);else d.push(r)}}const f=new cp(c.name,h,u,d,l);r.push(f),n.set(s)}var o;return r}(new Uint8Array(e));this.layers=t.reduce((e,t)=>Object.assign(Object.assign({},e),{[t.name]:new Wf(t)}),{})}}class Yf{constructor(e,t){this.feature=e,this.type=e.type,this.properties=e.tags?e.tags:{},this.extent=t,"id"in e&&("string"==typeof e.id?this.id=parseInt(e.id,10):"number"!=typeof e.id||isNaN(e.id)||(this.id=e.id))}loadGeometry(){const e=[],t=1===this.feature.type?[this.feature.geometry]:this.feature.geometry;for(const n of t){const t=[];for(const e of n)t.push(new i(e[0],e[1]));e.push(t)}return e}}const Jf="_geojsonTileLayer";function Kf(e,t,i=""){t.writeVarintField(15,e.version||1),t.writeStringField(1,e.name||""),t.writeVarintField(5,e.extent||4096);const n={jsonPrefix:i,keys:[],values:[],keycache:{},valuecache:{}};for(let i=0;i<e.length;i++)n.feature=e.feature(i),t.writeMessage(2,Qf,n);const r=n.keys;for(const e of r)t.writeStringField(3,e);const o=n.values;for(const e of o)t.writeMessage(4,rm,e)}function Qf(e,t){if(!e.feature)return;const i=e.feature;void 0!==i.id&&t.writeVarintField(1,i.id),t.writeMessage(2,em,e),t.writeVarintField(3,i.type),t.writeMessage(4,nm,i)}function em(e,t){for(const i in e.feature?.properties){let n=e.feature.properties[i],r=e.keycache[i];if(null==n)continue;void 0===r&&(e.keys.push(i),r=e.keys.length-1,e.keycache[i]=r),t.writeVarint(r),"string"!=typeof n&&"boolean"!=typeof n&&"number"!=typeof n&&(n=e.jsonPrefix+JSON.stringify(n));const o=typeof n+":"+n;let s=e.valuecache[o];void 0===s&&(e.values.push(n),s=e.values.length-1,e.valuecache[o]=s),t.writeVarint(s)}}function tm(e,t){return(t<<3)+(7&e)}function im(e){return e<<1^e>>31}function nm(e,t){const i=e.loadGeometry(),n=e.type;let r=0,o=0;for(const s of i){let i=1;1===n&&(i=s.length),t.writeVarint(tm(1,i));const a=3===n?s.length-1:s.length;for(let e=0;e<a;e++){1===e&&1!==n&&t.writeVarint(tm(2,a-1));const i=s[e].x-r,l=s[e].y-o;t.writeVarint(im(i)),t.writeVarint(im(l)),r+=i,o+=l}3===e.type&&t.writeVarint(tm(7,1))}}function rm(e,t){const i=typeof e;"string"===i?t.writeStringField(1,e):"boolean"===i?t.writeBooleanField(7,e):"number"===i&&(e%1!=0?t.writeDoubleField(3,e):e<0?t.writeSVarintField(6,e):t.writeVarintField(5,e))}class om{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new ho(C,16,0),this.grid3D=new ho(C,16,0),this.featureIndexArray=new qs,this.promoteId=t}insert(e,t,i,n,r,o){const s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,n,r);const a=o?this.grid3D:this.grid;for(const e of t){const t=[1/0,1/0,-1/0,-1/0];for(const i of e)t[0]=Math.min(t[0],i.x),t[1]=Math.min(t[1],i.y),t[2]=Math.max(t[2],i.x),t[3]=Math.max(t[3],i.y);t[0]<C&&t[1]<C&&t[2]>=0&&t[3]>=0&&a.insert(s,t[0],t[1],t[2],t[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers="mlt"!==this.encoding?new Gc(new Bh(this.rawTileData)).layers:new Xf(this.rawTileData).layers,this.sourceLayerCoder=new ep(this.vtLayers?Object.keys(this.vtLayers).sort():[Jf])),this.vtLayers}query(e,t,n,r){this.loadVTLayers();const o=e.params,s=C/e.tileSize/e.scale,a=fr(o.filter,o.globalState),l=e.queryGeometry,c=e.queryPadding*s,u=Qd.fromPoints(l),h=this.grid.query(u.minX-c,u.minY-c,u.maxX+c,u.maxY+c),d=Qd.fromPoints(e.cameraQueryGeometry).expandBy(c),p=this.grid3D.query(d.minX,d.minY,d.maxX,d.maxY,(t,n,r,o)=>function(e,t,n,r,o){for(const i of e)if(t<=i.x&&n<=i.y&&r>=i.x&&o>=i.y)return!0;const s=[new i(t,n),new i(t,o),new i(r,o),new i(r,n)];if(e.length>2)for(const t of s)if(nl(e,t))return!0;for(let t=0;t<e.length-1;t++)if(rl(e[t],e[t+1],s))return!0;return!1}(e.cameraQueryGeometry,t-c,n-c,r+c,o+c));for(const e of p)h.push(e);h.sort(am);const f={};let m;for(const i of h){if(i===m)continue;m=i;const c=this.featureIndexArray.get(i);let u=null;this.loadMatchingFeature(f,c.bucketIndex,c.sourceLayerIndex,c.featureIndex,a,o.layers,o.availableImages,t,n,r,(t,i,n)=>(u||(u=Ua(t)),i.queryIntersectsFeature({queryGeometry:l,feature:t,featureState:n,geometry:u,zoom:this.z,transform:e.transform,pixelsToTileUnits:s,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation})))}return f}loadMatchingFeature(e,t,i,n,r,o,s,a,l,c,u){const h=this.bucketLayerIDs[t];if(o&&!h.some(e=>o.has(e)))return;const d=this.sourceLayerCoder.decode(i),p=this.vtLayers[d].feature(n);if(r.needGeometry){const e=qa(p,!0);if(!r.filter(new zo(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!r.filter(new zo(this.tileID.overscaledZ),p))return;const f=this.getId(p,d);for(const t of h){if(o&&!o.has(t))continue;const i=a[t];if(!i)continue;let r={};f&&c&&(r=c.getState(i.sourceLayer||Jf,f));const h=B({},l[t]);h.paint=sm(h.paint,i.paint,p,r,s),h.layout=sm(h.layout,i.layout,p,r,s);const d=!u||u(p,i,r);if(!d)continue;const m=new tp(p,this.z,this.x,this.y,f);m.layer=h;let g=e[t];void 0===g&&(g=e[t]=[]),g.push({featureIndex:n,feature:m,intersectionZ:d})}}lookupSymbolFeatures(e,t,i,n,r,o,s,a){const l={};this.loadVTLayers();const c=fr(r.filterSpec,r.globalState);for(const r of e)this.loadMatchingFeature(l,i,n,r,c,o,s,a,t);return l}hasLayer(e){for(const t of this.bucketLayerIDs)for(const i of t)if(e===i)return!0;return!1}getId(e,t){var i;let n=e.id;return this.promoteId&&(n=e.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[t]],"boolean"==typeof n&&(n=Number(n)),void 0===n&&(null===(i=e.properties)||void 0===i?void 0:i.cluster)&&this.promoteId&&(n=Number(e.properties.cluster_id))),n}}function sm(e,t,i,n,r){return j(e,(e,o)=>{const s=t instanceof Zo?t.get(o):null;return(null==s?void 0:s.evaluate)?s.evaluate(i,n,r):s})}function am(e,t){return t-e}function lm(e,t,n,r,o){const s=[];for(const a of e){let e;for(let l=0;l<a.length-1;l++){let c=a[l],u=a[l+1];c.x<t&&u.x<t||(c.x<t?c=new i(t,c.y+(t-c.x)/(u.x-c.x)*(u.y-c.y))._round():u.x<t&&(u=new i(t,c.y+(t-c.x)/(u.x-c.x)*(u.y-c.y))._round()),c.y<n&&u.y<n||(c.y<n?c=new i(c.x+(n-c.y)/(u.y-c.y)*(u.x-c.x),n)._round():u.y<n&&(u=new i(c.x+(n-c.y)/(u.y-c.y)*(u.x-c.x),n)._round()),c.x>=r&&u.x>=r||(c.x>=r?c=new i(r,c.y+(r-c.x)/(u.x-c.x)*(u.y-c.y))._round():u.x>=r&&(u=new i(r,c.y+(r-c.x)/(u.x-c.x)*(u.y-c.y))._round()),c.y>=o&&u.y>=o||(c.y>=o?c=new i(c.x+(o-c.y)/(u.y-c.y)*(u.x-c.x),o)._round():u.y>=o&&(u=new i(c.x+(o-c.y)/(u.y-c.y)*(u.x-c.x),o)._round()),e&&c.equals(e[e.length-1])||(e=[c],s.push(e)),e.push(u)))))}}return s}function cm(e,t,i,n,r){switch(t){case 1:return function(e,t,i,n){const r=[];for(const o of e)for(const e of o){const o=0===n?e.x:e.y;o>=t&&o<=i&&r.push([e])}return r}(e,i,n,r);case 2:return hm(e,i,n,r,!1);case 3:return hm(e,i,n,r,!0)}return[]}function um(e,t,n,r,o){const s=0===r?dm:pm;let a=[];const l=[];for(let i=0;i<e.length-1;i++){const c=e[i],u=e[i+1],h=0===r?c.x:c.y,d=0===r?u.x:u.y;let p=!1;h<t?d>t&&a.push(s(c,u,t)):h>n?d<n&&a.push(s(c,u,n)):a.push(c),d<t&&h>=t&&(a.push(s(c,u,t)),p=!0),d>n&&h<=n&&(a.push(s(c,u,n)),p=!0),!o&&p&&(l.push(a),a=[])}const c=e.length-1,u=0===r?e[c].x:e[c].y;return u>=t&&u<=n&&a.push(e[c]),o&&a.length>0&&!a[0].equals(a[a.length-1])&&a.push(new i(a[0].x,a[0].y)),a.length>0&&l.push(a),l}function hm(e,t,i,n,r){const o=[];for(const s of e){const e=um(s,t,i,n,r);e.length>0&&o.push(...e)}return o}function dm(e,t,n){return new i(n,e.y+(n-e.x)/(t.x-e.x)*(t.y-e.y))}function pm(e,t,n){return new i(e.x+(n-e.y)/(t.y-e.y)*(t.x-e.x),n)}fo("FeatureIndex",om,{omit:["rawTileData","sourceLayerCoder"]});class fm extends i{constructor(e,t,i,n){super(e,t),this.angle=i,void 0!==n&&(this.segment=n)}clone(){return new fm(this.x,this.y,this.angle,this.segment)}}function mm(e,t,i,n,r){if(void 0===t.segment||0===i)return!0;let o=t,s=t.segment+1,a=0;for(;a>-i/2;){if(s--,s<0)return!1;a-=e[s].dist(o),o=e[s]}a+=e[s].dist(e[s+1]),s++;const l=[];let c=0;for(;a<i/2;){const t=e[s],i=e[s+1];if(!i)return!1;let o=e[s-1].angleTo(t)-t.angleTo(i);for(o=Math.abs((o+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:a,angleDelta:o}),c+=o;a-l[0].distance>n;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=t.dist(i)}return!0}function gm(e){let t=0;for(let i=0;i<e.length-1;i++)t+=e[i].dist(e[i+1]);return t}function ym(e,t,i){return e?.6*t*i:0}function _m(e,t){return Math.max(e?e.right-e.left:0,t?t.right-t.left:0)}function vm(e,t,i,n,r,o){const s=ym(i,r,o),a=_m(i,n)*o;let l=0;const c=gm(e)/2;for(let i=0;i<e.length-1;i++){const n=e[i],r=e[i+1],o=n.dist(r);if(l+o>c){const u=(c-l)/o,h=gi.number(n.x,r.x,u),d=gi.number(n.y,r.y,u),p=new fm(h,d,r.angleTo(n),i);return p._round(),!s||mm(e,p,a,s,t)?p:void 0}l+=o}}function xm(e,t,i,n,r,o,s,a,l){const c=ym(n,o,s),u=_m(n,r),h=u*s,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h<t/4&&(t=h+t/4),bm(e,d?t/2*a%t:(u/2+2*o)*s*a%t,t,c,i,h,d,!1,l)}function bm(e,t,i,n,r,o,s,a,l){const c=o/2,u=gm(e);let h=0,d=t-i,p=[];for(let t=0;t<e.length-1;t++){const s=e[t],a=e[t+1],f=s.dist(a),m=a.angleTo(s);for(;d+i<h+f;){d+=i;const g=(d-h)/f,y=gi.number(s.x,a.x,g),_=gi.number(s.y,a.y,g);if(y>=0&&y<l&&_>=0&&_<l&&d-c>=0&&d+c<=u){const i=new fm(y,_,m,t);i._round(),n&&!mm(e,i,o,n,r)||p.push(i)}}h+=f}return a||p.length||s||(p=bm(e,h/2,i,n,r,o,s,!0,l)),p}function wm(e,t,n,r){const o=[],s=e.image,a=s.pixelRatio,l=s.paddedRect.w-2,c=s.paddedRect.h-2;let u={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom};const h=s.stretchX||[[0,l]],d=s.stretchY||[[0,c]],p=(e,t)=>e+t[1]-t[0],f=h.reduce(p,0),m=d.reduce(p,0),g=l-f,y=c-m;let _=0,v=f,x=0,b=m,w=0,E=g,T=0,S=y;if(s.content&&r){const t=s.content,i=t[2]-t[0],n=t[3]-t[1];(s.textFitWidth||s.textFitHeight)&&(u=pd(e)),_=Em(h,0,t[0]),x=Em(d,0,t[1]),v=Em(h,t[0],t[2]),b=Em(d,t[1],t[3]),w=t[0]-_,T=t[1]-x,E=i-v,S=n-b}const I=u.x1,k=u.y1,M=u.x2-I,C=u.y2-k,P=(e,r,o,l)=>{const c=Sm(e.stretch-_,v,M,I),u=Im(e.fixed-w,E,e.stretch,f),h=Sm(r.stretch-x,b,C,k),d=Im(r.fixed-T,S,r.stretch,m),p=Sm(o.stretch-_,v,M,I),g=Im(o.fixed-w,E,o.stretch,f),y=Sm(l.stretch-x,b,C,k),P=Im(l.fixed-T,S,l.stretch,m),A=new i(c,h),L=new i(p,h),D=new i(p,y),R=new i(c,y),z=new i(u/a,d/a),F=new i(g/a,P/a),O=t*Math.PI/180;if(O){const e=Math.sin(O),t=Math.cos(O),i=[t,-e,e,t];A._matMult(i),L._matMult(i),R._matMult(i),D._matMult(i)}const N=e.stretch+e.fixed,B=r.stretch+r.fixed;return{tl:A,tr:L,bl:R,br:D,tex:{x:s.paddedRect.x+1+N,y:s.paddedRect.y+1+B,w:o.stretch+o.fixed-N,h:l.stretch+l.fixed-B},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:z,pixelOffsetBR:F,minFontScaleX:E/a/M,minFontScaleY:S/a/C,isSDF:n}};if(r&&(s.stretchX||s.stretchY)){const e=Tm(h,g,f),t=Tm(d,y,m);for(let i=0;i<e.length-1;i++){const n=e[i],r=e[i+1];for(let e=0;e<t.length-1;e++)o.push(P(n,t[e],r,t[e+1]))}}else o.push(P({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:l+1},{fixed:0,stretch:c+1}));return o}function Em(e,t,i){let n=0;for(const r of e)n+=Math.max(t,Math.min(i,r[1]))-Math.max(t,Math.min(i,r[0]));return n}function Tm(e,t,i){const n=[{fixed:-1,stretch:0}];for(const[t,i]of e){const e=n[n.length-1];n.push({fixed:t-e.stretch,stretch:e.stretch}),n.push({fixed:t-e.stretch,stretch:e.stretch+(i-t)})}return n.push({fixed:t+1,stretch:i}),n}function Sm(e,t,i,n){return e/t*i+n}function Im(e,t,i,n){return e-t*i/n}fo("Anchor",fm);class km{constructor(e,t,n,r,o,s,a,l,c,u){var h;if(this.boxStartIndex=e.length,c){let e=s.top,t=s.bottom;const i=s.collisionPadding;i&&(e-=i[1],t+=i[3]);let n=t-e;n>0&&(n=Math.max(10,n),this.circleDiameter=n)}else{const c=(null===(h=s.image)||void 0===h?void 0:h.content)&&(s.image.textFitWidth||s.image.textFitHeight)?pd(s):{x1:s.left,y1:s.top,x2:s.right,y2:s.bottom};c.y1=c.y1*a-l[0],c.y2=c.y2*a+l[2],c.x1=c.x1*a-l[3],c.x2=c.x2*a+l[1];const d=s.collisionPadding;if(d&&(c.x1-=d[0]*a,c.y1-=d[1]*a,c.x2+=d[2]*a,c.y2+=d[3]*a),u){const e=new i(c.x1,c.y1),t=new i(c.x2,c.y1),n=new i(c.x1,c.y2),r=new i(c.x2,c.y2),o=u*Math.PI/180;e._rotate(o),t._rotate(o),n._rotate(o),r._rotate(o),c.x1=Math.min(e.x,t.x,n.x,r.x),c.x2=Math.max(e.x,t.x,n.x,r.x),c.y1=Math.min(e.y,t.y,n.y,r.y),c.y2=Math.max(e.y,t.y,n.y,r.y)}e.emplaceBack(t.x,t.y,c.x1,c.y1,c.x2,c.y2,n,r,o)}this.boxEndIndex=e.length}}class Mm{constructor(e=[],t=(e,t)=>e<t?-1:e>t?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:i}=this,n=t[e];for(;e>0;){const r=e-1>>1,o=t[r];if(i(n,o)>=0)break;t[e]=o,e=r}t[e]=n}_down(e){const{data:t,compare:i}=this,n=this.length>>1,r=t[e];for(;e<n;){let n=1+(e<<1);const o=n+1;if(o<this.length&&i(t[o],t[n])<0&&(n=o),i(t[n],r)>=0)break;t[e]=t[n],e=n}t[e]=r}}function Cm(e,t=1){const n=Qd.fromPoints(e[0]),r=Math.min(n.width(),n.height());let o=r/2;const s=new Mm([],Pm),{minX:a,minY:l,maxX:c,maxY:u}=n;if(0===r)return new i(a,l);for(let t=a;t<c;t+=r)for(let i=l;i<u;i+=r)s.push(new Am(t+o,i+o,o,e));const h=function(e){let t=0,i=0,n=0;const r=e[0];for(let e=0,o=r.length,s=o-1;e<o;s=e++){const o=r[e],a=r[s],l=o.x*a.y-a.x*o.y;i+=(o.x+a.x)*l,n+=(o.y+a.y)*l,t+=3*l}return new Am(i/t,n/t,0,e)}(e);let d=h;for(;s.length;){const i=s.pop();(i.d>d.d||!d.d)&&(d=i),i.max-d.d<=t||(o=i.h/2,s.push(new Am(i.p.x-o,i.p.y-o,o,e)),s.push(new Am(i.p.x+o,i.p.y-o,o,e)),s.push(new Am(i.p.x-o,i.p.y+o,o,e)),s.push(new Am(i.p.x+o,i.p.y+o,o,e)))}return h.d>0&&d.d-h.d<=t?h.p:d.p}function Pm(e,t){return t.max-e.max}class Am{constructor(e,t,n,r){this.p=new i(e,t),this.h=n,this.d=function(e,t){let i=!1,n=1/0;for(const r of t)for(let t=0,o=r.length,s=o-1;t<o;s=t++){const o=r[t],a=r[s];o.y>e.y!=a.y>e.y&&e.x<(a.x-o.x)*(e.y-o.y)/(a.y-o.y)+o.x&&(i=!i),n=Math.min(n,tl(e,o,a))}return(i?1:-1)*Math.sqrt(n)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}}var Lm;e.aM=void 0,(Lm=e.aM||(e.aM={}))[Lm.center=1]="center",Lm[Lm.left=2]="left",Lm[Lm.right=3]="right",Lm[Lm.top=4]="top",Lm[Lm.bottom=5]="bottom",Lm[Lm["top-left"]=6]="top-left",Lm[Lm["top-right"]=7]="top-right",Lm[Lm["bottom-left"]=8]="bottom-left",Lm[Lm["bottom-right"]=9]="bottom-right";const Dm=Number.POSITIVE_INFINITY;function Rm(e,t){return t[1]!==Dm?function(e,t,i){let n=0,r=0;switch(t=Math.abs(t),i=Math.abs(i),e){case"top-right":case"top-left":case"top":r=i-7;break;case"bottom-right":case"bottom-left":case"bottom":r=7-i}switch(e){case"top-right":case"bottom-right":case"right":n=-t;break;case"top-left":case"bottom-left":case"left":n=t}return[n,r]}(e,t[0],t[1]):function(e,t){let i=0,n=0;t<0&&(t=0);const r=t/Math.SQRT2;switch(e){case"top-right":case"top-left":n=r-7;break;case"bottom-right":case"bottom-left":n=7-r;break;case"bottom":n=7-t;break;case"top":n=t-7}switch(e){case"top-right":case"bottom-right":i=-r;break;case"top-left":case"bottom-left":i=r;break;case"left":i=t;break;case"right":i=-t}return[i,n]}(e,t[0])}function zm(e,t,i){var n;const r=e.layout,o=null===(n=r.get("text-variable-anchor-offset"))||void 0===n?void 0:n.evaluate(t,{},i);if(o){const e=o.values,t=[];for(let i=0;i<e.length;i+=2){const n=t[i]=e[i],r=e[i+1].map(e=>e*Ih);n.startsWith("top")?r[1]-=7:n.startsWith("bottom")&&(r[1]+=7),t[i+1]=r}return new Nt(t)}const s=r.get("text-variable-anchor");if(s){let n;n=void 0!==e._unevaluatedLayout.getValue("text-radial-offset")?[r.get("text-radial-offset").evaluate(t,{},i)*Ih,Dm]:r.get("text-offset").evaluate(t,{},i).map(e=>e*Ih);const o=[];for(const e of s)o.push(e,Rm(e,n));return new Nt(o)}return null}function Fm(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Om(t,i,n,r,o,s,a,l,c,u,h,d){let p=s.textMaxSize.evaluate(i,{});void 0===p&&(p=a);const f=t.layers[0].layout,m=f.get("icon-offset").evaluate(i,{},h),g=Bm(n.horizontal),y=a/24,_=t.tilePixelRatio*y,v=t.tilePixelRatio*p/24,x=t.tilePixelRatio*l,b=t.tilePixelRatio*f.get("symbol-spacing"),w=f.get("text-padding")*t.tilePixelRatio,E=function(e,t,i,n=1){const r=e.get("icon-padding").evaluate(t,{},i),o=null==r?void 0:r.values;return[o[0]*n,o[1]*n,o[2]*n,o[3]*n]}(f,i,h,t.tilePixelRatio),T=f.get("text-max-angle")/180*Math.PI,S="viewport"!==f.get("text-rotation-alignment")&&"point"!==f.get("symbol-placement"),I="map"===f.get("icon-rotation-alignment")&&"point"!==f.get("symbol-placement"),k=f.get("symbol-placement"),M=b/2,P=f.get("icon-text-fit");let A;r&&"none"!==P&&(t.allowVerticalPlacement&&n.vertical&&(A=fd(r,n.vertical,P,f.get("icon-text-fit-padding"),m,y)),g&&(r=fd(r,g,P,f.get("icon-text-fit-padding"),m,y)));const L=h?d.line.getGranularityForZoomLevel(h.z):1,D=(l,d)=>{d.x<0||d.x>=C||d.y<0||d.y>=C||function(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,y,_,v,x,b,w,E,T,S){const I=t.addToLineVertexArray(i,n);let k,M,C,P,A=0,L=0,D=0,R=0,z=-1,F=-1;const O={};let N=va("");if(t.allowVerticalPlacement&&r.vertical){const e=l.layout.get("text-rotate").evaluate(b,{},T)+90;C=new km(c,i,u,h,d,r.vertical,p,f,m,e),a&&(P=new km(c,i,u,h,d,a,y,_,m,e))}if(o){const n=l.layout.get("icon-rotate").evaluate(b,{}),r="none"!==l.layout.get("icon-text-fit"),s=wm(o,n,E,r),p=a?wm(a,n,E,r):void 0;M=new km(c,i,u,h,d,o,y,_,!1,n),A=4*s.length;const f=t.iconSizeData;let m=null;"source"===f.kind?(m=[md*l.layout.get("icon-size").evaluate(b,{})],m[0]>gd&&q()):"composite"===f.kind&&(m=[md*w.compositeIconSizes[0].evaluate(b,{},T),md*w.compositeIconSizes[1].evaluate(b,{},T)],(m[0]>gd||m[1]>gd)&&q()),t.addSymbols(t.icon,s,m,x,v,b,e.ax.none,i,I.lineStartIndex,I.lineLength,-1,T),z=t.icon.placedSymbolArray.length-1,p&&(L=4*p.length,t.addSymbols(t.icon,p,m,x,v,b,e.ax.vertical,i,I.lineStartIndex,I.lineLength,-1,T),F=t.icon.placedSymbolArray.length-1)}const B=Object.keys(r.horizontal);for(const n of B){const o=r.horizontal[n];if(!k){N=va(o.text);const e=l.layout.get("text-rotate").evaluate(b,{},T);k=new km(c,i,u,h,d,o,p,f,m,e)}const a=1===o.positionedLines.length;if(D+=Nm(t,i,o,s,l,m,b,g,I,r.vertical?e.ax.horizontal:e.ax.horizontalOnly,a?B:[n],O,z,w,T),a)break}r.vertical&&(R+=Nm(t,i,r.vertical,s,l,m,b,g,I,e.ax.vertical,["vertical"],O,F,w,T));const G=k?k.boxStartIndex:t.collisionBoxArray.length,j=k?k.boxEndIndex:t.collisionBoxArray.length,V=C?C.boxStartIndex:t.collisionBoxArray.length,U=C?C.boxEndIndex:t.collisionBoxArray.length,Z=M?M.boxStartIndex:t.collisionBoxArray.length,$=M?M.boxEndIndex:t.collisionBoxArray.length,H=P?P.boxStartIndex:t.collisionBoxArray.length,W=P?P.boxEndIndex:t.collisionBoxArray.length;let X=-1;const Y=(e,t)=>(null==e?void 0:e.circleDiameter)?Math.max(e.circleDiameter,t):t;X=Y(k,X),X=Y(C,X),X=Y(M,X),X=Y(P,X);const J=X>-1?1:0;J&&(X*=S/Ih),void 0!==b.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,b.sortKey);const K=zm(l,b,T),[Q,ee]=function(t,i){const n=t.length,r=null==i?void 0:i.values;if((null==r?void 0:r.length)>0)for(let i=0;i<r.length;i+=2){const n=r[i+1];t.emplaceBack(e.aM[r[i]],n[0],n[1])}return[n,t.length]}(t.textAnchorOffsets,K);t.symbolInstances.emplaceBack(i.x,i.y,O.right>=0?O.right:-1,O.center>=0?O.center:-1,O.left>=0?O.left:-1,O.vertical||-1,z,F,N,G,j,V,U,Z,$,H,W,u,D,R,A,L,J,0,p,X,Q,ee)}(t,d,l,n,r,o,A,t.layers[0],t.collisionBoxArray,i.index,i.sourceLayerIndex,t.index,_,[w,w,w,w],S,c,x,E,I,m,i,s,u,h,a)};if("line"===k)for(const e of lm(i.geometry,0,0,C,C)){const i=wc(e,L),o=xm(i,b,T,n.vertical||g,r,24,v,t.overscaling,C);for(const e of o)g&&Gm(t,g.text,M,e)||D(i,e)}else if("line-center"===k){for(const e of i.geometry)if(e.length>1){const t=wc(e,L),i=vm(t,T,n.vertical||g,r,24,v);i&&D(t,i)}}else if("Polygon"===i.type)for(const e of tn(i.geometry,0)){const t=Cm(e,16);D(wc(e[0],L,!0),new fm(t.x,t.y,0))}else if("LineString"===i.type)for(const e of i.geometry){const t=wc(e,L);D(t,new fm(t[0].x,t[0].y,0))}else if("Point"===i.type)for(const e of i.geometry)for(const t of e)D([t],new fm(t.x,t.y,0))}function Nm(e,t,n,r,o,s,a,l,c,u,h,d,p,f,m){const g=function(e,t,n,r,o,s,a,l){const c=r.layout.get("text-rotate").evaluate(s,{})*Math.PI/180,u=[];for(const e of t.positionedLines)for(const r of e.positionedGlyphs){if(!r.rect)continue;const s=r.rect||{};let h=4,d=!0,p=1,f=0;const m=(o||l)&&r.vertical,g=r.metrics.advance*r.scale/2;if(l&&t.verticalizable&&(f=e.lineOffset/2-(r.imageName?-(Ih-r.metrics.width*r.scale)/2:(r.scale-1)*Ih)),r.imageName){const e=a[r.imageName];d=e.sdf,p=e.pixelRatio,h=1/p}const y=o?[r.x+g,r.y]:[0,0];let _=o?[0,0]:[r.x+g+n[0],r.y+n[1]-f],v=[0,0];m&&(v=_,_=[0,0]);const x=r.metrics.isDoubleResolution?2:1,b=(r.metrics.left-h)*r.scale-g+_[0],w=(-r.metrics.top-h)*r.scale+_[1],E=b+s.w/x*r.scale/p,T=w+s.h/x*r.scale/p,S=new i(b,w),I=new i(E,w),k=new i(b,T),M=new i(E,T);if(m){const e=new i(-g,g- -17),t=-Math.PI/2,n=12-g,o=new i(22-n,-(r.imageName?n:0)),s=new i(...v);S._rotateAround(t,e)._add(o)._add(s),I._rotateAround(t,e)._add(o)._add(s),k._rotateAround(t,e)._add(o)._add(s),M._rotateAround(t,e)._add(o)._add(s)}if(c){const e=Math.sin(c),t=Math.cos(c),i=[t,-e,e,t];S._matMult(i),I._matMult(i),k._matMult(i),M._matMult(i)}const C=new i(0,0),P=new i(0,0);u.push({tl:S,tr:I,bl:k,br:M,tex:s,writingMode:t.writingMode,glyphOffset:y,sectionIndex:r.sectionIndex,isSDF:d,pixelOffsetTL:C,pixelOffsetBR:P,minFontScaleX:0,minFontScaleY:0})}return u}(0,n,l,o,s,a,r,e.allowVerticalPlacement),y=e.textSizeData;let _=null;"source"===y.kind?(_=[md*o.layout.get("text-size").evaluate(a,{})],_[0]>gd&&q()):"composite"===y.kind&&(_=[md*f.compositeTextSizes[0].evaluate(a,{},m),md*f.compositeTextSizes[1].evaluate(a,{},m)],(_[0]>gd||_[1]>gd)&&q()),e.addSymbols(e.text,g,_,l,s,a,u,t,c.lineStartIndex,c.lineLength,p,m);for(const t of h)d[t]=e.text.placedSymbolArray.length-1;return 4*g.length}function Bm(e){for(const t in e)return e[t];return null}function Gm(e,t,i,n){const r=e.compareText;if(t in r){const e=r[t];for(let t=e.length-1;t>=0;t--)if(n.dist(e[t])<i)return!0}else r[t]=[];return r[t].push(n),!1}e.$=se,e.A=p,e.B=Oo,e.C=uo,e.D=$o,e.E=ve,e.F=oo,e.G=function([e,t,i]){return t+=90,t*=Math.PI/180,i*=Math.PI/180,{x:e*Math.cos(t)*Math.sin(i),y:e*Math.sin(t)*Math.sin(i),z:e*Math.cos(i)}},e.H=gi,e.I=td,e.J=zo,e.K=ao,e.L=function(e){if(null==H){const t=e.navigator?e.navigator.userAgent:null;H=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return H},e.M=ue,e.N=class{constructor(e,t){this.target=e,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new zd(()=>this.process()),this.subscription=Q(this.target,"message",e=>this.receive(e),!1),this.globalScope=$(self)?e:window}registerMessageHandler(e,t){this.messageHandlers[e]=t}unregisterMessageHandler(e){delete this.messageHandlers[e]}sendAsync(e,t){return new Promise((i,n)=>{const r=Math.round(1e18*Math.random()).toString(36).substring(0,10),o=t?Q(t.signal,"abort",()=>{null==o||o.unsubscribe(),delete this.resolveRejects[r];const t={id:r,type:"<cancel>",origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(t)},Fd):null;this.resolveRejects[r]={resolve:e=>{null==o||o.unsubscribe(),i(e)},reject:e=>{null==o||o.unsubscribe(),n(e)}};const s=[],a=Object.assign(Object.assign({},e),{id:r,sourceMapId:this.mapId,origin:location.origin,data:_o(e.data,s)});this.target.postMessage(a,{transfer:s})})}receive(e){const t=e.data,i=t.id,n=["file://","resource://android","null"],r=[t.origin,location.origin],o=t.origin===location.origin,s=r.some(e=>n.includes(e));if((o||s)&&(!t.targetMapId||this.mapId===t.targetMapId)){if("<cancel>"===t.type){delete this.tasks[i];const e=this.abortControllers[i];return delete this.abortControllers[i],void(e&&e.abort())}if($(self)||t.mustQueue)return this.tasks[i]=t,this.taskQueue.push(i),void this.invoker.trigger();this.processTask(i,t)}}process(){if(0===this.taskQueue.length)return;const e=this.taskQueue.shift(),t=this.tasks[e];delete this.tasks[e],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(e,t)}processTask(e,i){return t(this,void 0,void 0,function*(){if("<response>"===i.type){const t=this.resolveRejects[e];if(delete this.resolveRejects[e],!t)return;return void(i.error?t.reject(A(vo(i.error))):t.resolve(vo(i.data)))}if(!this.messageHandlers[i.type])return void this.completeTask(e,new Error(`Could not find a registered handler for ${i.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const t=vo(i.data),n=new AbortController;this.abortControllers[e]=n;try{const r=yield this.messageHandlers[i.type](i.sourceMapId,t,n);this.completeTask(e,null,r)}catch(t){this.completeTask(e,A(t))}})}completeTask(e,t,i){const n=[];delete this.abortControllers[e];const r={id:e,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:t?_o(t):null,data:_o(i,n)};this.target.postMessage(r,{transfer:n})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},e.O=function(){var e=new p(16);return p!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},e.P=i,e.Q=function(e,t,i){var n,r,o,s,a,l,c,u,h,d,p,f,m=i[0],g=i[1],y=i[2];return t===e?(e[12]=t[0]*m+t[4]*g+t[8]*y+t[12],e[13]=t[1]*m+t[5]*g+t[9]*y+t[13],e[14]=t[2]*m+t[6]*g+t[10]*y+t[14],e[15]=t[3]*m+t[7]*g+t[11]*y+t[15]):(r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],e[0]=n=t[0],e[1]=r,e[2]=o,e[3]=s,e[4]=a,e[5]=l,e[6]=c,e[7]=u,e[8]=h,e[9]=d,e[10]=p,e[11]=f,e[12]=n*m+a*g+h*y+t[12],e[13]=r*m+l*g+d*y+t[13],e[14]=o*m+c*g+p*y+t[14],e[15]=s*m+u*g+f*y+t[15]),e},e.R=Il,e.S=function(e,t,i){var n=i[0],r=i[1],o=i[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},e.T=Ol,e.U=function(e,t,i){var n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],m=t[12],g=t[13],y=t[14],_=t[15],v=i[0],x=i[1],b=i[2],w=i[3];return e[0]=v*n+x*a+b*h+w*m,e[1]=v*r+x*l+b*d+w*g,e[2]=v*o+x*c+b*p+w*y,e[3]=v*s+x*u+b*f+w*_,e[4]=(v=i[4])*n+(x=i[5])*a+(b=i[6])*h+(w=i[7])*m,e[5]=v*r+x*l+b*d+w*g,e[6]=v*o+x*c+b*p+w*y,e[7]=v*s+x*u+b*f+w*_,e[8]=(v=i[8])*n+(x=i[9])*a+(b=i[10])*h+(w=i[11])*m,e[9]=v*r+x*l+b*d+w*g,e[10]=v*o+x*c+b*p+w*y,e[11]=v*s+x*u+b*f+w*_,e[12]=(v=i[12])*n+(x=i[13])*a+(b=i[14])*h+(w=i[15])*m,e[13]=v*r+x*l+b*d+w*g,e[14]=v*o+x*c+b*p+w*y,e[15]=v*s+x*u+b*f+w*_,e},e.V=function(e,t){const i={};for(const n of t)n in e&&(i[n]=e[n]);return i},e.W=Nd,e.X=N,e.Y=Vd,e.Z=jd,e._=t,e.a=oe,e.a$=function(e){var t=new p(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},e.a0=u,e.a1=h,e.a2=Y,e.a3=Jd,e.a4=qd,e.a5=Zd,e.a6=C,e.a7=Hd,e.a8=Qd,e.a9=25,e.aA=function(e){var t=e[0],i=e[1];return Math.sqrt(t*t+i*i)},e.aB=function(e){return e[0]=0,e[1]=0,e},e.aC=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e},e.aD=bd,e.aE=T,e.aF=function(e,t,n,r){const o=t.y-e.y,s=t.x-e.x,a=r.y-n.y,l=r.x-n.x,c=a*s-l*o;if(0===c)return null;const u=(l*(e.y-n.y)-a*(e.x-n.x))/c;return new i(e.x+u*s,e.y+u*o)},e.aG=lm,e.aH=Wa,e.aI=function(e){let t=1/0,i=1/0,n=-1/0,r=-1/0;for(const o of e)t=Math.min(t,o.x),i=Math.min(i,o.y),n=Math.max(n,o.x),r=Math.max(r,o.y);return[t,i,n,r]},e.aJ=Ih,e.aK=P,e.aL=function(e,t,i,n,r=!1){if(!i[0]&&!i[1])return[0,0];const o=r?"map"===n?-e.bearingInRadians:0:"viewport"===n?e.bearingInRadians:0;if(o){const e=Math.sin(o),t=Math.cos(o);i=[i[0]*t-i[1]*e,i[0]*e+i[1]*t]}return[r?i[0]:P(t,i[0],e.zoom),r?i[1]:P(t,i[1],e.zoom)]},e.aN=_d,e.aO=Fm,e.aP=od,e.aQ=e=>"symbol"===e.type,e.aR=eu,e.aS=as,e.aT=yc,e.aU=Zs,e.aV=la,e.aW=ra,e.aX=te,e.aY=$d,e.aZ=x,e.a_=v,e.aa=Xd,e.ab=e=>{const t=window.document.createElement("video");return t.muted=!0,new Promise(i=>{t.onloadstart=()=>{i(t)};for(const i of e){const e=window.document.createElement("source");fe(i)||(t.crossOrigin="Anonymous"),e.src=i,t.appendChild(e)}})},e.ac=Le,e.ad=function(){return G++},e.ae=Rs,e.af=Sd,e.ag=Jf,e.ah=fr,e.ai=qa,e.aj=tp,e.ak=function(e){const t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(e,i,n,r)=>{const o=n||r;return t[i]=!o||o.toLowerCase(),""}),t["max-age"]){const e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e}return t},e.al=O,e.am=85.051129,e.an=ee,e.ao=function(e){return Math.pow(2,e)},e.ap=m,e.aq=Ud,e.ar=function(e){return Math.log(e)/Math.LN2},e.as=function(e){var t=e[0],i=e[1];return t*t+i*i},e.at=function(e){if(!e.length)return new Set;const t=Math.max(...e.map(e=>e.canonical.z));let i=1/0,n=-1/0,r=1/0,o=-1/0;const s=[];for(const a of e){const{x:e,y:l,z:c}=a.canonical,u=Math.pow(2,t-c),h=e*u,d=l*u;s.push({id:a,x:h,y:d}),h<i&&(i=h),h>n&&(n=h),d<r&&(r=d),d>o&&(o=d)}const a=new Set;for(const e of s)e.x!==i&&e.x!==n&&e.y!==r&&e.y!==o||a.add(e.id);return a},e.au=function(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),n=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||n-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x},e.av=class{constructor(e,t){this.max=e,this.onRemove=t,this.reset()}reset(){for(const e in this.data)for(const t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,i){const n=e.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:t,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout(()=>{this.remove(e,r)},i)),this.data[n].push(r),this.order.push(n),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const i=e.wrapped().key,n=void 0===t?0:this.data[i].indexOf(t),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){const t=[];for(const i in this.data)for(const n of this.data[i])e(n.value)||t.push(n);for(const e of t)this.remove(e.value.tileID,e)}},e.aw=function(e,t){let i=0,n=0;if("constant"===e.kind)n=e.layoutSize;else if("source"!==e.kind){const{interpolationType:r,minZoom:o,maxZoom:s}=e,a=r?O(fi.interpolationFactor(r,t,o,s),0,1):0;"camera"===e.kind?n=gi.number(e.minSize,e.maxSize,a):i=a}return{uSizeT:i,uSize:n}},e.ay=function(e,{uSize:t,uSizeT:i},{lowerSize:n,upperSize:r}){return"source"===e.kind?n/md:"composite"===e.kind?gi.number(n/md,r/md,i):t},e.az=k,e.b=W,e.b$=ka,e.b0=function(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e},e.b1=function(e,t){var i=t[0],n=t[1],r=t[2],o=i*i+n*n+r*r;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e},e.b2=b,e.b3=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},e.b4=function(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e[3]=t[3]*i[3],e},e.b5=y,e.b6=function(e,t,i){const n=t[0]*i[0]+t[1]*i[1]+t[2]*i[2];return 0===n?null:(-(e[0]*i[0]+e[1]*i[1]+e[2]*i[2])-i[3])/n},e.b7=E,e.b8=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e},e.b9=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]},e.bA=I,e.bB=function(e,t,i){var n=i[0],r=i[1],o=i[2],s=i[3],a=t[0],l=t[1],c=t[2],u=r*c-o*l,h=o*a-n*c,d=n*l-r*a;return e[0]=a+s*(u+=u)+r*(d+=d)-o*(h+=h),e[1]=l+s*h+o*u-n*d,e[2]=c+s*d+n*h-r*u,e},e.bC=function(e,t,i){const n=(r=[e[0],e[1],e[2],t[0],t[1],t[2],i[0],i[1],i[2]])[0]*((u=r[8])*(s=r[4])-(a=r[5])*(c=r[7]))+r[1]*(-u*(o=r[3])+a*(l=r[6]))+r[2]*(c*o-s*l);var r,o,s,a,l,c,u;if(0===n)return null;const h=b([],[t[0],t[1],t[2]],[i[0],i[1],i[2]]),d=b([],[i[0],i[1],i[2]],[e[0],e[1],e[2]]),p=b([],[e[0],e[1],e[2]],[t[0],t[1],t[2]]),f=x([],h,-e[3]);return v(f,f,x([],d,-t[3])),v(f,f,x([],p,-i[3])),x(f,f,1/n),f},e.bD=Od,e.bE=function(){return new Float64Array(4)},e.bF=function(e,t,i,n){var r=[],o=[];return r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],o[0]=r[0]*Math.cos(n)-r[1]*Math.sin(n),o[1]=r[0]*Math.sin(n)+r[1]*Math.cos(n),o[2]=r[2],e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},e.bG=function(e,t,i,n){var r=[],o=[];return r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],o[0]=r[0],o[1]=r[1]*Math.cos(n)-r[2]*Math.sin(n),o[2]=r[1]*Math.sin(n)+r[2]*Math.cos(n),e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},e.bH=function(e,t,i,n){var r=[],o=[];return r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],o[0]=r[2]*Math.sin(n)+r[0]*Math.cos(n),o[1]=r[1],o[2]=r[2]*Math.cos(n)-r[0]*Math.sin(n),e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},e.bI=function(e,t,i){var n=Math.sin(i),r=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[8],u=t[9],h=t[10],d=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*r-c*n,e[1]=s*r-u*n,e[2]=a*r-h*n,e[3]=l*r-d*n,e[8]=o*n+c*r,e[9]=s*n+u*r,e[10]=a*n+h*r,e[11]=l*n+d*r,e},e.bJ=function(e,t){const i=L(e,360),n=L(t,360),r=n-i,o=n>i?r-360:r+360;return Math.abs(r)<Math.abs(o)?r:o},e.bK=function(e){return e[0]=0,e[1]=0,e[2]=0,e},e.bL=function(e,t,i,n){const r=Math.sqrt(e*e+t*t),o=Math.sqrt(i*i+n*n);e/=r,t/=r,i/=o,n/=o;const s=Math.acos(e*i+t*n);return-t*i+e*n>0?s:-s},e.bM=function(e,t){const i=L(e,2*Math.PI),n=L(t,2*Math.PI);return Math.min(Math.abs(i-n),Math.abs(i-n+2*Math.PI),Math.abs(i-n-2*Math.PI))},e.bN=function(){const e={},t=xe.$version;for(const i in xe.$root){const n=xe.$root[i];if(n.required){let r=null;r="version"===i?t:"array"===n.type?[]:{},null!=r&&(e[i]=r)}}return e},e.bO=de,e.bP=xo,e.bQ=function e(t,i){if(Array.isArray(t)){if(!Array.isArray(i)||t.length!==i.length)return!1;for(let n=0;n<t.length;n++)if(!e(t[n],i[n]))return!1;return!0}if("object"==typeof t&&null!==t&&null!==i){if("object"!=typeof i)return!1;if(Object.keys(t).length!==Object.keys(i).length)return!1;for(const n in t)if(!e(t[n],i[n]))return!1;return!0}return t===i},e.bR=ae,e.bS=function(e){e=e.slice();const t=Object.create(null);for(let i=0;i<e.length;i++)t[e[i].id]=e[i];for(let i=0;i<e.length;i++)"ref"in e[i]&&(e[i]=we(e[i],t[e[i].ref]));return e},e.bT=function(e,t){if("custom"===e.type)return new Rd(e,t);switch(e.type){case"background":return new Dd(e,t);case"circle":return new _l(e,t);case"color-relief":return new Gl(e,t);case"fill":return new Pc(e,t);case"fill-extrusion":return new Yc(e,t);case"heatmap":return new Pl(e,t);case"hillshade":return new Dl(e,t);case"line":return new yh(e,t);case"raster":return new ns(e,t);case"symbol":return new Pd(e,t)}},e.bU=e=>"raster"===e.type,e.bV=U,e.bW=function(e,t){if(!e)return[{command:"setStyle",args:[t]}];let i=[];try{if(!Ee(e.version,t.version))return[{command:"setStyle",args:[t]}];Ee(e.center,t.center)||i.push({command:"setCenter",args:[t.center]}),Ee(e.state,t.state)||i.push({command:"setGlobalState",args:[t.state]}),Ee(e.centerAltitude,t.centerAltitude)||i.push({command:"setCenterAltitude",args:[t.centerAltitude]}),Ee(e.zoom,t.zoom)||i.push({command:"setZoom",args:[t.zoom]}),Ee(e.bearing,t.bearing)||i.push({command:"setBearing",args:[t.bearing]}),Ee(e.pitch,t.pitch)||i.push({command:"setPitch",args:[t.pitch]}),Ee(e.roll,t.roll)||i.push({command:"setRoll",args:[t.roll]}),Ee(e.sprite,t.sprite)||i.push({command:"setSprite",args:[t.sprite]}),Ee(e.glyphs,t.glyphs)||i.push({command:"setGlyphs",args:[t.glyphs]}),Ee(e.transition,t.transition)||i.push({command:"setTransition",args:[t.transition]}),Ee(e.light,t.light)||i.push({command:"setLight",args:[t.light]}),Ee(e.terrain,t.terrain)||i.push({command:"setTerrain",args:[t.terrain]}),Ee(e.sky,t.sky)||i.push({command:"setSky",args:[t.sky]}),Ee(e.projection,t.projection)||i.push({command:"setProjection",args:[t.projection]});const n={},r=[];!function(e,t,i,n){let r;for(r in t=t||{},e=e||{})Object.prototype.hasOwnProperty.call(e,r)&&(Object.prototype.hasOwnProperty.call(t,r)||Ie(r,i,n));for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&(Object.prototype.hasOwnProperty.call(e,r)?Ee(e[r],t[r])||("geojson"===e[r].type&&"geojson"===t[r].type&&Me(e,t,r)?Te(i,{command:"setGeoJSONSourceData",args:[r,t[r].data]}):ke(r,t,i,n)):Se(r,t,i))}(e.sources,t.sources,r,n);const o=[];e.layers&&e.layers.forEach(e=>{"source"in e&&n[e.source]?i.push({command:"removeLayer",args:[e.id]}):o.push(e)}),i=i.concat(r),function(e,t,i){t=t||[];const n=(e=e||[]).map(Pe),r=t.map(Pe),o=e.reduce(Ae,{}),s=t.reduce(Ae,{}),a=n.slice(),l=Object.create(null);let c,u,h,d,p;for(let e=0,t=0;e<n.length;e++)c=n[e],Object.prototype.hasOwnProperty.call(s,c)?t++:(Te(i,{command:"removeLayer",args:[c]}),a.splice(a.indexOf(c,t),1));for(let e=0,t=0;e<r.length;e++)c=r[r.length-1-e],a[a.length-1-e]!==c&&(Object.prototype.hasOwnProperty.call(o,c)?(Te(i,{command:"removeLayer",args:[c]}),a.splice(a.lastIndexOf(c,a.length-t),1)):t++,d=a[a.length-e],Te(i,{command:"addLayer",args:[s[c],d]}),a.splice(a.length-e,0,c),l[c]=!0);for(let e=0;e<r.length;e++)if(c=r[e],u=o[c],h=s[c],!l[c]&&!Ee(u,h))if(Ee(u.source,h.source)&&Ee(u["source-layer"],h["source-layer"])&&Ee(u.type,h.type)){for(p in Ce(u.layout,h.layout,i,c,null,"setLayoutProperty"),Ce(u.paint,h.paint,i,c,null,"setPaintProperty"),Ee(u.filter,h.filter)||Te(i,{command:"setFilter",args:[c,h.filter]}),Ee(u.minzoom,h.minzoom)&&Ee(u.maxzoom,h.maxzoom)||Te(i,{command:"setLayerZoomRange",args:[c,h.minzoom,h.maxzoom]}),u)Object.prototype.hasOwnProperty.call(u,p)&&"layout"!==p&&"paint"!==p&&"filter"!==p&&"metadata"!==p&&"minzoom"!==p&&"maxzoom"!==p&&(0===p.indexOf("paint.")?Ce(u[p],h[p],i,c,p.slice(6),"setPaintProperty"):Ee(u[p],h[p])||Te(i,{command:"setLayerProperty",args:[c,p,h[p]]}));for(p in h)Object.prototype.hasOwnProperty.call(h,p)&&!Object.prototype.hasOwnProperty.call(u,p)&&"layout"!==p&&"paint"!==p&&"filter"!==p&&"metadata"!==p&&"minzoom"!==p&&"maxzoom"!==p&&(0===p.indexOf("paint.")?Ce(u[p],h[p],i,c,p.slice(6),"setPaintProperty"):Ee(u[p],h[p])||Te(i,{command:"setLayerProperty",args:[c,p,h[p]]}))}else Te(i,{command:"removeLayer",args:[c]}),d=a[a.lastIndexOf(c)+1],Te(i,{command:"addLayer",args:[h,d]})}(o,t.layers,i)}catch(e){i=[{command:"setStyle",args:[t]}]}return i},e.bX=function(e){const t=[],i=e.id;return void 0===i&&t.push({message:`layers.${i}: missing required property "id"`}),void 0===e.render&&t.push({message:`layers.${i}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),t},e.bY=j,e.bZ=V,e.b_=class extends Ta{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1i(this.location,e))}},e.ba=Yd,e.bb=Kd,e.bc=function(e,t,i,n,r){var o=1/Math.tan(t/2);if(e[0]=o/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=r&&r!==1/0){var s=1/(n-r);e[10]=(r+n)*s,e[14]=2*r*n*s}else e[10]=-1,e[14]=-2*n;return e},e.bd=function(e){var t=new p(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},e.be=function(e,t,i){var n=Math.sin(i),r=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[4],u=t[5],h=t[6],d=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*r+c*n,e[1]=s*r+u*n,e[2]=a*r+h*n,e[3]=l*r+d*n,e[4]=c*r-o*n,e[5]=u*r-s*n,e[6]=h*r-a*n,e[7]=d*r-l*n,e},e.bf=function(e,t,i){var n=Math.sin(i),r=Math.cos(i),o=t[4],s=t[5],a=t[6],l=t[7],c=t[8],u=t[9],h=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=o*r+c*n,e[5]=s*r+u*n,e[6]=a*r+h*n,e[7]=l*r+d*n,e[8]=c*r-o*n,e[9]=u*r-s*n,e[10]=h*r-a*n,e[11]=d*r-l*n,e},e.bg=function(e,t){var i=t[0],n=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],p=t[11],f=t[12],m=t[13],g=t[14],y=t[15],_=i*a-n*s,v=i*l-r*s,x=i*c-o*s,b=n*l-r*a,w=n*c-o*a,E=r*c-o*l,T=u*m-h*f,S=u*g-d*f,I=u*y-p*f,k=h*g-d*m,M=h*y-p*m,C=d*y-p*g,P=_*C-v*M+x*k+b*I-w*S+E*T;return P?(e[0]=(a*C-l*M+c*k)*(P=1/P),e[1]=(r*M-n*C-o*k)*P,e[2]=(m*E-g*w+y*b)*P,e[3]=(d*w-h*E-p*b)*P,e[4]=(l*I-s*C-c*S)*P,e[5]=(i*C-r*I+o*S)*P,e[6]=(g*x-f*E-y*v)*P,e[7]=(u*E-d*x+p*v)*P,e[8]=(s*M-a*I+c*T)*P,e[9]=(n*I-i*M-o*T)*P,e[10]=(f*w-m*x+y*_)*P,e[11]=(h*x-u*w-p*_)*P,e[12]=(a*S-s*k-l*T)*P,e[13]=(i*k-n*S+r*T)*P,e[14]=(m*v-f*b-g*_)*P,e[15]=(u*b-h*v+d*_)*P,e):null},e.bh=function(){const e=new Float32Array(16);return m(e),e},e.bi=function(){const e=new Float64Array(16);return m(e),e},e.bj=function(){return new Float64Array(16)},e.bk=function(e,t,i){const n=new Float64Array(4);return I(n,e,t-90,i),n},e.bl=function(e,t,i,n){var r,o,s,a,l,c=t[0],u=t[1],h=t[2],p=t[3],f=i[0],m=i[1],g=i[2],y=i[3];return(o=c*f+u*m+h*g+p*y)<0&&(o=-o,f=-f,m=-m,g=-g,y=-y),1-o>d?(r=Math.acos(o),s=Math.sin(r),a=Math.sin((1-n)*r)/s,l=Math.sin(n*r)/s):(a=1-n,l=n),e[0]=a*c+l*f,e[1]=a*u+l*m,e[2]=a*h+l*g,e[3]=a*p+l*y,e},e.bm=function(e){const t=new Float64Array(9);var i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,y,_,v;h=(r=(n=e)[0])*(l=r+r),d=(o=n[1])*l,f=(s=n[2])*l,m=s*(c=o+o),y=(a=n[3])*l,_=a*c,v=a*(u=s+s),(i=t)[0]=1-(p=o*c)-(g=s*u),i[3]=d-v,i[6]=f+_,i[1]=d+v,i[4]=1-h-g,i[7]=m-y,i[2]=f-_,i[5]=m+y,i[8]=1-h-p;const x=te(-Math.asin(O(t[2],-1,1)));let b,w;return Math.hypot(t[5],t[8])<.001?(b=0,w=-te(Math.atan2(t[3],t[4]))):(b=te(0===t[5]&&0===t[8]?0:Math.atan2(t[5],t[8])),w=te(0===t[1]&&0===t[0]?0:Math.atan2(t[1],t[0]))),{roll:b,pitch:x+90,bearing:w}},e.bn=function(e,t){return e.roll==t.roll&&e.pitch==t.pitch&&e.bearing==t.bearing},e.bo=Mt,e.bp=Sa,e.bq=_c,e.br=vc,e.bs=gc,e.bt=D,e.bu=R,e.bv=Gt,e.bw=function(e,t,i,n,r){return D(n,r,O((e-t)/(i-t),0,1))},e.bx=function(e,t,i,n){return e[0]=t[0]+i[0]*n,e[1]=t[1]+i[1]*n,e[2]=t[2]+i[2]*n,e},e.by=L,e.bz=function(){return new Float64Array(3)},e.c=le,e.c$=rr,e.c0=class extends Ta{constructor(e,t){super(e,t),this.current=Ma}set(e){if(e[12]!==this.current[12]||e[0]!==this.current[0])return this.current=e,void this.gl.uniformMatrix4fv(this.location,!1,e);for(let t=1;t<16;t++)if(e[t]!==this.current[t]){this.current=e,this.gl.uniformMatrix4fv(this.location,!1,e);break}}},e.c1=Ia,e.c2=class extends Ta{constructor(e,t){super(e,t),this.current=[0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]||(this.current=e,this.gl.uniform3f(this.location,e[0],e[1],e[2]))}},e.c3=class extends Ta{constructor(e,t){super(e,t),this.current=[0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]||(this.current=e,this.gl.uniform2f(this.location,e[0],e[1]))}},e.c4=f,e.c5=function(e,t){var i=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=i,e[2]=0,e[3]=-i,e[4]=n,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},e.c6=function(e,t,i){var n=t[0],r=t[1],o=t[2];return e[0]=n*i[0]+r*i[3]+o*i[6],e[1]=n*i[1]+r*i[4]+o*i[7],e[2]=n*i[2]+r*i[5]+o*i[8],e},e.c7=function(e,t,i,n,r,o,s){var a=1/(t-i),l=1/(n-r),c=1/(o-s);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+i)*a,e[13]=(r+n)*l,e[14]=(s+o)*c,e[15]=1,e},e.c8=class extends Ta{constructor(e,t){super(e,t),this.current=new Array}set(e){if(e!=this.current){this.current=e;const t=new Float32Array(4*e.length);for(let i=0;i<e.length;i++)t[4*i]=e[i].r,t[4*i+1]=e[i].g,t[4*i+2]=e[i].b,t[4*i+3]=e[i].a;this.gl.uniform4fv(this.location,t)}}},e.c9=class extends Ta{constructor(e,t){super(e,t),this.current=new Array}set(e){if(e!=this.current){this.current=e;const t=new Float32Array(e);this.gl.uniform1fv(this.location,t)}}},e.cA=function(e,t){return ie[t]&&"touches"in e},e.cB=function(e){return ie[e]||ne[e]},e.cC=function(e,t,i){var n=t[0],r=t[1];return e[0]=i[0]*n+i[4]*r+i[12],e[1]=i[1]*n+i[5]*r+i[13],e},e.cD=function(e,t){const{x:i,y:n}=Hd.fromLngLat(t);return!(e<0||e>25||n<0||n>=1||i<0||i>=1)},e.cE=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},e.cF=class extends us{},e.cG=he,e.cH=function(e,t){le.REGISTERED_PROTOCOLS[e]=t},e.cI=function(e){delete le.REGISTERED_PROTOCOLS[e]},e.cJ=function(e,t){const i={};for(let n=0;n<e.length;n++){const r=t&&t[e[n].id]||Er(e[n]);t&&(t[e[n].id]=r);let o=i[r];o||(o=i[r]=[]),o.push(e[n])}const n=[];for(const e in i)n.push(i[e]);return n},e.cK=fo,e.cL=ep,e.cM=om,e.cN=id,e.cO=function(t){var i,n;t.bucket.createArrays(),t.bucket.tilePixelRatio=C/(512*t.bucket.overscaling),t.bucket.compareText={},t.bucket.iconsNeedLinear=!1;const r=t.bucket.layers[0],o=r.layout,s=r._unevaluatedLayout._values,a={layoutIconSize:s["icon-size"].possiblyEvaluate(new zo(t.bucket.zoom+1),t.canonical),layoutTextSize:s["text-size"].possiblyEvaluate(new zo(t.bucket.zoom+1),t.canonical),textMaxSize:s["text-size"].possiblyEvaluate(new zo(18))};if("composite"===t.bucket.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.bucket.textSizeData;a.compositeTextSizes=[s["text-size"].possiblyEvaluate(new zo(e),t.canonical),s["text-size"].possiblyEvaluate(new zo(i),t.canonical)]}if("composite"===t.bucket.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.bucket.iconSizeData;a.compositeIconSizes=[s["icon-size"].possiblyEvaluate(new zo(e),t.canonical),s["icon-size"].possiblyEvaluate(new zo(i),t.canonical)]}const l=o.get("text-line-height")*Ih,c="viewport"!==o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement"),u=o.get("text-keep-upright"),h=o.get("text-size");for(const s of t.bucket.features){const d=o.get("text-font").evaluate(s,{},t.canonical).join(","),p=h.evaluate(s,{},t.canonical),f=a.layoutTextSize.evaluate(s,{},t.canonical),m=a.layoutIconSize.evaluate(s,{},t.canonical),g={horizontal:{},vertical:void 0},y=s.text;let _,v=[0,0];if(y){const i=y.toString(),n=o.get("text-letter-spacing").evaluate(s,{},t.canonical)*Ih,a=So(i)?n:0,h=o.get("text-anchor").evaluate(s,{},t.canonical),m=zm(r,s,t.canonical);if(!m){const e=o.get("text-radial-offset").evaluate(s,{},t.canonical);v=e?Rm(h,[e*Ih,Dm]):o.get("text-offset").evaluate(s,{},t.canonical).map(e=>e*Ih)}let _=c?"center":o.get("text-justify").evaluate(s,{},t.canonical);const x="point"===o.get("symbol-placement")?o.get("text-max-width").evaluate(s,{},t.canonical)*Ih:1/0,b=()=>{t.bucket.allowVerticalPlacement&&To(i)&&(g.vertical=rd(y,t.glyphMap,t.glyphPositions,t.imagePositions,d,x,l,h,"left",a,v,e.ax.vertical,!0,f,p))};if(!c&&m){const i=new Set;if("auto"===_)for(let e=0;e<m.values.length;e+=2)i.add(Fm(m.values[e]));else i.add(_);let n=!1;for(const r of i)if(!g.horizontal[r])if(n)g.horizontal[r]=g.horizontal[0];else{const i=rd(y,t.glyphMap,t.glyphPositions,t.imagePositions,d,x,l,"center",r,a,v,e.ax.horizontal,!1,f,p);i&&(g.horizontal[r]=i,n=1===i.positionedLines.length)}b()}else{"auto"===_&&(_=Fm(h));const n=rd(y,t.glyphMap,t.glyphPositions,t.imagePositions,d,x,l,h,_,a,v,e.ax.horizontal,!1,f,p);n&&(g.horizontal[_]=n),b(),To(i)&&c&&u&&(g.vertical=rd(y,t.glyphMap,t.glyphPositions,t.imagePositions,d,x,l,h,_,a,v,e.ax.vertical,!1,f,p))}}let x=!1;if(null===(i=s.icon)||void 0===i?void 0:i.name){const e=t.imageMap[s.icon.name];e&&(_=dd(t.imagePositions[s.icon.name],o.get("icon-offset").evaluate(s,{},t.canonical),o.get("icon-anchor").evaluate(s,{},t.canonical)),x=!!e.sdf,void 0===t.bucket.sdfIcons?t.bucket.sdfIcons=x:t.bucket.sdfIcons!==x&&q(),(e.pixelRatio!==t.bucket.pixelRatio||0!==o.get("icon-rotate").constantOr(1))&&(t.bucket.iconsNeedLinear=!0))}const b=Bm(g.horizontal)||g.vertical;(n=t.bucket).iconsInText||(n.iconsInText=!!b&&b.iconsInText),(b||_)&&Om(t.bucket,s,g,_,t.imageMap,a,f,m,v,x,t.canonical,t.subdivisionGranularity)}t.showCollisionBoxes&&t.bucket.generateCollisionDebugBuffers()},e.cP=Ic,e.cQ=qc,e.cR=hh,e.cS=function(e,t=""){const i=new Bh;return function(e,t,i=""){for(const n in e.layers)t.writeMessage(3,(e,t)=>Kf(e,t,i),e.layers[n])}(e,i,t),i.finish()},e.cT=function(e,t,i,n,r,o){let s=cm(e,t,i,r,0);return s=cm(s,t,n,o,1),s},e.cU=class{constructor(e){this.maxEntries=e,this.map=new Map}get(e){const t=this.map.get(e);return void 0!==t&&(this.map.delete(e),this.map.set(e,t)),t}set(e,t){if(this.map.has(e))this.map.delete(e);else if(this.map.size>=this.maxEntries){const e=this.map.keys().next().value;this.map.delete(e)}this.map.set(e,t)}clear(){this.map.clear()}},e.cV=Gc,e.cW=Bh,e.cX=Xf,e.cY=function(e,i,n,r,o){return t(this,void 0,void 0,function*(){if(h())try{return yield Y(e,i,n,r,o)}catch(e){}return function(e,t,i,n,r){const o=e.width,s=e.height;J&&K||(J=new OffscreenCanvas(o,s),K=J.getContext("2d",{willReadFrequently:!0})),J.width=o,J.height=s,K.drawImage(e,0,0,o,s);const a=K.getImageData(t,i,n,r);return K.clearRect(0,0,o,s),a.data}(e,i,n,r,o)})},e.cZ=Nl,e.c_=class{constructor(e,t){this.layers={[Jf]:this},this.name=Jf,this.version=t?t.version:1,this.extent=t?t.extent:4096,this.length=e.length,this.features=e}feature(e){return new Yf(this.features[e],this.extent)}},e.ca=class extends ws{},e.cb=Eh,e.cc=class extends Ts{},e.cd=Cl,e.ce=function(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},e.cf=Ml,e.cg=function(e,t,i){var n=t[0],r=t[1],o=t[2],s=i[3]*n+i[7]*r+i[11]*o+i[15];return e[0]=(i[0]*n+i[4]*r+i[8]*o+i[12])/(s=s||1),e[1]=(i[1]*n+i[5]*r+i[9]*o+i[13])/s,e[2]=(i[2]*n+i[6]*r+i[10]*o+i[14])/s,e},e.ch=class extends hs{},e.ci=class extends As{},e.cj=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]},e.ck=function(e,t){var i=e[0],n=e[1],r=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],p=e[10],f=e[11],m=e[12],g=e[13],y=e[14],_=e[15],v=t[0],x=t[1],b=t[2],w=t[3],E=t[4],T=t[5],S=t[6],I=t[7],k=t[8],M=t[9],C=t[10],P=t[11],A=t[12],L=t[13],D=t[14],R=t[15];return Math.abs(i-v)<=d*Math.max(1,Math.abs(i),Math.abs(v))&&Math.abs(n-x)<=d*Math.max(1,Math.abs(n),Math.abs(x))&&Math.abs(r-b)<=d*Math.max(1,Math.abs(r),Math.abs(b))&&Math.abs(o-w)<=d*Math.max(1,Math.abs(o),Math.abs(w))&&Math.abs(s-E)<=d*Math.max(1,Math.abs(s),Math.abs(E))&&Math.abs(a-T)<=d*Math.max(1,Math.abs(a),Math.abs(T))&&Math.abs(l-S)<=d*Math.max(1,Math.abs(l),Math.abs(S))&&Math.abs(c-I)<=d*Math.max(1,Math.abs(c),Math.abs(I))&&Math.abs(u-k)<=d*Math.max(1,Math.abs(u),Math.abs(k))&&Math.abs(h-M)<=d*Math.max(1,Math.abs(h),Math.abs(M))&&Math.abs(p-C)<=d*Math.max(1,Math.abs(p),Math.abs(C))&&Math.abs(f-P)<=d*Math.max(1,Math.abs(f),Math.abs(P))&&Math.abs(m-A)<=d*Math.max(1,Math.abs(m),Math.abs(A))&&Math.abs(g-L)<=d*Math.max(1,Math.abs(g),Math.abs(L))&&Math.abs(y-D)<=d*Math.max(1,Math.abs(y),Math.abs(D))&&Math.abs(_-R)<=d*Math.max(1,Math.abs(_),Math.abs(R))},e.cl=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},e.cm=e=>"circle"===e.type,e.cn=e=>"heatmap"===e.type,e.co=e=>"line"===e.type,e.cp=e=>"fill"===e.type,e.cq=e=>"fill-extrusion"===e.type,e.cr=e=>"hillshade"===e.type,e.cs=e=>"color-relief"===e.type,e.ct=e=>"background"===e.type,e.cu=e=>"custom"===e.type,e.cv=z,e.cw=function(e,t,i){if(t<=0)return e;const n=1/t;return void 0===i||Math.abs(i)<1e-10?Math.round(e*n)/n:(i>0?Math.ceil(e*n-1e-9):Math.floor(e*n+1e-10))/n},e.cx=function(e,t,i){const n=M(t.x-i.x,t.y-i.y),r=M(e.x-i.x,e.y-i.y);var o,s;return te(Math.atan2(n[0]*r[1]-n[1]*r[0],(o=n)[0]*(s=r)[0]+o[1]*s[1]))},e.cy=F,e.cz=function(e,t){var i;if(!ne[t])return!1;const n=null==e?void 0:e.target,r=(null===(i=null==n?void 0:n.ownerDocument)||void 0===i?void 0:i.defaultView)||window;return e instanceof r.MouseEvent||e instanceof r.WheelEvent},e.d=A,e.d0=class{constructor(e,t){if((t=this.options=Object.assign({},rh,t)).debug,t.maxZoom<0||t.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");let i=hu(e,t);i=Fu(i,t),t.updateable&&(this.source=i),this.initializeIndex(i,t)}initializeIndex(e,t){this.tileIndex=t.cluster?new Uu(t.clusterOptions):new ih(t),e.length&&this.tileIndex.initialize(e)}getTile(e,t,i){return t=+t,i=+i,(e=+e)<0||e>24?null:this.tileIndex.getTile(e,t,i)}updateData(e,t){const i=this.options;if(!i.updateable)throw new Error("to update tile geojson `updateable` option must be set to true");let{affected:n,source:r}=function(e,t,i){const n=function(e,t){return e?{removeAll:e.removeAll,remove:new Set(e.remove||[]),add:new Map(e.add?.map(e=>[t.promoteId?e.properties[t.promoteId]:e.id,e])),update:new Map(e.update?.map(e=>[e.id,e]))}:{remove:new Set,add:new Map,update:new Map}}(t,i);let r=[];if(n.removeAll&&(r=e,e=[]),n.remove.size||n.add.size){const t=[];for(const i of e)(n.remove.has(i.id)||n.add.has(i.id))&&t.push(i);if(t.length){r.push(...t);const i=new Set(t.map(e=>e.id));e=e.filter(e=>!i.has(e.id))}if(n.add.size){let t=hu({type:"FeatureCollection",features:Array.from(n.add.values())},i);t=Fu(t,i),r.push(...t),e.push(...t)}}if(n.update.size){const t=new Map,o=[];for(const i of e)n.update.has(i.id)?t.set(i.id,[...t.get(i.id)||[],i]):o.push(i);for(const[e,s]of n.update){const n=t.get(e);if(!n||0===n.length)continue;const a=Gu(n,s,i);r.push(...n,...a),o.push(...a)}e=o}return{affected:r,source:e}}(this.source,e,i);t&&({affected:n,source:r}=this.filterUpdate(r,n,t)),n.length&&(this.source=r,this.tileIndex.updateIndex(r,n,i))}filterUpdate(e,t,i){const n=new Set;for(const r of e)null!=r.id&&(i(yu(r))||(t.push(r),n.add(r.id)));return{affected:t,source:e=e.filter(e=>!n.has(e.id))}}getData(){if(!this.options.updateable)throw new Error("to retrieve data the `updateable` option must be set to true");return{type:"FeatureCollection",features:this.source.map(e=>yu(e))}}updateClusterOptions(e,t){const i=this.options.cluster;this.options.cluster=e,this.options.clusterOptions=t,i!=e?this.initializeIndex(this.source,this.options):this.tileIndex.updateIndex(this.source,[],this.options)}getClusterExpansionZoom(e){return this.tileIndex.getClusterExpansionZoom(e)}getClusterChildren(e){return this.tileIndex.getChildren(e)}getClusterLeaves(e,t,i){return this.tileIndex.getLeaves(e,t,i)}},e.d1=Ro,e.e=B,e.f=fe,e.g=ce,e.h=e=>t(void 0,void 0,void 0,function*(){if(0===e.byteLength)return createImageBitmap(new ImageData(1,1));const t=new Blob([new Uint8Array(e)],{type:"image/png"});try{return createImageBitmap(t)}catch(e){throw new Error(`Could not load image because of ${A(e).message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}}),e.i=$,e.j=e=>new Promise((t,i)=>{const n=new Image;n.onload=()=>{t(n),URL.revokeObjectURL(n.src),n.onload=null,window.requestAnimationFrame(()=>n.src=X)},n.onerror=()=>i(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const r=new Blob([new Uint8Array(e)],{type:"image/png"});n.src=e.byteLength?URL.createObjectURL(r):X}),e.k=(e,t)=>pe(B(e,{type:"json"}),t),e.l=_e,e.m=pe,e.n=ye,e.o=(e,t)=>pe(B(e,{type:"arrayBuffer"}),t),e.p=ed,e.q=function(e){return new Bh(e).readFields(Jh,[])},e.r=function(e){return/[\u02EA\u02EB\u1100-\u11FF\u2E80-\u2FDF\u3000-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))},e.s=Q,e.t=Sl,e.u=Jo,e.v=ro,e.w=q,e.x=xe,e.y=Go,e.z=so}),i("worker",["./shared"],function(e){class t{constructor(e,t){this.keyCache={},e&&this.replace(e,t)}replace(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t)}update(t,i,n){for(const i of t){this._layerConfigs[i.id]=i;const t=this._layers[i.id]=e.bT(i,n);t._featureFilter=e.ah(t.filter,n),this.keyCache[i.id]&&delete this.keyCache[i.id]}for(const e of i)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const r=e.cJ(Object.values(this._layerConfigs),this.keyCache);for(const t of r){const i=t.map(e=>this._layers[e.id]),n=i[0];if(n.isHidden())continue;const r=n.source||"";let o=this.familiesBySource[r];o||(o=this.familiesBySource[r]={});const s=n.sourceLayer||e.ag;let a=o[s];a||(a=o[s]=[]),a.push(i)}}}class i{constructor(t){const i={},n=[];for(const e in t){const r=t[e],o=i[e]={};for(const e in r){const t=r[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const i={x:0,y:0,w:t.bitmap.width+2,h:t.bitmap.height+2};n.push(i),o[e]={rect:i,metrics:t.metrics}}}const{w:r,h:o}=e.p(n),s=new e.t({width:r||1,height:o||1});for(const n in t){const r=t[n];for(const t in r){const o=r[+t];if(!o||0===o.bitmap.width||0===o.bitmap.height)continue;const a=i[n][t].rect;e.t.copy(o.bitmap,s,{x:0,y:0},{x:a.x+1,y:a.y+1},o.bitmap)}}this.image=s,this.positions=i}}e.cK("GlyphAtlas",i);class n{constructor(t){this.tileID=new e.a3(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.uid=t.uid,this.zoom=t.zoom,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.inFlightDependencies=[]}parse(t,n,o,s,a){return e._(this,void 0,void 0,function*(){this.status="parsing",this.data=t,this.collisionBoxArray=new e.ae;const l=new e.cL(Object.keys(t.layers).sort()),c=new e.cM(this.tileID,this.promoteId);c.bucketLayerIDs=[];const u={},h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:o,subdivisionGranularity:a},d=n.familiesBySource[this.source];for(const i in d){const n=t.layers[i];if(!n)continue;1===n.version&&e.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const s=l.encode(i),a=[];for(let e=0;e<n.length;e++){const t=n.feature(e),r=c.getId(t,i);a.push({feature:t,id:r,index:e,sourceLayerIndex:s})}for(const t of d[i]){const i=t[0];i.source!==this.source&&e.w(`layer.source = ${i.source} does not equal this.source = ${this.source}`),i.isHidden(this.zoom,!0)||(r(t,this.zoom,o),(u[i.id]=i.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:s,sourceID:this.source})).populate(a,h,this.tileID.canonical),c.bucketLayerIDs.push(t.map(e=>e.id)))}}const p=e.bY(h.glyphDependencies,e=>Object.keys(e).map(Number));for(const e of this.inFlightDependencies)null==e||e.abort();this.inFlightDependencies=[];let f=Promise.resolve({});if(Object.keys(p).length){const e=new AbortController;this.inFlightDependencies.push(e),f=s.sendAsync({type:"GG",data:{stacks:p,source:this.source,tileID:this.tileID,type:"glyphs"}},e)}const m=Object.keys(h.iconDependencies);let g=Promise.resolve({});if(m.length){const e=new AbortController;this.inFlightDependencies.push(e),g=s.sendAsync({type:"GI",data:{icons:m,source:this.source,tileID:this.tileID,type:"icons"}},e)}const y=Object.keys(h.patternDependencies);let _=Promise.resolve({});if(y.length){const e=new AbortController;this.inFlightDependencies.push(e),_=s.sendAsync({type:"GI",data:{icons:y,source:this.source,tileID:this.tileID,type:"patterns"}},e)}const v=h.dashDependencies;let x=Promise.resolve({});if(Object.keys(v).length){const e=new AbortController;this.inFlightDependencies.push(e),x=s.sendAsync({type:"GDA",data:{dashes:v}},e)}const[b,w,E,T]=yield Promise.all([f,g,_,x]),S=new i(b),I=new e.cN(w,E);for(const t in u){const i=u[t];i instanceof e.af?(r(i.layers,this.zoom,o),e.cO({bucket:i,glyphMap:b,glyphPositions:S.positions,imageMap:w,imagePositions:I.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:h.subdivisionGranularity})):i.hasDependencies&&(i instanceof e.cP||i instanceof e.cQ||i instanceof e.cR)&&(r(i.layers,this.zoom,o),i.addFeatures(h,this.tileID.canonical,I.patternPositions,T))}return this.status="done",{buckets:Object.values(u).filter(e=>!e.isEmpty()),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:S.image,imageAtlas:I,dashPositions:T,glyphMap:this.returnDependencies?b:null,iconMap:this.returnDependencies?w:null,glyphPositions:this.returnDependencies?S.positions:null}})}}function r(t,i,n){const r=new e.J(i);for(const e of t)e.recalculate(r,n)}class o{constructor(){this.loading={},this.loaded={},this.parsing={}}startLoading(e,t){this.loading[e]=t}finishLoading(e){delete this.loading[e]}abort(e){const t=this.loading[e];(null==t?void 0:t.abort)&&(t.abort.abort(),delete this.loading[e])}setParsing(e,t){this.parsing[e]=t}consumeParsing(e){const t=this.parsing[e];if(t)return delete this.parsing[e],t}clearParsing(e){delete this.parsing[e]}markLoaded(e,t){this.loaded[e]=t}getLoaded(e){const t=this.loaded[e];if(t)return t}removeLoaded(e){delete this.loaded[e]}clearLoaded(){this.loaded={}}}class s{constructor(e){this.start=`${e}#start`,this.end=`${e}#end`,this.measure=e,performance.mark(this.start)}finish(){performance.mark(this.end);let e=performance.getEntriesByName(this.measure);return 0===e.length&&(performance.measure(this.measure,this.start,this.end),e=performance.getEntriesByName(this.measure),performance.clearMarks(this.start),performance.clearMarks(this.end),performance.clearMeasures(this.measure)),e}}class a{constructor(e,t,i,n,r){this.type=e,this.properties=i||{},this.extent=r,this.pointsArray=t,this.id=n}loadGeometry(){return this.pointsArray.map(t=>t.map(t=>new e.P(t.x,t.y)))}}class l{constructor(e,t,i){this.version=2,this._myFeatures=e,this.name=t,this.length=e.length,this.extent=i}feature(e){return this._myFeatures[e]}}class c{constructor(){this.layers={}}addLayer(e){this.layers[e.name]=e}}function u(t){let i=e.cS(t);return 0===i.byteOffset&&i.byteLength===i.buffer.byteLength||(i=new Uint8Array(i)),{vectorTile:t,rawData:i.buffer}}function h(t,i,n){const{extent:r}=t,o=Math.pow(2,n.z-i.z),s=(n.x-i.x*o)*r,c=(n.y-i.y*o)*r,u=[];for(let i=0;i<t.length;i++){const n=t.feature(i);let l=n.loadGeometry();for(const e of l)for(const t of e)t.x=t.x*o-s,t.y=t.y*o-c;const h=128;l=e.cT(l,n.type,-h,-h,r+h,r+h),0!==l.length&&u.push(new a(n.type,l,n.properties,n.id,r))}return new l(u,t.name,r)}class d{constructor(t,i,n){this.actor=t,this.layerIndex=i,this.availableImages=n,this.tileState=new o,this.overzoomedTileResultCache=new e.cU(1e3)}loadVectorTile(t,i){try{return{vectorTile:"mlt"!==t.encoding?new e.cV(new e.cW(i)):new e.cX(i),rawData:i}}catch(n){const r=new Uint8Array(i);let o=`Unable to parse the tile at ${t.request.url}, `;throw o+=31===r[0]&&139===r[1]?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${e.d(n).message}`,new Error(o)}}loadTile(t){return e._(this,void 0,void 0,function*(){const{uid:i,overzoomParameters:r}=t;r&&(t.request=r.overzoomRequest);const o=this._startRequestTiming(t),s=new n(t);this.tileState.startLoading(i,s);const a=new AbortController;s.abort=a;try{const n=yield e.o(t.request,a);if(t.etag&&t.etag===n.etag)return this.tileState.finishLoading(i),this._getEtagUnmodifiedResult(n,o);const l=this.loadVectorTile(t,n.data);if(this.tileState.finishLoading(i),!l)return null;let{vectorTile:c,rawData:u}=l;r&&({vectorTile:c,rawData:u}=this._getOverzoomTile(t,c));const h=this._getExpiryData(n),d=this._finishRequestTiming(o);s.vectorTile=c,this.tileState.markLoaded(i,s);const p={rawData:u,cacheControl:h,resourceTiming:d};this.tileState.setParsing(i,p);try{return yield this._parseWorkerTile(s,t,p)}finally{this.tileState.clearParsing(i)}}catch(e){throw this.tileState.finishLoading(i),s.status="done",this.tileState.markLoaded(i,s),e}})}_getEtagUnmodifiedResult(t,i){const n=this._getExpiryData(t),r=this._finishRequestTiming(i);return e.e({etagUnmodified:!0},n,r)}_parseWorkerTile(t,i,n){return e._(this,void 0,void 0,function*(){let r=yield t.parse(t.vectorTile,this.layerIndex,this.availableImages,this.actor,i.subdivisionGranularity);if(n){const{rawData:t,cacheControl:o,resourceTiming:s}=n;r=e.e({rawTileData:t.slice(0),encoding:i.encoding},r,o,s)}return r})}_getExpiryData({expires:e,cacheControl:t,etag:i}){const n={};return e&&(n.expires=e),t&&(n.cacheControl=t),i&&(n.etag=i),n}_startRequestTiming(e){var t;if(null===(t=e.request)||void 0===t?void 0:t.collectResourceTiming)return new s(e.request.url)}_finishRequestTiming(e){const t=null==e?void 0:e.finish();return t?{resourceTiming:JSON.parse(JSON.stringify(t))}:{}}_getOverzoomTile(e,t){var i;const{tileID:n,source:r,overzoomParameters:o}=e,{maxZoomTileID:s}=o,a=`${s.key}_${n.key}_${null===(i=e.request)||void 0===i?void 0:i.url}`,l=this.overzoomedTileResultCache.get(a);if(l)return l;const d=new c,p=this.layerIndex.familiesBySource[r];for(const e in p){const i=t.layers[e];if(!i)continue;const r=h(i,s,n.canonical);r.length>0&&d.addLayer(r)}const f=u(d);return this.overzoomedTileResultCache.set(a,f),f}reloadTile(t){return e._(this,void 0,void 0,function*(){const e=t.uid,i=this.tileState.getLoaded(e);if(!i)throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");if(i.showCollisionBoxes=t.showCollisionBoxes,"parsing"===i.status){const n=this.tileState.consumeParsing(e);return yield this._parseWorkerTile(i,t,n)}if("done"===i.status&&i.vectorTile)return yield this._parseWorkerTile(i,t)})}abortTile(t){return e._(this,void 0,void 0,function*(){this.tileState.abort(t.uid)})}removeTile(t){return e._(this,void 0,void 0,function*(){this.tileState.removeLoaded(t.uid)})}}class p{constructor(){this.loaded={}}loadTile(t){return e._(this,void 0,void 0,function*(){const{uid:i,encoding:n,rawImageData:r,redFactor:o,greenFactor:s,blueFactor:a,baseShift:l}=t,c=r.width+2,u=r.height+2,h=e.b(r)?new e.R({width:c,height:u},yield e.cY(r,-1,-1,c,u)):r,d=new e.cZ(i,h,n,o,s,a,l);return this.loaded||(this.loaded={}),this.loaded[i]=d,d})}removeTile(e){const t=this.loaded,i=e.uid;(null==t?void 0:t[i])&&delete t[i]}}class f{constructor(e,t,i,n=m){this.actor=e,this.layerIndex=t,this.availableImages=i,this.tileState=new o,this._createGeoJSONIndex=n}loadVectorTile(t){if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");const{z:i,x:n,y:r}=t.tileID.canonical,o=this._geoJSONIndex.getTile(i,n,r);return o?u(new e.c_(o.features,{version:2,extent:e.a6})):null}loadTile(t){return e._(this,void 0,void 0,function*(){const{uid:e}=t,i=new n(t);i.abort=new AbortController;try{const n=this.loadVectorTile(t);if(!n)return null;const{vectorTile:r,rawData:o}=n;i.vectorTile=r,this.tileState.markLoaded(e,i);const s={rawData:o};this.tileState.setParsing(e,s);try{return yield this._parseWorkerTile(i,t,s)}finally{this.tileState.clearParsing(e)}}catch(t){throw i.status="done",this.tileState.markLoaded(e,i),t}})}_reloadLoadedTile(t){return e._(this,void 0,void 0,function*(){const e=t.uid,i=this.tileState.getLoaded(e);if(!i)throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");if(i.showCollisionBoxes=t.showCollisionBoxes,"parsing"===i.status){const n=this.tileState.consumeParsing(e);return yield this._parseWorkerTile(i,t,n)}if("done"===i.status&&i.vectorTile)return yield this._parseWorkerTile(i,t)})}_parseWorkerTile(t,i,n){return e._(this,void 0,void 0,function*(){let r=yield t.parse(t.vectorTile,this.layerIndex,this.availableImages,this.actor,i.subdivisionGranularity);if(n){const{rawData:t}=n;r=e.e({rawTileData:t.slice(0),encoding:"mvt"},r)}return r})}abortTile(t){return e._(this,void 0,void 0,function*(){this.tileState.abort(t.uid)})}removeTile(t){return e._(this,void 0,void 0,function*(){this.tileState.removeLoaded(t.uid)})}loadData(t){return e._(this,void 0,void 0,function*(){var i;null===(i=this._pendingRequest)||void 0===i||i.abort();const n=this._startRequestTiming(t);this._pendingRequest=new AbortController;try{yield this.loadAndProcessGeoJSON(t,this._pendingRequest),delete this._pendingRequest,this.tileState.clearLoaded();const e={};return t.request&&(e.data=t.data),this._finishRequestTiming(n,t,e),e}catch(t){if(delete this._pendingRequest,!e.$(t))throw t;return{abandoned:!0}}})}_startRequestTiming(e){var t;if(null===(t=e.request)||void 0===t?void 0:t.collectResourceTiming)return new s(e.request.url)}_finishRequestTiming(e,t,i){const n=null==e?void 0:e.finish();n&&(i.resourceTiming={[t.source]:JSON.parse(JSON.stringify(n))})}reloadTile(e){return this.tileState.getLoaded(e.uid)?this._reloadLoadedTile(e):this.loadTile(e)}loadAndProcessGeoJSON(t,i){return e._(this,void 0,void 0,function*(){var n;if(t.request&&(t.data=(yield e.k(t.request,i)).data),t.data)return t.data=this._filterGeoJSON(t.data,t.filter),void(this._geoJSONIndex=this._createGeoJSONIndex(t.data,t));if(t.dataDiff)return null!==(n=this._geoJSONIndex)&&void 0!==n||(this._geoJSONIndex=this._createGeoJSONIndex({type:"FeatureCollection",features:[]},t)),void this._geoJSONIndex.updateData(t.dataDiff,this._getFilterPredicate(t.filter));if(t.updateCluster&&this._geoJSONIndex.updateClusterOptions(t.geojsonVtOptions.cluster,g(t)),null==this._geoJSONIndex)throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`)})}_filterGeoJSON(e,t){if("FeatureCollection"!==e.type)return e;const i=this._getFilterPredicate(t);return i?{type:"FeatureCollection",features:e.features.filter(e=>i(e))}:e}_getFilterPredicate(t){if("boolean"!=typeof t&&!(null==t?void 0:t.length))return;const i=e.c$(t,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===i.result)throw new Error(i.value.map(e=>`${e.key}: ${e.message}`).join(", "));return e=>i.value.evaluate({zoom:0},e)}removeSource(t){return e._(this,void 0,void 0,function*(){var e;null===(e=this._pendingRequest)||void 0===e||e.abort()})}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getClusterChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getClusterLeaves(e.clusterId,e.limit,e.offset)}}function m(t,i){const n=e.e(i.geojsonVtOptions||{},{updateable:!0,clusterOptions:g(i)});return new e.d0(t,n)}function g({geojsonVtOptions:t,clusterProperties:i}){if(!i||!t.clusterOptions)return t.clusterOptions;const n={},r={},o={accumulated:null,zoom:0},s={properties:null},a=Object.keys(i);for(const t of a){const[o,s]=i[t],a=e.c$(s),l=e.c$("string"==typeof o?[o,["accumulated"],["get",t]]:o);n[t]=a.value,r[t]=l.value}return t.clusterOptions.map=e=>{s.properties=e;const t={};for(const e of a)t[e]=n[e].evaluate(o,s);return t},t.clusterOptions.reduce=(e,t)=>{s.properties=t;for(const t of a)o.accumulated=e[t],e[t]=r[t].evaluate(o,s)},t.clusterOptions}class y{constructor(t){this.self=t,this.actor=new e.N(t),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(e,t)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=t},this.self.addProtocol=e.cH,this.self.removeProtocol=e.cI,this.self.registerRTLTextPlugin=t=>{e.d1.setMethods(t)},this.self.makeRequest=e.m,this.actor.registerMessageHandler("LDT",(e,t)=>this._getDEMWorkerSource(e,t.source).loadTile(t)),this.actor.registerMessageHandler("RDT",(t,i)=>e._(this,void 0,void 0,function*(){this._getDEMWorkerSource(t,i.source).removeTile(i)})),this.actor.registerMessageHandler("GCEZ",(t,i)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(t,i.type,i.source).getClusterExpansionZoom(i)})),this.actor.registerMessageHandler("GCC",(t,i)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(t,i.type,i.source).getClusterChildren(i)})),this.actor.registerMessageHandler("GCL",(t,i)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(t,i.type,i.source).getClusterLeaves(i)})),this.actor.registerMessageHandler("LD",(e,t)=>this._getWorkerSource(e,t.type,t.source).loadData(t)),this.actor.registerMessageHandler("LT",(e,t)=>this._getWorkerSource(e,t.type,t.source).loadTile(t)),this.actor.registerMessageHandler("RT",(e,t)=>this._getWorkerSource(e,t.type,t.source).reloadTile(t)),this.actor.registerMessageHandler("AT",(e,t)=>this._getWorkerSource(e,t.type,t.source).abortTile(t)),this.actor.registerMessageHandler("RMT",(e,t)=>this._getWorkerSource(e,t.type,t.source).removeTile(t)),this.actor.registerMessageHandler("RS",(t,i)=>e._(this,void 0,void 0,function*(){var e,n;if(!(null===(n=null===(e=this.workerSources[t])||void 0===e?void 0:e[i.type])||void 0===n?void 0:n[i.source]))return;const r=this.workerSources[t][i.type][i.source];delete this.workerSources[t][i.type][i.source],void 0!==r.removeSource&&r.removeSource(i)})),this.actor.registerMessageHandler("RM",t=>e._(this,void 0,void 0,function*(){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t],this.globalStates.delete(t)})),this.actor.registerMessageHandler("SR",(t,i)=>e._(this,void 0,void 0,function*(){this.referrer=i})),this.actor.registerMessageHandler("SRPS",(e,t)=>this._syncRTLPluginState(e,t)),this.actor.registerMessageHandler("IS",(t,i)=>e._(this,void 0,void 0,function*(){this.self.importScripts(i)})),this.actor.registerMessageHandler("SI",(e,t)=>this._setImages(e,t)),this.actor.registerMessageHandler("UL",(t,i)=>e._(this,void 0,void 0,function*(){this._getLayerIndex(t).update(i.layers,i.removedIds,this._getGlobalState(t))})),this.actor.registerMessageHandler("UGS",(t,i)=>e._(this,void 0,void 0,function*(){const e=this._getGlobalState(t);for(const t in i)e[t]=i[t]})),this.actor.registerMessageHandler("SL",(t,i)=>e._(this,void 0,void 0,function*(){this._getLayerIndex(t).replace(i,this._getGlobalState(t))}))}_getGlobalState(e){let t=this.globalStates.get(e);return t||(t={},this.globalStates.set(e,t)),t}_setImages(t,i){return e._(this,void 0,void 0,function*(){this.availableImages[t]=i;for(const e in this.workerSources[t]){const n=this.workerSources[t][e];for(const e in n)n[e].availableImages=i}})}_syncRTLPluginState(t,i){return e._(this,void 0,void 0,function*(){return yield e.d1.syncState(i,this.self.importScripts)})}_getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}_getLayerIndex(e){let i=this.layerIndexes[e];return i||(i=this.layerIndexes[e]=new t),i}_getWorkerSource(e,t,i){var n,r;if((n=this.workerSources)[e]||(n[e]={}),(r=this.workerSources[e])[t]||(r[t]={}),!this.workerSources[e][t][i]){const n={sendAsync:(t,i)=>(t.targetMapId=e,this.actor.sendAsync(t,i))};switch(t){case"vector":this.workerSources[e][t][i]=new d(n,this._getLayerIndex(e),this._getAvailableImages(e));break;case"geojson":this.workerSources[e][t][i]=new f(n,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][t][i]=new this.externalWorkerSourceTypes[t](n,this._getLayerIndex(e),this._getAvailableImages(e))}}return this.workerSources[e][t][i]}_getDEMWorkerSource(e,t){var i,n;return(i=this.demWorkerSources)[e]||(i[e]={}),(n=this.demWorkerSources[e])[t]||(n[t]=new p),this.demWorkerSources[e][t]}}return e.i(self)&&(self.worker=new y(self)),y}),i("index",["exports","./shared"],function(e,t){var i="5.24.0";function n(){var e=new t.A(4);return t.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let r,o,s;const a={frame(e,i,n,r){const o=r||window,s=o.requestAnimationFrame(e=>{a(),i(e)}),{unsubscribe:a}=t.s(e.signal,"abort",()=>{a(),o.cancelAnimationFrame(s),n(new t.a(e.signal.reason))},!1)},frameAsync(e,t){return new Promise((i,n)=>{this.frame(e,i,n,t)})},getImageData(e,t=0){return this.getImageCanvasContext(e).getImageData(-t,-t,e.width+2*t,e.height+2*t)},getImageCanvasContext(e){const t=window.document.createElement("canvas"),i=t.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0,e.width,e.height),i},resolveURL:e=>(r||(r=document.createElement("a")),r.href=e,r.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return void 0!==s?s:!!matchMedia&&(null!=o||(o=matchMedia("(prefers-reduced-motion: reduce)")),o.matches)},set prefersReducedMotion(e){s=e}},l=new class{constructor(){this._frozenAt=null}getCurrentTime(){return null!==this._frozenAt?this._frozenAt:performance.now()}setNow(e){this._frozenAt=e}restoreNow(){this._frozenAt=null}isFrozen(){return null!==this._frozenAt}};function c(){return l.getCurrentTime()}var u,h;class d{static create(e,t,i){const n=window.document.createElement(e);return void 0!==t&&(n.className=t),i&&i.appendChild(n),n}static createNS(e,t){return window.document.createElementNS(e,t)}static disableDrag(){d.docStyle&&d.selectProp&&(d.userSelect=d.docStyle[d.selectProp],d.docStyle[d.selectProp]="none")}static enableDrag(){d.docStyle&&d.selectProp&&(d.docStyle[d.selectProp]=d.userSelect)}static suppressClickInternal(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",d.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",d.suppressClickInternal,!0),window.setTimeout(()=>{window.removeEventListener("click",d.suppressClickInternal,!0)},0)}static getScale(e){const t=e.getBoundingClientRect();return{x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}static getPoint(e,i,n){const r=i.boundingClientRect;return new t.P((n.clientX-r.left)/i.x-e.clientLeft,(n.clientY-r.top)/i.y-e.clientTop)}static mousePos(e,t){const i=d.getScale(e);return d.getPoint(e,i,t)}static touchPos(e,t){const i=[],n=d.getScale(e);for(const r of t)i.push(d.getPoint(e,n,r));return i}static sanitize(e){const t=(new DOMParser).parseFromString(e,"text/html").body||document.createElement("body"),i=t.querySelectorAll("script");for(const e of i)e.remove();return d.clean(t),t.innerHTML}static isPossiblyDangerous(e,t){const i=t.replace(/\s+/g,"").toLowerCase();return!(!["src","href","xlink:href"].includes(e)||!i.includes("javascript:")&&!i.includes("data:"))||!!e.startsWith("on")||void 0}static clean(e){const t=e.children;for(const e of t)d.removeAttributes(e),d.clean(e)}static removeAttributes(e){for(const{name:t,value:i}of e.attributes)d.isPossiblyDangerous(t,i)&&e.removeAttribute(t)}}d.docStyle="undefined"!=typeof window&&(null===(u=window.document)||void 0===u?void 0:u.documentElement.style),d.selectProp=!d.docStyle||"userSelect"in d.docStyle?"userSelect":"webkitUserSelect",function(e){let i,n,r,o;e.resetRequestQueue=()=>{i=[],n=0,r=0,o={}},e.addThrottleControl=e=>{const t=r++;return o[t]=e,t},e.removeThrottleControl=e=>{delete o[e],a()},e.getImage=(e,n,r=!0)=>new Promise((o,s)=>{e.headers||(e.headers={}),e.headers.accept="image/webp,*/*",t.e(e,{type:"image"}),i.push({abortController:n,requestParameters:e,supportImageRefresh:r,state:"queued",onError:e=>{s(e)},onSuccess:e=>{o(e)}}),a()});const s=e=>t._(this,void 0,void 0,function*(){e.state="running";const{requestParameters:i,supportImageRefresh:r,onError:o,onSuccess:s,abortController:c}=e,u=!1===r&&!t.i(self)&&!t.g(i.url)&&(!i.headers||Object.keys(i.headers).reduce((e,t)=>e&&"accept"===t,!0));n++;const h=u?l(i,c):t.m(i,c);try{const i=yield h;delete e.abortController,e.state="completed",i.data instanceof HTMLImageElement||t.b(i.data)?s(i):i.data&&s({data:yield(d=i.data,"function"==typeof createImageBitmap?t.h(d):t.j(d)),cacheControl:i.cacheControl,expires:i.expires})}catch(i){delete e.abortController,o(t.d(i))}finally{n--,a()}var d}),a=()=>{const e=(()=>{for(const e of Object.keys(o))if(o[e]())return!0;return!1})()?t.c.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:t.c.MAX_PARALLEL_IMAGE_REQUESTS;for(let t=n;t<e&&i.length>0;t++){const e=i.shift();e.abortController.signal.aborted?t--:s(e)}},l=(e,i)=>new Promise((n,r)=>{const o=new Image,s=e.url,a=e.credentials;a&&"include"===a?o.crossOrigin="use-credentials":(a&&"same-origin"===a||!t.f(s))&&(o.crossOrigin="anonymous"),i.signal.addEventListener("abort",()=>{o.src="",r(new t.a(i.signal.reason))}),o.fetchPriority="high",o.onload=()=>{o.onerror=o.onload=null,n({data:o})},o.onerror=()=>{o.onerror=o.onload=null,i.signal.aborted||r(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."))},o.src=s})}(h||(h={})),h.resetRequestQueue();class p{constructor(e){this._transformRequestFn=null!=e?e:null}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function f(e){const t=[];if("string"==typeof e)t.push({id:"default",url:e});else if(e&&e.length>0){const i=[];for(const{id:n,url:r}of e){const e=`${n}${r}`;i.includes(e)||(i.push(e),t.push({id:n,url:r}))}}return t}function m(e,t,i){try{const n=new URL(e);return n.pathname+=`${t}${i}`,n.toString()}catch(t){throw new Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function g(e){const{userImage:t}=e;return!(!(null==t?void 0:t.render)||!t.render()||(e.data.replace(new Uint8Array(t.data.buffer)),0))}class y extends t.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0}destroy(){this.atlasTexture&&(this.atlasTexture.destroy(),this.atlasTexture=null);for(const e of Object.keys(this.images))this.removeImage(e);this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,promiseResolve:t}of this.requestors)t(this._getImagesForIds(e));this.requestors=[]}}getImage(e){const i=this.images[e];if(i&&!i.data&&i.spriteData){const e=i.spriteData;i.data=new t.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),i.spriteData=null}return i}addImage(e,t){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,t)&&(this.images[e]=t)}_validate(e,i){let n=!0;const r=i.data||i.spriteData;return this._validateStretch(i.stretchX,null==r?void 0:r.width)||(this.fire(new t.l(new Error(`Image "${e}" has invalid "stretchX" value`))),n=!1),this._validateStretch(i.stretchY,null==r?void 0:r.height)||(this.fire(new t.l(new Error(`Image "${e}" has invalid "stretchY" value`))),n=!1),this._validateContent(i.content,i)||(this.fire(new t.l(new Error(`Image "${e}" has invalid "content" value`))),n=!1),n}_validateStretch(e,t){if(!e)return!0;let i=0;for(const n of e){if(n[0]<i||n[1]<n[0]||t<n[1])return!1;i=n[1]}return!0}_validateContent(e,t){if(!e)return!0;if(4!==e.length)return!1;const i=t.spriteData,n=(null==i?void 0:i.width)||t.data.width,r=(null==i?void 0:i.height)||t.data.height;return!(e[0]<0||n<e[0]||e[1]<0||r<e[1]||e[2]<0||n<e[2]||e[3]<0||r<e[3]||e[2]<e[0]||!(e[3]>=e[1]))}updateImage(e,t,i=!0){const n=this.getImage(e);if(i&&(n.data.width!==t.data.width||n.data.height!==t.data.height))throw new Error(`size mismatch between old image (${n.data.width}x${n.data.height}) and new image (${t.data.width}x${t.data.height}).`);t.version=n.version+1,this.images[e]=t,this.updatedImages[e]=!0}removeImage(e){var t;const i=this.images[e];delete this.images[e],delete this.patterns[e],(null===(t=i.userImage)||void 0===t?void 0:t.onRemove)&&i.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(e){return new Promise((t,i)=>{let n=!0;if(!this.isLoaded())for(const t of e)this.images[t]||(n=!1);this.isLoaded()||n?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t})})}_getImagesForIds(e){var i;const n={};for(const r of e){let e=this.getImage(r);e||(this.fire(new t.n("styleimagemissing",{id:r})),e=this.getImage(r)),e?n[r]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:Boolean(null===(i=e.userImage)||void 0===i?void 0:i.render)}:t.w(`Image "${r}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return n}getPixelSize(){const{width:e,height:t}=this.atlasImage;return{width:e,height:t}}getPattern(e){const i=this.patterns[e],n=this.getImage(e);if(!n)return null;if(i&&i.position.version===n.version)return i.position;if(i)i.position.version=n.version;else{const i={w:n.data.width+2,h:n.data.height+2,x:0,y:0},r=new t.I(i,n);this.patterns[e]={bin:i,position:r}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const i=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new t.T(e,this.atlasImage,i.RGBA),this.atlasTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const t in this.patterns)e.push(this.patterns[t].bin);const{w:i,h:n}=t.p(e),r=this.atlasImage;r.resize({width:i||1,height:n||1});for(const e in this.patterns){const{bin:i}=this.patterns[e],n=i.x+1,o=i.y+1,s=this.getImage(e).data,a=s.width,l=s.height;t.R.copy(s,r,{x:0,y:0},{x:n,y:o},{width:a,height:l}),t.R.copy(s,r,{x:0,y:l-1},{x:n,y:o-1},{width:a,height:1}),t.R.copy(s,r,{x:0,y:0},{x:n,y:o+l},{width:a,height:1}),t.R.copy(s,r,{x:a-1,y:0},{x:n-1,y:o},{width:1,height:l}),t.R.copy(s,r,{x:0,y:0},{x:n+a,y:o},{width:1,height:l})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const i of e){if(this.callbackDispatchedThisFrame[i])continue;this.callbackDispatchedThisFrame[i]=!0;const e=this.getImage(i);e||t.w(`Image with ID: "${i}" was not found`),g(e)&&this.updateImage(i,e)}}cloneImages(){const e={};for(const t in this.images){const i=this.images[t];e[t]=Object.assign(Object.assign({},i),{data:i.data?i.data.clone():null})}return e}}const _=1e20,v=new Float64Array(256);for(let e=0;e<256;e++){const t=.5-Math.pow(e/255,1/2.2);v[e]=t*Math.abs(t)}function x(e,t,i,n,r,o,s,a,l){for(let c=t;c<t+n;c++)b(e,i*o+c,o,r,s,a,l);for(let c=i;c<i+r;c++)b(e,c*o+t,1,n,s,a,l)}function b(e,t,i,n,r,o,s){o[0]=0,s[0]=-_,s[1]=_,r[0]=e[t];for(let a=1,l=0,c=0;a<n;a++){r[a]=e[t+a*i];const n=a*a;do{const e=o[l];c=(r[a]-r[e]+n-e*e)/(a-e)/2}while(c<=s[l]&&--l>-1);l++,o[l]=a,s[l]=c,s[l+1]=_}for(let a=0,l=0;a<n;a++){for(;s[l+1]<a;)l++;const n=o[l],c=a-n;e[t+a*i]=r[n]+c*c}}v[255]=-_;const w=t.v.layout_symbol["text-font"].default.join(",");class E{constructor(e,t,i){this.requestManager=e,this.localIdeographFontFamily=t,this.entries={},this.lang=i}setURL(e){this.url=e}getGlyphs(e){return t._(this,void 0,void 0,function*(){const t=[];for(const i in e)for(const n of e[i])t.push(this._getAndCacheGlyphsPromise(i,n));const i=yield Promise.all(t),n={};for(const{stack:e,id:t,glyph:r}of i)n[e]||(n[e]={}),n[e][t]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics};return n})}_getAndCacheGlyphsPromise(e,i){return t._(this,void 0,void 0,function*(){var t,n;null!==(t=(n=this.entries)[e])&&void 0!==t||(n[e]={glyphs:{},requests:{},ranges:{}});const r=this.entries[e];let o=r.glyphs[i];return void 0!==o?{stack:e,id:i,glyph:o}:!this.url||this._charUsesLocalIdeographFontFamily(i)?(o=r.glyphs[i]=this._drawGlyph(r,e,i),{stack:e,id:i,glyph:o}):yield this._downloadAndCacheRangePromise(e,i)})}_downloadAndCacheRangePromise(e,i){return t._(this,void 0,void 0,function*(){var n;const r=this.entries[e],o=Math.floor(i/256);if(r.ranges[o])return{stack:e,id:i,glyph:null};(n=r.requests)[o]||(n[o]=E.loadGlyphRange(e,o,this.url,this.requestManager));try{const t=yield r.requests[o];for(const e in t)r.glyphs[+e]=t[+e];return r.ranges[o]=!0,{stack:e,id:i,glyph:t[i]||null}}catch(n){const s=r.glyphs[i]=this._drawGlyph(r,e,i);return this._warnOnMissingGlyphRange(s,o,i,t.d(n)),{stack:e,id:i,glyph:s}}})}_warnOnMissingGlyphRange(e,i,n,r){const o=256*i,s=o+255,a=n.toString(16).padStart(4,"0").toUpperCase();t.w(`Unable to load glyph range ${i}, ${o}-${s}. Rendering codepoint U+${a} locally instead. ${r}`)}_charUsesLocalIdeographFontFamily(e){return!!this.localIdeographFontFamily&&t.r(e)}_drawGlyph(e,i,n){const r=i===w&&""!==this.localIdeographFontFamily&&this._charUsesLocalIdeographFontFamily(n),o=r?"ideographTinySDF":"tinySDF";e[o]||(e[o]=this._createTinySDF(r?this.localIdeographFontFamily:i));const s=e[o].draw(String.fromCodePoint(n)),a=/^\p{gc=Cf}+$/u.test(String.fromCodePoint(n));return{id:n,bitmap:new t.t({width:s.width||60,height:s.height||60},s.data),metrics:{width:a?0:s.glyphWidth/2||24,height:s.glyphHeight/2||24,left:s.glyphLeft/2+.5||0,top:s.glyphTop/2-27.5||-8,advance:a?0:s.glyphAdvance/2||24,isDoubleResolution:!0}}}_createTinySDF(e){const t=e?e.split(","):[];t.push("sans-serif");const i=t.map(e=>/[-\w]+/.test(e)?e:`'${CSS.escape(e)}'`).join(",");return new E.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:i,fontWeight:this._fontWeight(t[0]),fontStyle:this._fontStyle(t[0]),lang:this.lang})}_fontStyle(e){return/italic/i.test(e)?"italic":/oblique/i.test(e)?"oblique":"normal"}_fontWeight(e){const t={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};let i;for(const[n,r]of Object.entries(t))new RegExp(`\\b${n}\\b`,"i").test(e)&&(i=`${r}`);return i}destroy(){for(const e in this.entries){const t=this.entries[e];t.tinySDF=null,t.ideographTinySDF=null,t.glyphs={},t.requests={},t.ranges={}}this.entries={}}}E.loadGlyphRange=function(e,i,n,r){return t._(this,void 0,void 0,function*(){const o=256*i,s=o+255,a=yield r.transformRequest(n.replace("{fontstack}",e).replace("{range}",`${o}-${s}`),"Glyphs"),l=yield t.o(a,new AbortController);if(!(null==l?void 0:l.data))throw new Error(`Could not load glyph range. range: ${i}, ${o}-${s}`);const c={};for(const e of t.q(l.data))c[e.id]=e;return c})},E.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal",lang:a=null}={}){this.buffer=t,this.radius=i,this.cutoff=n,this.lang=a;const l=this.size=e+4*t,c=this._createCanvas(l),u=this.ctx=c.getContext("2d",{willReadFrequently:!0});u.font=`${s} ${o} ${e}px ${r}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l)}_createCanvas(e){if("undefined"!=typeof OffscreenCanvas)return new OffscreenCanvas(e,e);const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(e),s=Math.ceil(i),a=Math.floor(r),l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o)-a)),c=Math.max(0,Math.min(this.size-this.buffer,s+Math.ceil(n))),u=l+2*this.buffer,h=c+2*this.buffer,d=Math.max(u*h,0),p=new Uint8ClampedArray(d),f={data:p,width:u,height:h,glyphWidth:l,glyphHeight:c,glyphTop:s,glyphLeft:a,glyphAdvance:t};if(0===l||0===c)return f;const{ctx:m,buffer:g,gridInner:y,gridOuter:b}=this;this.lang&&(m.lang=this.lang),m.clearRect(g,g,l,c),m.fillText(e,g-a,g+s);const w=m.getImageData(g,g,l,c);b.fill(_,0,d),y.fill(0,0,d);let E=3;for(let e=0;e<c;e++){let t=(e+g)*u+g;for(let e=0;e<l;e++,E+=4,t++){const e=w.data[E];if(0===e)continue;const i=v[e];b[t]=Math.max(0,i),y[t]=Math.max(0,-i)}}x(b,0,0,u,h,u,this.f,this.v,this.z),x(y,g,g,l,c,u,this.f,this.v,this.z);const T=255/this.radius,S=255*(1-this.cutoff);for(let e=0;e<d;e++){const t=Math.sqrt(b[e])-Math.sqrt(y[e]);p[e]=Math.round(S-T*t)}return f}};class T{constructor(){this.specification=t.x.light.position}possiblyEvaluate(e,i){return t.G(e.expression.evaluate(i))}interpolate(e,i,n){return{x:t.H.number(e.x,i.x,n),y:t.H.number(e.y,i.y,n),z:t.H.number(e.z,i.z,n)}}}let S;class I extends t.E{constructor(e){super(),S||(S=new t.u({anchor:new t.D(t.x.light.anchor),position:new T,color:new t.D(t.x.light.color),intensity:new t.D(t.x.light.intensity)})),this._transitionable=new t.y(S,void 0),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,i={}){if(!this._validate(t.z,e,i))for(const i in e){const n=e[i];i.endsWith(t.B)?this._transitionable.setTransition(i.slice(0,-t.B.length),n):this._transitionable.setValue(i,n)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,i,n){return!1!==(null==n?void 0:n.validate)&&t.C(this,e.call(t.F,{value:i,style:{glyphs:!0,sprite:!0},styleSpec:t.x}))}}const k=new t.u({"sky-color":new t.D(t.x.sky["sky-color"]),"horizon-color":new t.D(t.x.sky["horizon-color"]),"fog-color":new t.D(t.x.sky["fog-color"]),"fog-ground-blend":new t.D(t.x.sky["fog-ground-blend"]),"horizon-fog-blend":new t.D(t.x.sky["horizon-fog-blend"]),"sky-horizon-blend":new t.D(t.x.sky["sky-horizon-blend"]),"atmosphere-blend":new t.D(t.x.sky["atmosphere-blend"])});class M extends t.E{constructor(e){super(),this._transitionable=new t.y(k,void 0),this.setSky(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new t.J(0))}setSky(e,i={}){if(!this._validate(t.K,e,i)){e||(e={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0});for(const i in e){const n=e[i];i.endsWith(t.B)?this._transitionable.setTransition(i.slice(0,-t.B.length),n):this._transitionable.setValue(i,n)}}}getSky(){return this._transitionable.serialize()}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,i,n={}){return!1!==(null==n?void 0:n.validate)&&t.C(this,e.call(t.F,t.e({value:i,style:{glyphs:!0,sprite:!0},styleSpec:t.x})))}calculateFogBlendOpacity(e){return e<60?0:e<70?(e-60)/10:1}}class C{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(e,t){var i;const n=e.join(",")+String(t);return(i=this.dashEntry)[n]||(i[n]=this.addDash(e,t)),this.dashEntry[n]}getDashRanges(e,t,i){const n=[];let r=e.length%2==1?-e[e.length-1]*i:0,o=e[0]*i,s=!0;n.push({left:r,right:o,isDash:s,zeroLength:0===e[0]});let a=e[0];for(let t=1;t<e.length;t++){s=!s;const l=e[t];r=a*i,a+=l,o=a*i,n.push({left:r,right:o,isDash:s,zeroLength:0===l})}return n}addRoundDash(e,t,i){const n=t/2;for(let t=-i;t<=i;t++){const r=this.width*(this.nextRow+i+t);let o=0,s=e[o];for(let a=0;a<this.width;a++){a/s.right>1&&(s=e[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),u=Math.min(l,c);let h;const d=t/i*(n+1);if(s.isDash){const e=n-Math.abs(d);h=Math.sqrt(u*u+e*e)}else h=n-Math.sqrt(u*u+d*d);this.data[r+a]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(e){for(let t=e.length-1;t>=0;--t){const i=e[t],n=e[t+1];i.zeroLength?e.splice(t,1):n&&n.isDash===i.isDash&&(n.left=i.left,e.splice(t,1))}const t=e[0],i=e[e.length-1];t.isDash===i.isDash&&(t.left=i.left-this.width,i.right=t.right+this.width);const n=this.width*this.nextRow;let r=0,o=e[r];for(let t=0;t<this.width;t++){t/o.right>1&&(o=e[++r]);const i=Math.abs(t-o.left),s=Math.abs(t-o.right),a=Math.min(i,s);this.data[n+t]=Math.max(0,Math.min(255,(o.isDash?a:-a)+128))}}addDash(e,i){const n=i?7:0,r=2*n+1;if(this.nextRow+r>this.height)return t.w("LineAtlas out of space"),null;let o=0;for(const t of e)o+=t;if(0!==o){const t=this.width/o,r=this.getDashRanges(e,this.width,t);i?this.addRoundDash(r,t,n):this.addRegularDash(r)}const s={y:this.nextRow+n,height:2*n,width:o};return this.nextRow+=r,this.dirty=!0,s}bind(e){const t=e.gl;this.texture?(t.bindTexture(t.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,t.texSubImage2D(t.TEXTURE_2D,0,0,0,this.width,this.height,t.ALPHA,t.UNSIGNED_BYTE,this.data))):(this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texImage2D(t.TEXTURE_2D,0,t.ALPHA,this.width,this.height,0,t.ALPHA,t.UNSIGNED_BYTE,this.data))}}const P="_ml_preloaded_worker_pool";class A{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length<A.workerCount;)this.workers.push(new Worker(t.c.WORKER_URL));return this.active[e]=!0,this.workers.slice()}release(e){if(delete this.active[e],0===this.numActive()){for(const e of this.workers)e.terminate();this.workers=null}}isPreloaded(){return!!this.active[P]}numActive(){return Object.keys(this.active).length}}const L=Math.floor(a.hardwareConcurrency/2);let D,R;function z(){return D||(D=new A),D}A.workerCount=t.L(globalThis)?Math.max(Math.min(L,3),1):1;class F{constructor(e,i){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=i;const n=this.workerPool.acquire(i);for(let e=0;e<n.length;e++){const r=new t.N(n[e],i);r.name=`Worker ${e}`,this.actors.push(r)}if(!this.actors.length)throw new Error("No actors found")}broadcast(e,t){const i=[];for(const n of this.actors)i.push(n.sendAsync({type:e,data:t}));return Promise.all(i)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(e=!0){for(const e of this.actors)e.remove();this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,t){for(const i of this.actors)i.registerMessageHandler(e,t)}unregisterMessageHandler(e){for(const t of this.actors)t.unregisterMessageHandler(e)}}function O(){return R||(R=new F(z(),t.M),R.registerMessageHandler("GR",(e,i,n)=>t.m(i,n))),R}function N(e,i){const n=t.O();return t.Q(n,n,[1,1,0]),t.S(n,n,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?t.U(n,n,e.calculatePosMatrix(i.toUnwrapped())):n}function B(e,t,i,n,r,o,s){var a;const l=function(e,t,i){if(e)for(const n of e){const e=t[n];if((null==e?void 0:e.source)===i&&"fill-extrusion"===e.type)return!0}else for(const e in t){const n=t[e];if(n.source===i&&"fill-extrusion"===n.type)return!0}return!1}(null!==(a=null==r?void 0:r.layers)&&void 0!==a?a:null,t,e.id),c=o.maxPitchScaleFactor(),u=e.tilesIn(n,c,l);u.sort(G);const h=[];for(const n of u)h.push({wrappedTileID:n.tileID.wrapped().key,queryResults:n.tile.queryRenderedFeatures(t,i,e.getState(),n.queryGeometry,n.cameraQueryGeometry,n.scale,r,o,c,N(o,n.tileID),s?(e,t)=>s(n.tileID,e,t):void 0)});return function(e,t){for(const i in e)for(const n of e[i])j(n,t);return e}(function(e){const t={},i={};for(const{queryResults:n,wrappedTileID:r}of e){i[r]||(i[r]={});const e=i[r];for(const i in n){const r=n[i];e[i]||(e[i]={});const o=e[i];t[i]||(t[i]=[]);for(const e of r)o[e.featureIndex]||(o[e.featureIndex]=!0,t[i].push(e))}}return t}(h),e)}function G(e,t){const i=e.tileID,n=t.tileID;return i.overscaledZ-n.overscaledZ||i.canonical.y-n.canonical.y||i.wrap-n.wrap||i.canonical.x-n.canonical.x}function j(e,t){const i=e.feature,n=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=n}function V(e,i,n,r){return t._(this,void 0,void 0,function*(){let o=e;if(e.url?o=(yield t.k(yield i.transformRequest(e.url,"Source"),n)).data:yield a.frameAsync(n,r),!o)return null;const s=t.V(t.e(o,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in o&&o.vector_layers&&(s.vectorLayerIds=o.vector_layers.map(e=>e.id)),s})}class U{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):Array.isArray(e)&&(4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1])))}setNorthEast(e){return this._ne=e instanceof t.W?new t.W(e.lng,e.lat):t.W.convert(e),this}setSouthWest(e){return this._sw=e instanceof t.W?new t.W(e.lng,e.lat):t.W.convert(e),this}extend(e){const i=this._sw,n=this._ne;let r,o;if(e instanceof t.W)r=e,o=e;else{if(!(e instanceof U))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(U.convert(e)):this.extend(t.W.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(t.W.convert(e)):this;if(r=e._sw,o=e._ne,!r||!o)return this}return i||n?(i.lng=Math.min(r.lng,i.lng),i.lat=Math.min(r.lat,i.lat),n.lng=Math.max(o.lng,n.lng),n.lat=Math.max(o.lat,n.lat)):(this._sw=new t.W(r.lng,r.lat),this._ne=new t.W(o.lng,o.lat)),this}getCenter(){return new t.W((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 t.W(this.getWest(),this.getNorth())}getSouthEast(){return new t.W(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){const{lng:i,lat:n}=t.W.convert(e);let r=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&r}intersects(e){if(!((e=U.convert(e)).getNorth()>=this.getSouth()&&e.getSouth()<=this.getNorth()))return!1;const i=Math.abs(this.getEast()-this.getWest()),n=Math.abs(e.getEast()-e.getWest());if(i>=360||n>=360)return!0;const r=t.X(this.getWest(),-180,180),o=t.X(this.getEast(),-180,180),s=t.X(e.getWest(),-180,180),a=t.X(e.getEast(),-180,180),l=r>o,c=s>a;return!(!l||!c)||(l?a>=r||s<=o:c?o>=s||r<=a:s<=o&&a>=r)}static convert(e){return e instanceof U?e:e?new U(e):e}static fromLngLat(e,i=0){const n=360*i/40075017,r=n/Math.cos(Math.PI/180*e.lat);return new U(new t.W(e.lng-r,e.lat-n),new t.W(e.lng+r,e.lat+n))}adjustAntiMeridian(){const e=new t.W(this._sw.lng,this._sw.lat),i=new t.W(this._ne.lng,this._ne.lat);return new U(e,e.lng>i.lng?new t.W(i.lng+360,i.lat):i)}}class q{constructor(e,t,i){this.bounds=U.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=i||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const i=Math.pow(2,e.z),n=Math.floor(t.Z(this.bounds.getWest())*i),r=Math.floor(t.Y(this.bounds.getNorth())*i),o=Math.ceil(t.Z(this.bounds.getEast())*i),s=Math.ceil(t.Y(this.bounds.getSouth())*i);return e.x>=n&&e.x<o&&e.y>=r&&e.y<s}}class Z extends t.E{constructor(e,i,n,r){if(super(),this.id=e,this.dispatcher=n,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,t.e(this,t.V(i,["url","scheme","tileSize","promoteId","encoding"])),this._options=t.e({type:"vector"},i),this._collectResourceTiming=i.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r)}load(){return t._(this,arguments,void 0,function*(e=!1){this._loaded=!1,this.fire(new t.n("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const i=yield V(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,i&&(t.e(this,i),i.bounds&&(this.tileBounds=new q(i.bounds,this.minzoom,this.maxzoom)),this.fire(new t.n("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.n("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,t.$(e)||this.fire(new t.l(t.d(e)))}})}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}setSourceProperty(e){this._tileJSONRequest&&this._tileJSONRequest.abort(),e(),this.load(!0)}setTiles(e){return this.setSourceProperty(()=>{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return t.e({},this._options)}loadTile(e){return t._(this,void 0,void 0,function*(){const t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:yield this.map._requestManager.transformRequest(t,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.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:yield this._getOverzoomParameters(e),etag:e.etag};i.request.collectResourceTiming=this._collectResourceTiming;let n="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise((t,i)=>{e.reloadPromise={resolve:t,reject:i}})}else e.actor=this.dispatcher.getActor(),n="LT";e.abortController=new AbortController;try{const t=yield e.actor.sendAsync({type:n,data:i},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,t);const r={};return(null==t?void 0:t.etagUnmodified)&&(r.unmodified=!0),r}catch(t){if(delete e.abortController,e.aborted)return;if(t&&404!==t.status)throw t;this._afterTileLoadWorkerResponse(e,null)}})}_getOverzoomParameters(e){return t._(this,void 0,void 0,function*(){if(e.tileID.canonical.z<=this.maxzoom)return;if(void 0===this.map._zoomLevelsToOverscale)return;const t=e.tileID.scaledTo(this.maxzoom).canonical,i=t.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:t,overzoomRequest:yield this.map._requestManager.transformRequest(i,"Tile")}})}_afterTileLoadWorkerResponse(e,t){if((null==t?void 0:t.resourceTiming)&&(e.resourceTiming=t.resourceTiming),t&&this.map._refreshExpiredTiles&&e.setExpiryData(t),e.etag=null==t?void 0:t.etag,e.loadVectorData(t,this.map.painter),e.reloadPromise){const t=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(t.resolve).catch(t.reject)}}abortTile(e){return t._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}}))})}unloadTile(e){return t._(this,void 0,void 0,function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}}))})}hasTransition(){return!1}}class $ extends t.E{constructor(e,i,n,r){super(),this.id=e,this.dispatcher=n,this.setEventedParent(r),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=t.e({type:"raster"},i),t.e(this,t.V(i,["url","scheme","tileSize"]))}load(){return t._(this,arguments,void 0,function*(e=!1){this._loaded=!1,this.fire(new t.n("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const i=yield V(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,i&&(t.e(this,i),i.bounds&&(this.tileBounds=new q(i.bounds,this.minzoom,this.maxzoom)),this.fire(new t.n("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.n("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,t.$(e)||this.fire(new t.l(t.d(e)))}})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load(!0)}setTiles(e){return this.setSourceProperty(()=>{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}serialize(){return t.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return t._(this,void 0,void 0,function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const n=yield h.getImage(yield this.map._requestManager.transformRequest(i,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(null==n?void 0:n.data){this.map._refreshExpiredTiles&&(n.cacheControl||n.expires)&&e.setExpiryData({cacheControl:n.cacheControl,expires:n.expires});const i=this.map.painter.context,r=i.gl,o=n.data;e.texture=this.map.painter.getTileTexture(o.width),e.texture?e.texture.update(o,{useMipmap:!0}):(e.texture=new t.T(i,o,r.RGBA,{useMipmap:!0}),e.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE,r.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}})}abortTile(e){return t._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)})}unloadTile(e){return t._(this,void 0,void 0,function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)})}hasTransition(){return!1}}class H extends ${constructor(e,i,n,r){super(e,i,n,r),this.type="raster-dem",this.maxzoom=22,this._options=t.e({type:"raster-dem"},i),this.encoding=i.encoding||"_mbx",this.redFactor=i.redFactor,this.greenFactor=i.greenFactor,this.blueFactor=i.blueFactor,this.baseShift=i.baseShift}loadTile(e){return t._(this,void 0,void 0,function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),n=yield this.map._requestManager.transformRequest(i,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const i=yield h.getImage(n,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(null==i?void 0:i.data){const n=i.data;this.map._refreshExpiredTiles&&(i.cacheControl||i.expires)&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const r=t.b(n)&&t.a0()?n:yield this.readImageNow(n),o={type:this.type,uid:e.uid,source:this.id,rawImageData:r,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(e.actor&&"expired"!==e.state&&"reloading"!==e.state)return;e.actor&&"expired"!==e.state||(e.actor=this.dispatcher.getActor()),e.dem=yield e.actor.sendAsync({type:"LDT",data:o}),e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}})}readImageNow(e){return t._(this,void 0,void 0,function*(){if("undefined"!=typeof VideoFrame&&t.a1()){const i=e.width+2,n=e.height+2;try{return new t.R({width:i,height:n},yield t.a2(e,-1,-1,i,n))}catch(e){}}return a.getImageData(e,1)})}_getNeighboringTiles(e){const i=e.canonical,n=Math.pow(2,i.z),r=(i.x-1+n)%n,o=0===i.x?e.wrap-1:e.wrap,s=(i.x+1+n)%n,a=i.x+1===n?e.wrap+1:e.wrap,l={};return l[new t.a3(e.overscaledZ,o,i.z,r,i.y).key]={backfilled:!1},l[new t.a3(e.overscaledZ,a,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new t.a3(e.overscaledZ,o,i.z,r,i.y-1).key]={backfilled:!1},l[new t.a3(e.overscaledZ,e.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new t.a3(e.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1<n&&(l[new t.a3(e.overscaledZ,o,i.z,r,i.y+1).key]={backfilled:!1},l[new t.a3(e.overscaledZ,e.wrap,i.z,i.x,i.y+1).key]={backfilled:!1},l[new t.a3(e.overscaledZ,a,i.z,s,i.y+1).key]={backfilled:!1}),l}unloadTile(e){return t._(this,void 0,void 0,function*(){e.demTexture&&this.map.painter.saveTileTexture(e.demTexture),e.fbo&&(e.fbo.destroy(),delete e.fbo),e.dem&&delete e.dem,delete e.neighboringTiles,e.state="unloaded",e.actor&&(yield e.actor.sendAsync({type:"RDT",data:{type:this.type,uid:e.uid,source:this.id}}))})}}function W(e,t){return t?e.properties[t]:e.id}function X(e,t){const i={id:e.id};if(t.removeAllProperties&&(delete e.removeProperties,delete e.addOrUpdateProperties,delete t.removeProperties),t.removeProperties)for(const i of t.removeProperties){const t=e.addOrUpdateProperties.findIndex(e=>e.key===i);t>-1&&e.addOrUpdateProperties.splice(t,1)}return(e.removeAllProperties||t.removeAllProperties)&&(i.removeAllProperties=!0),(e.removeProperties||t.removeProperties)&&(i.removeProperties=[...e.removeProperties||[],...t.removeProperties||[]]),(e.addOrUpdateProperties||t.addOrUpdateProperties)&&(i.addOrUpdateProperties=[...e.addOrUpdateProperties||[],...t.addOrUpdateProperties||[]]),(e.newGeometry||t.newGeometry)&&(i.newGeometry=t.newGeometry||e.newGeometry),i}function Y(e){var t,i;if(!e)return{};const n={};return n.removeAll=e.removeAll,n.remove=new Set(e.remove||[]),n.add=new Map(null===(t=e.add)||void 0===t?void 0:t.map(e=>[e.id,e])),n.update=new Map(null===(i=e.update)||void 0===i?void 0:i.map(e=>[e.id,e])),n}function J(e){return e&&0!==e.length?"number"==typeof e[0]?[e]:e.flatMap(e=>J(e)):[]}function K(e){return"GeometryCollection"===e.type?e.geometries.flatMap(e=>K(e)):J(e.coordinates)}function Q(e){const t=new U;let i;switch(e.type){case"FeatureCollection":i=e.features.flatMap(e=>K(e.geometry));break;case"Feature":i=K(e.geometry);break;default:i=K(e)}if(0===i.length)return t;for(const e of i){const[i,n]=e;t.extend([i,n])}return t}class ee extends t.E{constructor(e,i,n,r){super(),this.id=e,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.actor=n.getActor(),this.setEventedParent(r),this._data="string"==typeof i.data?{url:i.data}:{geojson:i.data},this._options=t.e({},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&&t.w(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${i.clusterMaxZoom}".`),this.workerOptions=t.e({source:this.id,geojsonVtOptions:{buffer:this._pixelsToTileUnits(void 0!==i.buffer?i.buffer:128),tolerance:this._pixelsToTileUnits(void 0!==i.tolerance?i.tolerance:.375),extent:t.a6,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:t.a6,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(e){return e*(t.a6/this.tileSize)}_getClusterMaxZoom(e){const i=e?Math.round(e):this.maxzoom-1;return Number.isInteger(e)||void 0===e||t.w(`Integer expected for option 'clusterMaxZoom': provided value "${e}" rounded to "${i}"`),i}load(){return t._(this,void 0,void 0,function*(){yield this._updateWorkerData()})}onAdd(e){this.map=e,this.load()}setData(e,t){this._data="string"==typeof e?{url:e}:{geojson:e},this._pendingWorkerUpdate={data:e};const i=this._updateWorkerData();return t?i:this}updateData(e,t){this._pendingWorkerUpdate.diff=function(e,t){if(!e)return t||{};if(!t)return e||{};const i=Y(e),n=Y(t);!function(e,t){t.removeAll&&(e.add.clear(),e.update.clear(),e.remove.clear(),t.remove.clear());for(const i of t.remove)e.add.delete(i),e.update.delete(i);for(const[i,n]of t.update){const r=e.update.get(i);r&&(t.update.set(i,X(r,n)),e.update.delete(i))}}(i,n);const r={};if((i.removeAll||n.removeAll)&&(r.removeAll=!0),r.remove=new Set([...i.remove,...n.remove]),r.add=new Map([...i.add,...n.add]),r.update=new Map([...i.update,...n.update]),r.remove.size&&r.add.size)for(const e of r.add.keys())r.remove.delete(e);return function(e){const t={};return e.removeAll&&(t.removeAll=e.removeAll),e.remove&&(t.remove=Array.from(e.remove)),e.add&&(t.add=Array.from(e.add.values())),e.update&&(t.update=Array.from(e.update.values())),t}(r)}(this._pendingWorkerUpdate.diff,e);const i=this._updateWorkerData();return t?i:this}getData(){return t._(this,void 0,void 0,function*(){return this._data.url&&(yield this.once("data")),this._data.geojson?this._data.geojson:{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}})}getBounds(){return t._(this,void 0,void 0,function*(){return Q(yield this.getData())})}setClusterOptions(e){return this.workerOptions.geojsonVtOptions.cluster=e.cluster,void 0!==e.clusterRadius&&(this.workerOptions.geojsonVtOptions.clusterOptions.radius=this._pixelsToTileUnits(e.clusterRadius)),void 0!==e.clusterMaxZoom&&(this.workerOptions.geojsonVtOptions.clusterOptions.maxZoom=this._getClusterMaxZoom(e.clusterMaxZoom)),this._pendingWorkerUpdate.updateCluster=!0,this._updateWorkerData(),this}getClusterExpansionZoom(e){return this.actor.sendAsync({type:"GCEZ",data:{type:this.type,clusterId:e,source:this.id}})}getClusterChildren(e){return this.actor.sendAsync({type:"GCC",data:{type:this.type,clusterId:e,source:this.id}})}getClusterLeaves(e,t,i){return this.actor.sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:e,limit:t,offset:i}})}_updateWorkerData(){return t._(this,void 0,void 0,function*(){if(this._isUpdatingWorker)return;if(!this._hasPendingWorkerUpdate())return void t.w(`No pending worker updates for GeoJSONSource ${this.id}.`);const{data:e,diff:i,updateCluster:n}=this._pendingWorkerUpdate,r=this._getLoadGeoJSONParameters(e,i,n);void 0!==e?this._pendingWorkerUpdate.data=void 0:i?this._pendingWorkerUpdate.diff=void 0:n&&(this._pendingWorkerUpdate.updateCluster=void 0),yield this._dispatchWorkerUpdate(r)})}_getLoadGeoJSONParameters(e,i,n){return t._(this,void 0,void 0,function*(){const r=t.e({type:this.type},this.workerOptions);return"string"==typeof e?(r.request=yield this.map._requestManager.transformRequest(a.resolveURL(e),"Source"),r.request.collectResourceTiming=this._collectResourceTiming,r):void 0!==e?(r.data=e,r):i?(r.dataDiff=i,r):n?(r.updateCluster=!0,r):void 0})}_dispatchWorkerUpdate(e){return t._(this,void 0,void 0,function*(){this._isUpdatingWorker=!0,this.fire(new t.n("dataloading",{dataType:"source"}));try{const i=yield e,n=yield this.actor.sendAsync({type:"LD",data:i});if(this._isUpdatingWorker=!1,this._removed||n.abandoned)return void this.fire(new t.n("dataabort",{dataType:"source"}));n.data&&(this._data={geojson:n.data});const r=this._applyDiffToSource(i.dataDiff),o=this._getShouldReloadTileOptions(r),s={dataType:"source"};this._applyResourceTiming(s,n),this.fire(new t.n("data",Object.assign(Object.assign({},s),{sourceDataType:"metadata"}))),this.fire(new t.n("data",Object.assign(Object.assign({},s),{sourceDataType:"content",shouldReloadTileOptions:o})))}catch(e){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new t.n("dataabort",{dataType:"source"}));this.fire(new t.l(t.d(e)))}finally{this._hasPendingWorkerUpdate()&&this._updateWorkerData()}})}_applyResourceTiming(e,i){var n;if(!this._collectResourceTiming)return;const r=null===(n=i.resourceTiming)||void 0===n?void 0:n[this.id];if(!r)return;const o=r.slice(0);(null==o?void 0:o.length)&&t.e(e,{resourceTiming:o})}_applyDiffToSource(e){if(!e)return;const t="string"==typeof this.promoteId?this.promoteId:void 0;if(!this._data.url&&!this._data.updateable){const e=function(e,t){const i=new Map;if(null==e)return i;if(null==e.type)return i;if("Feature"===e.type){const n=W(e,t);if(null==n)return;return i.set(n,e),i}if("FeatureCollection"===e.type){const n=new Set;for(const r of e.features){const e=W(r,t);if(null==e)return;if(n.has(e))return;n.add(e),i.set(e,r)}return i}}(this._data.geojson,t);if(!e)throw new Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:e}}if(!this._data.updateable)return;const i=function(e,t,i){var n,r;const o=[];if(t.removeAll)e.clear();else if(t.remove)for(const i of t.remove){const t=e.get(i);t&&(o.push(t.geometry),e.delete(i))}if(t.add)for(const n of t.add){const t=W(n,i);if(null==t)continue;const r=e.get(t);r&&o.push(r.geometry),o.push(n.geometry),e.set(t,n)}if(t.update)for(const i of t.update){const t=e.get(i.id);if(!t)continue;const s=!!i.newGeometry,a=i.removeAllProperties||(null===(n=i.removeProperties)||void 0===n?void 0:n.length)>0||(null===(r=i.addOrUpdateProperties)||void 0===r?void 0:r.length)>0;if(!s&&!a)continue;o.push(t.geometry);const l=Object.assign({},t);if(e.set(i.id,l),s&&(o.push(i.newGeometry),l.geometry=i.newGeometry),a){if(l.properties=i.removeAllProperties?{}:Object.assign({},l.properties||{}),i.removeProperties)for(const e of i.removeProperties)delete l.properties[e];if(i.addOrUpdateProperties)for(const{key:e,value:t}of i.addOrUpdateProperties)l.properties[e]=t}}return o}(this._data.updateable,e,t);return e.removeAll||this._options.cluster?void 0:i}_getShouldReloadTileOptions(e){if(e)return{affectedBounds:e.filter(Boolean).map(e=>Q(e))}}shouldReloadTile(e,{affectedBounds:i}){if("loading"===e.state)return!0;if("unloaded"===e.state)return!1;const{buffer:n,extent:r}=this.workerOptions.geojsonVtOptions,o=function({x:e,y:i,z:n},r=0){const o=t.a4((e-r)/Math.pow(2,n)),s=t.a5((i+1+r)/Math.pow(2,n)),a=t.a4((e+1+r)/Math.pow(2,n)),l=t.a5((i-r)/Math.pow(2,n));return new U([o,s],[a,l])}(e.tileID.canonical,n/r);for(const e of i)if(o.intersects(e))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}loadTile(e){return t._(this,void 0,void 0,function*(){const t=e.actor?"RT":"LT";e.actor=this.actor;const i={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.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};e.abortController=new AbortController;const n=yield this.actor.sendAsync({type:t,data:i},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(n,this.map.painter,"RT"===t)})}abortTile(e){return t._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0})}unloadTile(e){return t._(this,void 0,void 0,function*(){e.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}})})}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}})}serialize(){return t.e({},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}}class te extends t.E{constructor(e,t,i,n){super(),this.flippedWindingOrder=!1,this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(n),this.options=t}load(e){return t._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new t.n("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const t=yield h.getImage(yield this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,(null==t?void 0:t.data)&&(this.image=t.data,e&&(this.coordinates=e),this._finishLoading())}catch(e){this._request=null,this._loaded=!0,t.$(e)||this.fire(new t.l(t.d(e)))}})}loaded(){return this._loaded}updateImage(e){return e.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=e.url,this.load(e.coordinates).finally(()=>this.texture=null),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.n("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(e){this.coordinates=e;const i=e.map(t.a7.fromLngLat);var n;return this.tileID=function(e){const i=t.a8.fromPoints(e),n=i.width(),r=i.height(),o=Math.max(n,r),s=Math.max(0,Math.floor(-Math.log(o)/Math.LN2)),a=Math.pow(2,s);return new t.aa(s,Math.floor((i.minX+i.maxX)/2*a),Math.floor((i.minY+i.maxY)/2*a))}(i),this.terrainTileRanges=this._getOverlappingTileRanges(i),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=i.map(e=>this.tileID.getTilePoint(e)._round()),this.flippedWindingOrder=((n=this.tileCoords)[1].x-n[0].x)*(n[2].y-n[0].y)-(n[1].y-n[0].y)*(n[2].x-n[0].x)<0,this.fire(new t.n("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,i=e.gl;this.texture||(this.texture=new t.T(e,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let n=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,n=!0)}n&&this.fire(new t.n("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return t._(this,void 0,void 0,function*(){var t;(null===(t=this.tileID)||void 0===t?void 0:t.equals(e.tileID.canonical))?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"})}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(e){const{minX:i,minY:n,maxX:r,maxY:o}=t.a8.fromPoints(e),s={};for(let e=0;e<=t.a9;e++){const t=Math.pow(2,e),a=Math.floor(i*t),l=Math.floor(n*t),c=Math.floor(r*t),u=Math.floor(o*t),h=(a%t+t)%t,d=c%t,p=Math.floor(a/t),f=Math.floor(c/t);s[e]={minWrap:p,maxWrap:f,minTileXWrapped:h,maxTileXWrapped:d,minTileY:l,maxTileY:u}}return s}}class ie extends te{constructor(e,t,i,n){super(e,t,i,n),this._onPlayingHandler=()=>{var e;null===(e=this.map)||void 0===e||e.triggerRepaint()},this.roundZoom=!0,this.type="video",this.options=t}load(){return t._(this,void 0,void 0,function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const t of e.urls)this.urls.push((yield this.map._requestManager.transformRequest(t,"Source")).url);try{const e=yield t.ab(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener("playing",this._onPlayingHandler),this.map&&this.video.play(),this._finishLoading()}catch(e){this.fire(new t.l(t.d(e)))}})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const i=this.video.seekable;e<i.start(0)||e>i.end(0)?this.fire(new t.l(new t.ac(`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=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,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;const e=this.map.painter.context,i=e.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 t.T(e,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let n=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,n=!0)}n&&this.fire(new t.n("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class ne extends te{constructor(e,i,n,r){super(e,i,n,r),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some(e=>!Array.isArray(e)||2!==e.length||e.some(e=>"number"!=typeof e))||this.fire(new t.l(new t.ac(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.l(new t.ac(`sources.${e}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new t.l(new t.ac(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new t.l(new t.ac(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new t.l(new t.ac(`sources.${e}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){return t._(this,void 0,void 0,function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.l(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())})}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context,n=i.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new t.T(i,this.canvas,n.RGBA,{premultiply:!0}),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let r=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,r=!0)}r&&this.fire(new t.n("data",{dataType:"source",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(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}}const re={},oe=e=>{switch(e){case"geojson":return ee;case"image":return te;case"raster":return $;case"raster-dem":return H;case"vector":return Z;case"video":return ie;case"canvas":return ne}return re[e]},se="RTLPluginLoaded";class ae extends t.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=O()}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch(e=>{throw this.status="error",e})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(e){return t._(this,arguments,void 0,function*(e,t=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=a.resolveURL(e),!this.url)throw new Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!t)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()})}_requestImport(){return t._(this,void 0,void 0,function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new t.n(se))})}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}}let le=null;function ce(){return le||(le=new ae),le}var ue,he;!function(e){e[e.Base=0]="Base",e[e.Parent=1]="Parent"}(ue||(ue={})),function(e){e[e.Departing=0]="Departing",e[e.Incoming=1]="Incoming"}(he||(he={}));class de{constructor(e,i){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=t.ad(),this.uses=0,this.tileSize=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttFingerprint={},this.expiredRequestCount=0,this.state="loading"}isRenderable(e){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(e||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:e,fadingDirection:t,fadingParentID:i,fadeEndTime:n}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=t,this.fadingParentID=i,this.fadeEndTime=n}setSelfFadeLogic(e){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=e}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=c(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(e,i,n){if(!0!==(null==e?void 0:e.etagUnmodified))if(this.hasData()&&this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestEncoding=e.encoding,this.latestFeatureIndex.rawTileData=e.rawTileData,this.latestFeatureIndex.encoding=e.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(e,t){const i={};if(!t)return i;for(const n of e){const e=n.layerIds.map(e=>t.getLayer(e)).filter(Boolean);if(0!==e.length){n.layers=e,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0]));for(const t of e)i[t.id]=n}}return i}(e.buckets,null==i?void 0:i.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.af){if(this.hasSymbolBuckets=!0,!n)break;i.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.af&&i.hasRTLText){this.hasRTLText=!0,ce().lazyLoad();break}}this.queryPadding=0;for(const e in this.buckets){const t=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(e).queryRadius(t))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),this.dashPositions=e.dashPositions}else this.collisionBoxArray=new t.ae;else this.state="loaded"}unloadVectorData(){for(const e in this.buckets)this.buckets[e].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(e){return this.buckets[e.id]}upload(e){for(const t in this.buckets){const i=this.buckets[t];i.uploadPending()&&i.upload(e)}const i=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new t.T(e,this.imageAtlas.image,i.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new t.T(e,this.glyphAtlasImage,i.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,i,n,r,o,s,a,l,c,u){var h;return(null===(h=this.latestFeatureIndex)||void 0===h?void 0:h.rawTileData)?this.latestFeatureIndex.query({queryGeometry:n,cameraQueryGeometry:r,scale:o,tileSize:this.tileSize,pixelPosMatrix:c,transform:a,params:s,queryPadding:this.queryPadding*l,getElevation:u},e,t,i):{}}querySourceFeatures(e,i){const n=this.latestFeatureIndex;if(!(null==n?void 0:n.rawTileData))return;const r=n.loadVTLayers(),o=(null==i?void 0:i.sourceLayer)?i.sourceLayer:"",s=r[t.ag]||r[o];if(!s)return;const a=t.ah(null==i?void 0:i.filter,null==i?void 0:i.globalState),{z:l,x:c,y:u}=this.tileID.canonical,h={z:l,x:c,y:u};for(let i=0;i<s.length;i++){const r=s.feature(i);if(a.needGeometry){const e=t.ai(r,!0);if(!a.filter(new t.J(this.tileID.overscaledZ),e,this.tileID.canonical))continue}else if(!a.filter(new t.J(this.tileID.overscaledZ),r))continue;const d=n.getId(r,o),p=new t.aj(r,l,c,u,d);p.tile=h,e.push(p)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){const i=this.expirationTime;if(e.cacheControl){const i=t.ak(e.cacheControl);i["max-age"]&&(this.expirationTime=Date.now()+1e3*i["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){const e=Date.now();let t=!1;if(this.expirationTime>e)t=!1;else if(i)if(this.expirationTime<i)t=!0;else{const n=this.expirationTime-i;n?this.expirationTime=e+Math.max(n,3e4):t=!0}else t=!0;t?(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(),Math.pow(2,31)-1)}setFeatureState(e,i){var n,r,o;if(!(null===(n=this.latestFeatureIndex)||void 0===n?void 0:n.rawTileData)||0===Object.keys(e).length)return;const s=this.latestFeatureIndex.loadVTLayers();for(const n in this.buckets){if(!i.style.hasLayer(n))continue;const a=this.buckets[n],l=a.layers[0].sourceLayer||t.ag,c=s[l],u=e[l];if(!c||!u||0===Object.keys(u).length)continue;a.update(u,c,(null===(r=this.imageAtlas)||void 0===r?void 0:r.patternPositions)||{},this.dashPositions||{});const h=null===(o=null==i?void 0:i.style)||void 0===o?void 0:o.getLayer(n);h&&(this.queryPadding=Math.max(this.queryPadding,h.queryRadius(a)))}}holdingForSymbolFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<c()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(e){this.symbolFadeHoldUntil=c()+e}setDependencies(e,t){const i={};for(const e of t)i[e]=!0;this.dependencies[e]=i}hasDependency(e,t){for(const i of e){const e=this.dependencies[i];if(e)for(const i of t)if(e[i])return!0}return!1}}class pe{constructor(){this.state={},this.stateChanges={},this.deletedStates={},this.revision=0}updateState(e,i,n){var r,o,s,a,l;const c=String(i);if((a=this.stateChanges)[e]||(a[e]={}),(l=this.stateChanges[e])[c]||(l[c]={}),t.e(this.stateChanges[e][c],n),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==c&&(this.deletedStates[e][t]=null)}else if(null===(null===(r=this.deletedStates[e])||void 0===r?void 0:r[c])){this.deletedStates[e][c]={};for(const t in this.state[e][c])n[t]||(this.deletedStates[e][c][t]=null)}else for(const t in n)null===(null===(s=null===(o=this.deletedStates[e])||void 0===o?void 0:o[c])||void 0===s?void 0:s[t])&&delete this.deletedStates[e][c][t]}removeFeatureState(e,t,i){var n,r,o;if(null===this.deletedStates[e])return;const s=String(t);if((r=this.deletedStates)[e]||(r[e]={}),i&&void 0!==t)null!==this.deletedStates[e][s]&&((o=this.deletedStates[e])[s]||(o[s]={}),this.deletedStates[e][s][i]=null);else if(void 0!==t)if(null===(n=this.stateChanges[e])||void 0===n?void 0:n[s])for(i in this.deletedStates[e][s]={},this.stateChanges[e][s])this.deletedStates[e][s][i]=null;else this.deletedStates[e][s]=null;else this.deletedStates[e]=null}getState(e,i){const n=String(i),r=t.e({},(this.state[e]||{})[n],(this.stateChanges[e]||{})[n]);if(null===this.deletedStates[e])return{};if(this.deletedStates[e]){const t=this.deletedStates[e][i];if(null===t)return{};for(const e in t)delete r[e]}return r}initializeTileState(e,t){e.setFeatureState(this.state,t)}coalesceChanges(e,i){var n,r,o;const s={};for(const e in this.stateChanges){(n=this.state)[e]||(n[e]={});const i={};for(const n in this.stateChanges[e])(r=this.state[e])[n]||(r[n]={}),t.e(this.state[e][n],this.stateChanges[e][n]),i[n]=this.state[e][n];s[e]=i}for(const e in this.deletedStates){(o=this.state)[e]||(o[e]={});const i={};if(null===this.deletedStates[e])for(const t in this.state[e])i[t]={},this.state[e][t]={};else for(const t in this.deletedStates[e]){if(null===this.deletedStates[e][t])this.state[e][t]={};else for(const i of Object.keys(this.deletedStates[e][t]))delete this.state[e][t][i];i[t]=this.state[e][t]}s[e]||(s[e]={}),t.e(s[e],i)}this.stateChanges={},this.deletedStates={},0!==Object.keys(s).length&&(this.revision++,e.setFeatureState(s,i))}}const fe=89.25;function me(e,i){const n=t.al(i.lat,-t.am,t.am);return new t.P(t.Z(i.lng)*e,t.Y(n)*e)}function ge(e,i){return new t.a7(i.x/e,i.y/e).toLngLat()}function ye(e){return e.cameraToCenterDistance*Math.min(.85*Math.tan(t.an(90-e.pitch)),Math.tan(t.an(fe-e.pitch)))}function _e(e,i){const n=e.canonical,r=i/t.ao(n.z),o=n.x+Math.pow(2,n.z)*e.wrap,s=t.ap(new Float64Array(16));return t.Q(s,s,[o*r,n.y*r,0]),t.S(s,s,[r/t.a6,r/t.a6,1]),s}function ve(e,i,n,r,o){const s=t.a7.fromLngLat(e,i),a=o*t.aq(1,e.lat),{x:l,y:c,z:u}=xe(n,r);return new t.a7(s.x+a*-l,s.y+a*-c,s.z+a*-u)}function xe(e,i){const n=t.an(e),r=t.an(i),o=Math.cos(-n),s=Math.sin(n);return{x:s*Math.sin(r),y:-s*Math.cos(r),z:o}}function be(e,t,i){const n=t.intersectsFrustum(e);if(!i||0===n)return n;const r=t.intersectsPlane(i);return 0===r?0:2===n&&2===r?2:1}function we(e,t,i){let n=0;const r=(i-t)/10;for(let o=0;o<10;o++)n+=r*Math.pow(Math.cos(t+(o+.5)/10*(i-t)),e);return n}function Ee(e,i){return function(n,r,o,s,a){const l=2*((e-1)/t.ar(Math.cos(t.an(fe-a))/Math.cos(t.an(fe)))-1),c=Math.acos(o/s),u=2*we(l-1,0,t.an(a/2)),h=Math.min(t.an(fe),c+t.an(a/2)),d=we(l-1,Math.min(h,c-t.an(a/2)),h),p=Math.atan(r/o),f=Math.hypot(r,o);let m=n;return m+=t.ar(s/f/Math.max(.5,Math.cos(t.an(a/2)))),m+=l*t.ar(Math.cos(p))/2,m-=t.ar(Math.max(1,d/u/i))/2,m}}const Te=Ee(9.314,3);function Se(e,i){const n=(i.roundZoom?Math.round:Math.floor)(e.zoom+t.ar(e.tileSize/i.tileSize));return Math.max(0,n)}function Ie(e,i){const n=e.getCameraFrustum(),r=e.getClippingPlane(),o=e.screenPointToMercatorCoordinate(e.getCameraPoint()),s=t.a7.fromLngLat(e.center,e.elevation);o.z=s.z+Math.cos(e.pitchInRadians)*e.cameraToCenterDistance/e.worldSize;const a=e.getCoveringTilesDetailsProvider(),l=a.allowVariableZoom(e,i),c=Se(e,i),u=i.minzoom||0,h=void 0!==i.maxzoom?i.maxzoom:e.maxZoom,d=Math.min(Math.max(0,c),h),p=Math.pow(2,d),f=[p*o.x,p*o.y,0],m=[p*s.x,p*s.y,0],g=Math.hypot(s.x-o.x,s.y-o.y),y=Math.abs(s.z-o.z),_=Math.hypot(g,y),v=e=>({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),x=[],b=[];if(e.renderWorldCopies&&a.allowWorldCopies())for(let e=1;e<=3;e++)x.push(v(-e)),x.push(v(e));for(x.push(v(0));x.length>0;){const p=x.pop(),g=p.x,v=p.y;let w=p.fullyVisible;const E={x:g,y:v,z:p.zoom},T=a.getTileBoundingVolume(E,p.wrap,e.elevation,i);if(!w){const e=be(n,T,r);if(0===e)continue;w=2===e}const S=a.distanceToTile2d(o.x,o.y,E,T);let I=c;l&&(I=(i.calculateTileZoom||Te)(e.zoom+t.ar(e.tileSize/i.tileSize),S,y,_,e.fov)),I=(i.roundZoom?Math.round:Math.floor)(I),I=Math.max(0,I);const k=Math.min(I,h);if(p.wrap=a.getWrap(s,E,p.wrap),p.zoom>=k){if(p.zoom<u)continue;const e=d-p.zoom,n=f[0]-.5-(g<<e),r=f[1]-.5-(v<<e),o=i.reparseOverscaled?Math.max(p.zoom,I):p.zoom;b.push({tileID:new t.a3(p.zoom===h?o:p.zoom,p.wrap,p.zoom,g,v),distanceSq:t.as([m[0]-.5-g,m[1]-.5-v]),tileDistanceToCamera:Math.sqrt(n*n+r*r)})}else for(let e=0;e<4;e++)x.push({zoom:p.zoom+1,x:(g<<1)+e%2,y:(v<<1)+(e>>1),wrap:p.wrap,fullyVisible:w})}return b.sort((e,t)=>e.distanceSq-t.distanceSq).map(e=>e.tileID)}const ke=t.a8.fromPoints([new t.P(0,0),new t.P(t.a6,t.a6)]);function Me(e){return"raster"===e||"image"===e||"video"===e}function Ce(e,t,i,n,r,o,s){if(!t.hasData())return!1;const{tileID:a,fadingRole:l,fadingDirection:c,fadingParentID:u}=t;if(l===ue.Base&&c===he.Incoming&&u)return i[u.key]=u,!0;const h=Math.max(a.overscaledZ-r,o);for(let r=a.overscaledZ-1;r>=h;r--){const o=a.scaledTo(r),l=e.getLoadedTile(o);if(l)return t.setCrossFadeLogic({fadingRole:ue.Base,fadingDirection:he.Incoming,fadingParentID:l.tileID,fadeEndTime:n+s}),l.setCrossFadeLogic({fadingRole:ue.Parent,fadingDirection:he.Departing,fadeEndTime:n+s}),i[o.key]=o,!0}return!1}function Pe(e,t,i,n,r,o){if(!t.hasData())return!1;const s=t.tileID.children(r);let a=Ae(e,t,s,i,n,r,o);if(a)return!0;for(const l of s)Ae(e,t,l.children(r),i,n,r,o)&&(a=!0);return a}function Ae(e,t,i,n,r,o,s){if(i[0].overscaledZ>=o)return!1;let a=!1;for(const o of i){const i=e.getLoadedTile(o);if(!i)continue;const{fadingRole:l,fadingDirection:c,fadingParentID:u}=i;l===ue.Base&&c===he.Departing&&u||(i.setCrossFadeLogic({fadingRole:ue.Base,fadingDirection:he.Departing,fadingParentID:t.tileID,fadeEndTime:r+s}),t.setCrossFadeLogic({fadingRole:ue.Parent,fadingDirection:he.Incoming,fadeEndTime:r+s})),n[o.key]=o,a=!0}return a}function Le(e,t,i,n){const r=e.tileID;return!!e.selfFading||!e.hasData()&&!!t.has(r)&&(e.setSelfFadeLogic(i+n),!0)}function De(e,t){var i;e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0;let n=t.tileID.canonical.x-e.tileID.canonical.x;const r=t.tileID.canonical.y-e.tileID.canonical.y,o=Math.pow(2,e.tileID.canonical.z),s=t.tileID.key;0===n&&0===r||Math.abs(r)>1||(Math.abs(n)>1&&(1===Math.abs(n+o)?n+=o:1===Math.abs(n-o)&&(n-=o)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,n,r),(null===(i=e.neighboringTiles)||void 0===i?void 0:i[s])&&(e.neighboringTiles[s].backfilled=!0)))}class Re{constructor(){this._tiles={}}handleWrapJump(e){const t={};for(const i in this._tiles){const n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),t[n.tileID.key]=n}this._tiles=t}setFeatureState(e,t){for(const i in this._tiles)this._tiles[i].setFeatureState(e,t)}getAllTiles(){return Object.values(this._tiles)}getAllIds(e=!1){return e?Object.values(this._tiles).map(e=>e.tileID).sort(t.au).map(e=>e.key):Object.keys(this._tiles)}getTileById(e){return this._tiles[e]}setTile(e,t){this._tiles[e]=t}deleteTileById(e){delete this._tiles[e]}getLoadedTile(e){const t=this.getTileById(e.key);return(null==t?void 0:t.hasData())?t:null}isIdRenderable(e,t=!1){var i;return null===(i=this.getTileById(e))||void 0===i?void 0:i.isRenderable(t)}getRenderableIds(e=0,i){const n=[];for(const e of this.getAllIds())this.isIdRenderable(e,i)&&n.push(this.getTileById(e));return i?n.sort((i,n)=>{const r=i.tileID,o=n.tileID,s=new t.P(r.canonical.x,r.canonical.y)._rotate(-e),a=new t.P(o.canonical.x,o.canonical.y)._rotate(-e);return r.overscaledZ-o.overscaledZ||a.y-s.y||a.x-s.x}).map(e=>e.tileID.key):n.map(e=>e.tileID).sort(t.au).map(e=>e.key)}}class ze extends t.E{constructor(e,i,n){super(),this.id=e,this.dispatcher=n,this.on("data",e=>{this._dataHandler(e)}),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((e,t,i,n)=>{const r=new(oe(t.type))(e,t,i,n);if(r.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${r.id}`);return r})(e,i,n,this),this._inViewTiles=new Re,this._outOfViewCache=new t.av(0,e=>this._unloadTile(e)),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new pe,this._didEmitContent=!1,this._updated=!1}onAdd(e){var t;this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,(null===(t=this._source)||void 0===t?void 0:t.onAdd)&&this._source.onAdd(e)}onRemove(e){var t;for(const e of this._inViewTiles.getAllTiles())e.unloadVectorData();this.clearTiles(),(null===(t=this._source)||void 0===t?void 0:t.onRemove)&&this._source.onRemove(e),this._inViewTiles=new Re}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!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(const e of this._inViewTiles.getAllTiles())if("loaded"!==e.state&&"errored"!==e.state)return!1;return!0}getSource(){return this._source}getState(){return this._state}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(e,i,n){return t._(this,void 0,void 0,function*(){try{const t=yield this._source.loadTile(e);this._tileLoaded(e,i,n,t)}catch(i){e.state="errored",404!==i.status?this._source.fire(new t.l(t.d(i),{tile:e})):this.update(this.transform,this.terrain)}})}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new t.n("dataabort",{tile:e,coord:e.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._inViewTiles,this.map?this.map.painter:null);for(const t of this._inViewTiles.getAllTiles())t.upload(e),t.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(e){var t;return this._inViewTiles.getRenderableIds(null===(t=this.transform)||void 0===t?void 0:t.bearingInRadians,e)}hasRenderableParent(e){const t=e.overscaledZ-1;if(t>=this._source.minzoom){const i=this.getLoadedTile(e.scaledTo(t));if(i)return this._inViewTiles.isIdRenderable(i.tileID.key)}return!1}reload(e,t=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._outOfViewCache.reset();for(const i of this._inViewTiles.getAllIds()){const n=this._inViewTiles.getTileById(i);t&&!this._source.shouldReloadTile(n,t)||(e?this._reloadTile(i,"expired"):"errored"!==n.state&&this._reloadTile(i,"reloading"))}}}_reloadTile(e,i){return t._(this,void 0,void 0,function*(){const t=this._inViewTiles.getTileById(e);t&&("loading"!==t.state&&(t.state=i),yield this._loadTile(t,e,i))})}_tileLoaded(e,i,n,r){e.timeAdded=c(),e.selfFading&&(e.fadeEndTime=e.timeAdded+this._rasterFadeDuration),"expired"===n&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(i,e),(null==r?void 0:r.unmodified)||("raster-dem"===this.getSource().type&&e.dem&&function(e,t){var i,n,r;const o=t.getRenderableIds();for(const s of o){if(!(null===(i=e.neighboringTiles)||void 0===i?void 0:i[s]))continue;const o=t.getTileById(s);e.neighboringTiles[s].backfilled||De(e,o),(null===(r=null===(n=o.neighboringTiles)||void 0===n?void 0:n[e.tileID.key])||void 0===r?void 0:r.backfilled)||De(o,e)}}(e,this._inViewTiles),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new t.n("data",{dataType:"source",tile:e,coord:e.tileID})))}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._inViewTiles.getTileById(e)}_retainLoadedChildren(e,t){const i=this._getLoadedDescendents(t),n=new Set;for(const r of t){const t=i[r.key];if(!(null==t?void 0:t.length)){n.add(r);continue}const o=r.overscaledZ+ze.maxOverzooming,s=t.filter(e=>e.tileID.overscaledZ<=o);if(!s.length){n.add(r);continue}const a=Math.min(...s.map(e=>e.tileID.overscaledZ)),l=s.filter(e=>e.tileID.overscaledZ===a).map(e=>e.tileID);for(const t of l)e[t.key]=t;this._areDescendentsComplete(l,a,r.overscaledZ)||n.add(r)}return n}_getLoadedDescendents(e){var t;const i={};for(const n of this._inViewTiles.getAllTiles().filter(e=>e.hasData()))for(const r of e)n.tileID.isChildOf(r)&&(i[t=r.key]||(i[t]=[]),i[r.key].push(n));return i}_areDescendentsComplete(e,t,i){return 1===e.length&&e[0].isOverscaled()?e[0].overscaledZ===t:Math.pow(4,t-i)===e.length}getLoadedTile(e){return this._inViewTiles.getLoadedTile(e)}updateCacheSize(e){const i=Math.ceil(e.width/this._source.tileSize)+1,n=Math.ceil(e.height/this._source.tileSize)+1,r=Math.floor(i*n*(null===this._maxTileCacheZoomLevels?t.c.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),o="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,r):r;this._outOfViewCache.setMaxSize(o)}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);this._prevLng=e,t&&(this._inViewTiles.handleWrapJump(t),this._resetTileReloadTimers())}update(e,i){if(!this._sourceLoaded||this._paused)return;let n;this.transform=e,this.terrain=i,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?n=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(e=>new t.a3(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)):(n=Ie(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:"vector"===this._source.type&&void 0!==this.map._zoomLevelsToOverscale?e.maxZoom-this.map._zoomLevelsToOverscale:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:i,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(n=n.filter(e=>this._source.hasTile(e)))):n=[],this.usedForTerrain&&(n=this._addTerrainIdealTiles(n));const r=0===n.length&&!this._updated&&this._didEmitContent;this._updated=!0,r&&this.fire(new t.n("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const o=Se(e,this._source),s=this._updateRetainedTiles(n,o),a=Me(this._source.type);a&&this._rasterFadeDuration>0&&!i&&function(e,i,n,r,o,s,a){const l=c(),u=t.at(i);for(const t of i){const i=e.getTileById(t.key);i.fadingDirection!==he.Departing&&0!==i.fadeOpacity||i.resetFadeLogic(),Ce(e,i,n,l,r,o,a)||Pe(e,i,n,l,s,a)||Le(i,u,l,a)||i.resetFadeLogic()}}(this._inViewTiles,n,s,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),a?this._cleanUpRasterTiles(s):this._cleanUpVectorTiles(s)}_cleanUpRasterTiles(e){for(const t of this._inViewTiles.getAllIds())e[t]||this._removeTile(t)}_cleanUpVectorTiles(e){for(const t of this._inViewTiles.getAllIds()){const i=this._inViewTiles.getTileById(t);e[t]?i.clearSymbolFadeHold():i.hasSymbolBuckets?i.holdingForSymbolFade()?i.symbolFadeFinished()&&this._removeTile(t):i.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(t)}}_addTerrainIdealTiles(e){const t=[];for(const i of e)if(i.canonical.z>this._source.minzoom){const e=i.scaledTo(i.canonical.z-1);t.push(e);const n=i.scaledTo(Math.max(this._source.minzoom,Math.min(i.canonical.z,5)));t.push(n)}return e.concat(t)}releaseSymbolFadeTiles(){for(const e of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(e).holdingForSymbolFade()&&this._removeTile(e)}_updateRetainedTiles(e,t){var i;const n=new Set;for(const t of e)this._addTile(t).hasData()||n.add(t);const r=e.reduce((e,t)=>(e[t.key]=t,e),{}),o=this._retainLoadedChildren(r,n),s={},a=Math.max(t-ze.maxUnderzooming,this._source.minzoom);for(const e of o){let t=this._inViewTiles.getTileById(e.key),n=null==t?void 0:t.wasRequested();for(let o=e.overscaledZ-1;o>=a;--o){const a=e.scaledTo(o);if(s[a.key])break;if(s[a.key]=!0,t=this.getTile(a),!t&&n&&(t=this._addTile(a)),t){const e=t.hasData();if((e||!(null===(i=this.map)||void 0===i?void 0:i.cancelPendingTileRequestsWhileZooming)||n)&&(r[a.key]=a),n=t.wasRequested(),e)break}}}return r}_addTile(e){let i=this._inViewTiles.getTileById(e.key);if(i)return i;i=this._outOfViewCache.getAndRemove(e),i&&(i.resetFadeLogic(),this._setTileReloadTimer(e.key,i),i.tileID=e,this._state.initializeTileState(i,this.map?this.map.painter:null));const n=i;return i||(i=new de(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(i,e.key,i.state)),i.uses++,this._inViewTiles.setTile(e.key,i),n||this._source.fire(new t.n("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(e,t){this._clearTileReloadTimer(e);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},i))}_clearTileReloadTimer(e){const t=this._timers[e];t&&(clearTimeout(t),delete this._timers[e])}_resetTileReloadTimers(){for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e of this._inViewTiles.getAllIds()){const t=this._inViewTiles.getTileById(e);this._setTileReloadTimer(e,t)}}refreshTiles(e){for(const t of this._inViewTiles.getAllIds()){const i=this._inViewTiles.getTileById(t);(this._inViewTiles.isIdRenderable(t)||"errored"==i.state)&&e.some(e=>e.equals(i.tileID.canonical))&&this._reloadTile(t,"expired")}}_removeTile(e){const t=this._inViewTiles.getTileById(e);t&&(t.uses--,this._inViewTiles.deleteTileById(e),this._clearTileReloadTimer(e),t.uses>0||(t.hasData()&&"reloading"!==t.state?this._outOfViewCache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}_dataHandler(e){"source"===e.dataType&&("metadata"!==e.sourceDataType?"content"===e.sourceDataType&&this._sourceLoaded&&!this._paused&&(this.reload(e.sourceDataChanged,e.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0):this._sourceLoaded=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e of this._inViewTiles.getAllIds())this._removeTile(e);this._outOfViewCache.reset()}tilesIn(e,i,n){const r=[],o=this.transform;if(!o)return r;const s=o.getCoveringTilesDetailsProvider().allowWorldCopies(),a=n?o.getCameraQueryGeometry(e):e,l=e=>o.screenPointToMercatorCoordinate(e,this.terrain),c=this.transformBbox(e,l,!s),u=this.transformBbox(a,l,!s),h=this.getIds(),d=t.a8.fromPoints(u);for(const e of h){const n=this._inViewTiles.getTileById(e);if(n.holdingForSymbolFade())continue;const a=s?[n.tileID]:[n.tileID.unwrapTo(-1),n.tileID.unwrapTo(0)],l=Math.pow(2,o.zoom-n.tileID.overscaledZ),h=i*n.queryPadding*t.a6/n.tileSize/l;for(const e of a){const i=d.map(i=>e.getTilePoint(new t.a7(i.x,i.y)));if(i.expandBy(h),i.intersects(ke)){const t=c.map(t=>e.getTilePoint(t)),i=u.map(t=>e.getTilePoint(t));r.push({tile:n,tileID:s?e:e.unwrapTo(0),queryGeometry:t,cameraQueryGeometry:i,scale:l})}}}return r}transformBbox(e,i,n){let r=e.map(i);if(n){const n=t.a8.fromPoints(e);n.shrinkBy(.001*Math.min(n.width(),n.height()));const o=n.map(i);t.a8.fromPoints(r).covers(o)||(r=r.map(e=>e.x>.5?new t.a7(e.x-1,e.y,e.z):e))}return r}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map(e=>this._inViewTiles.getTileById(e).tileID);return this.transform&&this.transform.populateCache(t),t}hasTransition(){return!!this._source.hasTransition()||Me(this._source.type)&&function(e,t){if(t<=0)return!1;const i=c();for(const t of e.getAllTiles())if(t.fadeEndTime>=i)return!0;return!1}(this._inViewTiles,this._rasterFadeDuration)}setRasterFadeDuration(e){this._rasterFadeDuration=e}setFeatureState(e,i,n){e||(e=t.ag),this._state.updateState(e,i,n)}removeFeatureState(e,i,n){e||(e=t.ag),this._state.removeFeatureState(e,i,n)}getFeatureState(e,i){return e||(e=t.ag),this._state.getState(e,i)}setDependencies(e,t,i){const n=this._inViewTiles.getTileById(e);n&&n.setDependencies(t,i)}reloadTilesForDependencies(e,t){for(const i of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(i).hasDependency(e,t)&&this._reloadTile(i,"reloading");this._outOfViewCache.filter(i=>!i.hasDependency(e,t))}areTilesLoaded(){for(const e of this._inViewTiles.getAllTiles())if("loaded"!==e.state&&"errored"!==e.state)return!1;return!0}}ze.maxUnderzooming=10,ze.maxOverzooming=3;class Fe{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e<this.points.length;e++)this._distances[e]=this._distances[e-1]+this.points[e].dist(this.points[e-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(t||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(e){if(1===this.points.length)return this.points[0];e=t.al(e,0,1);let i=1,n=this._distances[i];const r=e*this.paddedLength+this.padding;for(;n<r&&i<this._distances.length;)n=this._distances[++i];const o=i-1,s=this._distances[o],a=n-s,l=a>0?(r-s)/a:0;return this.points[o].mult(1-l).add(this.points[i].mult(l))}}function Oe(e,t){let i=!0;return"always"===e||"never"!==e&&"never"!==t||(i=!1),i}class Ne{constructor(e,t,i){const n=this.boxCells=[],r=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;e<this.xCellCount*this.yCellCount;e++)n.push([]),r.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=t,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/t,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,t,i,n,r){this._forEachCell(t,i,n,r,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(n),this.bboxes.push(r)}insertCircle(e,t,i,n){this._forEachCell(t-n,i-n,t+n,i+n,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(i),this.circles.push(n)}_insertBoxCell(e,t,i,n,r,o){this.boxCells[r].push(o)}_insertCircleCell(e,t,i,n,r,o){this.circleCells[r].push(o)}_query(e,t,i,n,r,o,s){if(i<0||e>this.width||n<0||t>this.height)return[];const a=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=n){if(r)return[{key:null,x1:e,y1:t,x2:i,y2:n}];for(let e=0;e<this.boxKeys.length;e++)a.push({key:this.boxKeys[e],x1:this.bboxes[4*e],y1:this.bboxes[4*e+1],x2:this.bboxes[4*e+2],y2:this.bboxes[4*e+3]});for(let e=0;e<this.circleKeys.length;e++){const t=this.circles[3*e],i=this.circles[3*e+1],n=this.circles[3*e+2];a.push({key:this.circleKeys[e],x1:t-n,y1:i-n,x2:t+n,y2:i+n})}}else this._forEachCell(e,t,i,n,this._queryCell,a,{hitTest:r,overlapMode:o,seenUids:{box:{},circle:{}}},s);return a}query(e,t,i,n){return this._query(e,t,i,n,!1,null)}hitTest(e,t,i,n,r,o){return this._query(e,t,i,n,!0,r,o).length>0}hitTestCircle(e,t,i,n,r){const o=e-i,s=e+i,a=t-i,l=t+i;if(s<0||o>this.width||l<0||a>this.height)return!1;const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:!0,overlapMode:n,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},r),c.length>0}_queryCell(e,t,i,n,r,o,s,a){const{seenUids:l,hitTest:c,overlapMode:u}=s,h=this.boxCells[r],d=1e-6;if(null!==h){const r=this.bboxes;for(const s of h)if(!l.box[s]){l.box[s]=!0;const h=4*s,p=this.boxKeys[s];if(e<=r[h+2]+d&&t<=r[h+3]+d&&i>=r[h+0]-d&&n>=r[h+1]-d&&(!a||a(p))&&(!c||!Oe(u,p.overlapMode))&&(o.push({key:p,x1:r[h],y1:r[h+1],x2:r[h+2],y2:r[h+3]}),c))return!0}}const p=this.circleCells[r];if(null!==p){const r=this.circles;for(const s of p)if(!l.circle[s]){l.circle[s]=!0;const h=3*s,d=this.circleKeys[s];if(this._circleAndRectCollide(r[h],r[h+1],r[h+2],e,t,i,n)&&(!a||a(d))&&(!c||!Oe(u,d.overlapMode))){const e=r[h],t=r[h+1],i=r[h+2];if(o.push({key:d,x1:e-i,y1:t-i,x2:e+i,y2:t+i}),c)return!0}}}return!1}_queryCellCircle(e,t,i,n,r,o,s,a){const{circle:l,seenUids:c,overlapMode:u}=s,h=this.boxCells[r];if(null!==h){const e=this.bboxes;for(const t of h)if(!c.box[t]){c.box[t]=!0;const i=4*t,n=this.boxKeys[t];if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!a||a(n))&&!Oe(u,n.overlapMode))return o.push(!0),!0}}const d=this.circleCells[r];if(null!==d){const e=this.circles;for(const t of d)if(!c.circle[t]){c.circle[t]=!0;const i=3*t,n=this.circleKeys[t];if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!a||a(n))&&!Oe(u,n.overlapMode))return o.push(!0),!0}}}_forEachCell(e,t,i,n,r,o,s,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),u=this._convertToXCellCoord(i),h=this._convertToYCellCoord(n);for(let d=l;d<=u;d++)for(let l=c;l<=h;l++)if(r.call(this,e,t,i,n,this.xCellCount*l+d,o,s,a))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,n,r,o){const s=n-e,a=r-t,l=i+o;return l*l>s*s+a*a}_circleAndRectCollide(e,t,i,n,r,o,s){const a=(o-n)/2,l=Math.abs(e-(n+a));if(l>a+i)return!1;const c=(s-r)/2,u=Math.abs(t-(r+c));if(u>c+i)return!1;if(l<=a||u<=c)return!0;const h=l-a,d=u-c;return h*h+d*d<=i*i}}function Be(e,t){const i=1/(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),n=1/(t[8]*t[8]+t[9]*t[9]+t[10]*t[10]),r=t[0]*i,o=t[4]*i,s=t[8]*n,a=t[1]*i,l=t[5]*i,c=t[9]*n,u=t[2]*i,h=t[6]*i,d=t[10]*n;e[0]=r,e[1]=o,e[2]=s,e[4]=a,e[5]=l,e[6]=c,e[8]=u,e[9]=h,e[10]=d;const p=t[12],f=t[13],m=t[14];return e[12]=-r*p-a*f-u*m,e[13]=-o*p-l*f-h*m,e[14]=-s*p-c*f-d*m,e[3]=0,e[7]=0,e[11]=0,e[15]=1,e}const Ge=t.O();function je(e,i,r){const o=t.O();if(!e){const{vecSouth:e,vecEast:t}=Ue(i),r=n();r[0]=t[0],r[1]=t[1],r[2]=e[0],r[3]=e[1],s=r,(d=(l=(a=r)[0])*(h=a[3])-(u=a[2])*(c=a[1]))&&(s[0]=h*(d=1/d),s[1]=-c*d,s[2]=-u*d,s[3]=l*d),o[0]=r[0],o[1]=r[1],o[4]=r[2],o[5]=r[3]}var s,a,l,c,u,h,d;return t.S(o,o,[1/r,1/r,1]),o}function Ve(e,i,n,r){if(e){const e=t.O();if(!i){const{vecSouth:t,vecEast:i}=Ue(n);e[0]=i[0],e[1]=i[1],e[4]=t[0],e[5]=t[1]}return t.S(e,e,[r,r,1]),e}return n.pixelsToClipSpaceMatrix}function Ue(e){const i=Math.cos(e.rollInRadians),n=Math.sin(e.rollInRadians),r=Math.cos(e.pitchInRadians),o=Math.cos(e.bearingInRadians),s=Math.sin(e.bearingInRadians),a=t.az();a[0]=-o*r*n-s*i,a[1]=-s*r*n+o*i;const l=t.aA(a);l<1e-9?t.aB(a):t.aC(a,a,1/l);const c=t.az();c[0]=o*r*i-s*n,c[1]=s*r*i+o*n;const u=t.aA(c);return u<1e-9?t.aB(c):t.aC(c,c,1/u),{vecEast:c,vecSouth:a}}function qe(e,i,n,r){let o;r?(o=[e,i,r(e,i),1],t.aE(o,o,n)):(o=[e,i,0,1],at(o,o,n));const s=o[3];return{point:new t.P(o[0]/s,o[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}function Ze(e,t){return.5+e/t*.5}function $e(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function He(e,i,n,r,o,s,a,l,c,u,h,d,p){const f=n?e.textSizeData:e.iconSizeData,m=t.aw(f,i.transform.zoom),g=[256/i.width*2+1,256/i.height*2+1],y=n?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;y.clear();const _=e.lineVertexArray,v=n?e.text.placedSymbolArray:e.icon.placedSymbolArray,x=i.transform.width/i.transform.height;let b=!1;for(let n=0;n<v.length;n++){const w=v.get(n);if(w.hidden||w.writingMode===t.ax.vertical&&!b){st(w.numGlyphs,y);continue}b=!1;const E=new t.P(w.anchorX,w.anchorY),T={getElevation:p,pitchedLabelPlaneMatrix:r,lineVertexArray:_,pitchWithMap:s,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:i.transform,tileAnchorPoint:E,unwrappedTileID:c,width:u,height:h,translation:d},S=tt(w.anchorX,w.anchorY,T);if(!$e(S.point,g)){st(w.numGlyphs,y);continue}const I=Ze(i.transform.cameraToCenterDistance,S.signedDistanceFromCamera),k=t.ay(f,m,w),M=s?k*i.transform.getPitchedTextCorrection(w.anchorX,w.anchorY,c)/I:k*I,C=Ye({projectionContext:T,pitchedLabelPlaneMatrixInverse:o,symbol:w,fontSize:M,flip:!1,keepUpright:a,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:y,aspectRatio:x,rotateToLine:l});b=C.useVertical,(C.notEnoughRoom||b||C.needsFlipping&&Ye({projectionContext:T,pitchedLabelPlaneMatrixInverse:o,symbol:w,fontSize:M,flip:!0,keepUpright:a,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:y,aspectRatio:x,rotateToLine:l}).notEnoughRoom)&&st(w.numGlyphs,y)}n?e.text.dynamicLayoutVertexBuffer.updateData(y):e.icon.dynamicLayoutVertexBuffer.updateData(y)}function We(e,t,i,n,r,o,s,a){const l=o.glyphStartIndex+o.numGlyphs,c=o.lineStartIndex,u=o.lineStartIndex+o.lineLength,h=t.getoffsetX(o.glyphStartIndex),d=t.getoffsetX(l-1),p=rt(e*h,i,n,r,o.segment,c,u,a,s);if(!p)return null;const f=rt(e*d,i,n,r,o.segment,c,u,a,s);return f?a.projectionCache.anyProjectionOccluded?null:{first:p,last:f}:null}function Xe(e,i,n,r){return e===t.ax.horizontal&&Math.abs(n.y-i.y)>Math.abs(n.x-i.x)*r?{useVertical:!0}:(e===t.ax.vertical?i.y<n.y:i.x>n.x)?{needsFlipping:!0}:null}function Ye(e){const{projectionContext:i,pitchedLabelPlaneMatrixInverse:n,symbol:r,fontSize:o,flip:s,keepUpright:a,glyphOffsetArray:l,dynamicLayoutVertexArray:c,aspectRatio:u,rotateToLine:h}=e,d=o/24,p=r.lineOffsetX*d,f=r.lineOffsetY*d;let m;if(r.numGlyphs>1){const e=r.glyphStartIndex+r.numGlyphs,t=r.lineStartIndex,o=r.lineStartIndex+r.lineLength,c=We(d,l,p,f,s,r,h,i);if(!c)return{notEnoughRoom:!0};const g=et(c.first.point.x,c.first.point.y,i,n),y=et(c.last.point.x,c.last.point.y,i,n);if(a&&!s){const e=Xe(r.writingMode,g,y,u);if(e)return e}m=[c.first];for(let n=r.glyphStartIndex+1;n<e-1;n++){const e=rt(d*l.getoffsetX(n),p,f,s,r.segment,t,o,i,h);if(!e)return{notEnoughRoom:!0};m.push(e)}m.push(c.last)}else{if(a&&!s){const e=Qe(i.tileAnchorPoint.x,i.tileAnchorPoint.y,i).point,o=r.lineStartIndex+r.segment+1,s=new t.P(i.lineVertexArray.getx(o),i.lineVertexArray.gety(o)),a=Qe(s.x,s.y,i),l=a.signedDistanceFromCamera>0?a.point:Je(i.tileAnchorPoint,s,e,1,i),c=et(e.x,e.y,i,n),h=et(l.x,l.y,i,n),d=Xe(r.writingMode,c,h,u);if(d)return d}const e=rt(d*l.getoffsetX(r.glyphStartIndex),p,f,s,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,i,h);if(!e||i.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};m=[e]}for(const e of m)t.aD(c,e.point,e.angle);return{}}function Je(e,t,i,n,r){const o=e.add(e.sub(t)._unit()),s=Qe(o.x,o.y,r).point,a=i.sub(s);return i.add(a._mult(n/a.mag()))}function Ke(e,i,n){const r=i.projectionCache;if(r.projections[e])return r.projections[e];const o=new t.P(i.lineVertexArray.getx(e),i.lineVertexArray.gety(e)),s=Qe(o.x,o.y,i);if(s.signedDistanceFromCamera>0)return r.projections[e]=s.point,r.anyProjectionOccluded||(r.anyProjectionOccluded=s.isOccluded),s.point;const a=e-n.direction;return Je(0===n.distanceFromAnchor?i.tileAnchorPoint:new t.P(i.lineVertexArray.getx(a),i.lineVertexArray.gety(a)),o,n.previousVertex,n.absOffsetX-n.distanceFromAnchor+1,i)}function Qe(e,t,i){const n=e+i.translation[0],r=t+i.translation[1];let o;return i.pitchWithMap?(o=qe(n,r,i.pitchedLabelPlaneMatrix,i.getElevation),o.isOccluded=!1):(o=i.transform.projectTileCoordinates(n,r,i.unwrappedTileID,i.getElevation),o.point.x=(.5*o.point.x+.5)*i.width,o.point.y=(.5*-o.point.y+.5)*i.height),o}function et(e,i,n,r){if(n.pitchWithMap){const o=[e,i,0,1];return t.aE(o,o,r),n.transform.projectTileCoordinates(o[0]/o[3],o[1]/o[3],n.unwrappedTileID,n.getElevation).point}return{x:e/n.width*2-1,y:1-i/n.height*2}}function tt(e,t,i){return i.transform.projectTileCoordinates(e,t,i.unwrappedTileID,i.getElevation)}function it(e,t,i){return e._unit()._perp()._mult(t*i)}function nt(e,i,n,r,o,s,a,l,c){if(l.projectionCache.offsets[e])return l.projectionCache.offsets[e];const u=n.add(i);if(e+c.direction<r||e+c.direction>=o)return l.projectionCache.offsets[e]=u,u;const h=Ke(e+c.direction,l,c),d=it(h.sub(n),a,c.direction),p=n.add(d),f=h.add(d);return l.projectionCache.offsets[e]=t.aF(s,u,p,f)||u,l.projectionCache.offsets[e]}function rt(e,t,i,n,r,o,s,a,l){const c=n?e-t:e+t;let u=c>0?1:-1,h=0;n&&(u*=-1,h=Math.PI),u<0&&(h+=Math.PI);let d,p=u>0?o+r:o+r+1;a.projectionCache.cachedAnchorPoint?d=a.projectionCache.cachedAnchorPoint:(d=Qe(a.tileAnchorPoint.x,a.tileAnchorPoint.y,a).point,a.projectionCache.cachedAnchorPoint=d);let f,m,g=d,y=d,_=0,v=0;const x=Math.abs(c),b=[];let w;for(;_+v<=x;){if(p+=u,p<o||p>=s)return null;_+=v,y=g,m=f;const e={absOffsetX:x,direction:u,distanceFromAnchor:_,previousVertex:y};if(g=Ke(p,a,e),0===i)b.push(y),w=g.sub(y);else{let t;const n=g.sub(y);t=0===n.mag()?it(Ke(p+u,a,e).sub(g),i,u):it(n,i,u),m||(m=y.add(t)),f=nt(p,t,g,o,s,m,i,a,e),b.push(m),w=f.sub(m)}v=w.mag()}const E=w._mult((x-_)/v)._add(m||y),T=h+Math.atan2(g.y-y.y,g.x-y.x);return b.push(E),{point:E,angle:l?T:0,path:b}}const ot=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function st(e,t){for(let i=0;i<e;i++){const e=t.length;t.resize(e+4),t.float32.set(ot,3*e)}}function at(e,t,i){const n=t[0],r=t[1];return e[0]=i[0]*n+i[4]*r+i[12],e[1]=i[1]*n+i[5]*r+i[13],e[3]=i[3]*n+i[7]*r+i[15],e}const lt=100;class ct{constructor(e,t=new Ne(e.width+200,e.height+200,25),i=new Ne(e.width+200,e.height+200,25)){this.transform=e,this.grid=t,this.ignoredGrid=i,this.pitchFactor=Math.cos(e.pitch*Math.PI/180)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+lt,this.screenBottomBoundary=e.height+lt,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(e,t,i,n,r,o,s,a,l,c,u,h){const d=this.projectAndGetPerspectiveRatio(e.anchorPointX+a[0],e.anchorPointY+a[1],r,c,h),p=i*d.perspectiveRatio;let f;if(o||s)f=this._projectCollisionBox(e,p,n,r,o,s,a,d,c,u,h);else{const t=d.x+(u?u.x*p:0),i=d.y+(u?u.y*p:0);f={allPointsOccluded:!1,box:[t+e.x1*p,i+e.y1*p,t+e.x2*p,i+e.y2*p]}}const[m,g,y,_]=f.box,v=o?f.allPointsOccluded:d.isOccluded;let x=v;return x||(x=d.perspectiveRatio<this.perspectiveRatioCutoff),x||(x=!this.isInsideGrid(m,g,y,_)),x||"always"!==t&&this.grid.hitTest(m,g,y,_,t,l)?{box:[m,g,y,_],placeable:!1,offscreen:!1,occluded:v}:{box:[m,g,y,_],placeable:!0,offscreen:this.isOffscreen(m,g,y,_),occluded:v}}placeCollisionCircles(e,i,n,r,o,s,a,l,c,u,h,d,p,f){const m=[],g=new t.P(i.anchorX,i.anchorY),y=this.getPerspectiveRatio(g.x,g.y,s,f),_=(c?o*this.transform.getPitchedTextCorrection(i.anchorX,i.anchorY,s)/y:o*y)/t.aJ,v={getElevation:f,pitchedLabelPlaneMatrix:a,lineVertexArray:n,pitchWithMap:c,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:g,unwrappedTileID:s,width:this.transform.width,height:this.transform.height,translation:p},x=We(_,r,i.lineOffsetX*_,i.lineOffsetY*_,!1,i,!1,v);let b=!1,w=!1,E=!0;if(x){const i=.5*h*y+d,n=new t.P(-100,-100),r=new t.P(this.screenRightBoundary,this.screenBottomBoundary),o=new Fe,s=x.first,a=x.last;let p=[];for(let e=s.path.length-1;e>=1;e--)p.push(s.path[e]);for(let e=1;e<a.path.length;e++)p.push(a.path[e]);const f=2.5*i;if(c){const e=this.projectPathToScreenSpace(p,v);p=e.some(e=>e.signedDistanceFromCamera<=0)?[]:e.map(e=>e.point)}let g=[];if(p.length>0){const e=p[0].clone(),i=p[0].clone();for(let t=1;t<p.length;t++)e.x=Math.min(e.x,p[t].x),e.y=Math.min(e.y,p[t].y),i.x=Math.max(i.x,p[t].x),i.y=Math.max(i.y,p[t].y);g=e.x>=n.x&&i.x<=r.x&&e.y>=n.y&&i.y<=r.y?[p]:i.x<n.x||e.x>r.x||i.y<n.y||e.y>r.y?[]:t.aG([p],n.x,n.y,r.x,r.y)}for(const t of g){o.reset(t,.25*i);let n=0;n=o.length<=.5*i?1:Math.ceil(o.paddedLength/f)+1;for(let t=0;t<n;t++){const r=t/Math.max(n-1,1),s=o.lerp(r),a=s.x+lt,c=s.y+lt;m.push(a,c,i,0);const h=a-i,d=c-i,p=a+i,f=c+i;if(E&&(E=this.isOffscreen(h,d,p,f)),w||(w=this.isInsideGrid(h,d,p,f)),"always"!==e&&this.grid.hitTestCircle(a,c,i,e,u)&&(b=!0,!l))return{circles:[],offscreen:!1,collisionDetected:b}}}}return{circles:!l&&b||!w||y<this.perspectiveRatioCutoff?[]:m,offscreen:E,collisionDetected:b}}projectPathToScreenSpace(e,t){const i=function(e,t){const i=Ge;return function(e,t){const i=1/(t[0]*t[5]-t[1]*t[4]);e[0]=t[5]*i,e[1]=-t[1]*i,e[2]=0,e[3]=0,e[4]=-t[4]*i,e[5]=t[0]*i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1/t[10],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1/t[15]}(i,t.pitchedLabelPlaneMatrix),e.map(e=>{const n=qe(e.x,e.y,i,t.getElevation),r=t.transform.projectTileCoordinates(n.point.x,n.point.y,t.unwrappedTileID,t.getElevation);return r.point.x=(.5*r.point.x+.5)*t.width,r.point.y=(.5*-r.point.y+.5)*t.height,r})}(e,t);return function(e){let t=0,i=0,n=0,r=0;for(let o=0;o<e.length;o++)e[o].isOccluded?(n=o+1,r=0):(r++,r>i&&(i=r,t=n));return e.slice(t,t+i)}(i)}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const i=[],n=new t.a8;for(const r of e){const e=new t.P(r.x+lt,r.y+lt);n.extend(e),i.push(e)}const{minX:r,minY:o,maxX:s,maxY:a}=n,l=this.grid.query(r,o,s,a).concat(this.ignoredGrid.query(r,o,s,a)),c={},u={};for(const e of l){const n=e.key;if(void 0===c[n.bucketInstanceId]&&(c[n.bucketInstanceId]={}),c[n.bucketInstanceId][n.featureIndex])continue;const r=[new t.P(e.x1,e.y1),new t.P(e.x2,e.y1),new t.P(e.x2,e.y2),new t.P(e.x1,e.y2)];t.aH(i,r)&&(c[n.bucketInstanceId][n.featureIndex]=!0,void 0===u[n.bucketInstanceId]&&(u[n.bucketInstanceId]=[]),u[n.bucketInstanceId].push(n.featureIndex))}return u}insertCollisionBox(e,t,i,n,r,o){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:n,featureIndex:r,collisionGroupID:o,overlapMode:t},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,i,n,r,o){const s=i?this.ignoredGrid:this.grid,a={bucketInstanceId:n,featureIndex:r,collisionGroupID:o,overlapMode:t};for(let t=0;t<e.length;t+=4)s.insertCircle(a,e[t],e[t+1],e[t+2])}projectAndGetPerspectiveRatio(e,i,n,r,o){if(o){let n;r?(n=[e,i,r(e,i),1],t.aE(n,n,o)):(n=[e,i,0,1],at(n,n,o));const s=n[3];return{x:(n[0]/s+1)/2*this.transform.width+lt,y:(-n[1]/s+1)/2*this.transform.height+lt,perspectiveRatio:.5+this.transform.cameraToCenterDistance/s*.5,isOccluded:!1,signedDistanceFromCamera:s}}{const t=this.transform.projectTileCoordinates(e,i,n,r);return{x:(t.point.x+1)/2*this.transform.width+lt,y:(1-t.point.y)/2*this.transform.height+lt,perspectiveRatio:.5+this.transform.cameraToCenterDistance/t.signedDistanceFromCamera*.5,isOccluded:t.isOccluded,signedDistanceFromCamera:t.signedDistanceFromCamera}}}getPerspectiveRatio(e,t,i,n){const r=this.transform.projectTileCoordinates(e,t,i,n);return.5+this.transform.cameraToCenterDistance/r.signedDistanceFromCamera*.5}isOffscreen(e,t,i,n){return i<lt||e>=this.screenRightBoundary||n<lt||t>this.screenBottomBoundary}isInsideGrid(e,t,i,n){return i>=0&&e<this.gridRightBoundary&&n>=0&&t<this.gridBottomBoundary}getViewportMatrix(){const e=t.ap([]);return t.Q(e,e,[-100,-100,0]),e}_projectCollisionBox(e,i,n,r,o,s,a,l,c,u,h){let d=1,p=0,f=0,m=1;const g=e.anchorPointX+a[0],y=e.anchorPointY+a[1];if(s&&!o){const e=this.projectAndGetPerspectiveRatio(g+1,y,r,c,h),t=e.x-l.x,i=Math.atan((e.y-l.y)/t)+(t<0?Math.PI:0),n=Math.sin(i),o=Math.cos(i);d=o,p=n,f=-n,m=o}else if(!s&&o){const e=Ue(this.transform);d=e.vecEast[0],p=e.vecEast[1],f=e.vecSouth[0],m=e.vecSouth[1]}let _=l.x,v=l.y,x=i;o&&(_=g,v=y,x=Math.pow(2,-(this.transform.zoom-n.overscaledZ)),x*=this.transform.getPitchedTextCorrection(g,y,r),u||(x*=t.al(.5+l.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))),u&&(_+=d*u.x*x+f*u.y*x,v+=p*u.x*x+m*u.y*x);const b=e.x1*x,w=e.x2*x,E=(b+w)/2,T=e.y1*x,S=e.y2*x,I=(T+S)/2,k=[{offsetX:b,offsetY:T},{offsetX:E,offsetY:T},{offsetX:w,offsetY:T},{offsetX:w,offsetY:I},{offsetX:w,offsetY:S},{offsetX:E,offsetY:S},{offsetX:b,offsetY:S},{offsetX:b,offsetY:I}];let M=[];for(const{offsetX:e,offsetY:i}of k)M.push(new t.P(_+d*e+f*i,v+p*e+m*i));let C=!1;if(o){const e=M.map(e=>this.projectAndGetPerspectiveRatio(e.x,e.y,r,c,h));C=e.some(e=>!e.isOccluded),M=e.map(e=>new t.P(e.x,e.y))}else C=!0;return{box:t.aI(M),allPointsOccluded:!C}}}class ut{constructor(e,t,i,n){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):n&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class ht{constructor(e,t,i,n,r){this.text=new ut(e?e.text:null,t,i,r),this.icon=new ut(e?e.icon:null,t,n,r)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class dt{constructor(e,t,i){this.text=e,this.icon=t,this.skipFade=i}}class pt{constructor(e,t,i,n,r){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=n,this.tileID=r}}class ft{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){const t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t}}return this.collisionGroups[e]}}function mt(e,i,n,r,o){const{horizontalAlign:s,verticalAlign:a}=t.aP(e);return new t.P(-(s-.5)*i+r[0]*o,-(a-.5)*n+r[1]*o)}class gt{constructor(e,t,i,n,r){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new ct(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new ft(n),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){const t=this.terrain;return t?(i,n)=>t.getElevation(e,i,n):null}getBucketParts(e,i,n,r){const o=n.getBucket(i),s=n.latestFeatureIndex;if(!o||!s||i.id!==o.layerIds[0])return;const a=n.collisionBoxArray,l=o.layers[0].layout,c=o.layers[0].paint,u=Math.pow(2,this.transform.zoom-n.tileID.overscaledZ),h=n.tileSize/t.a6,d=n.tileID.toUnwrapped(),p="map"===l.get("text-rotation-alignment"),f=t.aK(n,1,this.transform.zoom),m=t.aL(this.collisionIndex.transform,n,c.get("text-translate"),c.get("text-translate-anchor")),g=t.aL(this.collisionIndex.transform,n,c.get("icon-translate"),c.get("icon-translate-anchor")),y=je(p,this.transform,f);this.retainedQueryData[o.bucketInstanceId]=new pt(o.bucketInstanceId,s,o.sourceLayerIndex,o.index,n.tileID);const _={bucket:o,layout:l,translationText:m,translationIcon:g,unwrappedTileID:d,pitchedLabelPlaneMatrix:y,scale:u,textPixelRatio:h,holdingForFade:n.holdingForSymbolFade(),collisionBoxArray:a,partiallyEvaluatedTextSize:t.aw(o.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(r)for(const t of o.sortKeyRanges){const{sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:r}=t;e.push({sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:r,parameters:_})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:_})}attemptAnchorPlacement(e,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,y,_,v,x){var b,w,E;const T=t.aM[e.textAnchor],S=[e.textOffset0,e.textOffset1],I=mt(T,n,r,S,o),k=this.collisionIndex.placeCollisionBox(i,d,l,c,u,a,s,g,h.predicate,v,I,x);if((!_||this.collisionIndex.placeCollisionBox(_,d,l,c,u,a,s,y,h.predicate,v,I,x).placeable)&&k.placeable){let e;if((null===(b=this.prevPlacement)||void 0===b?void 0:b.variableOffsets[p.crossTileID])&&(null===(E=null===(w=this.prevPlacement)||void 0===w?void 0:w.placements[p.crossTileID])||void 0===E?void 0:E.text)&&(e=this.prevPlacement.variableOffsets[p.crossTileID].anchor),0===p.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[p.crossTileID]={textOffset:S,width:n,height:r,anchor:T,textBoxScale:o,prevAnchor:e},this.markUsedJustification(f,T,p,m),f.allowVerticalPlacement&&(this.markUsedOrientation(f,m,p),this.placedOrientations[p.crossTileID]=m),{shift:I,placedGlyphBoxes:k}}}placeLayerBucketPart(e,i,n){const{bucket:r,layout:o,translationText:s,translationIcon:a,unwrappedTileID:l,pitchedLabelPlaneMatrix:c,textPixelRatio:u,holdingForFade:h,collisionBoxArray:d,partiallyEvaluatedTextSize:p,collisionGroup:f}=e.parameters,m=o.get("text-optional"),g=o.get("icon-optional"),y=t.aN(o,"text-overlap","text-allow-overlap"),_="always"===y,v=t.aN(o,"icon-overlap","icon-allow-overlap"),x="always"===v,b="map"===o.get("text-rotation-alignment"),w="map"===o.get("text-pitch-alignment"),E="none"!==o.get("icon-text-fit"),T="viewport-y"===o.get("symbol-z-order"),S=_&&(x||!r.hasIconData()||g),I=x&&(_||!r.hasTextData()||m);!r.collisionArrays&&d&&r.deserializeCollisionBoxes(d);const k=this.retainedQueryData[r.bucketInstanceId].tileID,M=this._getTerrainElevationFunc(k),C=this.transform.getFastPathSimpleProjectionMatrix(k),P=(e,d,x)=>{var T,P;if(i[e.crossTileID])return;if(h)return void(this.placements[e.crossTileID]=new dt(!1,!1,!1));let A=!1,L=!1,D=!0,R=null,z={box:null,placeable:!1,offscreen:null,occluded:!1},F={placeable:!1},O=null,N=null,B=null,G=0,j=0,V=0;d.textFeatureIndex?G=d.textFeatureIndex:e.useRuntimeCollisionCircles&&(G=e.featureIndex),d.verticalTextFeatureIndex&&(j=d.verticalTextFeatureIndex);const U=d.textBox;if(U){const i=i=>{let n=t.ax.horizontal;if(r.allowVerticalPlacement&&!i&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,n=t,this.markUsedOrientation(r,n,e))}return n},o=(i,n)=>{if(r.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const e of r.writingModes)if(e===t.ax.vertical?(z=n(),F=z):z=i(),null==z?void 0:z.placeable)break}else z=i()},c=e.textAnchorOffsetStartIndex,h=e.textAnchorOffsetEndIndex;if(h===c){const n=(t,i)=>{const n=this.collisionIndex.placeCollisionBox(t,y,u,k,l,w,b,s,f.predicate,M,void 0,C);return(null==n?void 0:n.placeable)&&(this.markUsedOrientation(r,i,e),this.placedOrientations[e.crossTileID]=i),n};o(()=>n(U,t.ax.horizontal),()=>{const i=d.verticalTextBox;return r.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&i?n(i,t.ax.vertical):{box:null,offscreen:null}}),i(null==z?void 0:z.placeable)}else{let p=t.aM[null===(P=null===(T=this.prevPlacement)||void 0===T?void 0:T.variableOffsets[e.crossTileID])||void 0===P?void 0:P.anchor];const m=(t,i,o)=>{const d=t.x2-t.x1,m=t.y2-t.y1,g=e.textBoxScale,_=E&&"never"===v?i:null;let x=null,T="never"===y?1:2,S="never";p&&T++;for(let i=0;i<T;i++){for(let i=c;i<h;i++){const n=r.textAnchorOffsets.get(i);if(p&&n.textAnchor!==p)continue;const c=this.attemptAnchorPlacement(n,t,d,m,g,b,w,u,k,l,f,S,e,r,o,s,a,_,M);if(c&&(x=c.placedGlyphBoxes,null==x?void 0:x.placeable))return A=!0,R=c.shift,x}p?p=null:S=y}return n&&!x&&(x={box:this.collisionIndex.placeCollisionBox(U,"always",u,k,l,w,b,s,f.predicate,M,void 0,C).box,offscreen:!1,placeable:!1,occluded:!1}),x};o(()=>m(U,d.iconBox,t.ax.horizontal),()=>{const i=d.verticalTextBox;return r.allowVerticalPlacement&&!(null==z?void 0:z.placeable)&&e.numVerticalGlyphVertices>0&&i?m(i,d.verticalIconBox,t.ax.vertical):{box:null,occluded:!0,offscreen:null}}),z&&(A=z.placeable,D=z.offscreen);const g=i(null==z?void 0:z.placeable);if(!A&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(r,t.anchor,e,g))}}}if(O=z,A=null==O?void 0:O.placeable,D=null==O?void 0:O.offscreen,e.useRuntimeCollisionCircles&&e.centerJustifiedTextSymbolIndex>=0){const i=r.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),a=t.ay(r.textSizeData,p,i),u=o.get("text-padding");N=this.collisionIndex.placeCollisionCircles(y,i,r.lineVertexArray,r.glyphOffsetArray,a,l,c,n,w,f.predicate,e.collisionCircleDiameter,u,s,M),N.circles.length&&N.collisionDetected&&!n&&t.w("Collisions detected, but collision boxes are not shown"),A=_||N.circles.length>0&&!N.collisionDetected,D&&(D=N.offscreen)}if(d.iconFeatureIndex&&(V=d.iconFeatureIndex),d.iconBox){const e=e=>this.collisionIndex.placeCollisionBox(e,v,u,k,l,w,b,a,f.predicate,M,E&&R?R:void 0,C);F&&F.placeable&&d.verticalIconBox?(B=e(d.verticalIconBox),L=B.placeable):(B=e(d.iconBox),L=B.placeable),D&&(D=B.offscreen)}const q=m||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,Z=g||0===e.numIconVertices;q||Z?Z?q||L&&(L=A):A=L&&A:L=A=L&&A;const $=L&&B.placeable;if(A&&O.placeable&&this.collisionIndex.insertCollisionBox(O.box,y,o.get("text-ignore-placement"),r.bucketInstanceId,F&&F.placeable&&j?j:G,f.ID),$&&this.collisionIndex.insertCollisionBox(B.box,v,o.get("icon-ignore-placement"),r.bucketInstanceId,V,f.ID),N&&A&&this.collisionIndex.insertCollisionCircles(N.circles,y,o.get("text-ignore-placement"),r.bucketInstanceId,G,f.ID),n&&this.storeCollisionData(r.bucketInstanceId,x,d,O,B,N),0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===r.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[e.crossTileID]=new dt((A||S)&&!(null==O?void 0:O.occluded),(L||I)&&!(null==B?void 0:B.occluded),D||r.justReloaded),i[e.crossTileID]=!0};if(T){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const t=r.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=t.length-1;e>=0;--e){const i=t[e];P(r.symbolInstances.get(i),r.collisionArrays[i],i)}}else for(let t=e.symbolInstanceStart;t<e.symbolInstanceEnd;t++)P(r.symbolInstances.get(t),r.collisionArrays[t],t);r.justReloaded=!1}storeCollisionData(e,t,i,n,r,o){if(i.textBox||i.iconBox){let o,s;this.collisionBoxArrays.has(e)?o=this.collisionBoxArrays.get(e):(o=new Map,this.collisionBoxArrays.set(e,o)),o.has(t)?s=o.get(t):(s={text:null,icon:null},o.set(t,s)),i.textBox&&(s.text=n.box),i.iconBox&&(s.icon=r.box)}if(o){let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=[]);for(let e=0;e<o.circles.length;e+=4)t.push(o.circles[e+0]-lt),t.push(o.circles[e+1]-lt),t.push(o.circles[e+2]),t.push(o.collisionDetected?1:0)}}markUsedJustification(e,i,n,r){let o;o=r===t.ax.vertical?n.verticalPlacedTextSymbolIndex:{left:n.leftJustifiedTextSymbolIndex,center:n.centerJustifiedTextSymbolIndex,right:n.rightJustifiedTextSymbolIndex}[t.aO(i)];const s=[n.leftJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.rightJustifiedTextSymbolIndex,n.verticalPlacedTextSymbolIndex];for(const t of s)t>=0&&(e.text.placedSymbolArray.get(t).crossTileID=o>=0&&t!==o?0:n.crossTileID)}markUsedOrientation(e,i,n){const r=i===t.ax.horizontal||i===t.ax.horizontalOnly?i:0,o=i===t.ax.vertical?i:0,s=[n.leftJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.rightJustifiedTextSymbolIndex];for(const t of s)e.text.placedSymbolArray.get(t).placedOrientation=r;n.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(n.verticalPlacedTextSymbolIndex).placedOrientation=o)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const n=t?t.symbolFadeChange(e):1,r=t?t.opacities:{},o=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=r[e];o?(this.opacities[e]=new ht(o,n,t.text,t.icon),i||(i=t.text!==o.text.placed),i||(i=t.icon!==o.icon.placed)):(this.opacities[e]=new ht(null,n,t.text,t.icon,t.skipFade),i||(i=t.text||t.icon))}for(const e in r){const t=r[e];if(!this.opacities[e]){const r=new ht(t,n,!1,!1);r.isHidden()||(this.opacities[e]=r,i||(i=t.text.placed),i||(i=t.icon.placed))}}for(const e in o)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=o[e]);for(const e in s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);if(t&&void 0===t.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){const i={};for(const n of t){const t=n.getBucket(e);t&&n.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,n.tileID,i,n.collisionBoxArray)}}updateBucketOpacities(e,i,n,r){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const o=e.layers[0],s=o.layout,a=new ht(null,0,!1,!1,!0),l=s.get("text-allow-overlap"),c=s.get("icon-allow-overlap"),u=o._unevaluatedLayout.hasValue("text-variable-anchor")||o._unevaluatedLayout.hasValue("text-variable-anchor-offset"),h="map"===s.get("text-rotation-alignment"),d="map"===s.get("text-pitch-alignment"),p="none"!==s.get("icon-text-fit"),f=new ht(null,0,l&&(c||!e.hasIconData()||s.get("icon-optional")),c&&(l||!e.hasTextData()||s.get("text-optional")),!0);!e.collisionArrays&&r&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(r);const m=(e,t,i)=>{for(let n=0;n<t/4;n++)e.opacityVertexArray.emplaceBack(i);e.hasVisibleVertices||(e.hasVisibleVertices=i!==It)},g=this.collisionBoxArrays.get(e.bucketInstanceId);for(let i=0;i<e.symbolInstances.length;i++){const r=e.symbolInstances.get(i),{numHorizontalGlyphVertices:o,numVerticalGlyphVertices:s,crossTileID:l}=r;let c=this.opacities[l];n[l]?c=a:c||(c=f,this.opacities[l]=c),n[l]=!0;const y=r.numIconVertices>0,_=this.placedOrientations[r.crossTileID],v=_===t.ax.vertical,x=_===t.ax.horizontal||_===t.ax.horizontalOnly;if(o>0||s>0){const t=St(c.text);m(e.text,o,v?It:t),m(e.text,s,x?It:t);const i=c.text.isHidden(),n=[r.rightJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.leftJustifiedTextSymbolIndex];for(const t of n)t>=0&&(e.text.placedSymbolArray.get(t).hidden=i||v?1:0);r.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).hidden=i||x?1:0);const a=this.variableOffsets[r.crossTileID];a&&this.markUsedJustification(e,a.anchor,r,_);const l=this.placedOrientations[r.crossTileID];l&&(this.markUsedJustification(e,"left",r,l),this.markUsedOrientation(e,l,r))}if(y){const t=St(c.icon),i=!(p&&r.verticalPlacedIconSymbolIndex&&v);r.placedIconSymbolIndex>=0&&(m(e.icon,r.numIconVertices,i?t:It),e.icon.placedSymbolArray.get(r.placedIconSymbolIndex).hidden=c.icon.isHidden()),r.verticalPlacedIconSymbolIndex>=0&&(m(e.icon,r.numVerticalIconVertices,i?It:t),e.icon.placedSymbolArray.get(r.verticalPlacedIconSymbolIndex).hidden=c.icon.isHidden())}const b=(null==g?void 0:g.has(i))?g.get(i):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const n=e.collisionArrays[i];if(n){let i=new t.P(0,0);if(n.textBox||n.verticalTextBox){let t=!0;if(u){const e=this.variableOffsets[l];e?(i=mt(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),h&&i._rotate(d?-this.transform.bearingInRadians:this.transform.bearingInRadians)):t=!1}if(n.textBox||n.verticalTextBox){let r;n.textBox&&(r=v),n.verticalTextBox&&(r=x),yt(e.textCollisionBox.collisionVertexArray,c.text.placed,!t||r,b.text,i.x,i.y)}}if(n.iconBox||n.verticalIconBox){const t=Boolean(!x&&n.verticalIconBox);let r;n.iconBox&&(r=t),n.verticalIconBox&&(r=!t),yt(e.iconCollisionBox.collisionVertexArray,c.icon.placed,r,b.icon,p?i.x:0,p?i.y:0)}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId])}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,t){const i=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*i>e}setStale(){this.stale=!0}}function yt(e,t,i,n,r,o){n&&0!==n.length||(n=[0,0,0,0]);const s=n[0]-lt,a=n[1]-lt,l=n[2]-lt,c=n[3]-lt;e.emplaceBack(t?1:0,i?1:0,r||0,o||0,s,a),e.emplaceBack(t?1:0,i?1:0,r||0,o||0,l,a),e.emplaceBack(t?1:0,i?1:0,r||0,o||0,l,c),e.emplaceBack(t?1:0,i?1:0,r||0,o||0,s,c)}const _t=Math.pow(2,25),vt=Math.pow(2,24),xt=Math.pow(2,17),bt=Math.pow(2,16),wt=Math.pow(2,9),Et=Math.pow(2,8),Tt=Math.pow(2,1);function St(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,i=Math.floor(127*e.opacity);return i*_t+t*vt+i*xt+t*bt+i*wt+t*Et+i*Tt+t}const It=0;class kt{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,t,i,n,r){const o=this._bucketParts;for(;this._currentTileIndex<e.length;)if(t.getBucketParts(o,n,e[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,r())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,o.sort((e,t)=>e.sortKey-t.sortKey));this._currentPartIndex<o.length;)if(t.placeLayerBucketPart(o[this._currentPartIndex],this._seenCrossTileIDs,i),this._currentPartIndex++,r())return!0;return!1}}class Mt{constructor(e,t,i,n,r,o,s,a){this.placement=new gt(e,t,o,s,a),this._currentPlacementIndex=i.length-1,this._forceFullPlacement=n,this._showCollisionBoxes=r,this._done=!1}isDone(){return this._done}continuePlacement(e,i,n){const r=c(),o=()=>!this._forceFullPlacement&&c()-r>2;for(;this._currentPlacementIndex>=0;){const r=i[e[this._currentPlacementIndex]],s=this.placement.collisionIndex.transform.zoom;if(t.aQ(r)&&r.layout&&(!r.minzoom||r.minzoom<=s)&&(!r.maxzoom||r.maxzoom>s)){if(this._inProgressLayer||(this._inProgressLayer=new kt(r)),this._inProgressLayer.continuePlacement(n[r.source],this.placement,this._showCollisionBoxes,r,o))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Ct=512/t.a6/2;class Pt{constructor(e,i,n){this.tileID=e,this.bucketInstanceId=n,this._symbolsByKey={};const r=new Map;for(let e=0;e<i.length;e++){const t=i.get(e),n=t.key,o=r.get(n);o?o.push(t):r.set(n,[t])}for(const[e,i]of r){const n={positions:i.map(e=>({x:Math.floor(e.anchorX*Ct),y:Math.floor(e.anchorY*Ct)})),crossTileIDs:i.map(e=>e.crossTileID)};if(n.positions.length>128){const e=new t.aR(n.positions.length,16,Uint16Array);for(const{x:t,y:i}of n.positions)e.add(t,i);e.finish(),delete n.positions,n.index=e}this._symbolsByKey[e]=n}}getScaledCoordinates(e,i){const{x:n,y:r,z:o}=this.tileID.canonical,{x:s,y:a,z:l}=i.canonical,c=Ct/Math.pow(2,l-o),u=(a*t.a6+e.anchorY)*c,h=r*t.a6*Ct;return{x:Math.floor((s*t.a6+e.anchorX)*c-n*t.a6*Ct),y:Math.floor(u-h)}}findMatches(e,t,i){const n=this.tileID.canonical.z<t.canonical.z?1:Math.pow(2,this.tileID.canonical.z-t.canonical.z);for(let r=0;r<e.length;r++){const o=e.get(r);if(o.crossTileID)continue;const s=this._symbolsByKey[o.key];if(!s)continue;const a=this.getScaledCoordinates(o,t);if(s.index){const e=s.index.range(a.x-n,a.y-n,a.x+n,a.y+n).sort();for(const t of e){const e=s.crossTileIDs[t];if(!i[e]){i[e]=!0,o.crossTileID=e;break}}}else if(s.positions)for(let e=0;e<s.positions.length;e++){const t=s.positions[e],r=s.crossTileIDs[e];if(Math.abs(t.x-a.x)<=n&&Math.abs(t.y-a.y)<=n&&!i[r]){i[r]=!0,o.crossTileID=r;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map(({crossTileIDs:e})=>e)}}class At{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Lt{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const t=Math.round((e-this.lng)/360);if(0!==t)for(const e in this.indexes){const i=this.indexes[e],n={};for(const e in i){const r=i[e];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),n[r.tileID.key]=r}this.indexes[e]=n}this.lng=e}addBucket(e,t,i){var n,r,o;if(null===(n=this.indexes[e.overscaledZ])||void 0===n?void 0:n[e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let e=0;e<t.symbolInstances.length;e++)t.symbolInstances.get(e).crossTileID=0;(r=this.usedCrossTileIDs)[o=e.overscaledZ]||(r[o]={});const s=this.usedCrossTileIDs[e.overscaledZ];for(const i in this.indexes){const n=this.indexes[i];if(Number(i)>e.overscaledZ)for(const i in n){const r=n[i];r.tileID.isChildOf(e)&&r.findMatches(t.symbolInstances,e,s)}else{const r=n[e.scaledTo(Number(i)).key];r&&r.findMatches(t.symbolInstances,e,s)}}for(let e=0;e<t.symbolInstances.length;e++){const n=t.symbolInstances.get(e);n.crossTileID||(n.crossTileID=i.generate(),s[n.crossTileID]=!0)}return void 0===this.indexes[e.overscaledZ]&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new Pt(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(const i of t.getCrossTileIDsLists())for(const t of i)delete this.usedCrossTileIDs[e][t]}removeStaleBuckets(e){let t=!1;for(const i in this.indexes){const n=this.indexes[i];for(const r in n)e[n[r].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,n[r]),delete n[r],t=!0)}return t}}class Dt{constructor(){this.layerIndexes={},this.crossTileIDs=new At,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,t,i){let n=this.layerIndexes[e.id];void 0===n&&(n=this.layerIndexes[e.id]=new Lt);let r=!1;const o={};n.handleWrapJump(i);for(const i of t){const t=i.getBucket(e);e.id===(null==t?void 0:t.layerIds[0])&&(t.bucketInstanceId||(this.maxBucketInstanceId+=1,t.bucketInstanceId=this.maxBucketInstanceId),n.addBucket(i.tileID,t,this.crossTileIDs)&&(r=!0),o[t.bucketInstanceId]=!0)}return n.removeStaleBuckets(o)&&(r=!0),r}pruneUnusedLayers(e){const t={};for(const i of e)t[i]=!0;for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}var Rt="void main() {fragColor=vec4(1.0);}";const zt={prelude:Ft("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}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\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst 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) {\n#ifdef TERRAIN3D\nhighp 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));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 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;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;"),projectionMercator:Ft("","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:Ft("","#define GLOBE_RADIUS 6371008.8\nuniform 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;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\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); \nif (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;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len\n);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) {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) {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:Ft("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:Ft("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;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","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;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:Ft("in vec3 v_data;in float v_visibility;\n#pragma _mbx: define highp vec4 color\n#pragma _mbx: define mediump float radius\n#pragma _mbx: define lowp float blur\n#pragma _mbx: define lowp float opacity\n#pragma _mbx: define highp vec4 stroke_color\n#pragma _mbx: define mediump float stroke_width\n#pragma _mbx: define lowp float stroke_opacity\nvoid main() {\n#pragma _mbx: initialize highp vec4 color\n#pragma _mbx: initialize mediump float radius\n#pragma _mbx: initialize lowp float blur\n#pragma _mbx: initialize lowp float opacity\n#pragma _mbx: initialize highp vec4 stroke_color\n#pragma _mbx: initialize mediump float stroke_width\n#pragma _mbx: initialize lowp float stroke_opacity\nvec2 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/(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;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","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 lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility;\n#pragma _mbx: define highp vec4 color\n#pragma _mbx: define mediump float radius\n#pragma _mbx: define lowp float blur\n#pragma _mbx: define lowp float opacity\n#pragma _mbx: define highp vec4 stroke_color\n#pragma _mbx: define mediump float stroke_width\n#pragma _mbx: define lowp float stroke_opacity\nvoid main(void) {\n#pragma _mbx: initialize highp vec4 color\n#pragma _mbx: initialize mediump float radius\n#pragma _mbx: initialize lowp float blur\n#pragma _mbx: initialize lowp float opacity\n#pragma _mbx: initialize highp vec4 stroke_color\n#pragma _mbx: initialize mediump float stroke_width\n#pragma _mbx: initialize lowp float stroke_opacity\nvec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat 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 {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_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);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} 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);}"),clippingMask:Ft(Rt,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:Ft("uniform highp float u_intensity;in vec2 v_extrude;\n#pragma _mbx: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma _mbx: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out vec2 v_extrude;\n#pragma _mbx: define highp float weight\n#pragma _mbx: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma _mbx: initialize highp float weight\n#pragma _mbx: initialize mediump float radius\nvec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/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=floor(pos_raw/8.0);\n#ifdef GLOBE\nvec2 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);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:Ft("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;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:Ft("in float v_placed;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;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;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:Ft("in float v_radius;in vec2 v_extrude;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;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;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:Ft("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform 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) {float x=(float(stop)+0.5)/float(u_color_ramp_size);vec4 data=texture(u_elevation_stops,vec2(x,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\n{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));\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_dimension;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.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:Ft("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);}","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:Ft(Rt,"in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:Ft("#pragma _mbx: define highp vec4 color\n#pragma _mbx: define lowp float opacity\nvoid main() {\n#pragma _mbx: initialize highp vec4 color\n#pragma _mbx: initialize lowp float opacity\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;in vec2 a_pos;\n#pragma _mbx: define highp vec4 color\n#pragma _mbx: define lowp float opacity\nvoid main() {\n#pragma _mbx: initialize highp vec4 color\n#pragma _mbx: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:Ft("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma _mbx: define highp vec4 outline_color\n#pragma _mbx: define lowp float opacity\nvoid main() {\n#pragma _mbx: initialize highp vec4 outline_color\n#pragma _mbx: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma _mbx: define highp vec4 outline_color\n#pragma _mbx: define lowp float opacity\nvoid main() {\n#pragma _mbx: initialize highp vec4 outline_color\n#pragma _mbx: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:Ft("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma _mbx: define lowp float opacity\n#pragma _mbx: define lowp vec4 pattern_from\n#pragma _mbx: define lowp vec4 pattern_to\nvoid main() {\n#pragma _mbx: initialize lowp float opacity\n#pragma _mbx: initialize mediump vec4 pattern_from\n#pragma _mbx: initialize mediump vec4 pattern_to\nvec2 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);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma _mbx: define lowp float opacity\n#pragma _mbx: define lowp vec4 pattern_from\n#pragma _mbx: define lowp vec4 pattern_to\n#pragma _mbx: define lowp float pixel_ratio_from\n#pragma _mbx: define lowp float pixel_ratio_to\nvoid main() {\n#pragma _mbx: initialize lowp float opacity\n#pragma _mbx: initialize mediump vec4 pattern_from\n#pragma _mbx: initialize mediump vec4 pattern_to\n#pragma _mbx: initialize lowp float pixel_ratio_from\n#pragma _mbx: initialize lowp float pixel_ratio_to\nvec2 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;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:Ft("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma _mbx: define lowp float opacity\n#pragma _mbx: define lowp vec4 pattern_from\n#pragma _mbx: define lowp vec4 pattern_to\nvoid main() {\n#pragma _mbx: initialize lowp float opacity\n#pragma _mbx: initialize mediump vec4 pattern_from\n#pragma _mbx: initialize mediump vec4 pattern_to\nvec2 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);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma _mbx: define lowp float opacity\n#pragma _mbx: define lowp vec4 pattern_from\n#pragma _mbx: define lowp vec4 pattern_to\n#pragma _mbx: define lowp float pixel_ratio_from\n#pragma _mbx: define lowp float pixel_ratio_to\nvoid main() {\n#pragma _mbx: initialize lowp float opacity\n#pragma _mbx: initialize mediump vec4 pattern_from\n#pragma _mbx: initialize mediump vec4 pattern_to\n#pragma _mbx: initialize lowp float pixel_ratio_from\n#pragma _mbx: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=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:Ft("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","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;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma _mbx: define highp float base\n#pragma _mbx: define highp float height\n#pragma _mbx: define highp vec4 color\nvoid main() {\n#pragma _mbx: initialize highp float base\n#pragma _mbx: initialize highp float height\n#pragma _mbx: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat 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);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:Ft("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;\n#pragma _mbx: define lowp float base\n#pragma _mbx: define lowp float height\n#pragma _mbx: define lowp vec4 pattern_from\n#pragma _mbx: define lowp vec4 pattern_to\n#pragma _mbx: define lowp float pixel_ratio_from\n#pragma _mbx: define lowp float pixel_ratio_to\nvoid main() {\n#pragma _mbx: initialize lowp float base\n#pragma _mbx: initialize lowp float height\n#pragma _mbx: initialize mediump vec4 pattern_from\n#pragma _mbx: initialize mediump vec4 pattern_to\n#pragma _mbx: initialize lowp float pixel_ratio_from\n#pragma _mbx: initialize lowp float pixel_ratio_to\nvec2 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;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","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;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;\n#pragma _mbx: define lowp float base\n#pragma _mbx: define lowp float height\n#pragma _mbx: define lowp vec4 pattern_from\n#pragma _mbx: define lowp vec4 pattern_to\n#pragma _mbx: define lowp float pixel_ratio_from\n#pragma _mbx: define lowp float pixel_ratio_to\nvoid main() {\n#pragma _mbx: initialize lowp float base\n#pragma _mbx: initialize lowp float height\n#pragma _mbx: initialize mediump vec4 pattern_from\n#pragma _mbx: initialize mediump vec4 pattern_to\n#pragma _mbx: initialize lowp float pixel_ratio_from\n#pragma _mbx: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: 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+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:Ft("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(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);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:Ft("uniform sampler2D u_image;in 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];\n#define PI 3.141592653589793\n#define STANDARD 0\n#define COMBINED 1\n#define IGOR 2\n#define MULTIDIRECTIONAL 3\n#define BASIC 4\nfloat 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\n{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\n{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() {vec4 pixel=texture(u_image,v_pos);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);}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;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:Ft("uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma _mbx: define highp vec4 color\n#pragma _mbx: define lowp float blur\n#pragma _mbx: define lowp float opacity\nvoid main() {\n#pragma _mbx: initialize highp vec4 color\n#pragma _mbx: initialize lowp float blur\n#pragma _mbx: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma _mbx: define highp vec4 color\n#pragma _mbx: define lowp float blur\n#pragma _mbx: define lowp float opacity\n#pragma _mbx: define mediump float gapwidth\n#pragma _mbx: define lowp float offset\n#pragma _mbx: define mediump float width\nvoid main() {\n#pragma _mbx: initialize highp vec4 color\n#pragma _mbx: initialize lowp float blur\n#pragma _mbx: initialize lowp float opacity\n#pragma _mbx: initialize mediump float gapwidth\n#pragma _mbx: initialize lowp float offset\n#pragma _mbx: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);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;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat 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;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:Ft("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma _mbx: define lowp float blur\n#pragma _mbx: define lowp float opacity\nvoid main() {\n#pragma _mbx: initialize lowp float blur\n#pragma _mbx: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma _mbx: define lowp float blur\n#pragma _mbx: define lowp float opacity\n#pragma _mbx: define mediump float gapwidth\n#pragma _mbx: define lowp float offset\n#pragma _mbx: define mediump float width\nvoid main() {\n#pragma _mbx: initialize lowp float blur\n#pragma _mbx: initialize lowp float opacity\n#pragma _mbx: initialize mediump float gapwidth\n#pragma _mbx: initialize lowp float offset\n#pragma _mbx: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);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;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat 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;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:Ft("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma _mbx: define lowp vec4 pattern_from\n#pragma _mbx: define lowp vec4 pattern_to\n#pragma _mbx: define lowp float pixel_ratio_from\n#pragma _mbx: define lowp float pixel_ratio_to\n#pragma _mbx: define lowp float blur\n#pragma _mbx: define lowp float opacity\nvoid main() {\n#pragma _mbx: initialize mediump vec4 pattern_from\n#pragma _mbx: initialize mediump vec4 pattern_to\n#pragma _mbx: initialize lowp float pixel_ratio_from\n#pragma _mbx: initialize lowp float pixel_ratio_to\n#pragma _mbx: initialize lowp float blur\n#pragma _mbx: initialize lowp float opacity\nvec2 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;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma _mbx: define lowp float blur\n#pragma _mbx: define lowp float opacity\n#pragma _mbx: define lowp float offset\n#pragma _mbx: define mediump float gapwidth\n#pragma _mbx: define mediump float width\n#pragma _mbx: define lowp float floorwidth\n#pragma _mbx: define lowp vec4 pattern_from\n#pragma _mbx: define lowp vec4 pattern_to\n#pragma _mbx: define lowp float pixel_ratio_from\n#pragma _mbx: define lowp float pixel_ratio_to\nvoid main() {\n#pragma _mbx: initialize lowp float blur\n#pragma _mbx: initialize lowp float opacity\n#pragma _mbx: initialize lowp float offset\n#pragma _mbx: initialize mediump float gapwidth\n#pragma _mbx: initialize mediump float width\n#pragma _mbx: initialize lowp float floorwidth\n#pragma _mbx: initialize mediump vec4 pattern_from\n#pragma _mbx: initialize mediump vec4 pattern_to\n#pragma _mbx: initialize lowp float pixel_ratio_from\n#pragma _mbx: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);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;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat 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;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:Ft("uniform lowp float u_device_pixel_ratio;uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma _mbx: define highp vec4 color\n#pragma _mbx: define lowp float blur\n#pragma _mbx: define lowp float opacity\n#pragma _mbx: define mediump float width\n#pragma _mbx: define lowp float floorwidth\n#pragma _mbx: define mediump vec4 dasharray_from\n#pragma _mbx: define mediump vec4 dasharray_to\nvoid main() {\n#pragma _mbx: initialize highp vec4 color\n#pragma _mbx: initialize lowp float blur\n#pragma _mbx: initialize lowp float opacity\n#pragma _mbx: initialize mediump float width\n#pragma _mbx: initialize lowp float floorwidth\n#pragma _mbx: initialize mediump vec4 dasharray_from\n#pragma _mbx: initialize mediump vec4 dasharray_to\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);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);float 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);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma _mbx: define highp vec4 color\n#pragma _mbx: define lowp float blur\n#pragma _mbx: define lowp float opacity\n#pragma _mbx: define mediump float gapwidth\n#pragma _mbx: define lowp float offset\n#pragma _mbx: define mediump float width\n#pragma _mbx: define lowp float floorwidth\n#pragma _mbx: define mediump vec4 dasharray_from\n#pragma _mbx: define mediump vec4 dasharray_to\nvoid main() {\n#pragma _mbx: initialize highp vec4 color\n#pragma _mbx: initialize lowp float blur\n#pragma _mbx: initialize lowp float opacity\n#pragma _mbx: initialize mediump float gapwidth\n#pragma _mbx: initialize lowp float offset\n#pragma _mbx: initialize mediump float width\n#pragma _mbx: initialize lowp float floorwidth\n#pragma _mbx: initialize mediump vec4 dasharray_from\n#pragma _mbx: initialize mediump vec4 dasharray_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);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;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat 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;\n#endif\nfloat 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:Ft("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma _mbx: define lowp float blur\n#pragma _mbx: define lowp float opacity\n#pragma _mbx: define mediump float width\n#pragma _mbx: define lowp float floorwidth\n#pragma _mbx: define mediump vec4 dasharray_from\n#pragma _mbx: define mediump vec4 dasharray_to\nvoid main() {\n#pragma _mbx: initialize lowp float blur\n#pragma _mbx: initialize lowp float opacity\n#pragma _mbx: initialize mediump float width\n#pragma _mbx: initialize lowp float floorwidth\n#pragma _mbx: initialize mediump vec4 dasharray_from\n#pragma _mbx: initialize mediump vec4 dasharray_to\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);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);float 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);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;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;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma _mbx: define lowp float blur\n#pragma _mbx: define lowp float opacity\n#pragma _mbx: define mediump float gapwidth\n#pragma _mbx: define lowp float offset\n#pragma _mbx: define mediump float width\n#pragma _mbx: define lowp float floorwidth\n#pragma _mbx: define mediump vec4 dasharray_from\n#pragma _mbx: define mediump vec4 dasharray_to\nvoid main() {\n#pragma _mbx: initialize lowp float blur\n#pragma _mbx: initialize lowp float opacity\n#pragma _mbx: initialize mediump float gapwidth\n#pragma _mbx: initialize lowp float offset\n#pragma _mbx: initialize mediump float width\n#pragma _mbx: initialize lowp float floorwidth\n#pragma _mbx: initialize mediump vec4 dasharray_from\n#pragma _mbx: initialize mediump vec4 dasharray_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*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=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);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;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat 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;\n#endif\nfloat 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);}"),raster:Ft("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:Ft("uniform sampler2D u_texture;in vec2 v_tex;in float v_total_opacity;void main() {fragColor=texture(u_texture,v_tex)*v_total_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_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;out vec2 v_tex;out float v_total_opacity;\n#pragma _mbx: define lowp float opacity\nvoid main() {\n#pragma _mbx: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}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_fade_change :-u_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 ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=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;\n#ifdef GLOBE\nif(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);}\n#endif\nvec4 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:Ft("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform bool u_is_plain;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;\n#pragma _mbx: define highp vec4 fill_color\n#pragma _mbx: define highp vec4 halo_color\n#pragma _mbx: define lowp float halo_width\n#pragma _mbx: define lowp float halo_blur\nvoid main() {\n#pragma _mbx: initialize highp vec4 fill_color\n#pragma _mbx: initialize highp vec4 halo_color\n#pragma _mbx: initialize lowp float halo_width\n#pragma _mbx: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float 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;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_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 highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1;\n#pragma _mbx: define highp vec4 fill_color\n#pragma _mbx: define highp vec4 halo_color\n#pragma _mbx: define lowp float opacity\n#pragma _mbx: define lowp float halo_width\n#pragma _mbx: define lowp float halo_blur\nvoid main() {\n#pragma _mbx: initialize highp vec4 fill_color\n#pragma _mbx: initialize highp vec4 halo_color\n#pragma _mbx: initialize lowp float opacity\n#pragma _mbx: initialize lowp float halo_width\n#pragma _mbx: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy/16.0;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}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_fade_change :-u_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 ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=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;\n#ifdef GLOBE\nif(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);}\n#endif\nvec4 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:Ft("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform bool u_is_text;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;in vec4 v_data0;in vec4 v_data1;\n#pragma _mbx: define highp vec4 fill_color\n#pragma _mbx: define highp vec4 halo_color\n#pragma _mbx: define lowp float halo_width\n#pragma _mbx: define lowp float halo_blur\nvoid main() {\n#pragma _mbx: initialize highp vec4 fill_color\n#pragma _mbx: initialize highp vec4 halo_color\n#pragma _mbx: initialize lowp float halo_width\n#pragma _mbx: initialize lowp float halo_blur\nfloat total_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;fragColor=texture(u_texture_icon,tex_icon)*total_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;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;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out vec4 v_data1;\n#pragma _mbx: define highp vec4 fill_color\n#pragma _mbx: define highp vec4 halo_color\n#pragma _mbx: define lowp float opacity\n#pragma _mbx: define lowp float halo_width\n#pragma _mbx: define lowp float halo_blur\nvoid main() {\n#pragma _mbx: initialize highp vec4 fill_color\n#pragma _mbx: initialize highp vec4 halo_color\n#pragma _mbx: initialize lowp float opacity\n#pragma _mbx: initialize lowp float halo_width\n#pragma _mbx: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}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_fade_change :-u_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 ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=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;\n#ifdef GLOBE\nif(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);}\n#endif\nvec4 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=vec4(gamma_scale,size,total_opacity,is_sdf);}"),terrain:Ft("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);float 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;}}","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:Ft("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);}","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;}"),terrainCoords:Ft("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;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);}"),projectionErrorMeasurement:Ft("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:Ft("#ifdef GL_ES\nprecision highp float;\n#endif\nin 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\n);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;}","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:Ft("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;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;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(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function Ft(e,t){const i=/#pragma _mbx: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,n=t.match(/in ([\w]+) ([\w]+)/g),r=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=o?o.concat(r):r,a={};return{fragmentSource:e=e.replace(i,(e,t,i,n,r)=>(a[r]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nin ${i} ${n} ${r};\n#else\nuniform ${i} ${n} u_${r};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${r}\n ${i} ${n} ${r} = u_${r};\n#endif\n`)),vertexSource:t=t.replace(i,(e,t,i,n,r)=>{const o="float"===n?"vec2":"vec4",s=r.match(/color/)?"color":o;return a[r]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nuniform lowp float u_${r}_t;\nin ${i} ${o} a_${r};\nout ${i} ${n} ${r};\n#else\nuniform ${i} ${n} u_${r};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${r}\n ${r} = a_${r};\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${r}\n ${r} = unpack_mix_${s}(a_${r}, u_${r}_t);\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nuniform lowp float u_${r}_t;\nin ${i} ${o} a_${r};\n#else\nuniform ${i} ${n} u_${r};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${r}\n ${i} ${n} ${r} = a_${r};\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${r}\n ${i} ${n} ${r} = unpack_mix_${s}(a_${r}, u_${r}_t);\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`}),staticAttributes:n,staticUniforms:s}}class Ot{constructor(e,t,i){this.vertexBuffer=e,this.indexBuffer=t,this.segments=i}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Nt=t.aS([{name:"a_pos",type:"Int16",components:2}]);const Bt="#define PROJECTION_MERCATOR",Gt="mercator";class jt{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return Gt}get shaderDefine(){return Bt}get shaderPreludeCode(){return zt.projectionMercator}get vertexShaderPreludeCode(){return zt.projectionMercator.vertexSource}get subdivisionGranularity(){return t.aT.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,i,n,r,o){if(this._cachedMesh)return this._cachedMesh;const s=new t.aU;s.emplaceBack(0,0),s.emplaceBack(t.a6,0),s.emplaceBack(0,t.a6),s.emplaceBack(t.a6,t.a6);const a=e.createVertexBuffer(s,Nt.members),l=t.aV.simpleSegment(0,0,4,2),c=new t.aW;c.emplaceBack(1,0,2),c.emplaceBack(1,2,3);const u=e.createIndexBuffer(c);return this._cachedMesh=new Ot(a,u,l),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class Vt{constructor(e=0,t=0,i=0,n=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(n)||n<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=n}interpolate(e,i,n){return null!=i.top&&null!=e.top&&(this.top=t.H.number(e.top,i.top,n)),null!=i.bottom&&null!=e.bottom&&(this.bottom=t.H.number(e.bottom,i.bottom,n)),null!=i.left&&null!=e.left&&(this.left=t.H.number(e.left,i.left,n)),null!=i.right&&null!=e.right&&(this.right=t.H.number(e.right,i.right,n)),this}getCenter(e,i){const n=t.al((this.left+e-this.right)/2,0,e),r=t.al((this.top+i-this.bottom)/2,0,i);return new t.P(n,r)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Vt(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Ut(e,t){if(!e.renderWorldCopies||e.lngRange)return;const i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0}function qt(e){return Math.max(0,Math.floor(e))}class Zt{constructor(e,i){var n;this.applyConstrain=(e,t)=>null!==this._constrainOverride?this._constrainOverride(e,t):this._callbacks.defaultConstrain(e,t),this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===(null==i?void 0:i.renderWorldCopies)||!!(null==i?void 0:i.renderWorldCopies),this._minZoom=(null==i?void 0:i.minZoom)||0,this._maxZoom=(null==i?void 0:i.maxZoom)||22,this._minPitch=null==(null==i?void 0:i.minPitch)?0:null==i?void 0:i.minPitch,this._maxPitch=null==(null==i?void 0:i.maxPitch)?60:null==i?void 0:i.maxPitch,this._constrainOverride=null!==(n=null==i?void 0:i.constrainOverride)&&void 0!==n?n:null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new t.W(0,0),this._elevation=0,this._zoom=0,this._tileZoom=qt(this._zoom),this._scale=t.ao(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Vt,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,i,n){this._constrainOverride=e.constrainOverride,this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=qt(this._zoom),this._scale=t.ao(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new Vt(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!n&&e.autoCalculateNearFarZ,i&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}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(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)))}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get constrainOverride(){return this._constrainOverride}setConstrainOverride(e){void 0===e&&(e=null),this._constrainOverride!==e&&(this._constrainOverride=e,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 t.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const i=t.X(e,-180,180)*Math.PI/180;var r,o,s,a,l,c,u,h,d;this._bearingInRadians!==i&&(this._unmodified=!1,this._bearingInRadians=i,this._calcMatrices(),this._rotationMatrix=n(),r=this._rotationMatrix,s=-this._bearingInRadians,a=(o=this._rotationMatrix)[0],l=o[1],c=o[2],u=o[3],h=Math.sin(s),d=Math.cos(s),r[0]=a*d+c*h,r[1]=l*d+u*h,r[2]=a*-h+c*d,r[3]=l*-h+u*d)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const i=t.al(e,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(e){const t=e/180*Math.PI;this._rollInRadians!==t&&(this._unmodified=!1,this._rollInRadians=t,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return t.aX(this._fovInRadians)}setFov(e){e=t.al(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=t.an(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){const i=this.applyConstrain(this._center,e).zoom;this._zoom!==i&&(this._unmodified=!1,this._zoom=i,this._tileZoom=Math.max(0,Math.floor(i)),this._scale=t.ao(i),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,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(e,t){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=t,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this.constrainInternal(),this._calcMatrices()}resize(e,t,i=!0){this._width=e,this._height=t,i&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){var e,t;return 2!==(null===(e=this._latRange)||void 0===e?void 0:e.length)||2!==(null===(t=this._lngRange)||void 0===t?void 0:t.length)?null:new U([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]])}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-t.am,t.am])}getCameraQueryGeometry(e,i){if(1===i.length)return[i[0],e];{const{minX:n,minY:r,maxX:o,maxY:s}=t.a8.fromPoints(i).extend(e);return[new t.P(n,r),new t.P(o,r),new t.P(o,s),new t.P(n,s),new t.P(n,r)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:t,zoom:i}=this.applyConstrain(this.center,this.zoom);this.setCenter(t),this.setZoom(i),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=t.ap(new Float64Array(16));t.S(e,e,[this._width/2,-this._height/2,1]),t.Q(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=t.ap(new Float64Array(16)),t.S(e,e,[1,-1,1]),t.Q(e,e,[-1,-1,0]),t.S(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,i,n,r){const o=void 0!==n?n:this.bearing,s=r=void 0!==r?r:this.pitch,{distanceToCenter:a,clampedElevation:l}=this._distanceToCenterFromAltElevationPitch(i,this.elevation,s),{x:c,y:u}=xe(s,o),h=t.a7.fromLngLat(e,i);let d,p,f=t.aY(1,h.y),m=0;do{if(m+=1,m>10)break;p=a/f,d=new t.a7(h.x+c*p,h.y+u*p),f=1/d.meterInMercatorCoordinateUnits()}while(Math.abs(a-p*f)>1e-12);return{center:d.toLngLat(),elevation:l,zoom:t.ar(this.height/2/Math.tan(this.fovInRadians/2)/p/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const i=1/this.worldSize,n=t.aq(1,this.center.lat)*this.worldSize,r=t.a7.fromLngLat(this.center,this.elevation),o=r.x/i,s=r.y/i,a=r.z/i,l=this.pitch,c=this.bearing,{x:u,y:h,z:d}=xe(l,c),p=this.cameraToCenterDistance,f=o+p*-u,m=s+p*-h,g=a+p*d,{distanceToCenter:y,clampedElevation:_}=this._distanceToCenterFromAltElevationPitch(g/n,e,l),v=y*n,x=new t.a7((f+u*v)*i,(m+h*v)*i,0).toLngLat(),b=t.aq(1,x.lat),w=t.ar(this.height/2/Math.tan(this.fovInRadians/2)/y/b/this.tileSize);this._elevation=_,this._center=x,this.setZoom(w)}_distanceToCenterFromAltElevationPitch(e,i,n){const r=-Math.cos(t.an(n)),o=e-i;let s,a=i;return r*o>=0||Math.abs(r)<.1?(s=1e4,a=e+s*r):s=-o/r,{distanceToCenter:s,clampedElevation:a}}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const e=t.aq(1,this.center.lat)*this.worldSize;return ve(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];const i=e.canonical.z>=0?1<<e.canonical.z:Math.pow(2,e.canonical.z);return[e.canonical.x/i,e.canonical.y/i,1/i/t.a6,1/i/t.a6]}}class $t{constructor(e,i){this.min=e,this.max=i,this.center=t.aZ([],t.a_([],this.min,this.max),.5)}quadrant(e){const i=[e%2==0,e<2],n=t.a$(this.min),r=t.a$(this.max);for(let e=0;e<i.length;e++)n[e]=i[e]?this.min[e]:this.center[e],r[e]=i[e]?this.center[e]:this.max[e];return r[2]=this.max[2],new $t(n,r)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}intersectsFrustum(e){let t=!0;for(const i of e.planes){const e=this.intersectsPlane(i);if(0===e)return 0;1===e&&(t=!1)}return t?2:e.aabb.min[0]>this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]<this.min[0]||e.aabb.max[1]<this.min[1]||e.aabb.max[2]<this.min[2]?0:1}intersectsPlane(e){let t=e[3],i=e[3];for(let n=0;n<3;n++)e[n]>0?(t+=e[n]*this.min[n],i+=e[n]*this.max[n]):(i+=e[n]*this.min[n],t+=e[n]*this.max[n]);return t>=0?2:i<0?0:1}}class Ht{distanceToTile2d(e,t,i,n){const r=n,o=r.distanceX([e,t]),s=r.distanceY([e,t]);return Math.hypot(o,s)}getWrap(e,t,i){return i}getTileBoundingVolume(e,i,n,r){var o,s;let a=0,l=0;if(null==r?void 0:r.terrain){const c=new t.a3(e.z,i,e.z,e.x,e.y),u=r.terrain.getMinMaxElevation(c);a=null!==(o=u.minElevation)&&void 0!==o?o:Math.min(0,n),l=null!==(s=u.maxElevation)&&void 0!==s?s:Math.max(0,n)}const c=1<<e.z;return new $t([i+e.x/c,e.y/c,a],[i+(e.x+1)/c,(e.y+1)/c,l])}allowVariableZoom(e,i){const n=e.fov*(Math.abs(Math.cos(e.rollInRadians))*e.height+Math.abs(Math.sin(e.rollInRadians))*e.width)/e.height,r=t.al(78.5-n/2,0,60);return!!i.terrain||e.pitch>r}allowWorldCopies(){return!0}prepareNextFrame(){}}class Wt{constructor(e,t,i){this.points=e,this.planes=t,this.aabb=i}static fromInvProjectionMatrix(e,i=1,n=0,r,o){const s=o?[[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]],a=Math.pow(2,n),l=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(n=>function(e,i,n,r){const o=t.aE([],e,i),s=1/o[3]/n*r;return t.b4(o,o,[s,s,1/o[3],s])}(n,e,i,a));r&&function(e,i,n,r){const o=r?4:0,s=r?0:4;let a=0;const l=[],c=[];for(let i=0;i<4;i++){const n=t.b0([],e[i+s],e[i+o]),r=t.b5(n);t.aZ(n,n,1/r),l.push(r),c.push(n)}for(let i=0;i<4;i++){const r=t.b6(e[i+o],c[i],n);a=null!==r&&r>=0?Math.max(a,r):Math.max(a,l[i])}const u=function(e,i){const n=t.b0([],e[i[0]],e[i[1]]),r=t.b0([],e[i[2]],e[i[1]]),o=[0,0,0,0];return t.b1(o,t.b2([],n,r)),o[3]=-t.b3(o,e[i[0]]),o}(e,i),h=function(e,i){const n=t.b7(e),r=t.b8([],e,1/n),o=t.b0([],i,t.aZ([],r,t.b3(i,r))),s=t.b7(o);if(s>0){const e=Math.sqrt(1-r[3]*r[3]),n=t.aZ([],r,-r[3]),a=t.a_([],n,t.aZ([],o,e/s));return t.b9(i,a)}return null}(n,u);if(null!==h){const e=h/t.b3(c[0],u);a=Math.min(a,e)}for(let t=0;t<4;t++){const i=Math.min(a,l[t]);e[t+s]=[e[t+o][0]+c[t][0]*i,e[t+o][1]+c[t][1]*i,e[t+o][2]+c[t][2]*i,1]}}(l,s[0],r,o);const c=s.map(e=>{const i=t.b0([],l[e[0]],l[e[1]]),n=t.b0([],l[e[2]],l[e[1]]),r=t.b1([],t.b2([],i,n)),o=-t.b3(r,l[e[1]]);return r.concat(o)}),u=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],h=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const e of l)for(let t=0;t<3;t++)u[t]=Math.min(u[t],e[t]),h[t]=Math.max(h[t],e[t]);return new Wt(l,c,new $t(u,h))}}class Xt{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(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,i){this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}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(e,t){}constructor(e){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(e,i)=>{i=t.al(+i,this.minZoom,this.maxZoom);const n={center:new t.W(e.lng,e.lat),zoom:i};let r=this._helper._lngRange;if(!this._helper._renderWorldCopies&&null===r){const e=180-1e-10;r=[-e,e]}const o=this.tileSize*t.ao(n.zoom);let s=0,a=o,l=0,c=o,u=0,h=0;const{x:d,y:p}=this.size;if(this._helper._latRange){const e=this._helper._latRange;s=t.Y(e[1])*o,a=t.Y(e[0])*o,a-s<p&&(u=p/(a-s))}r&&(l=t.X(t.Z(r[0])*o,0,o),c=t.X(t.Z(r[1])*o,0,o),c<l&&(c+=o),c-l<d&&(h=d/(c-l)));const{x:f,y:m}=me(o,e);let g,y;const _=Math.max(h||0,u||0);if(_){const e=new t.P(h?(c+l)/2:f,u?(a+s)/2:m);return n.center=ge(o,e).wrap(),n.zoom+=t.ar(_),n}if(this._helper._latRange){const e=p/2;m-e<s&&(y=s+e),m+e>a&&(y=a-e)}if(r){const e=(l+c)/2;let i=f;this._helper._renderWorldCopies&&(i=t.X(f,e-o/2,e+o/2));const n=d/2;i-n<l&&(g=l+n),i+n>c&&(g=c-n)}if(void 0!==g||void 0!==y){const e=new t.P(null!=g?g:f,null!=y?y:m);n.center=ge(o,e).wrap()}return n},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Zt({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new Ht}clone(){const e=new Xt;return e.apply(this,!1),e}apply(e,t,i){this._helper.apply(e,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(e){const i=[new t.ba(0,e)];if(this._helper._renderWorldCopies){const n=this.screenPointToMercatorCoordinate(new t.P(0,0)),r=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,0)),o=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,this._helper._height)),s=this.screenPointToMercatorCoordinate(new t.P(0,this._helper._height)),a=Math.floor(Math.min(n.x,r.x,o.x,s.x)),l=Math.floor(Math.max(n.x,r.x,o.x,s.x)),c=1;for(let n=a-c;n<=l+c;n++)0!==n&&i.push(new t.ba(n,e))}return i}getCameraFrustum(){return Wt.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const t=this.screenPointToLocation(this.centerPoint,e),i=e?e.getElevationForLngLatZoom(t,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(i)}setLocationAtPoint(e,i){const n=t.aq(this.elevation,this.center.lat),r=this.screenPointToMercatorCoordinateAtZ(i,n),o=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,n),s=t.a7.fromLngLat(e),a=new t.a7(s.x-(r.x-o.x),s.y-(r.y-o.y));this.setCenter(null==a?void 0:a.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,i){return i?this.coordinatePoint(t.a7.fromLngLat(e),i.getElevationForLngLat(e,this),this._pixelMatrix3D):this.coordinatePoint(t.a7.fromLngLat(e))}screenPointToLocation(e,t){var i;return null===(i=this.screenPointToMercatorCoordinate(e,t))||void 0===i?void 0:i.toLngLat()}screenPointToMercatorCoordinate(e,t){if(t){const i=t.pointCoordinate(e);if(null!=i)return i}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,i){const n=i||0,r=[e.x,e.y,0,1],o=[e.x,e.y,1,1];t.aE(r,r,this._pixelMatrixInverse),t.aE(o,o,this._pixelMatrixInverse);const s=r[3],a=o[3],l=r[1]/s,c=o[1]/a,u=r[2]/s,h=o[2]/a,d=u===h?0:(n-u)/(h-u);return new t.a7(t.H.number(r[0]/s,o[0]/a,d)/this.worldSize,t.H.number(l,c,d)/this.worldSize,n)}coordinatePoint(e,i=0,n=this._pixelMatrix){const r=[e.x*this.worldSize,e.y*this.worldSize,i,1];return t.aE(r,r,n),new t.P(r[0]/r[3],r[1]/r[3])}getBounds(){const e=Math.max(0,this._helper._height/2-ye(this));return(new U).extend(this.screenPointToLocation(new t.P(0,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new t.P(0,this._helper._height)))}isPointOnMapSurface(e,t){return t?null!=t.pointCoordinate(e):e.y>this.height/2-ye(this)}calculatePosMatrix(e,i=!1,n){var r;const o=null!==(r=e.key)&&void 0!==r?r:t.bb(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),s=i?this._alignedPosMatrixCache:this._posMatrixCache;if(s.has(o)){const e=s.get(o);return n?e.f32:e.f64}const a=_e(e,this.worldSize);t.U(a,i?this._alignedProjMatrix:this._viewProjMatrix,a);const l={f64:a,f32:new Float32Array(a)};return s.set(o,l),n?l.f32:l.f64}calculateFogMatrix(e){const i=e.key,n=this._fogMatrixCacheF32;if(n.has(i))return n.get(i);const r=_e(e,this.worldSize);return t.U(r,this._fogMatrix,r),n.set(i,new Float32Array(r)),n.get(i)}calculateCenterFromCameraLngLatAlt(e,t,i,n){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,n)}_calculateNearFarZIfNeeded(e,i,n){if(!this._helper.autoCalculateNearFarZ)return;const r=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),o=e-r*this._helper._pixelPerMeter/Math.cos(i),s=r<0?o:e,a=Math.PI/2+this.pitchInRadians,l=t.an(this.fov)*(Math.abs(Math.cos(t.an(this.roll)))*this.height+Math.abs(Math.sin(t.an(this.roll)))*this.width)/this.height*(.5+n.y/this.height),c=Math.sin(l)*s/Math.sin(t.al(Math.PI-a-l,.01,Math.PI-.01)),u=ye(this),h=Math.atan(u/this._helper.cameraToCenterDistance),d=t.an(.75),p=h>d?2*h*(.5+n.y/(2*u)):d,f=Math.sin(p)*s/Math.sin(t.al(Math.PI-a-p,.01,Math.PI-.01)),m=Math.min(c,f);this._helper._farZ=1.01*(Math.cos(Math.PI/2-i)*m+s),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,i=me(this.worldSize,this.center),n=i.x,r=i.y;this._helper._pixelPerMeter=t.aq(1,this.center.lat)*this.worldSize;const o=t.an(Math.min(this.pitch,fe)),s=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(o));let a;var l,c;this._calculateNearFarZIfNeeded(s,o,e),a=new Float64Array(16),t.bc(a,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),(l=this._invProjMatrix)[0]=1/(c=a)[0],l[1]=0,l[2]=0,l[3]=0,l[4]=0,l[5]=1/c[5],l[6]=0,l[7]=0,l[8]=0,l[9]=0,l[10]=0,l[11]=1/c[14],l[12]=0,l[13]=0,l[14]=-1,l[15]=c[10]/c[14],a[8]=2*-e.x/this._helper._width,a[9]=2*e.y/this._helper._height,this._projectionMatrix=t.bd(a),t.S(a,a,[1,-1,1]),t.Q(a,a,[0,0,-this._helper.cameraToCenterDistance]),t.be(a,a,-this.rollInRadians),t.bf(a,a,this.pitchInRadians),t.be(a,a,-this.bearingInRadians),t.Q(a,a,[-n,-r,0]),this._mercatorMatrix=t.S([],a,[this.worldSize,this.worldSize,this.worldSize]),t.S(a,a,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=t.U(new Float64Array(16),this.clipSpaceToPixelsMatrix,a),t.Q(a,a,[0,0,-this.elevation]),this._viewProjMatrix=a,this._invViewProjMatrix=t.bg([],a);const u=[0,0,-1,1];t.aE(u,u,this._invViewProjMatrix),this._cameraPosition=[u[0]/u[3],u[1]/u[3],u[2]/u[3]],this._fogMatrix=new Float64Array(16),t.bc(this._fogMatrix,this.fovInRadians,this.width/this.height,s,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,t.S(this._fogMatrix,this._fogMatrix,[1,-1,1]),t.Q(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),t.be(this._fogMatrix,this._fogMatrix,-this.rollInRadians),t.bf(this._fogMatrix,this._fogMatrix,this.pitchInRadians),t.be(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),t.Q(this._fogMatrix,this._fogMatrix,[-n,-r,0]),t.S(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),t.Q(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=t.U(new Float64Array(16),this.clipSpaceToPixelsMatrix,a);const h=this._helper._width%2/2,d=this._helper._height%2/2,p=Math.cos(this.bearingInRadians),f=Math.sin(-this.bearingInRadians),m=n-Math.round(n)+p*h+f*d,g=r-Math.round(r)+p*d+f*h,y=new Float64Array(a);if(t.Q(y,y,[m>.5?m-1:m,g>.5?g-1:g,0]),this._alignedProjMatrix=y,a=t.bg(new Float64Array(16),this._pixelMatrix),!a)throw new 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;const e=this.screenPointToMercatorCoordinate(new t.P(0,0)),i=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.aE(i,i,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=t.aq(1,this.center.lat)*this.worldSize;return ve(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,i){const n=t.a7.fromLngLat(e),r=[n.x*this.worldSize,n.y*this.worldSize,i,1];return t.aE(r,r,this._viewProjMatrix),r[2]/r[3]}getProjectionData(e){const{overscaledTileID:i,aligned:n,applyTerrainMatrix:r}=e,o=this._helper.getMercatorTileCoordinates(i),s=i?this.calculatePosMatrix(i,n,!0):null;let a;return a=(null==i?void 0:i.terrainRttPosMatrix32f)&&r?i.terrainRttPosMatrix32f:s||t.bh(),{mainMatrix:a,tileMercatorCoords:o,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:a}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,t,i){return 1}transformLightDirection(e){return t.a$(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,i,n,r){const o=this.calculatePosMatrix(n);let s;r?(s=[e,i,r(e,i),1],t.aE(s,s,o)):(s=[e,i,0,1],at(s,s,o));const a=s[3];return{point:new t.P(s[0]/a,s[1]/a),signedDistanceFromCamera:a,isOccluded:!1}}populateCache(e){for(const t of e)this.calculatePosMatrix(t)}getMatrixForModel(e,i){const n=t.a7.fromLngLat(e,i),r=n.meterInMercatorCoordinateUnits(),o=t.bi();return t.Q(o,o,[n.x,n.y,n.z]),t.be(o,o,Math.PI),t.bf(o,o,Math.PI/2),t.S(o,o,[-r,r,r]),o}getProjectionDataForCustomLayer(e=!0){const i=new t.a3(0,0,0,0,0),n=this.getProjectionData({overscaledTileID:i,applyGlobeMatrix:e}),r=_e(i,this.worldSize);t.U(r,this._viewProjMatrix,r),n.tileMercatorCoords=[0,0,1,1];const o=[t.a6,t.a6,this.worldSize/this._helper.pixelsPerMeter],s=t.bj();return t.S(s,r,o),n.fallbackMatrix=s,n.mainMatrix=s,n}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function Yt(){t.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Jt(e){if(e.useSlerp)if(e.k<1){const i=t.bk(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),n=t.bk(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),r=new Float64Array(4);t.bl(r,i,n,e.k);const o=t.bm(r);e.tr.setRoll(o.roll),e.tr.setPitch(o.pitch),e.tr.setBearing(o.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(t.H.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(t.H.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(t.H.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function Kt(e,i,n,r,o){const s=o.padding,a=me(o.worldSize,n.getNorthWest()),l=me(o.worldSize,n.getNorthEast()),c=me(o.worldSize,n.getSouthEast()),u=me(o.worldSize,n.getSouthWest()),h=t.an(-r),d=a.rotate(h),p=l.rotate(h),f=c.rotate(h),m=u.rotate(h),g=new t.P(Math.max(d.x,p.x,m.x,f.x),Math.max(d.y,p.y,m.y,f.y)),y=new t.P(Math.min(d.x,p.x,m.x,f.x),Math.min(d.y,p.y,m.y,f.y)),_=g.sub(y),v=(o.width-(s.left+s.right+i.left+i.right))/_.x,x=(o.height-(s.top+s.bottom+i.top+i.bottom))/_.y;if(x<0||v<0)return void Yt();const b=Math.min(t.ar(o.scale*Math.min(v,x)),e.maxZoom),w=t.P.convert(e.offset),E=new t.P((i.left-i.right)/2,(i.top-i.bottom)/2).rotate(t.an(r)),T=w.add(E).mult(o.scale/t.ao(b));return{center:ge(o.worldSize,a.add(c).div(2).sub(T)),zoom:b,bearing:r}}class Qt{get useGlobeControls(){return!1}handlePanInertia(e,t){const i=e.mag(),n=Math.abs(ye(t));return{easingOffset:e.mult(Math.min(.75*n/i,1)),easingCenter:t.center}}handleMapControlsRollPitchBearingZoom(e,t){e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta),e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta)}handleMapControlsPan(e,t,i){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(i,e.around)}cameraForBoxAndBearing(e,t,i,n,r){return Kt(e,t,i,n,r)}handleJumpToCenterZoom(e,i){e.zoom!==(void 0!==i.zoom?+i.zoom:e.zoom)&&e.setZoom(+i.zoom),void 0!==i.center&&e.setCenter(t.W.convert(i.center))}handleEaseTo(e,i){const n=e.zoom,r=e.padding,o={roll:e.roll,pitch:e.pitch,bearing:e.bearing},s={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},a=void 0!==i.zoom,l=!e.isPaddingEqual(i.padding);let c=!1;const u=a?+i.zoom:e.zoom;let h=e.centerPoint.add(i.offsetAsPoint);const d=e.screenPointToLocation(h),{center:p,zoom:f}=e.applyConstrain(t.W.convert(i.center||d),null!=u?u:n);Ut(e,p);const m=me(e.worldSize,d),g=me(e.worldSize,p).sub(m),y=t.ao(f-n);return c=f!==n,{easeFunc:a=>{if(c&&e.setZoom(t.H.number(n,f,a)),t.bn(o,s)||Jt({startEulerAngles:o,endEulerAngles:s,tr:e,k:a,useSlerp:o.roll!=s.roll}),l&&(e.interpolatePadding(r,i.padding,a),h=e.centerPoint.add(i.offsetAsPoint)),i.around)e.setLocationAtPoint(i.around,i.aroundPoint);else{const i=t.ao(e.zoom-n),r=f>n?Math.min(2,y):Math.max(.5,y),o=Math.pow(r,1-a),s=ge(e.worldSize,m.add(g.mult(a*o)).mult(i));e.setLocationAtPoint(e.renderWorldCopies?s.wrap():s,h)}},isZooming:c,elevationCenter:p}}handleFlyTo(e,i){const n=void 0!==i.zoom,r=e.zoom,o=e.applyConstrain(t.W.convert(i.center||i.locationAtOffset),n?+i.zoom:r),s=o.center,a=o.zoom;Ut(e,s);const l=me(e.worldSize,i.locationAtOffset),c=me(e.worldSize,s).sub(l),u=c.mag(),h=t.ao(a-r);let d;if(void 0!==i.minZoom){const n=Math.min(+i.minZoom,r,a),o=e.applyConstrain(s,n).zoom;d=t.ao(o-r)}return{easeFunc:(i,n,o,u)=>{e.setZoom(1===i?a:r+t.ar(n));const h=1===i?s:ge(e.worldSize,l.add(c.mult(o)).mult(n));e.setLocationAtPoint(e.renderWorldCopies?h.wrap():h,u)},scaleOfZoom:h,targetCenter:s,scaleOfMinZoom:d,pixelPathLength:u}}}class ei{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i}}ei.Replace=[1,0],ei.disabled=new ei(ei.Replace,t.bo.transparent,[!1,!1,!1,!1]),ei.unblended=new ei(ei.Replace,t.bo.transparent,[!0,!0,!0,!0]),ei.alphaBlended=new ei([1,771],t.bo.transparent,[!0,!0,!0,!0]);const ti=2305;class ii{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}}ii.disabled=new ii(!1,1029,ti),ii.backCCW=new ii(!0,1029,ti),ii.frontCCW=new ii(!0,1028,ti);class ni{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}}ni.ReadOnly=!1,ni.ReadWrite=!0,ni.disabled=new ni(519,ni.ReadOnly,[0,1]);const ri=7680;class oi{constructor(e,t,i,n,r,o){this.test=e,this.ref=t,this.mask=i,this.fail=n,this.depthFail=r,this.pass=o}}function si(e){return"undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext}oi.disabled=new oi({func:519,mask:0},0,0,ri,ri,ri);class ai{get awaitingQuery(){return!!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;const i=e.context,n=i.gl;this._texFormat=n.RGBA,this._texType=n.UNSIGNED_BYTE;const r=new t.aU;r.emplaceBack(-1,-1),r.emplaceBack(2,-1),r.emplaceBack(-1,2);const o=new t.aW;o.emplaceBack(0,1,2),this._fullscreenTriangle=new Ot(i.createVertexBuffer(r,Nt.members),i.createIndexBuffer(o),t.aV.simpleSegment(0,0,r.length,o.length)),this._resultBuffer=new Uint8Array(4),i.activeTexture.set(n.TEXTURE1);const s=n.createTexture();n.bindTexture(n.TEXTURE_2D,s),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.NEAREST),n.texImage2D(n.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=i.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(s),si(n)&&(this._pbo=n.createBuffer(),n.bindBuffer(n.PIXEL_PACK_BUFFER,this._pbo),n.bufferData(n.PIXEL_PACK_BUFFER,4,n.STREAM_READ),n.bindBuffer(n.PIXEL_PACK_BUFFER,null))}destroy(){const e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(e,t){const i=this._updateCount;return this._readbackQueue?i>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():i>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,t),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,t=e.gl;e.activeTexture.set(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,i){const n=this._cachedRenderContext.context,r=n.gl;if(this._bindFramebuffer(),n.viewport.set([0,0,this._texWidth,this._texHeight]),n.clear({color:t.bo.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(n,r.TRIANGLES,ni.disabled,oi.disabled,ei.unblended,ii.disabled,((e,t)=>({u_input:e,u_output_expected:t}))(e,i),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&si(r)){r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pbo),r.readBuffer(r.COLOR_ATTACHMENT0),r.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),r.bindBuffer(r.PIXEL_PACK_BUFFER,null);const e=r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE,0);r.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:e}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){const e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&si(e)){const i=e.clientWaitSync(this._readbackQueue.sync,0,0);if(i===e.WAIT_FAILED)return t.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(i===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=ai._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(e){let t=0;return t+=e[0]/256,t+=e[1]/65536,t+=e[2]/16777216,e[3]<127&&(t=-t),t/128}}const li=t.a6/128;function ci(e,i){const n=void 0!==e.granularity?Math.max(e.granularity,1):1,r=n+(e.generateBorders?2:0),o=n+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),s=r+1,a=o+1,l=e.generateBorders?-1:0,c=e.generateBorders||e.extendToNorthPole?-1:0,u=n+(e.generateBorders?1:0),h=n+(e.generateBorders||e.extendToSouthPole?1:0),d=s*a,p=r*o*6,f=s*a>65536;if(f&&"16bit"===i)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const m=f||"32bit"===i,g=new Int16Array(2*d);let y=0;for(let i=c;i<=h;i++)for(let r=l;r<=u;r++){let o=r/n*t.a6;-1===r&&(o=-li),r===n+1&&(o=t.a6+li);let s=i/n*t.a6;-1===i&&(s=e.extendToNorthPole?t.bq:-li),i===n+1&&(s=e.extendToSouthPole?t.br:t.a6+li),g[y++]=o,g[y++]=s}const _=m?new Uint32Array(p):new Uint16Array(p);let v=0;for(let e=0;e<o;e++)for(let t=0;t<r;t++){const i=t+1+e*s,n=t+(e+1)*s,r=t+1+(e+1)*s;_[v++]=t+e*s,_[v++]=n,_[v++]=i,_[v++]=i,_[v++]=n,_[v++]=r}return{vertices:g.buffer.slice(0),indices:_.buffer.slice(0),uses32bitIndices:m}}const ui=new t.aT({fill:new t.bs(128,2),line:new t.bs(512,0),tile:new t.bs(128,32),stencil:new t.bs(128,1),circle:3});class hi{constructor(){this._tileMeshCache={},this._errorCorrectionUsable=0,this._errorMeasurementLastValue=0,this._errorCorrectionPreviousValue=0,this._errorMeasurementLastChangeTime=-1e3}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 zt.projectionGlobe}get vertexShaderPreludeCode(){return zt.projectionMercator.vertexSource}get subdivisionGranularity(){return ui}get useGlobeControls(){return!0}get latitudeErrorCorrectionRadians(){return this._errorCorrectionUsable}destroy(){this._errorMeasurement&&this._errorMeasurement.destroy()}updateGPUdependent(e){this._errorMeasurement||(this._errorMeasurement=new ai(e));const i=t.Y(this._errorQueryLatitudeDegrees),n=2*Math.atan(Math.exp(Math.PI-i*Math.PI*2))-.5*Math.PI,r=this._errorMeasurement.updateErrorLoop(i,n),o=c();r!==this._errorMeasurementLastValue&&(this._errorCorrectionPreviousValue=this._errorCorrectionUsable,this._errorMeasurementLastValue=r,this._errorMeasurementLastChangeTime=o);const s=Math.min(Math.max((o-this._errorMeasurementLastChangeTime)/1e3/.5,0),1);this._errorCorrectionUsable=t.bt(this._errorCorrectionPreviousValue,-this._errorMeasurementLastValue,t.bu(s))}_getMeshKey(e){return`${e.granularity.toString(36)}_${e.generateBorders?"b":""}${e.extendToNorthPole?"n":""}${e.extendToSouthPole?"s":""}`}getMeshFromTileID(e,t,i,n,r){const o=("stencil"===r?ui.stencil:ui.tile).getGranularityForZoomLevel(t.z);return this._getMesh(e,{granularity:o,generateBorders:i,extendToNorthPole:0===t.y&&n,extendToSouthPole:t.y===(1<<t.z)-1&&n})}_getMesh(e,i){const n=this._getMeshKey(i);if(n in this._tileMeshCache)return this._tileMeshCache[n];const r=function(e,i){const n=ci(i,"16bit"),r=t.aU.deserialize({arrayBuffer:n.vertices,length:n.vertices.byteLength/2/2}),o=t.aW.deserialize({arrayBuffer:n.indices,length:n.indices.byteLength/2/3});return new Ot(e.createVertexBuffer(r,Nt.members),e.createIndexBuffer(o),t.aV.simpleSegment(0,0,r.length,o.length))}(e,i);return this._tileMeshCache[n]=r,r}recalculate(e){}hasTransition(){var e;const t=c();let i=!1;return i||(i=(t-this._errorMeasurementLastChangeTime)/1e3<.7),i||(i=null===(e=this._errorMeasurement)||void 0===e?void 0:e.awaitingQuery),i}setErrorQueryLatitudeDegrees(e){this._errorQueryLatitudeDegrees=e}}const di=new t.u({type:new t.D(t.x.projection.type)});class pi extends t.E{constructor(e){super(),this._transitionable=new t.y(di,void 0),this.setProjection(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new t.J(0)),this._mercatorProjection=new jt,this._verticalPerspectiveProjection=new hi}get transitionState(){const e=this.properties.get("type");if("string"==typeof e&&"mercator"===e)return 0;if("string"==typeof e&&"vertical-perspective"===e)return 1;if(e instanceof t.bv){if("vertical-perspective"===e.from&&"mercator"===e.to)return 1-e.transition;if("mercator"===e.from&&"vertical-perspective"===e.to)return e.transition}return 1}get useGlobeRendering(){return this.transitionState>0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}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()}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e)}getMeshFromTileID(e,t,i,n,r){return this.currentProjection.getMeshFromTileID(e,t,i,n,r)}setProjection(e){this._transitionable.setValue("type",(null==e?void 0:e.type)||"mercator")}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e)}}function fi(e){const t=yi(e.worldSize,e.center.lat);return 2*Math.PI*t}function mi(e,i,n,r,o){const s=1/(1<<o),a=i/t.a6*s+r*s,l=t.by((e/t.a6*s+n*s)*Math.PI*2+Math.PI,2*Math.PI),c=2*Math.atan(Math.exp(Math.PI-a*Math.PI*2))-.5*Math.PI,u=Math.cos(c),h=new Float64Array(3);return h[0]=Math.sin(l)*u,h[1]=Math.sin(c),h[2]=Math.cos(l)*u,h}function gi(e){return function(e,t){const i=Math.cos(t),n=new Float64Array(3);return n[0]=Math.sin(e)*i,n[1]=Math.sin(t),n[2]=Math.cos(e)*i,n}(e.lng*Math.PI/180,e.lat*Math.PI/180)}function yi(e,t){return e/(2*Math.PI)/Math.cos(t*Math.PI/180)}function _i(e){const i=Math.asin(e[1])/Math.PI*180,n=Math.sqrt(e[0]*e[0]+e[2]*e[2]);if(n>1e-6){const r=e[0]/n,o=Math.acos(e[2]/n),s=(r>0?o:-o)/Math.PI*180;return new t.W(t.X(s,-180,180),i)}return new t.W(0,i)}function vi(e){return Math.cos(e*Math.PI/180)}function xi(e,i){const n=vi(e),r=vi(i);return t.ar(r/n)}function bi(e,i){const n=e.rotate(i.bearingInRadians),r=i.zoom+xi(i.center.lat,0),o=t.bt(1/vi(i.center.lat),1/vi(Math.min(Math.abs(i.center.lat),60)),t.bw(r,7,3,0,1)),s=360/fi({worldSize:i.worldSize,center:{lat:i.center.lat}});return new t.W(i.center.lng-n.x*s*o,t.al(i.center.lat+n.y*s,-t.am,t.am))}function wi(e){const t=.5*e,i=Math.sin(t),n=Math.cos(t);return Math.log(i+n)-Math.log(n-i)}function Ei(e,i,n,r){const o=e.lat+n*r;if(Math.abs(n)>1){const s=(Math.sign(e.lat+n)!==Math.sign(e.lat)?-Math.abs(e.lat):Math.abs(e.lat))*Math.PI/180,a=Math.abs(e.lat+n)*Math.PI/180,l=wi(s+r*(a-s)),c=wi(s),u=wi(a);return new t.W(e.lng+i*((l-c)/(u-c)),o)}return new t.W(e.lng+i*r,o)}class Ti{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,t,i,n){const r=`${e.z}_${e.x}_${e.y}_${(null==n?void 0:n.terrain)?"t":""}`,o=this._cache.get(r);if(o)return o;const s=this._cachePrevious.get(r);if(s)return this._cache.set(r,s),s;const a=this._boundingVolumeFactory(e,t,i,n);return this._cache.set(r,a),this._hadAnyChanges=!0,a}}class Si{constructor(e,t,i,n){this.min=i,this.max=n,this.points=e,this.planes=t}static fromAabb(e,t){const i=[];for(let n=0;n<8;n++)i.push([1&~n?e[0]:t[0],1==(n>>1&1)?t[1]:e[1],1==(n>>2&1)?t[2]:e[2]]);return new Si(i,[[-1,0,0,t[0]],[1,0,0,-e[0]],[0,-1,0,t[1]],[0,1,0,-e[1]],[0,0,-1,t[2]],[0,0,1,-e[2]]],e,t)}static fromCenterSizeAngles(e,i,n){const r=t.bA([],n[0],n[1],n[2]),o=t.bB([],[i[0],0,0],r),s=t.bB([],[0,i[1],0],r),a=t.bB([],[0,0,i[2]],r),l=[...e],c=[...e];for(let t=0;t<8;t++)for(let i=0;i<3;i++){const n=e[i]+o[i]*(1&~t?-1:1)+s[i]*(1==(t>>1&1)?1:-1)+a[i]*(1==(t>>2&1)?1:-1);l[i]=Math.min(l[i],n),c[i]=Math.max(c[i],n)}const u=[];for(let i=0;i<8;i++){const n=[...e];t.a_(n,n,t.aZ([],o,1&~i?-1:1)),t.a_(n,n,t.aZ([],s,1==(i>>1&1)?1:-1)),t.a_(n,n,t.aZ([],a,1==(i>>2&1)?1:-1)),u.push(n)}return new Si(u,[[...o,-t.b3(o,u[0])],[...s,-t.b3(s,u[0])],[...a,-t.b3(a,u[0])],[-o[0],-o[1],-o[2],-t.b3(o,u[7])],[-s[0],-s[1],-s[2],-t.b3(s,u[7])],[-a[0],-a[1],-a[2],-t.b3(a,u[7])]],l,c)}intersectsFrustum(e){let t=!0;const i=this.points.length,n=this.planes.length,r=e.planes.length,o=e.points.length;for(let n=0;n<r;n++){const r=e.planes[n];let o=0;for(let e=0;e<i;e++){const t=this.points[e];r[0]*t[0]+r[1]*t[1]+r[2]*t[2]+r[3]>=0&&o++}if(0===o)return 0;o<i&&(t=!1)}if(t)return 2;for(let t=0;t<n;t++){const i=this.planes[t];let n=0;for(let t=0;t<o;t++){const r=e.points[t];i[0]*r[0]+i[1]*r[1]+i[2]*r[2]+i[3]>=0&&n++}if(0===n)return 0}return 1}intersectsPlane(e){const t=this.points.length;let i=0;for(let n=0;n<t;n++){const t=this.points[n];e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]>=0&&i++}return i===t?2:0===i?0:1}}function Ii(e,t,i){const n=e-t;return n<0?-n:Math.max(0,n-i)}function ki(e,t,i,n,r){const o=e-i;let s;return s=o<0?Math.min(-o,1+o-r):o>r?Math.min(Math.max(o-r,0),1-o):0,Math.max(s,Ii(t,n,r))}class Mi{constructor(){this._boundingVolumeCache=new Ti(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,t,i,n){const r=1<<i.z,o=1/r,s=i.x/r,a=i.y/r;let l=2;return l=Math.min(l,ki(e,t,s,a,o)),l=Math.min(l,ki(e,t,s+.5,-a-o,o)),l=Math.min(l,ki(e,t,s+.5,2-a-o,o)),l}getWrap(e,t,i){const n=1<<t.z,r=1/n,o=t.x/n,s=Ii(e.x,o,r),a=Ii(e.x,o-1,r),l=Ii(e.x,o+1,r),c=Math.min(s,a,l);return c===l?1:c===a?-1:0}allowVariableZoom(e,t){return Se(e,t)>4}allowWorldCopies(){return!1}getTileBoundingVolume(e,t,i,n){return this._boundingVolumeCache.getTileBoundingVolume(e,t,i,n)}_computeTileBoundingVolume(e,i,n,r){var o,s;let a=0,l=0;if(null==r?void 0:r.terrain){const c=new t.a3(e.z,i,e.z,e.x,e.y),u=r.terrain.getMinMaxElevation(c);a=null!==(o=u.minElevation)&&void 0!==o?o:Math.min(0,n),l=null!==(s=u.maxElevation)&&void 0!==s?s:Math.max(0,n)}if(a/=t.bD,l/=t.bD,a+=1,l+=1,e.z<=0)return Si.fromAabb([-l,-l,-l],[l,l,l]);if(1===e.z)return Si.fromAabb([0===e.x?-l:0,0===e.y?0:-l,-l],[0===e.x?0:l,0===e.y?l:0,l]);{const i=[mi(0,0,e.x,e.y,e.z),mi(t.a6,0,e.x,e.y,e.z),mi(t.a6,t.a6,e.x,e.y,e.z),mi(0,t.a6,e.x,e.y,e.z)],n=[];for(const e of i)n.push(t.aZ([],e,l));if(l!==a)for(const e of i)n.push(t.aZ([],e,a));0===e.y&&n.push([0,1,0]),e.y===(1<<e.z)-1&&n.push([0,-1,0]);const r=[1,1,1],o=[-1,-1,-1];for(const e of n)for(let t=0;t<3;t++)r[t]=Math.min(r[t],e[t]),o[t]=Math.max(o[t],e[t]);const s=mi(t.a6/2,t.a6/2,e.x,e.y,e.z),c=t.b2([],[0,1,0],s);t.b1(c,c);const u=t.b2([],s,c);t.b1(u,u);const h=t.b2([],i[2],i[1]);t.b1(h,h);const d=t.b2([],i[0],i[3]);t.b1(d,d),n.push(t.aZ([],s,l)),e.y>=(1<<e.z)/2&&n.push(t.aZ([],mi(t.a6/2,0,e.x,e.y,e.z),l)),e.y<(1<<e.z)/2&&n.push(t.aZ([],mi(t.a6/2,t.a6,e.x,e.y,e.z),l));const p=Ci(s,n),f=Ci(u,n),m=[-s[0],-s[1],-s[2],p.max],g=[s[0],s[1],s[2],-p.min],y=[-u[0],-u[1],-u[2],f.max],_=[u[0],u[1],u[2],-f.min],v=[...h,0],x=[...d,0],b=[];return 0===e.y?b.push(t.bC(x,v,m),t.bC(x,v,g)):b.push(t.bC(y,v,m),t.bC(y,v,g),t.bC(y,x,m),t.bC(y,x,g)),e.y===(1<<e.z)-1?b.push(t.bC(x,v,m),t.bC(x,v,g)):b.push(t.bC(_,v,m),t.bC(_,v,g),t.bC(_,x,m),t.bC(_,x,g)),new Si(b,[m,g,y,_,v,x],r,o)}}}function Ci(e,i){let n=1/0,r=-1/0;for(const o of i){const i=t.b3(e,o);n=Math.min(n,i),r=Math.max(r,i)}return{min:n,max:r}}class Pi{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(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,i){this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t){this._helper.resize(e,t)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}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(e){}constructor(e){this._cachedClippingPlane=t.bE(),this._projectionMatrix=t.bi(),this._globeViewProjMatrix32f=t.bh(),this._globeViewProjMatrixNoCorrection=t.bi(),this._globeViewProjMatrixNoCorrectionInverted=t.bi(),this._globeProjMatrixInverted=t.bi(),this._cameraPosition=t.bz(),this._globeLatitudeErrorCorrectionRadians=0,this.defaultConstrain=(e,i)=>{const n=t.al(e.lat,-t.am,t.am),r=t.al(+i,this.minZoom+xi(0,n),this.maxZoom);return{center:new t.W(e.lng,n),zoom:r}},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Zt({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new Mi}clone(){const e=new Pi;return e.apply(this,!1),e}apply(e,t,i){this._globeLatitudeErrorCorrectionRadians=i||0,this._helper.apply(e,t)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=t.bz();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){const{overscaledTileID:t,applyGlobeMatrix:i}=e,n=this._helper.getMercatorTileCoordinates(t);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:n,clippingPlane:this._cachedClippingPlane,projectionTransition:i?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const i=this.pitchInRadians,n=this.cameraToCenterDistance/e,r=Math.sin(i)*n,o=Math.cos(i)*n+1,s=1/Math.sqrt(r*r+o*o)*1;let a=-r,l=o;const c=Math.sqrt(a*a+l*l);a/=c,l/=c;const u=[0,a,l];t.bF(u,u,[0,0,0],-this.bearingInRadians),t.bG(u,u,[0,0,0],-1*this.center.lat*Math.PI/180),t.bH(u,u,[0,0,0],this.center.lng*Math.PI/180);const h=1/t.b5(u);return t.aZ(u,u,h),[...u,-s*h]}isLocationOccluded(e){return!this.isSurfacePointVisible(gi(e))}transformLightDirection(e){const i=this._helper._center.lng*Math.PI/180,n=this._helper._center.lat*Math.PI/180,r=Math.cos(n),o=[Math.sin(i)*r,Math.sin(n),Math.cos(i)*r],s=[o[2],0,-o[0]],a=[0,0,0];t.b2(a,s,o),t.b1(s,s),t.b1(a,a);const l=[0,0,0];return t.b1(l,[s[0]*e[0]+a[0]*e[1]+o[0]*e[2],s[1]*e[0]+a[1]*e[1]+o[1]*e[2],s[2]*e[0]+a[2]*e[1]+o[2]*e[2]]),l}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,i,n){const r=function(e,i,n){const r=1/(1<<n.z);return new t.a7(e/t.a6*r+n.x*r,i/t.a6*r+n.y*r)}(e,i,n.canonical),o=(s=r.y,[t.by(r.x*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-s*Math.PI*2))-.5*Math.PI]);var s;return this.getCircleRadiusCorrection()/Math.cos(o[1])}projectTileCoordinates(e,i,n,r){const o=n.canonical,s=mi(e,i,o.x,o.y,o.z),a=1+(r?r(e,i):0)/t.bD,l=[s[0]*a,s[1]*a,s[2]*a,1];t.aE(l,l,this._globeViewProjMatrixNoCorrection);const c=this._cachedClippingPlane,u=c[0]*s[0]+c[1]*s[1]+c[2]*s[2]+c[3]<0;return{point:new t.P(l[0]/l[3],l[1]/l[3]),signedDistanceFromCamera:l[3],isOccluded:u}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;const e=yi(this.worldSize,this.center.lat),i=t.bj(),n=t.bj();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*e),t.bc(i,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);const r=this.centerOffset;i[8]=2*-r.x/this._helper._width,i[9]=2*r.y/this._helper._height,this._projectionMatrix=t.bd(i),this._globeProjMatrixInverted=t.bj(),t.bg(this._globeProjMatrixInverted,i),t.Q(i,i,[0,0,-this.cameraToCenterDistance]),t.be(i,i,this.rollInRadians),t.bf(i,i,-this.pitchInRadians),t.be(i,i,this.bearingInRadians),t.Q(i,i,[0,0,-e]);const o=t.bz();o[0]=e,o[1]=e,o[2]=e,t.bf(n,i,this.center.lat*Math.PI/180),t.bI(n,n,-this.center.lng*Math.PI/180),t.S(n,n,o),this._globeViewProjMatrixNoCorrection=n,t.bf(i,i,this.center.lat*Math.PI/180-this._globeLatitudeErrorCorrectionRadians),t.bI(i,i,-this.center.lng*Math.PI/180),t.S(i,i,o),this._globeViewProjMatrix32f=new Float32Array(i),this._globeViewProjMatrixNoCorrectionInverted=t.bj(),t.bg(this._globeViewProjMatrixNoCorrectionInverted,n);const s=t.bz();this._cameraPosition=t.bz(),this._cameraPosition[2]=this.cameraToCenterDistance/e,t.bF(this._cameraPosition,this._cameraPosition,s,-this.rollInRadians),t.bG(this._cameraPosition,this._cameraPosition,s,this.pitchInRadians),t.bF(this._cameraPosition,this._cameraPosition,s,-this.bearingInRadians),t.a_(this._cameraPosition,this._cameraPosition,[0,0,1]),t.bG(this._cameraPosition,this._cameraPosition,s,-this.center.lat*Math.PI/180),t.bH(this._cameraPosition,this._cameraPosition,s,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(e);const a=t.bd(this._globeViewProjMatrixNoCorrectionInverted);t.S(a,a,[1,1,-1]),this._cachedFrustum=Wt.fromInvProjectionMatrix(a,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(e){t.w("calculateFogMatrix is not supported on globe projection.");const i=t.bj();return t.ap(i),i}getVisibleUnwrappedCoordinates(e){return[new t.ba(0,e)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){e&&t.w("terrain is not fully supported on vertical perspective projection."),this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,i){if(!this._globeViewProjMatrixNoCorrection)return 1;const n=gi(e);t.aZ(n,n,1+i/t.bD);const r=t.bE();return t.aE(r,[n[0],n[1],n[2],1],this._globeViewProjMatrixNoCorrection),r[2]/r[3]}populateCache(e){}getBounds(){const e=.5*this.width,i=.5*this.height,n=[new t.P(0,0),new t.P(e,0),new t.P(this.width,0),new t.P(this.width,i),new t.P(this.width,this.height),new t.P(e,this.height),new t.P(0,this.height),new t.P(0,i)],r=[];for(const e of n)r.push(this.unprojectScreenPoint(e));let o=0,s=0,a=0,l=0;const c=this.center;for(const e of r){const i=t.bJ(c.lng,e.lng),n=t.bJ(c.lat,e.lat);i<s&&(s=i),i>o&&(o=i),n<l&&(l=n),n>a&&(a=n)}const u=[c.lng+s,c.lat+l,c.lng+o,c.lat+a];return this.isSurfacePointOnScreen([0,1,0])&&(u[3]=90,u[0]=-180,u[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(u[1]=-90,u[0]=-180,u[2]=180),new U(u)}calculateCenterFromCameraLngLatAlt(e,t,i,n){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,n)}setLocationAtPoint(e,i){const n=gi(this.unprojectScreenPoint(i)),r=gi(e),o=t.bz();t.bK(o);const s=t.bz();t.bH(s,n,o,-this.center.lng*Math.PI/180),t.bG(s,s,o,this.center.lat*Math.PI/180);const a=r[0]*r[0]+r[2]*r[2],l=s[0]*s[0];if(a<l)return;const c=Math.sqrt(a-l),u=-c,h=t.bL(r[0],r[2],s[0],c),d=t.bL(r[0],r[2],s[0],u),p=t.bz();t.bH(p,r,o,-h);const f=t.bL(p[1],p[2],s[1],s[2]),m=t.bz();t.bH(m,r,o,-d);const g=t.bL(m[1],m[2],s[1],s[2]),y=.5*Math.PI,_=f>=-y&&f<=y,v=g>=-y&&g<=y;let x,b;if(_&&v){const e=this.center.lng*Math.PI/180,i=this.center.lat*Math.PI/180;t.bM(h,e)+t.bM(f,i)<t.bM(d,e)+t.bM(g,i)?(x=h,b=f):(x=d,b=g)}else if(_)x=h,b=f;else{if(!v)return;x=d,b=g}const w=x/Math.PI*180,E=b/Math.PI*180,T=this.center.lat;this.setCenter(new t.W(w,t.al(E,-90,90))),this.setZoom(this.zoom+xi(T,this.center.lat))}locationToScreenPoint(e,i){const n=gi(e);if(i){const r=i.getElevationForLngLatZoom(e,this._helper._tileZoom);t.aZ(n,n,1+r/t.bD)}return this._projectSurfacePointToScreen(n)}_projectSurfacePointToScreen(e){const i=t.bE();return t.aE(i,[...e,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],new t.P((.5*i[0]+.5)*this.width,(.5*-i[1]+.5)*this.height)}screenPointToMercatorCoordinate(e,i){if(i){const t=i.pointCoordinate(e);if(t)return t}return t.a7.fromLngLat(this.unprojectScreenPoint(e))}screenPointToLocation(e,t){var i;return null===(i=this.screenPointToMercatorCoordinate(e,t))||void 0===i?void 0:i.toLngLat()}isPointOnMapSurface(e,t){const i=this._cameraPosition,n=this.getRayDirectionFromPixel(e);return!!this.rayPlanetIntersection(i,n)}getRayDirectionFromPixel(e){const i=t.bE();i[0]=e.x/this.width*2-1,i[1]=-1*(e.y/this.height*2-1),i[2]=1,i[3]=1,t.aE(i,i,this._globeViewProjMatrixNoCorrectionInverted),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3];const n=t.bz();n[0]=i[0]-this._cameraPosition[0],n[1]=i[1]-this._cameraPosition[1],n[2]=i[2]-this._cameraPosition[2];const r=t.bz();return t.b1(r,n),r}isSurfacePointVisible(e){const t=this._cachedClippingPlane;return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]>=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;const i=t.bE();return t.aE(i,[...e,1],this._globeViewProjMatrixNoCorrection),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}rayPlanetIntersection(e,i){const n=t.b3(e,i),r=t.bz(),o=t.bz();t.aZ(o,i,n),t.b0(r,e,o);const s=1-t.b3(r,r);if(s<0)return null;const a=t.b3(e,e)-1,l=-n+(n<0?1:-1)*Math.sqrt(s),c=a/l,u=l;return{tMin:Math.min(c,u),tMax:Math.max(c,u)}}unprojectScreenPoint(e){const i=this._cameraPosition,n=this.getRayDirectionFromPixel(e),r=this.rayPlanetIntersection(i,n);if(r){const e=t.bz();t.a_(e,i,[n[0]*r.tMin,n[1]*r.tMin,n[2]*r.tMin]);const o=t.bz();return t.b1(o,e),_i(o)}const o=this._cachedClippingPlane,s=o[0]*n[0]+o[1]*n[1]+o[2]*n[2],a=-t.b9(o,i)/s,l=t.bz();if(a>0)t.a_(l,i,[n[0]*a,n[1]*a,n[2]*a]);else{const e=t.bz();t.a_(e,i,[2*n[0],2*n[1],2*n[2]]);const r=t.b9(this._cachedClippingPlane,e);t.b0(l,e,[this._cachedClippingPlane[0]*r,this._cachedClippingPlane[1]*r,this._cachedClippingPlane[2]*r])}const c=function(e){const i=t.bz();return i[0]=e[0]*-e[3],i[1]=e[1]*-e[3],i[2]=e[2]*-e[3],{center:i,radius:Math.sqrt(1-e[3]*e[3])}}(o);return _i(function(e,i,n){const r=t.bz();t.b0(r,n,e);const o=t.bz();return t.bx(o,e,r,i/t.b7(r)),o}(c.center,c.radius,l))}getMatrixForModel(e,i){const n=t.W.convert(e),r=1/t.bD,o=t.bi();return t.bI(o,o,n.lng/180*Math.PI),t.bf(o,o,-n.lat/180*Math.PI),t.Q(o,o,[0,0,1+i/t.bD]),t.bf(o,o,.5*Math.PI),t.S(o,o,[r,r,r]),o}getProjectionDataForCustomLayer(e=!0){const i=this.getProjectionData({overscaledTileID:new t.a3(0,0,0,0,0),applyGlobeMatrix:e});return i.tileMercatorCoords=[0,0,1,1],i}getFastPathSimpleProjectionMatrix(e){}}class Ai{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(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,i){this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}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(e,t){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(e){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this.defaultConstrain=(e,t)=>this.currentTransform.defaultConstrain(e,t),this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Zt({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._globeness=1,this._mercatorTransform=new Xt,this._verticalPerspectiveTransform=new Pi}clone(){const e=new Ai;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this,!1),e}apply(e,t){this._helper.apply(e,t),this._mercatorTransform.apply(this,!1),this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians)}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(e){const t=this._mercatorTransform.getProjectionData(e),i=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?i.mainMatrix:t.mainMatrix,clippingPlane:i.clippingPlane,tileMercatorCoords:i.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:t.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return t.bt(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return t.bt(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,i,n){const r=this._mercatorTransform.getPitchedTextCorrection(e,i,n),o=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,i,n);return t.bt(r,o,this._globeness)}projectTileCoordinates(e,t,i,n){return this.currentTransform.projectTileCoordinates(e,t,i,n)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,t){return this.currentTransform.lngLatToCameraDepth(e,t)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(e,t,i,n){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,n)}setLocationAtPoint(e,t){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,t),void this.apply(this._mercatorTransform,!1);this._verticalPerspectiveTransform.setLocationAtPoint(e,t),this.apply(this._verticalPerspectiveTransform,!1)}locationToScreenPoint(e,t){return this.currentTransform.locationToScreenPoint(e,t)}screenPointToMercatorCoordinate(e,t){return this.currentTransform.screenPointToMercatorCoordinate(e,t)}screenPointToLocation(e,t){return this.currentTransform.screenPointToLocation(e,t)}isPointOnMapSurface(e,t){return this.currentTransform.isPointOnMapSurface(e,t)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,t){return this.currentTransform.getMatrixForModel(e,t)}getProjectionDataForCustomLayer(e=!0){const t=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return t;const i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return i.fallbackMatrix=t.mainMatrix,i}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class Li{get useGlobeControls(){return!0}handlePanInertia(e,i){const n=bi(e,i);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 t.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,i){const n=e.around,r=i.screenPointToLocation(n);e.bearingDelta&&i.setBearing(i.bearing+e.bearingDelta),e.pitchDelta&&i.setPitch(i.pitch+e.pitchDelta),e.rollDelta&&i.setRoll(i.roll+e.rollDelta);const o=i.zoom;e.zoomDelta&&i.setZoom(i.zoom+e.zoomDelta);const s=i.zoom-o;if(0===s)return;const a=t.bJ(i.center.lng,r.lng),l=a/(Math.abs(a/180)+1),c=t.bJ(i.center.lat,r.lat),u=i.getRayDirectionFromPixel(n),h=i.cameraPosition,d=-1*t.b3(h,u),p=t.bz();t.a_(p,h,[u[0]*d,u[1]*d,u[2]*d]);const f=t.b5(p)-1,m=Math.exp(.5*-Math.max(f-.3,0)),g=yi(i.worldSize,i.center.lat)/Math.min(i.width,i.height),y=t.bw(g,.9,.5,1,.25),_=(1-t.ao(-s))*Math.min(m,y),v=i.center.lat,x=i.zoom,b=new t.W(i.center.lng+l*_,t.al(i.center.lat+c*_,-t.am,t.am));i.setLocationAtPoint(r,n);const w=i.center,E=t.bw(Math.abs(a),45,85,0,1),T=t.bw(g,.75,.35,0,1),S=Math.pow(Math.max(E,T),.25),I=t.bJ(w.lng,b.lng),k=t.bJ(w.lat,b.lat);i.setCenter(new t.W(w.lng+I*S,w.lat+k*S).wrap()),i.setZoom(x+xi(v,i.center.lat))}handleMapControlsPan(e,t,i){if(!e.panDelta)return;const n=t.center.lat,r=t.zoom;t.setCenter(bi(e.panDelta,t).wrap()),t.setZoom(r+xi(n,t.center.lat))}cameraForBoxAndBearing(e,i,n,r,o){const s=Kt(e,i,n,r,o),a=i.left/o.width*2-1,l=(o.width-i.right)/o.width*2-1,c=i.top/o.height*-2+1,u=(o.height-i.bottom)/o.height*-2+1,h=t.bJ(n.getWest(),n.getEast())<0,d=h?n.getEast():n.getWest(),p=h?n.getWest():n.getEast(),f=Math.max(n.getNorth(),n.getSouth()),m=Math.min(n.getNorth(),n.getSouth()),g=d+.5*t.bJ(d,p),y=f+.5*t.bJ(f,m),_=o.clone();_.setCenter(s.center),_.setBearing(s.bearing),_.setPitch(0),_.setRoll(0),_.setZoom(s.zoom);const v=_.modelViewProjectionMatrix,x=[gi(n.getNorthWest()),gi(n.getNorthEast()),gi(n.getSouthWest()),gi(n.getSouthEast()),gi(new t.W(p,y)),gi(new t.W(d,y)),gi(new t.W(g,f)),gi(new t.W(g,m))],b=gi(s.center);let w=Number.POSITIVE_INFINITY;for(const e of x)a<0&&(w=Li.getLesserNonNegativeNonNull(w,Li.solveVectorScale(e,b,v,"x",a))),l>0&&(w=Li.getLesserNonNegativeNonNull(w,Li.solveVectorScale(e,b,v,"x",l))),c>0&&(w=Li.getLesserNonNegativeNonNull(w,Li.solveVectorScale(e,b,v,"y",c))),u<0&&(w=Li.getLesserNonNegativeNonNull(w,Li.solveVectorScale(e,b,v,"y",u)));if(Number.isFinite(w)&&0!==w)return s.zoom=Math.min(_.zoom+t.ar(w),e.maxZoom),s;Yt()}handleJumpToCenterZoom(e,i){const n=e.center.lat,r=e.applyConstrain(i.center?t.W.convert(i.center):e.center,e.zoom).center;e.setCenter(r.wrap());const o=void 0!==i.zoom?+i.zoom:e.zoom+xi(n,r.lat);e.zoom!==o&&e.setZoom(o)}handleEaseTo(e,i){const n=e.zoom,r=e.center,o=e.padding,s={roll:e.roll,pitch:e.pitch,bearing:e.bearing},a={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},l=void 0!==i.zoom,c=!e.isPaddingEqual(i.padding);let u=!1;const h=i.center?t.W.convert(i.center):r,d=e.applyConstrain(h,n).center;Ut(e,d);const p=e.clone();p.setCenter(d),p.setZoom(l?+i.zoom:n+xi(r.lat,h.lat)),p.setBearing(i.bearing);const f=new t.P(t.al(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.al(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));p.setLocationAtPoint(d,f);const m=(i.offset&&i.offsetAsPoint.mag())>0?p.center:d,g=l?+i.zoom:n+xi(r.lat,m.lat),y=n+xi(r.lat,0),_=g+xi(m.lat,0),v=t.bJ(r.lng,m.lng),x=t.bJ(r.lat,m.lat),b=t.ao(_-y);return u=g!==n,{easeFunc:n=>{if(t.bn(s,a)||Jt({startEulerAngles:s,endEulerAngles:a,tr:e,k:n,useSlerp:s.roll!=a.roll}),c&&e.interpolatePadding(o,i.padding,n),i.around)t.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(i.around,i.aroundPoint);else{const t=_>y?Math.min(2,b):Math.max(.5,b),i=Math.pow(t,1-n),o=Ei(r,v,x,n*i);e.setCenter(o.wrap())}if(u){const i=t.H.number(y,_,n)+xi(0,e.center.lat);e.setZoom(i)}},isZooming:u,elevationCenter:m}}handleFlyTo(e,i){const n=void 0!==i.zoom,r=e.center,o=e.zoom,s=e.padding,a=!e.isPaddingEqual(i.padding),l=e.applyConstrain(t.W.convert(i.center||i.locationAtOffset),o).center,c=n?+i.zoom:e.zoom+xi(e.center.lat,l.lat),u=e.clone();u.setCenter(l),u.setZoom(c),u.setBearing(i.bearing);const h=new t.P(t.al(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.al(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));u.setLocationAtPoint(l,h);const d=u.center;Ut(e,d);const p=function(e,i,n){const r=gi(i),o=gi(n),s=t.b3(r,o),a=Math.acos(s),l=fi(e);return a/(2*Math.PI)*l}(e,r,d),f=o+xi(r.lat,0),m=c+xi(d.lat,0),g=t.ao(m-f);let y;if("number"==typeof i.minZoom){const n=+i.minZoom+xi(d.lat,0),r=Math.min(n,f,m)+xi(0,d.lat),o=e.applyConstrain(d,r).zoom+xi(d.lat,0);y=t.ao(o-f)}const _=t.bJ(r.lng,d.lng),v=t.bJ(r.lat,d.lat);return{easeFunc:(n,o,l,u)=>{const h=Ei(r,_,v,l);a&&e.interpolatePadding(s,i.padding,n);const p=1===n?d:h;e.setCenter(p.wrap());const m=f+t.ar(o);e.setZoom(1===n?c:m+xi(0,p.lat))},scaleOfZoom:g,targetCenter:d,scaleOfMinZoom:y,pixelPathLength:p}}static solveVectorScale(e,t,i,n,r){const o="x"===n?[i[0],i[4],i[8],i[12]]:[i[1],i[5],i[9],i[13]],s=[i[3],i[7],i[11],i[15]],a=e[0]*o[0]+e[1]*o[1]+e[2]*o[2],l=e[0]*s[0]+e[1]*s[1]+e[2]*s[2],c=t[0]*o[0]+t[1]*o[1]+t[2]*o[2],u=t[0]*s[0]+t[1]*s[1]+t[2]*s[2];return c+r*l===a+r*u||s[3]*(a-c)+o[3]*(u-l)+a*u==c*l?null:(c+o[3]-r*u-r*s[3])/(c-a-r*u+r*l)}static getLesserNonNegativeNonNull(e,t){return null!==t&&t>=0&&t<e?t:e}}class Di{constructor(e){this._globe=e,this._mercatorCameraHelper=new Qt,this._verticalPerspectiveCameraHelper=new Li}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(e,t){return this.currentHelper.handlePanInertia(e,t)}handleMapControlsRollPitchBearingZoom(e,t){this.currentHelper.handleMapControlsRollPitchBearingZoom(e,t)}handleMapControlsPan(e,t,i){this.currentHelper.handleMapControlsPan(e,t,i)}cameraForBoxAndBearing(e,t,i,n,r){return this.currentHelper.cameraForBoxAndBearing(e,t,i,n,r)}handleJumpToCenterZoom(e,t){this.currentHelper.handleJumpToCenterZoom(e,t)}handleEaseTo(e,t){return this.currentHelper.handleEaseTo(e,t)}handleFlyTo(e,t){return this.currentHelper.handleFlyTo(e,t)}}const Ri=(e,i)=>t.C(e,null==i?void 0:i.filter(e=>"source.canvas"!==e.identifier)),zi=t.bN();class Fi extends t.E{constructor(e,i={}){var n,r;super(),this._rtlPluginLoaded=()=>{for(const e in this.tileManagers){const t=this.tileManagers[e].getSource().type;"vector"!==t&&"geojson"!==t||this.tileManagers[e].reload()}},this.map=e,this.dispatcher=new F(z(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",(e,t)=>this.getGlyphs(e,t)),this.dispatcher.registerMessageHandler("GI",(e,t)=>this.getImages(e,t)),this.dispatcher.registerMessageHandler("GDA",(e,t)=>this.getDashes(e,t)),this.imageManager=new y,this.imageManager.setEventedParent(this);const o=(null===(n=e._container)||void 0===n?void 0:n.lang)||"undefined"!=typeof document&&(null===(r=document.documentElement)||void 0===r?void 0:r.lang)||void 0;this.glyphManager=new E(e._requestManager,i.localIdeographFontFamily,o),this.lineAtlas=new C(256,512),this.crossTileSymbolIndex=new Dt,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",t.bO()),ce().on(se,this._rtlPluginLoaded),this.on("data",e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.tileManagers[e.sourceId];if(!t)return;const i=t.getSource();if(null==i?void 0:i.vectorLayerIds)for(const e in this._layers){const t=this._layers[e];t.source===i.id&&this._validateLayer(t)}})}_setInitialValues(){var e;this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new t.bP,this._availableImages=[],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.crossTileSymbolIndex=new((null===(e=this.crossTileSymbolIndex)||void 0===e?void 0:e.constructor)||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(e,i){var n,r,o;this._checkLoaded();const s=null===i?null!==(o=null===(r=null===(n=this.stylesheet.state)||void 0===n?void 0:n[e])||void 0===r?void 0:r.default)&&void 0!==o?o:null:i;if(t.bQ(s,this._globalState[e]))return this;this._globalState[e]=s,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();const i=[];for(const n in e)!t.bQ(this._globalState[n],e[n].default)&&(i.push(n),this._globalState[n]=e[n].default);this._applyGlobalStateChanges(i)}_applyGlobalStateChanges(e){if(0===e.length)return;const t=new Set,i={};for(const n of e){i[n]=this._globalState[n];for(const e in this._layers){const i=this._layers[e],r=i.getLayoutAffectingGlobalStateRefs(),o=i.getPaintAffectingGlobalStateRefs(),s=i.getVisibilityAffectingGlobalStateRefs();if(r.has(n)&&t.add(i.source),o.has(n))for(const{name:e,value:t}of o.get(n))this._updatePaintProperty(i,e,t);(null==s?void 0:s.has(n))&&(i.recalculateVisibility(),this._updateLayer(i))}}this.dispatcher.broadcast("UGS",i);for(const e in this.tileManagers)t.has(e)&&(this._reloadSource(e),this._changed=!0)}loadURL(e){return t._(this,arguments,void 0,function*(e,i={},n){this.fire(new t.n("dataloading",{dataType:"style"})),i.validate="boolean"!=typeof i.validate||i.validate,this._loadStyleRequest=new AbortController;const r=this._loadStyleRequest;try{const o=yield this.map._requestManager.transformRequest(e,"Style");t.bR(r.signal);const s=yield t.k(o,r);this._loadStyleRequest===r&&(this._loadStyleRequest=null),this._load(s.data,i,n)}catch(e){this._loadStyleRequest===r&&(this._loadStyleRequest=null),e&&!r.signal.aborted&&this.fire(new t.l(t.d(e)))}})}loadJSON(e,i={},n){this.fire(new t.n("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,a.frameAsync(this._frameRequest,this.map._ownerWindow).then(()=>{this._frameRequest=null,i.validate=!1!==i.validate,this._load(e,i,n)}).catch(()=>{})}loadEmpty(){this.fire(new t.n("dataloading",{dataType:"style"})),this._load(zi,{validate:!1})}_load(e,i,n){var r,o;let s=i.transformStyle?i.transformStyle(n,e):e;if(!i.validate||!Ri(this,t.F(s))){s=Object.assign({},s),this._loaded=!0,this.stylesheet=s;for(const e in s.sources)this.addSource(e,s.sources[e],{validate:!1});s.sprite?this._loadSprite(s.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(s.glyphs),this._createLayers(),this.light=new I(this.stylesheet.light),this._setProjectionInternal((null===(r=this.stylesheet.projection)||void 0===r?void 0:r.type)||"mercator"),this.sky=new M(this.stylesheet.sky),this.map.setTerrain(null!==(o=this.stylesheet.terrain)&&void 0!==o?o:null),this.fire(new t.n("data",{dataType:"style"})),this.fire(new t.n("style.load"))}}_createLayers(){var e,i,n;const r=t.bS(this.stylesheet.layers);this.setGlobalState(null!==(e=this.stylesheet.state)&&void 0!==e?e:null),this.dispatcher.broadcast("SL",r),this._order=r.map(e=>e.id),this._layers={},this._serializedLayers=null;for(const e of r){const r=t.bT(e,this._globalState);if(r.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=r,t.bU(r)&&this.tileManagers[r.source]){const t=null!==(n=null===(i=e.paint)||void 0===i?void 0:i["raster-fade-duration"])&&void 0!==n?n:r.paint.get("raster-fade-duration");this.tileManagers[r.source].setRasterFadeDuration(t)}}}_loadSprite(e,i=!1,n=void 0){this.imageManager.setLoaded(!1);const r=new AbortController;let o;this._spriteRequest=r,function(e,i,n,r){return t._(this,void 0,void 0,function*(){const o=f(e),s=n>1?"@2x":"",l={},c={};for(const{id:e,url:n}of o){const o=yield i.transformRequest(m(n,s,".json"),"SpriteJSON");l[e]=t.k(o,r);const a=yield i.transformRequest(m(n,s,".png"),"SpriteImage");c[e]=h.getImage(a,r)}return yield Promise.all([...Object.values(l),...Object.values(c)]),function(e,i){return t._(this,void 0,void 0,function*(){const t={};for(const n in e){t[n]={};const r=a.getImageCanvasContext((yield i[n]).data),o=(yield e[n]).data;for(const e in o){const{width:i,height:s,x:a,y:l,sdf:c,pixelRatio:u,stretchX:h,stretchY:d,content:p,textFitWidth:f,textFitHeight:m}=o[e];t[n][e]={data:null,pixelRatio:u,sdf:c,stretchX:h,stretchY:d,content:p,textFitWidth:f,textFitHeight:m,spriteData:{width:i,height:s,x:a,y:l,context:r}}}}return t})}(l,c)})}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then(e=>{if(this._spriteRequest=null,e)for(const t in e){this._spritesImagesIds[t]=[];const n=this._spritesImagesIds[t]?this._spritesImagesIds[t].filter(t=>!(t in e)):[];for(const e of n)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(const n in e[t]){const r="default"===t?n:`${t}:${n}`;this._spritesImagesIds[t].push(r),r in this.imageManager.images?this.imageManager.updateImage(r,e[t][n],!1):this.imageManager.addImage(r,e[t][n]),i&&(this._changedImages[r]=!0)}}}).catch(e=>{this._spriteRequest=null,o=e,r.signal.aborted||this.fire(new t.l(o))}).finally(()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),i&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.n("data",{dataType:"style"})),n&&n(o)})}_unloadSprite(){for(const e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.n("data",{dataType:"style"}))}_validateLayer(e){const i=this.tileManagers[e.source];if(!i)return;const n=e.sourceLayer;if(!n)return;const r=i.getSource();("geojson"===r.type||r.vectorLayerIds&&!r.vectorLayerIds.includes(n))&&this.fire(new t.l(new Error(`Source layer "${n}" does not exist on source "${r.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const e in this.tileManagers)if(!this.tileManagers[e].loaded())return!1;return this.imageManager.isLoaded()}_serializeByIds(e,i=!1){const n=this._serializedAllLayers();if(!e||0===e.length)return Object.values(i?t.bV(n):n);const r=[];for(const o of e)if(n[o]){const e=i?t.bV(n[o]):n[o];r.push(e)}return r}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const t=Object.keys(this._layers);for(const i of t){const t=this._layers[i];"custom"!==t.type&&(e[i]=t.serialize())}return e}hasTransitions(){var e,t,i;if(null===(e=this.light)||void 0===e?void 0:e.hasTransition())return!0;if(null===(t=this.sky)||void 0===t?void 0:t.hasTransition())return!0;if(null===(i=this.projection)||void 0===i?void 0:i.hasTransition())return!0;for(const e in this.tileManagers)if(this.tileManagers[e].hasTransition())return!0;for(const e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const i=this._changed;if(i){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const e in this._updatedSources){const t=this._updatedSources[e];if("reload"===t)this._reloadSource(e);else{if("clear"!==t)throw new Error(`Invalid action ${t}`);this._clearSource(e)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}const n={};for(const e in this.tileManagers){const t=this.tileManagers[e];n[e]=t.used,t.used=!1}for(const t of this._order){const i=this._layers[t];i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)&&i.source&&(this.tileManagers[i.source].used=!0)}for(const e in n){const i=this.tileManagers[e];!!n[e]!=!!i.used&&i.fire(new t.n("data",{sourceDataType:"visibility",dataType:"source",sourceId:e}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,i&&this.fire(new t.n("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.tileManagers)this.tileManagers[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,i={}){var n;this._checkLoaded();const r=this.serialize();if(e=i.transformStyle?i.transformStyle(r,e):e,(null===(n=i.validate)||void 0===n||n)&&Ri(this,t.F(e)))return!1;(e=t.bV(e)).layers=t.bS(e.layers);const o=t.bW(r,e),s=this._getOperationsToPerform(o);if(s.unimplemented.length>0)throw new Error(`Unimplemented: ${s.unimplemented.join(", ")}.`);if(0===s.operations.length)return!1;for(const e of s.operations)e();return this.stylesheet=e,this._serializedLayers=null,this.fire(new t.n("style.load",{style:this})),!0}_getOperationsToPerform(e){const t=[],i=[];for(const n of e)switch(n.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":t.push(()=>this.addLayer.apply(this,n.args));break;case"removeLayer":t.push(()=>this.removeLayer.apply(this,n.args));break;case"setPaintProperty":t.push(()=>this.setPaintProperty.apply(this,n.args));break;case"setLayoutProperty":t.push(()=>this.setLayoutProperty.apply(this,n.args));break;case"setFilter":t.push(()=>this.setFilter.apply(this,n.args));break;case"addSource":t.push(()=>this.addSource.apply(this,n.args));break;case"removeSource":t.push(()=>this.removeSource.apply(this,n.args));break;case"setLayerZoomRange":t.push(()=>this.setLayerZoomRange.apply(this,n.args));break;case"setLight":t.push(()=>this.setLight.apply(this,n.args));break;case"setGeoJSONSourceData":t.push(()=>this.setGeoJSONSourceData.apply(this,n.args));break;case"setGlyphs":t.push(()=>this.setGlyphs.apply(this,n.args));break;case"setSprite":t.push(()=>this.setSprite.apply(this,n.args));break;case"setTerrain":t.push(()=>this.map.setTerrain.apply(this,n.args));break;case"setSky":t.push(()=>this.setSky.apply(this,n.args));break;case"setProjection":this.setProjection.apply(this,n.args);break;case"setGlobalState":t.push(()=>this.setGlobalState.apply(this,n.args));break;case"setTransition":t.push(()=>{});break;default:i.push(n.command)}return{operations:t,unimplemented:i}}addImage(e,i){if(this.getImage(e))return this.fire(new t.l(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,i),this._afterImageUpdated(e)}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new t.l(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.n("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,i,n={}){var r;if(this._checkLoaded(),void 0!==this.tileManagers[e])throw new Error(`Source "${e}" already exists.`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].includes(i.type)&&this._validate(t.F.source,`sources.${e}`,i,null,n))return;(null===(r=this.map)||void 0===r?void 0:r._collectResourceTiming)&&(i.collectResourceTiming=!0);const o=this.tileManagers[e]=new ze(e,i,this.dispatcher);o.style=this,o.setEventedParent(this,()=>({isSourceLoaded:o.loaded(),source:o.serialize(),sourceId:e})),o.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),void 0===this.tileManagers[e])throw new Error(`There is no source with this ID=${e}`);for(const i in this._layers)if(this._layers[i].source===e)return this.fire(new t.l(new Error(`Source "${e}" cannot be removed while layer "${i}" is using it.`)));const i=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],i.fire(new t.n("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,t){if(this._checkLoaded(),void 0===this.tileManagers[e])throw new Error(`There is no source with this ID=${e}`);const i=this.tileManagers[e].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(t),this._changed=!0}getSource(e){var t;return null===(t=this.tileManagers[e])||void 0===t?void 0:t.getSource()}addLayer(e,i,n={}){this._checkLoaded();const r=e.id;if(this.getLayer(r))return void this.fire(new t.l(new Error(`Layer "${r}" already exists on this map.`)));let o;if("custom"===e.type){if(Ri(this,t.bX(e)))return;o=t.bT(e,this._globalState)}else{if("source"in e&&"object"==typeof e.source&&(this.addSource(r,e.source),e=t.bV(e),e=t.e(e,{source:r})),this._validate(t.F.layer,`layers.${r}`,e,{arrayIndex:-1},n))return;o=t.bT(e,this._globalState),this._validateLayer(o),o.setEventedParent(this,{layer:{id:r}})}const s=i?this._order.indexOf(i):this._order.length;if(i&&-1===s)this.fire(new t.l(new Error(`Cannot add layer "${r}" before non-existing layer "${i}".`)));else{if(this._order.splice(s,0,r),this._layerOrderChanged=!0,this._layers[r]=o,this._removedLayers[r]&&o.source&&"custom"!==o.type){const e=this._removedLayers[r];delete this._removedLayers[r],e.type!==o.type?this._updatedSources[o.source]="clear":(this._updatedSources[o.source]="reload",this.tileManagers[o.source].pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map)}}moveLayer(e,i){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.l(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===i)return;const n=this._order.indexOf(e);this._order.splice(n,1);const r=i?this._order.indexOf(i):this._order.length;i&&-1===r?this.fire(new t.l(new Error(`Cannot move layer "${e}" before non-existing layer "${i}".`))):(this._order.splice(r,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();const i=this._layers[e];if(!i)return void this.fire(new t.l(new Error(`Cannot remove non-existing layer "${e}".`)));i.setEventedParent(null);const n=this._order.indexOf(e);this._order.splice(n,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=i,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],i.onRemove&&i.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,i,n){this._checkLoaded();const r=this.getLayer(e);r?r.minzoom===i&&r.maxzoom===n||(null!=i&&(r.minzoom=i),null!=n&&(r.maxzoom=n),this._updateLayer(r)):this.fire(new t.l(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,i,n={}){this._checkLoaded();const r=this.getLayer(e);if(r){if(!t.bQ(r.filter,i))return null==i?(r.setFilter(void 0),void this._updateLayer(r)):void(this._validate(t.F.filter,`layers.${r.id}.filter`,i,null,n)||(r.setFilter(t.bV(i)),this._updateLayer(r)))}else this.fire(new t.l(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return t.bV(this.getLayer(e).filter)}setLayoutProperty(e,i,n,r={}){this._checkLoaded();const o=this.getLayer(e);o?t.bQ(o.getLayoutProperty(i),n)||(o.setLayoutProperty(i,n,r),this._updateLayer(o)):this.fire(new t.l(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,i){const n=this.getLayer(e);if(n)return n.getLayoutProperty(i);this.fire(new t.l(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,i,n,r={}){this._checkLoaded();const o=this.getLayer(e);o?t.bQ(o.getPaintProperty(i),n)||this._updatePaintProperty(o,i,n,r):this.fire(new t.l(new Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,i,n,r={}){e.setPaintProperty(i,n,r)&&this._updateLayer(e),t.bU(e)&&"raster-fade-duration"===i&&this.tileManagers[e.source].setRasterFadeDuration(n),this._changed=!0,this._updatedPaintProps[e.id]=!0,this._serializedLayers=null}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,i){this._checkLoaded();const n=e.source,r=e.sourceLayer,o=this.tileManagers[n];if(void 0===o)return void this.fire(new t.l(new Error(`The source '${n}' does not exist in the map's style.`)));const s=o.getSource().type;"geojson"===s&&r?this.fire(new t.l(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==s||r?(void 0===e.id&&this.fire(new t.l(new Error("The feature id parameter must be provided."))),o.setFeatureState(r,e.id,i)):this.fire(new t.l(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,i){this._checkLoaded();const n=e.source,r=this.tileManagers[n];if(void 0===r)return void this.fire(new t.l(new Error(`The source '${n}' does not exist in the map's style.`)));const o=r.getSource().type,s="vector"===o?e.sourceLayer:void 0;"vector"!==o||s?i&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new t.l(new Error("A feature id is required to remove its specific state property."))):r.removeFeatureState(s,e.id,i):this.fire(new t.l(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();const i=e.source,n=e.sourceLayer,r=this.tileManagers[i];if(void 0!==r)return"vector"!==r.getSource().type||n?(void 0===e.id&&this.fire(new t.l(new Error("The feature id parameter must be provided."))),r.getFeatureState(n,e.id)):void this.fire(new t.l(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new t.l(new Error(`The source '${i}' does not exist in the map's style.`)))}getTransition(){var e;return t.e({duration:300,delay:0},null===(e=this.stylesheet)||void 0===e?void 0:e.transition)}serialize(){if(!this._loaded)return;const e=t.bY(this.tileManagers,e=>e.serialize()),i=this._serializeByIds(this._order,!0),n=this.map.getTerrain()||void 0,r=this.stylesheet;return t.bZ({version:r.version,name:r.name,metadata:r.metadata,light:r.light,sky:r.sky,center:r.center,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch,sprite:r.sprite,glyphs:r.glyphs,transition:r.transition,projection:r.projection,sources:e,layers:i,terrain:n},e=>void 0!==e)}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&"raster"!==this.tileManagers[e.source].getSource().type&&(this._updatedSources[e.source]="reload",this.tileManagers[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._layers[e].type,i={},n=[];for(let r=this._order.length-1;r>=0;r--){const o=this._order[r];if(t(o)){i[o]=r;for(const t of e){const e=t[o];if(e)for(const t of e)n.push(t)}}}n.sort((e,t)=>t.intersectionZ-e.intersectionZ);const r=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if(t(s))for(let e=n.length-1;e>=0;e--){const t=n[e].feature;if(i[t.layer.id]<o)break;r.push(t),n.pop()}else for(const t of e){const e=t[s];if(e)for(const t of e)r.push(t.feature)}}return r}queryRenderedFeatures(e,i,n){(null==i?void 0:i.filter)&&this._validate(t.F.filter,"queryRenderedFeatures.filter",i.filter,null,i);const r={};if(null==i?void 0:i.layers){if(!(Array.isArray(i.layers)||i.layers instanceof Set))return this.fire(new t.l(new Error("parameters.layers must be an Array or a Set of strings"))),[];for(const e of i.layers){const i=this._layers[e];if(!i)return this.fire(new t.l(new Error(`The layer '${e}' does not exist in the map's style and cannot be queried for features.`))),[];r[i.source]=!0}}const o=[];i.availableImages=this._availableImages;const s=this._serializedAllLayers(),a=i.layers instanceof Set?i.layers:Array.isArray(i.layers)?new Set(i.layers):null,l=Object.assign(Object.assign({},i),{layers:a,globalState:this._globalState});for(const t in this.tileManagers)i.layers&&!r[t]||o.push(B(this.tileManagers[t],this._layers,s,e,l,n,this.map.terrain?(e,t,i)=>this.map.terrain.getElevation(e,t,i):void 0));return this.placement&&o.push(function(e,t,i,n,r,o,s){const a={},l=o.queryRenderedSymbols(n),c=[];for(const e of Object.keys(l).map(Number))c.push(s[e]);c.sort(G);for(const i of c){const n=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,{filterSpec:r.filter,globalState:r.globalState},r.layers,r.availableImages,e);for(const e in n){a[e]||(a[e]=[]);const t=n[e];t.sort((e,t)=>{const n=i.featureSortOrder;if(n){const i=n.indexOf(e.featureIndex);return n.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex});for(const i of t)a[e].push(i)}}return function(e,t,i){for(const n in e)for(const r of e[n])j(r,i[t[n].source]);return e}(a,e,i)}(this._layers,s,this.tileManagers,e,l,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(e,i){(null==i?void 0:i.filter)&&this._validate(t.F.filter,"querySourceFeatures.filter",i.filter,null,i);const n=this.tileManagers[e];return n?function(e,t){const i=e.getRenderableIds().map(t=>e.getTileByID(t)),n=[],r={};for(const e of i){const i=e.tileID.canonical.key;r[i]||(r[i]=!0,e.querySourceFeatures(n,t))}return n}(n,i?Object.assign(Object.assign({},i),{globalState:this._globalState}):{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(e,i={}){this._checkLoaded();const n=this.light.getLight();let r=!1;for(const i in e)if(!t.bQ(e[i],n[i])){r=!0;break}if(!r)return;const o={now:c(),transition:t.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,i),this.light.updateTransitions(o)}getProjection(){var e;return null===(e=this.stylesheet)||void 0===e?void 0:e.projection}setProjection(e){this._checkLoaded();const t=null!=e?e:{type:"mercator"};if(this.stylesheet.projection=e,this.projection){if(this.projection.name===t.type)return;this.projection.destroy(),delete this.projection}this._setProjectionInternal(t.type)}getSky(){var e;return null===(e=this.stylesheet)||void 0===e?void 0:e.sky}setSky(e,i={}){this._checkLoaded();const n=this.getSky();let r=!1;if(!e&&!n)return;if(e&&!n)r=!0;else if(!e&&n)r=!0;else for(const i in e)if(!t.bQ(e[i],n[i])){r=!0;break}if(!r)return;const o={now:c(),transition:t.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=e,this.sky.setSky(e,i),this.sky.updateTransitions(o)}_setProjectionInternal(e){const i=function(e,i){const n={constrainOverride:i};if(Array.isArray(e)){const t=new pi({type:e});return{projection:t,transform:new Ai(n),cameraHelper:new Di(t)}}switch(e){case"mercator":return{projection:new jt,transform:new Xt(n),cameraHelper:new Qt};case"globe":{const e=new pi({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]});return{projection:e,transform:new Ai(n),cameraHelper:new Di(e)}}case"vertical-perspective":return{projection:new hi,transform:new Pi(n),cameraHelper:new Li};default:return t.w(`Unknown projection name: ${e}. Falling back to mercator projection.`),{projection:new jt,transform:new Xt(n),cameraHelper:new Qt}}}(e,this.map.transformConstrain);this.projection=i.projection,this.map.migrateProjection(i.transform,i.cameraHelper);for(const e in this.tileManagers)this.tileManagers[e].reload()}_validate(e,i,n,r,o={}){return!1!==(null==o?void 0:o.validate)&&Ri(this,e.call(t.F,t.e({key:i,style:this.serialize(),value:n,styleSpec:t.x},r)))}_remove(e=!0){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null),ce().off(se,this._rtlPluginLoaded);for(const e in this._layers)this._layers[e].setEventedParent(null);for(const e in this.tileManagers){const t=this.tileManagers[e];t.setEventedParent(null),t.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),e&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(e)}_clearSource(e){this.tileManagers[e].clearTiles()}_reloadSource(e){this.tileManagers[e].resume(),this.tileManagers[e].reload()}_updateSources(e){for(const t in this.tileManagers)this.tileManagers[t].update(e,this.map.terrain)}_generateCollisionBoxes(){for(const e in this.tileManagers)this._reloadSource(e)}_updatePlacement(e,t,i,n,r=!1){let o=!1,s=!1;const a={};for(const t of this._order){const i=this._layers[t];if("symbol"!==i.type)continue;if(!a[i.source]){const e=this.tileManagers[i.source];a[i.source]=e.getRenderableIds(!0).map(t=>e.getTileByID(t)).sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1))}const n=this.crossTileSymbolIndex.addLayer(i,a[i.source],e.center.lng);o||(o=n)}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),r||(r=this._layerOrderChanged||0===i),(r||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(c(),e.zoom))&&(this.pauseablePlacement=new Mt(e,this.map.terrain,this._order,r,t,i,n,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,a),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(c()),s=!0),o&&this.pauseablePlacement.placement.setStale()),s||o)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,a[t.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(c())}_releaseSymbolFadeTiles(){for(const e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles()}getImages(e,i){return t._(this,void 0,void 0,function*(){const e=yield this.imageManager.getImages(i.icons);this._updateTilesForChangedImages();const t=this.tileManagers[i.source];return t&&t.setDependencies(i.tileID.key,i.type,i.icons),e})}getGlyphs(e,i){return t._(this,void 0,void 0,function*(){const e=yield this.glyphManager.getGlyphs(i.stacks),t=this.tileManagers[i.source];return t&&t.setDependencies(i.tileID.key,i.type,[""]),e})}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,i={}){this._checkLoaded(),e&&this._validate(t.F.glyphs,"glyphs",e,null,i)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}getDashes(e,i){return t._(this,void 0,void 0,function*(){const e={};for(const[t,n]of Object.entries(i.dashes))e[t]=this.lineAtlas.getDash(n.dasharray,n.round);return e})}addSprite(e,i,n={},r){this._checkLoaded();const o=[{id:e,url:i}],s=[...f(this.stylesheet.sprite),...o];this._validate(t.F.sprite,"sprite",s,null,n)||(this.stylesheet.sprite=s,this._loadSprite(o,!0,r))}removeSprite(e){this._checkLoaded();const i=f(this.stylesheet.sprite);if(i.find(t=>t.id===e)){if(this._spritesImagesIds[e])for(const t of this._spritesImagesIds[e])this.imageManager.removeImage(t),this._changedImages[t]=!0;i.splice(i.findIndex(t=>t.id===e),1),this.stylesheet.sprite=i.length>0?i:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.n("data",{dataType:"style"}))}else this.fire(new t.l(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return f(this.stylesheet.sprite)}setSprite(e,i={},n){this._checkLoaded(),e&&this._validate(t.F.sprite,"sprite",e,null,i)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,n):(this._unloadSprite(),n&&n(null)))}destroy(){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null);for(const e in this.tileManagers){const t=this.tileManagers[e];t.setEventedParent(null),t.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this._availableImages=[],this._spritesImagesIds={}),this.glyphManager&&this.glyphManager.destroy();for(const e in this._layers){const t=this._layers[e];t.setEventedParent(null),t.onRemove&&t.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={}}}var Oi=t.aS([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Ni{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,t,i,n,r,o,s,a,l){this.context=e;let c=this.boundPaintVertexBuffers.length!==n.length;for(let e=0;!c&&e<n.length;e++)this.boundPaintVertexBuffers[e]!==n[e]&&(c=!0);!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==i||c||this.boundIndexBuffer!==r||this.boundVertexOffset!==o||this.boundDynamicVertexBuffer!==s||this.boundDynamicVertexBuffer2!==a||this.boundDynamicVertexBuffer3!==l?this.freshBind(t,i,n,r,o,s,a,l):(e.bindVertexArray.set(this.vao),s&&s.bind(),(null==r?void 0:r.dynamicDraw)&&r.bind(),a&&a.bind(),l&&l.bind())}freshBind(e,t,i,n,r,o,s,a){const l=e.numAttributes,c=this.context,u=c.gl;this.vao&&this.destroy(),this.vao=c.createVertexArray(),c.bindVertexArray.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=n,this.boundVertexOffset=r,this.boundDynamicVertexBuffer=o,this.boundDynamicVertexBuffer2=s,this.boundDynamicVertexBuffer3=a,t.enableAttributes(u,e);for(const t of i)t.enableAttributes(u,e);o&&o.enableAttributes(u,e),s&&s.enableAttributes(u,e),a&&a.enableAttributes(u,e),t.bind(),t.setVertexAttribPointers(u,e,r);for(const t of i)t.bind(),t.setVertexAttribPointers(u,e,r);o&&(o.bind(),o.setVertexAttribPointers(u,e,r)),n&&n.bind(),s&&(s.bind(),s.setVertexAttribPointers(u,e,r)),a&&(a.bind(),a.setVertexAttribPointers(u,e,r)),c.currentNumAttributes=l}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const Bi=(e,i,n,r,o)=>({u_texture:0,u_ele_delta:e,u_fog_matrix:i,u_fog_color:n?n.properties.get("fog-color"):t.bo.white,u_fog_ground_blend:n?n.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:o?0:n?n.calculateFogBlendOpacity(r):0,u_horizon_color:n?n.properties.get("horizon-color"):t.bo.white,u_horizon_fog_blend:n?n.properties.get("horizon-fog-blend"):1,u_is_globe_mode:o?1:0}),Gi={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function ji(e){const t=[];for(const i of e){if(null===i)continue;const e=i.split(" ");t.push(e.pop())}return t}class Vi{constructor(e,i,n,r,o,s,a,l,c=[]){const u=e.gl;this.program=u.createProgram();const h=ji(i.staticAttributes),d=n?n.getBinderAttributes():[],p=h.concat(d),f=zt.prelude.staticUniforms?ji(zt.prelude.staticUniforms):[],m=a.staticUniforms?ji(a.staticUniforms):[],g=i.staticUniforms?ji(i.staticUniforms):[],y=n?n.getBinderUniforms():[],_=f.concat(m).concat(g).concat(y),v=[];for(const e of _)v.includes(e)||v.push(e);const x=n?n.defines():[];si(u)&&x.unshift("#version 300 es"),o&&x.push("#define OVERDRAW_INSPECTOR;"),s&&x.push("#define TERRAIN3D;"),l&&x.push(l),c&&x.push(...c);let b=x.concat(zt.prelude.fragmentSource,a.fragmentSource,i.fragmentSource).join("\n"),w=x.concat(zt.prelude.vertexSource,a.vertexSource,i.vertexSource).join("\n");si(u)||(b=function(e){return e.replace(/\bin\s/g,"varying ").replace("out highp vec4 fragColor;","").replace(/fragColor/g,"gl_FragColor").replace(/texture\(/g,"texture2D(")}(b),w=function(e){return e.replace(/\bin\s/g,"attribute ").replace(/\bout\s/g,"varying ").replace(/texture\(/g,"texture2D(")}(w));const E=u.createShader(u.FRAGMENT_SHADER);if(u.isContextLost())return void(this.failedToCreate=!0);if(u.shaderSource(E,b),u.compileShader(E),!u.getShaderParameter(E,u.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${u.getShaderInfoLog(E)}`);u.attachShader(this.program,E);const T=u.createShader(u.VERTEX_SHADER);if(u.isContextLost())return void(this.failedToCreate=!0);if(u.shaderSource(T,w),u.compileShader(T),!u.getShaderParameter(T,u.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${u.getShaderInfoLog(T)}`);u.attachShader(this.program,T),this.attributes={};const S={};this.numAttributes=p.length;for(let e=0;e<this.numAttributes;e++)p[e]&&(u.bindAttribLocation(this.program,e,p[e]),this.attributes[p[e]]=e);if(u.linkProgram(this.program),!u.getProgramParameter(this.program,u.LINK_STATUS))throw new Error(`Program failed to link: ${u.getProgramInfoLog(this.program)}`);u.deleteShader(T),u.deleteShader(E);for(const e of v)if(e&&!S[e]){const t=u.getUniformLocation(this.program,e);t&&(S[e]=t)}this.fixedUniforms=r(e,S),this.terrainUniforms=((e,i)=>({u_depth:new t.b_(e,i.u_depth),u_terrain:new t.b_(e,i.u_terrain),u_terrain_dim:new t.bp(e,i.u_terrain_dim),u_terrain_matrix:new t.c0(e,i.u_terrain_matrix),u_terrain_unpack:new t.c1(e,i.u_terrain_unpack),u_terrain_exaggeration:new t.bp(e,i.u_terrain_exaggeration)}))(e,S),this.projectionUniforms=((e,i)=>({u_projection_matrix:new t.c0(e,i.u_projection_matrix),u_projection_tile_mercator_coords:new t.c1(e,i.u_projection_tile_mercator_coords),u_projection_clipping_plane:new t.c1(e,i.u_projection_clipping_plane),u_projection_transition:new t.bp(e,i.u_projection_transition),u_projection_fallback_matrix:new t.c0(e,i.u_projection_fallback_matrix)}))(e,S),this.binderUniforms=n?n.getUniforms(e,S):[]}draw(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,y,_){var v;const x=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(i),e.setStencilMode(n),e.setColorMode(r),e.setCullFace(o),a){e.activeTexture.set(x.TEXTURE2),x.bindTexture(x.TEXTURE_2D,a.depthTexture),e.activeTexture.set(x.TEXTURE3),x.bindTexture(x.TEXTURE_2D,a.texture);for(const e in this.terrainUniforms)this.terrainUniforms[e].set(a[e])}if(l)for(const e in l)this.projectionUniforms[Gi[e]].set(l[e]);if(s)for(const e in this.fixedUniforms)this.fixedUniforms[e].set(s[e]);m&&m.setUniforms(e,this.binderUniforms,p,{zoom:f});let b=0;switch(t){case x.LINES:b=2;break;case x.TRIANGLES:b=3;break;case x.LINE_STRIP:b=1}for(const i of d.get())i.vaos||(i.vaos={}),(v=i.vaos)[c]||(v[c]=new Ni),i.vaos[c].bind(e,this,u,m?m.getPaintVertexBuffers():[],h,i.vertexOffset,g,y,_),x.drawElements(t,i.primitiveLength*b,x.UNSIGNED_SHORT,i.primitiveOffset*b*2)}}function Ui(e,i,n){const r=1/t.aK(n,1,i.transform.tileZoom),o=Math.pow(2,n.tileID.overscaledZ),s=n.tileSize*Math.pow(2,i.transform.tileZoom)/o,a=s*(n.tileID.canonical.x+n.tileID.wrap*o),l=s*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[r,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[a>>16,l>>16],u_pixel_coord_lower:[65535&a,65535&l]}}const qi=(e,i,n,r)=>{const o=e.style.light,s=o.properties.get("position"),a=[s.x,s.y,s.z],l=t.c4();"viewport"===o.properties.get("anchor")&&t.c5(l,e.transform.bearingInRadians),t.c6(a,a,l);const c=e.transform.transformLightDirection(a),u=o.properties.get("color");return{u_lightpos:a,u_lightpos_globe:c,u_lightintensity:o.properties.get("intensity"),u_lightcolor:[u.r,u.g,u.b],u_vertical_gradient:+i,u_opacity:n,u_fill_translate:r}},Zi=(e,i,n,r,o,s,a)=>t.e(qi(e,i,n,r),Ui(s,e,a),{u_height_factor:-Math.pow(2,o.overscaledZ)/a.tileSize/8}),$i=(e,i,n,r)=>t.e(Ui(i,e,n),{u_fill_translate:r}),Hi=(e,t)=>({u_world:e,u_fill_translate:t}),Wi=(e,i,n,r,o)=>t.e($i(e,i,n,o),{u_world:r}),Xi=(e,i,n,r,o)=>{const s=e.transform;let a,l,c=0;if("map"===n.paint.get("circle-pitch-alignment")){const e=t.aK(i,1,s.zoom);a=!0,l=[e,e],c=e/(t.a6*Math.pow(2,i.tileID.overscaledZ))*2*Math.PI*o}else a=!1,l=s.pixelsToGLUnits;return{u_camera_to_center_distance:s.cameraToCenterDistance,u_scale_with_map:+("map"===n.paint.get("circle-pitch-scale")),u_pitch_with_map:+a,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:l,u_globe_extrude_scale:c,u_translate:r}},Yi=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),Ji=e=>({u_viewport_size:[e.width,e.height]}),Ki=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),Qi=(e,i,n,r)=>{const o=t.aK(e,1,i)/(t.a6*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*r;return{u_extrude_scale:t.aK(e,1,i),u_intensity:n,u_globe_extrude_scale:o}},en=(e,i,n,r)=>{const o=t.O();t.c7(o,0,e.width,e.height,0,0,1);const s=e.context.gl;return{u_matrix:o,u_world:[s.drawingBufferWidth,s.drawingBufferHeight],u_image:n,u_color_ramp:r,u_opacity:i.paint.get("heatmap-opacity")}},tn=(e,t,i)=>{const n=i.paint.get("hillshade-accent-color");let r;switch(i.paint.get("hillshade-method")){case"basic":r=4;break;case"combined":r=1;break;case"igor":r=2;break;case"multidirectional":r=3;break;default:r=0}const o=i.getIlluminationProperties();for(let t=0;t<o.directionRadians.length;t++)"viewport"===i.paint.get("hillshade-illumination-anchor")&&(o.directionRadians[t]+=e.transform.bearingInRadians);return{u_image:0,u_latrange:rn(0,t.tileID),u_exaggeration:i.paint.get("hillshade-exaggeration"),u_altitudes:o.altitudeRadians,u_azimuths:o.directionRadians,u_accent:n,u_method:r,u_highlights:o.highlightColor,u_shadows:o.shadowColor}},nn=(e,i)=>{const n=i.stride,r=t.O();return t.c7(r,0,t.a6,-t.a6,0,0,1),t.Q(r,r,[0,-t.a6,0]),{u_matrix:r,u_image:1,u_dimension:[n,n],u_zoom:e.overscaledZ,u_unpack:i.getUnpackVector()}};function rn(e,i){const n=Math.pow(2,i.canonical.z),r=i.canonical.y;return[new t.a7(0,r/n).toLngLat().lat,new t.a7(0,(r+1)/n).toLngLat().lat]}const on=(e,t,i=0)=>({u_image:0,u_unpack:t.getUnpackVector(),u_dimension:[t.stride,t.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:i,u_opacity:e.paint.get("color-relief-opacity")}),sn=(e,i,n,r)=>{const o=e.transform;return{u_translation:dn(e,i,n),u_ratio:r/t.aK(i,1,o.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},an=(e,i,n,r,o)=>t.e(sn(e,i,n,r),{u_image:0,u_image_height:o}),ln=(e,i,n,r,o)=>{const s=e.transform,a=hn(i,s);return{u_translation:dn(e,i,n),u_texsize:i.imageAtlasTexture.size,u_ratio:r/t.aK(i,1,s.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[a,o.fromScale,o.toScale],u_fade:o.t,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]]}},cn=(e,i,n,r,o)=>{const s=hn(i,e.transform);return t.e(sn(e,i,n,r),{u_tileratio:s,u_crossfade_from:o.fromScale,u_crossfade_to:o.toScale,u_image:0,u_mix:o.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})},un=(e,i,n,r,o,s)=>{const a=hn(i,e.transform);return t.e(sn(e,i,n,r),{u_image:0,u_image_height:s,u_tileratio:a,u_crossfade_from:o.fromScale,u_crossfade_to:o.toScale,u_image_dash:1,u_mix:o.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})};function hn(e,i){return 1/t.aK(e,1,i.tileZoom)}function dn(e,i,n){return t.aL(e.transform,i,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const pn=(e,t,i,n,r)=>{return{u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_fade_t:i.mix,u_opacity:i.opacity*n.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:n.paint.get("raster-brightness-min"),u_brightness_high:n.paint.get("raster-brightness-max"),u_saturation_factor:(s=n.paint.get("raster-saturation"),s>0?1-1/(1.001-s):-s),u_contrast_factor:(o=n.paint.get("raster-contrast"),o>0?1/(1-o):1+o),u_spin_weights:fn(n.paint.get("raster-hue-rotate")),u_coords_top:[r[0].x,r[0].y,r[1].x,r[1].y],u_coords_bottom:[r[3].x,r[3].y,r[2].x,r[2].y]};var o,s};function fn(e){e*=Math.PI/180;const t=Math.sin(e),i=Math.cos(e);return[(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}const mn=(e,t,i,n,r,o,s,a,l,c,u,h,d)=>{const p=s.transform;return{u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:p.cameraToCenterDistance,u_pitch:p.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:p.width/p.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+u,u_pitch_with_map:+n,u_is_along_line:r,u_is_variable_anchor:o,u_texsize:h,u_texture:0,u_translation:c,u_pitched_scale:d}},gn=(e,i,n,r,o,s,a,l,c,u,h,d,p,f)=>{const m=a.transform;return t.e(mn(e,i,n,r,o,s,a,l,c,u,h,d,f),{u_gamma_scale:r?Math.cos(m.pitch*Math.PI/180)*m.cameraToCenterDistance:1,u_device_pixel_ratio:a.pixelRatio,u_is_halo:p?1:0,u_is_plain:1})},yn=(e,i,n,r,o,s,a,l,c,u,h,d,p)=>t.e(gn(e,i,n,r,o,s,a,l,c,u,!0,h,!0,p),{u_texsize_icon:d,u_texture_icon:1}),_n=(e,t)=>({u_opacity:e,u_color:t}),vn=(e,i,n,r,o)=>t.e(function(e,i,n,r){const o=n.imageManager.getPattern(e.from.toString()),s=n.imageManager.getPattern(e.to.toString()),{width:a,height:l}=n.imageManager.getPixelSize(),c=Math.pow(2,r.tileID.overscaledZ),u=r.tileSize*Math.pow(2,n.transform.tileZoom)/c,h=u*(r.tileID.canonical.x+r.tileID.wrap*c),d=u*r.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:[a,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/t.aK(r,1,n.transform.tileZoom),u_pixel_coord_upper:[h>>16,d>>16],u_pixel_coord_lower:[65535&h,65535&d]}}(n,o,i,r),{u_opacity:e}),xn=(e,t)=>{},bn={fillExtrusion:(e,i)=>({u_lightpos:new t.c2(e,i.u_lightpos),u_lightpos_globe:new t.c2(e,i.u_lightpos_globe),u_lightintensity:new t.bp(e,i.u_lightintensity),u_lightcolor:new t.c2(e,i.u_lightcolor),u_vertical_gradient:new t.bp(e,i.u_vertical_gradient),u_opacity:new t.bp(e,i.u_opacity),u_fill_translate:new t.c3(e,i.u_fill_translate)}),fillExtrusionPattern:(e,i)=>({u_lightpos:new t.c2(e,i.u_lightpos),u_lightpos_globe:new t.c2(e,i.u_lightpos_globe),u_lightintensity:new t.bp(e,i.u_lightintensity),u_lightcolor:new t.c2(e,i.u_lightcolor),u_vertical_gradient:new t.bp(e,i.u_vertical_gradient),u_height_factor:new t.bp(e,i.u_height_factor),u_opacity:new t.bp(e,i.u_opacity),u_fill_translate:new t.c3(e,i.u_fill_translate),u_image:new t.b_(e,i.u_image),u_texsize:new t.c3(e,i.u_texsize),u_pixel_coord_upper:new t.c3(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c3(e,i.u_pixel_coord_lower),u_scale:new t.c2(e,i.u_scale),u_fade:new t.bp(e,i.u_fade)}),fill:(e,i)=>({u_fill_translate:new t.c3(e,i.u_fill_translate)}),fillPattern:(e,i)=>({u_image:new t.b_(e,i.u_image),u_texsize:new t.c3(e,i.u_texsize),u_pixel_coord_upper:new t.c3(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c3(e,i.u_pixel_coord_lower),u_scale:new t.c2(e,i.u_scale),u_fade:new t.bp(e,i.u_fade),u_fill_translate:new t.c3(e,i.u_fill_translate)}),fillOutline:(e,i)=>({u_world:new t.c3(e,i.u_world),u_fill_translate:new t.c3(e,i.u_fill_translate)}),fillOutlinePattern:(e,i)=>({u_world:new t.c3(e,i.u_world),u_image:new t.b_(e,i.u_image),u_texsize:new t.c3(e,i.u_texsize),u_pixel_coord_upper:new t.c3(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c3(e,i.u_pixel_coord_lower),u_scale:new t.c2(e,i.u_scale),u_fade:new t.bp(e,i.u_fade),u_fill_translate:new t.c3(e,i.u_fill_translate)}),circle:(e,i)=>({u_camera_to_center_distance:new t.bp(e,i.u_camera_to_center_distance),u_scale_with_map:new t.b_(e,i.u_scale_with_map),u_pitch_with_map:new t.b_(e,i.u_pitch_with_map),u_extrude_scale:new t.c3(e,i.u_extrude_scale),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_globe_extrude_scale:new t.bp(e,i.u_globe_extrude_scale),u_translate:new t.c3(e,i.u_translate)}),collisionBox:(e,i)=>({u_pixel_extrude_scale:new t.c3(e,i.u_pixel_extrude_scale)}),collisionCircle:(e,i)=>({u_viewport_size:new t.c3(e,i.u_viewport_size)}),debug:(e,i)=>({u_color:new t.b$(e,i.u_color),u_overlay:new t.b_(e,i.u_overlay),u_overlay_scale:new t.bp(e,i.u_overlay_scale)}),depth:xn,clippingMask:xn,heatmap:(e,i)=>({u_extrude_scale:new t.bp(e,i.u_extrude_scale),u_intensity:new t.bp(e,i.u_intensity),u_globe_extrude_scale:new t.bp(e,i.u_globe_extrude_scale)}),heatmapTexture:(e,i)=>({u_matrix:new t.c0(e,i.u_matrix),u_world:new t.c3(e,i.u_world),u_image:new t.b_(e,i.u_image),u_color_ramp:new t.b_(e,i.u_color_ramp),u_opacity:new t.bp(e,i.u_opacity)}),hillshade:(e,i)=>({u_image:new t.b_(e,i.u_image),u_latrange:new t.c3(e,i.u_latrange),u_exaggeration:new t.bp(e,i.u_exaggeration),u_altitudes:new t.c9(e,i.u_altitudes),u_azimuths:new t.c9(e,i.u_azimuths),u_accent:new t.b$(e,i.u_accent),u_method:new t.b_(e,i.u_method),u_shadows:new t.c8(e,i.u_shadows),u_highlights:new t.c8(e,i.u_highlights)}),hillshadePrepare:(e,i)=>({u_matrix:new t.c0(e,i.u_matrix),u_image:new t.b_(e,i.u_image),u_dimension:new t.c3(e,i.u_dimension),u_zoom:new t.bp(e,i.u_zoom),u_unpack:new t.c1(e,i.u_unpack)}),colorRelief:(e,i)=>({u_image:new t.b_(e,i.u_image),u_unpack:new t.c1(e,i.u_unpack),u_dimension:new t.c3(e,i.u_dimension),u_elevation_stops:new t.b_(e,i.u_elevation_stops),u_color_stops:new t.b_(e,i.u_color_stops),u_color_ramp_size:new t.b_(e,i.u_color_ramp_size),u_opacity:new t.bp(e,i.u_opacity)}),line:(e,i)=>({u_translation:new t.c3(e,i.u_translation),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c3(e,i.u_units_to_pixels)}),lineGradient:(e,i)=>({u_translation:new t.c3(e,i.u_translation),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c3(e,i.u_units_to_pixels),u_image:new t.b_(e,i.u_image),u_image_height:new t.bp(e,i.u_image_height)}),linePattern:(e,i)=>({u_translation:new t.c3(e,i.u_translation),u_texsize:new t.c3(e,i.u_texsize),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_image:new t.b_(e,i.u_image),u_units_to_pixels:new t.c3(e,i.u_units_to_pixels),u_scale:new t.c2(e,i.u_scale),u_fade:new t.bp(e,i.u_fade)}),lineSDF:(e,i)=>({u_translation:new t.c3(e,i.u_translation),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c3(e,i.u_units_to_pixels),u_image:new t.b_(e,i.u_image),u_mix:new t.bp(e,i.u_mix),u_tileratio:new t.bp(e,i.u_tileratio),u_crossfade_from:new t.bp(e,i.u_crossfade_from),u_crossfade_to:new t.bp(e,i.u_crossfade_to),u_lineatlas_width:new t.bp(e,i.u_lineatlas_width),u_lineatlas_height:new t.bp(e,i.u_lineatlas_height)}),lineGradientSDF:(e,i)=>({u_translation:new t.c3(e,i.u_translation),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c3(e,i.u_units_to_pixels),u_image:new t.b_(e,i.u_image),u_image_height:new t.bp(e,i.u_image_height),u_tileratio:new t.bp(e,i.u_tileratio),u_crossfade_from:new t.bp(e,i.u_crossfade_from),u_crossfade_to:new t.bp(e,i.u_crossfade_to),u_image_dash:new t.b_(e,i.u_image_dash),u_mix:new t.bp(e,i.u_mix),u_lineatlas_width:new t.bp(e,i.u_lineatlas_width),u_lineatlas_height:new t.bp(e,i.u_lineatlas_height)}),raster:(e,i)=>({u_tl_parent:new t.c3(e,i.u_tl_parent),u_scale_parent:new t.bp(e,i.u_scale_parent),u_buffer_scale:new t.bp(e,i.u_buffer_scale),u_fade_t:new t.bp(e,i.u_fade_t),u_opacity:new t.bp(e,i.u_opacity),u_image0:new t.b_(e,i.u_image0),u_image1:new t.b_(e,i.u_image1),u_brightness_low:new t.bp(e,i.u_brightness_low),u_brightness_high:new t.bp(e,i.u_brightness_high),u_saturation_factor:new t.bp(e,i.u_saturation_factor),u_contrast_factor:new t.bp(e,i.u_contrast_factor),u_spin_weights:new t.c2(e,i.u_spin_weights),u_coords_top:new t.c1(e,i.u_coords_top),u_coords_bottom:new t.c1(e,i.u_coords_bottom)}),symbolIcon:(e,i)=>({u_is_size_zoom_constant:new t.b_(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.b_(e,i.u_is_size_feature_constant),u_size_t:new t.bp(e,i.u_size_t),u_size:new t.bp(e,i.u_size),u_camera_to_center_distance:new t.bp(e,i.u_camera_to_center_distance),u_pitch:new t.bp(e,i.u_pitch),u_rotate_symbol:new t.b_(e,i.u_rotate_symbol),u_aspect_ratio:new t.bp(e,i.u_aspect_ratio),u_fade_change:new t.bp(e,i.u_fade_change),u_label_plane_matrix:new t.c0(e,i.u_label_plane_matrix),u_coord_matrix:new t.c0(e,i.u_coord_matrix),u_is_text:new t.b_(e,i.u_is_text),u_pitch_with_map:new t.b_(e,i.u_pitch_with_map),u_is_along_line:new t.b_(e,i.u_is_along_line),u_is_variable_anchor:new t.b_(e,i.u_is_variable_anchor),u_texsize:new t.c3(e,i.u_texsize),u_texture:new t.b_(e,i.u_texture),u_translation:new t.c3(e,i.u_translation),u_pitched_scale:new t.bp(e,i.u_pitched_scale)}),symbolSDF:(e,i)=>({u_is_size_zoom_constant:new t.b_(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.b_(e,i.u_is_size_feature_constant),u_size_t:new t.bp(e,i.u_size_t),u_size:new t.bp(e,i.u_size),u_camera_to_center_distance:new t.bp(e,i.u_camera_to_center_distance),u_pitch:new t.bp(e,i.u_pitch),u_rotate_symbol:new t.b_(e,i.u_rotate_symbol),u_aspect_ratio:new t.bp(e,i.u_aspect_ratio),u_fade_change:new t.bp(e,i.u_fade_change),u_label_plane_matrix:new t.c0(e,i.u_label_plane_matrix),u_coord_matrix:new t.c0(e,i.u_coord_matrix),u_is_text:new t.b_(e,i.u_is_text),u_pitch_with_map:new t.b_(e,i.u_pitch_with_map),u_is_along_line:new t.b_(e,i.u_is_along_line),u_is_variable_anchor:new t.b_(e,i.u_is_variable_anchor),u_texsize:new t.c3(e,i.u_texsize),u_texture:new t.b_(e,i.u_texture),u_gamma_scale:new t.bp(e,i.u_gamma_scale),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_is_halo:new t.b_(e,i.u_is_halo),u_is_plain:new t.b_(e,i.u_is_plain),u_translation:new t.c3(e,i.u_translation),u_pitched_scale:new t.bp(e,i.u_pitched_scale)}),symbolTextAndIcon:(e,i)=>({u_is_size_zoom_constant:new t.b_(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.b_(e,i.u_is_size_feature_constant),u_size_t:new t.bp(e,i.u_size_t),u_size:new t.bp(e,i.u_size),u_camera_to_center_distance:new t.bp(e,i.u_camera_to_center_distance),u_pitch:new t.bp(e,i.u_pitch),u_rotate_symbol:new t.b_(e,i.u_rotate_symbol),u_aspect_ratio:new t.bp(e,i.u_aspect_ratio),u_fade_change:new t.bp(e,i.u_fade_change),u_label_plane_matrix:new t.c0(e,i.u_label_plane_matrix),u_coord_matrix:new t.c0(e,i.u_coord_matrix),u_is_text:new t.b_(e,i.u_is_text),u_pitch_with_map:new t.b_(e,i.u_pitch_with_map),u_is_along_line:new t.b_(e,i.u_is_along_line),u_is_variable_anchor:new t.b_(e,i.u_is_variable_anchor),u_texsize:new t.c3(e,i.u_texsize),u_texsize_icon:new t.c3(e,i.u_texsize_icon),u_texture:new t.b_(e,i.u_texture),u_texture_icon:new t.b_(e,i.u_texture_icon),u_gamma_scale:new t.bp(e,i.u_gamma_scale),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_is_halo:new t.b_(e,i.u_is_halo),u_translation:new t.c3(e,i.u_translation),u_pitched_scale:new t.bp(e,i.u_pitched_scale)}),background:(e,i)=>({u_opacity:new t.bp(e,i.u_opacity),u_color:new t.b$(e,i.u_color)}),backgroundPattern:(e,i)=>({u_opacity:new t.bp(e,i.u_opacity),u_image:new t.b_(e,i.u_image),u_pattern_tl_a:new t.c3(e,i.u_pattern_tl_a),u_pattern_br_a:new t.c3(e,i.u_pattern_br_a),u_pattern_tl_b:new t.c3(e,i.u_pattern_tl_b),u_pattern_br_b:new t.c3(e,i.u_pattern_br_b),u_texsize:new t.c3(e,i.u_texsize),u_mix:new t.bp(e,i.u_mix),u_pattern_size_a:new t.c3(e,i.u_pattern_size_a),u_pattern_size_b:new t.c3(e,i.u_pattern_size_b),u_scale_a:new t.bp(e,i.u_scale_a),u_scale_b:new t.bp(e,i.u_scale_b),u_pixel_coord_upper:new t.c3(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c3(e,i.u_pixel_coord_lower),u_tile_units_to_pixels:new t.bp(e,i.u_tile_units_to_pixels)}),terrain:(e,i)=>({u_texture:new t.b_(e,i.u_texture),u_ele_delta:new t.bp(e,i.u_ele_delta),u_fog_matrix:new t.c0(e,i.u_fog_matrix),u_fog_color:new t.b$(e,i.u_fog_color),u_fog_ground_blend:new t.bp(e,i.u_fog_ground_blend),u_fog_ground_blend_opacity:new t.bp(e,i.u_fog_ground_blend_opacity),u_horizon_color:new t.b$(e,i.u_horizon_color),u_horizon_fog_blend:new t.bp(e,i.u_horizon_fog_blend),u_is_globe_mode:new t.bp(e,i.u_is_globe_mode)}),terrainDepth:(e,i)=>({u_ele_delta:new t.bp(e,i.u_ele_delta)}),terrainCoords:(e,i)=>({u_texture:new t.b_(e,i.u_texture),u_terrain_coords_id:new t.bp(e,i.u_terrain_coords_id),u_ele_delta:new t.bp(e,i.u_ele_delta)}),projectionErrorMeasurement:(e,i)=>({u_input:new t.bp(e,i.u_input),u_output_expected:new t.bp(e,i.u_output_expected)}),atmosphere:(e,i)=>({u_sun_pos:new t.c2(e,i.u_sun_pos),u_atmosphere_blend:new t.bp(e,i.u_atmosphere_blend),u_globe_position:new t.c2(e,i.u_globe_position),u_globe_radius:new t.bp(e,i.u_globe_radius),u_inv_proj_matrix:new t.c0(e,i.u_inv_proj_matrix)}),sky:(e,i)=>({u_sky_color:new t.b$(e,i.u_sky_color),u_horizon_color:new t.b$(e,i.u_horizon_color),u_horizon:new t.c3(e,i.u_horizon),u_horizon_normal:new t.c3(e,i.u_horizon_normal),u_sky_horizon_blend:new t.bp(e,i.u_sky_horizon_blend),u_sky_blend:new t.bp(e,i.u_sky_blend)})};class wn{constructor(e,t,i){this.context=e;const n=e.gl;this.buffer=n.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||t.freeBufferAfterUpload()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const t=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const En={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Tn{constructor(e,t,i,n){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=n,this.context=e;const r=e.gl;this.buffer=r.createBuffer(),e.bindVertexBuffer.set(this.buffer),r.bufferData(r.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||t.freeBufferAfterUpload()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(const i of this.attributes){const n=t.attributes[i.name];void 0!==n&&e.enableVertexAttribArray(n)}}setVertexAttribPointers(e,t,i){for(const n of this.attributes){const r=t.attributes[n.name];void 0!==r&&e.vertexAttribPointer(r,n.components,e[En[n.type]],!1,this.itemSize,n.offset+this.itemSize*(i||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Sn{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class In extends Sn{getDefault(){return t.bo.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class kn extends Sn{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class Mn extends Sn{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class Cn extends Sn{getDefault(){return[!0,!0,!0,!0]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class Pn extends Sn{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class An extends Sn{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class Ln extends Sn{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const t=this.current;(e.func!==t.func||e.ref!==t.ref||e.mask!==t.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}}class Dn extends Sn{getDefault(){const e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}}class Rn extends Sn{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1}}class zn extends Sn{getDefault(){return[0,1]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}}class Fn extends Sn{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1}}class On extends Sn{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class Nn extends Sn{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1}}class Bn extends Sn{getDefault(){const e=this.gl;return[e.ONE,e.ZERO]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.blendFunc(e[0],e[1]),this.current=e,this.dirty=!1)}}class Gn extends Sn{getDefault(){return t.bo.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class jn extends Sn{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}}class Vn extends Sn{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1}}class Un extends Sn{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class qn extends Sn{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}class Zn extends Sn{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}}class $n extends Sn{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class Hn extends Sn{getDefault(){const e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class Wn extends Sn{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class Xn extends Sn{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Yn extends Sn{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class Jn extends Sn{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Kn extends Sn{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Qn extends Sn{getDefault(){return null}set(e){var t;if(e===this.current&&!this.dirty)return;const i=this.gl;si(i)?i.bindVertexArray(e):null===(t=i.getExtension("OES_vertex_array_object"))||void 0===t||t.bindVertexArrayOES(e),this.current=e,this.dirty=!1}}class er extends Sn{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class tr extends Sn{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class ir extends Sn{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class nr extends Sn{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}}class rr extends nr{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class or extends nr{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class sr extends nr{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}const ar="Framebuffer is not complete";class lr{constructor(e,t,i,n,r){this.context=e,this.width=t,this.height=i;const o=e.gl,s=this.framebuffer=o.createFramebuffer();if(this.colorAttachment=new rr(e,s),n)this.depthAttachment=r?new sr(e,s):new or(e,s);else if(r)throw new Error("Stencil cannot be set without depth");if(o.checkFramebufferStatus(o.FRAMEBUFFER)!==o.FRAMEBUFFER_COMPLETE)throw new Error(ar)}destroy(){const e=this.context.gl,t=this.colorAttachment.get();if(t&&e.deleteTexture(t),this.depthAttachment){const t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t)}e.deleteFramebuffer(this.framebuffer)}}class cr{constructor(e){var t,i;if(this.gl=e,this.clearColor=new In(this),this.clearDepth=new kn(this),this.clearStencil=new Mn(this),this.colorMask=new Cn(this),this.depthMask=new Pn(this),this.stencilMask=new An(this),this.stencilFunc=new Ln(this),this.stencilOp=new Dn(this),this.stencilTest=new Rn(this),this.depthRange=new zn(this),this.depthTest=new Fn(this),this.depthFunc=new On(this),this.blend=new Nn(this),this.blendFunc=new Bn(this),this.blendColor=new Gn(this),this.blendEquation=new jn(this),this.cullFace=new Vn(this),this.cullFaceSide=new Un(this),this.frontFace=new qn(this),this.program=new Zn(this),this.activeTexture=new $n(this),this.viewport=new Hn(this),this.bindFramebuffer=new Wn(this),this.bindRenderbuffer=new Xn(this),this.bindTexture=new Yn(this),this.bindVertexBuffer=new Jn(this),this.bindElementBuffer=new Kn(this),this.bindVertexArray=new Qn(this),this.pixelStoreUnpack=new er(this),this.pixelStoreUnpackPremultiplyAlpha=new tr(this),this.pixelStoreUnpackFlipY=new ir(this),this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),si(e)){this.HALF_FLOAT=e.HALF_FLOAT;const n=e.getExtension("EXT_color_buffer_half_float");this.RGBA16F=null!==(t=e.RGBA16F)&&void 0!==t?t:null==n?void 0:n.RGBA16F_EXT,this.RGB16F=null!==(i=e.RGB16F)&&void 0!==i?i:null==n?void 0:n.RGB16F_EXT,e.getExtension("EXT_color_buffer_float")}else{e.getExtension("EXT_color_buffer_half_float"),e.getExtension("OES_texture_half_float_linear");const t=e.getExtension("OES_texture_half_float");this.HALF_FLOAT=null==t?void 0:t.HALF_FLOAT_OES}}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}createIndexBuffer(e,t){return new wn(this,e,t)}createVertexBuffer(e,t,i){return new Tn(this,e,t,i)}createRenderbuffer(e,t,i){const n=this.gl,r=n.createRenderbuffer();return this.bindRenderbuffer.set(r),n.renderbufferStorage(n.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),r}createFramebuffer(e,t,i,n){return new lr(this,e,t,i,n)}clear({color:e,depth:t,stencil:i}){const n=this.gl;let r=0;e&&(r|=n.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),void 0!==t&&(r|=n.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(r|=n.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),n.clear(r)}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(e){t.bQ(e.blendFunction,ei.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor)),this.colorMask.set(e.mask)}createVertexArray(){var e;return si(this.gl)?this.gl.createVertexArray():null===(e=this.gl.getExtension("OES_vertex_array_object"))||void 0===e?void 0:e.createVertexArrayOES()}deleteVertexArray(e){var t;si(this.gl)?this.gl.deleteVertexArray(e):null===(t=this.gl.getExtension("OES_vertex_array_object"))||void 0===t||t.deleteVertexArrayOES(e)}unbindVAO(){this.bindVertexArray.set(null)}}let ur;function hr(e,i,n,r,o){var s,a;const l=e.context,c=e.transform,u=l.gl,h=e.useProgram("collisionBox"),d=[];let p=0,f=0;for(const t of r){const r=i.getTile(t).getBucket(n);if(!r)continue;const a=o?r.textCollisionBox:r.iconCollisionBox,m=r.collisionCircleArray;m.length>0&&(d.push({circleArray:m,circleOffset:f,coord:t}),p+=m.length/4,f=p),a&&h.draw(l,u.LINES,ni.disabled,oi.disabled,e.colorModeForRenderPass(),ii.disabled,Yi(e.transform),null===(s=e.style.map.terrain)||void 0===s?void 0:s.getTerrainData(t),c.getProjectionData({overscaledTileID:t,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),n.id,a.layoutVertexBuffer,a.indexBuffer,a.segments,null,e.transform.zoom,null,null,a.collisionVertexBuffer)}if(!o||!d.length)return;const m=e.useProgram("collisionCircle"),g=new t.ca;g.resize(4*p),g._trim();let y=0;for(const e of d)for(let t=0;t<e.circleArray.length/4;t++){const i=4*t,n=e.circleArray[i+0],r=e.circleArray[i+1],o=e.circleArray[i+2],s=e.circleArray[i+3];g.emplace(y++,n,r,o,s,0),g.emplace(y++,n,r,o,s,1),g.emplace(y++,n,r,o,s,2),g.emplace(y++,n,r,o,s,3)}(!ur||ur.length<2*p)&&(ur=function(e){const i=2*e,n=new t.cc;n.resize(i),n._trim();for(let e=0;e<i;e++){const t=6*e;n.uint16[t+0]=4*e+0,n.uint16[t+1]=4*e+1,n.uint16[t+2]=4*e+2,n.uint16[t+3]=4*e+2,n.uint16[t+4]=4*e+3,n.uint16[t+5]=4*e+0}return n}(p));const _=l.createIndexBuffer(ur,!0),v=l.createVertexBuffer(g,t.cb.members,!0);for(const i of d){const r=Ji(e.transform);m.draw(l,u.TRIANGLES,ni.disabled,oi.disabled,e.colorModeForRenderPass(),ii.disabled,r,null===(a=e.style.map.terrain)||void 0===a?void 0:a.getTerrainData(i.coord),null,n.id,v,_,t.aV.simpleSegment(0,2*i.circleOffset,i.circleArray.length,i.circleArray.length/2),null,e.transform.zoom,null,null,null)}v.destroy(),_.destroy()}const dr=t.ap(new Float32Array(16));function pr(e,i,n,r,o,s){const{horizontalAlign:a,verticalAlign:l}=t.aP(e);return new t.P((-(a-.5)*i/o+r[0])*s,(-(l-.5)*n/o+r[1])*s)}function fr(e,i,n,r,o,s){const a=i.tileAnchorPoint.add(new t.P(i.translation[0],i.translation[1]));if(i.pitchWithMap){let e=r.mult(s);n||(e=e.rotate(-o));const t=a.add(e);return qe(t.x,t.y,i.pitchedLabelPlaneMatrix,i.getElevation).point}if(n){const t=Qe(i.tileAnchorPoint.x+1,i.tileAnchorPoint.y,i).point.sub(e),n=Math.atan(t.y/t.x)+(t.x<0?Math.PI:0);return e.add(r.rotate(n))}return e.add(r)}function mr(e,i,n,r,o,s,a,l,c,u,h,d){const p=e.text.placedSymbolArray,f=e.text.dynamicLayoutVertexArray,m=e.icon.dynamicLayoutVertexArray,g={};f.clear();for(let m=0;m<p.length;m++){const y=p.get(m),_=y.hidden||!y.crossTileID||e.allowVerticalPlacement&&!y.placedOrientation?null:r[y.crossTileID];if(_){const r=new t.P(y.anchorX,y.anchorY),p={getElevation:d,width:o.width,height:o.height,pitchedLabelPlaneMatrix:s,pitchWithMap:n,transform:o,tileAnchorPoint:r,translation:u,unwrappedTileID:h},m=n?tt(r.x,r.y,p):Qe(r.x,r.y,p),v=Ze(o.cameraToCenterDistance,m.signedDistanceFromCamera);let x=t.ay(e.textSizeData,l,y)*v/t.aJ;n&&(x*=e.tilePixelRatio/a);const{width:b,height:w,anchor:E,textOffset:T,textBoxScale:S}=_,I=pr(E,b,w,T,S,x),k=o.getPitchedTextCorrection(r.x+u[0],r.y+u[1],h),M=fr(m.point,p,i,I,-o.bearingInRadians,k),C=e.allowVerticalPlacement&&y.placedOrientation===t.ax.vertical?Math.PI/2:0;for(let e=0;e<y.numGlyphs;e++)t.aD(f,M,C);c&&y.associatedIconIndex>=0&&(g[y.associatedIconIndex]={shiftedAnchor:M,angle:C})}else st(y.numGlyphs,f)}if(c){m.clear();const i=e.icon.placedSymbolArray;for(let e=0;e<i.length;e++){const n=i.get(e);if(n.hidden)st(n.numGlyphs,m);else{const i=g[e];if(i)for(let e=0;e<n.numGlyphs;e++)t.aD(m,i.shiftedAnchor,i.angle);else st(n.numGlyphs,m)}}e.icon.dynamicLayoutVertexBuffer.updateData(m)}e.text.dynamicLayoutVertexBuffer.updateData(f)}function gr(e,t,i){return i.iconsInText&&t?"symbolTextAndIcon":e?"symbolSDF":"symbolIcon"}function yr(e,i,n,r,o,s,a,l,c,u,h,d,p){var f,m;const g=e.context,y=g.gl,_=e.transform,v="map"===l,x="map"===c,b="viewport"!==l&&"point"!==n.layout.get("symbol-placement"),w=v&&!x&&!b,E=!n.layout.get("symbol-sort-key").isConstant();let T=!1;const S=e.getDepthModeForSublayer(0,ni.ReadOnly),I=n._unevaluatedLayout.hasValue("text-variable-anchor")||n._unevaluatedLayout.hasValue("text-variable-anchor-offset"),k=[],M=_.getCircleRadiusCorrection();for(const l of r){const r=i.getTile(l),c=r.getBucket(n);if(!c)continue;const h=o?c.text:c.icon;if(!(null==h?void 0:h.segments.get().length)||!h.hasVisibleVertices)continue;const d=h.programConfigurations.get(n.id),m=o||c.sdfIcons,g=o?c.textSizeData:c.iconSizeData,S=x||0!==_.pitch,C=e.useProgram(gr(m,o,c),d),P=t.aw(g,_.zoom),A=null===(f=e.style.map.terrain)||void 0===f?void 0:f.getTerrainData(l);let L,D,R,z,F=[0,0],O=null;if(o)D=r.glyphAtlasTexture,R=y.LINEAR,L=r.glyphAtlasTexture.size,c.iconsInText&&(F=r.imageAtlasTexture.size,O=r.imageAtlasTexture,z=S||e.options.rotating||e.options.zooming||"composite"===g.kind||"camera"===g.kind?y.LINEAR:y.NEAREST);else{const t=1!==n.layout.get("icon-size").constantOr(0)||c.iconsNeedLinear;D=r.imageAtlasTexture,R=m||e.options.rotating||e.options.zooming||t||S?y.LINEAR:y.NEAREST,L=r.imageAtlasTexture.size}const N=t.aK(r,1,e.transform.zoom),B=je(v,e.transform,N),G=Ve(x,v,e.transform,N),j=t.aL(_,r,s,a),V=_.getProjectionData({overscaledTileID:l,applyGlobeMatrix:!p,applyTerrainMatrix:!0}),U=I&&c.hasTextData(),q="none"!==n.layout.get("icon-text-fit")&&U&&c.hasIconData();if(b){const i=t.O();Be(i,B);const r=e.style.map.terrain?(t,i)=>e.style.map.terrain.getElevation(l,t,i):null,s="map"===n.layout.get("text-rotation-alignment");He(c,e,o,B,i,x,u,s,l.toUnwrapped(),_.width,_.height,j,r)}const Z=o&&I||q,$=b||Z?dr:x?B:e.transform.clipSpaceToPixelsMatrix,H=m&&0!==n.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1);let W;W=m?c.iconsInText?yn(g.kind,P,w,x,b,Z,e,$,G,j,L,F,M):gn(g.kind,P,w,x,b,Z,e,$,G,j,o,L,H,M):mn(g.kind,P,w,x,b,Z,e,$,G,j,o,L,M);const X={program:C,buffers:h,uniformValues:W,projectionData:V,atlasTexture:D,atlasTextureIcon:O,atlasInterpolation:R,atlasInterpolationIcon:z,isSDF:m,hasHalo:H};if(E&&c.canOverlap){T=!0;const e=h.segments.get();for(const i of e)k.push({segments:new t.aV([i]),sortKey:i.sortKey,state:X,terrainData:A})}else k.push({segments:h.segments,sortKey:0,state:X,terrainData:A})}T&&k.sort((e,t)=>e.sortKey-t.sortKey);const C=null!==(m=n.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(null))&&void 0!==m?m:1/0,P=n.layout.get("text-letter-spacing").constantOr(0)*t.aJ<0||C>1;for(const t of k){const i=t.state;g.activeTexture.set(y.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,y.CLAMP_TO_EDGE),i.atlasTextureIcon&&(g.activeTexture.set(y.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,y.CLAMP_TO_EDGE));const r=i.isSDF&&i.hasHalo;if(r){const r=i.uniformValues;r.u_is_halo=1,P&&(r.u_is_plain=0,_r(i.buffers,t.segments,n,e,i.program,S,h,d,r,i.projectionData,t.terrainData),r.u_is_halo=0,r.u_is_plain=1)}_r(i.buffers,t.segments,n,e,i.program,S,h,d,i.uniformValues,i.projectionData,t.terrainData),r&&!P&&(i.uniformValues.u_is_halo=0)}}function _r(e,t,i,n,r,o,s,a,l,c,u){const h=n.context;r.draw(h,h.gl.TRIANGLES,o,s,a,ii.backCCW,l,u,c,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,n.transform.zoom,e.programConfigurations.get(i.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function vr(e,i,n,r,o){const s=e.context,a=s.gl,l=oi.disabled,c=new ei([a.ONE,a.ONE],t.bo.transparent,[!0,!0,!0,!0]),u=i.getBucket(n);if(!u)return;const h=r.key;let d=n.heatmapFbos.get(h);d||(d=br(s,i.tileSize,i.tileSize),n.heatmapFbos.set(h,d)),s.bindFramebuffer.set(d.framebuffer),s.viewport.set([0,0,i.tileSize,i.tileSize]),s.clear({color:t.bo.transparent});const p=u.programConfigurations.get(n.id),f=e.useProgram("heatmap",p,!o),m=e.transform.getProjectionData({overscaledTileID:i.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),g=e.style.map.terrain.getTerrainData(r);f.draw(s,a.TRIANGLES,ni.disabled,l,c,ii.disabled,Qi(i,e.transform.zoom,n.paint.get("heatmap-intensity"),1),g,m,n.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,n.paint,e.transform.zoom,p)}function xr(e,t,i,n,r){const o=e.context,s=o.gl,a=e.transform;o.setColorMode(e.colorModeForRenderPass());const l=wr(o,t),c=i.key,u=t.heatmapFbos.get(c);if(!u)return;o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,u.colorAttachment.get()),o.activeTexture.set(s.TEXTURE1),l.bind(s.LINEAR,s.CLAMP_TO_EDGE);const h=a.getProjectionData({overscaledTileID:i,applyTerrainMatrix:r,applyGlobeMatrix:!n});e.useProgram("heatmapTexture").draw(o,s.TRIANGLES,ni.disabled,oi.disabled,e.colorModeForRenderPass(),ii.disabled,en(e,t,0,1),null,h,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,a.zoom),u.destroy(),t.heatmapFbos.delete(c)}function br(e,t,i){var n,r;const o=e.gl,s=o.createTexture();o.bindTexture(o.TEXTURE_2D,s),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.LINEAR);const a=null!==(n=e.HALF_FLOAT)&&void 0!==n?n:o.UNSIGNED_BYTE,l=null!==(r=e.RGBA16F)&&void 0!==r?r:o.RGBA;o.texImage2D(o.TEXTURE_2D,0,l,t,i,0,o.RGBA,a,null);const c=e.createFramebuffer(t,i,!1,!1);return c.colorAttachment.set(s),c}function wr(e,i){return i.colorRampTexture||(i.colorRampTexture=new t.T(e,i.colorRamp,e.gl.RGBA)),i.colorRampTexture}function Er(e,i,n,r,o,s,a,l){let c=256;if(o.stepInterpolant){const r=i.getSource().maxzoom,o=a.canonical.z===r?Math.ceil(1<<e.transform.maxZoom-a.canonical.z):1;c=t.al(t.ce(s.maxLineLength/t.a6*1024*o),256,n.maxTextureSize)}return l.gradient=t.cf({expression:o.gradientExpression(),evaluationKey:"lineProgress",resolution:c,image:l.gradient||void 0,clips:s.lineClipsArray}),l.texture?l.texture.update(l.gradient):l.texture=new t.T(n,l.gradient,r.RGBA),l.version=o.gradientVersion,l.texture}function Tr(e,t,i,n,r){e.activeTexture.set(t.TEXTURE0),i.imageAtlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE),n.updatePaintBuffers(r)}function Sr(e,t,i,n,r,o){(r||e.lineAtlas.dirty)&&(t.activeTexture.set(i.TEXTURE0),e.lineAtlas.bind(t)),n.updatePaintBuffers(o)}function Ir(e,t,i,n,r,o,s){const a=o.gradients[r.id];let l=a.texture;r.gradientVersion!==a.version&&(l=Er(e,t,i,n,r,o,s,a)),i.activeTexture.set(n.TEXTURE0),l.bind(r.stepInterpolant?n.NEAREST:n.LINEAR,n.CLAMP_TO_EDGE)}function kr(e,t,i,n,r,o,s,a,l){const c=o.gradients[r.id];let u=c.texture;r.gradientVersion!==c.version&&(u=Er(e,t,i,n,r,o,s,c)),i.activeTexture.set(n.TEXTURE0),u.bind(r.stepInterpolant?n.NEAREST:n.LINEAR,n.CLAMP_TO_EDGE),i.activeTexture.set(n.TEXTURE1),e.lineAtlas.bind(i),a.updatePaintBuffers(l)}function Mr(e,t,i,n,r){if(!i||!(null==n?void 0:n.imageAtlas))return;const o=n.imageAtlas.patternPositions;let s=o[i.to.toString()],a=o[i.from.toString()];if(!s&&a&&(s=a),!a&&s&&(a=s),!s||!a){const e=r.getPaintProperty(t);s=o[e],a=o[e]}s&&a&&e.setConstantPatternPositions(s,a)}function Cr(e,i,n,r,o,s,a,l){var c;const u=e.context.gl,h="fill-pattern",d=n.paint.get(h),p=null==d?void 0:d.constantOr(1),f=n.getCrossfadeParameters();let m,g,y,_,v;const x=e.transform,b=n.paint.get("fill-translate"),w=n.paint.get("fill-translate-anchor");a?(g=p&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",m=u.LINES):(g=p?"fillPattern":"fill",m=u.TRIANGLES);const E=d.constantOr(null);for(const d of r){const r=i.getTile(d);if(p&&!r.patternsLoaded())continue;const T=r.getBucket(n);if(!T)continue;const S=T.programConfigurations.get(n.id),I=e.useProgram(g,S),k=null===(c=e.style.map.terrain)||void 0===c?void 0:c.getTerrainData(d);p&&(e.context.activeTexture.set(u.TEXTURE0),r.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),S.updatePaintBuffers(f)),Mr(S,h,E,r,n);const M=x.getProjectionData({overscaledTileID:d,applyGlobeMatrix:!l,applyTerrainMatrix:!0}),C=t.aL(x,r,b,w);if(a){_=T.indexBuffer2,v=T.segments2;const t=[u.drawingBufferWidth,u.drawingBufferHeight];y="fillOutlinePattern"===g&&p?Wi(e,f,r,t,C):Hi(t,C)}else _=T.indexBuffer,v=T.segments,y=p?$i(e,f,r,C):{u_fill_translate:C};const P=e.stencilModeForClipping(d);I.draw(e.context,m,o,P,s,ii.backCCW,y,k,M,n.id,T.layoutVertexBuffer,_,v,n.paint,e.transform.zoom,S)}}function Pr(e,i,n,r,o,s,a,l){var c;const u=e.context,h=u.gl,d="fill-extrusion-pattern",p=n.paint.get(d),f=p.constantOr(1),m=n.getCrossfadeParameters(),g=n.paint.get("fill-extrusion-opacity"),y=p.constantOr(null),_=e.transform;for(const p of r){const r=i.getTile(p),v=r.getBucket(n);if(!v)continue;const x=null===(c=e.style.map.terrain)||void 0===c?void 0:c.getTerrainData(p),b=v.programConfigurations.get(n.id),w=e.useProgram(f?"fillExtrusionPattern":"fillExtrusion",b);f&&(e.context.activeTexture.set(h.TEXTURE0),r.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),b.updatePaintBuffers(m));const E=_.getProjectionData({overscaledTileID:p,applyGlobeMatrix:!l,applyTerrainMatrix:!0});Mr(b,d,y,r,n);const T=t.aL(_,r,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),S=n.paint.get("fill-extrusion-vertical-gradient"),I=f?Zi(e,S,g,T,p,m,r):qi(e,S,g,T);w.draw(u,u.gl.TRIANGLES,o,s,a,ii.backCCW,I,x,E,n.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,n.paint,e.transform.zoom,b,e.style.map.terrain&&v.centroidVertexBuffer)}}function Ar(e,t,i,n,r,o,s,a,l){var c;const u=e.style.projection,h=e.context,d=e.transform,p=h.gl,f=[`#define NUM_ILLUMINATION_SOURCES ${i.paint.get("hillshade-highlight-color").values.length}`],m=e.useProgram("hillshade",null,!1,f),g=!e.options.moving;for(const f of n){const n=t.getTile(f),y=n.fbo;if(!y)continue;const _=u.getMeshFromTileID(h,f.canonical,a,!0,"raster"),v=null===(c=e.style.map.terrain)||void 0===c?void 0:c.getTerrainData(f);h.activeTexture.set(p.TEXTURE0),p.bindTexture(p.TEXTURE_2D,y.colorAttachment.get());const x=d.getProjectionData({overscaledTileID:f,aligned:g,applyGlobeMatrix:!l,applyTerrainMatrix:!0});m.draw(h,p.TRIANGLES,o,r[f.overscaledZ],s,ii.backCCW,tn(e,n,i),v,x,i.id,_.vertexBuffer,_.indexBuffer,_.segments)}}let Lr=0;function Dr(e,i,n,r,o,s,a,l,c){var u;const h=e.style.projection,d=e.context,p=e.transform,f=d.gl,m=e.useProgram("colorRelief"),g=!e.options.moving,y="nearest"===n.paint.get("resampling")?f.NEAREST:f.LINEAR;let _=!0,v=0;for(const x of r){const r=i.getTile(x),b=r.dem;if(_){Lr||(Lr=f.getParameter(f.MAX_TEXTURE_SIZE));const e=Lr,{elevationTexture:t,colorTexture:i}=n.getColorRampTextures(d,e,b.getUnpackVector());d.activeTexture.set(f.TEXTURE1),t.bind(f.NEAREST,f.CLAMP_TO_EDGE),d.activeTexture.set(f.TEXTURE4),i.bind(f.LINEAR,f.CLAMP_TO_EDGE),_=!1,v=t.size[0]}if(!(null==b?void 0:b.data))continue;const w=b.stride,E=b.getPixels();if(d.activeTexture.set(f.TEXTURE0),d.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture||(r.demTexture=e.getTileTexture(w)),r.demTexture){const e=r.demTexture;e.update(E,{premultiply:!1}),e.bind(y,f.CLAMP_TO_EDGE)}else r.demTexture=new t.T(d,E,f.RGBA,{premultiply:!1}),r.demTexture.bind(y,f.CLAMP_TO_EDGE);const T=h.getMeshFromTileID(d,x.canonical,l,!0,"raster"),S=null===(u=e.style.map.terrain)||void 0===u?void 0:u.getTerrainData(x),I=p.getProjectionData({overscaledTileID:x,aligned:g,applyGlobeMatrix:!c,applyTerrainMatrix:!0});m.draw(d,f.TRIANGLES,s,o[x.overscaledZ],a,ii.backCCW,on(n,r.dem,v),S,I,n.id,T.vertexBuffer,T.indexBuffer,T.segments)}}const Rr=[new t.P(0,0),new t.P(t.a6,0),new t.P(t.a6,t.a6),new t.P(0,t.a6)];function zr(e,t,i,n,r,o,s,a,l=!1,c=!1){var u;const h=n[n.length-1].overscaledZ,d=e.context,p=d.gl,f=e.useProgram("raster"),m=e.transform,g=e.style.projection,y=e.colorModeForRenderPass(),_=!e.options.moving,v=i.paint.get("raster-opacity"),x="nearest"===i.paint.get("resampling")||"nearest"===i.paint.get("raster-resampling")?p.NEAREST:p.LINEAR,b=i.paint.get("raster-fade-duration"),w=!!e.style.map.terrain;for(const E of n){const n=e.getDepthModeForSublayer(E.overscaledZ-h,1===v?ni.ReadWrite:ni.ReadOnly,p.LESS),T=t.getTile(E);d.activeTexture.set(p.TEXTURE0),T.texture.bind(x,p.CLAMP_TO_EDGE,p.LINEAR_MIPMAP_NEAREST),d.activeTexture.set(p.TEXTURE1);const{parentTile:S,parentScaleBy:I,parentTopLeft:k,fadeValues:M}=Fr(T,t,b,w);T.fadeOpacity=M.tileOpacity,S?(S.fadeOpacity=M.parentTileOpacity,S.texture.bind(x,p.CLAMP_TO_EDGE,p.LINEAR_MIPMAP_NEAREST)):T.texture.bind(x,p.CLAMP_TO_EDGE,p.LINEAR_MIPMAP_NEAREST),T.texture.useMipmap&&d.extTextureFilterAnisotropic&&e.transform.pitch>e.options.anisotropicFilterPitch&&p.texParameterf(p.TEXTURE_2D,d.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,d.extTextureFilterAnisotropicMax);const C=null===(u=e.style.map.terrain)||void 0===u?void 0:u.getTerrainData(E),P=m.getProjectionData({overscaledTileID:E,aligned:_,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),A=pn(k,I,M.fadeMix,i,a),L=g.getMeshFromTileID(d,E.canonical,o,s,"raster");f.draw(d,p.TRIANGLES,n,r?r[E.overscaledZ]:oi.disabled,y,l?ii.frontCCW:ii.backCCW,A,C,P,i.id,L.vertexBuffer,L.indexBuffer,L.segments)}}function Fr(e,i,n,r){const o={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(0===n||r)return o;if(e.fadingParentID){const r=i.getLoadedTile(e.fadingParentID);if(!r)return o;const s=Math.pow(2,r.tileID.overscaledZ-e.tileID.overscaledZ),a=[e.tileID.canonical.x*s%1,e.tileID.canonical.y*s%1],l=function(e,i,n){const r=c(),o=(r-i.timeAdded)/n,s=e.fadingDirection===he.Incoming,a=t.al((r-e.timeAdded)/n,0,1),l=t.al(1-o,0,1),u=s?a:l;return{tileOpacity:u,parentTileOpacity:s?l:a,fadeMix:{opacity:1,mix:1-u}}}(e,r,n);return{parentTile:r,parentScaleBy:s,parentTopLeft:a,fadeValues:l}}if(e.selfFading){const i=function(e,i){const n=(c()-e.timeAdded)/i,r=t.al(n,0,1);return{tileOpacity:r,fadeMix:{opacity:r,mix:0}}}(e,n);return{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:i}}return o}const Or=new t.bo(1,0,0,1),Nr=new t.bo(0,1,0,1),Br=new t.bo(0,0,1,1),Gr=new t.bo(1,0,1,1),jr=new t.bo(0,1,1,1);function Vr(e,t,i,n){qr(e,0,t+i/2,e.transform.width,i,n)}function Ur(e,t,i,n){qr(e,t-i/2,0,i,e.transform.height,n)}function qr(e,t,i,n,r,o){const s=e.context,a=s.gl;a.enable(a.SCISSOR_TEST),a.scissor(t*e.pixelRatio,i*e.pixelRatio,n*e.pixelRatio,r*e.pixelRatio),s.clear({color:o}),a.disable(a.SCISSOR_TEST)}function Zr(e,i,n){var r;const o=e.context,s=o.gl,a=e.useProgram("debug"),l=ni.disabled,c=oi.disabled,u=e.colorModeForRenderPass(),h="$debug",d=null===(r=e.style.map.terrain)||void 0===r?void 0:r.getTerrainData(n);o.activeTexture.set(s.TEXTURE0);const p=i.getTileByID(n.key).latestRawTileData,f=Math.floor(((null==p?void 0:p.byteLength)||0)/1024),m=i.getTile(n).tileSize,g=512/Math.min(m,512)*(n.overscaledZ/e.transform.zoom)*.5;let y=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(y+=` => ${n.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,n=e.context.gl,r=e.debugOverlayCanvas.getContext("2d");r.clearRect(0,0,i.width,i.height),r.shadowColor="white",r.shadowBlur=2,r.lineWidth=1.5,r.strokeStyle="white",r.textBaseline="top",r.font="bold 36px Open Sans, sans-serif",r.fillText(t,5,5),r.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}(e,`${y} ${f}kB`);const _=e.transform.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!0,applyTerrainMatrix:!0});a.draw(o,s.TRIANGLES,l,c,ei.alphaBlended,ii.disabled,Ki(t.bo.transparent,g),null,_,h,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),a.draw(o,s.LINE_STRIP,l,c,u,ii.disabled,Ki(t.bo.red),d,_,h,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function $r(e,t,i,n){const{isRenderingGlobe:r}=n,o=e.context,s=o.gl,a=e.transform,l=e.colorModeForRenderPass(),c=e.getDepthModeFor3D(),u=e.useProgram("terrain");o.bindFramebuffer.set(null),o.viewport.set([0,0,e.width,e.height]);for(const n of i){const i=t.getTerrainMesh(n.tileID),h=e.renderToTexture.getTexture(n),d=t.getTerrainData(n.tileID);o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,h.texture);const p=t.getMeshFrameDelta(a.zoom),f=a.calculateFogMatrix(n.tileID.toUnwrapped()),m=Bi(p,f,e.style.sky,a.pitch,r),g=a.getProjectionData({overscaledTileID:n.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});u.draw(o,s.TRIANGLES,c,oi.disabled,l,ii.backCCW,m,d,g,"terrain",i.vertexBuffer,i.indexBuffer,i.segments)}}function Hr(e,i){if(!i.mesh){const n=new t.aU;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(1,1),n.emplaceBack(-1,1);const r=new t.aW;r.emplaceBack(0,1,2),r.emplaceBack(0,2,3),i.mesh=new Ot(e.createVertexBuffer(n,Nt.members),e.createIndexBuffer(r),t.aV.simpleSegment(0,0,n.length,r.length))}return i.mesh}const Wr={symbol:function(e,i,n,r,o,s){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:a}=s,l=oi.disabled,c=e.colorModeForRenderPass();(n._unevaluatedLayout.hasValue("text-variable-anchor")||n._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(e,i,n,r,o,s,a,l,c){var u;const h=i.transform,d=i.style.map.terrain,p="map"===o,f="map"===s;for(const o of e){const e=r.getTile(o),s=e.getBucket(n);if(!(null===(u=null==s?void 0:s.text)||void 0===u?void 0:u.segments.get().length))continue;const m=t.aw(s.textSizeData,h.zoom),g=t.aK(e,1,i.transform.zoom),y=je(p,i.transform,g),_="none"!==n.layout.get("icon-text-fit")&&s.hasIconData();if(m){const i=Math.pow(2,h.zoom-e.tileID.overscaledZ),n=d?(e,t)=>d.getElevation(o,e,t):null;mr(s,p,f,c,h,y,i,m,_,t.aL(h,e,a,l),o.toUnwrapped(),n)}}}(r,e,n,i,n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),o),0!==n.paint.get("icon-opacity").constantOr(1)&&yr(e,i,n,r,!1,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),n.layout.get("icon-rotation-alignment"),n.layout.get("icon-pitch-alignment"),n.layout.get("icon-keep-upright"),l,c,a),0!==n.paint.get("text-opacity").constantOr(1)&&yr(e,i,n,r,!0,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),n.layout.get("text-keep-upright"),l,c,a),i.map.showCollisionBoxes&&(hr(e,i,n,r,!0),hr(e,i,n,r,!1))},circle:function(e,i,n,r,o){var s;if("translucent"!==e.renderPass)return;const{isRenderingToTexture:a}=o,l=n.paint.get("circle-opacity"),c=n.paint.get("circle-stroke-width"),u=n.paint.get("circle-stroke-opacity"),h=!n.layout.get("circle-sort-key").isConstant();if(0===l.constantOr(1)&&(0===c.constantOr(1)||0===u.constantOr(1)))return;const d=e.context,p=d.gl,f=e.transform,m=e.getDepthModeForSublayer(0,ni.ReadOnly),g=oi.disabled,y=e.colorModeForRenderPass(),_=[],v=f.getCircleRadiusCorrection();for(const o of r){const r=i.getTile(o),l=r.getBucket(n);if(!l)continue;const c=n.paint.get("circle-translate"),u=n.paint.get("circle-translate-anchor"),d=t.aL(f,r,c,u),p=l.programConfigurations.get(n.id),m=e.useProgram("circle",p),g=l.layoutVertexBuffer,y=l.indexBuffer,x=null===(s=e.style.map.terrain)||void 0===s?void 0:s.getTerrainData(o),b={programConfiguration:p,program:m,layoutVertexBuffer:g,indexBuffer:y,uniformValues:Xi(e,r,n,d,v),terrainData:x,projectionData:f.getProjectionData({overscaledTileID:o,applyGlobeMatrix:!a,applyTerrainMatrix:!0})};if(h){const e=l.segments.get();for(const i of e)_.push({segments:new t.aV([i]),sortKey:i.sortKey,state:b})}else _.push({segments:l.segments,sortKey:0,state:b})}h&&_.sort((e,t)=>e.sortKey-t.sortKey);for(const t of _){const{programConfiguration:i,program:r,layoutVertexBuffer:o,indexBuffer:s,uniformValues:a,terrainData:l,projectionData:c}=t.state;r.draw(d,p.TRIANGLES,m,g,y,ii.backCCW,a,l,c,n.id,o,s,t.segments,n.paint,e.transform.zoom,i)}},heatmap:function(e,i,n,r,o){if(0===n.paint.get("heatmap-opacity"))return;const s=e.context,{isRenderingToTexture:a,isRenderingGlobe:l}=o;if(e.style.map.terrain){for(const t of r){const r=i.getTile(t);i.hasRenderableParent(t)||("offscreen"===e.renderPass?vr(e,r,n,t,l):"translucent"===e.renderPass&&xr(e,n,t,a,l))}s.viewport.set([0,0,e.width,e.height])}else"offscreen"===e.renderPass?function(e,i,n,r){const o=e.context,s=o.gl,a=e.transform,l=oi.disabled,c=new ei([s.ONE,s.ONE],t.bo.transparent,[!0,!0,!0,!0]);(function(e,i,n){const r=e.gl;e.activeTexture.set(r.TEXTURE1),e.viewport.set([0,0,i.width/4,i.height/4]);let o=n.heatmapFbos.get(t.cd);o?(r.bindTexture(r.TEXTURE_2D,o.colorAttachment.get()),e.bindFramebuffer.set(o.framebuffer)):(o=br(e,i.width/4,i.height/4),n.heatmapFbos.set(t.cd,o))})(o,e,n),o.clear({color:t.bo.transparent});for(const t of r){if(i.hasRenderableParent(t))continue;const r=i.getTile(t),u=r.getBucket(n);if(!u)continue;const h=u.programConfigurations.get(n.id),d=e.useProgram("heatmap",h),p=a.getProjectionData({overscaledTileID:t,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),f=a.getCircleRadiusCorrection();d.draw(o,s.TRIANGLES,ni.disabled,l,c,ii.backCCW,Qi(r,a.zoom,n.paint.get("heatmap-intensity"),f),null,p,n.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,n.paint,a.zoom,h)}o.viewport.set([0,0,e.width,e.height])}(e,i,n,r):"translucent"===e.renderPass&&function(e,i){const n=e.context,r=n.gl;n.setColorMode(e.colorModeForRenderPass());const o=i.heatmapFbos.get(t.cd);o&&(n.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,o.colorAttachment.get()),n.activeTexture.set(r.TEXTURE1),wr(n,i).bind(r.LINEAR,r.CLAMP_TO_EDGE),e.useProgram("heatmapTexture").draw(n,r.TRIANGLES,ni.disabled,oi.disabled,e.colorModeForRenderPass(),ii.disabled,en(e,i,0,1),null,null,i.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,i.paint,e.transform.zoom))}(e,n)},line:function(e,t,i,n,r){var o;if("translucent"!==e.renderPass)return;const{isRenderingToTexture:s}=r,a=i.paint.get("line-opacity"),l=i.paint.get("line-width");if(0===a.constantOr(1)||0===l.constantOr(1))return;const c=e.getDepthModeForSublayer(0,ni.ReadOnly),u=e.colorModeForRenderPass(),h=i.paint.get("line-dasharray"),d=h.constantOr(1),p=i.paint.get("line-pattern"),f=p.constantOr(1),m=i.paint.get("line-gradient"),g=i.getCrossfadeParameters();let y;y=f?"linePattern":d&&m?"lineGradientSDF":d?"lineSDF":m?"lineGradient":"line";const _=e.context,v=_.gl,x=e.transform;let b=!0;for(const r of n){const n=t.getTile(r);if(f&&!n.patternsLoaded())continue;const a=n.getBucket(i);if(!a)continue;const l=a.programConfigurations.get(i.id),w=e.context.program.get(),E=e.useProgram(y,l),T=b||E.program!==w,S=null===(o=e.style.map.terrain)||void 0===o?void 0:o.getTerrainData(r),I=p.constantOr(null),k=null==h?void 0:h.constantOr(null);if(I&&n.imageAtlas){const e=n.imageAtlas,t=e.patternPositions[I.to.toString()],i=e.patternPositions[I.from.toString()];t&&i&&l.setConstantPatternPositions(t,i)}else if(k){const t="round"===i.layout.get("line-cap").constantOr(null),n=e.lineAtlas.getDash(k.to,t),r=e.lineAtlas.getDash(k.from,t);l.setConstantDashPositions(n,r)}const M=x.getProjectionData({overscaledTileID:r,applyGlobeMatrix:!s,applyTerrainMatrix:!0}),C=x.getPixelScale();let P;f?(P=ln(e,n,i,C,g),Tr(_,v,n,l,g)):d&&m?(P=un(e,n,i,C,g,a.lineClipsArray.length),kr(e,t,_,v,i,a,r,l,g)):d?(P=cn(e,n,i,C,g),Sr(e,_,v,l,T,g)):m?(P=an(e,n,i,C,a.lineClipsArray.length),Ir(e,t,_,v,i,a,r)):P=sn(e,n,i,C);const A=e.stencilModeForClipping(r);E.draw(_,v.TRIANGLES,c,A,u,ii.disabled,P,S,M,i.id,a.layoutVertexBuffer,a.indexBuffer,a.segments,i.paint,e.transform.zoom,l,a.layoutVertexBuffer2),b=!1}},fill:function(e,i,n,r,o){const s=n.paint.get("fill-color"),a=n.paint.get("fill-opacity");if(0===a.constantOr(1))return;const{isRenderingToTexture:l}=o,c=e.colorModeForRenderPass(),u=n.paint.get("fill-pattern"),h=e.opaquePassEnabledForLayer()&&!u.constantOr(1)&&1===s.constantOr(t.bo.transparent).a&&1===a.constantOr(0)?"opaque":"translucent";if(e.renderPass===h){const t=e.getDepthModeForSublayer(1,"opaque"===e.renderPass?ni.ReadWrite:ni.ReadOnly);Cr(e,i,n,r,t,c,!1,l)}if("translucent"===e.renderPass&&n.paint.get("fill-antialias")){const t=e.getDepthModeForSublayer(n.getPaintProperty("fill-outline-color")?2:0,ni.ReadOnly);Cr(e,i,n,r,t,c,!0,l)}},fillExtrusion:function(e,t,i,n,r){const o=i.paint.get("fill-extrusion-opacity");if(0===o)return;const{isRenderingToTexture:s}=r;if("translucent"===e.renderPass){const r=new ni(e.context.gl.LEQUAL,ni.ReadWrite,e.depthRangeFor3D);if(1!==o||i.paint.get("fill-extrusion-pattern").constantOr(1))Pr(e,t,i,n,r,oi.disabled,ei.disabled,s),Pr(e,t,i,n,r,e.stencilModeFor3D(),e.colorModeForRenderPass(),s);else{const o=e.colorModeForRenderPass();Pr(e,t,i,n,r,oi.disabled,o,s)}}},hillshade:function(e,i,n,r,o){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;const{isRenderingToTexture:s}=o,a=e.context,l=e.style.projection.useSubdivision,c=e.getDepthModeForSublayer(0,ni.ReadOnly),u=e.colorModeForRenderPass();if("offscreen"===e.renderPass)!function(e,i,n,r,o,s,a){const l=e.context,c=l.gl,u="nearest"===r.paint.get("resampling")?c.NEAREST:c.LINEAR;for(const h of n){const n=i.getTile(h),d=n.dem;if(!(null==d?void 0:d.data))continue;if(!n.needsHillshadePrepare)continue;const p=d.dim,f=d.stride,m=d.getPixels();if(l.activeTexture.set(c.TEXTURE1),l.pixelStoreUnpackPremultiplyAlpha.set(!1),n.demTexture||(n.demTexture=e.getTileTexture(f)),n.demTexture){const e=n.demTexture;e.update(m,{premultiply:!1}),e.bind(c.NEAREST,c.CLAMP_TO_EDGE)}else n.demTexture=new t.T(l,m,c.RGBA,{premultiply:!1}),n.demTexture.bind(c.NEAREST,c.CLAMP_TO_EDGE);l.activeTexture.set(c.TEXTURE0);let g=n.fbo;if(!g){const e=new t.T(l,{width:p,height:p,data:null},c.RGBA);e.bind(u,c.CLAMP_TO_EDGE),g=n.fbo=l.createFramebuffer(p,p,!0,!1),g.colorAttachment.set(e.texture)}l.bindFramebuffer.set(g.framebuffer),l.viewport.set([0,0,p,p]),e.useProgram("hillshadePrepare").draw(l,c.TRIANGLES,o,s,a,ii.disabled,nn(n.tileID,d),null,null,r.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments),n.needsHillshadePrepare=!1}}(e,i,r,n,c,oi.disabled,u),a.viewport.set([0,0,e.width,e.height]);else if("translucent"===e.renderPass)if(l){const[t,o,a]=e.stencilConfigForOverlapTwoPass(r);Ar(e,i,n,a,t,c,u,!1,s),Ar(e,i,n,a,o,c,u,!0,s)}else{const[t,o]=e.getStencilConfigForOverlapAndUpdateStencilID(r);Ar(e,i,n,o,t,c,u,!1,s)}},colorRelief:function(e,t,i,n,r){if("translucent"!==e.renderPass)return;if(!n.length)return;const{isRenderingToTexture:o}=r,s=e.style.projection.useSubdivision,a=e.getDepthModeForSublayer(0,ni.ReadOnly),l=e.colorModeForRenderPass();if(s){const[r,s,c]=e.stencilConfigForOverlapTwoPass(n);Dr(e,t,i,c,r,a,l,!1,o),Dr(e,t,i,c,s,a,l,!0,o)}else{const[r,s]=e.getStencilConfigForOverlapAndUpdateStencilID(n);Dr(e,t,i,s,r,a,l,!1,o)}},raster:function(e,t,i,n,r){if("translucent"!==e.renderPass)return;if(0===i.paint.get("raster-opacity"))return;if(!n.length)return;const{isRenderingToTexture:o}=r,s=t.getSource(),a=e.style.projection.useSubdivision;if(s instanceof te)zr(e,t,i,n,null,!1,!1,s.tileCoords,s.flippedWindingOrder,o);else if(a){const[r,s,a]=e.stencilConfigForOverlapTwoPass(n);zr(e,t,i,a,r,!1,!0,Rr,!1,o),zr(e,t,i,a,s,!0,!0,Rr,!1,o)}else{const[r,s]=e.getStencilConfigForOverlapAndUpdateStencilID(n);zr(e,t,i,s,r,!1,!0,Rr,!1,o)}},background:function(e,t,i,n,r){var o;const s=i.paint.get("background-color"),a=i.paint.get("background-opacity");if(0===a)return;const{isRenderingToTexture:l}=r,c=e.context,u=c.gl,h=e.style.projection,d=e.transform,p=d.tileSize,f=i.paint.get("background-pattern");if(e.isPatternMissing(f))return;const m=!f&&1===s.a&&1===a&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(e.renderPass!==m)return;const g=oi.disabled,y=e.getDepthModeForSublayer(0,"opaque"===m?ni.ReadWrite:ni.ReadOnly),_=e.colorModeForRenderPass(),v=e.useProgram(f?"backgroundPattern":"background"),x=n||Ie(d,{tileSize:p,terrain:e.style.map.terrain});f&&(c.activeTexture.set(u.TEXTURE0),e.imageManager.bind(e.context));const b=i.getCrossfadeParameters();for(const t of x){const n=d.getProjectionData({overscaledTileID:t,applyGlobeMatrix:!l,applyTerrainMatrix:!0}),r=f?vn(a,e,f,{tileID:t,tileSize:p},b):_n(a,s),m=null===(o=e.style.map.terrain)||void 0===o?void 0:o.getTerrainData(t),x=h.getMeshFromTileID(c,t.canonical,!1,!0,"raster");v.draw(c,u.TRIANGLES,y,g,_,ii.backCCW,r,m,n,i.id,x.vertexBuffer,x.indexBuffer,x.segments)}},sky:function(e,t){const i=e.context,n=i.gl,r=((e,t,i)=>{const n=Math.cos(t.rollInRadians),r=Math.sin(t.rollInRadians),o=ye(t),s=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(t.width/2-o*r)*i,(t.height/2+o*n)*i],u_horizon_normal:[-r,n],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*t.height/2*i,u_sky_blend:s}})(t,e.style.map.transform,e.pixelRatio),o=new ni(n.LEQUAL,ni.ReadWrite,[0,1]),s=oi.disabled,a=e.colorModeForRenderPass(),l=e.useProgram("sky"),c=Hr(i,t);l.draw(i,n.TRIANGLES,o,s,a,ii.disabled,r,null,void 0,"sky",c.vertexBuffer,c.indexBuffer,c.segments)},atmosphere:function(e,i,n){const r=e.context,o=r.gl,s=e.useProgram("atmosphere"),a=new ni(o.LEQUAL,ni.ReadOnly,[0,1]),l=e.transform,c=function(e,i){const n=e.properties.get("position"),r=[-n.x,-n.y,-n.z],o=t.ap(new Float64Array(16));return"map"===e.properties.get("anchor")&&(t.be(o,o,i.rollInRadians),t.bf(o,o,-i.pitchInRadians),t.be(o,o,i.bearingInRadians),t.bf(o,o,i.center.lat*Math.PI/180),t.bI(o,o,-i.center.lng*Math.PI/180)),t.cg(r,r,o),r}(n,e.transform),u=l.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),h=i.properties.get("atmosphere-blend")*u.projectionTransition;if(0===h)return;const d=yi(l.worldSize,l.center.lat),p=l.inverseProjectionMatrix,f=new Float64Array(4);f[3]=1,t.aE(f,f,l.modelViewProjectionMatrix),f[0]/=f[3],f[1]/=f[3],f[2]/=f[3],f[3]=1,t.aE(f,f,p),f[0]/=f[3],f[1]/=f[3],f[2]/=f[3],f[3]=1;const m=((e,t,i,n,r)=>({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:i,u_globe_radius:n,u_inv_proj_matrix:r}))(c,h,[f[0],f[1],f[2]],d,p),g=Hr(r,i);s.draw(r,o.TRIANGLES,a,oi.disabled,ei.alphaBlended,ii.disabled,m,null,null,"atmosphere",g.vertexBuffer,g.indexBuffer,g.segments)},custom:function(e,t,i,n){const{isRenderingGlobe:r}=n,o=e.context,s=i.implementation,a=e.style.projection,l=e.transform,c=l.getProjectionDataForCustomLayer(r),u={farZ:l.farZ,nearZ:l.nearZ,fov:l.fov*Math.PI/180,modelViewProjectionMatrix:l.modelViewProjectionMatrix,projectionMatrix:l.projectionMatrix,shaderData:{variantName:a.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;\nuniform mat4 u_projection_matrix;\n${a.shaderPreludeCode.vertexSource}`,define:a.shaderDefine},defaultProjectionData:c},h=s.renderingMode?s.renderingMode:"2d";if("offscreen"===e.renderPass){const t=s.prerender;t&&(e.setCustomLayerDefaults(),o.setColorMode(e.colorModeForRenderPass()),t.call(s,o.gl,u),o.setDirty(),e.setBaseState())}else if("translucent"===e.renderPass){e.setCustomLayerDefaults(),o.setColorMode(e.colorModeForRenderPass()),o.setStencilMode(oi.disabled);const t="3d"===h?e.getDepthModeFor3D():e.getDepthModeForSublayer(0,ni.ReadOnly);o.setDepthMode(t),s.render(o.gl,u),o.setDirty(),e.setBaseState(),o.bindFramebuffer.set(null)}},debug:function(e,t,i){for(const n of i)Zr(e,t,n)},debugPadding:function(e){const t=e.transform.padding;Vr(e,e.transform.height-(t.top||0),3,Or),Vr(e,t.bottom||0,3,Nr),Ur(e,t.left||0,3,Br),Ur(e,e.transform.width-(t.right||0),3,Gr);const i=e.transform.centerPoint;!function(e,t,i,n){qr(e,t-1,i-10,2,20,n),qr(e,t-10,i-1,20,2,n)}(e,i.x,e.transform.height-i.y,jr)},terrainDepth:function(e,i){const n=e.context,r=n.gl,o=e.transform,s=ei.unblended,a=new ni(r.LEQUAL,ni.ReadWrite,[0,1]),l=i.tileManager.getRenderableTiles(),c=e.useProgram("terrainDepth");n.bindFramebuffer.set(i.getFramebuffer("depth").framebuffer),n.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),n.clear({color:t.bo.transparent,depth:1});for(const e of l){const t=i.getTerrainMesh(e.tileID),l=i.getTerrainData(e.tileID),u=o.getProjectionData({overscaledTileID:e.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),h={u_ele_delta:i.getMeshFrameDelta(o.zoom)};c.draw(n,r.TRIANGLES,a,oi.disabled,s,ii.backCCW,h,l,u,"terrain",t.vertexBuffer,t.indexBuffer,t.segments)}n.bindFramebuffer.set(null),n.viewport.set([0,0,e.width,e.height])},terrainCoords:function(e,i){const n=e.context,r=n.gl,o=e.transform,s=ei.unblended,a=new ni(r.LEQUAL,ni.ReadWrite,[0,1]),l=i.getCoordsTexture(),c=i.tileManager.getRenderableTiles(),u=e.useProgram("terrainCoords");n.bindFramebuffer.set(i.getFramebuffer("coords").framebuffer),n.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),n.clear({color:t.bo.transparent,depth:1}),i.coordsIndex=[];for(const e of c){const t=i.getTerrainMesh(e.tileID),c=i.getTerrainData(e.tileID);n.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,l.texture);const h={u_terrain_coords_id:(255-i.coordsIndex.length)/255,u_texture:0,u_ele_delta:i.getMeshFrameDelta(o.zoom)},d=o.getProjectionData({overscaledTileID:e.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});u.draw(n,r.TRIANGLES,a,oi.disabled,s,ii.backCCW,h,c,d,"terrain",t.vertexBuffer,t.indexBuffer,t.segments),i.coordsIndex.push(e.tileID.key)}n.bindFramebuffer.set(null),n.viewport.set([0,0,e.width,e.height])}};class Xr{constructor(e,i){this.drawFunctions=Wr,this.context=new cr(e),this.transform=i,this._tileTextures={},this.terrainFacilitator={depthDirty:!0,coordsDirty:!1,matrix:t.ap(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=ze.maxOverzooming+ze.maxUnderzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Dt}resize(e,t,i){if(this.width=Math.floor(e*i),this.height=Math.floor(t*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style._order)this.style._layers[e].resize()}setup(){const e=this.context,i=new t.aU;i.emplaceBack(0,0),i.emplaceBack(t.a6,0),i.emplaceBack(0,t.a6),i.emplaceBack(t.a6,t.a6),this.tileExtentBuffer=e.createVertexBuffer(i,Nt.members),this.tileExtentSegments=t.aV.simpleSegment(0,0,4,2);const n=new t.aU;n.emplaceBack(0,0),n.emplaceBack(t.a6,0),n.emplaceBack(0,t.a6),n.emplaceBack(t.a6,t.a6),this.debugBuffer=e.createVertexBuffer(n,Nt.members),this.debugSegments=t.aV.simpleSegment(0,0,4,5);const r=new t.ch;r.emplaceBack(0,0,0,0),r.emplaceBack(t.a6,0,t.a6,0),r.emplaceBack(0,t.a6,0,t.a6),r.emplaceBack(t.a6,t.a6,t.a6,t.a6),this.rasterBoundsBuffer=e.createVertexBuffer(r,Oi.members),this.rasterBoundsSegments=t.aV.simpleSegment(0,0,4,2);const o=new t.aU;o.emplaceBack(0,0),o.emplaceBack(t.a6,0),o.emplaceBack(0,t.a6),o.emplaceBack(t.a6,t.a6),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(o,Nt.members),this.rasterBoundsSegmentsPosOnly=t.aV.simpleSegment(0,0,4,5);const s=new t.aU;s.emplaceBack(0,0),s.emplaceBack(1,0),s.emplaceBack(0,1),s.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(s,Nt.members),this.viewportSegments=t.aV.simpleSegment(0,0,4,2);const a=new t.ci;a.emplaceBack(0),a.emplaceBack(1),a.emplaceBack(3),a.emplaceBack(2),a.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(a);const l=new t.aW;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(l);const c=this.context.gl;this.stencilClearMode=new oi({func:c.ALWAYS,mask:0},0,255,c.ZERO,c.ZERO,c.ZERO),this.tileExtentMesh=new Ot(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const e=this.context,i=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const n=t.O();t.c7(n,0,this.width,this.height,0,0,1),t.S(n,n,[i.drawingBufferWidth,i.drawingBufferHeight,0]);const r={mainMatrix:n,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:n};this.useProgram("clippingMask",null,!0).draw(e,i.TRIANGLES,ni.disabled,this.stencilClearMode,ei.disabled,ii.disabled,null,null,r,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,t,i){if(this.currentStencilSource===e.source||!e.isTileClipped()||!(null==t?void 0:t.length))return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();const n=this.context;n.setColorMode(ei.disabled),n.setDepthMode(ni.disabled);const r={};for(const e of t)r[e.key]=this.nextStencilID++;this._renderTileMasks(r,t,i,!0),this._renderTileMasks(r,t,i,!1),this._tileClippingMaskIDs=r}_renderTileMasks(e,t,i,n){var r;const o=this.context,s=o.gl,a=this.style.projection,l=this.transform,c=this.useProgram("clippingMask");for(const u of t){const t=e[u.key],h=null===(r=this.style.map.terrain)||void 0===r?void 0:r.getTerrainData(u),d=a.getMeshFromTileID(this.context,u.canonical,n,!0,"stencil"),p=l.getProjectionData({overscaledTileID:u,applyGlobeMatrix:!i,applyTerrainMatrix:!0});c.draw(o,s.TRIANGLES,ni.disabled,new oi({func:s.ALWAYS,mask:0},t,255,s.KEEP,s.KEEP,s.REPLACE),ei.disabled,i?ii.disabled:ii.backCCW,null,h,p,"$clipping",d.vertexBuffer,d.indexBuffer,d.segments)}}_renderTilesDepthBuffer(){var e;const t=this.context,i=t.gl,n=this.style.projection,r=this.transform,o=this.useProgram("depth"),s=this.getDepthModeFor3D(),a=Ie(r,{tileSize:r.tileSize});for(const l of a){const a=null===(e=this.style.map.terrain)||void 0===e?void 0:e.getTerrainData(l),c=n.getMeshFromTileID(this.context,l.canonical,!0,!0,"raster"),u=r.getProjectionData({overscaledTileID:l,applyGlobeMatrix:!0,applyTerrainMatrix:!0});o.draw(t,i.TRIANGLES,s,oi.disabled,ei.disabled,ii.backCCW,null,a,u,"$clipping",c.vertexBuffer,c.indexBuffer,c.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new oi({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){const t=this.context.gl;return new oi({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const t=this.context.gl,i=e.sort((e,t)=>t.overscaledZ-e.overscaledZ),n=i[i.length-1].overscaledZ,r=i[0].overscaledZ-n+1;if(r>1){this.currentStencilSource=void 0,this.nextStencilID+r>256&&this.clearStencil();const e={};for(let i=0;i<r;i++)e[i+n]=new oi({func:t.GEQUAL,mask:255},i+this.nextStencilID,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID+=r,[e,i]}return[{[n]:oi.disabled},i]}stencilConfigForOverlapTwoPass(e){const t=this.context.gl,i=e.sort((e,t)=>t.overscaledZ-e.overscaledZ),n=i[i.length-1].overscaledZ,r=i[0].overscaledZ-n+1;if(this.clearStencil(),r>1){const e={},o={};for(let i=0;i<r;i++)e[i+n]=new oi({func:t.GREATER,mask:255},r+1+i,255,t.KEEP,t.KEEP,t.REPLACE),o[i+n]=new oi({func:t.GREATER,mask:255},1+i,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID=2*r+1,[e,o,i]}return this.nextStencilID=3,[{[n]:new oi({func:t.GREATER,mask:255},2,255,t.KEEP,t.KEEP,t.REPLACE)},{[n]:new oi({func:t.GREATER,mask:255},1,255,t.KEEP,t.KEEP,t.REPLACE)},i]}colorModeForRenderPass(){const e=this.context.gl;if(this._showOverdrawInspector){const i=1/8;return new ei([e.CONSTANT_COLOR,e.ONE],new t.bo(i,i,i,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?ei.unblended:ei.alphaBlended}getDepthModeForSublayer(e,t,i){if(!this.opaquePassEnabledForLayer())return ni.disabled;const n=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new ni(i||this.context.gl.LEQUAL,t,[n,n])}getDepthModeFor3D(){return new ni(this.context.gl.LEQUAL,ni.ReadWrite,this.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(e,i){var n,r,o;this.style=e,this.options=i,this.lineAtlas=e.lineAtlas,this.imageManager=e.imageManager,this.glyphManager=e.glyphManager,this.symbolFadeChange=e.placement.symbolFadeChange(c()),this.imageManager.beginFrame();const s=this.style._order,a=this.style.tileManagers,l={},u={},h={},d={isRenderingToTexture:!1,isRenderingGlobe:(null===(n=e.projection)||void 0===n?void 0:n.transitionState)>0};for(const e in a){const t=a[e];t.used&&t.prepare(this.context),l[e]=t.getVisibleCoordinates(!1),u[e]=l[e].slice().reverse(),h[e]=t.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let e=0;e<s.length;e++)if(this.style._layers[s[e]].is3D()){this.opaquePassCutoff=e;break}this.maybeDrawDepth(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const e of s){const t=this.style._layers[e];if(!t.hasOffscreenPass()||t.isHidden(this.transform.zoom))continue;const i=u[t.source];("custom"===t.type||i.length)&&this.renderLayer(this,a[t.source],t,i,d)}if(null===(r=this.style.projection)||void 0===r||r.updateGPUdependent({context:this.context,useProgram:e=>this.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?t.bo.black:t.bo.transparent,depth:1}),this.clearStencil(),this.style.sky&&this.drawFunctions.sky(this,this.style.sky),this._showOverdrawInspector=i.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=s.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[s[this.currentLayer]],t=a[e.source],i=l[e.source];this._renderTileClippingMasks(e,i,!1),this.renderLayer(this,t,e,i,d)}this.renderPass="translucent";let p=!1;for(this.currentLayer=0;this.currentLayer<s.length;this.currentLayer++){const e=this.style._layers[s[this.currentLayer]],t=a[e.source];if(null===(o=this.renderToTexture)||void 0===o?void 0:o.renderLayer(e,d))continue;this.opaquePassEnabledForLayer()||p||(p=!0,d.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());const i=("symbol"===e.type?h:u)[e.source];this._renderTileClippingMasks(e,l[e.source],!!this.renderToTexture),this.renderLayer(this,t,e,i,d)}if(d.isRenderingGlobe&&this.drawFunctions.atmosphere(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const e=function(e,t){let i=null;const n=Object.values(e._layers).flatMap(i=>i.source&&!i.isHidden(t)?[e.tileManagers[i.source]]:[]),r=n.filter(e=>"vector"===e.getSource().type),o=n.filter(e=>"vector"!==e.getSource().type),s=e=>{(!i||i.getSource().maxzoom<e.getSource().maxzoom)&&(i=e)};for(const e of r)s(e);if(!i)for(const e of o)s(e);return i}(this.style,this.transform.zoom);e&&this.drawFunctions.debug(this,e,e.getVisibleCoordinates())}this.options.showPadding&&this.drawFunctions.debugPadding(this),this.context.setDefault()}maybeDrawDepth(e){var i,n;if(!(null===(n=null===(i=this.style)||void 0===i?void 0:i.map)||void 0===n?void 0:n.terrain))return;const r=this.terrainFacilitator.matrix,o=this.transform.modelViewProjectionMatrix;let s=this.terrainFacilitator.depthDirty;s||(s=e?!t.cj(r,o):!t.ck(r,o)),s||(s=this.style.map.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime)),s&&(t.cl(r,o),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.depthDirty=!1,this.terrainFacilitator.coordsDirty=!0,this.drawFunctions.terrainDepth(this,this.style.map.terrain))}maybeDrawCoords(){var e,t;(null===(t=null===(e=this.style)||void 0===e?void 0:e.map)||void 0===t?void 0:t.terrain)&&this.terrainFacilitator.coordsDirty&&(this.terrainFacilitator.coordsDirty=!1,this.drawFunctions.terrainCoords(this,this.style.map.terrain))}renderLayer(e,i,n,r,o){if(n.isHidden(this.transform.zoom))return;if("background"!==n.type&&"custom"!==n.type&&!(r||[]).length)return;this.id=n.id;const s=this.drawFunctions;t.aQ(n)?s.symbol(e,i,n,r,this.style.placement.variableOffsets,o):t.cm(n)?s.circle(e,i,n,r,o):t.cn(n)?s.heatmap(e,i,n,r,o):t.co(n)?s.line(e,i,n,r,o):t.cp(n)?s.fill(e,i,n,r,o):t.cq(n)?s.fillExtrusion(e,i,n,r,o):t.cr(n)?s.hillshade(e,i,n,r,o):t.cs(n)?s.colorRelief(e,i,n,r,o):t.bU(n)?s.raster(e,i,n,r,o):t.ct(n)?s.background(e,i,n,r,o):t.cu(n)&&s.custom(e,i,n,o)}saveTileTexture(e){const t=this._tileTextures[e.size[0]];t?t.length<Xr.MAX_TEXTURE_POOL_SIZE_PER_BUCKET?t.push(e):e.destroy():this._tileTextures[e.size[0]]=[e]}getTileTexture(e){const t=this._tileTextures[e];return t&&t.length>0?t.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const t=this.imageManager.getPattern(e.from.toString()),i=this.imageManager.getPattern(e.to.toString());return!t||!i}useProgram(e,t,i=!1,n=[]){var r;this.cache||(this.cache={});const o=!!this.style.map.terrain,s=this.style.projection,a=i?zt.projectionMercator:s.shaderPreludeCode,l=i?Bt:s.shaderDefine,c=e+(t?t.cacheKey:"")+`/${i?Gt:s.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(o?"/terrain":"")+(n?`/${n.join("/")}`:"");return(r=this.cache)[c]||(r[c]=new Vi(this.context,zt[e],t,bn[e],this._showOverdrawInspector,o,a,l,n)),this.cache[c]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new t.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){var e,t;if(this._tileTextures){for(const e in this._tileTextures){const t=this._tileTextures[e];if(t)for(const e of t)e.destroy()}this._tileTextures={}}if(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&&(null===(e=this.tileExtentMesh.vertexBuffer)||void 0===e||e.destroy()),this.tileExtentMesh&&(null===(t=this.tileExtentMesh.indexBuffer)||void 0===t||t.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(const e in this.cache){const t=this.cache[e];(null==t?void 0:t.program)&&this.context.gl.deleteProgram(t.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:t}=this.context.gl;return this.width!==e||this.height!==t}}function Yr(e,t){let i,n=!1,r=null;const o=()=>{r=null,n&&(e(...i),r=setTimeout(o,t),n=!1)};return(...e)=>(n=!0,i=e,r||o(),r)}Xr.MAX_TEXTURE_POOL_SIZE_PER_BUCKET=50;class Jr{constructor(e){this._getCurrentHash=()=>{const e=window.location.hash.replace("#","");if(this._hashName){let t;const i=e.split("&").map(e=>e.split("="));for(const e of i)e[0]===this._hashName&&(t=e);return(t&&t[1]||"").split("/")}return e.split("/")},this._onHashChange=()=>{const e=this._getCurrentHash();if(!this._isValidHash(e))return!1;const t=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:t,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{const e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e)},this._removeHash=()=>{const e=this._getCurrentHash();if(0===e.length)return;const t=e.join("/");let i=t;i.split("&").length>0&&(i=i.split("&")[0]),this._hashName&&(i=`${this._hashName}=${t}`);let n=window.location.hash.replace(i,"");n.startsWith("#&")?n=n.slice(0,1)+n.slice(2):"#"===n&&(n="");let r=window.location.href.replace(/(#.+)?$/,n);r=r.replace("&&","&"),window.history.replaceState(window.history.state,null,r)},this._updateHash=Yr(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,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(e){const t=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,n=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),r=Math.pow(10,n),o=Math.round(t.lng*r)/r,s=Math.round(t.lat*r)/r,a=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=e?`/${o}/${s}/${i}`:`${i}/${s}/${o}`,(a||l)&&(c+="/"+Math.round(10*a)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const e=this._hashName;let t=!1;const i=window.location.hash.slice(1).split("&").map(i=>{const n=i.split("=")[0];return n===e?(t=!0,`${n}=${c}`):i}).filter(e=>e);return t||i.push(`${e}=${c}`),`#${i.join("&")}`}return`#${c}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new t.W(+e[2],+e[1])}catch(e){return!1}const i=+e[0],n=+(e[3]||0),r=+(e[4]||0);return i>=this._map.getMinZoom()&&i<=this._map.getMaxZoom()&&n>=-180&&n<=180&&r>=this._map.getMinPitch()&&r<=this._map.getMaxPitch()}}const Kr={linearity:.3,easing:t.cv(0,0,.3,1)},Qr=t.e({deceleration:2500,maxSpeed:1400},Kr),eo=t.e({deceleration:20,maxSpeed:1400},Kr),to=t.e({deceleration:1e3,maxSpeed:360},Kr),io=t.e({deceleration:1e3,maxSpeed:90},Kr),no=t.e({deceleration:1e3,maxSpeed:360},Kr);class ro{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:c(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,t=c();for(;e.length>0&&t-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,roll:0,pan:new t.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,i.roll+=e.rollDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const n=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(i.pan.mag()){const o=so(i.pan.mag(),n,t.e({},Qr,e||{})),s=i.pan.mult(o.amount/i.pan.mag()),a=this._map.cameraHelper.handlePanInertia(s,this._map.transform);r.center=a.easingCenter,r.offset=a.easingOffset,oo(r,o)}if(i.zoom){const e=so(i.zoom,n,eo);r.zoom=t.cw(this._map.transform.zoom+e.amount,this._map.getZoomSnap(),e.amount),oo(r,e)}if(i.bearing){const e=so(i.bearing,n,to);r.bearing=this._map.transform.bearing+t.al(e.amount,-179,179),oo(r,e)}if(i.pitch){const e=so(i.pitch,n,io);r.pitch=this._map.transform.pitch+e.amount,oo(r,e)}if(i.roll){const e=so(i.roll,n,no);r.roll=this._map.transform.roll+t.al(e.amount,-179,179),oo(r,e)}if(r.zoom||r.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;r.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),t.e(r,{noMoveStart:!0})}}function oo(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function so(e,i,n){const{maxSpeed:r,linearity:o,deceleration:s}=n,a=t.al(e*o/(i/1e3),-r,r),l=Math.abs(a)/(s*o);return{easing:n.easing,duration:1e3*l,amount:a*(l/2)}}class ao extends t.n{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,i,n,r={}){n=n instanceof MouseEvent?n:new MouseEvent(e,n);const o=d.mousePos(i.getCanvas(),n),s=i.unproject(o);super(e,t.e({point:o,lngLat:s,originalEvent:n},r)),this._defaultPrevented=!1,this.target=i}}class lo extends t.n{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,i,n){const r="touchend"===e?n.changedTouches:n.touches,o=d.touchPos(i.getCanvasContainer(),r),s=o.map(e=>i.unproject(e)),a=o.reduce((e,t,i,n)=>e.add(t.div(n.length)),new t.P(0,0));super(e,{points:o,point:a,lngLats:s,lngLat:i.unproject(a),originalEvent:n}),this._defaultPrevented=!1}}class co extends t.n{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1}}class uo{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new co(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new ao(e.type,this._map,e))}mouseup(e){this._map.fire(new ao(e.type,this._map,e))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new ao(e.type,this._map,e))}dblclick(e){return this._firePreventable(new ao(e.type,this._map,e))}mouseover(e){this._map.fire(new ao(e.type,this._map,e))}mouseout(e){this._map.fire(new ao(e.type,this._map,e))}touchstart(e){return this._firePreventable(new lo(e.type,this._map,e))}touchmove(e){this._map.fire(new lo(e.type,this._map,e))}touchend(e){this._map.fire(new lo(e.type,this._map,e))}touchcancel(e){this._map.fire(new lo(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ho{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new ao(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ao("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new ao(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class po{constructor(e){this._map=e}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this._map.terrain)}}class fo{constructor(e,t){this._map=e,this._tr=new po(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1,t.boxZoom&&"object"==typeof t.boxZoom&&(this._boxZoomEnd=t.boxZoom.boxZoomEnd)}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(d.disableDrag(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)<this._clickTolerance)return;const n=this._startPos;this._lastPos=i,this._box||(this._box=d.create("div","_mlgl-boxzoom",this._container),this._container.classList.add("_mlgl-crosshair"),this._fireEvent("boxzoomstart",e));const r=Math.min(n.x,i.x),o=Math.max(n.x,i.x),s=Math.min(n.y,i.y),a=Math.max(n.y,i.y);this._box.style.transform=`translate(${r}px,${s}px)`,this._box.style.width=o-r+"px",this._box.style.height=a-s+"px"}mouseupWindow(e,i){if(!this._active)return;if(0!==e.button)return;const n=this._startPos,r=i;if(this.reset(),d.suppressClick(),n.x!==r.x||n.y!==r.y)return this._map.fire(new t.n("boxzoomend",{originalEvent:e})),this._boxZoomEnd?void this._boxZoomEnd(this._map,n,r,e):{cameraAnimation:e=>e.fitScreenCoordinates(n,r,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("_mlgl-crosshair"),this._box&&(this._box.remove(),this._box=null),d.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,i){return this._map.fire(new t.n(e,{originalEvent:i}))}}function mo(e,t){if(e.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${e.length}, points ${t.length}`);const i={};for(let n=0;n<e.length;n++)i[e[n].identifier]=t[n];return i}class go{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(e,i,n){(this.centroid||n.length>this.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),n.length===this.numTouches&&(this.centroid=function(e){const i=new t.P(0,0);for(const t of e)i._add(t);return i.div(e.length)}(i),this.touches=mo(n,i)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const n=mo(i,t);for(const e in this.touches){const t=n[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0)}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class yo{constructor(e){this.singleTap=new go(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,t,i){this.singleTap.touchstart(e,t,i)}touchmove(e,t,i){this.singleTap.touchmove(e,t,i)}touchend(e,t,i){const n=this.singleTap.touchend(e,t,i);if(n){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(n)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=n,this.count===this.numTaps)return this.reset(),n}}}class _o{constructor(e){this._tr=new po(e),this._zoomIn=new yo({numTouches:1,numTaps:2}),this._zoomOut=new yo({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i)}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i)}touchend(e,i,n){const r=this._zoomIn.touchend(e,i,n),o=this._zoomOut.touchend(e,i,n),s=this._tr;return r?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:i=>i.easeTo({duration:300,zoom:t.cw(s.zoom+1,i.getZoomSnap()),around:s.unproject(r)},{originalEvent:e})}):o?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:i=>i.easeTo({duration:300,zoom:t.cw(s.zoom-1,i.getZoomSnap()),around:s.unproject(o)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class vo{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){const t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(t)?t[0]:t,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,t){if(!this.isEnabled())return;const i=this._lastPoint;if(!i)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const n=Array.isArray(t)?t[0]:t;return!this._moved&&n.dist(i)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=n,this._move(i,n))}dragEnd(e){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(e)&&(this._moved&&d.suppressClick(),this.reset(e))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}const xo=0,bo=2,wo={[xo]:1,[bo]:2};class Eo{constructor(e){this._correctEvent=e.checkCorrectEvent}startMove(e){this._eventButton=e.button}endMove(e){delete this._eventButton}isValidStartEvent(e){return this._correctEvent(e)}isValidMoveEvent(e){return!function(e,t){const i=wo[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton)}isValidEndEvent(e){return e.button===this._eventButton}}class To{constructor(){this._firstTouch=void 0}_isOneFingerTouch(e){return 1===e.targetTouches.length}_isSameTouchEvent(e){return e.targetTouches[0].identifier===this._firstTouch}startMove(e){this._firstTouch=e.targetTouches[0].identifier}endMove(e){delete this._firstTouch}isValidStartEvent(e){return this._isOneFingerTouch(e)}isValidMoveEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}isValidEndEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}}class So{constructor(e=new Eo({checkCorrectEvent:()=>!0}),t=new To){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t}_executeRelevantHandler(e,t,i){return e instanceof MouseEvent?t(e):"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?i(e):void 0}startMove(e){this._executeRelevantHandler(e,e=>{this.mouseMoveStateManager.startMove(e)},e=>{this.oneFingerTouchMoveStateManager.startMove(e)})}endMove(e){this._executeRelevantHandler(e,e=>{this.mouseMoveStateManager.endMove(e)},e=>{this.oneFingerTouchMoveStateManager.endMove(e)})}isValidStartEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidStartEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e))}isValidMoveEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidMoveEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e))}isValidEndEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidEndEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e))}}const Io=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};class ko{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new t.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active){if(!this._shouldBePrevented(i.length))return e.preventDefault(),this._calculateTransform(e,t,i);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&this._shouldBePrevented(i.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,i,n){n.length>0&&(this._active=!0);const r=mo(n,i),o=new t.P(0,0),s=new t.P(0,0);let a=0;for(const e in r){const t=r[e],i=this._touches[e];i&&(o._add(t),s._add(t.sub(i)),a++,r[e]=t)}if(this._touches=r,this._shouldBePrevented(a)||!s.mag())return;const l=s.div(a);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:o.div(a),panDelta:l}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Mo{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(e,t,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,i){if(!this._firstTwoTouches)return;e.preventDefault();const[n,r]=this._firstTwoTouches,o=Co(i,t,n),s=Co(i,t,r);if(!o||!s)return;const a=this._aroundCenter?null:o.add(s).div(2);return this._move([o,s],a,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;const[n,r]=this._firstTwoTouches,o=Co(i,t,n),s=Co(i,t,r);o&&s||(this._active&&d.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function Co(e,t,i){for(let n=0;n<e.length;n++)if(e[n].identifier===i)return t[n]}function Po(e,t){return Math.log(e/t)/Math.LN2}class Ao extends Mo{constructor(){super(),this._zoomRate=1,this._zoomThreshold=.1}setZoomRate(e){this._zoomRate=null!=e?e:1}setZoomThreshold(e){this._zoomThreshold=null!=e?e:.1}reset(){super.reset(),delete this._distance,delete this._startDistance}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,t){const i=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(Po(this._distance,this._startDistance))<this._zoomThreshold))return this._active=!0,{zoomDelta:Po(this._distance,i)*this._zoomRate,pinchAround:t}}}function Lo(e,t){return 180*e.angleWith(t)/Math.PI}class Do extends Mo{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1])}_move(e,t,i){const n=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Lo(this._vector,n),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());const t=25/(Math.PI*this._minDiameter)*360,i=Lo(e,this._startVector);return Math.abs(i)<t}}function Ro(e){return Math.abs(e.y)>Math.abs(e.x)}class zo extends Mo{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,t,i){super.touchstart(e,t,i),this._currentTouchCount=i.length}_start(e){this._lastPoints=e,Ro(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const n=e[0].sub(this._lastPoints[0]),r=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(n,r,i.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(n.y+r.y)/2*-.5}):void 0}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const n=e.mag()>=2,r=t.mag()>=2;if(!n&&!r)return;if(!n||!r)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return Ro(e)&&Ro(t)&&o}}const Fo={panStep:100,bearingStep:15,pitchStep:10};class Oo{constructor(e){this._tr=new po(e);const t=Fo;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let i=0,n=0,r=0,o=0,s=0;switch(e.keyCode){case 61:case 107:case 171:case 187:i=1;break;case 189:case 109:case 173:i=-1;break;case 37:e.shiftKey?n=-1:(e.preventDefault(),o=-1);break;case 39:e.shiftKey?n=1:(e.preventDefault(),o=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),s=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),s=1);break;default:return}return this._rotationDisabled&&(n=0,r=0),{cameraAnimation:a=>{const l=this._tr;a.easeTo({duration:300,easeId:"keyboardHandler",easing:No,zoom:i?t.cw(l.zoom+i*(e.shiftKey?2:1),a.getZoomSnap()):l.zoom,bearing:l.bearing+n*this._bearingStep,pitch:l.pitch+r*this._pitchStep,offset:[-o*this._panStep,-s*this._panStep],center:l.center},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function No(e){return e*(2-e)}const Bo=4.000244140625,Go=1/450;class jo{constructor(e,t){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)},this._map=e,this._tr=new po(e),this._triggerRenderFrame=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Go}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const i=c(),n=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==t&&t%Bo==0?this._type="wheel":0!==t&&Math.abs(t)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(n*t)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.preventDefault()}_start(e){if(!this._delta)return;this._needsRerender=!1,this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const i=d.mousePos(this._map.getCanvas(),e),n=this._tr;this._aroundPoint=this._aroundCenter?n.transform.locationToScreenPoint(t.W.convert(n.center)):i,this._needsRerender||(this._needsRerender=!0,this._triggerRenderFrame())}renderFrame(){if(!this._needsRerender)return;if(this._needsRerender=!1,!this.isActive())return;const e=this._tr.transform;if("number"==typeof this._lastExpectedZoom){const t=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=t),"number"==typeof this._targetZoom&&(this._targetZoom+=t)}if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>Bo?this._wheelZoomRate:this._defaultZoomRate;let n=2/(1+Math.exp(-Math.abs(this._delta*i)));this._delta<0&&0!==n&&(n=1/n);const r="number"!=typeof this._targetZoom?e.scale:t.ao(this._targetZoom),o=e.applyConstrain(e.getCameraLngLat(),t.ar(r*n)).zoom,s=this._map.getZoomSnap();if("wheel"===this._type&&s>0){const i=t.cw(e.zoom,s);this._targetZoom=t.cw(o,s,o-i)}else this._targetZoom=o;"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const i="number"!=typeof this._targetZoom?e.zoom:this._targetZoom,n=this._startZoom,r=this._easing;let o,s=!1;if("wheel"===this._type&&n&&r){const e=c()-this._lastWheelEventTime,a=Math.min((e+5)/200,1),l=r(a);o=t.H.number(n,i,l),a<1?this._needsRerender=!0:s=!0}else o=i,s=!0;return this._active=!0,s&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout},200)),this._lastExpectedZoom=o,{noInertia:!0,needsRenderFrame:!s,zoomDelta:o-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let i=t.cy;if(this._prevEase){const e=this._prevEase,n=(c()-e.start)/e.duration,r=e.easing(n+.01)-e.easing(n),o=.27/Math.sqrt(r*r+1e-4)*.01,s=Math.sqrt(.0729-o*o);i=t.cv(o,s,.25,1)}return this._prevEase={start:c(),duration:e,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Vo{constructor(e,t){this._clickZoom=e,this._tapZoom=t}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class Uo{constructor(e){this._tr=new po(e),this.reset()}reset(){this._active=!1}dblclick(e,i){return e.preventDefault(),{cameraAnimation:n=>{n.easeTo({duration:300,zoom:t.cw(this._tr.zoom+(e.shiftKey?-1:1),n.getZoomSnap()),around:this._tr.unproject(i)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class qo{constructor(){this._tap=new yo({numTouches:1,numTaps:1}),this._zoomRate=1,this.reset()}setZoomRate(e){this._zoomRate=null!=e?e:1}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,t,i){if(!this._swipePoint)if(this._tapTime){const n=t[0],r=e.timeStamp-this._tapTime<500,o=this._tapPoint.dist(n)<30;r&&o?i.length>0&&(this._swipePoint=n,this._swipeTouch=i[0].identifier):this.reset()}else this._tap.touchstart(e,t,i)}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const n=t[0],r=n.y-this._swipePoint.y;return this._swipePoint=n,e.preventDefault(),this._active=!0,{zoomDelta:r/128*this._zoomRate}}}else this._tap.touchmove(e,t,i)}touchend(e,t,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else{const n=this._tap.touchend(e,t,i);n&&(this._tapTime=e.timeStamp,this._tapPoint=n)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Zo{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("_mlgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("_mlgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class $o{constructor(e,t,i,n){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=i,this._mouseRoll=n}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()}}class Ho{constructor(e,t,i,n){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=n,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("_mlgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("_mlgl-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(e){this._touchZoom.setZoomRate(e),this._tapDragZoom.setZoomRate(e)}setZoomThreshold(e){this._touchZoom.setZoomThreshold(e)}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class Wo{constructor(e,t){this._bypassKey=navigator.userAgent.includes("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=t,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("_mlgl-cooperative-gestures"),this._container=d.create("div","_mlgl-cooperative-gesture-screen",e);let t=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(t=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),n=document.createElement("div");n.className="_mlgl-desktop-message",n.textContent=t,this._container.appendChild(n);const r=document.createElement("div");r.className="_mlgl-mobile-message",r.textContent=i,this._container.appendChild(r),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(this._container.remove(),this._map.getCanvasContainer().classList.remove("_mlgl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,i){this._enabled&&(this._map.fire(new t.n("cooperativegestureprevented",{gestureType:e,originalEvent:i})),this._container.classList.add("_mlgl-show"),setTimeout(()=>{this._container.classList.remove("_mlgl-show")},100))}}const Xo=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class Yo extends t.n{}function Jo(e){var t;return(null===(t=e.panDelta)||void 0===t?void 0:t.mag())||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class Ko{get _ownerDocument(){var e;return(null===(e=this._el)||void 0===e?void 0:e.ownerDocument)||document}get _ownerWindow(){var e,t;return(null===(t=null===(e=this._el)||void 0===e?void 0:e.ownerDocument)||void 0===t?void 0:t.defaultView)||window}constructor(e,i){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`)},this.handleEvent=(e,i)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;const n="renderFrame"===e.type?void 0:e,r={needsRenderFrame:!1},o={},s={};for(const{handlerName:a,handler:l,allowed:c}of this._handlers){if(!l.isEnabled())continue;let u;if(this._blockedByActive(s,c,a))l.reset();else if(l[i||e.type]){if(t.cz(e,i||e.type)){const t=d.mousePos(this._map.getCanvas(),e);u=l[i||e.type](e,t)}else if(t.cA(e,i||e.type)){const t=this._getMapTouches(e.touches),n=d.touchPos(this._map.getCanvas(),t);u=l[i||e.type](e,n,t)}else t.cB(i||e.type)||(u=l[i||e.type](e));this.mergeHandlerResult(r,o,u,a,n),(null==u?void 0:u.needsRenderFrame)&&this._triggerRenderFrame()}(u||l.isActive())&&(s[a]=l)}const a={};for(const e in this._previousActiveHandlers)s[e]||(a[e]=n);this._previousActiveHandlers=s,(Object.keys(a).length||Jo(r))&&(this._changes.push([r,o,a]),this._triggerRenderFrame()),(Object.keys(s).length||Jo(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:l}=r;l&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],l(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ro(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i);const n=this._el;this._listeners=[[n,"touchstart",{passive:!0}],[n,"touchmove",{passive:!1}],[n,"touchend",void 0],[n,"touchcancel",void 0],[n,"mousedown",void 0],[n,"mousemove",void 0],[n,"mouseup",void 0],[this._ownerDocument,"mousemove",{capture:!0}],[this._ownerDocument,"mouseup",void 0],[n,"mouseover",void 0],[n,"mouseout",void 0],[n,"dblclick",void 0],[n,"click",void 0],[n,"keydown",{capture:!1}],[n,"keyup",void 0],[n,"wheel",{passive:!1}],[n,"contextmenu",void 0],[this._ownerWindow,"blur",void 0]];for(const[e,t,i]of this._listeners)e.addEventListener(t,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,i)}destroy(){for(const[e,t,i]of this._listeners)e.removeEventListener(t,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(e){const i=this._map,n=i.getCanvasContainer();this._add("mapEvent",new uo(i,e));const r=i.boxZoom=new fo(i,e);this._add("boxZoom",r),e.interactive&&e.boxZoom&&r.enable();const o=i.cooperativeGestures=new Wo(i,e.cooperativeGestures);this._add("cooperativeGestures",o),e.cooperativeGestures&&o.enable();const s=new _o(i),a=new Uo(i);i.doubleClickZoom=new Vo(a,s),this._add("tapZoom",s),this._add("clickZoom",a),e.interactive&&e.doubleClickZoom&&i.doubleClickZoom.enable();const l=new qo;this._add("tapDragZoom",l);const c=i.touchPitch=new zo(i);this._add("touchPitch",c),e.interactive&&e.touchPitch&&i.touchPitch.enable(e.touchPitch);const u=()=>i.project(i.getCenter()),h=function({enable:e,clickTolerance:i,aroundCenter:n=!0,minPixelCenterThreshold:r=100,rotateDegreesPerPixelMoved:o=.8},s){const a=new Eo({checkCorrectEvent:e=>0===e.button&&e.ctrlKey||2===e.button&&!e.ctrlKey});return new vo({clickTolerance:i,move:(e,i)=>{const a=s();if(n&&Math.abs(a.y-e.y)>r)return{bearingDelta:t.cx(new t.P(e.x,i.y),i,a)};let l=(i.x-e.x)*o;return n&&i.y<a.y&&(l=-l),{bearingDelta:l}},moveStateManager:a,enable:e,assignEvents:Io})}(e,u),d=function({enable:e,clickTolerance:t,pitchDegreesPerPixelMoved:i=-.5}){const n=new Eo({checkCorrectEvent:e=>0===e.button&&e.ctrlKey||2===e.button});return new vo({clickTolerance:t,move:(e,t)=>({pitchDelta:(t.y-e.y)*i}),moveStateManager:n,enable:e,assignEvents:Io})}(e),p=function({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:i=.3},n){const r=new Eo({checkCorrectEvent:e=>2===e.button&&e.ctrlKey});return new vo({clickTolerance:t,move:(e,t)=>{const r=n();let o=(t.x-e.x)*i;return t.y<r.y&&(o=-o),{rollDelta:o}},moveStateManager:r,enable:e,assignEvents:Io})}(e,u);i.dragRotate=new $o(e,h,d,p),this._add("mouseRotate",h,["mousePitch"]),this._add("mousePitch",d,["mouseRotate","mouseRoll"]),this._add("mouseRoll",p,["mousePitch"]),e.interactive&&e.dragRotate&&i.dragRotate.enable();const f=function({enable:e,clickTolerance:t}){const i=new Eo({checkCorrectEvent:e=>0===e.button&&!e.ctrlKey});return new vo({clickTolerance:t,move:(e,t)=>({around:t,panDelta:t.sub(e)}),activateOnStart:!0,moveStateManager:i,enable:e,assignEvents:Io})}(e),m=new ko(e,i);i.dragPan=new Zo(n,f,m),this._add("mousePan",f),this._add("touchPan",m,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&i.dragPan.enable(e.dragPan);const g=new Do,y=new Ao;i.touchZoomRotate=new Ho(n,y,g,l),this._add("touchRotate",g,["touchPan","touchZoom"]),this._add("touchZoom",y,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&i.touchZoomRotate.enable(e.touchZoomRotate),this._add("blockableMapEvent",new ho(i));const _=i.scrollZoom=new jo(i,()=>this._triggerRenderFrame());this._add("scrollZoom",_,["mousePan"]),e.interactive&&e.scrollZoom&&i.scrollZoom.enable(e.scrollZoom);const v=i.keyboard=new Oo(i);this._add("keyboard",v),e.interactive&&e.keyboard&&i.keyboard.enable()}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(Xo(this._eventsInProgress))||this.isZooming()}_blockedByActive(e,t,i){for(const n in e)if(n!==i&&!(null==t?void 0:t.includes(n)))return!0;return!1}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}mergeHandlerResult(e,i,n,r,o){if(!n)return;t.e(e,n);const s={handlerName:r,originalEvent:n.originalEvent||o};void 0!==n.zoomDelta&&(i.zoom=s),void 0!==n.panDelta&&(i.drag=s),void 0!==n.rollDelta&&(i.roll=s),void 0!==n.pitchDelta&&(i.pitch=s),void 0!==n.bearingDelta&&(i.rotate=s)}_applyChanges(){const e={},i={},n={};for(const[r,o,s]of this._changes)r.panDelta&&(e.panDelta=(e.panDelta||new t.P(0,0))._add(r.panDelta)),r.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+r.pitchDelta),r.rollDelta&&(e.rollDelta=(e.rollDelta||0)+r.rollDelta),void 0!==r.around&&(e.around=r.around),void 0!==r.pinchAround&&(e.pinchAround=r.pinchAround),r.noInertia&&(e.noInertia=r.noInertia),t.e(i,o),t.e(n,s);this._updateMapTransform(e,i,n),this._changes=[]}_updateMapTransform(e,t,i){const n=this._map,r=n._getTransformForUpdate(),o=n.terrain;if(!(Jo(e)||o&&this._terrainMovement))return void this._fireEvents(t,i,!0);n._stop(!0);let{panDelta:s,zoomDelta:a,bearingDelta:l,pitchDelta:c,rollDelta:u,around:h,pinchAround:d}=e;void 0!==d&&(h=d),h||(h=n.transform.centerPoint),o&&!r.isPointOnMapSurface(h)&&(h=r.centerPoint);const p={panDelta:s,zoomDelta:a,rollDelta:u,pitchDelta:c,bearingDelta:l,around:h};this._map.cameraHelper.useGlobeControls&&!r.isPointOnMapSurface(h)&&(h=r.centerPoint);const f=h.distSqr(r.centerPoint)<.01?r.center:r.screenPointToLocation(s?h.sub(s):h);this._handleMapControls({terrain:o,tr:r,deltasForHelper:p,preZoomAroundLoc:f,combinedEventsInProgress:t,panDelta:s}),n._applyUpdatedTransform(r),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0)}_handleMapControls({terrain:e,tr:t,deltasForHelper:i,preZoomAroundLoc:n,combinedEventsInProgress:r,panDelta:o}){const s=this._map.cameraHelper;if(s.handleMapControlsRollPitchBearingZoom(i,t),e)return s.useGlobeControls?(this._terrainMovement||!r.drag&&!r.zoom||(this._terrainMovement=!0,this._map._elevationFreeze=!0),void s.handleMapControlsPan(i,t,n)):this._terrainMovement||!r.drag&&!r.zoom?void(r.drag&&this._terrainMovement&&o?t.setCenter(t.screenPointToLocation(t.centerPoint.sub(o))):s.handleMapControlsPan(i,t,n)):(this._terrainMovement=!0,this._map._elevationFreeze=!0,void s.handleMapControlsPan(i,t,n));s.handleMapControlsPan(i,t,n)}_fireEvents(e,i,n){const r=Xo(this._eventsInProgress),o=Xo(e),s={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(s[`${t}start`]=i),this._eventsInProgress[t]=e[t]}!r&&o&&this._fireEvent("movestart",o.originalEvent);for(const e in s)this._fireEvent(e,s[e]);o&&this._fireEvent("move",o.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i)}const l={};let c;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:n}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],c=i[t]||n,l[`${e}end`]=c)}for(const e in l)this._fireEvent(e,l[e]);const u=Xo(this._eventsInProgress),h=(r||o)&&!u;if(h&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e)}if(n&&h){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap<e&&e<this._bearingSnap;!e||!e.essential&&a.prefersReducedMotion?(this._map.fire(new t.n("moveend",{originalEvent:c})),i(this._map.getBearing())&&this._map.resetNorth()):(i(e.bearing||this._map.getBearing())&&(e.bearing=0),e.freezeElevation=!0,this._map.easeTo(e,{originalEvent:c})),this._updatingCamera=!1}}_fireEvent(e,i){this._map.fire(new t.n(e,i?{originalEvent:i}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(e=>{delete this._frameId,this.handleEvent(new Yo("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class Qo extends t.E{constructor(e,t,i){super(),this._renderFrameCallback=()=>{const e=Math.min((c()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=i.bearingSnap,this._zoomSnap=i.zoomSnap,this.cameraHelper=t,this.on("moveend",()=>{delete this._requestedCameraState})}migrateProjection(e,t){e.apply(this.transform,!0),this.transform=e,this.cameraHelper=t}getCenter(){return new t.W(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,t){return this.jumpTo({elevation:e},t),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,i,n){return e=t.P.convert(e).mult(-1),this.panTo(this.transform.center,t.e({offset:e},i),n)}panTo(e,i,n){return this.easeTo(t.e({center:e},i),n)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,i,n){return this.easeTo(t.e({zoom:e},i),n)}zoomIn(e,i){return this.zoomTo(t.cw(this.getZoom()+1,this._zoomSnap),e,i),this}zoomOut(e,i){return this.zoomTo(t.cw(this.getZoom()-1,this._zoomSnap),e,i),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,i){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new t.n("movestart",i)).fire(new t.n("move",i)).fire(new t.n("moveend",i))),this}getBearing(){return this.transform.bearing}setZoomSnap(e){return this._zoomSnap=e,this}getZoomSnap(){return this._zoomSnap}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,i,n){return this.easeTo(t.e({bearing:e},i),n)}resetNorth(e,i){return this.rotateTo(0,t.e({duration:1e3},e),i),this}resetNorthPitch(e,i){return this.easeTo(t.e({bearing:0,pitch:0,roll:0,duration:1e3},e),i),this}snapToNorth(e,t){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,t):this}getPitch(){return this.transform.pitch}setPitch(e,t){return this.jumpTo({pitch:e},t),this}getRoll(){return this.transform.roll}setRoll(e,t){return this.jumpTo({roll:e},t),this}cameraForBounds(e,t){e=U.convert(e).adjustAntiMeridian();const i=(null==t?void 0:t.bearing)||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),i,t)}_cameraForBoxAndBearing(e,i,n,r){const o={top:0,bottom:0,right:0,left:0};if("number"==typeof(r=t.e({padding:o,offset:[0,0],maxZoom:this.transform.maxZoom},r)).padding){const e=r.padding;r.padding={top:e,bottom:e,right:e,left:e}}const s=t.e(o,r.padding);r.padding=s;const a=this.transform,l=new U(e,i),c=this.cameraHelper.cameraForBoxAndBearing(r,s,l,n,a);return c&&this._zoomSnap&&(c.zoom=t.cw(c.zoom,this._zoomSnap,-1)),c}fitBounds(e,t,i){return this._fitInternal(this.cameraForBounds(e,t),t,i)}fitScreenCoordinates(e,i,n,r,o){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(t.P.convert(e)),this.transform.screenPointToLocation(t.P.convert(i)),n,r),r,o)}_fitInternal(e,i,n){return e?(delete(i=t.e(e,i)).padding,i.linear?this.easeTo(i,n):this.flyTo(i,n)):this}jumpTo(e,i){this.stop(),"zoom"in e&&this._zoomSnap&&(e.zoom=t.cw(e.zoom,this._zoomSnap));const n=this._getTransformForUpdate();let r=!1,o=!1,s=!1;const a=n.zoom;this.terrain&&n.setElevation(this.terrain.getElevationForLngLatZoom(e.center?t.W.convert(e.center):n.center,e.zoom||n.tileZoom)),this.cameraHelper.handleJumpToCenterZoom(n,e);const l=n.zoom!==a;return"elevation"in e&&n.elevation!==+e.elevation&&n.setElevation(+e.elevation),"bearing"in e&&n.bearing!==+e.bearing&&(r=!0,n.setBearing(+e.bearing)),"pitch"in e&&n.pitch!==+e.pitch&&(o=!0,n.setPitch(+e.pitch)),"roll"in e&&n.roll!==+e.roll&&(s=!0,n.setRoll(+e.roll)),null==e.padding||n.isPaddingEqual(e.padding)||n.setPadding(e.padding),this._applyUpdatedTransform(n),this.fire(new t.n("movestart",i)).fire(new t.n("move",i)),l&&this.fire(new t.n("zoomstart",i)).fire(new t.n("zoom",i)).fire(new t.n("zoomend",i)),r&&this.fire(new t.n("rotatestart",i)).fire(new t.n("rotate",i)).fire(new t.n("rotateend",i)),o&&this.fire(new t.n("pitchstart",i)).fire(new t.n("pitch",i)).fire(new t.n("pitchend",i)),s&&this.fire(new t.n("rollstart",i)).fire(new t.n("roll",i)).fire(new t.n("rollend",i)),this.fire(new t.n("moveend",i))}calculateCameraOptionsFromTo(e,i,n,r=0){const o=t.a7.fromLngLat(e,i),s=t.a7.fromLngLat(n,r),a=s.x-o.x,l=s.y-o.y,c=s.z-o.z,u=Math.hypot(a,l,c);if(0===u)throw new Error("Can't calculate camera options with same From and To");const h=Math.hypot(a,l),d=t.ar(this.transform.cameraToCenterDistance/u/this.transform.tileSize),p=180*Math.atan2(a,-l)/Math.PI;let f=180*Math.acos(h/u)/Math.PI;return f=c<0?90-f:90+f,{center:s.toLngLat(),elevation:r,zoom:d,pitch:f,bearing:p}}calculateCameraOptionsFromCameraLngLatAltRotation(e,t,i,n,r){const o=this.transform.calculateCenterFromCameraLngLatAlt(e,t,i,n);return{center:o.center,elevation:o.elevation,zoom:o.zoom,bearing:i,pitch:n,roll:r}}easeTo(e,i){this._stop(!1,e.easeId),"zoom"in(e=t.e({offset:[0,0],duration:500,easing:t.cy},e))&&this._zoomSnap&&(e.zoom=t.cw(e.zoom,this._zoomSnap)),(!1===e.animate||!e.essential&&a.prefersReducedMotion)&&(e.duration=0);const n=this._getTransformForUpdate(),r=this.getBearing(),o=n.pitch,s=n.roll,l="bearing"in e?this._normalizeBearing(e.bearing,r):r,c="pitch"in e?+e.pitch:o,u="roll"in e?this._normalizeBearing(e.roll,s):s,h="padding"in e?e.padding:n.padding,d=t.P.convert(e.offset);let p,f;e.around&&(p=t.W.convert(e.around),f=n.locationToScreenPoint(p));const m={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},g=this.cameraHelper.handleEaseTo(n,{bearing:l,pitch:c,roll:u,padding:h,around:p,aroundPoint:f,offsetAsPoint:d,offset:e.offset,zoom:e.zoom,center:e.center});return this._rotating||(this._rotating=r!==l),this._pitching||(this._pitching=c!==o),this._rolling||(this._rolling=u!==s),this._padding=!n.isPaddingEqual(h),this._zooming||(this._zooming=g.isZooming),this._easeId=e.easeId,this._prepareEase(i,e.noMoveStart,m),this.terrain&&this._prepareElevation(g.elevationCenter),this._ease(t=>{g.easeFunc(t),this.terrain&&!e.freezeElevation&&this._updateElevation(t),this._applyUpdatedTransform(n),this._fireMoveEvents(i)},t=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i,t)},e),this}_prepareEase(e,i,n={}){this._moving=!0,i||n.moving||this.fire(new t.n("movestart",e)),this._zooming&&!n.zooming&&this.fire(new t.n("zoomstart",e)),this._rotating&&!n.rotating&&this.fire(new t.n("rotatestart",e)),this._pitching&&!n.pitching&&this.fire(new t.n("pitchstart",e)),this._rolling&&!n.rolling&&this.fire(new t.n("rollstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){void 0!==this._elevationStart&&void 0!==this._elevationCenter||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const i=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&i!==this._elevationTarget){const t=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(t-(i-(t*e+this._elevationStart))/(1-e)),this._elevationTarget=i}this.transform.setElevation(t.H.number(this._elevationStart,this._elevationTarget,e))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};const t=e.getCameraLngLat(),i=e.getCameraAltitude(),n=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(i<n){const i=this.calculateCameraOptionsFromTo(t,n,e.center,e.elevation);return{pitch:i.pitch,zoom:i.zoom}}return{}}_applyUpdatedTransform(e){const t=[];if(t.push(e=>this._elevateCameraIfInsideTerrain(e)),this.transformCameraUpdate&&t.push(e=>this.transformCameraUpdate(e)),!t.length)return;const i=e.clone();for(const e of t){const t=i.clone(),{center:n,zoom:r,roll:o,pitch:s,bearing:a,elevation:l}=e(t);n&&t.setCenter(n),void 0!==l&&t.setElevation(l),void 0!==r&&t.setZoom(r),void 0!==o&&t.setRoll(o),void 0!==s&&t.setPitch(s),void 0!==a&&t.setBearing(a),i.apply(t,!1)}this.transform.apply(i,!1)}_fireMoveEvents(e){this.fire(new t.n("move",e)),this._zooming&&this.fire(new t.n("zoom",e)),this._rotating&&this.fire(new t.n("rotate",e)),this._pitching&&this.fire(new t.n("pitch",e)),this._rolling&&this.fire(new t.n("roll",e))}_afterEase(e,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;const n=this._zooming,r=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,n&&this.fire(new t.n("zoomend",e)),r&&this.fire(new t.n("rotateend",e)),o&&this.fire(new t.n("pitchend",e)),s&&this.fire(new t.n("rollend",e)),this.fire(new t.n("moveend",e))}flyTo(e,i){if(!e.essential&&a.prefersReducedMotion){const n=t.V(e,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(n,i)}this.stop(),"zoom"in(e=t.e({offset:[0,0],speed:1.2,curve:1.42,easing:t.cy},e))&&this._zoomSnap&&(e.zoom=t.cw(e.zoom,this._zoomSnap));const n=this._getTransformForUpdate(),r=n.bearing,o=n.pitch,s=n.roll,l=n.padding,c="bearing"in e?this._normalizeBearing(e.bearing,r):r,u="pitch"in e?+e.pitch:o,h="roll"in e?this._normalizeBearing(e.roll,s):s,d="padding"in e?e.padding:n.padding,p=t.P.convert(e.offset);let f=n.centerPoint.add(p);const m=n.screenPointToLocation(f),g=this.cameraHelper.handleFlyTo(n,{bearing:c,pitch:u,roll:h,padding:d,locationAtOffset:m,offsetAsPoint:p,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let y=e.curve;const _=Math.max(n.width,n.height),v=_/g.scaleOfZoom,x=g.pixelPathLength;"number"==typeof g.scaleOfMinZoom&&(y=Math.sqrt(_/g.scaleOfMinZoom/x*2));const b=y*y;function w(e){const t=(v*v-_*_+(e?-1:1)*b*b*x*x)/(2*(e?v:_)*b*x);return Math.log(Math.sqrt(t*t+1)-t)}function E(e){return(Math.exp(e)-Math.exp(-e))/2}function T(e){return(Math.exp(e)+Math.exp(-e))/2}const S=w(!1);let I=function(e){return T(S)/T(S+y*e)},k=function(e){return _*((T(S)*(E(t=S+y*e)/T(t))-E(S))/b)/x;var t},M=(w(!0)-S)/y;if(Math.abs(x)<2e-6||!isFinite(M)){if(Math.abs(_-v)<1e-6)return this.easeTo(e,i);const t=v<_?-1:1;M=Math.abs(Math.log(v/_))/y,k=()=>0,I=e=>Math.exp(t*y*e)}return e.duration="duration"in e?+e.duration:1e3*M/("screenSpeed"in e?+e.screenSpeed/y:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=r!==c,this._pitching=u!==o,this._rolling=h!==s,this._padding=!n.isPaddingEqual(d),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(g.targetCenter),this._ease(a=>{const m=a*M,y=1/I(m),_=k(m);this._rotating&&n.setBearing(t.H.number(r,c,a)),this._pitching&&n.setPitch(t.H.number(o,u,a)),this._rolling&&n.setRoll(t.H.number(s,h,a)),this._padding&&(n.interpolatePadding(l,d,a),f=n.centerPoint.add(p)),g.easeFunc(a,y,_,f),this.terrain&&!e.freezeElevation&&this._updateElevation(a),this._applyUpdatedTransform(n),this._fireMoveEvents(i)},()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i)},e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,t){var i;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,t)}return e||null===(i=this.handlers)||void 0===i||i.stop(!1),this}_ease(e,t,i){!1===i.animate||0===i.duration?(e(1),t()):(this._easeStart=c(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,i){e=t.X(e,-180,180);const n=Math.abs(e-i);return Math.abs(e-360-i)<n&&(e-=360),Math.abs(e+360-i)<n&&(e+=360),e}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLat(t.W.convert(e),this.transform):null}}const es={compact:!0,customAttribution:'<a href="https://_ml.org/" target="_blank">MapLibre</a>'};class ts{constructor(e=es){this._toggleAttribution=()=>{this._container.classList.contains("_mlgl-compact")&&(this._container.classList.contains("_mlgl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("_mlgl-compact-show")):(this._container.classList.add("_mlgl-compact-show"),this._container.removeAttribute("open")))},this._updateData=e=>{!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType&&"terrain"!==e.type||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("_mlgl-compact")||this._container.classList.contains("_mlgl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("_mlgl-compact","_mlgl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("_mlgl-compact")&&this._container.classList.remove("_mlgl-compact","_mlgl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("_mlgl-compact")&&this._container.classList.contains("_mlgl-compact-show")&&this._container.classList.remove("_mlgl-compact-show")},this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=d.create("details","_mlgl-ctrl _mlgl-ctrl-attrib"),this._compactButton=d.create("summary","_mlgl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=d.create("div","_mlgl-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(e,t){const i=this._map._getUIString(`AttributionControl.${t}`);e.title=i,e.setAttribute("aria-label",i)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map(e=>"string"!=typeof e?"":e)):"string"==typeof this.options.customAttribution&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}const t=this._map.style.tileManagers;for(const i in t){const n=t[i];if(n.used||n.usedForTerrain){const t=n.getSource();t.attribution&&!e.includes(t.attribution)&&e.push(t.attribution)}}e=e.filter(e=>String(e).trim()),e.sort((e,t)=>e.length-t.length),e=e.filter((t,i)=>{for(let n=i+1;n<e.length;n++)if(e[n].includes(t))return!1;return!0});const i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=d.sanitize(i),this._container.classList.remove("_mlgl-attrib-empty")):this._container.classList.add("_mlgl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class is{constructor(e={}){this._updateCompact=()=>{const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&t.classList.add("_mlgl-compact"):t.classList.remove("_mlgl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){var t;this._map=e,this._compact=null===(t=this.options)||void 0===t?void 0:t.compact,this._container=d.create("div","_mlgl-ctrl");const i=d.create("a","_mlgl-ctrl-logo");return i.target="_blank",i.rel="noopener nofollow",i.href="https://_ml.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}}class ns{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var rs=t.aS([{name:"a_pos3d",type:"Int16",components:3}]);class os extends t.E{constructor(e){super(),this._lastTilesetChange=c(),this.tileManager=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null}getSource(){return this.tileManager._source}update(e,i){this.tileManager.update(e,i),this._renderableTilesKeys=[];const n={};for(const r of Ie(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i,calculateTileZoom:this.tileManager._source.calculateTileZoom}))n[r.key]=!0,this._renderableTilesKeys.push(r.key),this._tiles[r.key]||(r.terrainRttPosMatrix32f=new Float64Array(16),t.c7(r.terrainRttPosMatrix32f,0,t.a6,t.a6,0,0,1),this._tiles[r.key]=new de(r,this.tileSize),this._lastTilesetChange=c());for(const e in this._tiles)n[e]||delete this._tiles[e]}freeRtt(e){for(const t in this._tiles){const i=this._tiles[t];(!e||i.tileID.equals(e)||i.tileID.isChildOf(e)||e.isChildOf(i.tileID))&&(i.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(e=>this.getTileByID(e))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,t){return t?this._getTerrainCoordsForTileRanges(e,t):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){const i={};for(const n of this._renderableTilesKeys){const r=this._tiles[n].tileID,o=e.clone(),s=t.bj();if(r.canonical.equals(e.canonical))t.c7(s,0,t.a6,t.a6,0,0,1);else if(r.canonical.isChildOf(e.canonical)){const i=r.canonical.z-e.canonical.z,n=r.canonical.x-(r.canonical.x>>i<<i),o=r.canonical.y-(r.canonical.y>>i<<i),a=t.a6>>i;t.c7(s,0,a,a,0,0,1),t.Q(s,s,[-n*a,-o*a,0])}else{if(!e.canonical.isChildOf(r.canonical))continue;{const i=e.canonical.z-r.canonical.z,n=e.canonical.x-(e.canonical.x>>i<<i),o=e.canonical.y-(e.canonical.y>>i<<i),a=t.a6>>i;t.c7(s,0,t.a6,t.a6,0,0,1),t.Q(s,s,[n*a,o*a,0]),t.S(s,s,[1/2**i,1/2**i,0])}}o.terrainRttPosMatrix32f=new Float32Array(s),i[n]=o}return i}_getTerrainCoordsForTileRanges(e,i){const n={};for(const r of this._renderableTilesKeys){const o=this._tiles[r].tileID;if(!this._isWithinTileRanges(o,i))continue;const s=e.clone(),a=t.bj();if(o.canonical.z===e.canonical.z){const i=e.canonical.x-o.canonical.x+e.wrap*(1<<e.canonical.z),n=e.canonical.y-o.canonical.y;t.c7(a,0,t.a6,t.a6,0,0,1),t.Q(a,a,[i*t.a6,n*t.a6,0])}else if(o.canonical.z>e.canonical.z){const i=o.canonical.z-e.canonical.z,n=o.canonical.x-(o.canonical.x>>i<<i)+e.wrap*(1<<o.canonical.z),r=o.canonical.y-(o.canonical.y>>i<<i),s=e.canonical.x-(o.canonical.x>>i),l=e.canonical.y-(o.canonical.y>>i),c=t.a6>>i;t.c7(a,0,c,c,0,0,1),t.Q(a,a,[-n*c+s*t.a6,-r*c+l*t.a6,0])}else{const i=e.canonical.z-o.canonical.z,n=e.canonical.x-(e.canonical.x>>i<<i)+e.wrap*(1<<e.canonical.z),r=e.canonical.y-(e.canonical.y>>i<<i),s=(e.canonical.x>>i)-o.canonical.x,l=(e.canonical.y>>i)-o.canonical.y,c=t.a6<<i;t.c7(a,0,c,c,0,0,1),t.Q(a,a,[n*t.a6+s*c,r*t.a6+l*c,0])}s.terrainRttPosMatrix32f=new Float32Array(a),n[r]=s}return n}getSourceTile(e,t){var i,n;const r=this.tileManager._source;let o=e.overscaledZ-this.deltaZoom;if(o>r.maxzoom&&(o=r.maxzoom),o<r.minzoom)return;(i=this._sourceTileCache)[n=e.key]||(i[n]=e.scaledTo(o).key);let s=this.findTileInCaches(this._sourceTileCache[e.key]);if(!(null==s?void 0:s.dem)&&t)for(;o>=r.minzoom&&!(null==s?void 0:s.dem);)s=this.findTileInCaches(e.scaledTo(o--).key);return s}findTileInCaches(e){let t=this.tileManager.getTileByID(e);return t||(t=this.tileManager._outOfViewCache.getByKey(e),t)}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){const i=t[e.canonical.z];return!!i&&(e.wrap>i.minWrap||e.wrap<i.maxWrap||e.canonical.x>=i.minTileXWrapped&&e.canonical.x<=i.maxTileXWrapped&&e.canonical.y>=i.minTileY&&e.canonical.y<=i.maxTileY)}}class ss{constructor(e,t,i){this._meshCache={},this.painter=e,this.tileManager=new os(t),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}destroy(){this._fbo&&(this._fbo.destroy(),this._fbo=null),this._fboCoordsTexture&&(this._fboCoordsTexture.destroy(),this._fboCoordsTexture=null),this._fboDepthTexture&&(this._fboDepthTexture.destroy(),this._fboDepthTexture=null),this._emptyDemTexture&&(this._emptyDemTexture.destroy(),this._emptyDemTexture=null),this._emptyDepthTexture&&(this._emptyDepthTexture.destroy(),this._emptyDepthTexture=null),this._coordsTexture&&(this._coordsTexture.destroy(),this._coordsTexture=null);for(const e in this._meshCache)this._meshCache[e].destroy();this._meshCache={},this.tileManager.destruct()}getDEMElevation(e,i,n,r=t.a6){var o;const s=e.normalizeCoordinates(i,n,r);if(!s)return 0;const a=this.getTerrainData(s.tileID),l=null===(o=a.tile)||void 0===o?void 0:o.dem;if(!l)return 0;const c=t.cC([],[s.x/r*t.a6,s.y/r*t.a6],a.u_terrain_matrix),u=[c[0]*l.dim,c[1]*l.dim],h=Math.floor(u[0]),d=Math.floor(u[1]),p=u[0]-h,f=u[1]-d;return l.get(h,d)*(1-p)*(1-f)+l.get(h+1,d)*p*(1-f)+l.get(h,d+1)*(1-p)*f+l.get(h+1,d+1)*p*f}getElevationForLngLatZoom(e,i){if(!t.cD(i,e.wrap()))return 0;const{tileID:n,mercatorX:r,mercatorY:o}=this._getOverscaledTileIDFromLngLatZoom(e,i);return this.getElevation(n,r%t.a6,o%t.a6,t.a6)}getElevationForLngLat(e,t){const i=Ie(t,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this});let n=0;for(const e of i)e.canonical.z>n&&(n=Math.min(e.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(e,n)}getElevation(e,i,n,r=t.a6){return this.getDEMElevation(e,i,n,r)*this.exaggeration}getTerrainData(e){var i,n;if(!this._emptyDemTexture){const e=this.painter.context,i=new t.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new t.T(e,i,e.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new t.T(e,new t.R({width:1,height:1}),e.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=t.ap([])}const r=this.tileManager.getSourceTile(e,!0);if((null==r?void 0:r.dem)&&(!r.demTexture||r.needsTerrainPrepare)){const e=this.painter.context;r.demTexture=this.painter.getTileTexture(r.dem.stride),r.demTexture?r.demTexture.update(r.dem.getPixels(),{premultiply:!1}):r.demTexture=new t.T(e,r.dem.getPixels(),e.gl.RGBA,{premultiply:!1}),r.demTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),r.needsTerrainPrepare=!1}const o=r&&r.toString()+r.tileID.key+e.key;if(o&&!this._demMatrixCache[o]){const i=this.tileManager.getSource().maxzoom;let n=e.canonical.z-r.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=i?n=e.canonical.z-i:t.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const s=e.canonical.x-(e.canonical.x>>n<<n),a=e.canonical.y-(e.canonical.y>>n<<n),l=t.cE(new Float64Array(16),[1/(t.a6<<n),1/(t.a6<<n),0]);t.Q(l,l,[s*t.a6,a*t.a6,0]),this._demMatrixCache[o]={matrix:l,coord:e}}return{u_depth:2,u_terrain:3,u_terrain_dim:(null===(i=null==r?void 0:r.dem)||void 0===i?void 0:i.dim)||1,u_terrain_matrix:o?this._demMatrixCache[o].matrix:this._emptyDemMatrix,u_terrain_unpack:(null===(n=null==r?void 0:r.dem)||void 0===n?void 0:n.getUnpackVector())||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:((null==r?void 0:r.demTexture)||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:r}}getFramebuffer(e){const i=this.painter,n=i.width/devicePixelRatio,r=i.height/devicePixelRatio;return!this._fbo||this._fbo.width===n&&this._fbo.height===r||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new t.T(i.context,{width:n,height:r,data:null},i.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(i.context.gl.NEAREST,i.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new t.T(i.context,{width:n,height:r,data:null},i.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(i.context.gl.NEAREST,i.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=i.context.createFramebuffer(n,r,!0,!1),this._fbo.depthAttachment.set(i.context.createRenderbuffer(i.context.gl.DEPTH_COMPONENT16,n,r))),this._fbo.colorAttachment.set("coords"===e?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const e=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const i=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let e=0,t=0;e<this._coordsTextureSize;e++)for(let n=0;n<this._coordsTextureSize;n++,t+=4)i[t+0]=255&n,i[t+1]=255&e,i[t+2]=n>>8<<4|e>>8,i[t+3]=0;const n=new t.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),r=new t.T(e,n,e.gl.RGBA,{premultiply:!1});return r.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=r,r}pointCoordinate(e){this.painter.maybeDrawDepth(!0),this.painter.maybeDrawCoords();const i=new Uint8Array(4),n=this.painter.context,r=n.gl,o=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),s=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),a=Math.round(this.painter.height/devicePixelRatio);n.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),r.readPixels(o,a-s-1,1,1,r.RGBA,r.UNSIGNED_BYTE,i),n.bindFramebuffer.set(null);const l=i[0]+(i[2]>>4<<8),c=i[1]+((15&i[2])<<8),u=this.coordsIndex[255-i[3]],h=u&&this.tileManager.getTileByID(u);if(!h)return null;const d=this._coordsTextureSize,p=(1<<h.tileID.canonical.z)*d;return new t.a7((h.tileID.canonical.x*d+l)/p+h.tileID.wrap,(h.tileID.canonical.y*d+c)/p,this.getElevation(h.tileID,l,c,d))}depthAtPoint(e){const t=new Uint8Array(4),i=this.painter.context,n=i.gl;return i.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),n.readPixels(e.x,this.painter.height/devicePixelRatio-e.y-1,1,1,n.RGBA,n.UNSIGNED_BYTE,t),i.bindFramebuffer.set(null),(t[0]/16777216+t[1]/65536+t[2]/256+t[3])/256}getTerrainMesh(e){var i;const n=(null===(i=this.painter.style.projection)||void 0===i?void 0:i.transitionState)>0,r=n&&0===e.canonical.y,o=n&&e.canonical.y===(1<<e.canonical.z)-1,s=`m_${r?"n":""}_${o?"s":""}`;if(this._meshCache[s])return this._meshCache[s];const a=this.painter.context,l=new t.cF,c=new t.aW,u=this.meshSize,h=t.a6/u,d=u*u;for(let e=0;e<=u;e++)for(let t=0;t<=u;t++)l.emplaceBack(t*h,e*h,0);for(let e=0;e<d;e+=u+1)for(let t=0;t<u;t++)c.emplaceBack(t+e,u+t+e+1,u+t+e+2),c.emplaceBack(t+e,u+t+e+2,t+e+1);const p=l.length,f=p+(u+1),m=(u+1)*u,g=r?t.bq:0,y=r?0:1,_=o?t.br:t.a6,v=o?0:1;for(let e=0;e<=u;e++)l.emplaceBack(e*h,g,y);for(let e=0;e<=u;e++)l.emplaceBack(e*h,_,v);for(let e=0;e<u;e++)c.emplaceBack(m+e,f+e,f+e+1),c.emplaceBack(m+e,f+e+1,m+e+1),c.emplaceBack(0+e,p+e+1,p+e),c.emplaceBack(0+e,0+e+1,p+e+1);const x=l.length,b=x+2*(u+1);for(const e of[0,1])for(let i=0;i<=u;i++)for(const n of[0,1])l.emplaceBack(e*t.a6,i*h,n);for(let e=0;e<2*u;e+=2)c.emplaceBack(x+e,x+e+1,x+e+3),c.emplaceBack(x+e,x+e+3,x+e+2),c.emplaceBack(b+e,b+e+3,b+e+1),c.emplaceBack(b+e,b+e+2,b+e+3);const w=new Ot(a.createVertexBuffer(l,rs.members),a.createIndexBuffer(c),t.aV.simpleSegment(0,0,l.length,c.length));return this._meshCache[s]=w,w}getMeshFrameDelta(e){return 2*Math.PI*t.bD/Math.pow(2,Math.max(e,0))/5}getMinTileElevationForLngLatZoom(e,i){var n;if(!t.cD(i,e.wrap()))return 0;const{tileID:r}=this._getOverscaledTileIDFromLngLatZoom(e,i);return null!==(n=this.getMinMaxElevation(r).minElevation)&&void 0!==n?n:0}getMinMaxElevation(e){const t=this.getTerrainData(e).tile,i={minElevation:null,maxElevation:null};return(null==t?void 0:t.dem)&&(i.minElevation=t.dem.min*this.exaggeration,i.maxElevation=t.dem.max*this.exaggeration),i}_getOverscaledTileIDFromLngLatZoom(e,i){const n=t.a7.fromLngLat(e.wrap()),r=(1<<i)*t.a6,o=n.x*r,s=n.y*r,a=Math.floor(o/t.a6),l=Math.floor(s/t.a6);return{tileID:new t.a3(i,0,i,a,l),mercatorX:o,mercatorY:s}}}class as{constructor(e,t,i){this._context=e,this._size=t,this._tileSize=i,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const e of this._objects)e.texture.destroy(),e.fbo.destroy()}_createObject(e){const i=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),n=new t.T(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return n.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),this._context.extTextureFilterAnisotropic&&this._context.gl.texParameterf(this._context.gl.TEXTURE_2D,this._context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this._context.extTextureFilterAnisotropicMax),i.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),i.colorAttachment.set(n.texture),{id:e,fbo:i,texture:n,stamp:-1,inUse:!1}}getObjectForId(e){return this._objects[e]}useObject(e){e.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter(t=>e.id!==t),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(const e of this._recentlyUsed)if(!this._objects[e].inUse)return this._objects[e];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(const e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length<this._size)&&!1===this._objects.some(e=>!e.inUse)}}const ls={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class cs{constructor(e,t){this.painter=e,this.terrain=t,this.pool=new as(e.context,30,t.tileManager.tileSize*t.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,t){var i,n,r;this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter(i=>!e._layers[i].isHidden(t)),this._coordsAscending={};for(const t in e.tileManagers){this._coordsAscending[t]={};const i=e.tileManagers[t].getVisibleCoordinates(),n=e.tileManagers[t].getSource(),o=n instanceof te?n.terrainTileRanges:null;for(const e of i){const i=this.terrain.tileManager.getTerrainCoords(e,o);for(const e in i)(r=this._coordsAscending[t])[e]||(r[e]=[]),this._coordsAscending[t][e].push(i[e])}}this._rttFingerprints={};for(const t of e._order){const r=e._layers[t],o=r.source;if(ls[r.type]&&!this._rttFingerprints[o]){this._rttFingerprints[o]={};const t=null!==(n=null===(i=e.tileManagers[o])||void 0===i?void 0:i.getState().revision)&&void 0!==n?n:0;for(const e in this._coordsAscending[o])this._rttFingerprints[o][e]=`${this._coordsAscending[o][e].map(e=>e.key).sort().join()}#${t}`}}for(const e of this._renderableTiles)for(const t in this._rttFingerprints){const i=this._rttFingerprints[t][e.tileID.key];i&&i!==e.rttFingerprint[t]&&(e.rtt=[])}}renderLayer(e,i){if(e.isHidden(this.painter.transform.zoom))return!1;const n=Object.assign(Object.assign({},i),{isRenderingToTexture:!0}),r=e.type,o=this.painter,s=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(ls[r]&&(this._prevType&&ls[this._prevType]||this._stacks.push([]),this._prevType=r,this._stacks[this._stacks.length-1].push(e.id),!s))return!0;if(ls[this._prevType]||ls[r]&&s){this._prevType=r;const e=this._stacks.length-1,i=this._stacks[e]||[];for(const r of this._renderableTiles){if(this.pool.isFull()&&($r(this.painter,this.terrain,this._rttTiles,n),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(r),r.rtt[e]){const t=this.pool.getObjectForId(r.rtt[e].id);if(t.stamp===r.rtt[e].stamp){this.pool.useObject(t);continue}}const s=this.pool.getOrCreateFreeObject();this.pool.useObject(s),this.pool.stampObject(s),r.rtt[e]={id:s.id,stamp:s.stamp},o.context.bindFramebuffer.set(s.fbo.framebuffer),o.context.clear({color:t.bo.transparent,stencil:0}),o.currentStencilSource=void 0;for(const e of i){const t=o.style._layers[e],i=t.source?this._coordsAscending[t.source][r.tileID.key]:[r.tileID];o.context.viewport.set([0,0,s.fbo.width,s.fbo.height]),o._renderTileClippingMasks(t,i,!0),o.renderLayer(o,o.style.tileManagers[t.source],t,i,n),t.source&&(r.rttFingerprint[t.source]=this._rttFingerprints[t.source][r.tileID.key])}}return $r(this.painter,this.terrain,this._rttTiles,n),this._rttTiles=[],this.pool.freeAllObjects(),ls[r]}return!1}}const us={"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"},hs=i,ds={hash:!1,interactive:!0,bearingSnap:7,zoomSnap:0,attributionControl:es,_mlLogo:!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,maxTileCacheSize:null,maxTileCacheZoomLevels:t.c.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,transformConstrain:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,rollEnabled:!1,reduceMotion:void 0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0,experimentalZoomLevelsToOverscale:void 0,anisotropicFilterPitch:20};let ps=class extends Qo{get _ownerWindow(){var e,t;return(null===(t=null===(e=this._container)||void 0===e?void 0:e.ownerDocument)||void 0===t?void 0:t.defaultView)||window}constructor(e){var i,n,r;const o=Object.assign(Object.assign(Object.assign({},ds),e),{canvasContextAttributes:Object.assign(Object.assign({},ds.canvasContextAttributes),e.canvasContextAttributes)});if(null!=o.minZoom&&null!=o.maxZoom&&o.minZoom>o.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=o.minPitch&&null!=o.maxPitch&&o.minPitch>o.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=o.minPitch&&o.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=o.maxPitch&&o.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const s=new Xt,l=new Qt;void 0!==o.minZoom&&s.setMinZoom(o.minZoom),void 0!==o.maxZoom&&s.setMaxZoom(o.maxZoom),void 0!==o.minPitch&&s.setMinPitch(o.minPitch),void 0!==o.maxPitch&&s.setMaxPitch(o.maxPitch),void 0!==o.renderWorldCopies&&s.setRenderWorldCopies(o.renderWorldCopies),null!==o.transformConstrain&&s.setConstrainOverride(o.transformConstrain),super(s,l,{bearingSnap:o.bearingSnap,zoomSnap:o.zoomSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new ns,this._controls=[],this._mapId=t.ad(),this._lostContextStyle={style:null,images:null},this._contextLost=e=>{if(e.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.painter.destroy(),this._lostContextStyle=this._getStyleAndImages(),this.style){for(const e of Object.values(this.style._layers))if(e._listeners)for(const[t]of Object.entries(e._listeners));this.style.destroy(),this.style=null,this.fire(new t.n("webglcontextlost",{originalEvent:e}))}else this.fire(new t.n("webglcontextlost",{originalEvent:e}))},this._contextRestored=e=>{this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&this.style&&(this.style.imageManager.images=this._lostContextStyle.images),this._lostContextStyle={style:null,images:null},this._setupPainter(),this.resize(),this._update(),this._resizeInternal(),this.fire(new t.n("webglcontextrestored",{originalEvent:e}))},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=o.interactive,this._maxTileCacheSize=o.maxTileCacheSize,this._maxTileCacheZoomLevels=o.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},o.canvasContextAttributes),this._trackResize=!0===o.trackResize,this._bearingSnap=o.bearingSnap,this._zoomSnap=o.zoomSnap,this._centerClampedToGround=o.centerClampedToGround,this._refreshExpiredTiles=!0===o.refreshExpiredTiles,this._fadeDuration=o.fadeDuration,this._crossSourceCollisions=!0===o.crossSourceCollisions,this._collectResourceTiming=!0===o.collectResourceTiming,this._locale=Object.assign(Object.assign({},us),o.locale),this._clickTolerance=o.clickTolerance,this._overridePixelRatio=o.pixelRatio,this._maxCanvasSize=o.maxCanvasSize,this._zoomLevelsToOverscale=o.experimentalZoomLevelsToOverscale,this.transformCameraUpdate=o.transformCameraUpdate,this.transformConstrain=o.transformConstrain,this.cancelPendingTileRequestsWhileZooming=!0===o.cancelPendingTileRequestsWhileZooming,this.setAnisotropicFilterPitch(o.anisotropicFilterPitch),void 0!==o.reduceMotion&&(a.prefersReducedMotion=o.reduceMotion),this._imageQueueHandle=h.addThrottleControl(()=>this.isMoving()),this._requestManager=new p(o.transformRequest),this._container=this._resolveContainer(o.container),o.maxBounds&&this.setMaxBounds(o.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this.on("terrain",()=>{this.painter.terrainFacilitator.depthDirty=!0,this._update(!0)}),this.once("idle",()=>this._idleTriggered=!0),"undefined"!=typeof window&&(this._ownerWindow.addEventListener("online",this._onWindowOnline,!1),this._setupResizeObserver()),this.handlers=new Ko(this,o),this._hash=o.hash?new Jr("string"==typeof o.hash&&o.hash||void 0).addTo(this):void 0,(null===(i=this._hash)||void 0===i?void 0:i._onHashChange())||(this.jumpTo({center:o.center,elevation:o.elevation,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch,roll:o.roll}),o.bounds&&(this.resize(),this.fitBounds(o.bounds,t.e({},o.fitBoundsOptions,{duration:0}))));const c="string"==typeof o.style||!("globe"===(null===(r=null===(n=o.style)||void 0===n?void 0:n.projection)||void 0===r?void 0:r.type));this.resize(null,c),this._localIdeographFontFamily=o.localIdeographFontFamily,this._validateStyle=o.validateStyle,o.style&&this.setStyle(o.style,{localIdeographFontFamily:o.localIdeographFontFamily}),o.attributionControl&&this.addControl(new ts("boolean"==typeof o.attributionControl?void 0:o.attributionControl)),o._mlLogo&&this.addControl(new is,o.logoPosition),this.on("style.load",()=>{if(c||this._resizeTransform(),this.transform.unmodified){const e=t.V(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e)}}),this.on("data",e=>{this._update("style"===e.dataType),this.fire(new t.n(`${e.dataType}data`,e))}),this.on("dataloading",e=>{this.fire(new t.n(`${e.dataType}dataloading`,e))}),this.on("dataabort",e=>{this.fire(new t.n("sourcedataabort",e))})}_getMapId(){return this._mapId}setGlobalStateProperty(e,t){return this.style.setGlobalStateProperty(e,t),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,i){if(void 0===i&&(i=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!(null==e?void 0:e.onAdd))return this.fire(new t.l(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=e.onAdd(this);this._controls.push(e);const r=this._controlPositions[i];return i.includes("bottom")?r.insertBefore(n,r.firstChild):r.appendChild(n),this}removeControl(e){if(!(null==e?void 0:e.onRemove))return this.fire(new t.l(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(e);return i>-1&&this._controls.splice(i,1),e.onRemove(this),this}hasControl(e){return this._controls.includes(e)}coveringTiles(e){return Ie(this.transform,e)}calculateCameraOptionsFromTo(e,t,i,n){return null==n&&this.terrain&&(n=this.terrain.getElevationForLngLat(i,this.transform)),super.calculateCameraOptionsFromTo(e,t,i,n)}resize(e,i=!0){if(null!==this._lostContextStyle.style)return this;this._resizeInternal(i);const n=!this._moving;return n&&(this.stop(),this.fire(new t.n("movestart",e)).fire(new t.n("move",e))),this.fire(new t.n("resize",e)),n&&this.fire(new t.n("moveend",e)),this}_resizeInternal(e=!0){const[t,i]=this._containerDimensions(),n=this._getClampedPixelRatio(t,i);if(this._resizeCanvas(t,i,n),this.painter.resize(t,i,n),this.painter.overLimit()){const e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];const n=this._getClampedPixelRatio(t,i);this._resizeCanvas(t,i,n),this.painter.resize(t,i,n)}this._resizeTransform(e)}_resizeTransform(e=!0){var t;const[i,n]=this._containerDimensions();this.transform.resize(i,n,e),null===(t=this._requestedCameraState)||void 0===t||t.resize(i,n,e)}_getClampedPixelRatio(e,t){const{0:i,1:n}=this._maxCanvasSize,r=this.getPixelRatio(),o=e*r,s=t*r;return Math.min(o>i?i/o:1,s>n?n/s:1)*r}getPixelRatio(){var e;return null!==(e=this._overridePixelRatio)&&void 0!==e?e:devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds(U.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom){const i=this.transform.zoom,n=this._getTransformForUpdate();return n.setMinZoom(e),this._applyUpdatedTransform(n),this._update(),i!==this.transform.zoom&&this.fire(new t.n("zoomstart")).fire(new t.n("zoom")).fire(new t.n("zoomend")).fire(new t.n("movestart")).fire(new t.n("move")).fire(new t.n("moveend")),this}throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(e){if((e=null==e?22:e)>=this.transform.minZoom){const i=this.transform.zoom,n=this._getTransformForUpdate();return n.setMaxZoom(e),this._applyUpdatedTransform(n),this._update(),i!==this.transform.zoom&&this.fire(new t.n("zoomstart")).fire(new t.n("zoom")).fire(new t.n("zoomend")).fire(new t.n("movestart")).fire(new t.n("move")).fire(new t.n("moveend")),this}throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch){const i=this.transform.pitch,n=this._getTransformForUpdate();return n.setMinPitch(e),this._applyUpdatedTransform(n),this._update(),i!==this.transform.pitch&&this.fire(new t.n("pitchstart")).fire(new t.n("pitch")).fire(new t.n("pitchend")).fire(new t.n("movestart")).fire(new t.n("move")).fire(new t.n("moveend")),this}throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(e){if((e=null==e?60:e)>180)throw new Error("maxPitch must be less than or equal to 180");if(e>=this.transform.minPitch){const i=this.transform.pitch,n=this._getTransformForUpdate();return n.setMaxPitch(e),this._applyUpdatedTransform(n),this._update(),i!==this.transform.pitch&&this.fire(new t.n("pitchstart")).fire(new t.n("pitch")).fire(new t.n("pitchend")).fire(new t.n("movestart")).fire(new t.n("move")).fire(new t.n("moveend")),this}throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getAnisotropicFilterPitch(){return this._anisotropicFilterPitch}setAnisotropicFilterPitch(e){if((e=null==e?20:e)>180)throw new Error("anisotropicFilterPitch must be less than or equal to 180");if(e<0)throw new Error("anisotropicFilterPitch must be greater than or equal to 0");return this._anisotropicFilterPitch=e,this._update()}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}setTransformConstrain(e){return this.transform.setConstrainOverride(e),this._update()}project(e){return this.transform.locationToScreenPoint(t.W.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this.terrain)}isMoving(){var e;return this._moving||(null===(e=this.handlers)||void 0===e?void 0:e.isMoving())}isZooming(){var e;return this._zooming||(null===(e=this.handlers)||void 0===e?void 0:e.isZooming())}isRotating(){var e;return this._rotating||(null===(e=this.handlers)||void 0===e?void 0:e.isRotating())}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let n=!1;const r=r=>{const o=t.filter(e=>this.getLayer(e)),s=0!==o.length?this.queryRenderedFeatures(r.point,{layers:o}):[];s.length?n||(n=!0,i.call(this,new ao(e,this,r.originalEvent,{features:s}))):n=!1};return{layers:t,listener:i,delegates:{mousemove:r,mouseout:()=>{n=!1}}}}if("mouseleave"===e||"mouseout"===e){let n=!1;const r=r=>{const o=t.filter(e=>this.getLayer(e));(0!==o.length?this.queryRenderedFeatures(r.point,{layers:o}):[]).length?n=!0:n&&(n=!1,i.call(this,new ao(e,this,r.originalEvent)))},o=t=>{n&&(n=!1,i.call(this,new ao(e,this,t.originalEvent)))};return{layers:t,listener:i,delegates:{mousemove:r,mouseout:o}}}{const n=e=>{const n=t.filter(e=>this.getLayer(e)),r=0!==n.length?this.queryRenderedFeatures(e.point,{layers:n}):[];r.length&&(e.features=r,i.call(this,e),delete e.features)};return{layers:t,listener:i,delegates:{[e]:n}}}}_saveDelegatedListener(e,t){var i;this._delegatedListeners||(this._delegatedListeners={}),(i=this._delegatedListeners)[e]||(i[e]=[]),this._delegatedListeners[e].push(t)}_removeDelegatedListener(e,t,i){var n;if(!(null===(n=this._delegatedListeners)||void 0===n?void 0:n[e]))return;const r=this._delegatedListeners[e];for(let e=0;e<r.length;e++){const n=r[e];if(n.listener===i&&n.layers.length===t.length&&n.layers.every(e=>t.includes(e))){for(const e in n.delegates)this.off(e,n.delegates[e]);return void r.splice(e,1)}}}on(e,t,i){if(void 0===i)return super.on(e,t);const n="string"==typeof t?[t]:t,r=this._createDelegatedListener(e,n,i);this._saveDelegatedListener(e,r);for(const e in r.delegates)this.on(e,r.delegates[e]);return{unsubscribe:()=>{this._removeDelegatedListener(e,n,i)}}}once(e,t,i){if(void 0===i)return super.once(e,t);const n="string"==typeof t?[t]:t,r=this._createDelegatedListener(e,n,i);for(const t in r.delegates){const o=r.delegates[t];r.delegates[t]=(...t)=>{this._removeDelegatedListener(e,n,i),o(...t)}}this._saveDelegatedListener(e,r);for(const e in r.delegates)this.once(e,r.delegates[e]);return this}off(e,t,i){return void 0===i?super.off(e,t):(this._removeDelegatedListener(e,"string"==typeof t?[t]:t,i),this)}queryRenderedFeatures(e,i){if(!this.style)return[];let n;const r=e instanceof t.P||Array.isArray(e),o=r?e:[[0,0],[this.transform.width,this.transform.height]];if(i||(i=(r?{}:e)||{}),o instanceof t.P||"number"==typeof o[0])n=[t.P.convert(o)];else{const e=t.P.convert(o[0]),i=t.P.convert(o[1]);n=[e,new t.P(i.x,e.y),i,new t.P(e.x,i.y),e]}return this.style.queryRenderedFeatures(n,i,this.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,i){return!1!==(i=t.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(e,i))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){var i,n,r;if(null===(i=this._diffStyleRequest)||void 0===i||i.abort(),this._diffStyleRequest=null,t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(e,t));const o=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new Fi(this,t||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,t,o):this.style.loadJSON(e,t,o),this):(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),null===(r=null===(n=this.style)||void 0===n?void 0:n.projection)||void 0===r||r.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Fi(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,i){return t._(this,void 0,void 0,function*(){var n;if(null===(n=this._diffStyleRequest)||void 0===n||n.abort(),"string"==typeof e){const n=e;this._diffStyleRequest=new AbortController;const r=this._diffStyleRequest;try{const e=yield this._requestManager.transformRequest(n,"Style");if(r.signal.aborted)return void(this._diffStyleRequest=null);const o=yield t.k(e,r);this._diffStyleRequest=null,this._updateDiff(o.data,i)}catch(e){this._diffStyleRequest=null,t.$(e)||this.fire(new t.l(t.d(e)))}}else"object"==typeof e&&(this._diffStyleRequest=null,this._updateDiff(e,i))})}_updateDiff(e,i){try{this.style.setState(e,i)&&this._update(!0)}catch(n){t.w(`Unable to perform style diff: ${t.d(n).message}. Rebuilding the style from scratch.`),this._updateStyle(e,i)}}getStyle(){if(this.style)return this.style.serialize()}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){if(this.style)return this.style.loaded();t.w("There is no style added to the map.")}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){var i;const n=null===(i=this.style)||void 0===i?void 0:i.tileManagers[e];if(void 0!==n)return n.loaded();this.fire(new t.l(new Error(`There is no tile manager with ID '${e}'`)))}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){const i=this.style.tileManagers[e.source];if(!i)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&i.reload();for(const i in this.style._layers){const n=this.style._layers[i];"hillshade"===n.type&&n.source===e.source&&t.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),"color-relief"===n.type&&n.source===e.source&&t.w("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=new ss(this.painter,i,e),this.painter.renderToTexture=new cs(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=t=>{var i;"style"===t.dataType?this.terrain.tileManager.freeRtt():"source"===t.dataType&&t.tile&&(t.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),"image"===(null===(i=t.source)||void 0===i?void 0:i.type)?this.terrain.tileManager.freeRtt():this.terrain.tileManager.freeRtt(t.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.destroy(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new t.n("terrain",{terrain:e})),this}getTerrain(){var e,t;return null!==(t=null===(e=this.terrain)||void 0===e?void 0:e.options)&&void 0!==t?t:null}areTilesLoaded(){var e;const t=null===(e=this.style)||void 0===e?void 0:e.tileManagers;for(const e of Object.values(t))if(!e.areTilesLoaded())return!1;return!0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}setSourceTileLodParams(e,t,i){if(i){const n=this.getSource(i);if(!n)throw new Error(`There is no source with ID "${i}", cannot set LOD parameters`);n.calculateTileZoom=Ee(Math.max(1,e),Math.max(1,t))}else for(const i in this.style.tileManagers)this.style.tileManagers[i].getSource().calculateTileZoom=Ee(Math.max(1,e),Math.max(1,t));return this._update(!0),this}refreshTiles(e,i){const n=this.style.tileManagers[e];if(!n)throw new Error(`There is no tile manager with ID "${e}", cannot refresh tile`);void 0===i?n.reload(!0):n.refreshTiles(i.map(e=>new t.aa(e.z,e.x,e.y)))}addImage(e,i,n={}){const{pixelRatio:r=1,sdf:o=!1,stretchX:s,stretchY:l,content:c,textFitWidth:u,textFitHeight:h}=n;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||t.b(i))){if(void 0===i.width||void 0===i.height)return this.fire(new t.l(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:n,height:a,data:d}=i,p=i;return this.style.addImage(e,{data:new t.R({width:n,height:a},new Uint8Array(d)),pixelRatio:r,stretchX:s,stretchY:l,content:c,textFitWidth:u,textFitHeight:h,sdf:o,version:0,userImage:p}),p.onAdd&&p.onAdd(this,e),this}}{const{width:n,height:d,data:p}=a.getImageData(i);this.style.addImage(e,{data:new t.R({width:n,height:d},p),pixelRatio:r,stretchX:s,stretchY:l,content:c,textFitWidth:u,textFitHeight:h,sdf:o,version:0})}}updateImage(e,i){const n=this.style.getImage(e);if(!n)return this.fire(new t.l(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const r=i instanceof HTMLImageElement||t.b(i)?a.getImageData(i):i,{width:o,height:s,data:l}=r;if(void 0===o||void 0===s)return this.fire(new t.l(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(o!==n.data.width||s!==n.data.height)return this.fire(new t.l(new Error("The width and height of the updated image must be that same as the previous version of the image")));const c=!(i instanceof HTMLImageElement||t.b(i));return n.data.replace(l,c),this.style.updateImage(e,n),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.l(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(e){return t._(this,void 0,void 0,function*(){return h.getImage(yield this._requestManager.transformRequest(e,"Image"),new AbortController)})}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(e,t,i){return this.style.setLayerZoomRange(e,t,i),this._update(!0)}setFilter(e,t,i={}){return this.style.setFilter(e,t,i),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,i,n={}){return this.style.setPaintProperty(e,t,i,n),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,n={}){return this.style.setLayoutProperty(e,t,i,n),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setGlyphs(e,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,t,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,i,e=>{e||this._update(!0)}),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,t,e=>{e||this._update(!0)}),this}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,t=0;return this._container&&(e=this._container.clientWidth||400,t=this._container.clientHeight||300),[e,t]}_setupResizeObserver(){var e;let t=!1;const i=Yr(e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())},50),n=null!==(e=this._ownerWindow.ResizeObserver)&&void 0!==e?e:ResizeObserver;this._resizeObserver=new n(e=>{t?i(e):t=!0}),this._resizeObserver.observe(this._container)}_resolveContainer(e){if("string"==typeof e){const t=document.getElementById(e);if(!t)throw new Error(`Container '${e}' not found.`);return t}if(e instanceof HTMLElement)return e;if(e&&"object"==typeof e&&1===e.nodeType)return e;throw new Error("Invalid type: 'container' must be a String or HTMLElement.")}_setupContainer(){const e=this._container;e.classList.add("_mlgl-map");const t=this._canvasContainer=d.create("div","_mlgl-canvas-container",e);this._interactive&&t.classList.add("_mlgl-interactive"),this._canvas=d.create("canvas","_mlgl-canvas",t),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");const i=this._containerDimensions(),n=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],n);const r=this._controlContainer=d.create("div","_mlgl-control-container",e),o=this._controlPositions={};for(const e of["top-left","top-right","bottom-left","bottom-right"])o[e]=d.create("div",`_mlgl-ctrl-${e} `,r);this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,t,i){this._canvas.width=Math.floor(i*e),this._canvas.height=Math.floor(i*t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`}_setupPainter(){const e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let t=null;this._canvas.addEventListener("webglcontextcreationerror",i=>{t={requestedAttributes:e},i&&(t.statusMessage=i.statusMessage,t.type=i.type)},{once:!0});let i=null;if(i=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext("webgl2",e)||this._canvas.getContext("webgl",e),!i){const e="Failed to initialize WebGL";throw t?(t.message=e,new Error(JSON.stringify(t))):new Error(e)}this.painter=new Xr(i,this.transform)}migrateProjection(e,i){super.migrateProjection(e,i),this.painter.transform=e,this.fire(new t.n("projectiontransition",{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){var t;return(null===(t=this.style)||void 0===t?void 0:t._loaded)?(this._styleDirty||(this._styleDirty=e),this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_render(e){var i,n,r,o,s,a;const l=this._idleTriggered?this._fadeDuration:0,u=(null===(i=this.style.projection)||void 0===i?void 0:i.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let h=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,i=c();this.style.zoomHistory.update(e,i);const n=new t.J(e,{now:i,fadeDuration:l,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),r=n.crossFadingFactor();1===r&&r===this._crossFadingFactor||(h=!0,this._crossFadingFactor=r),this.style.update(n)}const d=(null===(n=this.style.projection)||void 0===n?void 0:n.transitionState)>0!==u;null===(r=this.style.projection)||void 0===r||r.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(o=this.style.projection)||void 0===o?void 0:o.transitionState,null===(s=this.style.projection)||void 0===s?void 0:s.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||d)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.tileManager.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=null===(a=this.style)||void 0===a?void 0:a._updatePlacement(this.transform,this.showCollisionBoxes,l,this._crossSourceCollisions,d),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:l,showPadding:this.showPadding,anisotropicFilterPitch:this.getAnisotropicFilterPitch()}),this.fire(new t.n("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new t.n("load"))),this.style&&(this.style.hasTransitions()||h)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const p=this._sourcesDirty||this._styleDirty||this._placementDirty;return p||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new t.n("idle")),!this._loaded||this._fullyLoaded||p||(this._fullyLoaded=!0),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var e,i;this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),null===(e=this._diffStyleRequest)||void 0===e||e.abort(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&this._ownerWindow.removeEventListener("online",this._onWindowOnline,!1),h.removeThrottleControl(this._imageQueueHandle),null===(i=this._resizeObserver)||void 0===i||i.disconnect();const n=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==n?void 0:n.loseContext)&&n.loseContext(),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("_mlgl-map"),this._removed=!0,this.fire(new t.n("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,a.frame(this._frameRequest,e=>{this._frameRequest=null;try{this._render(e)}catch(e){if(!t.$(e)&&!function(e){return e.message===ar}(e))throw e}},()=>{},this._ownerWindow))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get version(){return hs}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}};const fs={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};class ms{constructor(e,i,n=!1){this.mousedown=e=>{this.startMove(e,d.mousePos(this.element,e)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)},this.mousemove=e=>{this.move(e,d.mousePos(this.element,e))},this.mouseup=e=>{this._rotatePitchHandler.dragEnd(e),this.offTemp()},this.touchstart=e=>{1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=d.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),window.addEventListener("touchmove",this.touchmove,{passive:!1}),window.addEventListener("touchend",this.touchend))},this.touchmove=e=>{1!==e.targetTouches.length?this.reset():(this._lastPos=d.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos))},this.touchend=e=>{0===e.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;const r=new So;this._rotatePitchHandler=new vo({clickTolerance:3,move:(e,r)=>{const o=i.getBoundingClientRect(),s=new t.P((o.bottom-o.top)/2,(o.right-o.left)/2);return{bearingDelta:t.cx(new t.P(e.x,r.y),r,s),pitchDelta:n?-.5*(r.y-e.y):void 0}},moveStateManager:r,enable:!0,assignEvents:()=>{}}),this.map=e,i.addEventListener("mousedown",this.mousedown),i.addEventListener("touchstart",this.touchstart,{passive:!1}),i.addEventListener("touchcancel",this.reset)}startMove(e,t){this._rotatePitchHandler.dragStart(e,t),d.disableDrag()}move(e,t){const i=this.map,{bearingDelta:n,pitchDelta:r}=this._rotatePitchHandler.dragMove(e,t)||{};n&&i.setBearing(i.getBearing()+n),r&&i.setPitch(i.getPitch()+r)}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){d.enableDrag(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend)}}let gs;function ys(e,i,n,r=!1){if(r||!n.getCoveringTilesDetailsProvider().allowWorldCopies())return null==e?void 0:e.wrap();const o=new t.W(e.lng,e.lat);if(e=new t.W(e.lng,e.lat),i){const r=new t.W(e.lng-360,e.lat),o=new t.W(e.lng+360,e.lat),s=n.locationToScreenPoint(e).distSqr(i);n.locationToScreenPoint(r).distSqr(i)<s?e=r:n.locationToScreenPoint(o).distSqr(i)<s&&(e=o)}for(;Math.abs(e.lng-n.center.lng)>180;){const t=n.locationToScreenPoint(e);if(t.x>=0&&t.y>=0&&t.x<=n.width&&t.y<=n.height)break;e.lng>n.center.lng?e.lng-=360:e.lng+=360}return e.lng!==o.lng&&n.isPointOnMapSurface(n.locationToScreenPoint(e))?e:o}const _s={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function vs(e,t,i){const n=e.classList;for(const e in _s)n.remove(`_mlgl-${i}-anchor-${e}`);n.add(`_mlgl-${i}-anchor-${t}`)}class xs extends t.E{constructor(e){if(super(),this._onClick=e=>{this.fire(new t.n("click",{originalEvent:e}))},this._onKeyPress=e=>{"Space"!==e.code&&"Enter"!==e.code||this.togglePopup()},this._onMapClick=e=>{const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup()},this._update=e=>{if(!this._map)return;const t=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!t)&&this._map.once("render",this._update),this._lngLat=ys(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let i="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?i=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(i=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let n="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?n="rotateX(0deg)":"map"===this._pitchAlignment&&(n=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&"moveend"!==e.type||(this._pos=this._pos.round()),this._element.style.transform=`${_s[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${n} ${i}`,a.frameAsync(new AbortController,this._map._ownerWindow).then(()=>{this._updateOpacity("moveend"===(null==e?void 0:e.type))}).catch(()=>{})},this._onMove=e=>{if(!this._isDragging){const t=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t}this._isDragging&&(this._pos=e.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 t.n("dragstart"))),this.fire(new t.n("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 t.n("dragend")),this._state="inactive"},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.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=(null==e?void 0:e.anchor)||"center",this._color=(null==e?void 0:e.color)||"#3FB1CE",this._scale=(null==e?void 0:e.scale)||1,this._draggable=(null==e?void 0:e.draggable)||!1,this._clickTolerance=(null==e?void 0:e.clickTolerance)||0,this._subpixelPositioning=(null==e?void 0:e.subpixelPositioning)||!1,this._isDragging=!1,this._state="inactive",this._rotation=(null==e?void 0:e.rotation)||0,this._rotationAlignment=(null==e?void 0:e.rotationAlignment)||"auto",this._pitchAlignment=(null==e?void 0:e.pitchAlignment)&&"auto"!==e.pitchAlignment?e.pitchAlignment:this._rotationAlignment,this.setOpacity(null==e?void 0:e.opacity,null==e?void 0:e.opacityWhenCovered),null==e?void 0:e.element)this._element=e.element,this._offset=t.P.convert((null==e?void 0:e.offset)||[0,0]);else{this._defaultMarker=!0,this._element=d.create("div");const i=d.createNS("http://www.w3.org/2000/svg","svg"),n=41,r=27;i.setAttributeNS(null,"display","block"),i.setAttributeNS(null,"height",`${n}px`),i.setAttributeNS(null,"width",`${r}px`),i.setAttributeNS(null,"viewBox",`0 0 ${r} ${n}`);const o=d.createNS("http://www.w3.org/2000/svg","g");o.setAttributeNS(null,"stroke","none"),o.setAttributeNS(null,"stroke-width","1"),o.setAttributeNS(null,"fill","none"),o.setAttributeNS(null,"fill-rule","evenodd");const s=d.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"fill-rule","nonzero");const a=d.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"transform","translate(3.0, 29.0)"),a.setAttributeNS(null,"fill","#000000");const l=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const e of l){const t=d.createNS("http://www.w3.org/2000/svg","ellipse");t.setAttributeNS(null,"opacity","0.04"),t.setAttributeNS(null,"cx","10.5"),t.setAttributeNS(null,"cy","5.80029008"),t.setAttributeNS(null,"rx",e.rx),t.setAttributeNS(null,"ry",e.ry),a.appendChild(t)}const c=d.createNS("http://www.w3.org/2000/svg","g");c.setAttributeNS(null,"fill",this._color);const u=d.createNS("http://www.w3.org/2000/svg","path");u.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),c.appendChild(u);const h=d.createNS("http://www.w3.org/2000/svg","g");h.setAttributeNS(null,"opacity","0.25"),h.setAttributeNS(null,"fill","#000000");const p=d.createNS("http://www.w3.org/2000/svg","path");p.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),h.appendChild(p);const f=d.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"transform","translate(6.0, 7.0)"),f.setAttributeNS(null,"fill","#FFFFFF");const m=d.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const g=d.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#000000"),g.setAttributeNS(null,"opacity","0.25"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962");const y=d.createNS("http://www.w3.org/2000/svg","circle");y.setAttributeNS(null,"fill","#FFFFFF"),y.setAttributeNS(null,"cx","5.5"),y.setAttributeNS(null,"cy","5.5"),y.setAttributeNS(null,"r","5.4999962"),m.appendChild(g),m.appendChild(y),s.appendChild(a),s.appendChild(c),s.appendChild(h),s.appendChild(f),s.appendChild(m),i.appendChild(s),i.setAttributeNS(null,"height",n*this._scale+"px"),i.setAttributeNS(null,"width",r*this._scale+"px"),this._element.appendChild(i),this._offset=t.P.convert((null==e?void 0:e.offset)||[0,-14])}if(this._element.classList.add("_mlgl-marker"),this._element.addEventListener("dragstart",e=>{e.preventDefault()}),this._element.addEventListener("mousedown",e=>{e.preventDefault()}),vs(this._element,this._anchor,"marker"),null==e?void 0:e.className)for(const t of e.className.split(" "))this._element.classList.add(t);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),this._element.hasAttribute("role")||this._element.setAttribute("role","button"),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.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._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("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.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.W.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const t=38.1,i=13.5,n=Math.abs(i)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[n,-1*(t-i+n)],"bottom-right":[-n,-1*(t-i+n)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var i,n;const r=null===(i=this._map)||void 0===i?void 0:i.terrain,o=this._map.transform.isLocationOccluded(this._lngLat);if(!r||o){const e=o?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==e&&(this._element.style.opacity=e,this._element.classList.toggle("_mlgl-marker-covered",o)))}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const s=this._map,a=s.terrain.depthAtPoint(this._pos),l=s.terrain.getElevationForLngLat(this._lngLat,s.transform);if(s.transform.lngLatToCameraDepth(this._lngLat,l)-a<.006)return this._element.style.opacity=this._opacity,void this._element.classList.remove("_mlgl-marker-covered");const c=-this._offset.y/s.transform.pixelsPerMeter,u=Math.sin(s.getPitch()*Math.PI/180)*c,h=s.terrain.depthAtPoint(new t.P(this._pos.x,this._pos.y-this._offset.y)),d=s.transform.lngLatToCameraDepth(this._lngLat,l+u)-h>.006;(null===(n=this._popup)||void 0===n?void 0:n.isOpen())&&d&&this._popup.remove(),this._element.style.opacity=d?this._opacityWhenCovered:this._opacity,this._element.classList.toggle("_mlgl-marker-covered",d)}getOffset(){return this._offset}setOffset(e){return this._offset=t.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&"auto"!==e?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return(void 0===this._opacity||void 0===e&&void 0===t)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=String(e)),void 0!==t&&(this._opacityWhenCovered=String(t)),this._map&&this._updateOpacity(!0),this}}const bs={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let ws=0,Es=!1;const Ts={maxWidth:100,unit:"metric"};function Ss(e,t,i){const n=(null==i?void 0:i.maxWidth)||100,r=e._container.clientHeight/2,o=e._container.clientWidth/2,s=e.unproject([o-n/2,r]),a=e.unproject([o+n/2,r]),l=Math.round(e.project(a).x-e.project(s).x),c=Math.min(n,l,e._container.clientWidth),u=s.distanceTo(a);if("imperial"===(null==i?void 0:i.unit)){const i=3.2808*u;i>5280?Is(t,c,i/5280,e._getUIString("ScaleControl.Miles")):Is(t,c,i,e._getUIString("ScaleControl.Feet"))}else"nautical"===(null==i?void 0:i.unit)?Is(t,c,u/1852,e._getUIString("ScaleControl.NauticalMiles")):u>=1e3?Is(t,c,u/1e3,e._getUIString("ScaleControl.Kilometers")):Is(t,c,u,e._getUIString("ScaleControl.Meters"))}function Is(e,t,i,n){const r=function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}(i);e.style.width=t*(r/i)+"px",e.innerHTML=`${r}&nbsp;${n}`}const ks={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},Ms=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Cs(e){if(e){if("number"==typeof e){const i=Math.round(Math.abs(e)/Math.SQRT2);return{center:new t.P(0,0),top:new t.P(0,e),"top-left":new t.P(i,i),"top-right":new t.P(-i,i),bottom:new t.P(0,-e),"bottom-left":new t.P(i,-i),"bottom-right":new t.P(-i,-i),left:new t.P(e,0),right:new t.P(-e,0)}}if(e instanceof t.P||Array.isArray(e)){const i=t.P.convert(e);return{center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return{center:t.P.convert(e.center||[0,0]),top:t.P.convert(e.top||[0,0]),"top-left":t.P.convert(e["top-left"]||[0,0]),"top-right":t.P.convert(e["top-right"]||[0,0]),bottom:t.P.convert(e.bottom||[0,0]),"bottom-left":t.P.convert(e["bottom-left"]||[0,0]),"bottom-right":t.P.convert(e["bottom-right"]||[0,0]),left:t.P.convert(e.left||[0,0]),right:t.P.convert(e.right||[0,0])}}return Cs(new t.P(0,0))}const Ps=i;e.AJAXError=t.cG,e.EXTENT=t.a6,e.Event=t.n,e.Evented=t.E,e.LngLat=t.W,e.MercatorCoordinate=t.a7,e.Point=t.P,e.addProtocol=t.cH,e.config=t.c,e.removeProtocol=t.cI,e.AttributionControl=ts,e.BoxZoomHandler=fo,e.CanvasSource=ne,e.CooperativeGesturesHandler=Wo,e.DoubleClickZoomHandler=Vo,e.DragPanHandler=Zo,e.DragRotateHandler=$o,e.EdgeInsets=Vt,e.FullscreenControl=class extends t.E{constructor(e={}){var i;super(),this._onFullscreenChange=()=>{var e;let t=window.document.fullscreenElement||window.document.webkitFullscreenElement;for(;null===(e=null==t?void 0:t.shadowRoot)||void 0===e?void 0:e.fullscreenElement;)t=t.shadowRoot.fullscreenElement;t===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,this._pseudo=null!==(i=e.pseudo)&&void 0!==i&&i,(null==e?void 0:e.container)&&(e.container instanceof HTMLElement?this._container=e.container:t.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=d.create("div","_mlgl-ctrl _mlgl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const e=this._fullscreenButton=d.create("button","_mlgl-ctrl-fullscreen",this._controlContainer);d.create("span","_mlgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.title=e}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("_mlgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("_mlgl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new t.n("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new t.n("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){this._pseudo?this._togglePseudoFullScreen():window.document.exitFullscreen?window.document.exitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._pseudo?this._togglePseudoFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("_mlgl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},e.GeoJSONSource=ee,e.GeolocateControl=class extends t.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.n("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("_mlgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("_mlgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("_mlgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("_mlgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("_mlgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("_mlgl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("_mlgl-user-location-dot-stale"),this.fire(new t.n("geolocate",e)),this._finish()}},this._updateCamera=e=>{const i=new t.W(e.coords.longitude,e.coords.latitude),n=e.coords.accuracy,r=this._map.getBearing(),o=t.e({bearing:r},this.options.fitBoundsOptions),s=U.fromLngLat(i,n);this._map.fitBounds(s,o,{geolocateSource:!0})},this._updateMarker=e=>{if(e){const i=new t.W(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=e.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=e=>{if(this._map){if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("_mlgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("_mlgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("_mlgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("_mlgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("_mlgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&Es)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("_mlgl-user-location-dot-stale"),this.fire(new t.n("error",e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._onMoveStart=e=>{if(!this._map)return;const i=(null==e?void 0:e[0])instanceof ResizeObserverEntry;e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||i||this._map.isZooming()||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("_mlgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("_mlgl-ctrl-geolocate-active"),this.fire(new t.n("trackuserlocationend")),this.fire(new t.n("userlocationlostfocus")))},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",e=>{e.preventDefault()}),this._geolocateButton=d.create("button","_mlgl-ctrl-geolocate",this._container),d.create("span","_mlgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(!1===e){t.w("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=d.create("div","_mlgl-user-location-dot"),this._userLocationDotMarker=new xs({element:this._dotElement}),this._circleElement=d.create("div","_mlgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new xs({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onUpdate),this._map.on("move",this._onUpdate),this._map.on("rotate",this._onUpdate),this._map.on("pitch",this._onUpdate)),this._geolocateButton.addEventListener("click",()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",this._onMoveStart)}},this.options=t.e({},bs,e)}onAdd(e){return this._map=e,this._container=d.create("div","_mlgl-ctrl _mlgl-ctrl-group"),this._setupUI(),function(){return t._(this,arguments,void 0,function*(e=!1){if(void 0!==gs&&!e)return gs;if(void 0===window.navigator.permissions)return gs=!!window.navigator.geolocation,gs;try{const e=yield window.navigator.permissions.query({name:"geolocation"});gs="denied"!==e.state}catch(e){gs=!!window.navigator.geolocation}return gs})}().then(e=>this._finishSetupUI(e)),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("movestart",this._onMoveStart),this._map.off("zoom",this._onUpdate),this._map.off("move",this._onUpdate),this._map.off("rotate",this._onUpdate),this._map.off("pitch",this._onUpdate),this._map=void 0,ws=0,Es=!1}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return t&&(i.longitude<t.getWest()||i.longitude>t.getEast()||i.latitude<t.getSouth()||i.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("_mlgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("_mlgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("_mlgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("_mlgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("_mlgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("_mlgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("_mlgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("_mlgl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":case"BACKGROUND_ERROR":case"OFF":case void 0:break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){const e=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&e))return;const t=this._map.project(e),i=this._map.unproject([t.x+100,t.y]),n=e.distanceTo(i)/100,r=2*this._accuracy/n;this._circleElement.style.width=`${r.toFixed(2)}px`,this._circleElement.style.height=`${r.toFixed(2)}px`}trigger(){if(!this._setup)return t.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new t.n("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":ws--,Es=!1,this._watchState="OFF",this._geolocateButton.classList.remove("_mlgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("_mlgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("_mlgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("_mlgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("_mlgl-ctrl-geolocate-background-error"),this.fire(new t.n("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("_mlgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.n("trackuserlocationstart")),this.fire(new t.n("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("_mlgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("_mlgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("_mlgl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("_mlgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),ws++,ws>1?(e={maximumAge:6e5,timeout:0},Es=!0):(e=this.options.positionOptions,Es=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("_mlgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},e.GlobeControl=class{constructor(){this._toggleProjection=()=>{var e;const t=null===(e=this._map.getProjection())||void 0===e?void 0:e.type;this._map.setProjection("mercator"!==t&&t?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var e;this._globeButton.classList.remove("_mlgl-ctrl-globe"),this._globeButton.classList.remove("_mlgl-ctrl-globe-enabled"),"globe"===(null===(e=this._map.getProjection())||void 0===e?void 0:e.type)?(this._globeButton.classList.add("_mlgl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("_mlgl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(e){return this._map=e,this._container=d.create("div","_mlgl-ctrl _mlgl-ctrl-group"),this._globeButton=d.create("button","_mlgl-ctrl-globe",this._container),d.create("span","_mlgl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._map.on("projectiontransition",this._updateGlobeIcon),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateGlobeIcon),this._map.off("projectiontransition",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},e.Hash=Jr,e.ImageSource=te,e.KeyboardHandler=Oo,e.LngLatBounds=U,e.LogoControl=is,e.Map=ps,e.MapLibreMap=ps,e.MapMouseEvent=ao,e.MapTouchEvent=lo,e.MapWheelEvent=co,e.Marker=xs,e.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{const e=this._map.getZoom(),t=e===this._map.getMaxZoom(),i=e===this._map.getMinZoom();this._zoomInButton.disabled=t,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",t.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(e,t)=>{const i=this._map._getUIString(`NavigationControl.${t}`);e.title=i,e.setAttribute("aria-label",i)},this.options=t.e({},fs,e),this._container=d.create("div","_mlgl-ctrl _mlgl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("_mlgl-ctrl-zoom-in",e=>this._map.zoomIn({},{originalEvent:e})),d.create("span","_mlgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("_mlgl-ctrl-zoom-out",e=>this._map.zoomOut({},{originalEvent:e})),d.create("span","_mlgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("_mlgl-ctrl-compass",e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})}),this._compassIcon=d.create("span","_mlgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new ms(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off("zoom",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(e,t){const i=d.create("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}},e.Popup=class extends t.E{constructor(e){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:"")},this.remove=()=>(this._content&&this._content.remove(),this._container&&(this._container.remove(),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousemove",this._update),this._map.off("mouseup",this._update),this._map.off("drag",this._update),this._map._canvasContainer.classList.remove("_mlgl-track-pointer"),delete this._map,this.fire(new t.n("close"))),this),this._update=e=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=d.create("div","_mlgl-popup",this._map.getContainer()),this._tip=d.create("div","_mlgl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const e of this.options.className.split(" "))this._container.classList.add(e);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("_mlgl-popup-track-pointer")}let t;if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=ys(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),e&&"point"in e&&e.point&&(t=e.point),this._trackPointer&&!t)return;const i=this._flatPos=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&t?t:this._map.transform.locationToScreenPoint(this._lngLat));let n=this.options.anchor;const r=Cs(this.options.offset);if(!n){const e=this._container.offsetWidth,t=this._container.offsetHeight,o=function(e){var t,i,n,r;return e?{top:null!==(t=e.top)&&void 0!==t?t:0,right:null!==(i=e.right)&&void 0!==i?i:0,bottom:null!==(n=e.bottom)&&void 0!==n?n:0,left:null!==(r=e.left)&&void 0!==r?r:0}:{top:0,right:0,bottom:0,left:0}}(this.options.padding);let s;s=i.y+r.bottom.y<t+o.top?["top"]:i.y>this._map.transform.height-t-o.bottom?["bottom"]:[],i.x<e/2+o.left?s.push("left"):i.x>this._map.transform.width-e/2-o.right&&s.push("right"),n=0===s.length?"bottom":s.join("-")}let o=i.add(r[n]);this.options.subpixelPositioning||(o=o.round()),this._container.style.transform=`${_s[n]} translate(${o.x}px,${o.y}px)`,vs(this._container,n,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=t.e(Object.create(ks),e)}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._map.on("terrain",this._update),this._map.on("projectiontransition",this._update),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._update),this._map.on("mouseup",this._update),this._container&&this._container.classList.add("_mlgl-popup-track-pointer"),this._map._canvasContainer.classList.add("_mlgl-track-pointer")):this._map.on("move",this._update),this.fire(new t.n("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.W.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._update),this._container&&this._container.classList.remove("_mlgl-popup-track-pointer"),this._map._canvasContainer.classList.remove("_mlgl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._update),this._map.on("drag",this._update),this._container&&this._container.classList.add("_mlgl-popup-track-pointer"),this._map._canvasContainer.classList.add("_mlgl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),i=document.createElement("body");let n;for(i.innerHTML=e;n=i.firstChild,n;)t.appendChild(n);return this.setDOMContent(t)}getMaxWidth(){var e;return null===(e=this._container)||void 0===e?void 0:e.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=d.create("div","_mlgl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e}setPadding(e){this.options.padding=e,this._update()}_createCloseButton(){this.options.closeButton&&(this._closeButton=d.create("button","_mlgl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(Ms);e&&e.focus()}},e.RasterDEMTileSource=H,e.RasterTileSource=$,e.ScaleControl=class{constructor(e){this._onMove=()=>{Ss(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,Ss(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},Ts),e)}getDefaultPosition(){return"bottom-left"}onAdd(e){return this._map=e,this._container=d.create("div","_mlgl-ctrl _mlgl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._onMove),this._map=void 0}},e.ScrollZoomHandler=jo,e.Style=Fi,e.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("_mlgl-ctrl-terrain"),this._terrainButton.classList.remove("_mlgl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("_mlgl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("_mlgl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=e}onAdd(e){return this._map=e,this._container=d.create("div","_mlgl-ctrl _mlgl-ctrl-group"),this._terrainButton=d.create("button","_mlgl-ctrl-terrain",this._container),d.create("span","_mlgl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){this._container.remove(),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},e.TwoFingersTouchPitchHandler=zo,e.TwoFingersTouchRotateHandler=Do,e.TwoFingersTouchZoomHandler=Ao,e.TwoFingersTouchZoomRotateHandler=Ho,e.VectorTileSource=Z,e.VideoSource=ie,e.addSourceType=(e,i)=>t._(void 0,void 0,void 0,function*(){if(oe(e))throw new Error(`A source type called "${e}" already exists.`);((e,t)=>{re[e]=t})(e,i)}),e.clearPrewarmedResources=function(){const e=D;e&&e.isPreloaded()&&1===e.numActive()&&(e.release(P),D=null)},e.createTileMesh=ci,e.getGlobalDispatcher=O,e.getMaxParallelImageRequests=function(){return t.c.MAX_PARALLEL_IMAGE_REQUESTS},e.getRTLTextPluginStatus=function(){return ce().getRTLTextPluginStatus()},e.getVersion=function(){return Ps},e.getWorkerCount=function(){return A.workerCount},e.getWorkerUrl=function(){return t.c.WORKER_URL},e.importScriptInWorkers=function(e){return O().broadcast("IS",e)},e.isTimeFrozen=function(){return l.isFrozen()},e.now=c,e.prewarm=function(){z().acquire(P)},e.restoreNow=function(){l.restoreNow()},e.setMaxParallelImageRequests=function(e){t.c.MAX_PARALLEL_IMAGE_REQUESTS=e},e.setNow=function(e){l.setNow(e)},e.setRTLTextPlugin=function(e,t){return ce().setRTLTextPlugin(e,t)},e.setWorkerCount=function(e){A.workerCount=e},e.setWorkerUrl=function(e){t.c.WORKER_URL=e}}),e}()}(n);var r=n.exports,o=i(r),s=t({__proto__:null,default:o},[r]);const a={airport:"#e2e8f0",runway:"#94a3b8",apron:"#cbd5e1",taxiway:"#e2e8f0",taxiwayLine:"#f59e0b",holding:"#b91c1c",stand:"#1e293b",runwayMarking:"#ffffff",runwayCenterline:"#ffffff",standLine:"#64748b",threshold:"#c2410c",restricted:"#b91c1c",hotspot:"#ea580c"};const l={airport:"#334155",runway:"#475569",apron:"#1e293b",taxiway:"#334155",taxiwayLine:"#fbbf24",holding:"#ef4444",stand:"#34d399",runwayMarking:"#cbd5e1",runwayCenterline:"#94a3b8",standLine:"#64748b",threshold:"#f97316",restricted:"#f87171",hotspot:"#fb923c"};const c={airport:"#4b5563",runway:"#71717a",apron:"#27272a",taxiway:"#3f3f46",taxiwayLine:"#eab308",holding:"#ef4444",stand:"#10b981",runwayMarking:"#e4e4e7",runwayCenterline:"#d4d4d8",standLine:"#6b7280",threshold:"#f97316",restricted:"#f87171",hotspot:"#fb923c"};function u(e="amm",t="light"){return"dark"===t?function(e="amm"){return[{id:"amm-airport-fill",type:"fill",source:e,"source-layer":"amm-airport",minzoom:11,paint:{"fill-color":l.airport,"fill-opacity":.3}},{id:"amm-airport-stroke",type:"line",source:e,"source-layer":"amm-airport",minzoom:11,paint:{"line-color":"#475569","line-width":1}},{id:"amm-runway-fill",type:"fill",source:e,"source-layer":"amm-runway",minzoom:11,paint:{"fill-color":l.runway,"fill-opacity":1}},{id:"amm-runway-stroke",type:"line",source:e,"source-layer":"amm-runway",minzoom:11,paint:{"line-color":"#64748b","line-width":.5}},{id:"amm-apron-fill",type:"fill",source:e,"source-layer":"amm-apron",minzoom:11,paint:{"fill-color":l.apron,"fill-opacity":1}},{id:"amm-apron-stroke",type:"line",source:e,"source-layer":"amm-apron",minzoom:11,paint:{"line-color":"#334155","line-width":.5}},{id:"amm-taxiway-fill",type:"fill",source:e,"source-layer":"amm-taxiway",minzoom:11,paint:{"fill-color":l.taxiway,"fill-opacity":.8}},{id:"amm-taxiway-line",type:"line",source:e,"source-layer":"amm-taxiway-line",minzoom:11,paint:{"line-color":l.taxiwayLine,"line-width":["interpolate",["linear"],["zoom"],15,.8,18,2]}},{id:"amm-taxiway-label",type:"symbol",source:e,"source-layer":"amm-taxiway-line",minzoom:14,layout:{"text-field":["get","idlin"],"text-size":10,"icon-image":"text_bg","icon-text-fit":"both","icon-text-fit-padding":[1,2,1,2],"symbol-placement":"line","text-keep-upright":!0,"text-allow-overlap":!1},paint:{"text-color":"#0f172a","icon-color":l.taxiwayLine}},{id:"amm-holding",type:"line",source:e,"source-layer":"amm-holding",minzoom:11,paint:{"line-color":l.holding,"line-width":1.5}},{id:"amm-runway-marking",type:"fill",source:e,"source-layer":"amm-runway-marking",minzoom:13,paint:{"fill-color":l.runwayMarking,"fill-opacity":.8}},{id:"amm-restricted-fill",type:"fill",source:e,"source-layer":"amm-restricted",minzoom:11,paint:{"fill-color":l.restricted,"fill-opacity":.12}},{id:"amm-restricted-stroke",type:"line",source:e,"source-layer":"amm-restricted",minzoom:11,paint:{"line-color":l.restricted,"line-width":1.2,"line-dasharray":[4,2]}},{id:"amm-hotspot-fill",type:"fill",source:e,"source-layer":"amm-hotspot",minzoom:11,paint:{"fill-color":l.hotspot,"fill-opacity":.15}},{id:"amm-hotspot-stroke",type:"line",source:e,"source-layer":"amm-hotspot",minzoom:11,paint:{"line-color":l.hotspot,"line-width":1.2}},{id:"amm-runway-centerline",type:"line",source:e,"source-layer":"amm-runway-centerline",minzoom:11,paint:{"line-color":l.runwayCenterline,"line-width":1,"line-dasharray":[6,3]}},{id:"amm-runway-info",type:"symbol",source:e,"source-layer":"amm-runway-label",minzoom:13,layout:{"text-field":["concat",["coalesce",["get","length"],""],"×",["coalesce",["get","width"],""],"m"],"text-size":["interpolate",["exponential",1.5],["zoom"],13,10,16,13],"symbol-placement":"point","text-rotate":["coalesce",["get","bearing"],0],"text-rotation-alignment":"map","text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":"#e2e8f0","text-halo-color":"#0f172a","text-halo-width":2}},{id:"amm-stand-line",type:"line",source:e,"source-layer":"amm-stand-line",minzoom:13,paint:{"line-color":l.standLine,"line-width":1}},{id:"amm-runway-threshold-label",type:"symbol",source:e,"source-layer":"amm-runway-threshold",minzoom:12,layout:{"icon-image":"text_bg","icon-text-fit":"both","icon-text-fit-padding":[1,2,1,2],"text-field":["get","idthr"],"text-size":14,"text-allow-overlap":!0,"text-rotation-alignment":"map","icon-rotation-alignment":"map"},paint:{"text-color":"#ffffff","icon-color":"#ef4444"}},{id:"amm-stand",type:"circle",source:e,"source-layer":"amm-stand",minzoom:12,paint:{"circle-color":l.stand,"circle-radius":1.5}},{id:"amm-stand-label",type:"symbol",source:e,"source-layer":"amm-stand",minzoom:14,layout:{"text-field":["get","idstd"],"text-size":9,"text-anchor":"bottom","text-offset":[0,-.5],"text-allow-overlap":!1},paint:{"text-color":l.stand,"text-halo-color":"#0f172a","text-halo-width":1}},{id:"amm-obstacle-region-fill",type:"fill",source:e,"source-layer":"amm-obstacle-region",minzoom:11,paint:{"fill-color":"#fef08a","fill-opacity":.15}},{id:"amm-obstacle-region-stroke",type:"line",source:e,"source-layer":"amm-obstacle-region",minzoom:11,paint:{"line-color":"#eab308","line-width":1.2,"line-dasharray":[1.5,1]}},{id:"amm-obstacle-point",type:"circle",source:e,"source-layer":"amm-obstacle-point",minzoom:11,paint:{"circle-color":"#f97316","circle-radius":4,"circle-stroke-color":"#0f172a","circle-stroke-width":1}},{id:"amm-obstacle-point-label",type:"symbol",source:e,"source-layer":"amm-obstacle-point",minzoom:14,layout:{"text-field":["coalesce",["get","ident"],["get","LABEL"]],"text-size":9,"text-anchor":"bottom","text-offset":[0,-.5],"text-allow-overlap":!1},paint:{"text-color":"#fdba74","text-halo-color":"#0f172a","text-halo-width":1.2}},{id:"amm-construction-fill",type:"fill",source:e,"source-layer":"amm-construction",minzoom:11,paint:{"fill-pattern":"normal:passline","fill-opacity":.6}},{id:"amm-construction-stroke",type:"line",source:e,"source-layer":"amm-construction",minzoom:11,paint:{"line-color":"#ea580c","line-width":1.2,"line-dasharray":[4,2]}},{id:"amm-construction-label",type:"symbol",source:e,"source-layer":"amm-construction",minzoom:13,layout:{"text-field":["get","text"],"text-size":9,"text-anchor":"center","symbol-placement":"point","text-allow-overlap":!1},paint:{"text-color":"#f97316","text-halo-color":"#0f172a","text-halo-width":1}}]}(e):"neutral"===t?function(e="amm"){const t="#1f1f23";return[{id:"amm-airport-fill",type:"fill",source:e,"source-layer":"amm-airport",minzoom:11,paint:{"fill-color":c.airport,"fill-opacity":.3}},{id:"amm-airport-stroke",type:"line",source:e,"source-layer":"amm-airport",minzoom:11,paint:{"line-color":"#52525b","line-width":1}},{id:"amm-runway-fill",type:"fill",source:e,"source-layer":"amm-runway",minzoom:11,paint:{"fill-color":c.runway,"fill-opacity":1}},{id:"amm-runway-stroke",type:"line",source:e,"source-layer":"amm-runway",minzoom:11,paint:{"line-color":"#52525b","line-width":.5}},{id:"amm-apron-fill",type:"fill",source:e,"source-layer":"amm-apron",minzoom:11,paint:{"fill-color":c.apron,"fill-opacity":1}},{id:"amm-apron-stroke",type:"line",source:e,"source-layer":"amm-apron",minzoom:11,paint:{"line-color":"#3f3f46","line-width":.5}},{id:"amm-taxiway-fill",type:"fill",source:e,"source-layer":"amm-taxiway",minzoom:11,paint:{"fill-color":c.taxiway,"fill-opacity":.9}},{id:"amm-taxiway-line",type:"line",source:e,"source-layer":"amm-taxiway-line",minzoom:11,paint:{"line-color":c.taxiwayLine,"line-width":["interpolate",["linear"],["zoom"],15,.8,18,2]}},{id:"amm-taxiway-label",type:"symbol",source:e,"source-layer":"amm-taxiway-line",minzoom:14,layout:{"text-field":["get","idlin"],"text-size":10,"icon-image":"text_bg","icon-text-fit":"both","icon-text-fit-padding":[1,2,1,2],"symbol-placement":"line","text-keep-upright":!0,"text-allow-overlap":!1},paint:{"text-color":t,"icon-color":c.taxiwayLine}},{id:"amm-holding",type:"line",source:e,"source-layer":"amm-holding",minzoom:11,paint:{"line-color":c.holding,"line-width":1.5}},{id:"amm-runway-marking",type:"fill",source:e,"source-layer":"amm-runway-marking",minzoom:13,paint:{"fill-color":c.runwayMarking,"fill-opacity":.85}},{id:"amm-restricted-fill",type:"fill",source:e,"source-layer":"amm-restricted",minzoom:11,paint:{"fill-color":c.restricted,"fill-opacity":.1}},{id:"amm-restricted-stroke",type:"line",source:e,"source-layer":"amm-restricted",minzoom:11,paint:{"line-color":c.restricted,"line-width":1.2,"line-dasharray":[4,2]}},{id:"amm-hotspot-fill",type:"fill",source:e,"source-layer":"amm-hotspot",minzoom:11,paint:{"fill-color":c.hotspot,"fill-opacity":.12}},{id:"amm-hotspot-stroke",type:"line",source:e,"source-layer":"amm-hotspot",minzoom:11,paint:{"line-color":c.hotspot,"line-width":1.2}},{id:"amm-runway-centerline",type:"line",source:e,"source-layer":"amm-runway-centerline",minzoom:11,paint:{"line-color":c.runwayCenterline,"line-width":1,"line-dasharray":[6,3]}},{id:"amm-runway-info",type:"symbol",source:e,"source-layer":"amm-runway-label",minzoom:13,layout:{"text-field":["concat",["coalesce",["get","length"],""],"×",["coalesce",["get","width"],""],"m"],"text-size":["interpolate",["exponential",1.5],["zoom"],13,10,16,13],"symbol-placement":"point","text-rotate":["coalesce",["get","bearing"],0],"text-rotation-alignment":"map","text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":"#e4e4e7","text-halo-color":t,"text-halo-width":2}},{id:"amm-stand-line",type:"line",source:e,"source-layer":"amm-stand-line",minzoom:13,paint:{"line-color":c.standLine,"line-width":1}},{id:"amm-runway-threshold-label",type:"symbol",source:e,"source-layer":"amm-runway-threshold",minzoom:12,layout:{"icon-image":"text_bg","icon-text-fit":"both","icon-text-fit-padding":[1,2,1,2],"text-field":["get","idthr"],"text-size":14,"text-allow-overlap":!0,"text-rotation-alignment":"map","icon-rotation-alignment":"map"},paint:{"text-color":"#ffffff","icon-color":c.threshold}},{id:"amm-stand",type:"circle",source:e,"source-layer":"amm-stand",minzoom:12,paint:{"circle-color":c.stand,"circle-radius":1.5}},{id:"amm-stand-label",type:"symbol",source:e,"source-layer":"amm-stand",minzoom:14,layout:{"text-field":["get","idstd"],"text-size":9,"text-anchor":"bottom","text-offset":[0,-.5],"text-allow-overlap":!1},paint:{"text-color":c.stand,"text-halo-color":t,"text-halo-width":1}},{id:"amm-obstacle-region-fill",type:"fill",source:e,"source-layer":"amm-obstacle-region",minzoom:11,paint:{"fill-color":"#fef08a","fill-opacity":.1}},{id:"amm-obstacle-region-stroke",type:"line",source:e,"source-layer":"amm-obstacle-region",minzoom:11,paint:{"line-color":"#eab308","line-width":1.2,"line-dasharray":[1.5,1]}},{id:"amm-obstacle-point",type:"circle",source:e,"source-layer":"amm-obstacle-point",minzoom:11,paint:{"circle-color":"#f97316","circle-radius":4,"circle-stroke-color":t,"circle-stroke-width":1}},{id:"amm-obstacle-point-label",type:"symbol",source:e,"source-layer":"amm-obstacle-point",minzoom:14,layout:{"text-field":["coalesce",["get","ident"],["get","LABEL"]],"text-size":9,"text-anchor":"bottom","text-offset":[0,-.5],"text-allow-overlap":!1},paint:{"text-color":"#fdba74","text-halo-color":t,"text-halo-width":1.2}},{id:"amm-construction-fill",type:"fill",source:e,"source-layer":"amm-construction",minzoom:11,paint:{"fill-pattern":"normal:passline","fill-opacity":.6}},{id:"amm-construction-stroke",type:"line",source:e,"source-layer":"amm-construction",minzoom:11,paint:{"line-color":"#ea580c","line-width":1.2,"line-dasharray":[4,2]}},{id:"amm-construction-label",type:"symbol",source:e,"source-layer":"amm-construction",minzoom:13,layout:{"text-field":["get","text"],"text-size":9,"text-anchor":"center","symbol-placement":"point","text-allow-overlap":!1},paint:{"text-color":"#f97316","text-halo-color":t,"text-halo-width":1}}]}(e):function(e="amm"){return[{id:"amm-airport-fill",type:"fill",source:e,"source-layer":"amm-airport",minzoom:11,paint:{"fill-color":a.airport,"fill-opacity":.4}},{id:"amm-airport-stroke",type:"line",source:e,"source-layer":"amm-airport",minzoom:11,paint:{"line-color":a.airport,"line-width":1}},{id:"amm-runway-fill",type:"fill",source:e,"source-layer":"amm-runway",minzoom:11,paint:{"fill-color":a.runway,"fill-opacity":.9}},{id:"amm-runway-stroke",type:"line",source:e,"source-layer":"amm-runway",minzoom:11,paint:{"line-color":"#64748b","line-width":.5}},{id:"amm-apron-fill",type:"fill",source:e,"source-layer":"amm-apron",minzoom:11,paint:{"fill-color":a.apron,"fill-opacity":.6}},{id:"amm-apron-stroke",type:"line",source:e,"source-layer":"amm-apron",minzoom:11,paint:{"line-color":"#94a3b8","line-width":.5}},{id:"amm-taxiway-fill",type:"fill",source:e,"source-layer":"amm-taxiway",minzoom:11,paint:{"fill-color":a.taxiway,"fill-opacity":.7}},{id:"amm-taxiway-line",type:"line",source:e,"source-layer":"amm-taxiway-line",minzoom:11,paint:{"line-color":a.taxiwayLine,"line-width":["interpolate",["linear"],["zoom"],15,.8,18,2]}},{id:"amm-taxiway-label",type:"symbol",source:e,"source-layer":"amm-taxiway-line",minzoom:14,layout:{"text-field":["get","idlin"],"text-size":10,"icon-image":"text_bg","icon-text-fit":"both","icon-text-fit-padding":[1,2,1,2],"symbol-placement":"line","text-keep-upright":!0,"text-allow-overlap":!1},paint:{"text-color":"#FFF","icon-color":a.taxiwayLine}},{id:"amm-holding",type:"line",source:e,"source-layer":"amm-holding",minzoom:11,paint:{"line-color":a.holding,"line-width":1.5}},{id:"amm-runway-marking",type:"fill",source:e,"source-layer":"amm-runway-marking",minzoom:13,paint:{"fill-color":a.runwayMarking,"fill-opacity":.9}},{id:"amm-restricted-fill",type:"fill",source:e,"source-layer":"amm-restricted",minzoom:11,paint:{"fill-color":a.restricted,"fill-opacity":.08}},{id:"amm-restricted-stroke",type:"line",source:e,"source-layer":"amm-restricted",minzoom:11,paint:{"line-color":a.restricted,"line-width":1.5,"line-dasharray":[4,2]}},{id:"amm-hotspot-fill",type:"fill",source:e,"source-layer":"amm-hotspot",minzoom:11,paint:{"fill-color":a.hotspot,"fill-opacity":.1}},{id:"amm-hotspot-stroke",type:"line",source:e,"source-layer":"amm-hotspot",minzoom:11,paint:{"line-color":a.hotspot,"line-width":1.5}},{id:"amm-runway-centerline",type:"line",source:e,"source-layer":"amm-runway-centerline",minzoom:11,paint:{"line-color":a.runwayCenterline,"line-width":1,"line-dasharray":[6,3]}},{id:"amm-runway-info",type:"symbol",source:e,"source-layer":"amm-runway-label",minzoom:13,layout:{"text-field":["concat",["coalesce",["get","length"],""],"×",["coalesce",["get","width"],""],"m"],"text-size":["interpolate",["exponential",1.5],["zoom"],13,10,16,13],"symbol-placement":"point","text-rotate":["coalesce",["get","bearing"],0],"text-rotation-alignment":"map","text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":"#f8fafc","text-halo-color":"#334155","text-halo-width":2.5}},{id:"amm-stand-line",type:"line",source:e,"source-layer":"amm-stand-line",minzoom:13,paint:{"line-color":a.standLine,"line-width":1}},{id:"amm-runway-threshold-label",type:"symbol",source:e,"source-layer":"amm-runway-threshold",minzoom:12,layout:{"icon-image":"text_bg","icon-text-fit":"both","icon-text-fit-padding":[1,2,1,2],"text-field":["get","idthr"],"text-size":14,"text-allow-overlap":!0,"text-rotation-alignment":"map","icon-rotation-alignment":"map"},paint:{"text-color":"#fff","icon-color":"#b91c1c"}},{id:"amm-stand",type:"circle",source:e,"source-layer":"amm-stand",minzoom:12,paint:{"circle-color":a.stand,"circle-radius":1.5}},{id:"amm-stand-label",type:"symbol",source:e,"source-layer":"amm-stand",minzoom:14,layout:{"text-field":["get","idstd"],"text-size":9,"text-anchor":"bottom","text-offset":[0,-.5],"text-allow-overlap":!1},paint:{"text-color":a.standLine}},{id:"amm-obstacle-region-fill",type:"fill",source:e,"source-layer":"amm-obstacle-region",minzoom:11,paint:{"fill-color":"#fef08a","fill-opacity":.35}},{id:"amm-obstacle-region-stroke",type:"line",source:e,"source-layer":"amm-obstacle-region",minzoom:11,paint:{"line-color":"#ca8a04","line-width":1.5,"line-dasharray":[1.5,1]}},{id:"amm-obstacle-point",type:"circle",source:e,"source-layer":"amm-obstacle-point",minzoom:11,paint:{"circle-color":"#b45309","circle-radius":4,"circle-stroke-color":"#ffffff","circle-stroke-width":1}},{id:"amm-obstacle-point-label",type:"symbol",source:e,"source-layer":"amm-obstacle-point",minzoom:14,layout:{"text-field":["coalesce",["get","ident"],["get","LABEL"]],"text-size":9,"text-anchor":"bottom","text-offset":[0,-.5],"text-allow-overlap":!1},paint:{"text-color":"#92400e","text-halo-color":"#ffffff","text-halo-width":1}},{id:"amm-construction-fill",type:"fill",source:e,"source-layer":"amm-construction",minzoom:11,paint:{"fill-pattern":"normal:passline","fill-opacity":.8}},{id:"amm-construction-stroke",type:"line",source:e,"source-layer":"amm-construction",minzoom:11,paint:{"line-color":"#d97706","line-width":1.5,"line-dasharray":[4,2]}},{id:"amm-construction-label",type:"symbol",source:e,"source-layer":"amm-construction",minzoom:13,layout:{"text-field":["get","text"],"text-size":9,"text-anchor":"center","symbol-placement":"point","text-allow-overlap":!1},paint:{"text-color":"#92400e","text-halo-color":"#ffffff","text-halo-width":1}}]}(e)}const h={ammAirport:["amm-airport-fill","amm-airport-stroke"],ammRunway:["amm-runway-fill","amm-runway-stroke","amm-runway-info","amm-runway-marking","amm-runway-centerline","amm-runway-threshold","amm-runway-threshold-label"],ammApron:["amm-apron-fill","amm-apron-stroke"],ammTaxiway:["amm-taxiway-fill","amm-taxiway-line","amm-taxiway-label"],ammHolding:["amm-holding"],ammStand:["amm-stand","amm-stand-label","amm-stand-line"],ammRestricted:["amm-restricted-fill","amm-restricted-stroke"],ammHotspot:["amm-hotspot-fill","amm-hotspot-stroke"],ammObstacle:["amm-obstacle-region-fill","amm-obstacle-region-stroke","amm-obstacle-point","amm-obstacle-point-label"],ammConstruction:["amm-construction-fill","amm-construction-stroke","amm-construction-label"]};const d={background:["background"],landLayer:["landLayer"],boundary:["boundary"],airspace:["airspaceLayer","airspace_label_side_layer","airspaceLayer_line","airspace_label_center_layer"],airline:["airline","airline_label","airline_point","airline_radial"],controlled:["controlledLayer","controlledLayer_stroke","controlled_line_label"],restricted:["restrictedLayer","restrictedLayer_stroke","restricted_line_label"],vor:["vor_icon","vor_icon_dial","vor_label"],ndb:["ndb_icon"],airport:["airport"],runway:["runway-line","runway-line-amm","runway-label"],adiz:["adiz-line","adiz-label"],waypointOffAirway:["waypoint-off-airway-symbol"],amm:Object.values(h).flat(),terrain:["terrain-color","terrain-hillshade"],contour:["contour-line","contour-label"]},p={background:!0,landLayer:!0,boundary:!0,airspace:!0,airline:!0,controlled:!0,restricted:!0,vor:!0,ndb:!0,airport:!0,runway:!0,adiz:!0,waypointOffAirway:!0,amm:!0,terrain:!1,contour:!1},f={fir:"airspace",segment:"airline",waypoint:"airline"};class m{constructor(e,t,i){this.customLayers=new Map,this.builtInLayers=new Map,this.customLayerStyles={},this.map=e,this.performanceManager=t,this.customLayerStyles=i||{},this.initializeBuiltInLayers()}initializeBuiltInLayers(){const e=Object.values(d).flat(),t=this.map.getStyle()?.layers||[];e.forEach(e=>{const i=t.find(t=>t.id===e),n="none"!==i?.layout?.visibility;this.builtInLayers.set(e,n)})}addLayer(e){try{if(this.map.getLayer(e.id))return e.id;if(!this.map.getSource(e.source))return"";const t=this.performanceManager?this.performanceManager.optimizeLayerConfig(e,this.map.getZoom()):e;return this.map.addLayer(t),this.customLayers.set(e.id,t),e.id}catch(e){return""}}removeLayer(e){try{return!!this.map.getLayer(e)&&(this.map.removeLayer(e),this.customLayers.delete(e),!0)}catch(e){return!1}}updateLayer(e,t){try{if(!this.map.getLayer(e))return!1;this.map.removeLayer(e);const i=this.customLayers.get(e)||this.map.getStyle().layers.find(t=>t.id===e);if(!i)return!1;const n={...i,...t},r=this.performanceManager?this.performanceManager.optimizeLayerConfig(n,this.map.getZoom()):n;return this.map.addLayer(r),this.customLayers.has(e)&&this.customLayers.set(e,r),!0}catch(e){return!1}}showLayer(e){try{return!!this.map.getLayer(e)&&(this.map.setLayoutProperty(e,"visibility","visible"),!0)}catch(e){return!1}}hideLayer(e){try{return!!this.map.getLayer(e)&&(this.map.setLayoutProperty(e,"visibility","none"),!0)}catch(e){return!1}}toggleLayer(e){try{if(!this.map.getLayer(e))return!1;const t="visible"===this.map.getLayoutProperty(e,"visibility")?"none":"visible";return this.map.setLayoutProperty(e,"visibility",t),!0}catch(e){return!1}}getLayer(e){try{return this.map.getLayer(e)?this.customLayers.get(e)||this.map.getStyle().layers.find(t=>t.id===e):void 0}catch(e){return}}getAllLayers(){try{return(this.map.getStyle().layers||[]).map(e=>this.customLayers.get(e.id)||e)}catch(e){return[]}}batchUpdateLayers(e){e.forEach(({id:e,updates:t})=>{this.updateLayer(e,t)})}batchShowLayers(e){e.forEach(e=>{this.showLayer(e)})}batchHideLayers(e){e.forEach(e=>{this.hideLayer(e)})}async addBuiltInLayer(e,t){if(Array.isArray(e)){for(const i of e)await this.addBuiltInLayer(i,t);return}const i=d[e];if(Array.isArray(i))for(const e of i)try{if(!this.map.getLayer(e))continue;const t=this.customLayerStyles[e];if(t?.layout)for(const[i,n]of Object.entries(t.layout))this.map.setLayoutProperty(e,i,n);if(t?.paint)for(const[i,n]of Object.entries(t.paint))this.map.setPaintProperty(e,i,n);this.map.setLayoutProperty(e,"visibility","visible"),this.builtInLayers.set(e,!0)}catch(e){}}removeBuiltInLayer(e){const t=d[e];if(!Array.isArray(t))return!1;let i=!1;for(const e of t)try{this.map.getLayer(e)&&(this.map.setLayoutProperty(e,"visibility","none"),this.builtInLayers.set(e,!1),i=!0)}catch(e){}return i}getBuiltInLayers(){return d}isBuiltInLayerVisible(e){return this.builtInLayers.get(e)||!1}setLODEnabled(e){this.performanceManager&&this.performanceManager.setLODEnabled(e)}setLayerLODConfig(e,config){this.performanceManager&&this.performanceManager.setLayerLODConfig(e,config)}}class g{constructor(e,t){this.features=new Map,this.featureCounter=0,this.map=e,this.performanceManager=t}generateFeatureId(e){return e||"feature_"+ ++this.featureCounter}addPoint(e,t={},i,n){const r=this.generateFeatureId(n),o={type:"Feature",geometry:{type:"Point",coordinates:e},properties:{...t,featureType:"point",featureId:r},id:r};return this.features.set(r,o),this.createFeatureLayer(r,o,i),r}addLine(e,t={},i,n){const r=this.generateFeatureId(n),o={type:"Feature",geometry:{type:"LineString",coordinates:e},properties:{...t,featureType:"line",featureId:r},id:r};return this.features.set(r,o),this.createFeatureLayer(r,o,i),r}addPolygon(e,t={},i,n){const r=this.generateFeatureId(n),o={type:"Feature",geometry:{type:"Polygon",coordinates:e},properties:{...t,featureType:"polygon",featureId:r},id:r};return this.features.set(r,o),this.createFeatureLayer(r,o,i),r}addGeoJSON(e,t,i){return t&&"object"==typeof t&&"FeatureCollection"!==t.type&&"GeometryCollection"!==t.type&&!t.geometry&&(i=t,t=void 0),t||(t={type:"FeatureCollection",features:[]}),this.map.addSource(e,{type:"geojson",data:t??void 0,...i})}addFeature(e,t){const i=this.generateFeatureId(),n={...e,id:i,properties:{...e.properties,featureId:i}};return this.features.set(i,n),this.createFeatureLayer(i,n,t),i}removeFeature(e){try{return!!this.features.get(e)&&(this.removeFeatureLayer(e),this.features.delete(e),!0)}catch(e){return!1}}updateFeature(e,t){try{const i=this.features.get(e);if(!i)return!1;const n={...i,...t};return this.features.set(e,n),t.style&&(this.removeFeatureLayer(e),this.createFeatureLayer(e,n,t.style)),!0}catch(e){return!1}}clearAllFeatures(){try{this.features.forEach((e,t)=>{this.removeFeatureLayer(t)}),this.features.clear()}catch(e){}}getFeature(e){return this.features.get(e)}getAllFeatures(){return Array.from(this.features.values())}setClusteringEnabled(e){this.performanceManager&&this.performanceManager.setClusteringEnabled(e)}setClusteringConfig(e,config){this.performanceManager&&this.performanceManager.setClusteringConfig(e,config)}createFeatureLayer(e,t,i){try{const n=`${e}`,r=`${e}`;if(!this.map.getSource(n)){const e={type:"geojson",data:t};this.map.addSource(n,e)}if(!this.map.getLayer(r)){const e={id:r,type:this.getLayerType(t.geometry.type,i),source:n,paint:i?.paint||this.getDefaultPaint(t.geometry.type,i),layout:i?.layout||this.getDefaultLayout(t.geometry.type,i)};i?.filter&&(e.filter=i.filter),this.map.addLayer(e)}}catch(e){}}removeFeatureLayer(e){try{const t=`${e}`,i=`${e}`;this.map.getLayer(t)&&this.map.removeLayer(t),this.map.getSource(i)&&this.map.removeSource(i)}catch(e){}}getLayerType(e,t){switch(e){case"Point":case"MultiPoint":return t?.layout&&t.layout["text-field"]?"symbol":"circle";case"LineString":case"MultiLineString":return"line";case"Polygon":case"MultiPolygon":return"fill";default:return"circle"}}getDefaultPaint(e,t){if(t?.layout&&t.layout["text-field"])return{"text-color":"#000000","text-halo-color":"#ffffff","text-halo-width":1};switch(e){case"Point":case"MultiPoint":return{"circle-radius":8,"circle-color":"#ffff00","circle-opacity":.8,"circle-stroke-width":2,"circle-stroke-color":"#ffffff"};case"LineString":case"MultiLineString":return{"line-color":"#ffff00","line-width":2,"line-opacity":.8};case"Polygon":case"MultiPolygon":return{"fill-color":"#ffff00","fill-opacity":.6,"fill-outline-color":"#ffff00"};default:return{}}}getDefaultLayout(e,t){if(t?.layout&&t.layout["text-field"])return{"text-size":14,"text-anchor":"center","text-allow-overlap":!1};switch(e){case"Point":case"MultiPoint":return{"circle-sort-key":["get","featureId"]};case"LineString":case"MultiLineString":return{"line-join":"round","line-cap":"round"};default:return{}}}}class y{constructor(e={}){this.lodEnabled=!1,this.clusteringEnabled=!1,this.lazyLoadingEnabled=!1,this.layerLODConfigs=new Map,this.clusteringConfigs=new Map,this.visibleLayers=new Set,this.layerLoadQueue=[],this.isProcessingQueue=!1,this.lodEnabled=e.lodEnabled??!1,this.clusteringEnabled=e.clusteringEnabled??!1,this.lazyLoadingEnabled=e.lazyLoadingEnabled??!1}setLODEnabled(e){this.lodEnabled=e}setLayerLODConfig(e,config){this.layerLODConfigs.set(e,config)}getLayerLODConfig(e){return this.layerLODConfigs.get(e)}setClusteringEnabled(e){this.clusteringEnabled=e}setClusteringConfig(e,config){this.clusteringConfigs.set(e,config)}getClusteringConfig(e){return this.clusteringConfigs.get(e)}setLazyLoadingEnabled(e){this.lazyLoadingEnabled=e}addToLazyLoadQueue(e,t=0){this.lazyLoadingEnabled&&(this.layerLoadQueue.push(e),this.processLoadQueue())}async processLoadQueue(){if(!this.isProcessingQueue&&0!==this.layerLoadQueue.length){this.isProcessingQueue=!0;try{for(;this.layerLoadQueue.length>0;){const e=this.layerLoadQueue.shift();e&&(await this.loadLayer(e),await this.delay(50))}}finally{this.isProcessingQueue=!1}}}async loadLayer(e){try{await this.simulateLayerLoading(e),this.visibleLayers.add(e)}catch(e){}}async simulateLayerLoading(e){return new Promise(e=>{setTimeout(()=>{e()},100*Math.random()+50)})}delay(e){return new Promise(t=>setTimeout(t,e))}shouldLayerBeVisible(e,t){if(!this.lodEnabled)return!0;const config=this.layerLODConfigs.get(e);return!config||t>=config.minZoom&&t<=config.maxZoom}getPerformanceStats(){return{visibleLayers:this.visibleLayers.size,queuedLayers:this.layerLoadQueue.length,lodEnabled:this.lodEnabled,clusteringEnabled:this.clusteringEnabled,lazyLoadingEnabled:this.lazyLoadingEnabled}}optimizeLayerConfig(e,t){if(!this.lodEnabled)return e;const i=this.layerLODConfigs.get(e.id);return i&&t<i.minZoom?{...e,paint:this.simplifyPaintProperties(e.paint),layout:this.simplifyLayoutProperties(e.layout)}:e}simplifyPaintProperties(e){if(!e)return e;const t={};for(const[i,n]of Object.entries(e))"number"!=typeof n&&"string"!=typeof n||(t[i]=n);return t}simplifyLayoutProperties(e){if(!e)return e;const t={};for(const[i,n]of Object.entries(e))"number"!=typeof n&&"string"!=typeof n||(t[i]=n);return t}destroy(){this.layerLODConfigs.clear(),this.clusteringConfigs.clear(),this.visibleLayers.clear(),this.layerLoadQueue=[],this.isProcessingQueue=!1}}class _{constructor(e){this.plugins=new Map,this.sdk=e}use(e){if(!this.plugins.has(e.name))try{e.install(this.sdk),this.plugins.set(e.name,e)}catch(e){}}getPlugin(e){return this.plugins.get(e)}getAllPlugins(){return Array.from(this.plugins.values())}hasPlugin(e){return this.plugins.has(e)}uninstallPlugin(e){const t=this.plugins.get(e);if(!t)return!1;try{return t.uninstall&&t.uninstall(this.sdk),this.plugins.delete(e),!0}catch(e){return!1}}uninstallAllPlugins(){Array.from(this.plugins.keys()).forEach(e=>this.uninstallPlugin(e))}getPluginStats(){return{total:this.plugins.size,names:Array.from(this.plugins.keys())}}destroy(){this.uninstallAllPlugins(),this.plugins.clear()}}class v{constructor(e){this.sourceId="adsb",this.pointLayerId="adsb-points",this.labelLayerId="adsb-labels",this.opened=!1,this.enableInterpolation=!1,this.interpolationTimer=null,this.lastUpdateTime=0,this.currentFeatures=[],this.interpolatedFeatures=[],this.minZoomForInterpolation=8,this.lastBounds=null,this.boundsChangeThreshold=.01,this.lastTimeStamps=new Map,this.map=e}open(e,t,i){if(this.opened)return;if(this.map.getSource(this.sourceId)||this.map.addSource(this.sourceId,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),!this.map.getLayer(this.pointLayerId)){const t={id:this.pointLayerId,type:"symbol",source:this.sourceId,minzoom:2,layout:{"icon-image":"icon-10","icon-rotate":["get","heading"],"icon-rotation-alignment":"map","icon-allow-overlap":!0,"icon-size":["interpolate",["linear"],["zoom"],2,.4,8,.5]}},i=this.mergeLayerConfig(t,e||{});i.id=this.pointLayerId,i.source=this.sourceId,this.map.addLayer(i)}const n=t?.show;!this.map.getLayer(this.labelLayerId)&&n&&this.map.addLayer({id:this.labelLayerId,type:"symbol",source:this.sourceId,minzoom:6,layout:{"text-field":["coalesce",["get","label"],["get","callsign"],"暂无名称"],"text-size":12,"text-offset":[.8,0],"text-anchor":"left","text-allow-overlap":!0,"symbol-placement":"point"},paint:{"text-color":"#000","text-halo-color":"#fff","text-halo-width":1}}),this.enableInterpolation=i||!1,this.opened=!0}close(){this.opened&&(this.stopInterpolation(),this.lastTimeStamps.clear(),this.map.getLayer(this.labelLayerId)&&this.map.removeLayer(this.labelLayerId),this.map.getLayer(this.pointLayerId)&&this.map.removeLayer(this.pointLayerId),this.opened=!1)}update(e){const t=e||[],i=Date.now();this.enableInterpolation&&this.currentFeatures.length>0?this.currentFeatures=this.mergeFeaturesWithInterpolation(t,i):(this.currentFeatures=t,this.interpolatedFeatures=[]),this.lastUpdateTime=i,this.enableInterpolation?(this.stopInterpolation(),this.startInterpolation()):this.updateMapDisplay(this.currentFeatures)}startInterpolation(){this.enableInterpolation&&!this.interpolationTimer&&(this.interpolationTimer=setInterval(()=>{this.performInterpolation()},1e3))}stopInterpolation(){this.interpolationTimer&&(clearInterval(this.interpolationTimer),this.interpolationTimer=null)}performInterpolation(){if(0===this.currentFeatures.length)return;if(this.map.getZoom()<this.minZoomForInterpolation)return void this.updateMapDisplay(this.currentFeatures);const e=(Date.now()-this.lastUpdateTime)/1e3;if(e>60)return void this.stopInterpolation();const t=this.map.getBounds();this.hasBoundsChanged(t)&&(this.lastBounds=t);const i=this.interpolatedFeatures.length>0?this.interpolatedFeatures:this.currentFeatures;this.interpolatedFeatures=i.map(i=>this.isFeatureInBounds(i,t)?this.interpolateFeature(i,e):i),this.updateMapDisplay(this.interpolatedFeatures)}interpolateFeature(e,t){const i=e.properties||{},n=i.heading||0,r=i.speed||0;if(!e.geometry||!e.geometry.coordinates||0===n||0===r)return e;const[o,s]=e.geometry.coordinates,a=n*Math.PI/180,l=1852*r/3600*t,c=6371e3,u=s+l*Math.cos(a)/c*(180/Math.PI),h=o+l*Math.sin(a)/c*(180/Math.PI)/Math.cos(s*Math.PI/180);return{...e,geometry:{...e.geometry,coordinates:[h,u]}}}mergeFeaturesWithInterpolation(e,t){if((t-this.lastUpdateTime)/1e3<.5)return this.currentFeatures;const i=[],n=new Map;return e.forEach(e=>{const t=this.getFeatureId(e);t&&n.set(t,e)}),this.currentFeatures.forEach(e=>{const t=this.getFeatureId(e),r=t?n.get(t):null;r?(this.hasPositionChanged(e,r)?i.push(r):i.push(e),n.delete(t)):i.push(e)}),n.forEach(e=>{const t=this.getFeatureId(e);t&&this.updateTimeStampCache(t,e),i.push(e)}),i}getFeatureId(e){const t=e.properties||{};return t.id||t.icao||t.callsign||t.aircraft_id||null}hasTimeStampChanged(e,t){const i=this.getTimeStamp(e),n=this.getTimeStamp(t);if(!i||!n)return!0;return!this.compareTimeStamps(i,n)}compareTimeStamps(e,t){if(e===t)return!0;try{const i=new Date(e),n=new Date(t);if(isNaN(i.getTime())||isNaN(n.getTime()))return!1;return Math.abs(i.getTime()-n.getTime())<1e3}catch(e){return!1}}hasPositionChanged(e,t){const i=e.geometry?.coordinates,n=t.geometry?.coordinates;if(!i||!n)return!0;const[r,o]=i,[s,a]=n,l=Math.abs(s-r),c=Math.abs(a-o),u=1e-4;return l>u||c>u}getTimeStamp(e){const t=e.properties||{},i=t.time_stamp||t.timestamp||t.time||null;if(!i)return null;if("string"==typeof i){if(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?([+-]\d{2}:\d{2}|Z)$/.test(i))return i;const e=new Date(i);if(!isNaN(e.getTime()))return i}return null}updateTimeStampCache(e,t){const i=this.getTimeStamp(t);i&&this.lastTimeStamps.set(e,i)}hasSignificantPositionChange(e,t){const i=e.geometry?.coordinates,n=t.geometry?.coordinates;if(!i||!n)return!0;const[r,o]=i,[s,a]=n,l=Math.abs(s-r),c=Math.abs(a-o);return l>.01||c>.01}getVisibleFeatures(e,t){return e.filter(e=>this.isFeatureInBounds(e,t))}isFeatureInBounds(e,t){if(!e.geometry||!e.geometry.coordinates)return!1;const[i,n]=e.geometry.coordinates,r=.1,o=t.getWest()-(t.getWest()-t.getEast())*r,s=t.getEast()+(t.getEast()-t.getWest())*r,a=t.getSouth()-(t.getSouth()-t.getNorth())*r,l=t.getNorth()+(t.getNorth()-t.getSouth())*r;return i>=o&&i<=s&&n>=a&&n<=l}hasBoundsChanged(e){if(!this.lastBounds)return!0;const t=e.getWest(),i=e.getEast(),n=e.getSouth(),r=e.getNorth(),o=this.lastBounds.getWest(),s=this.lastBounds.getEast(),a=this.lastBounds.getSouth(),l=this.lastBounds.getNorth();return(Math.abs(t-o)+Math.abs(i-s)+Math.abs(n-a)+Math.abs(r-l))/4>this.boundsChangeThreshold}updateMapDisplay(e){const t=this.map.getSource(this.sourceId);t&&t.setData({type:"FeatureCollection",features:e})}destroy(){this.close()}mergeLayerConfig(e,t){if(!t||"object"!=typeof t)return e;const i={...e};for(const n of Object.keys(t)){if("id"===n||"source"===n)continue;const r=e[n],o=t[n];r&&o&&"object"==typeof r&&!Array.isArray(r)&&"object"==typeof o&&!Array.isArray(o)?i[n]=this.mergeLayerConfig(r,o):i[n]=o}return i}}class x{constructor(e){this.hoveredLayers=new Map,this.isEnabled=!1,this.debounceTimers=new Map,this.debounceDelay=100,this.cleanupFunctions=new Map,this.resolveArray=(e,t)=>Array.isArray(e)?e:e instanceof RegExp?t.getStyle().layers.map(e=>e.id).filter(t=>t.match(e)):e instanceof Function?t.getStyle().layers.filter(t=>e(t)).map(e=>e.id):[e],this.arrayifyAndOff=e=>{const t=this;return function(i,...n){const r=t.resolveArray(i,this.map).map(t=>e.call(this,t,...n));return()=>r.forEach(e=>e())}},this.hoverLayer=this.arrayifyAndOff(function(e,t){this.clearLayerListeners([e]);const i=i=>{const n=`${e}-${t.toString()}`;this.debounceTimers&&this.debounceTimers.has(n)&&clearTimeout(this.debounceTimers.get(n));const r=setTimeout(()=>{i.features=this.map.queryRenderedFeatures(i.point,{layers:[e]}),t(i)},this.debounceDelay||300);this.debounceTimers&&this.debounceTimers.set(n,r)};this.map.on("mousemove",e,i);const n=()=>{this.map.off("mousemove",e,i);const n=`${e}-${t.toString()}`;this.debounceTimers&&this.debounceTimers.has(n)&&(clearTimeout(this.debounceTimers.get(n)),this.debounceTimers.delete(n))};return this.cleanupFunctions.set(e,n),n}),this.map=e}setDebounceDelay(e){this.debounceDelay=e}hoverPopup(e,t,i={}){if(!this.map)throw"地图未初始化";return this.arrayifyAndOff(function(e,t){const n=new r.Popup({closeButton:!1,...i}),o=async e=>{if(e?.features?.[0]){n.setLngLat(e.lngLat),n.setHTML('<div style="padding: 10px;">加载中...</div>'),n.addTo(this.map);try{const i=await t(e.features[0],n);n.setHTML(i)}catch(e){n.setHTML('<div style="padding: 10px; color: red;">加载失败</div>')}}},s=e=>{n.remove()};return this.map.on("mouseenter",e,o),this.map.on("mouseout",e,s),()=>{this.map.off("mouseenter",e,o),this.map.off("mouseout",e,s),s()}}).call(this,e,t)}}class b{constructor(e){this.cleanupFunctions=new Map,this.resolveArray=(e,t)=>Array.isArray(e)?e:e instanceof RegExp?t.getStyle().layers.map(e=>e.id).filter(t=>t.match(e)):e instanceof Function?t.getStyle().layers.filter(t=>e(t)).map(e=>e.id):[e],this.arrayifyAndOff=e=>function(t,...i){const n=this.resolveArray(t,this.map).map(t=>e.call(this,t,...i));return()=>n.forEach(e=>e())},this.clickLayer=this.arrayifyAndOff(function(e,t){const i=i=>{try{const n=this.map.queryRenderedFeatures(i.point,{layers:[e]});t({...i,features:n})}catch(e){t({...i,features:[]})}};return this.map.on("click",e,i),()=>this.map.off("click",e,i)}),this.map=e}clickPopup(e,t,i={}){if(!this.map)throw"地图未初始化";return this.arrayifyAndOff(function(e,t){const n=new r.Popup({closeButton:!0,closeOnClick:!0,...i}),o=async e=>{if(e?.features?.[0]){const i=e.features[0];n.setLngLat(e.lngLat),n.setHTML('<div style="padding: 10px;">加载中...</div>'),n.addTo(this.map);try{const e=await t(i,n);n.setHTML(e)}catch(e){n.setHTML('<div style="padding: 10px; color: red;">加载失败</div>')}}};return this.map.on("click",e,o),()=>this.map.off("click",e,o)}).call(this,e,t)}clearLayerListeners(e){this.resolveArray(e,this.map).forEach(e=>{const t=this.cleanupFunctions.get(e);t&&(t(),this.cleanupFunctions.delete(e))})}}let w=null;class E{constructor(){this.config={},this.listeners=new Map,this.mapReinitCallback=null,this.parseURLParams()}static getInstance(){return E.instance||(E.instance=new E),E.instance}parseURLParams(){try{let e=this.getCurrentScriptUrl();e||(e=window.location.href);const t=new URL(e),i=new URLSearchParams(t.search),n={};if(i.has("apiKey")&&(n.apiKey=i.get("apiKey")),i.has("baseUrl")&&(n.baseUrl=i.get("baseUrl")),i.has("enableAIP")||i.has("enableNOTAM")||i.has("enableADSB")){n.chartConfig={};const e=this.parseBooleanParam(i.get("enableAIP")),t=this.parseBooleanParam(i.get("enableNOTAM")),r=this.parseBooleanParam(i.get("enableADSB"));void 0!==e&&(n.chartConfig.enableAIP=e),void 0!==t&&(n.chartConfig.enableNOTAM=t),void 0!==r&&(n.chartConfig.enableADSB=r)}if(i.has("theme")||i.has("language")){if(n.styleConfig={},i.has("theme")){const e=i.get("theme");"light"!==e&&"dark"!==e||(n.styleConfig.theme=e)}if(i.has("language")){const e=i.get("language");"zh-CN"!==e&&"en-US"!==e||(n.styleConfig.language=e)}}if(i.has("switchDay")){n.periodConfig={};const e=parseInt(i.get("switchDay"));!isNaN(e)&&e>=1&&e<=31&&(n.periodConfig.switchDay=e)}if(i.has("center")||i.has("zoom")){if(n.chartConfig||(n.chartConfig={}),i.has("center")){const e=i.get("center");try{const t=JSON.parse(e);Array.isArray(t)&&2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]&&(n.chartConfig.defaultCenter=[t[0],t[1]])}catch(e){}}if(i.has("zoom")){const e=parseFloat(i.get("zoom"));isNaN(e)||(n.chartConfig.defaultZoom=e)}}Object.keys(n).length>0&&this.setConfig(n)}catch(e){}}parseBooleanParam(e){if(null!==e)return"true"===e||"1"===e||"false"!==e&&"0"!==e&&void 0}getCurrentScriptUrl(){try{if(document.currentScript&&document.currentScript.src)return document.currentScript.src;const e=document.querySelectorAll("script[src]");for(const t of e){const e=t.getAttribute("src");if(e){const i=t;if(i.complete||"complete"===i.readyState||"loaded"===i.readyState)return e}}return null}catch(e){return null}}refreshFromURL(){this.parseURLParams()}setConfig(e){this.config={...this.config,...e},this.notifyListeners("configChanged",this.config)}getConfig(){return{...this.config}}getConfigItem(e,t){return void 0!==this.config[e]?this.config[e]:t}updateConfigItem(e,t){this.config[e]=t,this.notifyListeners("configItemChanged",{key:e,value:t})}addListener(e,t){return this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t),()=>{const i=this.listeners.get(e);if(i){const e=i.indexOf(t);e>-1&&i.splice(e,1)}}}removeListener(e,t){const i=this.listeners.get(e);if(i){const e=i.indexOf(t);e>-1&&i.splice(e,1)}}notifyListeners(e,t){const i=this.listeners.get(e);i&&i.forEach(e=>{try{e(t)}catch(e){}})}reset(){this.config={},this.notifyListeners("configReset",{})}setPeriod(e){const t=this.config.period;this.config.period=e,this.notifyListeners("periodChanged",e),t&&t!==e&&this.mapReinitCallback&&Promise.resolve(this.mapReinitCallback()).catch(e=>{})}getPeriod(){return this.config.period}async generateCurrentPeriod(){const e=await(w||(w=new M),w).getPeriodData(),{data:t}=await e.json();return t.filter(e=>"1"==e.valIscurrent)[0].txtPeriodName}setMapReinitCallback(e){this.mapReinitCallback=e}destroy(){this.listeners.clear(),this.config={}}}const T=E.getInstance(),S={pageNo:1,pageSize:100,onlyGeojson:!0,typeC:!0,notamOffset:"false",isInternational:!0,isCompanyVersion:!1,itemB:null,itemC:null},I={pageNo:-1,pageSize:99},k={pageNo:1,pageSize:999,onlyValid:!0,moduleName:"notam",topic:"official",itemB:null,itemC:null,nof:null,notamSeries:null,notamNoPart1:null,notamNoPart2:null,notamTypeIds:null};class M{constructor(){this._baseUrl="https://aips.siniswift.com"}setBaseUrl(e){this._baseUrl=e}notam_list(e){const{signal:t}=e,i={...S,...e};return delete i.signal,fetch(this._baseUrl+"/notamGraphicalCache/notamCache/listnotamCa",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i),...t&&{signal:t}})}notam_detail(e){const{signal:t}=e,i={...I,...e};return delete i.signal,fetch(this._baseUrl+"/data/notam/notam/listnotam",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i),...t&&{signal:t}})}notam_data(e){const{notamCode:t,signal:i}=e;let n=[],r="",o="",s="";if(t&&t.length>0){const e=(new Date).getFullYear().toString().slice(0,2);let i=/^\s*(?<Series>[A-Z]{1,3})?(?<Part1>\d{1,4})?\/?(?<Year>\d{2,4})?$\s*/;n=t.match(i),n.groups.Series&&(r=n.groups.Series),n.groups.Part1&&(o=n.groups.Part1),n.groups.Year&&(s=e+n.groups.Year)}const a={...k,...e};delete a.signal,a.notamSeries=r,a.notamNoPart1=o,a.notamNoPart2=s;for(const e in a)if(Object.prototype.hasOwnProperty.call(a,e)){const t=e;""===a[t]&&(a[t]=null)}return fetch(this._baseUrl+"/data/notam/notam/listnotam",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a),signal:i})}typhoon_volcano_ash(e){const{signal:t}=e,i={...e};return delete i.signal,fetch(this._baseUrl+"/plan/NavMap/AdvisoryAnalysis",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i),...t&&{signal:t}})}getRunwayData(e){const{signal:t}=e,i=new URLSearchParams;return i.append("searchParam",`{"AirportCode":"${e.AirportCode}","DataPeriod":"${T.getPeriod()}"}`),fetch(this._baseUrl+"/runway/AipsNavCommonService.asmx/GetRunwayData",{method:"POST",redirect:"follow",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i,...t&&{signal:t}})}getRadarData(e){return fetch(this._baseUrl+"/meteo/meteorology/listRadar?&maxNum=40",{method:"GET",...e&&{signal:e}})}getPeriodData(e){return fetch(this._baseUrl+"/data/datamanage/dataSource/listAll",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({}),...e&&{signal:e}})}getIndexData(e,t){return fetch(this._baseUrl+"/data/datamanage/mapData/selectByQueryIndex",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),...t&&{signal:t}})}getAirportPoint(e,t){const i={pageNo:0,pageSize:30,searchType:["AD_HP"],searchAccurate:!0,moduleName:"navmap",topic:"official",condition:e};return new Promise((e,n)=>{fetch(this._baseUrl+"/data/datamanage/mapData/listAll",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i),...t&&{signal:t}}).then(e=>e.json()).then(i=>{const r=i?.data?.data[0];this.getIndexData(r,t).then(e=>e.json()).then(t=>{e(t)}).catch(e=>{n(e)})}).catch(e=>e)})}}class C{constructor(e){this.sourceLineId="notam-source-line",this.sourceFillId="notam-source-fill",this.lineLayerId="notam-lines",this.fillLayerId="notam-fills",this.labelLayerId="notam-labels",this.opened=!1,this.beforeId="airline",this.defaultParams={pageNo:1,pageSize:100,onlyGeojson:!0,typeC:!0,notamOffset:"false",isInternational:!0,isCompanyVersion:!1},this.map=e,this.hoverManager=new x(this.map),this.clickManager=new b(this.map),this.api=new M}open(e,t,i,n=!1){if(!this.opened){if(this.map.getSource(this.sourceLineId)||this.map.addSource(this.sourceLineId,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.getSource(this.sourceFillId)||this.map.addSource(this.sourceFillId,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),!this.map.getLayer(this.lineLayerId)){const e={id:this.lineLayerId,type:"line",source:this.sourceLineId,minzoom:2,paint:{"line-color":"rgb(255, 120, 96)","line-width":["interpolate",["linear"],["zoom"],2,1,4,1,6,6],"line-opacity":["case",["boolean",["feature-state","hover"],!1],.8,.6]}},i=this.mergeLayerConfig(e,t||{});i.id=this.lineLayerId,i.source=this.sourceLineId,this.map.getLayer(this.beforeId)?this.map.addLayer(i,this.beforeId):this.map.addLayer(i)}if(!this.map.getLayer(this.fillLayerId)){const e={id:this.fillLayerId,type:"fill",source:this.sourceFillId,minzoom:2,paint:{"fill-color":"rgb(255, 120, 96)","fill-outline-color":"rgba(255, 120, 96,0.5)","fill-opacity":["case",["boolean",["feature-state","hover"],!1],.5,.3]}},t=this.mergeLayerConfig(e,i||{});t.id=this.fillLayerId,t.source=this.sourceFillId,this.map.getLayer(this.beforeId)?this.map.addLayer(t,this.beforeId):this.map.addLayer(t)}this.opened=!0,this.map.on("mousemove",this.lineLayerId,e=>{e.features&&e.features.length>0&&(this._lineHoveredStateId&&this.map.setFeatureState({source:this.sourceLineId,id:this._lineHoveredStateId},{hover:!1}),this._lineHoveredStateId=e.features[0]?.id,this.map.setFeatureState({source:this.sourceLineId,id:this._lineHoveredStateId},{hover:!0}))}),this.map.on("mousemove",this.fillLayerId,e=>{e.features&&e.features.length>0&&(this._fillHoveredStateId&&this.map.setFeatureState({source:this.sourceFillId,id:this._fillHoveredStateId},{hover:!1}),this._fillHoveredStateId=e.features[0]?.id,this.map.setFeatureState({source:this.sourceFillId,id:this._fillHoveredStateId},{hover:!0}))}),this.map.on("mouseleave",this.lineLayerId,()=>{this._lineHoveredStateId&&this.map.setFeatureState({source:this.sourceLineId,id:this._lineHoveredStateId},{hover:!1}),this._lineHoveredStateId=null}),this.map.on("mouseleave",this.fillLayerId,()=>{this._fillHoveredStateId&&this.map.setFeatureState({source:this.sourceFillId,id:this._fillHoveredStateId},{hover:!1}),this._fillHoveredStateId=null}),e&&this.getNotamData(this.defaultParams).then(e=>{this.update(e),this.openNotamDetail()})}}close(){this.opened&&(this.map.getLayer(this.labelLayerId)&&this.map.removeLayer(this.labelLayerId),this.map.getLayer(this.fillLayerId)&&this.map.removeLayer(this.fillLayerId),this.map.getLayer(this.lineLayerId)&&this.map.removeLayer(this.lineLayerId),this.opened=!1)}update(e){let t=[],i=[];e.forEach((e,n)=>{const r=e.geometry.type;"MultiLineString"===r||"LineString"===r?t.push({...e,id:n}):"Polygon"!==r&&"MultiPolygon"!==r||i.push({...e,id:n})});const n=this.map.getSource(this.sourceLineId),r=this.map.getSource(this.sourceFillId);n&&n.setData({type:"FeatureCollection",features:t}),r&&r.setData({type:"FeatureCollection",features:i})}hover(e){this.hoverManager.hoverLayer(["notam-lines","notam-fills"],e)}refresh(){this.getNotamData(this.defaultParams).then(e=>{this.update(e)})}destroy(){this.close()}async getNotamData(e){return await this._getNotamData(e)}openNotamDetail(){["notam-lines","notam-fills"].forEach(e=>{this.clickManager.clickPopup(e,async e=>{const t={notamSeries:e.properties.notamSeries,notamNoPart1:e.properties.notamNoPart1,notamNoPart2:e.properties.notamNoPart2,nof:e.properties.nof,pageNo:-1,pageSize:99},{data:i}=await this.api.notam_detail(t).then(e=>e.json()),{data:n=[]}=i,r=n.length>0?n[0]:{};if(0==Object.keys(r).length)return"";return`\n <div class="notam-popup">\n <div class="header">\n <div class="title">\n <span class="notamcode">${r.itemA}</span>\n <span class="notamcode">${r.notamCode}</span>\n \n </div>\n <span>${r.itemB||" "}</span>\n <span>-</span>\n <span>${r.itemC||" "}</span>\n <span>${r.itemC_text||" "}</span>\n <span>${r.itemCAux||" "}</span>\n </div>\n <div class="notam-body">\n <div class="itemd">${r.itemD?`D)${r.itemD}`:""}</div>\n <div class="iteme">${r.itemE?`E)${r.itemE}`:""}</div>\n <div class="itemflower">${r.itemFLower?`F)${r.itemFLower}`:""}</div>\n <div class="itemgupper">${r.itemGUpper?`G)${r.itemGUpper}`:""}</div>\n </div>\n </div>`})})}_getNotamData(e){return new Promise((t,i)=>{this.api.notam_list(e).then(e=>e.json()).then(e=>{const i=e.data.map(e=>{try{const t=JSON.parse(e.geojson);if("FeatureCollection"===t.type&&Array.isArray(t.features))return t.features.filter(e=>e&&e.geometry).map(t=>({...t,properties:{...t.properties,notamSeries:e.notamSeries,notamNoPart1:e.notamNoPart1,notamNoPart2:e.notamNoPart2,nof:e.nof,itemA:e.itemA,itemB:e.itemB,itemC:e.itemC,itemD:e.itemD,itemE:e.itemE,notamtype:e.notamtype}}))}catch(e){}return[]}).flat();t(i)}).catch(i)})}isObject(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}mergeLayerConfig(...e){return e.reduce((e,t)=>(Object.keys(t||{}).forEach(i=>{const n=e[i],r=t[i];this.isObject(n)&&this.isObject(r)?e[i]=this.mergeLayerConfig(n,r):e[i]=r}),e),{})}}class P{constructor(e){this.rasterUrl="",this.MAX_LAT=85,this.map=e,this.coordinates=[[-180,this.MAX_LAT],[180,this.MAX_LAT],[180,-this.MAX_LAT],[-180,-this.MAX_LAT]]}get rasterSourceUrl(){return this.rasterUrl}set rasterSourceUrl(e){this.rasterUrl=e}updateCoordinates(e){this.coordinates="radar"===e?[[73,54.2],[135,54.2],[135,12.2],[73,12.2]]:[[-180,this.MAX_LAT],[180,this.MAX_LAT],[180,-this.MAX_LAT],[-180,-this.MAX_LAT]]}addSource(e,t,i){this.map.getSource(e)||this.map.addSource(e,{type:"image",url:t,coordinates:i})}addLayer(e,t){this.map.getLayer(e)||this.map.addLayer({id:e,type:"raster",source:t,minzoom:0,maxzoom:17,paint:{"raster-opacity":1,"raster-resampling":"linear"}})}addRasterLayer(e,t,i){this.updateCoordinates(i),this.addSource(t,this.rasterUrl,this.coordinates),this.addLayer(e,t)}updateRasterLayer(e,t,i){this.rasterUrl=t,this.updateCoordinates(i);const n=this.map.getSource(e);n?.updateImage({url:t,coordinates:this.coordinates})}removeRasterLayer(e,t){this.map.getLayer(e)&&this.map.removeLayer(e),this.map.getSource(t)&&this.map.removeSource(t)}}class A{constructor(e,config={}){this.isVisible=!1,this.sourceId="graticule-source",this.pointSourceId="graticule-label-source",this.lineLayerId="graticule-lines",this.lonLabelLayerId="graticule-lon-labels",this.latLabelLayerId="graticule-lat-labels",this.lastInterval=null,this.map=e,this.config={enabled:config.enabled??!1,interval:config.interval??10,lineColor:config.lineColor??"#666666",lineWidth:config.lineWidth??1,lineOpacity:config.lineOpacity??.5,lineDasharray:config.lineDasharray??[2,2],labelColor:config.labelColor??"#333333",labelSize:config.labelSize??12,showLabels:config.showLabels??!0,labelFormat:config.labelFormat??"decimal"},this.config.enabled&&this.initialize(),this.map.on("zoomend",()=>this.update())}initialize(){this.map.isStyleLoaded()?(this.addGraticuleSources(),this.addGraticuleLayers(),this.isVisible=!0):this.map.once("style.load",()=>this.initialize())}addGraticuleSources(){const{lines:e,points:t}=this.generateGraticuleData();this.map.getSource(this.sourceId)?this.map.getSource(this.sourceId).setData(e):this.map.addSource(this.sourceId,{type:"geojson",data:e}),this.map.getSource(this.pointSourceId)?this.map.getSource(this.pointSourceId).setData(t):this.map.addSource(this.pointSourceId,{type:"geojson",data:t})}addGraticuleLayers(){if(!this.map.getLayer(this.lineLayerId)){const e={"line-color":this.config.lineColor,"line-width":this.config.lineWidth,"line-opacity":this.config.lineOpacity};this.config.lineDasharray&&this.config.lineDasharray.length>0&&(e["line-dasharray"]=this.config.lineDasharray),this.map.addLayer({id:this.lineLayerId,type:"line",source:this.sourceId,layout:{"line-join":"round","line-cap":"round"},paint:e})}this.config.showLabels&&(this.map.getLayer(this.lonLabelLayerId)||this.map.addLayer({id:this.lonLabelLayerId,type:"symbol",source:this.pointSourceId,filter:["has","lonLabel"],layout:{"text-field":["get","lonLabel"],"text-font":["Open Sans Regular","Arial Unicode MS Regular"],"text-size":this.config.labelSize,"text-offset":[.5,-.5],"text-anchor":"bottom-left","text-allow-overlap":!1},paint:{"text-color":this.config.labelColor,"text-halo-color":"#fff","text-halo-width":1}}),this.map.getLayer(this.latLabelLayerId)||this.map.addLayer({id:this.latLabelLayerId,type:"symbol",source:this.pointSourceId,filter:["has","latLabel"],layout:{"text-field":["get","latLabel"],"text-font":["Open Sans Regular","Arial Unicode MS Regular"],"text-size":this.config.labelSize,"text-offset":[.5,.5],"text-anchor":"top-left","text-allow-overlap":!1},paint:{"text-color":this.config.labelColor,"text-halo-color":"#fff","text-halo-width":1}}))}getDynamicInterval(){const e=this.map.getZoom();return e<=2?30:e<=4?15:e<=6?10:e<=8?5:e<=10?2.5:e<=12?1:e<=14?.5:.25}generateGraticuleData(){const e=[],t=[],i=this.getDynamicInterval();for(let t=-180;t<=180;t+=i)e.push({type:"Feature",properties:{type:"meridian",lon:t},geometry:{type:"LineString",coordinates:[[t,-90],[t,90]]}});for(let t=-90;t<=90;t+=i)e.push({type:"Feature",properties:{type:"parallel",lat:t},geometry:{type:"LineString",coordinates:[[-180,t],[180,t]]}});for(let e=-180;e<=180;e+=i)for(let n=-90;n<=90;n+=i){const i=this.formatCoordinate(e,"lon"),r=this.formatCoordinate(n,"lat");t.push({type:"Feature",geometry:{type:"Point",coordinates:[e,n]},properties:{lonLabel:i,latLabel:r}})}return this.lastInterval=i,{lines:{type:"FeatureCollection",features:e},points:{type:"FeatureCollection",features:t}}}formatCoordinate(e,t){if("dms"===this.config.labelFormat){const i=Math.abs(e),n=Math.floor(i),r=Math.floor(60*(i-n));return`${n}°${r}'${Math.round(60*(60*(i-n)-r))}"${"lon"===t?e>=0?"E":"W":e>=0?"N":"S"}`}{const i="lon"===t?e>=0?"E":"W":e>=0?"N":"S";return`${Math.abs(e).toFixed(1)}°${i}`}}update(){if(!this.isVisible)return;const e=this.getDynamicInterval();this.lastInterval!==e&&this.addGraticuleSources()}show(){this.initialize()}hide(){[this.lineLayerId,this.lonLabelLayerId,this.latLabelLayerId].forEach(e=>{this.map.getLayer(e)&&this.map.setLayoutProperty(e,"visibility","none")}),this.destroy()}toggle(){this.isVisible?this.hide():this.show()}updateConfig(e){this.config={...this.config,...e},this.isVisible&&this.refresh()}refresh(){this.isVisible&&(this.remove(),this.initialize())}remove(){[this.lineLayerId,this.lonLabelLayerId,this.latLabelLayerId].forEach(e=>{this.map.getLayer(e)&&this.map.removeLayer(e)}),[this.sourceId,this.pointSourceId].forEach(e=>{this.map.getSource(e)&&this.map.removeSource(e)}),this.isVisible=!1}getConfig(){return{...this.config}}isGraticuleVisible(){return this.isVisible}destroy(){this.map.off("zoomend",()=>this.update()),this.remove()}}function L(e){return e}function D(e,t){return"string"==typeof t&&(t=e.objects[t]),"GeometryCollection"===t.type?{type:"FeatureCollection",features:t.geometries.map(function(t){return R(e,t)})}:R(e,t)}function R(e,t){var i=t.id,n=t.bbox,r=null==t.properties?{}:t.properties,o=function(e,t){var i=function(e){if(null==e)return L;var t,i,n=e.scale[0],r=e.scale[1],o=e.translate[0],s=e.translate[1];return function(e,a){a||(t=i=0);var l=2,c=e.length,u=new Array(c);for(u[0]=(t+=e[0])*n+o,u[1]=(i+=e[1])*r+s;l<c;)u[l]=e[l],++l;return u}}(e.transform),n=e.arcs;function r(e,t){t.length&&t.pop();for(var r=n[e<0?~e:e],o=0,s=r.length;o<s;++o)t.push(i(r[o],o));e<0&&function(e,t){for(var i,n=e.length,r=n-t;r<--n;)i=e[r],e[r++]=e[n],e[n]=i}(t,s)}function o(e){return i(e)}function s(e){for(var t=[],i=0,n=e.length;i<n;++i)r(e[i],t);return t.length<2&&t.push(t[0]),t}function a(e){for(var t=s(e);t.length<4;)t.push(t[0]);return t}function l(e){return e.map(a)}function c(e){var t,i=e.type;switch(i){case"GeometryCollection":return{type:i,geometries:e.geometries.map(c)};case"Point":t=o(e.coordinates);break;case"MultiPoint":t=e.coordinates.map(o);break;case"LineString":t=s(e.arcs);break;case"MultiLineString":t=e.arcs.map(s);break;case"Polygon":t=l(e.arcs);break;case"MultiPolygon":t=e.arcs.map(l);break;default:return null}return{type:i,coordinates:t}}return c(t)}(e,t);return null==i&&null==n?{type:"Feature",properties:r,geometry:o}:null==n?{type:"Feature",id:i,properties:r,geometry:o}:{type:"Feature",id:i,bbox:n,properties:r,geometry:o}}class z{constructor(e){this.selectLayerIds=null,this.map=e,this.options={isHighlight:!0,highlightColor:"#FFFF00",lineWidth:5,fillOpacity:.3,circleRadius:10,tolerance:5,multiSelect:!0,onSelect:null,onContextMenu:null},this.highlightSourceId="highlight-feature-source",this.selectedFeatures=[],this._onClick=this._onClick.bind(this),this._onContextMenu=this._onContextMenu.bind(this)}setSelectLayers(e){e&&0!==e.length?this.selectLayerIds=e:this.selectLayerIds=null}setOptions(e){this.options=Object.assign(this.options,e),this.options.isHighlight?this._updateHighlightLayer():this.removeHighlightLayersOnly()}enable(){this.map.on("click",this._onClick),this.map.getCanvas().addEventListener("contextmenu",this._onContextMenu)}disable(){this.map.off("click",this._onClick),this.map.getCanvas().removeEventListener("contextmenu",this._onContextMenu),this.removeSelectedFeatures()}removeSelectedFeatures(){this.removeHighlightLayersOnly(),this.selectedFeatures=[]}removeHighlightLayersOnly(){["-line","-fill","-circle"].forEach(e=>{const t="highlight-feature"+e;this.map.getLayer(t)&&this.map.removeLayer(t)}),this.map.getSource(this.highlightSourceId)&&this.map.removeSource(this.highlightSourceId)}getSelected(){return this.selectedFeatures}_updateHighlightLayer(){const{highlightColor:e,lineWidth:t,fillOpacity:i,circleRadius:n}=this.options;0!==this.selectedFeatures.length?this.map.getSource(this.highlightSourceId)?this.map.getSource(this.highlightSourceId).setData({type:"FeatureCollection",features:this.selectedFeatures}):(this.map.addSource(this.highlightSourceId,{type:"geojson",data:{type:"FeatureCollection",features:this.selectedFeatures}}),this.map.addLayer({id:"highlight-feature-line",type:"line",source:this.highlightSourceId,paint:{"line-color":e,"line-width":t,"line-opacity":.8},filter:["any",["==",["geometry-type"],"LineString"],["==",["geometry-type"],"MultiLineString"]]}),this.map.addLayer({id:"highlight-feature-fill",type:"fill",source:this.highlightSourceId,paint:{"fill-color":e,"fill-opacity":i,"fill-outline-color":e},filter:["any",["==",["geometry-type"],"Polygon"],["==",["geometry-type"],"MultiPolygon"]]}),this.map.addLayer({id:"highlight-feature-circle",type:"circle",source:this.highlightSourceId,paint:{"circle-radius":n,"circle-color":e,"circle-opacity":.8,"circle-stroke-width":2,"circle-stroke-color":"#fff"},filter:["any",["==",["geometry-type"],"Point"],["==",["geometry-type"],"MultiPoint"]]})):this.removeSelectedFeatures()}_onClick(e){const{tolerance:t,multiSelect:i}=this.options,n=this.map.queryRenderedFeatures([[e.point.x-t,e.point.y-t],[e.point.x+t,e.point.y+t]]).find(e=>{if(e.layer&&"landLayer"===e.layer.id)return!1;if(this.selectLayerIds&&(!e.layer||!this.selectLayerIds.includes(e.layer.id)))return!1;const t=this.map.getLayer(e.layer.id);if(t&&"symbol"===t.type){return!this.map.getLayoutProperty(e.layer.id,"icon-image")}return!0});if(!n)return this.selectedFeatures=[],void(this.options.isHighlight&&this._updateHighlightLayer());if(i&&e.originalEvent&&e.originalEvent.ctrlKey){const e=n.id||JSON.stringify(n.geometry);this.selectedFeatures.some(t=>(t.id||JSON.stringify(t.geometry))===e)?this.selectedFeatures=this.selectedFeatures.filter(t=>(t.id||JSON.stringify(t.geometry))!==e):this.selectedFeatures.push(n)}else this.selectedFeatures=[n];if(this.options.isHighlight&&this._updateHighlightLayer(),"function"==typeof this.options.onSelect){const t=this.map.unproject(e.point);this.options.onSelect(t,n,this.selectedFeatures)}}_onContextMenu(e){e.preventDefault();const t=this.map.getCanvas().getBoundingClientRect(),i=e.clientX-t.left,n=e.clientY-t.top,{tolerance:r}=this.options,o=this.map.queryRenderedFeatures([[i-r,n-r],[i+r,n+r]]).find(e=>!(!e.layer||"landLayer"===e.layer.id)&&!(this.selectLayerIds&&!this.selectLayerIds.includes(e.layer.id)));if(o){const e=o?.properties;"function"==typeof this.options.onContextMenu&&this.options.onContextMenu(o,e)}return!1}}class F{constructor(e,t){this.fieldList=[],this.originalLayerList=[],this.isActive=!1,this.lastLineLayerVisibility=null,this.map=e,this.builtInKey="",this.lineLayerId="",this.lineLabelId="",this.suffix="_unique_label",this.fieldList=[],this.originalLabelLayer={},this.callback=t,this.boundExecute=this.execute.bind(this),this.boundOnStyleData=this.onStyleDataChange.bind(this),this.isActive=!1,this.lastLineLayerVisibility=null}get labelOptions(){return{builtInKey:this.builtInKey,lineLabelId:this.lineLabelId,lineLayerId:this.lineLayerId,suffix:this.suffix,fieldList:this.fieldList}}set labelOptions(e){this.builtInKey=e.builtInKey,this.lineLabelId=e.lineLabelId,this.lineLayerId=e.lineLayerId,this.suffix=e.suffix||"_unique_label",this.originalLabelLayer=this.map.getLayer(this.lineLabelId),this.originalLayerList=this.callback()[this.builtInKey]}getLineLayerVisibility(){try{return"none"!==this.map.getLayoutProperty(this.lineLayerId,"visibility")}catch(e){return!0}}onStyleDataChange(){const e=this.getLineLayerVisibility();null!==this.lastLineLayerVisibility&&this.lastLineLayerVisibility!==e&&this.handleLineLayerVisibilityChange(e),this.lastLineLayerVisibility=e}handleLineLayerVisibilityChange(e){e?this.isActive?(this.hideOriginalLabelLayer(),this.showDeduplicatedLabelLayer()):this.showOriginalLabelLayer():(this.hideOriginalLabelLayer(),this.hideDeduplicatedLabelLayer())}hideOriginalLabelLayer(){this.originalLayerList.forEach(e=>{e.includes(this.lineLabelId)&&this.map.setLayoutProperty(e,"visibility","none")})}showOriginalLabelLayer(){this.originalLayerList.forEach(e=>{e.includes(this.lineLabelId)&&this.map.setLayoutProperty(e,"visibility","visible")})}hideDeduplicatedLabelLayer(){const e=this.lineLabelId+this.suffix;this.map.getLayer(e)&&this.map.setLayoutProperty(e,"visibility","none")}showDeduplicatedLabelLayer(){const e=this.lineLabelId+this.suffix;this.map.getLayer(e)&&this.map.setLayoutProperty(e,"visibility","visible")}execute(){if(!this.originalLabelLayer||!this.isActive)return;const e=this.originalLabelLayer.minzoom||0,t=this.map.getZoom(),i=this.lineLabelId+this.suffix;if(!this.getLineLayerVisibility())return this.map.getLayer(i)&&this.map.setLayoutProperty(i,"visibility","none"),void this.hideOriginalLabelLayer();if(t<e)return this.map.getLayer(i)&&this.map.setLayoutProperty(i,"visibility","none"),void this.showOriginalLabelLayer();if(this.hideOriginalLabelLayer(),!this.map)return;const n=this.fieldList.length>0?this.fieldList:["txtDesig","txtDesigForward","txtDesigBackward"];let r=this.map.queryRenderedFeatures({layers:[this.lineLayerId]});r.length>500&&(r=r.slice(0,500));const o=this.map.getCenter(),s=new Map,a=(e,t)=>{let i=e;for(;i-t>180;)i-=360;for(;i-t<-180;)i+=360;return i};for(const e of r){if(!e.geometry||"LineString"!==e.geometry.type)continue;const t=e.geometry.coordinates;if(!t||t.length<2)continue;const i=n.map(t=>e.properties?e.properties[t]:void 0).find(e=>"string"==typeof e&&""!==e.trim())||"未知",r=Math.floor(t.length/2),l=t[r];if(!l)continue;const c=a(l[0],o.lng),u=this.map.project([c,l[1]]),h=this.map.project([o.lng,o.lat]),d=Math.hypot(u.x-h.x,u.y-h.y);if(s.has(i)&&d>=s.get(i).pixelDist)continue;const p=3,f=Math.max(0,r-p),m=Math.min(t.length-1,r+p);let g=0,y=0;for(let e=f;e<m;e++){const i=t[e],n=t[e+1];if(!i||!n)continue;const o=a(i[0],t[r][0]),s=a(n[0],t[r][0]),l=this.map.project([o,i[1]]),c=this.map.project([s,n[1]]);g+=c.x-l.x,y+=c.y-l.y}if(0===g&&0===y&&t.length>1){const e=t[Math.max(r-1,0)],i=t[Math.min(r+1,t.length-1)];if(e&&i){const n=a(e[0],t[r][0]),o=a(i[0],t[r][0]),s=this.map.project([n,e[1]]),l=this.map.project([o,i[1]]);g=l.x-s.x,y=l.y-s.y}}let _=180*Math.atan2(y,g)/Math.PI;_>90&&(_-=180),_<-90&&(_+=180);const v={...e.properties,angle:_};s.set(i,{geometry:e.geometry,properties:v,pixelDist:d})}if(0===s.size)return;const l={type:"FeatureCollection",features:Array.from(s.values()).map(e=>{const t=e.geometry.coordinates,i=Math.floor(t.length/2),n=Math.max(0,i-2),r=Math.min(t.length-1,i+2);return{type:"Feature",geometry:{type:"LineString",coordinates:t.slice(n,r+1)},properties:e.properties}})},{layout:c,paint:u}=this.cloneLayerStyle(this.map,this.lineLabelId),h=this.lineLabelId+this.suffix,d=this.originalLabelLayer.type||"symbol";this.map.getSource(h)?this.map.getSource(h).setData(l):(this.map.addSource(h,{type:"geojson",data:l}),this.map.addLayer({id:i,type:d,source:h,layout:c,paint:u,minzoom:e})),this.map.getLayer(i)&&this.map.setLayoutProperty(i,"visibility","visible")}update(){this.isActive||(this.isActive=!0,this.lastLineLayerVisibility=this.getLineLayerVisibility(),this.map.on("data",this.boundOnStyleData),this.map.isMoving&&this.map.isMoving()?this.map.once("idle",()=>{this.execute(),this.map.on("moveend",this.boundExecute)}):(this.execute(),this.map.on("moveend",this.boundExecute)))}remove(){if(!this.originalLabelLayer)return;this.isActive=!1,this.lastLineLayerVisibility=null,this.map.off("moveend",this.boundExecute),this.map.off("data",this.boundOnStyleData),this.showOriginalLabelLayer();const e=this.lineLabelId+this.suffix,t=this.lineLabelId+this.suffix;try{this.map.getLayer(e)&&this.map.removeLayer(e),this.map.getSource(t)&&this.map.removeSource(t)}catch(e){}}cloneLayerStyle(e,t){const i=e.getStyle().layers.find(e=>e.id===t);if(!i)return null;const n={...i.layout},r={...i.paint};return n.visibility="visible",n["symbol-placement"]="line",n["symbol-spacing"]=500,{layout:n,paint:r}}}class O{constructor(e){this.ARRAY_STYLE_KEYS=["amm","controlled","restricted","airspace"],this.layerExists=e=>{try{return void 0!==this.map.getLayer(e)}catch(e){return!0}},this.setStyle=e=>{e&&"object"==typeof e&&(this.handleNormalLayers(e),this.handleArrayLayers(e))},this.map=e}applyLayerStyle(e,t,i=!0){if(e&&"string"==typeof e&&t&&"object"==typeof t&&(!i||this.layerExists(e))){if(t.paint&&"object"==typeof t.paint)try{Object.entries(t.paint).forEach(([t,i])=>{t&&null!=i&&this.map.setPaintProperty(e,t,i)})}catch(e){}if(t.layout&&"object"==typeof t.layout)try{Object.entries(t.layout).forEach(([t,i])=>{t&&null!=i&&this.map.setLayoutProperty(e,t,i)})}catch(e){}}}handleNormalLayers(e){for(const[t,i]of Object.entries(e))this.ARRAY_STYLE_KEYS.includes(t)||this.applyLayerStyle(t,i)}handleArrayLayers(e){for(const t of this.ARRAY_STYLE_KEYS){const i=e[t];if(Array.isArray(i)&&0!==i.length)for(const e of i)if(e&&"object"==typeof e&&!Array.isArray(e))for(const[t,i]of Object.entries(e))i&&"object"==typeof i&&this.applyLayerStyle(t,i)}}}const N="https://aips.siniswift.com";function B(e,t){return`${e.replace(/\/$/,"")}/api/tiles/${t}/{z}/{x}/{y}.pbf`}const G=["interpolate",["linear"],["elevation"],0,"#a8c98a",600,"#cdd98a",1200,"#e8d79a",2400,"#c79a5b",3600,"#9c6b3f",4500,"#f2efe9"];async function j(e,t={}){const i=await fetch(e,{headers:t});if(!i.ok)throw new Error(`fetch ${e} → ${i.status}`);const n=i.headers.get("Content-Encoding"),r=i.headers.get("Content-Type")||"";if("gzip"===n||r.includes("json"))return i.json();const o=i.body.pipeThrough(new DecompressionStream("gzip"));return new Response(o).json()}const V={airspaceStroke:"#AAB7B8",restrictedStroke:"#D35400",controlledStroke:"#10B981",controlledFill:"#10B981",segment:"#2E4053",waypoint:"#1C2526",vor:"#00008B",ndb:"#0066CC",airport:"#006400",runway:"#333333"};const U={airspaceStroke:"#18C29C",restrictedStroke:"#CC7722",controlledStroke:"#22C55E",controlledFill:"#22C55E",segment:"#40C4FF",waypoint:"#74cdde",vor:"#72aae5",ndb:"#62d6ef",airport:"#73ccdd",runway:"#64748b"};const q={light:{id:"light",label:"日间",background:"#EAF2F8",build:function(){const e="navdata";return[{id:"landLayer",type:"fill",source:"land",layout:{visibility:"visible"},paint:{"fill-color":"#F7F9FB","fill-opacity":1}},{id:"boundary",type:"line",source:"boundary",minzoom:.5,paint:{"line-width":["interpolate",["linear"],["zoom"],0,1,7,4],"line-opacity":1,"line-pattern":"normal:national-border"}},{id:"adiz-line",type:"line",source:e,"source-layer":"adiz",minzoom:3,layout:{"line-cap":"round","line-join":"round"},paint:{"line-width":4,"line-pattern":"normal:adiz","line-opacity":["interpolate",["linear"],["zoom"],3,.6,8,.4]}},{id:"adiz-label",type:"symbol",source:e,"source-layer":"adiz-centroid",minzoom:3,layout:{"text-field":["coalesce",["get","TXT_NAME"],["get","CODE_ID"]],"text-size":10,"text-max-width":10,"symbol-placement":"point"},paint:{"text-color":"#6600cc","text-halo-color":"#ffffff","text-halo-width":1.5}},{id:"airspaceLayer",type:"line",source:e,"source-layer":"fir",minzoom:2,paint:{"line-color":V.airspaceStroke,"line-opacity":["interpolate",["linear"],["zoom"],2,0,2.7,.8,9,.8,10,.5],"line-width":.5,"line-dasharray":[4.2,4]}},{id:"airspaceLayer_line",type:"line",source:e,"source-layer":"fir",minzoom:5,layout:{"line-miter-limit":0,"line-cap":"butt","line-join":"miter"},paint:{"line-color":V.airspaceStroke,"line-opacity":["interpolate",["linear"],["zoom"],5,0,5.5,.8,9,.8,10,.5],"line-width":6,"line-dasharray":[.2,5]}},{id:"airspace_label_side_layer",type:"symbol",source:e,"source-layer":"fir",minzoom:4,layout:{"text-field":["concat",["get","TXT_NAME"],"/",["get","CODE_ID"],"/",["get","CODE_TYPE"]],"text-size":10,"symbol-placement":"line","text-max-width":8,"text-offset":[0,1],"text-letter-spacing":.05,"text-optional":!0},paint:{"text-color":V.airspaceStroke}},{id:"airspace_label_center_layer",type:"symbol",source:e,"source-layer":"fir-centroid",minzoom:3,layout:{"text-field":["coalesce",["get","TXT_NAME"],["get","CODE_ID"]],"text-size":["interpolate",["linear"],["zoom"],3,12,17,16],"symbol-placement":"point","text-max-width":8},paint:{"text-color":V.airspaceStroke,"text-opacity":["interpolate",["linear"],["zoom"],3,.85,8,.7,12,.5]}},{id:"restrictedLayer",type:"fill",source:e,"source-layer":"restricted-fill",minzoom:4,paint:{"fill-color":"#FAD7A0","fill-opacity":["interpolate",["linear"],["zoom"],10,.15,11.5,0]}},{id:"restrictedLayer_stroke",type:"line",source:e,"source-layer":"restricted",paint:{"line-color":"#f6bf65","line-width":1,"line-dasharray":[2,2],"line-opacity":["interpolate",["linear"],["zoom"],4,.5,8,1]}},{id:"restricted_line_label",type:"symbol",source:e,"source-layer":"restricted",minzoom:6,layout:{"text-field":["concat",["get","TXT_NAME"],"/",["get","CODE_ID"],"/",["get","CODE_TYPE"]],"text-letter-spacing":.1,"text-size":10,"symbol-placement":"line","text-max-width":8,"text-offset":[0,1]},paint:{"text-color":V.restrictedStroke}},{id:"controlledLayer",type:"fill",source:e,"source-layer":"controlled-fill",minzoom:4,paint:{"fill-color":V.controlledFill,"fill-opacity":["interpolate",["linear"],["zoom"],10,.035,11.5,0]}},{id:"controlledLayer_stroke",type:"line",source:e,"source-layer":"controlled",paint:{"line-color":V.controlledStroke,"line-width":1,"line-opacity":["interpolate",["linear"],["zoom"],4,.5,8,1],"line-dasharray":[1,1.4]}},{id:"controlled_line_label",type:"symbol",source:e,"source-layer":"controlled",minzoom:6,layout:{"text-field":["concat",["get","TXT_NAME"],"/",["get","CODE_ID"],"/",["get","CODE_TYPE"]],"text-size":10,"symbol-placement":"line","text-letter-spacing":.2,"text-max-width":8,"text-offset":[0,1]},paint:{"text-color":V.controlledStroke}},{id:"airline",type:"line",source:e,"source-layer":"segment",minzoom:5,paint:{"line-color":["case",["==",["get","HAS_REMARK"],1],"#E8A020",V.segment],"line-width":["interpolate",["linear"],["zoom"],5,.2,8,.8],"line-blur":0,"line-opacity":["interpolate",["linear"],["zoom"],5,.3,6,1,8,1,12,.8,15,.2]}},{id:"airline_label",type:"symbol",source:e,"source-layer":"segment",minzoom:6,layout:{"icon-image":["case",["all",["has","TXT_DESIG"],["!=",["get","TXT_DESIG"],""],["!=",["get","TXT_DESIG"]," "],["!=",["get","TXT_DESIG"],null]],"segment-both",["all",["has","TXT_DESIG_FORWARD"]],"segment-right",["all",["has","TXT_DESIG_BACKWARD"]],"segment-left","segment-both"],"icon-anchor":"center","symbol-placement":"line","icon-text-fit":"width","icon-size":1,"text-allow-overlap":!1,"icon-allow-overlap":!1,"text-optional":!1,"text-anchor":"center","text-justify":"center","text-line-height":1.3,"text-letter-spacing":.1,"text-field":["step",["zoom"],["format",["case",["all",["has","TXT_DESIG"],["!=",["get","TXT_DESIG"],""]],["get","TXT_DESIG"],["all",["has","TXT_DESIG_FORWARD"],["!=",["get","TXT_DESIG_FORWARD"],""]],["get","TXT_DESIG_FORWARD"],["all",["has","TXT_DESIG_BACKWARD"],["!=",["get","TXT_DESIG_BACKWARD"],""]],["get","TXT_DESIG_BACKWARD"],"-"],{"font-scale":1,"text-color":"#ffffff"}],10,["format",["concat",["get","VAL_LEN"],"",["get","UOM_DIST"]],{"font-scale":.95,"text-color":"#3E4759"},"\n",["case",["all",["has","TXT_DESIG_FORWARD"],["!=",["get","TXT_DESIG_FORWARD"],""]],["case",["all",["has","TXT_DESIG_RNP"],["!=",["get","TXT_DESIG_RNP"],""]],["get","TXT_DESIG_RNP"],""],""],{"font-scale":1,"text-color":"#E8A020"},["case",["all",["has","TXT_DESIG_FORWARD"],["!=",["get","TXT_DESIG_FORWARD"],""]],["case",["all",["has","TXT_DESIG_RNP"],["!=",["get","TXT_DESIG_RNP"],""]]," ",""],""],{},["case",["all",["has","TXT_DESIG_FORWARD"],["!=",["get","TXT_DESIG_FORWARD"],""]],["get","TXT_DESIG_FORWARD"],["all",["has","TXT_DESIG"],["!=",["get","TXT_DESIG"],""]],["get","TXT_DESIG"],["all",["has","TXT_DESIG_BACKWARD"],["!=",["get","TXT_DESIG_BACKWARD"],""]],["get","TXT_DESIG_BACKWARD"],"-"],{"font-scale":1,"text-color":"#ffffff","font-weight":"bold"},["case",["all",["has","TXT_DESIG_FORWARD"],["!=",["get","TXT_DESIG_FORWARD"],""]],"",["case",["all",["has","TXT_DESIG_RNP"],["!=",["get","TXT_DESIG_RNP"],""]]," ",""]],{},["case",["all",["has","TXT_DESIG_FORWARD"],["!=",["get","TXT_DESIG_FORWARD"],""]],"",["case",["all",["has","TXT_DESIG_RNP"],["!=",["get","TXT_DESIG_RNP"],""]],["get","TXT_DESIG_RNP"],""]],{"font-scale":.85,"text-color":"#E8A020"},"\n",["case",["all",["has","TXT_DESIG_HIGH"],["!=",["get","TXT_DESIG_HIGH"],""]],["get","TXT_DESIG_HIGH"],["all",["has","TXT_DESIG_FORWARD"],["!=",["get","TXT_DESIG_FORWARD"],""]],["get","TXT_DESIG_FORWARD"],["all",["has","TXT_DESIG_BACKWARD"],["!=",["get","TXT_DESIG_BACKWARD"],""]],["get","TXT_DESIG_BACKWARD"],"-"],{"font-scale":.95,"text-color":"#3E4759"}]],"text-size":["interpolate",["linear"],["zoom"],6,9,10,10],"icon-text-fit-padding":[0,3,0,3]},paint:{"text-halo-color":"#ffffff","text-halo-width":.1,"icon-color":V.segment,"text-opacity":["interpolate",["linear"],["zoom"],6,1,12,1,15,.3],"icon-opacity":["interpolate",["linear"],["zoom"],6,1,12,1,15,.3]}},{id:"airline_radial",type:"symbol",source:e,"source-layer":"segment-radial",minzoom:10,layout:{"text-field":["concat",["get","bearing"],"°"],"text-size":9,"text-rotate":["to-number",["get","line_angle"],0],"text-rotation-alignment":"map","text-allow-overlap":!0,"text-ignore-placement":!0,"text-offset":[0,-.6],"text-justify":"auto"},paint:{"text-color":V.segment}},{id:"airport",type:"symbol",source:e,minzoom:3,"source-layer":"airport",filter:["case",["<",["zoom"],6],["==",["get","level"],1],!0],layout:{"icon-image":["case",["==",["get","CODE_TYPE_MIL_OPS"],"MIL"],"airport-mil",["==",["get","CODE_TYPE_MIL_OPS"],"MILEXT"],"airport-milext","airport-civ"],"icon-size":["interpolate",["linear"],["zoom"],4,.5,10,.9],"symbol-z-order":"viewport-y","text-field":["get","codeId"],"text-letter-spacing":.05,"text-field":["get","CODE_ID"],"text-anchor":"bottom","text-justify":"center","text-size":["interpolate",["linear"],["zoom"],4,0,5,12],"text-offset":["interpolate",["linear"],["zoom"],4,["literal",[0,-1.2]],5,["literal",[0,-.6]]],"icon-allow-overlap":!0,"icon-ignore-placement":!0,"text-allow-overlap":!0,"text-ignore-placement":!0,visibility:"none","icon-size":["interpolate",["linear"],["zoom"],5,.6,9,1.2,12,1.3]},paint:{"icon-color":["case",["has","has_amm"],"#4B2D6E",V.airport],"icon-opacity":["interpolate",["linear"],["zoom"],2,.75,3,.95,5,1,9,1,11,.2],"text-color":["case",["has","has_amm"],"#4B2D6E",V.airport],"text-opacity":["interpolate",["linear"],["zoom"],4,.95,5,1,9,1,11,.2]}},{id:"runway-line",type:"line",source:e,"source-layer":"runway",filter:["!",["has","has_amm"]],minzoom:4,maxzoom:11,paint:{"line-color":V.runway,"line-width":["interpolate",["linear"],["zoom"],4,1,13,10]}},{id:"runway-line-amm",type:"line",source:e,"source-layer":"runway",filter:["has","has_amm"],minzoom:4,maxzoom:11,paint:{"line-color":V.runway,"line-width":["interpolate",["linear"],["zoom"],4,1,10,4],"line-opacity":["interpolate",["linear"],["zoom"],10.5,1,11,0]}},{id:"runway-label",type:"symbol",source:e,"source-layer":"runway",minzoom:10,layout:{"text-field":["concat",["to-string",["get","VAL_LEN"]],"×",["to-string",["get","VAL_WID"]],"m"],"text-size":10,"symbol-placement":"line-center","text-rotation-alignment":"map","text-optional":!0},paint:{"text-color":V.runway,"text-halo-width":1,"text-opacity":["interpolate",["linear"],["zoom"],10.5,1,11,0]}},{id:"vor_icon_dial",type:"symbol",source:e,"source-layer":"vor",minzoom:8,layout:{"icon-image":"vor_dial","icon-size":["interpolate",["linear"],["zoom"],8,.072,10,.072,11,.126,12,.18,13,.234,14,.288,15,.342,16,.396,17,.45,22,.45],"icon-rotate":["to-number",["get","VAL_MAG_VAR"],0],"icon-rotation-alignment":"map","symbol-z-order":"viewport-y","text-letter-spacing":.05,"text-optional":!0,"icon-allow-overlap":!0,visibility:"none"},paint:{"icon-color":"#0b417a"}},{id:"vor_icon",minzoom:4,maxzoom:9,type:"symbol",source:e,"source-layer":"vor",layout:{"icon-image":"v2:vor-normal","icon-size":["interpolate",["linear"],["zoom"],4,.7,8,1],"icon-rotation-alignment":"map","symbol-z-order":"viewport-y","text-letter-spacing":.05,"text-optional":!0,"icon-allow-overlap":!0},paint:{"icon-color":"#3874cb","icon-opacity":["interpolate",["linear"],["zoom"],8,1,9,0]}},{id:"vor_label",type:"symbol",source:e,"source-layer":"vor",minzoom:5,layout:{"text-field":["get","CODE_ID"],"text-size":10,"text-anchor":"bottom","text-offset":[0,-.8]},paint:{"text-color":V.vor,"text-halo-color":"#ffffff","text-halo-width":1}},{id:"ndb_icon",type:"symbol",source:e,minzoom:4,"source-layer":"ndb",layout:{"icon-image":"v2:ndb-normal","icon-size":["interpolate",["linear"],["zoom"],6,.5,10,1],"symbol-z-order":"viewport-y","text-field":["format",["get","CODE_ID"],{"text-color":V.ndb,"font-scale":1.1},"",{},["coalesce",["get","VAL_FREQ"],""],{"text-color":V.ndb,"font-scale":.95}],"text-size":10,"text-offset":[0,.5],"text-letter-spacing":.05,"text-optional":!0,"icon-allow-overlap":!0,"text-anchor":"top"},paint:{"text-color":V.ndb,"text-halo-color":"#ffffff","text-halo-width":.5,"text-halo-blur":1,"icon-color":V.ndb,"text-opacity":["interpolate",["linear"],["zoom"],4,0,5.5,0,6,.6,8,1,10,.3,12,0],"icon-opacity":["interpolate",["linear"],["zoom"],4,0,5,.3,5.5,.8,8,1,12,1,14,.6]}},{id:"airline_point",type:"symbol",source:e,"source-layer":"waypoint",minzoom:5,layout:{"icon-image":["case",["==",["get","report_type"],"C"],"waypoint-compusory","waypoint"],"icon-size":.6,"icon-allow-overlap":!0,"icon-ignore-placement":!0,"text-field":["get","CODE_ID"],"text-size":10,"text-letter-spacing":.02,"text-variable-anchor-offset":["bottom",[0,-.6],"top",[0,.6],"right",[-.6,0],"left",[.6,0],"bottom-right",[-.4,-.4],"bottom-left",[.4,-.4],"top-right",[-.4,.4],"top-left",[.4,.4]],"text-justify":"auto"},paint:{"icon-color":V.waypoint,"text-color":V.waypoint,"text-halo-color":"#ffffff","text-halo-width":1,"icon-halo-color":"rgba(0,0,0,0)","icon-halo-width":0,"icon-opacity":["interpolate",["linear"],["zoom"],5,.5,12,1,15,.2],"text-halo-color":"#FFFFFF","text-halo-blur":0,"text-opacity":["interpolate",["linear"],["zoom"],6,1,12,.9,15,.15]}},{id:"waypoint-off-airway-symbol",type:"symbol",source:e,"source-layer":"waypoint-off-airway",minzoom:7,layout:{"icon-image":["case",["==",["get","report_type"],"C"],"designate_point_inway","designate_point_notinway"],"icon-size":.6,"icon-allow-overlap":!0,"icon-ignore-placement":!0,"text-field":["get","CODE_ID"],"text-size":9,"text-variable-anchor-offset":["bottom",[0,-.6],"top",[0,.6],"right",[-.6,0],"left",[.6,0],"bottom-right",[-.4,-.4],"bottom-left",[.4,-.4],"top-right",[-.4,.4],"top-left",[.4,.4]],"text-justify":"auto","text-optional":!0},paint:{"icon-color":V.waypoint,"text-color":V.waypoint,"text-halo-color":"#ffffff","text-halo-width":1,"icon-opacity":["interpolate",["linear"],["zoom"],7,.5,12,1,15,.2],"text-opacity":["interpolate",["linear"],["zoom"],7,1,12,.9,15,.15]}}]}},dark:{id:"dark",label:"夜间",background:"#000000",build:function(){const e="navdata";return[{id:"landLayer",type:"fill",source:"land",layout:{visibility:"visible"},paint:{"fill-color":"#0A111A","fill-opacity":1}},{id:"boundary",type:"line",source:"boundary",minzoom:.5,paint:{"line-width":["interpolate",["linear"],["zoom"],0,1,7,4],"line-opacity":1,"line-pattern":"normal:national-border-dark"}},{id:"adiz-line",type:"line",source:e,"source-layer":"adiz",minzoom:3,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#a855f7","line-width":["interpolate",["linear"],["zoom"],3,3,7,6],"line-pattern":"normal:adiz","line-opacity":["interpolate",["linear"],["zoom"],3,.7,8,.5]}},{id:"adiz-label",type:"symbol",source:e,"source-layer":"adiz-centroid",minzoom:3,layout:{"text-field":["coalesce",["get","TXT_NAME"],["get","CODE_ID"]],"text-size":10,"text-max-width":10,"symbol-placement":"point"},paint:{"text-color":"#c084fc","text-halo-color":"#0f172a","text-halo-width":1.5}},{id:"airspaceLayer",type:"line",source:e,"source-layer":"fir",minzoom:2,layout:{"line-cap":"butt","line-join":"miter","line-miter-limit":0},paint:{"line-color":U.airspaceStroke,"line-opacity":["interpolate",["linear"],["zoom"],2,0,2.7,.8,9,.8,10,.5],"line-width":.8,"line-dasharray":[4.2,4]}},{id:"airspaceLayer_line",type:"line",source:e,"source-layer":"fir",minzoom:5,layout:{"line-miter-limit":0,"line-cap":"butt","line-join":"miter"},paint:{"line-color":U.airspaceStroke,"line-opacity":["interpolate",["linear"],["zoom"],5,0,5.5,.8,9,.8,10,.5],"line-width":5,"line-dasharray":[.2,5]}},{id:"airspace_label_side_layer",type:"symbol",source:e,"source-layer":"fir",minzoom:4,layout:{"text-field":["concat",["get","TXT_NAME"],"/",["get","CODE_ID"],"/",["get","CODE_TYPE"]],"text-size":10,"symbol-placement":"line","text-max-width":8,"text-offset":[0,1],"text-letter-spacing":.05,"text-optional":!0},paint:{"text-color":U.airspaceStroke,"text-halo-color":"#0f172a","text-halo-width":1}},{id:"airspace_label_center_layer",type:"symbol",source:e,"source-layer":"fir-centroid",minzoom:3,layout:{"text-field":["coalesce",["get","TXT_NAME"],["get","CODE_ID"]],"text-size":["interpolate",["linear"],["zoom"],3,12,17,16],"symbol-placement":"point","text-max-width":8},paint:{"text-color":U.airspaceStroke,"text-halo-color":"#0f172a","text-halo-width":1.5,"text-opacity":["interpolate",["linear"],["zoom"],3,.85,8,.7,12,.5]}},{id:"restrictedLayer",type:"fill",source:e,"source-layer":"restricted-fill",minzoom:4,paint:{"fill-color":["case",["==",["get","CODE_TYPE"],"P"],"#ef4444",["==",["get","CODE_TYPE"],"D"],"#f97316","#ef4444"],"fill-opacity":.04}},{id:"restrictedLayer_stroke",type:"line",source:e,"source-layer":"restricted",paint:{"line-color":U.restrictedStroke,"line-width":1,"line-dasharray":[2,2],"line-opacity":["interpolate",["linear"],["zoom"],4,.6,8,1]}},{id:"restricted_line_label",type:"symbol",source:e,"source-layer":"restricted",minzoom:6,layout:{"text-field":["coalesce",["get","TXT_NAME"],["get","CODE_ID"]],"text-size":10,"symbol-placement":"line","text-max-width":8,"text-offset":[0,1]},paint:{"text-color":U.restrictedStroke,"text-halo-color":"#0f172a","text-halo-width":1}},{id:"controlledLayer",type:"fill",source:e,"source-layer":"controlled-fill",minzoom:4,paint:{"fill-color":U.controlledFill,"fill-opacity":["interpolate",["linear"],["zoom"],10,.04,11.5,0]}},{id:"controlledLayer_stroke",type:"line",source:e,"source-layer":"controlled",paint:{"line-color":U.controlledStroke,"line-width":1,"line-opacity":["interpolate",["linear"],["zoom"],4,.6,8,1],"line-dasharray":[4,2]}},{id:"controlled_line_label",type:"symbol",source:e,"source-layer":"controlled",minzoom:6,layout:{"text-field":["coalesce",["get","TXT_NAME"],["get","CODE_ID"]],"text-size":10,"symbol-placement":"point","text-max-width":8},paint:{"text-color":U.controlledStroke,"text-halo-color":"#0f172a","text-halo-width":1.5}},{id:"airline",type:"line",source:e,"source-layer":"segment",minzoom:5,paint:{"line-color":["case",["==",["get","HAS_REMARK"],1],"#fbbf24",U.segment],"line-width":["interpolate",["linear"],["zoom"],5,.2,8,.8],"line-blur":0,"line-opacity":["interpolate",["linear"],["zoom"],5,.3,6,1,8,1,12,.8,15,.2]}},{id:"airline_label",type:"symbol",source:e,"source-layer":"segment",minzoom:6,layout:{"icon-image":["case",["all",["has","TXT_DESIG"],["!=",["get","TXT_DESIG"],""],["!=",["get","TXT_DESIG"]," "],["!=",["get","TXT_DESIG"],null]],"segment-both",["all",["has","TXT_DESIG_FORWARD"]],"segment-right",["all",["has","TXT_DESIG_BACKWARD"]],"segment-left","segment-both"],"icon-anchor":"center","symbol-placement":"line","icon-text-fit":"width","icon-size":1,"text-allow-overlap":!1,"icon-allow-overlap":!1,"text-anchor":"center","text-justify":"center","text-line-height":1.3,"text-letter-spacing":.1,"text-field":["step",["zoom"],["format",["case",["all",["has","TXT_DESIG"],["!=",["get","TXT_DESIG"],""]],["get","TXT_DESIG"],["all",["has","TXT_DESIG_FORWARD"],["!=",["get","TXT_DESIG_FORWARD"],""]],["get","TXT_DESIG_FORWARD"],["all",["has","TXT_DESIG_BACKWARD"],["!=",["get","TXT_DESIG_BACKWARD"],""]],["get","TXT_DESIG_BACKWARD"],"-"],{"font-scale":1,"text-color":"#0f172a"}],10,["format",["concat",["get","VAL_LEN"],"",["get","UOM_DIST"]],{"font-scale":.95,"text-color":"#cbd5e1"},"\n",["case",["all",["has","TXT_DESIG_FORWARD"],["!=",["get","TXT_DESIG_FORWARD"],""]],["case",["all",["has","TXT_DESIG_RNP"],["!=",["get","TXT_DESIG_RNP"],""]],["get","TXT_DESIG_RNP"],""],""],{"font-scale":1,"text-color":"#FFFFFF"},["case",["all",["has","TXT_DESIG_FORWARD"],["!=",["get","TXT_DESIG_FORWARD"],""]],["case",["all",["has","TXT_DESIG_RNP"],["!=",["get","TXT_DESIG_RNP"],""]]," ",""],""],{},["case",["all",["has","TXT_DESIG_FORWARD"],["!=",["get","TXT_DESIG_FORWARD"],""]],["get","TXT_DESIG_FORWARD"],["all",["has","TXT_DESIG"],["!=",["get","TXT_DESIG"],""]],["get","TXT_DESIG"],["all",["has","TXT_DESIG_BACKWARD"],["!=",["get","TXT_DESIG_BACKWARD"],""]],["get","TXT_DESIG_BACKWARD"],"-"],{"font-scale":1,"text-color":"#0f172a","font-weight":"bold"},["case",["all",["has","TXT_DESIG_FORWARD"],["!=",["get","TXT_DESIG_FORWARD"],""]],"",["case",["all",["has","TXT_DESIG_RNP"],["!=",["get","TXT_DESIG_RNP"],""]]," ",""]],{},["case",["all",["has","TXT_DESIG_FORWARD"],["!=",["get","TXT_DESIG_FORWARD"],""]],"",["case",["all",["has","TXT_DESIG_RNP"],["!=",["get","TXT_DESIG_RNP"],""]],["get","TXT_DESIG_RNP"],""]],{"font-scale":.85,"text-color":"#FFFFFF"},"\n",["case",["all",["has","TXT_DESIG_HIGH"],["!=",["get","TXT_DESIG_HIGH"],""]],["get","TXT_DESIG_HIGH"],["all",["has","TXT_DESIG_FORWARD"],["!=",["get","TXT_DESIG_FORWARD"],""]],["get","TXT_DESIG_FORWARD"],["all",["has","TXT_DESIG_BACKWARD"],["!=",["get","TXT_DESIG_BACKWARD"],""]],["get","TXT_DESIG_BACKWARD"],"-"],{"font-scale":.95,"text-color":"#cbd5e1"}]],"text-size":["interpolate",["linear"],["zoom"],6,9,10,10],"icon-text-fit-padding":[0,3,0,3]},paint:{"icon-color":U.segment}},{id:"airline_radial",type:"symbol",source:e,"source-layer":"segment-radial",minzoom:10,layout:{"text-field":["concat",["get","bearing"],"°"],"text-size":9,"text-rotate":["to-number",["get","line_angle"],0],"text-rotation-alignment":"map","text-allow-overlap":!0,"text-ignore-placement":!0,"text-offset":[0,-1]},paint:{"text-color":U.segment,"text-halo-color":"#0f172a","text-halo-width":1}},{id:"airport",type:"symbol",source:e,minzoom:3,"source-layer":"airport",filter:["case",["<",["zoom"],6],["==",["get","level"],1],!0],layout:{"icon-image":["case",["==",["get","CODE_TYPE_MIL_OPS"],"MIL"],"airport-mil",["==",["get","CODE_TYPE_MIL_OPS"],"MILEXT"],"airport-milext","airport-civ"],"icon-size":["interpolate",["linear"],["zoom"],4,.5,10,.9],"symbol-z-order":"viewport-y","text-field":["get","codeId"],"text-letter-spacing":.05,"text-anchor":"bottom","text-field":["get","CODE_ID"],"text-justify":"center","text-size":["interpolate",["linear"],["zoom"],4,0,5,12],"text-offset":["interpolate",["linear"],["zoom"],4,["literal",[0,-1.2]],5,["literal",[0,-.6]]],"icon-allow-overlap":!0,"icon-ignore-placement":!0,"text-allow-overlap":!0,"text-ignore-placement":!0,visibility:"none","icon-size":["interpolate",["linear"],["zoom"],5,.6,9,1.2,12,1.3]},paint:{"icon-color":["case",["has","has_amm"],"#4B2D6E",U.airport],"icon-opacity":["interpolate",["linear"],["zoom"],2,.75,3,.95,5,1,9,1,11,.2],"text-color":["case",["has","has_amm"],"#4B2D6E","#E0F7FA"],"text-opacity":["interpolate",["linear"],["zoom"],4,.95,5,1,9,1,11,.2]}},{id:"runway-line",type:"line",source:e,"source-layer":"runway",filter:["!",["has","has_amm"]],minzoom:4,paint:{"line-color":U.runway,"line-width":["interpolate",["linear"],["zoom"],4,1,10,3]}},{id:"runway-line-amm",type:"line",source:e,"source-layer":"runway",filter:["has","has_amm"],minzoom:4,paint:{"line-color":U.runway,"line-width":["interpolate",["linear"],["zoom"],4,1,10,3],"line-opacity":["interpolate",["linear"],["zoom"],10.5,1,11,0]}},{id:"runway-label",type:"symbol",source:e,"source-layer":"runway",minzoom:10,layout:{"text-field":["concat",["to-string",["get","VAL_LEN"]],"×",["to-string",["get","VAL_WID"]],"m"],"text-size":10,"text-font":["Noto Sans Regular"],"symbol-placement":"line-center","text-rotation-alignment":"map","text-optional":!0},paint:{"text-color":U.runway,"text-halo-color":"#0f172a","text-halo-width":1,"text-opacity":["interpolate",["linear"],["zoom"],10.5,1,11,0]}},{id:"vor_icon_dial",type:"symbol",source:e,"source-layer":"vor",layout:{"icon-image":"vor_dial","icon-size":["interpolate",["linear"],["zoom"],5,.072,10,.072,11,.126,12,.18,13,.234,14,.288,15,.342,16,.396,17,.45,22,.45],"icon-rotate":["to-number",["get","VAL_MAG_VAR"],0],"icon-rotation-alignment":"map","symbol-z-order":"viewport-y","text-letter-spacing":.05,"text-optional":!0,"icon-allow-overlap":!0,visibility:"none"},paint:{"icon-color":"#38bdf8"}},{id:"vor_icon",minzoom:4,maxzoom:9,type:"symbol",source:e,"source-layer":"vor",layout:{"icon-image":"v2:vor-normal","icon-size":["interpolate",["linear"],["zoom"],4,.7,8,1],"icon-rotation-alignment":"map","symbol-z-order":"viewport-y","text-letter-spacing":.05,"text-optional":!0,"icon-allow-overlap":!0},paint:{"icon-color":"#38bdf8","icon-opacity":["interpolate",["linear"],["zoom"],8,1,9,0]}},{id:"vor_label",type:"symbol",source:e,"source-layer":"vor",minzoom:5,layout:{"text-field":["get","CODE_ID"],"text-size":10,"text-anchor":"bottom","text-offset":[0,-.8]},paint:{"text-color":U.vor,"text-halo-color":"#0f172a","text-halo-width":1}},{id:"ndb_icon",type:"symbol",source:e,minzoom:4,"source-layer":"ndb",layout:{"icon-image":"ndb-inway","icon-size":["interpolate",["linear"],["zoom"],6,.5,10,1],"symbol-z-order":"viewport-y","text-field":["concat",["get","CODE_ID"],"\n",["get","VAL_FREQ"],"kHz"],"text-size":10,"text-offset":[0,1.4],"text-letter-spacing":.05,"text-optional":!0,"icon-allow-overlap":!0},paint:{"text-color":U.ndb,"text-halo-color":"#0f172a","text-halo-width":1,"icon-color":U.ndb}},{id:"airline_point",type:"symbol",source:e,"source-layer":"waypoint",minzoom:5,layout:{"icon-image":["case",["==",["get","report_type"],"C"],"waypoint-compusory","waypoint"],"icon-size":.6,"icon-allow-overlap":!0,"icon-ignore-placement":!0,"text-field":["get","CODE_ID"],"text-size":9,"text-variable-anchor-offset":["bottom",[0,-.6],"top",[0,.6],"right",[-.6,0],"left",[.6,0],"bottom-right",[-.4,-.4],"bottom-left",[.4,-.4],"top-right",[-.4,.4],"top-left",[.4,.4]],"text-justify":"auto","text-optional":!0},paint:{"icon-color":U.waypoint,"text-color":U.waypoint,"text-halo-color":"#0f172a","text-halo-width":1}},{id:"waypoint-off-airway-symbol",type:"symbol",source:e,"source-layer":"waypoint-off-airway",minzoom:7,layout:{"icon-image":["case",["==",["get","report_type"],"C"],"designate_point_inway","designate_point_notinway"],"icon-size":.6,"icon-allow-overlap":!0,"icon-ignore-placement":!0,"text-field":["get","CODE_ID"],"text-size":9,"text-variable-anchor-offset":["bottom",[0,-.6],"top",[0,.6],"right",[-.6,0],"left",[.6,0],"bottom-right",[-.4,-.4],"bottom-left",[.4,-.4],"top-right",[-.4,.4],"top-left",[.4,.4]],"text-justify":"auto","text-optional":!0},paint:{"icon-color":U.waypoint,"text-color":U.waypoint,"text-halo-color":"#0f172a","text-halo-width":1}}]}}};function Z(e="light"){return(q[e]??q.light).build()}class ${constructor(e,t={}){this._visible=!1,this.map=e,this.options=t}get visible(){return this._visible}open(e){this._visible=!0}setFrame(e){}close(){this._visible=!1}}class H{get globalConfig(){return T}get absb(){return this.adsb}constructor(e){return this.isDestroyed=!1,this._baseUrl="https://aips.siniswift.com",this._landGeojson=null,this._chartApiUrl=N,this.initialOptions={...e},this.ready=new Promise((e,t)=>{this._resolveReady=e,this._rejectReady=t}),this.processGlobalConfig(e),"undefined"!=typeof window&&(window.globalConfig=T),T.setMapReinitCallback(()=>{this.reinitializeMap()}),this.performanceManager=new y(e.performance),this.initializeMap(e),new Proxy(this,{get(e,t){if("symbol"==typeof t||Reflect.has(e,t)){const i=e[t];return"function"==typeof i?i.bind(e):i}const i=e.map;if(!i)return;const n=i[t];return"function"==typeof n?n.bind(i):n},set:(e,t,i)=>("symbol"==typeof t||Reflect.has(e,t)||!e.map?e[t]=i:t in e.map?e.map[t]=i:e[t]=i,!0),has:(e,t)=>Reflect.has(e,t)||!!e.map&&t in e.map})}initializeMap(e){this._baseUrl=e.staticUrl||"https://aips.siniswift.com",this._chartApiUrl=(e.apiUrl||N).replace(/\/$/,"");const t="dark"===e.theme?"dark":"light",i=q[t]??q.light,n=e.style??function(e){const t=e.apiUrl.replace(/\/$/,""),i=(e.spriteUrl??t).replace(/\/$/,"");return{version:8,glyphs:"https://aips.siniswift.com/mapsdk/glyphs/{fontstack}/{range}.pbf",sprite:[{id:"plane",url:`${i}/sprites/sprite-plane`},{id:"normal",url:`${i}/sprites/sprite-color`},{id:"default",url:`${i}/sprites/sprite`},{id:"v2",url:`${i}/sprites/sprite-v2`}],sources:{land:{type:"geojson",data:{type:"FeatureCollection",features:[]}},boundary:{type:"geojson",data:{type:"FeatureCollection",features:[]}}},layers:[{id:"background",type:"background",paint:{"background-color":e.background}}]}}({apiUrl:this._chartApiUrl,...e.spriteUrl?{spriteUrl:e.spriteUrl}:{},background:i.background});this.map=new r.Map({center:[116.3974,39.9093],zoom:10,minZoom:0,maxZoom:22,preserveDrawingBuffer:!1,...e,style:n}),this.api=new M,this.pluginManager=new _(this),e.plugins&&e.plugins.forEach(e=>this.use(e)),this.setupMapEventListeners();const o=T.getConfig().apiKey,s=o?{"X-Api-Key":o}:{},a=j(`${this._chartApiUrl}/topjson/land.topojson.gz`,s).catch(e=>null),l=j(`${this._chartApiUrl}/topjson/boundary.topojson.gz`,s).catch(e=>null);this.map.on("load",async()=>{if(e.period)this.setPeriod(e.period);else{const e=await this.globalConfig.generateCurrentPeriod();this.setPeriod(e)}this.initializeManagers(),this.initializeChartFeatures(),e.style||this.initializeAviationLayers();const[t,i]=await Promise.all([a,l]);if(t){const e=t,i=e.objects.land;if(i){this._landGeojson=D(e,i);const t=this.map.getSource("land");t?t.setData(this._landGeojson):this.map.addSource("land",{type:"geojson",data:this._landGeojson})}}const n=i?.objects?.boundary;if(n){const e=this.map.getSource("boundary");e&&e.setData(D(i,n))}this.map.fire("loadComplete",{notam:this.notam,adsb:this.adsb}),this.map.fire("aviation:ready",{notam:this.notam,adsb:this.adsb}),this._resolveReady()})}setupMapEventListeners(){this.map.on("error",e=>{}),this.map.on("zoom",()=>{this.handleZoomChange()})}handleZoomChange(){this.performanceManager}initializeManagers(){const e=this.getCustomLayerStyles();this.layerManager=new m(this.map,this.performanceManager,e),this.geoJSONManager=new g(this.map,this.performanceManager)}async initializeDefaultLayers(){const e=["water","landLayer","background"];for(const t of e)await this.addBuiltInLayer(t,"0")}initializeADSB(){this.adsb=new v(this.map)}initializeNOTAM(){this.notam=new C(this.map)}initializeHover(){this.hover=new x(this.map)}initializeCLick(){this.clickObj=new b(this.map)}initialRaster(){this.rasterManager=new P(this.map)}initializeGraticule(){this.graticule=new A(this.map)}initializeSelector(){this.selector=new z(this.map)}initializeLabelOptimizer(){this.lineLabelOptimizer=new F(this.map,this.layerManager.getBuiltInLayers)}initializeTheme(){this.theme=new O(this.map)}initializeChartFeatures(){const config=T.getConfig();this.initializeDefaultLayers(),config.chartConfig?.enableADSB&&this.initializeADSB(),config.chartConfig?.enableNOTAM&&this.initializeNOTAM(),this.initializeHover(),this.initializeCLick(),this.initialRaster(),this.initializeGraticule(),this.initializeSelector(),this.initializeLabelOptimizer(),this.initializeTheme(),this.wind=new $(this.map)}initializeAviationLayers(){const e=this.globalConfig.getPeriod();if(!e)return;this.map.getSource("navdata")||this.map.addSource("navdata",function(e,t){return{type:"vector",tiles:[B(e,t)],minzoom:0,maxzoom:14}}(this._chartApiUrl,e));const t="dark"===this.initialOptions.theme?"dark":"light";for(const e of Z(t))this.map.getLayer(e.id)||e.source&&!this.map.getSource(e.source)||this.map.addLayer(e);this.map.getSource("amm")||this.map.addSource("amm",{type:"vector",tiles:[`${this._chartApiUrl.replace(/\/$/,"")}/api/amm/{z}/{x}/{y}.pbf`],minzoom:11,maxzoom:18});const i=this.map.getLayer("airspaceLayer")?"airspaceLayer":void 0;for(const e of u("amm",t))this.map.getLayer(e.id)||this.map.addLayer(e,i);this.map.getSource("terrain")||this.map.addSource("terrain",function(e,t){return{type:"raster-dem",tiles:[t??`${e.replace(/\/$/,"")}/api/terrain/{z}/{x}/{y}.png`],tileSize:256,maxzoom:13}}(this._chartApiUrl,this.initialOptions.terrainUrl));for(const e of[{id:"terrain-color",type:"color-relief",source:"terrain",layout:{visibility:"none"},paint:{"color-relief-color":G}},{id:"terrain-hillshade",type:"hillshade",source:"terrain",layout:{visibility:"none"},paint:{"hillshade-shadow-color":"rgba(74,59,42,0.35)","hillshade-highlight-color":"rgba(255,246,230,0.25)","hillshade-accent-color":"rgba(74,59,42,0.2)","hillshade-exaggeration":.45,"hillshade-illumination-direction":315,"hillshade-illumination-anchor":"viewport"}}]){if(this.map.getLayer(e.id))continue;const t=i;this.map.addLayer(e,t)}const n=this.initialOptions.layers??{},r={...p,...n};for(const[e,t]of Object.entries(r))this.setLayerVisible(e,!!t)}setCenter(e){this.map.setCenter(e)}setZoom(e){this.map.setZoom(e)}setPitch(e){this.map.setPitch(e)}setBearing(e){this.map.setBearing(e)}fitBounds(e,t){this.map.fitBounds(e,t)}async addBuiltInLayer(e,t){await this.layerManager.addBuiltInLayer(e,t)}removeBuiltInLayer(e){this.layerManager.removeBuiltInLayer(e)}toggleBuiltInLayer(e){(this.layerManager.getBuiltInLayers()[e]||[]).forEach(e=>{this.layerManager.toggleLayer(e)})}toggleLayer(e){this.layerManager.toggleLayer(e)}showLayer(e){this.layerManager.showLayer(e)}hideLayer(e){this.layerManager.hideLayer(e)}clickLayer(e,t){this.clickObj.clickLayer(e,t)}getBuiltInLayers(){return this.layerManager.getBuiltInLayers()}isBuiltInLayerVisible(e){return this.layerManager.isBuiltInLayerVisible(e)}updateLayerStyle(e,t){this.layerManager.updateLayer(e,t)}toggleFullScreen(e){e?this.map.addControl(new r.FullscreenControl):this.map.removeControl(new r.FullscreenControl)}_snapshotVisibleLayers(){return Object.keys(d).filter(e=>(d[e]??[]).some(e=>{try{return!!this.map.getLayer(e)&&"visible"===this.map.getLayoutProperty(e,"visibility")}catch{return!1}}))}_restoreAfterStyleLoad(e){this.initializeManagers(),this.initializeChartFeatures();for(const t of e)for(const e of d[t]??[])this.map.getLayer(e)&&this.map.setLayoutProperty(e,"visibility","visible");this.restoreLandLayer()}async setMapStyle(e,t){const i=this._snapshotVisibleLayers();return new Promise(n=>{this.map.once("style.load",()=>{this._restoreAfterStyleLoad(i),n()}),this.map.setStyle(e,t)})}setTheme(e){const t=T.getConfig().styleConfig?.theme||"light";if(t===e)return;T.updateConfigItem("styleConfig",{theme:e,language:T.getConfig().styleConfig?.language||"zh-CN"}),this.initialOptions.theme=e;const i=this._themeLayerDefs(t),n=this._themeLayerDefs(e);for(const e of Object.keys(n))this.map.getLayer(e)&&this._applyThemedProps(e,i[e],n[e])}_themeLayerDefs(e){const t={background:{id:"background",paint:{"background-color":(q[e]??q.light).background}}};for(const i of Z(e))t[i.id]=i;for(const i of u("amm",e))t[i.id]=i;return t}_applyThemedProps(e,t,i){for(const n of["paint","layout"]){const r=t&&t[n]||{},o=i&&i[n]||{},s=new Set([...Object.keys(r),...Object.keys(o)]);for(const t of s){if("layout"===n&&"visibility"===t)continue;const i=o[t];if(JSON.stringify(i)!==JSON.stringify(r[t]))try{"paint"===n?this.map.setPaintProperty(e,t,i):this.map.setLayoutProperty(e,t,i)}catch(e){}}}}restoreLandLayer(){if(!this._landGeojson)return;const e=this.map.getSource("land");e?e.setData(this._landGeojson):this.map.addSource("land",{type:"geojson",data:this._landGeojson})}addPoint(e,t,i,n){return this.geoJSONManager.addPoint(e,t,i,n)}addLine(e,t,i,n){return this.geoJSONManager.addLine(e,t,i,n)}addPolygon(e,t,i,n){return this.geoJSONManager.addPolygon(e,t,i,n)}addGeoJSON(e,t,i){return this.geoJSONManager.addGeoJSON(e,t,i)}addLayer(e){this.layerManager.addLayer(e)}hoverLayer(e,t){this.hover.hoverLayer(e,t)}hoverPopup(e,t){return this.hover.hoverPopup(e,t)}clickPopup(e,t){return this.clickObj.clickPopup(e,t)}showLayers(e){this.layerManager.batchShowLayers(e)}hideLayers(e){this.layerManager.batchHideLayers(e)}setLayerVisible(e,t){const i=f[e]??e,n=d[i];if(!n)return;const r=n.filter(e=>this.map.getLayer(e));t?this.showLayers(r):this.hideLayers(r),"terrain"===i&&this.map.setTerrain(t?{source:"terrain",exaggeration:4}:null)}flyTo(e,t){this.map.flyTo(e,t)}on(e,t,i){"string"==typeof t?this.map.on(e,t,i):this.map.on(e,t??i)}off(e,t,i){"string"==typeof t?this.map.off(e,t,i):this.map.off(e,t??i)}getCenter(){return this.map.getCenter().toArray()}getZoom(){return this.map.getZoom()}getBounds(){const e=this.map.getBounds();return[[e.getWest(),e.getSouth()],[e.getEast(),e.getNorth()]]}use(e){this.pluginManager.use(e)}getPlugin(e){return this.pluginManager.getPlugin(e)}getPerformanceStats(){return this.performanceManager.getPerformanceStats()}getErrorStats(){}setPeriod(e){this.globalConfig.setPeriod(e);const t=this.map?.getSource("navdata");t?.setTiles&&t.setTiles([B(this._chartApiUrl,e)])}getPeriod(){return this.globalConfig.getPeriod()}async generateCurrentPeriod(){return await this.globalConfig.generateCurrentPeriod()}showGraticule(){this.graticule?.show()}hideGraticule(){this.graticule?.hide()}toggleGraticule(){this.graticule?.toggle()}updateGraticuleConfig(config){this.graticule?.updateConfig(config)}isGraticuleVisible(){return this.graticule?.isGraticuleVisible()||!1}get showTileBoundaries(){return this.map.showTileBoundaries}set showTileBoundaries(e){this.map.showTileBoundaries=e}enableLineLabelDedup(e,t,i,n=["txtDesig","txtDesigForward","txtDesigBackward"],r="_dedup_label"){this.lineLabelOptimizer&&(this.lineLabelOptimizer.labelOptions={builtInKey:i,lineLayerId:e,lineLabelId:t,fieldList:n,suffix:r},this.lineLabelOptimizer.update())}disableLineLabelDedup(){this.lineLabelOptimizer&&this.lineLabelOptimizer.remove()}async reinitializeMap(){if(!this.isDestroyed)try{this.map.fire("reinit",{period:this.globalConfig.getPeriod()})}catch(e){}}async registerIcon(e,t,i){const n=await this.map.loadImage(t);this.map.addImage(e,n,i)}setStyle(e){this.theme.setStyle(e)}processGlobalConfig(e){const config={version:e.version||"1.0.0",chartConfig:{enableAIP:e.enableAIP??!0,enableNOTAM:e.enableNOTAM??!0,enableADSB:e.enableADSB??!0,defaultCenter:e.center||[116.3974,39.9093],defaultZoom:e.zoom||2},styleConfig:{theme:e.theme||"light",language:e.language||"zh-CN"},periodConfig:{switchDay:e.switchDay??5}};e.apiKey&&(config.apiKey=e.apiKey),e.baseUrl&&(config.baseUrl=e.baseUrl),e.period&&(config.period=e.period),T.setConfig(config)}getCustomLayerStyles(){if(!this.initialOptions.style)return{};let e;"string"==typeof this.initialOptions.style||(e=this.initialOptions.style);const t={};for(const[i,n]of Object.entries(e))"amm"!==i&&"controlled"!==i&&"restricted"!==i&&"airspace"!==i&&"airline"!==i&&"placelabel"!==i&&"boundary"!==i&&(t[i]=n);const i=["amm","controlled","restricted","airspace","airline","placelabel","boundary"];for(const n of i)if(e[n]&&Array.isArray(e[n]))for(const i of e[n])if("object"==typeof i&&null!==i)for(const[e,n]of Object.entries(i))t[e]=n;return t}destroy(){this.isDestroyed||(this.globalConfig.setMapReinitCallback(null),this.pluginManager.destroy(),this.performanceManager.destroy(),this.graticule?.destroy(),this.map.remove(),this.isDestroyed=!0)}}var W=Object.defineProperty,X=(e,t,i)=>((e,t,i)=>t in e?W(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);const Y="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAABhGlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AYht+mLYpUHOwgopChOtlFRRxrFYpQIdQKrTqYXPoHTRqSFBdHwbXg4M9i1cHFWVcHV0EQ/AFxdnBSdJESv0sKLWK847iH97735e47QGhWmWaFEoCm22YmlRRz+VWx5xUhmmGMIi4zy5iTpDR8x9c9Any/i/Ms/7o/R79asBgQEIkTzDBt4g3imU3b4LxPHGVlWSU+J54w6YLEj1xXPH7jXHJZ4JlRM5uZJ44Si6UuVrqYlU2NeJo4pmo65Qs5j1XOW5y1ap2178lfGCnoK8tcpzWCFBaxBAkiFNRRQRU24rTrpFjI0HnSxz/s+iVyKeSqgJFjATVokF0/+B/87q1VnJr0kiJJIPziOB9jQM8u0Go4zvex47ROgOAzcKV3/LUmMPtJeqOjxY6AgW3g4rqjKXvA5Q4w9GTIpuxKQVpCsQi8n9E35YHBW6Bvzetb+xynD0CWepW+AQ4OgfESZa/7vLu3u2//1rT79wN2rHKoBaSKHQAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAN1wAADdcBQiibeAAAAAd0SU1FB+gEBAUlKJesuC4AABWbSURBVHja7Z3fcxTHEce/t1ohYekA2QaBDBgocGLHNmW7Kg4pV9l5SeUleci/4b9H/0aeU3mJXXEF5yEmEOw4hgKFH7JBtpEQwhLS3eVhunV9w+7tHWh3e2Z7q64OyZJ18+Mz3+7pme4W7Bn6tBdXWwD4lYj3FMA0gCkAswCOAJihrw8AOAfgdwDOAmgDmKDf3YunB6ADYB3AdQB/BnANwEMAWwA2ANwH8Ii+3gSwA6BLv8vvvfWPD/VslPOflnVBLhQQYKQCiEl6zQCYB/AigGMA3gBwGMB+guQQgFfpfZKg2sunC2AbwCqA/9H7FoCfAKwA+ArAtwB+BHCPoNmmFwOzw6AAgMFigIyrFhMChgMERJu+PkJQHCNI5un7qfi9F+i9VUJf88TeBvCY3js06TcIih8Jkq9IUTZIde6R2myI3zNVMUBGAiOlST1NrwMAjgM4BeAtAUKbIJklxZim35WAJSXB4UPSlROcINkkRXlEcKwLcP4NYAnAHQJlk17bUlUMlIYDkgHGPpr8BwEcJWVYAPA2AXKcwGAza0ooRiL6s1Vx//Yy3rtCUbaEebVOYCwBuAJgmZTmOwBrBNETA6XBgAwBYw7ACYLhbYLjRYLlIP3MpOest2oAYhxgep5zvk0QrBEUPxIkVwia2wAeGCgNBGQEME4DeIcAOUHm1bRwztMaVWIv1WVHOOubZGbdJkAuAbhpoDQIELErlRSAcZq+nhNqMeEpReh91vOUpSNU5QGBcbMAlG5Tdr1aDYGjRROdYxZFYOzzHO4Y+8o3w3YIgCJQOLbSaYKatBoAR0JKsB/Ay2Q+nRkRjKaYoL0RQblBZtj3cPGWbQDdmCFpRQyGVI0DcFuybwL4FVx0+6SBMRYot+Ci9p8DuAq3dfwwdjVpRQxHCheoO0xKcY7geJNgaRsYY4GyTlBcJUiukbKswAUqd2KEpBUhHBM06WfgotznAVwgQE6TmbWffiYxMEYCpUsA/ETm1U0C5CKAy3DR+g36mU5MkLQiAsM3qeYJjg/pfZ6+P4X+wUEDYzxQOmRSPYSLyF8G8Cm934vR5GpFBEeWSXWB4DiGwXNSMDieCRJg8LzXtwTHxVhNrlZEcMzCRb59k+owgZOaauypmuwQCCsZJtcy3HZw8JCkEcHxCoB3AXxkJlUli2oqVHmGFqIZsRDdZUjai6vBBhXTwOHgo+gMx2/ofcEzqQyMvYfEP7YzhcGjOCBINgBshwpJGigciYBjwYPjFQFHYnCUDgovQKzi/rMsIAkuqJgGCscU+kfSz5NZxXDMmr9ROSS8YPmQsLrwUfqt0CBpBQrHS+SE/xzArwmSBYNDjfP+iJTjMoC/A/ianPgf4LaBg4GkFRAcLbjI9xyA1wH8Fu6G31m4yLjtVOmC5DFc5P063A3GvwD4D9yxlScIZHcrCQgO9jmOknK8Re9Hvd0Tg6N+5z0tGKtJAC1xDcEAeU44UuGQnyez6iz6x0ZsG1cfJBPon6A+65nCuwuadkiSQODIinMcMTiCgeTIsM0UzZCkyjvZh0PGOV4wOILwbydorBbQP67Cz24wMeO/GSAF6iE71o9z2G5VWJDIhc536u8A2Ggvrqp02lPFcEzBHV+wOEeckPBu1xYrSHtxVd1R+UQhHGxaHYA7bHghy7kzOIL0SfzNlgs0xge0+iOpwo7kTpyHCwaew2BaT4MjfCXxx3eFlKSrzR9RoyCe33EsZ4Wxs1XhQ5LkWAjHeONFk4okiuBIPL+DbwIexuCRdXvCh2SiYKwTLZAkSuDgSHnuqmJwRAlJnrWgJtKuxcSSAaU8v8Oe+CDJ8kdkALjZCuKZVi+jn7dqYGcDcWY19EsX5L3kz8YGiL9jyWmZXtZiaqVKVpFZuIyHfgfFYlrllSfojdFPdZZXqMIf4QVyDS5Dyjr6JRt6jQMk4wj7GfSPrquR2D2Cwi9BwAEyruxUpPI8ieROntbSC89rYp+luXAHlGurvbjaqiuAmNa8erANegIuV+5JuIyHIZtWWdnT/SI2G/DS4xT0Eacz4qPiecV7QuwzGR9p0xx4By5TCt8dqU1FagEkQz1O02uOvhdivMNP18n1N7LKoN2HuzwkA2S9HLOKt0NfR7+Sblb5t0mEm0aV2+rPh9t1q0haY4f46nEi0F2rvITPsoJTViHNFfTTdfZG6KcryC8gKitghZpvOGtO1K4ilQMygnqEMqhFJQOWMFgD0C/FvAWvDPOQnZ4HBJQsQX0VT9dQDLmUQ968qFVFUiUrRWjqIZ3tvFoaS/S1rCK74znrow42A8WmyAO4JNJchfc6ATKs5kkSCCSqVKRSQCJQDz+J8yMUly3z65Dv7nCNuhpSv3VF32yLv79GCnWL/nZW1Sz2VbRfMFOnIqmCFSIU9cjKSbsEV3WpsPDlOED4j/i9ngcM1xfMUjEG5Qypi8xRDOWQqFGRyjpJRM33w12a+RDAH+HO4cyhX15Zs0nVwWDOp4tk3txCTRVhCyr3noSLK8g7NbN4uq67tofLVT+gfv4TXJmFu3A1SirLq1W1giRkNx8lxzIE9fDriy8D+ALAJzR4XIqsllLJ9Hd6BMq25xc9FDtn/Nn44tmkYkh8FXkbwH8hEs/FaGLxsYJpsfuye3JT6UCxv8G1xLlozCcEyTKZW9vsY9QV8c0AhQOUm56pt4N+5vtp6DzO45/wXqA5M00K3qnKzKoEkIwj7bLBE8rh4AyBN5BdA6MDRak0BShyQ+GugGMD7tTsGfQzUmqFJGtBXYNLhF2Js55W2FiWzOMkmUep8YlSOLq0+t4H8E8AnwH4BoFUUVr/+FCvvbjKO2eP4M42bdFnfw3ABwDeo3HYr9Tc8k3ya7RjV5mzXvrkzEjEcIpeB5WaV9LneEjK8RmAfwD4EoMFK1Xnl2U1wWDJtC+pLZ9R2x5KE1GpmXVQzJtKEzykFa8E83B5Wo8rdc6lWbJBPsc1Uo5lAKu0CgdTyTXD5OLP/Q21ja+5tqHvZLBvebwFd4btB1KRbhUTt8qVoE2QtBWrh5++/yKZVWuhwZEBCgc416hNmTUFlapILXOnKvtfVoSSW4xanXJ/K3clZDhyIFlB9o5cB/puL9Y2f0r9IxnZ2Y8oVQ/2O4ZOnBjqfgtIhi0EmvwRX0WOoMLs8GlFELL/8QY1cEqZgkjTaikA02OvTcmsBWxS0QLG92L4mP9VuMOapQcNkwro5+uiL8LdX9CWW5cd1ydwRxtuwB0fuS9NjhjUI2N3S8Z5rlPbdytAKVkU/DIYfAemkpwFpQGSUd+j0oY9w2q6AXfQ7xLc2ard7c+Y4PAgkdvZt6jtuydnlZlZuQttmWZW2QriS+M8dAUHffW4icGTo1HCkQFJXvs1pRuqxVSvwsRi+/Yw9CWgzlIPjSto0/ugVTCXggSEG8WX8aehKzBYpB69mNUjwx8JQUUYkmkMJvcI1sSqvEGmHtGrSKULbimAZMQ/KpPEMdVjGy6qvESvRqnHEBXh/lhD/1CgFkgy51RZjnpSMnwyp9Nh6Ip/8Gnd7+CyjzRVPfJU5Ar1zSYqvKCkbU6V7YNwinttDro8cvEjXLCMt3UbpR4ZKsLbvpyuiFOk1t0nWVZJ6XdZkhIbw///FP00mZrMK44kf0sTYRM6zyHVsXBsop/wTp4k0GRmyVzFKGtuVXWaV5NzzubVFlwE+Su4Y+2aTAkNpuc99LNBbinqmxaeznYflpM+RFG0rJJsSqzDS2rQRPMqw8xiX4TzCWty1CudU0lD54LMUsLJ3Uw9rH8aD0hIK6RKhW1aHzVRQeS9D78EgT3WR40HRB7zXjH/o9AP4Qwujdzha6KJxSskV31qamBwlL6SfdT1+tAAacAE6JrvUeiLdJvcP4lNAnusjwwQe+wxQOyxxwCxp+qnZYDY4NuT3TeVnXkyQHROAG2HKLX1T2WnZg0QXYqh8Ri+iifnNqjWGiIGSEmQZF7kqiKdfkDzQvNtUAPEBl+FeaU1XVN0gGhLhKw9mbYW51xjuqZK51RSUUO0HekIoRyDBgXRmq6psiMwScl0azwUWGs6/QAddG2VwCo9RJmU3JDMY+UKQNGeM7juvtFYrqKWY/hlNlrrpZu8rPOaS1JX2Tey9LK2chWVz6lSAMm5dKMtjaVMp881uCebamYNqWWvqVxF7pwq67JbUlGDNtGvSqrFWfdrcJ+Azsq7VTvmM9QX2mrZS+f8Cc2p0hfcJLYGPYOjLmtwz9GuTaNURKjHPuoD7g9ttewrX3CrUpANhY66v2K+02AV0d4XtZnsZQOiOTuGv2qeplejVCRDPZ7qByWLRS1zqTRAAsnSZyoSRh/Ulg0zqYh8rVn6ilbPJGYVobYlAahHbfMoqZN8xSpyEv1t3yghEXDwtu5J5epRiyVSlYJoztLnq8gZAGfhIsi79yBigkT4HXzs/wi1+Yxi9ahlDpUKSEDZwmVk/RSACwDOwwXLZiP0R2R7F6itF6jt2tpbazb+pMIVQHO2cDY3+J7IeQAfAXiXJtALACZiUBFqAyvHArXxI2qzvBujqa21zZ+0xhVgjuzfnpLB8CeOVL/d08jtxdVOqDl8BRxDFwKF6lGbBVKlgoRQ0SnP9DgNF1WeClVJPDgOUptCMCVrrXhVuoKsf3yo115czasJOKtsxeLPMUE7OfMAzgF4Da48MuBKI2+1F1c7CCAjvOeQMxwL1KZz1MYZMQ7aqoHl1kysou+TihuaWVUW+kp7ye3PMwA+APA+gF/AHQEP4oJVxgWoY9SG96lNZyC2s6G3VF5tVXerPKXp1yW/A711yRmSabgt0PcA/B7AHwD8EsBxYZKojJOIOAebjMfps/+B2vIetW0aOpPDSd/jDmqq216Fky7NrG0yUZbo9aqYaD1lgySd9qPIrve+DHerbbu9uNrVYHIJ1WAVzNqtmifl0HpJTKqHnC9rqLiWfVrzivAzAC9Bb9odhmQ/nk40x6bLfTIBngDYoYWgclAEGPy59hEERzJ2q2aUmlXqLI7KAPFURNqUGp31PJ+kDeAVz66/DuAWOfEbVYOSA8YM3Db6SbgIub9bNaEcDt85H/BZq1x80pobzrsSh6ArJpIHSUvY85z04QaASwBuAridBwovEnsIBYaAcQJuG/cdcsRPoZ9CVHsCuDznfBM11ElMa+gAua/9Je2qvAz92Q1bos/YD2kTLKcJkCxQtmlguwQLxgXGA0ICO4F+fi8fjNP09RxBLe+Wa47jqHDOawEksJhIHiS+E+xPTgZliUB5SO3jK8d8TVQCM46C8c7UNL0O0N8+lQHGDClLijDKGKhxzutUkDz78qByMyvPL8kzb5Zo9WMT4Z5QlG0MJtPrFQDJGwSTAsp59DOyvE2AZIHRQlhpVVWFA1IlnXCWBnsf+kkCEAAkLRq0LFBepV069rX4mMQG3HmiUe5V+1kO2+jnFH4D/ZxeR2mBCRkMVc55bYAMiYmcFLZ9L6CBzQNlFm4Le4vMybcIDD50599r6OWolMxEz2lSOWUq+xbT4m+HCIY657xuBZGO2G2y2eVVz8kABzgLlCka3IO0EcHm1QaZRY9HVBAZpGQzi2Mycss25Az1/pyo1TmvFRChIk9ot+cmvU4EqiJ5oMidpin084TN0YTvjDD4/P+Y8pxtP+N6yHdVWD14PtTunNetILGqiA8KPFh4kCUw4+5iIRIoiubCbSg4q1db3EFcx/VV5AF9T9sp371QlUS8UmGKDXtNCuVIEF/h0cJ5UOf5tlThyhGTihSpC2BVrdSqR60K0kAVsScw9agdkBBWEHuaPfa1A2IqYuqhVT20KIipiKmH2jFXAYipiKmHRvXQpCCmIqYeKsdaDSCmIqYe2tRDm4KYiph6qBtjVYCMoCJdgyR4OLqhqIdGBclbYW7BHRXXVFfEnmczrXZoLG+FYCGoAyRDRW7AZQ65D+AnuBOw9oT5dGgM79OY3tCsHkD9Z7GKVOQR3LHnz9G/Mcf5nEK4Y23PoGm1BeB7AFdpTJcgcu1q/OAqs4jQShJkh9oz8oJ3lcZ2C0BXaxLwRHnHDpNkc9jDdMyDMpnVAuKVb5NOnTns4TvmA2OouYSEagURppY57HE65l3t9VXSADrYHHZzzE1BnsFhvwm9RXjsCdgxDwqQHKm+Ri8ztcwxN0CEw85JxW5mrUimIuaYN1ZBLDZijrkBsgedb5DUrh6dmBaxoAApiI2Yw67HtMo1g0NSjyAVpCA2UpTr1p5yAeFT2Pdi2UhJAx8M3kK8iH5cZIL+HVP2wVBMq8dwpR4u05gMbMWHph6h+iC+w75CA/IpvQ8rKWBPOXAUjkWIcAQLiICkcNUySCrxO+T2+0Uai29pbDqhwhE0IDHbvYE9WQFcLjcXvD8YNCDerpYFEOszrbKOAAUVEIxVQaSpZWe16jWt/IWpEzocUQBSIPVmall/GyAjntWqrRBkhOpRqNgxqEdUCjLCsXi7gbh3plVU0fJhTxrhIGZJ/2G4moBc+swCiM8OSKN2DWPyQfJMraf25U1Fnsu0ii5a3hhAMkytvMiuQfLsfkd00fJGASIgGbbamT/yfH5HVNHypvkgRfay+SN704/RRMsbpyCeP7Jj/khpfkcU0fJGAuKZWuaPlON3dGKGI3pAzB8xv8N8EPNHzO8wBTF/xPwOA8T8EfM7DJAA/JGm3h/hAGvj/Y7GAjKifd1poNPeE+rReL+j0YAU+CPLaGaWRpklZrnpfkfTFSTPH/kEwBc0QZrktEuzc5n64JMm+x3ySdHQZ/3jQ7324qqcGJxHK4Xb+uVt3wnEu/070kLRVDgaDUiOaZHCJZ07TO8MSYwFeoY55U01Nc3EyvFHRnFOe5HBMdJmRZPVo/GACEiGraSxQeLDkeeUd5sOhwEymtN+NzJzQ5qVd80pNx/keZx2floAjiP8pNhZO1Z/NafcAHnW1ZXhiGFnq0kqaSZWyU57oX0e2EQa2c8y9TBAxoUk9J2tkdtjcBgg40ASw86W7VgZIKVCMqrN3lMOh+1YmZNeDiRDdrYA4BUAs6IfW8rhsB0rA6SUyebvbOVB0lL6mSUctmNlgOy5imAIJNpiJMNiHQNwmHoYIGVDoi1GMrLfZHCYk16G0645RmKxDgNEHSRaYiQW6zBAVEGiKUZisQ4DRCUkGmIkFuswJ121415njMRiHQaI+mecGMleQlIEh8U6DBA1KoKKIRkLDlMPA6RJkBgcBohBYnAYIAbJeJAYHAaIQWJwGCAGyXiQGBwGiEGSA4nBYYAYJDmQGBwGiEGSAwkMDgPEIBkOicFhgBgkGZDM0L83DA4DxCDpP1xi4Sh9/R2ASwaHAdJkSPjuRgJgEv167QBwFcDfAPwLdhuw1sfug9QAiXDCH8Pd+Psa7v7GHXpdpu/do58xOGp6/g9eQPkxBqxc0wAAAABJRU5ErkJggg==",J={draw:{marker:{type:"draw",eventType:"toggle",targetMode:"marker",settings:{exclusive:!0}},circle_marker:{type:"draw",eventType:"toggle",targetMode:"circle_marker",settings:{exclusive:!0}},text_marker:{type:"draw",eventType:"toggle",targetMode:"text_marker",settings:{exclusive:!0}},circle:{type:"draw",eventType:"toggle",targetMode:"circle",settings:{exclusive:!0}},line:{type:"draw",eventType:"toggle",targetMode:"line",settings:{exclusive:!0}},rectangle:{type:"draw",eventType:"toggle",targetMode:"rectangle",settings:{exclusive:!0}},polygon:{type:"draw",eventType:"toggle",targetMode:"polygon",settings:{exclusive:!0}},freehand:{type:"draw",eventType:"toggle",targetMode:"freehand",settings:{exclusive:!0}},custom_shape:{type:"draw",eventType:"toggle",targetMode:"custom_shape",settings:{exclusive:!0}}},edit:{drag:{type:"edit",eventType:"toggle",targetMode:"drag",settings:{exclusive:!0}},change:{type:"edit",eventType:"toggle",targetMode:"change",settings:{exclusive:!0}},rotate:{type:"edit",eventType:"toggle",targetMode:"rotate",settings:{exclusive:!0}},scale:{type:"edit",eventType:"toggle",targetMode:"scale",settings:{exclusive:!0}},copy:{type:"edit",eventType:"toggle",targetMode:"copy",settings:{exclusive:!0}},cut:{type:"edit",eventType:"toggle",targetMode:"cut",settings:{exclusive:!0}},split:{type:"edit",eventType:"toggle",targetMode:"split",settings:{exclusive:!0}},union:{type:"edit",eventType:"toggle",targetMode:"union",settings:{exclusive:!0}},difference:{type:"edit",eventType:"toggle",targetMode:"difference",settings:{exclusive:!0}},line_simplification:{type:"edit",eventType:"toggle",targetMode:"line_simplification",settings:{exclusive:!0}},lasso:{type:"edit",eventType:"toggle",targetMode:"lasso",settings:{exclusive:!0}},delete:{type:"edit",eventType:"toggle",targetMode:"delete",settings:{exclusive:!0}}},helper:{shape_markers:{type:"helper",eventType:"toggle",targetMode:"shape_markers",settings:{exclusive:!1,enabledBy:["drag","change","rotate","scale","line_simplification"]}},snapping:{type:"helper",eventType:"toggle",targetMode:"snapping",settings:{exclusive:!1}},pin:{type:"helper",eventType:"toggle",targetMode:"pin",settings:{exclusive:!1}},snap_guides:{type:"helper",eventType:"toggle",targetMode:"snap_guides",settings:{exclusive:!1}},measurements:{type:"helper",eventType:"toggle",targetMode:"measurements",settings:{exclusive:!1}},auto_trace:{type:"helper",eventType:"toggle",targetMode:"auto_trace",settings:{exclusive:!1}},geofencing:{type:"helper",eventType:"toggle",targetMode:"geofencing",settings:{exclusive:!1}},zoom_to_features:{type:"helper",eventType:"click",targetMode:"zoom_to_features",settings:{exclusive:!1}},click_to_edit:{type:"helper",eventType:"toggle",targetMode:"click_to_edit",settings:{exclusive:!1}}}},K='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="none" d="M0 0h24v24H0Z"/>\n <circle cx="32" cy="32" r="26" fill="currentColor" fill-opacity=".15" stroke="currentColor" stroke-width="7"/>\n <circle cx="32" cy="32" r="5" fill="currentColor"/>\n</svg>',Q={marker:'<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 64 64">\n <path d="M32 62.81s23.107-21.898 23.107-38.512a23.107 23.107 0 0 0-46.214 0C8.893 40.912 32 62.809 32 62.809m0-26.958a11.554 11.554 0 1 1 0-23.107 11.554 11.554 0 0 1 0 23.107"/>\n</svg>\n',circle:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="none" d="M0 0h24v24H0Z"/>\n <circle cx="32" cy="32" r="26" fill="currentColor" fill-opacity=".15" stroke="currentColor" stroke-width="7"/>\n <path stroke="currentColor" stroke-dasharray="3" stroke-width="4" d="M6 32h52M32 6v52"/>\n</svg>',circle_marker:K,text_marker:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="none" d="M0 0h24v24H0Z"/>\n <path fill="currentColor"\n d="M6.962 3.385h50.076a3.577 3.577 0 0 1 3.577 3.577v50.076a3.577 3.577 0 0 1-3.577 3.577H6.962a3.577 3.577 0 0 1-3.577-3.577V6.962a3.577 3.577 0 0 1 3.577-3.577Zm3.577 7.154v42.922h42.922V10.539Zm7.154 7.154h28.614v7.153H17.693Zm0 14.307h28.614v7.154H17.693Z"/>\n</svg>\n',line:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <line x1="8" y1="50" x2="24" y2="20" stroke="currentColor" stroke-width="8"/>\n <line x1="24" y1="20" x2="40" y2="54" stroke="currentColor" stroke-width="8"/>\n <line x1="40" y1="54" x2="54" y2="10" stroke="currentColor" stroke-width="8"/>\n <circle cx="8" cy="50" r="6" fill="white" stroke="currentColor" stroke-width="4.5"/>\n <circle cx="24" cy="20" r="6" fill="white" stroke="currentColor" stroke-width="4.5"/>\n <circle cx="40" cy="54" r="6" fill="white" stroke="currentColor" stroke-width="4.5"/>\n <circle cx="54" cy="10" r="6" fill="white" stroke="currentColor" stroke-width="4.5"/>\n</svg>\n',rectangle:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n \x3c!-- Rectangle --\x3e\n <polygon points="10,10 54,10 54,54 10,54" fill="none" stroke="currentColor" stroke-width="8"/>\n\n \x3c!-- Vertex Circles --\x3e\n <circle cx="10" cy="10" r="6" fill="white" stroke="currentColor" stroke-width="4.5"/>\n <circle cx="54" cy="10" r="6" fill="white" stroke="currentColor" stroke-width="4.5"/>\n <circle cx="54" cy="54" r="6" fill="white" stroke="currentColor" stroke-width="4.5"/>\n <circle cx="10" cy="54" r="6" fill="white" stroke="currentColor" stroke-width="4.5"/>\n</svg>\n',polygon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n \x3c!-- Polygon --\x3e\n <polygon points="8,28 40,6 55,35 51,55 18,54" fill="none" stroke="currentColor" stroke-width="8"/>\n\n \x3c!-- Vertex Circles --\x3e\n <circle cx="9" cy="28" r="6" fill="white" stroke="currentColor" stroke-width="4.5"/>\n <circle cx="40" cy="8" r="6" fill="white" stroke="currentColor" stroke-width="4.5"/>\n <circle cx="55" cy="35" r="6" fill="white" stroke="currentColor" stroke-width="4.5"/>\n <circle cx="50" cy="55" r="6" fill="white" stroke="currentColor" stroke-width="4.5"/>\n <circle cx="18" cy="54" r="6" fill="white" stroke="currentColor" stroke-width="4.5"/>\n</svg>\n',freehand:'<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 64 64">\n <path d="M44.698 2.661a1.644 1.644 0 0 1 2.328 0l9.866 9.866a1.644 1.644 0 0 1 0 2.329L24.004 47.744a1.644 1.644 0 0 1-.552.362L7.008 54.683a1.644 1.644 0 0 1-2.138-2.138l6.578-16.444a1.644 1.644 0 0 1 .362-.552zm-3.089 7.742 7.542 7.541 4.252-4.252-7.541-7.541zm5.216 9.866-7.54-7.54-21.378 21.376v.964h1.644a1.644 1.644 0 0 1 1.645 1.644v1.645h1.644a1.644 1.644 0 0 1 1.645 1.644v1.644h.963zM14.724 37.29l-.35.348L9.35 50.204l12.566-5.025.349-.35a1.644 1.644 0 0 1-1.07-1.538v-1.645h-1.644a1.644 1.644 0 0 1-1.644-1.644v-1.644h-1.644a1.644 1.644 0 0 1-1.54-1.07"/>\n <path stroke="currentColor" stroke-width="5.107"\n d="M6.298 59.53c3.44-1.692 6.88-3.384 10.558-4.319s7.594-1.111 11.719-.298c4.125.814 8.459 2.617 13.483 2.655 5.023.038 10.737-1.689 16.45-3.415"/>\n</svg>\n',custom_shape:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <circle cx="49.754" cy="50.219" r="10.098" fill="none" stroke="currentColor" stroke-width="5.1"/>\n <path fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="4.491"\n d="M44.516 26.657H17.842l6.669-11.55 6.668-11.55 6.669 11.55Z"/>\n <path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="6"\n stroke-width="4.683" d="M4.481 40.605h20.761v19.093H4.481z"/>\n</svg>\n',drag:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path\n fill="currentColor"\n d="M32 61.4 19.85 49.42l3.28-3.235 6.634 6.542V34.205H10.98l6.26 6.174-3.279 3.234L2.185 32l11.852-11.686 3.28 3.234-6.336 6.247h18.783V11.273l-6.261 6.174-3.28-3.234L32 2.6l11.777 11.613-3.28 3.234-6.26-6.174v18.522h18.782l-6.26-6.174 3.279-3.234L61.815 32 50.038 43.613l-3.28-3.234 6.261-6.174H34.236v18.522l6.634-6.542 3.28 3.234z"\n />\n</svg>\n',change:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="currentColor"\n d="m22.775 29.562 6.75-6.75-5.625-5.625-3.6 3.6-3.15-3.15 3.6-3.6-5.626-5.55-6.75 6.75zm25.95 26.101 6.75-6.825-5.624-5.625-3.6 3.6-3.15-3.15 3.6-3.6-5.55-5.55-6.75 6.75zm.6-46.126 5.25 5.25ZM16.7 59.039H5v-11.7l14.55-14.551L2 15.237l13.05-13.2 17.7 17.624L46.1 6.312q.676-.676 1.5-.976.826-.3 1.65-.3.826 0 1.65.3.826.3 1.5.976l5.326 5.325q.675.675.975 1.5.3.825.3 1.65t-.3 1.65q-.3.825-.975 1.5l-13.35 13.35L62 48.913l-13.125 13.05-17.551-17.55Zm-7.2-4.5h5.25l29.476-29.552-5.25-5.25L9.5 49.288Zm32.1-32.178-2.625-2.625 5.25 5.25Z"/>\n</svg>',rotate:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="currentColor"\n d="M58.709 17.724c-.3-.6-.601-.901-.902-1.502l-.3-.601c-.301-.601-.602-.902-.902-1.503l-.3-.601c-.301-.601-.602-.902-1.203-1.503l-.6-.901 8.414-9.317-13.825.3-13.824.301 1.502 13.524 1.503 13.524 9.617-10.819v.3l.3.602c.301.3.301.6.602.6l.3.602c0 .6 0 .901.3 1.202.903 2.104 1.804 4.208 2.105 6.311.6 4.208 0 8.716-1.804 12.623l-.6 1.202-.301.3-.902 1.503-.3.601c-.601.601-1.202 1.503-1.804 2.104-1.502 1.503-3.305 3.005-5.109 3.907-1.803 1.202-3.907 1.803-6.311 2.404-2.104.301-4.508.601-6.612.301-2.404-.3-4.508-.902-6.612-1.503-2.103-.901-3.907-2.104-5.71-3.606l-1.202-1.202-.601-.902-.601-.601c-.3-.3-.601-.601-.601-.902l-.902-1.202-.3-.3-.602-1.203c0-.3-.3-.3-.3-.6l-.902-1.503-.3-.601-.902-2.705q-.901-3.607-.901-7.213V27.04c0-.601 0-.901.3-1.202l.3-1.803.602-1.803c.901-2.405 2.103-4.509 3.606-6.612q2.254-3.156 5.41-5.41c.6-.3.901-1.202.3-1.803-.3-.3-.6-.601-.901-.601h-.601l-.3.3c-2.706 1.202-4.81 3.006-6.913 4.809-2.104 2.104-3.607 4.508-5.11 7.213-2.704 5.41-3.606 11.42-2.404 17.431.3 1.503.601 2.705.902 4.207l.902 2.405c.3.3.6.6.6 1.202l.602 1.202c0 .3.3.601.3.601l.902 1.503c.3.601.6.901.901 1.503l.301.6c.3.301.601.902.902 1.203l2.103 1.803c2.104 2.104 4.809 3.907 7.514 5.41q4.057 2.254 9.016 2.705c1.503.3 3.005.3 4.508.3 1.803 0 3.306 0 4.809-.3 3.005-.602 6.311-1.503 9.016-3.006l.6-.3c.602-.3.903-.601 1.504-.902l2.103-1.202c.601-.3.902-.601 1.203-.902l.6-.6a3.622 3.622 0 0 0 1.503-1.504l.3-.3c.902-.902 2.105-2.104 2.706-3.005l1.803-2.705 1.202-1.804c3.005-5.71 4.208-12.322 3.306-18.633-.601-3.306-1.503-6.612-3.005-9.317z"/>\n</svg>\n',scale:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <g fill="currentColor" stroke="currentColor">\n <path d="m37.62 5.028-.337.284-4.039 4.068 3.547 3.523L39.875 9.8l2.846.596 1.025-4.893-4.176-.877Zm9.995 6.393 9.787 2.053 1.026-4.895-9.787-2.05zm14.68 3.078 9.787 2.05 1.025-4.892-9.787-2.053zm-39.623 5.522 3.547 3.523 7.049-7.094-3.547-3.523zm-10.57 10.642 3.546 3.524 7.047-7.094-3.547-3.524zM1.529 41.306l3.55 3.523 7.046-7.096-3.547-3.523Zm70.977 4.027 3.91 3.115 3.44-4.387-1.118-6.55zM.947 48.319l5.617 8.274 4.137-2.809-5.617-8.273Zm62.211 8.744 3.91 3.116 6.233-7.82-3.91-3.116zM9.373 60.73l5.62 8.272 4.134-2.809-5.617-8.271zm44.438 8.067 3.91 3.115 6.232-7.82-3.91-3.117zM17.8 73.138l5.617 8.273 4.137-2.808-5.617-8.274zm26.662 7.388 3.91 3.116 6.232-7.82-3.91-3.116zm-18.236 5.022 5.617 8.273 4.136-2.81-5.617-8.272zm8.888 6.709 3.91 3.117 6.233-7.822-3.91-3.115z"\n stroke-width="3"\n transform="translate(2.517 1.586) scale(.60827)"/>\n <path d="M22.672 20.02a3.5 3.5 0 0 0-2.506 1.034L-.514 41.872a3.5 3.5 0 0 0-.412 4.434L18 74.176a3.5 3.5 0 0 0 5.633.216l33.494-42.038a3.5 3.5 0 0 0-2.018-5.605l-31.742-6.654a3.5 3.5 0 0 0-.695-.074zm1.121 7.317 24.32 5.098-26.992 33.877L6.484 44.759Z"\n stroke-width="3"\n transform="translate(2.517 1.586) scale(.60827)"/>\n <path d="m78.734 7.668 2.61 11.396-18.145 4.154 2.705 11.816L84.05 30.88l2.609 11.396L100 21.011Z"\n stroke-width="3"\n transform="translate(1.586 1.586) scale(.60827)"/>\n </g>\n</svg>\n',copy:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="currentColor"\n d="M41.687.926a2.173 2.173 0 0 0-.433.045c-4.075.232-7.358 3.618-7.358 7.747 0 .084.01.164.012.246l-12.987 4.261a7.842 7.842 0 0 0-6.126-3.563 2.173 2.173 0 0 0-.424-.043 2.173 2.173 0 0 0-.435.044c-4.073.232-7.358 3.618-7.358 7.747 0 3.143 1.901 5.869 4.604 7.097L8.377 35.11a2.173 2.173 0 0 0-.028.007C4.274 35.35.99 38.736.99 42.865c0 4.277 3.514 7.791 7.791 7.791 2.497 0 4.727-1.201 6.157-3.048l12.887 6.235a7.67 7.67 0 0 0-.139 1.44c0 4.277 3.515 7.791 7.792 7.791 4.278 0 7.793-3.514 7.793-7.792a7.67 7.67 0 0 0-1.885-5.027l.508-1.05-3.263-1.579 4.505-29.969.888-.29-.368-1.122a7.78 7.78 0 0 0 2.28-1.018l.447 1.364 4.72-1.547-.774-2.359-2.522.826a7.73 7.73 0 0 0 1.672-4.793c0-4.132-3.288-7.52-7.368-7.748a2.173 2.173 0 0 0-.424-.044zm0 4.346a3.414 3.414 0 0 1 3.447 3.446 3.415 3.415 0 0 1-3.446 3.447 3.414 3.414 0 0 1-3.446-3.447 3.414 3.414 0 0 1 3.445-3.446zm20.076 3.725a1.242 1.242 0 0 0-.382.062l-1.612.528.578 1.76-.293 1.94 2.456.37.486-3.234a1.242 1.242 0 0 0-1.233-1.426Zm-4.354 1.364-4.72 1.548.775 2.36 4.719-1.548-.774-2.36zm-22.153 2.732a7.877 7.877 0 0 0 3.735 2.922l-.062.408-.397.13.26.793-4.255 28.298-3.818-1.847-1.082 2.235 3.718 1.798a7.841 7.841 0 0 0-3.543 2.147l-13.272-6.42c.02-.23.035-.458.035-.692 0-2.888-1.609-5.408-3.969-6.745l2.912-11.012c3.74-.562 6.645-3.81 6.645-7.698l-.001-.02 13.094-4.297zm-20.885.87a3.414 3.414 0 0 1 3.445 3.447 3.414 3.414 0 0 1-3.445 3.447 3.414 3.414 0 0 1-3.447-3.447 3.414 3.414 0 0 1 3.446-3.446zm45.314 1.78-.738 4.912 2.456.37.738-4.912zM36.172 17.33l-1.793.588a1.242 1.242 0 0 0-.813.862l-.788 2.978 2.401.634.615-2.325 1.15-.377-.773-2.36zm22.405 5.781-.737 4.913 2.455.368.739-4.91zm-26.432 1.048-1.27 4.802 2.401.634 1.27-4.802zm25.325 6.32-.739 4.913 2.457.368.738-4.911-2.456-.37zm-27.23.882-1.27 4.802 2.402.634 1.27-4.801zm26.124 6.486-.739 4.91 2.455.37.74-4.912-2.457-.368zm-28.027.717-1.27 4.803 2.4.634 1.27-4.802-2.401-.634zm-19.555.856a3.414 3.414 0 0 1 3.446 3.446 3.414 3.414 0 0 1-3.446 3.447 3.414 3.414 0 0 1-3.445-3.447 3.414 3.414 0 0 1 3.445-3.446zm46.473 5.795-.739 4.91 2.456.37.74-4.911zm-11.124 5.072-1.082 2.236 4.47 2.164 1.083-2.237zm-8.651 1.55a3.414 3.414 0 0 1 3.445 3.446 3.414 3.414 0 0 1-3.445 3.447 3.414 3.414 0 0 1-3.447-3.447 3.414 3.414 0 0 1 3.446-3.446zm18.669.745-.358 2.378-2.953-1.428-1.083 2.236 4.472 2.163.541-1.117 1.228.183.608-4.046-2.455-.37z"/>\n</svg>\n',cut:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path stroke="currentColor" fill="currentColor" stroke-width="2"\n d="M44.095 2.247a2.285 2.285 0 0 0-.135.04L12.025 12.762a2.285 2.285 0 0 0-1.497 1.588l-7.772 29.4a2.285 2.285 0 0 0 1.213 2.641L35.397 61.6a2.285 2.285 0 0 0 2.873-.754l22.64-32.582a2.285 2.285 0 0 0 .05-2.534L46.6 3.23a2.285 2.285 0 0 0-2.504-.982ZM43.7 7.182l12.203 19.12-5.167 1.76 1.052 3.09 2.031-.693L38.07 53.122l.01-1.375-3.262-.023-.034 4.5-27.13-13.127 6.975-26.38Zm3.946 21.932-6.18 2.105 1.052 3.09 6.18-2.105zm-9.27 3.157-2.329.793a1.632 1.632 0 0 0-1.105 1.534l-.03 4.068 3.265.024.02-2.91 1.232-.419zm-3.488 9.66-.047 6.529 3.264.023.048-6.528z"/>\n</svg>\n',split:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <g fill="currentColor">\n <path d="m4.879 2.684-2.832 2.8L7.65 11.15l2.832-2.801Zm8.403 8.495-2.832 2.802 5.603 5.662 2.831-2.802zm8.404 8.494-2.832 2.8 5.602 5.664 2.832-2.802z"\n />\n <path d="M27.814 7.408a3.576 3.576 0 0 0-1.161-.176 3.2 3.2 0 0 0-.878.138l7.963 26.068L7.18 27.3c-.543 2.352 1.67 6.055 4.962 6.816l23.054 5.297 2.326 6.42c-2.27-.175-4.279 1.912-4.908 3.805-.535 1.698-.512 3.656.085 5.61.597 1.954 1.671 3.59 3.064 4.7 1.393 1.11 3.238 1.71 5.023 1.164 8.064-3.039 2.135-15.793.467-20.58 5.917 1.023 18.77 5.88 20.578-1.979.42-1.819-.306-3.616-1.509-4.929-1.203-1.313-2.909-2.27-4.9-2.73-1.99-.46-3.866-.547-5.602.303-1.737.849-3.768 2.642-3.468 4.73a6.17 6.17 0 0 0 .012.43l-6.563-1.794-6.88-22.632c-.702-2.297-3.445-3.99-5.108-4.523Zm26.824 26.88c1.36.315 2.472.99 3.116 1.692.644.703.795 1.307.684 1.79-.112.482-.511.956-1.399 1.305-.887.348-2.182.467-3.542.152-1.361-.314-2.472-.99-3.116-1.693-.644-.703-.797-1.304-.686-1.787.112-.482.513-.956 1.4-1.305a5.198 5.198 0 0 1 1.594-.327 6.98 6.98 0 0 1 1.949.173zM37.846 49.174c.333.069.71.25 1.13.585.746.594 1.497 1.654 1.905 2.99.408 1.335.379 2.635.092 3.545-.287.91-.731 1.34-1.205 1.484-.473.145-1.085.036-1.831-.558-.746-.594-1.496-1.655-1.904-2.99-.407-1.336-.378-2.637-.092-3.546.287-.91.732-1.342 1.206-1.486.118-.036.245-.057.38-.058.102 0 .207.011.319.034z"\n />\n </g>\n</svg>\n',delete:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="currentColor"\n d="M39.063 42.14 22.288 28.12 7.96 44.603l11.338 9.854h9.059zm-3.498 12.317h25.941v5.465h-44.25L4.377 48.726a5.465 5.465 0 0 1-.542-7.711L34.311 5.958a5.465 5.465 0 0 1 7.712-.538l16.496 14.343a5.465 5.465 0 0 1 .541 7.709z"/>\n</svg>',union:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="currentColor"\n d="M41.233 7.917c-5.5 0-10.519 2.077-14.328 5.482a21.443 21.443 0 0 0-4.138-.404c-11.88 0-21.544 9.664-21.544 21.544s9.664 21.544 21.544 21.544c5.5 0 10.519-2.077 14.328-5.482 1.34.263 2.722.404 4.138.404 11.88 0 21.544-9.664 21.544-21.544S53.113 7.917 41.233 7.917zm-9.969 6.791a21.61 21.61 0 0 1 5.598 3.499l-2.01 2.33a18.557 18.557 0 0 0-4.8-2.999Zm-7.927 2.765 2.557 1.714a18.558 18.558 0 0 0-2.396 5.128l-2.955-.86a21.614 21.614 0 0 1 2.794-5.982zm15.86 3.08a21.413 21.413 0 0 1 3.46 5.628l-2.839 1.188a18.357 18.357 0 0 0-2.963-4.817zm-19.334 6.142 3.053.399a18.348 18.348 0 0 0 .144 5.654l-3.027.552a21.407 21.407 0 0 1-.17-6.605Zm23.834 2.63a21.81 21.81 0 0 1 .548 3.263c.1 1.1.115 2.207.044 3.31l-3.07-.195c.12-1.888-.056-3.8-.511-5.64zm-19.918 6.172a18.37 18.37 0 0 0 2.64 5.003l-2.466 1.84a21.427 21.427 0 0 1-3.083-5.84Zm17.042 3.016 3.004.666a21.486 21.486 0 0 1-2.404 6.15l-2.66-1.547a18.434 18.434 0 0 0 2.06-5.27zm-12.535 4.124a18.554 18.554 0 0 0 4.6 3.302l-1.392 2.744a21.611 21.611 0 0 1-5.363-3.85Z"/>\n</svg>\n',difference:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="currentColor"\n d="m41.478 7.967-.033 3.069c1.887.02 3.772.337 5.561.933l.97-2.913a21.337 21.337 0 0 0-6.498-1.09Zm-3.294.215a21.567 21.567 0 0 0-6.298 1.915l1.332 2.766a18.518 18.518 0 0 1 5.401-1.641zm12.836 2.155-1.402 2.73a18.497 18.497 0 0 1 4.572 3.312l2.16-2.179a21.548 21.548 0 0 0-5.331-3.863ZM22.783 13.06c-11.848 0-21.486 9.638-21.486 21.486 0 11.849 9.638 21.486 21.486 21.486a21.37 21.37 0 0 0 14.288-5.466c.003 0 .006 0 .009.002.04-.036.078-.075.117-.11l.077-.072a21.285 21.285 0 0 0 1.51-1.532 22.128 22.128 0 0 0 .867-1.025 19.557 19.557 0 0 1-.88-.095c-.196-.025-.389-.058-.582-.09-.097-.015-.194-.028-.29-.045a18.378 18.378 0 0 1-1.576-.359l-.118-.03c-7.753-2.172-13.422-9.271-13.422-17.728a18.34 18.34 0 0 1 5.867-13.478c.1-.093.199-.185.3-.276.153-.136.31-.268.467-.4.097-.08.193-.163.291-.242.255-.203.514-.402.78-.592a21.534 21.534 0 0 0-1.76-.592l-.018-.005c-.176-.05-.355-.095-.533-.141-.132-.035-.263-.073-.397-.105-.213-.051-.43-.095-.646-.14-.077-.016-.153-.035-.231-.05H26.9a21.37 21.37 0 0 0-4.118-.4Zm35.728 3.64-2.472 1.82a18.424 18.424 0 0 1 2.61 5.004l2.907-.986a21.474 21.474 0 0 0-3.045-5.839Zm3.864 9.034-3.022.534c.328 1.86.37 3.772.118 5.642l3.042.409a21.448 21.448 0 0 0-.138-6.585zm-3.496 8.943a18.539 18.539 0 0 1-2.416 5.104l2.543 1.72a21.586 21.586 0 0 0 2.815-5.952zM54.703 42a18.288 18.288 0 0 1-4.428 3.492l1.505 2.675a21.348 21.348 0 0 0 5.173-4.08zm-6.995 4.69a18.512 18.512 0 0 1-5.526 1.158l.163 3.065a21.56 21.56 0 0 0 6.444-1.35z"/>\n</svg>\n',line_simplification:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="currentColor"\n d="M1.947 25.554c-2.176 3.77-.867 8.656 2.903 10.832 2.126 1.229 4.607 1.346 6.757.539l8.252 12.152a7.79 7.79 0 0 0-.701 1.005c-2.176 3.77-.867 8.656 2.903 10.833 3.77 2.177 8.655.867 10.832-2.903 2.1-3.64.93-8.294-2.543-10.572a2.211 2.211 0 0 0-.36-.26 2.211 2.211 0 0 0-.404-.181 7.955 7.955 0 0 0-6.086-.432l-8.348-12.292c.19-.252.369-.512.53-.79 1.457-2.526 1.339-5.537-.03-7.907l8.202-8.256c3.494 1.335 7.562.025 9.575-3.229l13.899 2.913c.266 2.435 1.634 4.721 3.899 6.03 3.77 2.176 8.655.866 10.832-2.904 2.101-3.64.93-8.294-2.543-10.572a2.211 2.211 0 0 0-.36-.26 2.211 2.211 0 0 0-.403-.181c-3.71-1.87-8.328-.556-10.429 3.083-.084.147-.155.297-.228.446l-13.5-2.83c-.053-2.55-1.329-5.023-3.58-6.499a2.211 2.211 0 0 0-.358-.259 2.211 2.211 0 0 0-.405-.181c-3.708-1.87-8.326-.556-10.428 3.083-1.61 2.79-1.307 6.19.486 8.652l-7.84 7.892a2.211 2.211 0 0 0-.094-.036c-3.71-1.87-8.328-.556-10.429 3.084zm3.83 2.211a3.473 3.473 0 0 1 4.79-1.282 3.472 3.472 0 0 1 1.284 4.789 3.473 3.473 0 0 1-4.79 1.284 3.475 3.475 0 0 1-1.283-4.79ZM23.656 8.173a3.474 3.474 0 0 1 4.79-1.283 3.472 3.472 0 0 1 1.283 4.79 3.473 3.473 0 0 1-4.789 1.284 3.475 3.475 0 0 1-1.284-4.791zm-.666 44.12a3.474 3.474 0 0 1 4.79-1.283 3.472 3.472 0 0 1 1.283 4.79 3.473 3.473 0 0 1-4.79 1.284 3.475 3.475 0 0 1-1.283-4.791zm29.166-37.88a3.474 3.474 0 0 1 4.79-1.283 3.472 3.472 0 0 1 1.283 4.79 3.473 3.473 0 0 1-4.79 1.284 3.475 3.475 0 0 1-1.283-4.791z"/>\n <path fill="currentColor"\n d="M12.9 13.516c-.63.177-.685.37-.88.95l-1.069 3.18 2.995 1.006.844-2.506 2.074-.882-1.236-2.908zm19.209 5.25 4.378 4.554 2.277-2.19-4.379-4.554zm8.132 3.106 1.441 2.812 5.623-2.882-1.441-2.812zM5.448 46.082l3.144.304.608-6.29-3.145-.303zm4.623 3.728 5.762 2.592 1.297-2.88-5.762-2.593z"/>\n</svg>\n',lasso:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <ellipse cx="4.907" cy="-32.051" fill="none" stroke="currentColor" stroke-dasharray="13.7543, 6.87718"\n stroke-width="5.489" rx="20.4" ry="13.713" transform="matrix(-.71127 .70292 -.86047 -.5095 0 0)"/>\n <path fill="currentColor"\n d="M34.597 25.275a1.934 1.934 0 0 0-2.04 2.165l2.922 31.37c.188 1.523 1.989 2.235 3.165 1.249l6.169-5.004 2.765 4.79c1.59 2.756 4.115 3.431 6.87 1.841 2.756-1.59 3.433-4.114 1.841-6.87l-2.755-4.773 7.31-2.803c1.443-.525 1.728-2.44.503-3.365L35.64 25.66a1.93 1.93 0 0 0-1.042-.383z"/>\n</svg>\n',shape_markers:null,snapping:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="currentColor" fill-rule="evenodd"\n d="M19.435 3.417c-4.478 0-8.96 1.693-12.343 5.076-6.766 6.766-6.766 17.913 0 24.679h.006c2.754 2.749 5.563 5.561 8.357 8.357 1.857 1.859 3.696 3.696 5.553 5.553l.949.949 1.892 1.898 9.496-9.49-1.898-1.898-6.502-6.502c-2.796-2.797-5.6-5.606-8.363-8.362-1.65-1.653-1.652-4.042 0-5.694 1.653-1.653 4.047-1.653 5.7 0l8.357 8.362 6.502 6.502 1.898 1.893 9.49-9.49-1.893-1.893-6.507-6.502-8.357-8.362c-3.384-3.383-7.86-5.076-12.337-5.076Zm0 2.68c3.789 0 7.577 1.432 10.439 4.294l8.357 8.362-5.694 5.694-8.357-8.362a6.7 6.7 0 0 0-9.496 0 6.697 6.697 0 0 0 0 9.49c2.76 2.755 5.566 5.564 8.363 8.362l-5.694 5.694c-2.795-2.796-5.601-5.607-8.357-8.357H8.99c-5.724-5.724-5.724-15.16 0-20.883 2.861-2.862 6.655-4.294 10.444-4.294ZM57.709 29.03a4.266 4.266 0 0 0-4.268 4.268c0 1.594.881 2.973 2.176 3.707-.714 4.997-1.424 10.107-2.176 15.037-.934 0-1.792.309-2.495.818l-7.115-5.07a4.25 4.25 0 0 0 .115-.965 4.27 4.27 0 1 0-4.268 4.268 4.23 4.23 0 0 0 2.732-1.012l6.973 4.965a4.22 4.22 0 0 0-.215 1.269 4.27 4.27 0 0 0 4.273 4.268 4.266 4.266 0 0 0 4.268-4.268 4.247 4.247 0 0 0-1.657-3.356l2.208-15.446c2.095-.273 3.722-2.045 3.722-4.215a4.27 4.27 0 0 0-4.273-4.268z"\n />\n</svg>\n',pin:'\ufeff<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="currentColor"\n d="M42.012 2.106a4.092 4.092 0 0 0-5.741.735 4.092 4.092 0 0 0 .572 5.607L23.964 23.45a8.185 8.185 0 0 0-10.458 2.142l5.18 4.005 5.454 4.218L7.87 59.22a1.124 7.304 37.712 0 0 1.54 1.19l20.494-22.138 5.454 4.217 5.18 4.005a8.185 8.185 0 0 0-.558-10.66l11.277-16.24a4.092 4.092 0 0 0 5.572-.858 4.092 4.092 0 0 0-.735-5.74z"/>\n</svg>\n',snap_guides:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path stroke="currentColor"\n stroke-width="3.8"\n d="m2.155 32.345 42.35-29.82M18.963 60.919l42.35-29.82M31.443 2.332l29.82 42.35M2.207 19.515l29.82 42.35"/>\n</svg>\n',measurements:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="currentColor"\n d="M1.717 38.645a2.675 2.668 79.7 0 0-.307 3.769L16.754 60.55a2.675 2.668 79.7 0 0 3.76.312l41.769-35.508a2.675 2.668 79.7 0 0 .307-3.769L47.246 3.45a2.675 2.668 79.7 0 0-3.76-.312zm5.486 2.352 37.702-32.05 11.892 14.056-2.717 2.31-4.458-5.269-2.033 1.729 4.457 5.269-3.11 2.643-4.457-5.268-2.034 1.728 4.458 5.27-3.106 2.64-4.458-5.27-2.033 1.73 4.457 5.268-3.11 2.644-6.194-7.32-2.033 1.728 6.193 7.32-3.11 2.645-4.457-5.269-2.034 1.729 4.458 5.268-3.106 2.64-4.458-5.268-2.033 1.73 4.457 5.268-3.11 2.643-4.457-5.268-2.034 1.729 4.458 5.268-2.098 1.783z"/>\n</svg>\n',auto_trace:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="currentColor"\n d="M16.862 2.13 7.297 21.17a2.091 2.091 0 0 0-.193 1.288l4.107 24.166-7.618 13.15 3.619 2.096 7.997-13.804a2.091 2.091 0 0 0 .252-1.397l-4.119-24.235 9.256-18.428Zm40.876.255-1.25 2.49 2.668 1.341 1.25-2.49zm-2.593 5.16-2.68 5.337 2.668 1.341 2.682-5.338zm-4.022 8.007-2.682 5.338 2.67 1.34 2.681-5.337zm-18.67 5.83.055 6.984-11.118.087.056 7.242 11.12-.088.054 6.985 10.521-10.688zm18.927 2.817-2.945.5 1.001 5.89 2.945-.5zm1.502 8.835-2.945.5 1.001 5.89 2.945-.5zm1.502 8.834-2.945.5.74 4.355-.24.413 2.585 1.499.51-.881a1.494 1.494 0 0 0 .18-1zm-3.943 7.854-2.994 5.17 2.584 1.496 2.994-5.169zm-4.492 7.754-1.497 2.584 2.584 1.497 1.498-2.584z"/>\n</svg>\n',geofencing:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="currentColor"\n d="M31.226 17.87c-4.69 0-8.532 3.832-8.532 8.508 0 1.812.58 3.495 1.558 4.88l5.932 10.255c.831 1.085 1.383.879 2.074-.058l6.543-11.135c.132-.24.236-.493.327-.753a8.396 8.396 0 0 0 .628-3.19c0-4.675-3.841-8.506-8.53-8.506zm0 3.987a4.5 4.5 0 0 1 4.532 4.52 4.5 4.5 0 0 1-4.532 4.521 4.5 4.5 0 0 1-4.534-4.52 4.5 4.5 0 0 1 4.533-4.52z"/>\n <path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="6"\n stroke-width="5" d="M8.97 53.509 4.423 19.145 35.698 4.199l23.88 25.127L43.06 59.801Z"/>\n</svg>\n',zoom_to_features:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="currentColor"\n d="M1.585 1.585V13.75h5.17v1.52H8.58v-1.52h5.17V1.585Zm3.041 3.041h6.083v6.083H4.626Zm9.429 2.13V8.58h3.65V6.755Zm5.475 0V8.58h3.65V6.755Zm5.474 0V8.58h3.65V6.755Zm5.475 0V8.58h3.65V6.755Zm5.475 0V8.58h3.65V6.755Zm5.475 0v1.597a1.521 1.521 0 0 0-.325.152l-15.686 9.758a1.52 1.52 0 0 0-.199 2.437l23.512 20.553a1.52 1.52 0 0 0 2.477-.78l4.212-17.037v.352h1.825v-3.65H55.42v1.524a1.52 1.52 0 0 0-.222-.296L43.002 8.741a1.521 1.521 0 0 0-.182-.16h2.259V6.754Zm5.475 0V8.58h3.65V6.755Zm5.474 0V8.58h3.65V6.755Zm3.042 2.432v3.65h1.825v-3.65Zm-13.752 2.549 10.757 11.137-3.57 14.446-20.087-17.559Zm13.752 2.926v3.65h1.825v-3.65ZM6.755 17.096v3.65H8.58v-3.65zm0 5.475v3.65h1.628a1.52 1.52 0 0 0 1.02.909l12.683 3.406 7.905 12.694c.168.27.417.481.712.602l13.39 4.576a1.52 1.52 0 0 0 1.157-2.814l-12.936-4.389L24.35 28.42a1.52 1.52 0 0 0-.896-.664L10.19 24.193a1.52 1.52 0 0 0-1.61.557v-2.178zm48.665 3.042v3.65h1.825v-3.65ZM6.755 28.046v3.65H8.58v-3.65zm48.665 3.042v3.65h1.825v-3.65ZM6.755 33.52v3.65H8.58v-3.65zm48.665 3.041v3.65h1.825v-3.65ZM6.755 38.996v3.65H8.58v-3.65zm48.665 3.041v3.65h1.825v-3.65zm-35.382.913c-3.454 0-6.287 2.833-6.287 6.287 0 3.076 2.248 5.654 5.179 6.183h-1.225v1.825h3.65V55.42h-.206c2.712-.5 4.777-2.796 5.055-5.59l.002-.002a1.52 1.52 0 0 0 0-1.18c-.314-3.168-2.922-5.698-6.168-5.698zM6.755 44.47v3.65H8.58v-3.65zm13.283 1.521a3.223 3.223 0 0 1 3.246 3.246 3.223 3.223 0 0 1-3.246 3.246 3.223 3.223 0 0 1-3.246-3.246 3.223 3.223 0 0 1 3.246-3.246zm35.382 1.52v2.738h-5.17v12.166h12.165V50.25h-5.17v-2.737ZM6.755 49.946v3.65H8.58v-3.65zm46.536 3.346h6.083v6.083H53.29ZM6.755 55.42v1.825h3.65V55.42H7.668Zm5.475 0v1.825h3.65V55.42zm10.95 0v1.825h3.65V55.42zm5.474 0v1.825h3.65V55.42zm5.475 0v1.825h3.65V55.42zm5.475 0v1.825h3.65V55.42zm5.475 0v1.825h3.65V55.42z"/>\n</svg>\n',click_to_edit:'<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 64 64">\n <path d="M7.839 34.833c-7.104-9.763-5.332-23.33 4.2-30.266C21.572-2.369 35.03.123 42.13 9.882L56.166 29.17c7.098 9.755 5.329 23.325-4.204 30.262-9.533 6.936-22.989 4.444-30.09-5.315L7.841 34.836Zm5.063-25.476c-6.079 5.766-7.006 15.598-1.634 22.98l.778 1.07 12.002-8.732zm3.43-2.495L27.476 22.18l12.002-8.733-.781-1.073c-5.37-7.38-15.01-9.522-22.367-5.512m25.643 10.014L14.54 36.836l10.762 14.79c5.818 7.997 16.653 9.842 24.163 4.378 7.51-5.465 9.088-16.342 3.267-24.342z"/>\n</svg>\n'},ee=["mode_start","mode_started","mode_end","mode_ended"],te=e=>Object.keys(e),ie=e=>Object.values(e),ne=(e,t)=>t.includes(e);function re(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var oe,se={exports:{}};var ae,le,ce,ue=(oe||(oe=1,le=se.exports,ce=function(){var e=function(){},t="undefined",i=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),n=["trace","debug","info","warn","error"],r={},o=null;function s(e,t){var i=e[t];if("function"==typeof i.bind)return i.bind(e);try{return Function.prototype.bind.call(i,e)}catch{return function(){return Function.prototype.apply.apply(i,[e,arguments])}}}function a(){console.log&&(console.log.apply||Function.prototype.apply.apply(console.log,[console,arguments])),console.trace}function l(){for(var i=this.getLevel(),r=0;r<n.length;r++){var o=n[r];this[o]=r<i?e:this.methodFactory(o,i,this.name)}if(this.log=this.debug,typeof console===t&&i<this.levels.SILENT)return"No console available for logging"}function c(e){return function(){typeof console!==t&&(l.call(this),this[e].apply(this,arguments))}}function u(n,r,o){return function(n){return"debug"===n&&(n="log"),typeof console!==t&&("trace"===n&&i?a:void 0!==console[n]?s(console,n):void 0!==console.log?s(console,"log"):e)}(n)||c.apply(this,arguments)}function h(e,i){var s,a,c,h=this,d="loglevel";function p(){var e;if(typeof window!==t&&d){try{e=window.localStorage[d]}catch{}if(typeof e===t)try{var i=window.document.cookie,n=encodeURIComponent(d),r=i.indexOf(n+"=");-1!==r&&(e=/^([^;]+)/.exec(i.slice(r+n.length+1))[1])}catch{}return void 0===h.levels[e]&&(e=void 0),e}}function f(e){var t=e;if("string"==typeof t&&void 0!==h.levels[t.toUpperCase()]&&(t=h.levels[t.toUpperCase()]),"number"==typeof t&&t>=0&&t<=h.levels.SILENT)return t;throw new TypeError("log.setLevel() called with invalid level: "+e)}"string"==typeof e?d+=":"+e:"symbol"==typeof e&&(d=void 0),h.name=e,h.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},h.methodFactory=i||u,h.getLevel=function(){return c??a??s},h.setLevel=function(e,i){return c=f(e),!1!==i&&function(e){var i=(n[e]||"silent").toUpperCase();if(typeof window!==t&&d){try{return void(window.localStorage[d]=i)}catch{}try{window.document.cookie=encodeURIComponent(d)+"="+i+";"}catch{}}}(c),l.call(h)},h.setDefaultLevel=function(e){a=f(e),p()||h.setLevel(e,!1)},h.resetLevel=function(){c=null,function(){if(typeof window!==t&&d){try{window.localStorage.removeItem(d)}catch{}try{window.document.cookie=encodeURIComponent(d)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}(),l.call(h)},h.enableAll=function(e){h.setLevel(h.levels.TRACE,e)},h.disableAll=function(e){h.setLevel(h.levels.SILENT,e)},h.rebuild=function(){if(o!==h&&(s=f(o.getLevel())),l.call(h),o===h)for(var e in r)r[e].rebuild()},s=f(o?o.getLevel():"WARN");var m=p();null!=m&&(c=f(m)),l.call(h)}(o=new h).getLogger=function(e){if("symbol"!=typeof e&&"string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var t=r[e];return t||(t=r[e]=new h(e,o.methodFactory)),t};var d=typeof window!==t?window.log:void 0;return o.noConflict=function(){return typeof window!==t&&window.log===o&&(window.log=d),o},o.getLoggers=function(){return r},o.default=o,o},(ae=se).exports?ae.exports=ce():le.log=ce()),se.exports);const he=re(ue);class de{isMarkerInstanceAvailable(){return!!this.markerInstance||(he.error("Marker instance is not available"),!1)}}var pe=6371008.8,fe={centimeters:100*pe,centimetres:100*pe,degrees:360/(2*Math.PI),feet:3.28084*pe,inches:39.37*pe,kilometers:pe/1e3,kilometres:pe/1e3,meters:pe,metres:pe,miles:pe/1609.344,millimeters:1e3*pe,millimetres:1e3*pe,nauticalmiles:pe/1852,radians:1,yards:1.0936*pe};function me(e,t,i={}){const n={type:"Feature"};return(0===i.id||i.id)&&(n.id=i.id),i.bbox&&(n.bbox=i.bbox),n.properties=t||{},n.geometry=e,n}function ge(e,t,i={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Ie(e[0])||!Ie(e[1]))throw new Error("coordinates must contain numbers");return me({type:"Point",coordinates:e},t,i)}function ye(e,t,i={}){for(const t of e){if(t.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(t[t.length-1].length!==t[0].length)throw new Error("First and last Position are not equivalent.");for(let e=0;e<t[t.length-1].length;e++)if(t[t.length-1][e]!==t[0][e])throw new Error("First and last Position are not equivalent.")}return me({type:"Polygon",coordinates:e},t,i)}function _e(e,t,i={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return me({type:"LineString",coordinates:e},t,i)}function ve(e,t={}){const i={type:"FeatureCollection"};return t.id&&(i.id=t.id),t.bbox&&(i.bbox=t.bbox),i.features=e,i}function xe(e,t,i={}){return me({type:"MultiPolygon",coordinates:e},t,i)}function be(e,t="kilometers"){const i=fe[t];if(!i)throw new Error(t+" units is invalid");return e*i}function we(e,t="kilometers"){const i=fe[t];if(!i)throw new Error(t+" units is invalid");return e/i}function Ee(e){return e%(2*Math.PI)*180/Math.PI}function Te(e){return e%360*Math.PI/180}function Se(e,t="kilometers",i="kilometers"){if(!(e>=0))throw new Error("length must be a positive number");return be(we(e,t),i)}function Ie(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function ke(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function Me(e,t,i){if(null!==e)for(var n,r,o,s,a,l,c,u,h=0,d=0,p=e.type,f="FeatureCollection"===p,m="Feature"===p,g=f?e.features.length:1,y=0;y<g;y++){a=(u=!!(c=f?e.features[y].geometry:m?e.geometry:e)&&"GeometryCollection"===c.type)?c.geometries.length:1;for(var _=0;_<a;_++){var v=0,x=0;if(null!==(s=u?c.geometries[_]:c)){l=s.coordinates;var b=s.type;switch(h=!i||"Polygon"!==b&&"MultiPolygon"!==b?0:1,b){case null:break;case"Point":if(!1===t(l,d,y,v,x))return!1;d++,v++;break;case"LineString":case"MultiPoint":for(n=0;n<l.length;n++){if(!1===t(l[n],d,y,v,x))return!1;d++,"MultiPoint"===b&&v++}"LineString"===b&&v++;break;case"Polygon":case"MultiLineString":for(n=0;n<l.length;n++){for(r=0;r<l[n].length-h;r++){if(!1===t(l[n][r],d,y,v,x))return!1;d++}"MultiLineString"===b&&v++,"Polygon"===b&&x++}"Polygon"===b&&v++;break;case"MultiPolygon":for(n=0;n<l.length;n++){for(x=0,r=0;r<l[n].length;r++){for(o=0;o<l[n][r].length-h;o++){if(!1===t(l[n][r][o],d,y,v,x))return!1;d++}x++}v++}break;case"GeometryCollection":for(n=0;n<s.geometries.length;n++)if(!1===Me(s.geometries[n],t,i))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Ce(e,t){if("Feature"===e.type)t(e,0);else if("FeatureCollection"===e.type)for(var i=0;i<e.features.length&&!1!==t(e.features[i],i);i++);}function Pe(e,t){var i,n,r,o,s,a,l,c,u,h,d=0,p="FeatureCollection"===e.type,f="Feature"===e.type,m=p?e.features.length:1;for(i=0;i<m;i++){for(a=p?e.features[i].geometry:f?e.geometry:e,c=p?e.features[i].properties:f?e.properties:{},u=p?e.features[i].bbox:f?e.bbox:void 0,h=p?e.features[i].id:f?e.id:void 0,s=(l=!!a&&"GeometryCollection"===a.type)?a.geometries.length:1,r=0;r<s;r++)if(null!==(o=l?a.geometries[r]:a))switch(o.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(o,d,c,u,h))return!1;break;case"GeometryCollection":for(n=0;n<o.geometries.length;n++)if(!1===t(o.geometries[n],d,c,u,h))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,d,c,u,h))return!1;d++}}function Ae(e,t){Pe(e,function(e,i,n,r,o){var s,a=null===e?null:e.type;switch(a){case null:case"Point":case"LineString":case"Polygon":return!1!==t(me(e,n,{bbox:r,id:o}),i,0)&&void 0}switch(a){case"MultiPoint":s="Point";break;case"MultiLineString":s="LineString";break;case"MultiPolygon":s="Polygon"}for(var l=0;l<e.coordinates.length;l++){var c=e.coordinates[l];if(!1===t(me({type:s,coordinates:c},n),i,l))return!1}})}function Le(e,t={}){if(null!=e.bbox&&!0!==t.recompute)return e.bbox;const i=[1/0,1/0,-1/0,-1/0];return Me(e,e=>{i[0]>e[0]&&(i[0]=e[0]),i[1]>e[1]&&(i[1]=e[1]),i[2]<e[0]&&(i[2]=e[0]),i[3]<e[1]&&(i[3]=e[1])}),i}var De=Le;function Re(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return[...e.geometry.coordinates];if("Point"===e.type)return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function ze(e){if(Array.isArray(e))return e;if("Feature"===e.type){if(null!==e.geometry)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function Fe(e){return"Feature"===e.type?e.geometry:e}function Oe(e,t){return"FeatureCollection"===e.type?"FeatureCollection":"GeometryCollection"===e.type?"GeometryCollection":"Feature"===e.type&&null!==e.geometry?e.geometry.type:e.type}function Ne(e,t,i,n={}){const r=Re(e),o=Te(r[0]),s=Te(r[1]),a=Te(i),l=we(t,n.units),c=Math.asin(Math.sin(s)*Math.cos(l)+Math.cos(s)*Math.sin(l)*Math.cos(a));return ge([Ee(o+Math.atan2(Math.sin(a)*Math.sin(l)*Math.cos(s),Math.cos(l)-Math.sin(s)*Math.sin(c))),Ee(c)],n.properties)}var Be=function(e,t,i={}){const n=i.steps||64,r=i.properties?i.properties:!Array.isArray(e)&&"Feature"===e.type&&e.properties?e.properties:{},o=[];for(let r=0;r<n;r++)o.push(Ne(e,t,-360*r/n,i).geometry.coordinates);return o.push(o[0]),ye([o],r)};function Ge(e,t,i={}){var n=Re(e),r=Re(t),o=Te(r[1]-n[1]),s=Te(r[0]-n[0]),a=Te(n[1]),l=Te(r[1]),c=Math.pow(Math.sin(o/2),2)+Math.pow(Math.sin(s/2),2)*Math.cos(a)*Math.cos(l);return be(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)),i.units)}var je=Ge;function Ve(e,t={}){const i=Fe(e);switch(!t.properties&&"Feature"===e.type&&(t.properties=e.properties),i.type){case"Polygon":return function(e,t={}){const i=Fe(e).coordinates,n=t.properties?t.properties:"Feature"===e.type?e.properties:{};return Ue(i,n)}(i,t);case"MultiPolygon":return function(e,t={}){const i=Fe(e).coordinates,n=t.properties?t.properties:"Feature"===e.type?e.properties:{},r=[];return i.forEach(e=>{r.push(Ue(e,n))}),ve(r)}(i,t);default:throw new Error("invalid poly")}}function Ue(e,t){return e.length>1?function(e,t,i={}){return me({type:"MultiLineString",coordinates:e},t,i)}(e,t):_e(e[0],t)}var qe="object"==typeof global&&global&&global.Object===Object&&global,Ze="object"==typeof self&&self&&self.Object===Object&&self,$e=qe||Ze||Function("return this")(),He=$e.Symbol,We=Object.prototype,Xe=We.hasOwnProperty,Ye=We.toString,Je=He?He.toStringTag:void 0;var Ke=Object.prototype.toString;var Qe=He?He.toStringTag:void 0;function et(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Qe&&Qe in Object(e)?function(e){var t=Xe.call(e,Je),i=e[Je];try{e[Je]=void 0;var n=!0}catch{}var r=Ye.call(e);return n&&(t?e[Je]=i:delete e[Je]),r}(e):function(e){return Ke.call(e)}(e)}function tt(e){return null!=e&&"object"==typeof e}function it(e){return"symbol"==typeof e||tt(e)&&"[object Symbol]"==et(e)}function nt(e,t){for(var i=-1,n=null==e?0:e.length,r=Array(n);++i<n;)r[i]=t(e[i],i,e);return r}var rt=Array.isArray,ot=He?He.prototype:void 0,st=ot?ot.toString:void 0;function at(e){if("string"==typeof e)return e;if(rt(e))return nt(e,at)+"";if(it(e))return st?st.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}var lt=/\s/;var ct=/^\s+/;function ut(e){return e&&e.slice(0,function(e){for(var t=e.length;t--&&lt.test(e.charAt(t)););return t}(e)+1).replace(ct,"")}function ht(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var dt=/^[-+]0x[0-9a-f]+$/i,pt=/^0b[01]+$/i,ft=/^0o[0-7]+$/i,mt=parseInt;function gt(e){if("number"==typeof e)return e;if(it(e))return NaN;if(ht(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=ht(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=ut(e);var i=pt.test(e);return i||ft.test(e)?mt(e.slice(2),i?2:8):dt.test(e)?NaN:+e}function yt(e){return e}function _t(e){if(!ht(e))return!1;var t=et(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var vt=$e["__core-js_shared__"],xt=function(){var e=/[^.]+$/.exec(vt&&vt.keys&&vt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();var bt=Function.prototype.toString;function wt(e){if(null!=e){try{return bt.call(e)}catch{}try{return e+""}catch{}}return""}var Et=/^\[object .+?Constructor\]$/,Tt=Function.prototype,St=Object.prototype,It=Tt.toString,kt=St.hasOwnProperty,Mt=RegExp("^"+It.call(kt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ct(e){return!(!ht(e)||function(e){return!!xt&&xt in e}(e))&&(_t(e)?Mt:Et).test(wt(e))}function Pt(e,t){var i=function(e,t){return null==e?void 0:e[t]}(e,t);return Ct(i)?i:void 0}var At=Pt($e,"WeakMap"),Lt=Object.create,Dt=function(){function e(){}return function(t){if(!ht(t))return{};if(Lt)return Lt(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}();var Rt=Date.now;function zt(e){return function(){return e}}var Ft=function(){try{var e=Pt(Object,"defineProperty");return e({},"",{}),e}catch{}}(),Ot=Ft?function(e,t){return Ft(e,"toString",{configurable:!0,enumerable:!1,value:zt(t),writable:!0})}:yt,Nt=function(e){var t=0,i=0;return function(){var n=Rt(),r=16-(n-i);if(i=n,r>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(Ot);function Bt(e){return e!=e}function Gt(e,t){return!!(null==e?0:e.length)&&function(e,t,i){return t==t?function(e,t,i){for(var n=i-1,r=e.length;++n<r;)if(e[n]===t)return n;return-1}(e,t,i):function(e,t,i){for(var n=e.length,r=i+-1;++r<n;)if(t(e[r],r,e))return r;return-1}(e,Bt,i)}(e,t,0)>-1}var jt=/^(?:0|[1-9]\d*)$/;function Vt(e,t){var i=typeof e;return!!(t=t??9007199254740991)&&("number"==i||"symbol"!=i&&jt.test(e))&&e>-1&&e%1==0&&e<t}function Ut(e,t,i){"__proto__"==t&&Ft?Ft(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}function qt(e,t){return e===t||e!=e&&t!=t}var Zt=Object.prototype.hasOwnProperty;function $t(e,t,i){var n=e[t];(!Zt.call(e,t)||!qt(n,i)||void 0===i&&!(t in e))&&Ut(e,t,i)}var Ht=Math.max;function Wt(e,t){return Nt(function(e,t,i){return t=Ht(void 0===t?e.length-1:t,0),function(){for(var n=arguments,r=-1,o=Ht(n.length-t,0),s=Array(o);++r<o;)s[r]=n[t+r];r=-1;for(var a=Array(t+1);++r<t;)a[r]=n[r];return a[t]=i(s),function(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)}(e,this,a)}}(e,t,yt),e+"")}function Xt(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function Yt(e){return null!=e&&Xt(e.length)&&!_t(e)}function Jt(e,t,i){if(!ht(i))return!1;var n=typeof t;return!!("number"==n?Yt(i)&&Vt(t,i.length):"string"==n&&t in i)&&qt(i[t],e)}function Kt(e){return Wt(function(t,i){var n=-1,r=i.length,o=r>1?i[r-1]:void 0,s=r>2?i[2]:void 0;for(o=e.length>3&&"function"==typeof o?(r--,o):void 0,s&&Jt(i[0],i[1],s)&&(o=r<3?void 0:o,r=1),t=Object(t);++n<r;){var a=i[n];a&&e(t,a,n,o)}return t})}var Qt=Object.prototype;function ei(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Qt)}function ti(e){return tt(e)&&"[object Arguments]"==et(e)}var ii=Object.prototype,ni=ii.hasOwnProperty,ri=ii.propertyIsEnumerable,oi=ti(function(){return arguments}())?ti:function(e){return tt(e)&&ni.call(e,"callee")&&!ri.call(e,"callee")};var si="object"==typeof e&&e&&!e.nodeType&&e,ai=si&&"object"==typeof module&&module&&!module.nodeType&&module,li=ai&&ai.exports===si?$e.Buffer:void 0,ci=(li?li.isBuffer:void 0)||function(){return!1},ui={};function hi(e){return function(t){return e(t)}}ui["[object Float32Array]"]=ui["[object Float64Array]"]=ui["[object Int8Array]"]=ui["[object Int16Array]"]=ui["[object Int32Array]"]=ui["[object Uint8Array]"]=ui["[object Uint8ClampedArray]"]=ui["[object Uint16Array]"]=ui["[object Uint32Array]"]=!0,ui["[object Arguments]"]=ui["[object Array]"]=ui["[object ArrayBuffer]"]=ui["[object Boolean]"]=ui["[object DataView]"]=ui["[object Date]"]=ui["[object Error]"]=ui["[object Function]"]=ui["[object Map]"]=ui["[object Number]"]=ui["[object Object]"]=ui["[object RegExp]"]=ui["[object Set]"]=ui["[object String]"]=ui["[object WeakMap]"]=!1;var di="object"==typeof e&&e&&!e.nodeType&&e,pi=di&&"object"==typeof module&&module&&!module.nodeType&&module,fi=pi&&pi.exports===di&&qe.process,mi=function(){try{return pi&&pi.require&&pi.require("util").types||fi&&fi.binding&&fi.binding("util")}catch{}}(),gi=mi&&mi.isTypedArray,yi=gi?hi(gi):function(e){return tt(e)&&Xt(e.length)&&!!ui[et(e)]},_i=Object.prototype.hasOwnProperty;function vi(e,t){var i=rt(e),n=!i&&oi(e),r=!i&&!n&&ci(e),o=!i&&!n&&!r&&yi(e),s=i||n||r||o,a=s?function(e,t){for(var i=-1,n=Array(e);++i<e;)n[i]=t(i);return n}(e.length,String):[],l=a.length;for(var c in e)(t||_i.call(e,c))&&(!s||!("length"==c||r&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Vt(c,l)))&&a.push(c);return a}function xi(e,t){return function(i){return e(t(i))}}var bi=xi(Object.keys,Object),wi=Object.prototype.hasOwnProperty;function Ei(e){return Yt(e)?vi(e):function(e){if(!ei(e))return bi(e);var t=[];for(var i in Object(e))wi.call(e,i)&&"constructor"!=i&&t.push(i);return t}(e)}var Ti=Object.prototype.hasOwnProperty;function Si(e){if(!ht(e))return function(e){var t=[];if(null!=e)for(var i in Object(e))t.push(i);return t}(e);var t=ei(e),i=[];for(var n in e)"constructor"==n&&(t||!Ti.call(e,n))||i.push(n);return i}function Ii(e){return Yt(e)?vi(e,!0):Si(e)}var ki=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Mi=/^\w*$/;function Ci(e,t){if(rt(e))return!1;var i=typeof e;return!("number"!=i&&"symbol"!=i&&"boolean"!=i&&null!=e&&!it(e))||(Mi.test(e)||!ki.test(e)||null!=t&&e in Object(t))}var Pi=Pt(Object,"create");var Ai=Object.prototype.hasOwnProperty;var Li=Object.prototype.hasOwnProperty;function Di(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}function Ri(e,t){for(var i=e.length;i--;)if(qt(e[i][0],t))return i;return-1}Di.prototype.clear=function(){this.__data__=Pi?Pi(null):{},this.size=0},Di.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Di.prototype.get=function(e){var t=this.__data__;if(Pi){var i=t[e];return"__lodash_hash_undefined__"===i?void 0:i}return Ai.call(t,e)?t[e]:void 0},Di.prototype.has=function(e){var t=this.__data__;return Pi?void 0!==t[e]:Li.call(t,e)},Di.prototype.set=function(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=Pi&&void 0===t?"__lodash_hash_undefined__":t,this};var zi=Array.prototype.splice;function Fi(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}Fi.prototype.clear=function(){this.__data__=[],this.size=0},Fi.prototype.delete=function(e){var t=this.__data__,i=Ri(t,e);return!(i<0)&&(i==t.length-1?t.pop():zi.call(t,i,1),--this.size,!0)},Fi.prototype.get=function(e){var t=this.__data__,i=Ri(t,e);return i<0?void 0:t[i][1]},Fi.prototype.has=function(e){return Ri(this.__data__,e)>-1},Fi.prototype.set=function(e,t){var i=this.__data__,n=Ri(i,e);return n<0?(++this.size,i.push([e,t])):i[n][1]=t,this};var Oi=Pt($e,"Map");function Ni(e,t){var i=e.__data__;return function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?i["string"==typeof t?"string":"hash"]:i.map}function Bi(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}Bi.prototype.clear=function(){this.size=0,this.__data__={hash:new Di,map:new(Oi||Fi),string:new Di}},Bi.prototype.delete=function(e){var t=Ni(this,e).delete(e);return this.size-=t?1:0,t},Bi.prototype.get=function(e){return Ni(this,e).get(e)},Bi.prototype.has=function(e){return Ni(this,e).has(e)},Bi.prototype.set=function(e,t){var i=Ni(this,e),n=i.size;return i.set(e,t),this.size+=i.size==n?0:1,this};function Gi(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var i=function(){var n=arguments,r=t?t.apply(this,n):n[0],o=i.cache;if(o.has(r))return o.get(r);var s=e.apply(this,n);return i.cache=o.set(r,s)||o,s};return i.cache=new(Gi.Cache||Bi),i}Gi.Cache=Bi;var ji=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Vi=/\\(\\)?/g,Ui=function(e){var t=Gi(e,function(e){return 500===i.size&&i.clear(),e}),i=t.cache;return t}(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(ji,function(e,i,n,r){t.push(n?r.replace(Vi,"$1"):i||e)}),t});function qi(e,t){return rt(e)?e:Ci(e,t)?[e]:Ui(function(e){return null==e?"":at(e)}(e))}function Zi(e){if("string"==typeof e||it(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function $i(e,t){for(var i=0,n=(t=qi(t,e)).length;null!=e&&i<n;)e=e[Zi(t[i++])];return i&&i==n?e:void 0}function Hi(e,t,i){var n=null==e?void 0:$i(e,t);return void 0===n?i:n}function Wi(e,t){for(var i=-1,n=t.length,r=e.length;++i<n;)e[r+i]=t[i];return e}var Xi=He?He.isConcatSpreadable:void 0;function Yi(e){return rt(e)||oi(e)||!!(Xi&&e&&e[Xi])}var Ji=xi(Object.getPrototypeOf,Object),Ki=Function.prototype,Qi=Object.prototype,en=Ki.toString,tn=Qi.hasOwnProperty,nn=en.call(Object);function rn(e){var t=this.__data__=new Fi(e);this.size=t.size}rn.prototype.clear=function(){this.__data__=new Fi,this.size=0},rn.prototype.delete=function(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i},rn.prototype.get=function(e){return this.__data__.get(e)},rn.prototype.has=function(e){return this.__data__.has(e)},rn.prototype.set=function(e,t){var i=this.__data__;if(i instanceof Fi){var n=i.__data__;if(!Oi||n.length<199)return n.push([e,t]),this.size=++i.size,this;i=this.__data__=new Bi(n)}return i.set(e,t),this.size=i.size,this};var on="object"==typeof e&&e&&!e.nodeType&&e,sn=on&&"object"==typeof module&&module&&!module.nodeType&&module,an=sn&&sn.exports===on?$e.Buffer:void 0,ln=an?an.allocUnsafe:void 0;function cn(e,t){if(t)return e.slice();var i=e.length,n=ln?ln(i):new e.constructor(i);return e.copy(n),n}var un=Object.prototype.propertyIsEnumerable,hn=Object.getOwnPropertySymbols,dn=hn?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var i=-1,n=null==e?0:e.length,r=0,o=[];++i<n;){var s=e[i];t(s,i,e)&&(o[r++]=s)}return o}(hn(e),function(t){return un.call(e,t)}))}:function(){return[]};function pn(e){return function(e,t,i){var n=t(e);return rt(e)?n:Wi(n,i(e))}(e,Ei,dn)}var fn=Pt($e,"DataView"),mn=Pt($e,"Promise"),gn=Pt($e,"Set"),yn="[object Map]",_n="[object Promise]",vn="[object Set]",xn="[object WeakMap]",bn="[object DataView]",wn=wt(fn),En=wt(Oi),Tn=wt(mn),Sn=wt(gn),In=wt(At),kn=et;(fn&&kn(new fn(new ArrayBuffer(1)))!=bn||Oi&&kn(new Oi)!=yn||mn&&kn(mn.resolve())!=_n||gn&&kn(new gn)!=vn||At&&kn(new At)!=xn)&&(kn=function(e){var t=et(e),i="[object Object]"==t?e.constructor:void 0,n=i?wt(i):"";if(n)switch(n){case wn:return bn;case En:return yn;case Tn:return _n;case Sn:return vn;case In:return xn}return t});var Mn=Object.prototype.hasOwnProperty;var Cn=$e.Uint8Array;function Pn(e){var t=new e.constructor(e.byteLength);return new Cn(t).set(new Cn(e)),t}var An=/\w*$/;var Ln=He?He.prototype:void 0,Dn=Ln?Ln.valueOf:void 0;function Rn(e,t){var i=t?Pn(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}function zn(e,t,i){var n=e.constructor;switch(t){case"[object ArrayBuffer]":return Pn(e);case"[object Boolean]":case"[object Date]":return new n(+e);case"[object DataView]":return function(e){var t=Pn(e.buffer);return new e.constructor(t,e.byteOffset,e.byteLength)}(e);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return Rn(e,i);case"[object Map]":case"[object Set]":return new n;case"[object Number]":case"[object String]":return new n(e);case"[object RegExp]":return function(e){var t=new e.constructor(e.source,An.exec(e));return t.lastIndex=e.lastIndex,t}(e);case"[object Symbol]":return function(e){return Dn?Object(Dn.call(e)):{}}(e)}}function Fn(e){return"function"!=typeof e.constructor||ei(e)?{}:Dt(Ji(e))}var On=mi&&mi.isMap,Nn=On?hi(On):function(e){return tt(e)&&"[object Map]"==kn(e)};var Bn=mi&&mi.isSet,Gn=Bn?hi(Bn):function(e){return tt(e)&&"[object Set]"==kn(e)},jn="[object Arguments]",Vn="[object Function]",Un="[object Object]",qn={};function Zn(e,t,i,n,r,o){var s,a=1&t;if(void 0!==s)return s;if(!ht(e))return e;var l=rt(e);if(l)s=function(e){var t=e.length,i=new e.constructor(t);return t&&"string"==typeof e[0]&&Mn.call(e,"index")&&(i.index=e.index,i.input=e.input),i}(e);else{var c=kn(e),u=c==Vn||"[object GeneratorFunction]"==c;if(ci(e))return cn(e,a);if(c==Un||c==jn||u&&!r)s=u?{}:Fn(e);else{if(!qn[c])return r?e:{};s=zn(e,c,a)}}o||(o=new rn);var h=o.get(e);if(h)return h;o.set(e,s),Gn(e)?e.forEach(function(n){s.add(Zn(n,t,i,n,e,o))}):Nn(e)&&e.forEach(function(n,r){s.set(r,Zn(n,t,i,r,e,o))});var d=l?void 0:pn(e);return function(e,t){for(var i=-1,n=null==e?0:e.length;++i<n&&!1!==t(e[i],i,e););}(d||e,function(n,r){d&&(n=e[r=n]),$t(s,r,Zn(n,t,i,r,e,o))}),s}qn[jn]=qn["[object Array]"]=qn["[object ArrayBuffer]"]=qn["[object DataView]"]=qn["[object Boolean]"]=qn["[object Date]"]=qn["[object Float32Array]"]=qn["[object Float64Array]"]=qn["[object Int8Array]"]=qn["[object Int16Array]"]=qn["[object Int32Array]"]=qn["[object Map]"]=qn["[object Number]"]=qn[Un]=qn["[object RegExp]"]=qn["[object Set]"]=qn["[object String]"]=qn["[object Symbol]"]=qn["[object Uint8Array]"]=qn["[object Uint8ClampedArray]"]=qn["[object Uint16Array]"]=qn["[object Uint32Array]"]=!0,qn["[object Error]"]=qn[Vn]=qn["[object WeakMap]"]=!1;function $n(e){return Zn(e,5)}function Hn(e){var t=-1,i=null==e?0:e.length;for(this.__data__=new Bi;++t<i;)this.add(e[t])}function Wn(e,t){for(var i=-1,n=null==e?0:e.length;++i<n;)if(t(e[i],i,e))return!0;return!1}function Xn(e,t){return e.has(t)}Hn.prototype.add=Hn.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},Hn.prototype.has=function(e){return this.__data__.has(e)};function Yn(e,t,i,n,r,o){var s=1&i,a=e.length,l=t.length;if(a!=l&&!(s&&l>a))return!1;var c=o.get(e),u=o.get(t);if(c&&u)return c==t&&u==e;var h=-1,d=!0,p=2&i?new Hn:void 0;for(o.set(e,t),o.set(t,e);++h<a;){var f=e[h],m=t[h];if(n)var g=s?n(m,f,h,t,e,o):n(f,m,h,e,t,o);if(void 0!==g){if(g)continue;d=!1;break}if(p){if(!Wn(t,function(e,t){if(!Xn(p,t)&&(f===e||r(f,e,i,n,o)))return p.push(t)})){d=!1;break}}else if(f!==m&&!r(f,m,i,n,o)){d=!1;break}}return o.delete(e),o.delete(t),d}function Jn(e){var t=-1,i=Array(e.size);return e.forEach(function(e,n){i[++t]=[n,e]}),i}function Kn(e){var t=-1,i=Array(e.size);return e.forEach(function(e){i[++t]=e}),i}var Qn=He?He.prototype:void 0,er=Qn?Qn.valueOf:void 0;var tr=Object.prototype.hasOwnProperty;var ir="[object Arguments]",nr="[object Array]",rr="[object Object]",or=Object.prototype.hasOwnProperty;function sr(e,t,i,n,r,o){var s=rt(e),a=rt(t),l=s?nr:kn(e),c=a?nr:kn(t),u=(l=l==ir?rr:l)==rr,h=(c=c==ir?rr:c)==rr,d=l==c;if(d&&ci(e)){if(!ci(t))return!1;s=!0,u=!1}if(d&&!u)return o||(o=new rn),s||yi(e)?Yn(e,t,i,n,r,o):function(e,t,i,n,r,o,s){switch(i){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!o(new Cn(e),new Cn(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return qt(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var a=Jn;case"[object Set]":var l=1&n;if(a||(a=Kn),e.size!=t.size&&!l)return!1;var c=s.get(e);if(c)return c==t;n|=2,s.set(e,t);var u=Yn(a(e),a(t),n,r,o,s);return s.delete(e),u;case"[object Symbol]":if(er)return er.call(e)==er.call(t)}return!1}(e,t,l,i,n,r,o);if(!(1&i)){var p=u&&or.call(e,"__wrapped__"),f=h&&or.call(t,"__wrapped__");if(p||f){var m=p?e.value():e,g=f?t.value():t;return o||(o=new rn),r(m,g,i,n,o)}}return!!d&&(o||(o=new rn),function(e,t,i,n,r,o){var s=1&i,a=pn(e),l=a.length;if(l!=pn(t).length&&!s)return!1;for(var c=l;c--;){var u=a[c];if(!(s?u in t:tr.call(t,u)))return!1}var h=o.get(e),d=o.get(t);if(h&&d)return h==t&&d==e;var p=!0;o.set(e,t),o.set(t,e);for(var f=s;++c<l;){var m=e[u=a[c]],g=t[u];if(n)var y=s?n(g,m,u,t,e,o):n(m,g,u,e,t,o);if(!(void 0===y?m===g||r(m,g,i,n,o):y)){p=!1;break}f||(f="constructor"==u)}if(p&&!f){var _=e.constructor,v=t.constructor;_!=v&&"constructor"in e&&"constructor"in t&&!("function"==typeof _&&_ instanceof _&&"function"==typeof v&&v instanceof v)&&(p=!1)}return o.delete(e),o.delete(t),p}(e,t,i,n,r,o))}function ar(e,t,i,n,r){return e===t||(null==e||null==t||!tt(e)&&!tt(t)?e!=e&&t!=t:sr(e,t,i,n,ar,r))}function lr(e){return e==e&&!ht(e)}function cr(e,t){return function(i){return null!=i&&(i[e]===t&&(void 0!==t||e in Object(i)))}}function ur(e){var t=function(e){for(var t=Ei(e),i=t.length;i--;){var n=t[i],r=e[n];t[i]=[n,r,lr(r)]}return t}(e);return 1==t.length&&t[0][2]?cr(t[0][0],t[0][1]):function(i){return i===e||function(e,t,i,n){var r=i.length,o=r;if(null==e)return!o;for(e=Object(e);r--;){var s=i[r];if(s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++r<o;){var a=(s=i[r])[0],l=e[a],c=s[1];if(s[2]){if(void 0===l&&!(a in e))return!1}else if(!ar(c,l,3,n,new rn))return!1}return!0}(i,0,t)}}function hr(e,t){return null!=e&&t in Object(e)}function dr(e,t){return null!=e&&function(e,t,i){for(var n=-1,r=(t=qi(t,e)).length,o=!1;++n<r;){var s=Zi(t[n]);if(!(o=null!=e&&i(e,s)))break;e=e[s]}return o||++n!=r?o:!!(r=null==e?0:e.length)&&Xt(r)&&Vt(s,r)&&(rt(e)||oi(e))}(e,t,hr)}function pr(e){return Ci(e)?function(e){return function(t){return null==t?void 0:t[e]}}(Zi(e)):function(e){return function(t){return $i(t,e)}}(e)}function fr(e){return"function"==typeof e?e:null==e?yt:"object"==typeof e?rt(e)?function(e,t){return Ci(e)&&lr(t)?cr(Zi(e),t):function(i){var n=Hi(i,e);return void 0===n&&n===t?dr(i,e):ar(t,n,3)}}(e[0],e[1]):ur(e):pr(e)}function mr(e,t,i,n){for(var r=-1,o=null==e?0:e.length;++r<o;){var s=e[r];t(n,s,i(s),e)}return n}var gr=function(e,t,i){for(var n=-1,r=Object(e),o=i(e),s=o.length;s--;){var a=o[++n];if(!1===t(r[a],a,r))break}return e};var yr=function(e){return function(t,i){if(null==t)return t;if(!Yt(t))return e(t,i);for(var n=t.length,r=-1,o=Object(t);++r<n&&!1!==i(o[r],r,o););return t}}(function(e,t){return e&&gr(e,t,Ei)});function _r(e,t,i,n){return yr(e,function(e,r,o){t(n,e,i(e),o)}),n}var vr=function(){return $e.Date.now()},xr=Math.max,br=Math.min;function wr(e,t,i){var n,r,o,s,a,l,c=0,u=!1,h=!1,d=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function p(t){var i=n,o=r;return n=r=void 0,c=t,s=e.apply(o,i)}function f(e){var i=e-l;return void 0===l||i>=t||i<0||h&&e-c>=o}function m(){var e=vr();if(f(e))return g(e);a=setTimeout(m,function(e){var i=t-(e-l);return h?br(i,o-(e-c)):i}(e))}function g(e){return a=void 0,d&&n?p(e):(n=r=void 0,s)}function y(){var e=vr(),i=f(e);if(n=arguments,r=this,l=e,i){if(void 0===a)return function(e){return c=e,a=setTimeout(m,t),u?p(e):s}(l);if(h)return clearTimeout(a),a=setTimeout(m,t),p(l)}return void 0===a&&(a=setTimeout(m,t)),s}return t=gt(t)||0,ht(i)&&(u=!!i.leading,o=(h="maxWait"in i)?xr(gt(i.maxWait)||0,t):o,d="trailing"in i?!!i.trailing:d),y.cancel=function(){void 0!==a&&clearTimeout(a),c=0,n=l=r=a=void 0},y.flush=function(){return void 0===a?s:g(vr())},y}function Er(e,t,i){(void 0!==i&&!qt(e[t],i)||void 0===i&&!(t in e))&&Ut(e,t,i)}function Tr(e){return tt(e)&&Yt(e)}function Sr(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}function Ir(e){return function(e,t,i){var n=!i;i||(i={});for(var r=-1,o=t.length;++r<o;){var s=t[r],a=void 0;void 0===a&&(a=e[s]),n?Ut(i,s,a):$t(i,s,a)}return i}(e,Ii(e))}function kr(e,t,i,n,r,o,s){var a=Sr(e,i),l=Sr(t,i),c=s.get(l);if(c)Er(e,i,c);else{var u=o?o(a,l,i+"",e,t,s):void 0,h=void 0===u;if(h){var d=rt(l),p=!d&&ci(l),f=!d&&!p&&yi(l);u=l,d||p||f?rt(a)?u=a:Tr(a)?u=function(e,t){var i=-1,n=e.length;for(t||(t=Array(n));++i<n;)t[i]=e[i];return t}(a):p?(h=!1,u=cn(l,!0)):f?(h=!1,u=Rn(l,!0)):u=[]:function(e){if(!tt(e)||"[object Object]"!=et(e))return!1;var t=Ji(e);if(null===t)return!0;var i=tn.call(t,"constructor")&&t.constructor;return"function"==typeof i&&i instanceof i&&en.call(i)==nn}(l)||oi(l)?(u=a,oi(a)?u=Ir(a):(!ht(a)||_t(a))&&(u=Fn(l))):h=!1}h&&(s.set(l,u),r(u,l,n,o,s),s.delete(l)),Er(e,i,u)}}function Mr(e,t,i,n,r){e!==t&&gr(t,function(o,s){if(r||(r=new rn),ht(o))kr(e,t,s,i,Mr,n,r);else{var a=n?n(Sr(e,s),o,s+"",e,t,r):void 0;void 0===a&&(a=o),Er(e,s,a)}},Ii)}var Cr=Kt(function(e,t,i,n){Mr(e,t,i,n)});function Pr(e,t,i){for(var n=-1,r=null==e?0:e.length;++n<r;)if(i(t,e[n]))return!0;return!1}function Ar(e){return null==e?[]:function(e,t){return nt(t,function(t){return e[t]})}(e,Ei(e))}var Lr=Math.min;function Dr(e){return Tr(e)?e:[]}var Rr=Wt(function(e){var t=nt(e,Dr);return t.length&&t[0]===e[0]?function(e){for(var t=Gt,i=e[0].length,n=e.length,r=n,o=Array(n),s=1/0,a=[];r--;){var l=e[r];s=Lr(l.length,s),o[r]=i>=120&&l.length>=120?new Hn(r&&l):void 0}l=e[0];var c=-1,u=o[0];e:for(;++c<i&&a.length<s;){var h=l[c],d=h;if(h=0!==h?h:0,!(u?Xn(u,d):t(a,d))){for(r=n;--r;){var p=o[r];if(!(p?Xn(p,d):t(e[r],d)))continue e}u&&u.push(d),a.push(h)}}return a}(t):[]});function zr(e,t){return ar(e,t)}var Fr=function(e,t){return function(i,n){var r=rt(i)?mr:_r,o=t?t():{};return r(i,e,fr(n),o)}}(function(e,t,i){Ut(e,i,t)}),Or=Kt(function(e,t,i){Mr(e,t,i)});function Nr(e,t){if(e!==t){var i=void 0!==e,n=null===e,r=e==e,o=it(e),s=void 0!==t,a=null===t,l=t==t,c=it(t);if(!a&&!c&&!o&&e>t||o&&s&&l&&!a&&!c||n&&s&&l||!i&&l||!r)return 1;if(!n&&!o&&!c&&e<t||c&&i&&r&&!n&&!o||a&&i&&r||!s&&r||!l)return-1}return 0}function Br(e,t,i){t=t.length?nt(t,function(e){return rt(e)?function(t){return $i(t,1===e.length?e[0]:e)}:e}):[yt];var n=-1;t=nt(t,hi(fr));var r=function(e,t){var i=-1,n=Yt(e)?Array(e.length):[];return yr(e,function(e,r,o){n[++i]=t(e,r,o)}),n}(e,function(e,i,r){return{criteria:nt(t,function(t){return t(e)}),index:++n,value:e}});return function(e,t){var i=e.length;for(e.sort(t);i--;)e[i]=e[i].value;return e}(r,function(e,t){return function(e,t,i){for(var n=-1,r=e.criteria,o=t.criteria,s=r.length,a=i.length;++n<s;){var l=Nr(r[n],o[n]);if(l)return n>=a?l:l*("desc"==i[n]?-1:1)}return e.index-t.index}(e,t,i)})}var Gr=Wt(function(e,t){if(null==e)return[];var i=t.length;return i>1&&Jt(e,t[0],t[1])?t=[]:i>2&&Jt(t[0],t[1],t[2])&&(t=[t[0]]),Br(e,function(e,t,i,n,r){var o=-1,s=e.length;for(i||(i=Yi),r||(r=[]);++o<s;){var a=e[o];i(a)?Wi(r,a):r[r.length]=a}return r}(t),[])});function jr(e,t,i){var n=!0,r=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return ht(i)&&(n="leading"in i?!!i.leading:n,r="trailing"in i?!!i.trailing:r),wr(e,t,{leading:n,maxWait:t,trailing:r})}var Vr=gn&&1/Kn(new gn([,-0]))[1]==1/0?function(e){return new gn(e)}:function(){};function Ur(e,t){return t="function"==typeof t?t:void 0,e&&e.length?function(e,t,i){var n=-1,r=Gt,o=e.length,s=!0,a=[],l=a;if(i)s=!1,r=Pr;else if(o>=200){var c=Vr(e);if(c)return Kn(c);s=!1,r=Xn,l=new Hn}else l=a;e:for(;++n<o;){var u=e[n],h=u;if(u=i||0!==u?u:0,s&&h==h){for(var d=l.length;d--;)if(l[d]===h)continue e;a.push(u)}else r(l,h,i)||(l!==a&&l.push(h),a.push(u))}return a}(e,0,t):[]}const qr=(e,t)=>e[0]===t[0]&&e[1]===t[1],Zr=e=>"Feature"===e.type&&"LineString"===e.geometry.type,$r=e=>"Feature"===e.type&&"Polygon"===e.geometry.type,Hr=e=>"Feature"===e.type&&"MultiPolygon"===e.geometry.type,Wr=(e,t)=>({lng:t[0]-e[0],lat:t[1]-e[1]}),Xr=e=>Array.isArray(e)&&e.length>=2&&e.length<=3&&e.every(e=>"number"==typeof e),Yr=(e,t,i=!1)=>{let n=0;const r=["features","geometries","geometry","coordinates"],o=(e,s,a=!1)=>{Xr(e)?(t({coordinate:e,path:s},n),n+=1):Array.isArray(e)?e.forEach((t,n)=>{a&&i&&n===e.length-1&&Xr(t)||o(t,[...s,n],a)}):"object"==typeof e&&null!==e&&te(e).forEach(t=>{const i=e[t];if(r.includes(t)&&i){const n="type"in e&&e.type,r="Polygon"===n||"MultiPolygon"===n;o(i,[...s,t],r)}})};o(e,[])},Jr=(e,t)=>{let i=0;const n=["features","geometries","geometry","coordinates"],r=(e,o,s,a)=>{Xr(e)&&Xr(o)?(t({start:{coordinate:[...e],path:s},end:{coordinate:[...o],path:a}},i),i+=1):Array.isArray(e)?e.forEach((t,i)=>{r(t,e[i+1],[...s,i],[...s,i+1])}):"object"==typeof e&&null!==e&&te(e).forEach(t=>{const i=e[t];n.includes(t)&&i&&r(i,void 0,[...s,t],[])})};r(e,void 0,[],[])},Kr=(e,t)=>{let i={absCoordIndex:-1,featureIndex:-1,multiFeatureIndex:-1,geometryIndex:-1};try{Me(e,(e,n,r,o,s)=>{if(e[0]===t[0]&&e[1]===t[1])throw i={absCoordIndex:n,featureIndex:r,multiFeatureIndex:o,geometryIndex:s},new Error("found")})}catch{}return i},Qr=(e,t)=>{const[i,n]=e,[r,o]=t;return[Math.min(i,r),Math.min(n,o),Math.max(i,r),Math.max(n,o)]},eo=(e,t)=>{const i=Qr(e,t),n=[i[0],i[1]],r=[i[2],i[3]],o=n[0],s=n[1],a=r[0],l=r[1];return{type:"Feature",properties:{shape:"rectangle"},geometry:{type:"Polygon",coordinates:[[[o,s],[a,s],[a,l],[o,l],[o,s]]]}}},to=e=>[e.geometry.coordinates[0],e.geometry.coordinates[1]],io=e=>{const t=De(e);return[[t[0],t[1]],[t[2],t[3]]]},no=e=>{let t=0;return Me(e,()=>{t+=1},!0),t},ro=e=>{const t=(e=>{const t=[];return Me(e,e=>{t.push([e[0],e[1]])},!0),t})(e);return t.some(e=>!zr(t[0],e))},oo=e=>{let t=null;try{Yr(e,e=>{throw t=e.coordinate,new Error("found")})}catch{return t}return null},so=(e,t)=>Math.sqrt((e[0]-t[0])**2+(e[1]-t[1])**2),ao=(e,t)=>Zr(e)?((e,t)=>{const{absCoordIndex:i}=Kr(e,t);return-1!==i&&(e.geometry.coordinates.splice(i,1),!0)})(e,t):$r(e)?((e,t)=>{const i=Kr(e,t);if(-1!==i.absCoordIndex){const n=[i.geometryIndex],r=Hi(e.geometry.coordinates,n),o=r.findIndex(e=>zr(e,t));return r.length<=4?(e.geometry.coordinates.splice(i.geometryIndex,1),!0):(r.splice(o,1),0===o&&(r[r.length-1]=[...r[0]]),!0)}return!1})(e,t):!!Hr(e)&&((e,t)=>{const i=Kr(e,t);if(-1!==i.absCoordIndex){const n=[i.multiFeatureIndex,i.geometryIndex],r=Hi(e.geometry.coordinates,n),o=r.findIndex(e=>zr(e,t));if(r.length<=4){n.pop();const t=Hi(e.geometry.coordinates,i.multiFeatureIndex);return t.splice(i.geometryIndex,1),0===t.length&&e.geometry.coordinates.splice(i.multiFeatureIndex,1),!0}return r.splice(o,1),0===o&&(r[r.length-1]=[...r[0]]),!0}return!1})(e,t),lo=({center:e,radius:t,steps:i=80})=>{const n=Be(e,t,{steps:i,units:"meters"});return n.geometry.coordinates[0][0]=[...n.geometry.coordinates[0][0]],n};function co(e,t={}){let i=0,n=0,r=0;return Me(e,function(e){i+=e[0],n+=e[1],r++},!0),ge([i/r,n/r],t.properties)}var uo=co;const ho=["circle","rectangle"];class po{constructor(e){X(this,"gm"),X(this,"id","no-id"),X(this,"parent",null),X(this,"shape"),X(this,"markers"),X(this,"shapeProperties",{center:null}),X(this,"source"),X(this,"orders",this.getEmptyOrders()),this.gm=e.gm,this.id=e.id,this.source=e.source,this.parent=e.parent,this.markers=new Map,this.shape=e.geoJsonShapeFeature.properties.shape,this.order=this.getFreeOrder(),this.addGeoJson(e.geoJsonShapeFeature)}get order(){const e=this.source.id;if(null!==this.orders[e])return this.orders[e];throw new Error(`Null order for feature id: ${this.id}`)}set order(e){const t=this.source.id;this.orders[t]=e}getEmptyOrders(){return Object.fromEntries(ie(tl).map(e=>[e,null]))}get temporary(){return this.source.id===tl.temporary}get sourceName(){return this.source.id}getFreeOrder(){return this.getSourceGeoJson().features.length}getGeoJson(){if(!this.isFeatureAvailable())throw new Error(`Feature not found: "${this.id}"`);this.fixOrder();const e=this.getSourceGeoJson().features[this.order]||null;if(this.id!==(null==e?void 0:e.id))throw he.error(`Feature not found: ${this.id} !== ${null==e?void 0:e.id}`,e,this.getSourceGeoJson()),new Error("Feature not found");return e}getShapeProperty(e){return this.shapeProperties[e]}setShapeProperty(e,t){this.shapeProperties[e]=t}getSourceGeoJson(){return this.source.getGeoJson()}addGeoJson(e){if(!this.isFeatureAvailable())throw new Error(`Feature not found: "${this.id}"`);const t=this.getSourceGeoJson();t.features[this.order]&&he.error("FeatureData.addGeoJson, not an empty feature",this.id,t);const i={...e,id:this.id,properties:{...e.properties,[il]:this.id}};t.features[this.order]=i,this.updateGeoJsonCenter(i),this.gm.features.updateSourceData({diff:{add:[i]},sourceName:this.sourceName})}removeGeoJson(){if(!this.isFeatureAvailable())throw new Error(`Feature not found: "${this.id}"`);this.fixOrder();delete this.getSourceGeoJson().features[this.order],this.gm.features.updateSourceData({diff:{remove:[this.id]},sourceName:this.sourceName}),this.order=null}removeMarkers(){this.markers.forEach(e=>{e.instance instanceof de?e.instance.remove():this.gm.features.delete(e.instance)}),this.markers=new Map}updateGeoJsonGeometry(e){if(!this.isFeatureAvailable())throw new Error(`Feature not found: "${this.id}"`);this.fixOrder();const t=this.getSourceGeoJson();t.features[this.order].geometry=e;const i={update:[t.features[this.order]]};this.gm.features.updateSourceData({diff:i,sourceName:this.sourceName})}updateGeoJsonProperties(e){if(!this.isFeatureAvailable())throw new Error(`Feature not found: "${this.id}"`);this.fixOrder();const t=this.getSourceGeoJson();t.features[this.order].properties={...t.features[this.order].properties,...e};const i={update:[t.features[this.order]]};this.gm.features.updateSourceData({diff:i,sourceName:this.sourceName})}updateGeoJsonCenter(e){if("circle"===this.shape){const t=to(uo(e));this.setShapeProperty("center",t)}}convertToPolygon(){return!!this.isConvertableToPolygon()&&(this.shape="polygon",this.shapeProperties.center=null,!0)}isConvertableToPolygon(){return ho.includes(this.shape)}fixOrder(){if(!this.isFeatureAvailable())throw new Error(`Feature not found: "${this.id}"`)}isFeatureAvailable(){return null!==this.order}changeSource({sourceName:e,atomic:t}){t?this.gm.features.withAtomicSourcesUpdate(()=>this.actualChangeSource({sourceName:e,atomic:t})):this.actualChangeSource({sourceName:e,atomic:t})}actualChangeSource({sourceName:e,atomic:t}){if(this.source.id===e)return void he.error(`FeatureData.changeSource: feature "${this.id}" already has the source "${e}"`);const i=this.gm.features.sources[e];if(!i)return void he.error(`FeatureData.changeSource: missing source "${e}"`);const n=this.getGeoJson();this.removeGeoJson(),this.source=i,this.order=this.getFreeOrder(),this.addGeoJson(n),this.markers.forEach(i=>{i.instance instanceof po&&i.instance.changeSource({sourceName:e,atomic:t})})}delete(){this.removeGeoJson(),this.removeMarkers(),this.id="no-id",this.orders=this.getEmptyOrders()}}const fo=["on","off"],mo=e=>go(e)&&"control"===e.type&&fo.includes(e.action),go=e=>!!(e&&"object"==typeof e&&"level"in e&&"type"in e&&"action"in e),yo=e=>go(e)&&ne(e.action,ee),_o="gm";class vo{constructor(e){X(this,"gm"),this.gm=e}trackExclusiveModes(e){if("mode_start"!==e.action)return;const{sectionName:t,modeName:i}=this.getControlIds(e)||{},n=this.getControl(e);null!=n&&n.settings.exclusive&&this.gm.control.eachControlWithOptions(e=>{const n=e.control.type,r=e.control.targetMode;n===t&&r===i||e.controlOptions.active&&e.control.settings.exclusive&&this.gm.options.disableMode(n,r)})}trackRelatedModes(e){yo(e)&&this.gm.control.eachControlWithOptions(t=>{var i;const n=t.control;null!=(i=n.settings.enabledBy)&&i.includes(e.mode)&&("mode_start"===e.action?this.gm.options.enableMode(n.type,n.targetMode):"mode_end"===e.action?this.gm.options.disableMode(n.type,n.targetMode):he.error("Unknown mode action",e.action))})}getControl(e){const{modeName:t,sectionName:i}=this.getControlIds(e)||{};return t&&i?this.gm.control.getControl({actionType:i,modeName:t}):null}getControlOptions(e){const{modeName:t,sectionName:i}=this.getControlIds(e)||{};return t&&i?this.gm.options.getControlOptions({actionType:i,modeName:t}):null}getControlIds(e){let t=null,i=null;return"mode_start"===e.action?(t=e.type,i=e.mode):mo(e)&&(t=e.section,i=e.target),t&&i?{sectionName:t,modeName:i}:null}}class xo{isInstanceAvailable(){return!!this.sourceInstance||(he.error("Source instance is not available"),!1)}}const bo=["intersection_violation","containment_violation"],wo=e=>go(e)&&"helper"===e.type,Eo=["draw","edit","helper"];class To{constructor(e){X(this,"gm"),X(this,"options",[]),X(this,"actions",[]),X(this,"flags",{featureCreateAllowed:!0,featureUpdateAllowed:!0}),X(this,"internalMapEventHandlers",{[`${_o}:helper`]:this.handleHelperEvent.bind(this)}),this.gm=e}startAction(){this.gm.events.bus.attachEvents(this.internalMapEventHandlers),this.gm.events.bus.attachEvents(this.mapEventHandlers),this.onStartAction()}endAction(){this.onEndAction(),this.gm.events.bus.detachEvents(this.mapEventHandlers),this.gm.events.bus.detachEvents(this.internalMapEventHandlers)}get snappingHelper(){return this.gm.actionInstances.helper__snapping||null}getOptionValue(e){const t=this.options.find(t=>t.name===e);if(!t)throw new Error(`Option ${e} not found`);if("toggle"===t.type)return t.value;if("select"===t.type)return t.value.value;throw new Error(`Unknown option type: ${JSON.stringify(t)}`)}applyOptionValue(e,t){const i=this.options.find(t=>t.name===e);if(i)if("toggle"===i.type&&"boolean"==typeof t)i.value=t;else if("select"===i.type){const e=i.choices.find(e=>e.value===t);e&&(i.value=e)}else he.error("Can't apply option value",e,t,i);else he.error("Option not found",e,t)}handleHelperEvent(e){return(e=>wo(e)&&"geofencing"===e.mode&&ne(e.action,bo))(e)?this.handleGeofencingViolationEvent(e):{next:!0}}handleGeofencingViolationEvent(e){return"draw"===e.actionType?this.flags.featureCreateAllowed=!1:"edit"===e.actionType&&(this.flags.featureUpdateAllowed=!1),{next:!0}}fireBeforeFeatureCreate({geoJsonFeatures:e,forceMode:t}){this.flags.featureCreateAllowed=!0;const i={level:"system",type:this.actionType,mode:t||this.mode,action:"before_create",geoJsonFeatures:e};this.gm.events.fire(`${_o}:${this.actionType}`,i)}fireBeforeFeatureUpdate({features:e,geoJsonFeatures:t,forceMode:i}){this.flags.featureUpdateAllowed=!0;const n={level:"system",type:this.actionType,mode:i||this.mode,action:"before_update",features:e,geoJsonFeatures:t};this.gm.events.fire(`${_o}:${this.actionType}`,n)}}const So=e=>go(e)&&"draw"===e.type,Io=e=>go(e)&&"draw"===e.type&&"variant"in e&&"line_drawer"===e.variant,ko=["marker","circle","circle_marker","text_marker","line","rectangle","polygon"],Mo=[...ko,"freehand","custom_shape"];class Co extends To{constructor(){super(...arguments),X(this,"actionType","draw"),X(this,"shape",null),X(this,"featureData",null)}saveFeature(){if(this.featureData){const e=this.featureData.getGeoJson();this.removeTmpFeature(),this.gm.features.createFeature({sourceName:tl.main,shapeGeoJson:e})}else he.error("BaseDraw.saveFeature: no featureData to save")}removeTmpFeature(){this.featureData&&(this.featureData.temporary||he.error("Not a temporary feature to remove",this.featureData),this.gm.features.delete(this.featureData),this.featureData=null)}fireMarkerPointerStartEvent(){if(!this.gm.markerPointer.marker||!this.shape)return;const e=this.gm.markerPointer.marker,t={level:"system",variant:null,type:"draw",mode:this.shape,action:"start",markerData:{type:"dom",instance:e,position:{coordinate:e.getLngLat(),path:[-1]}},featureData:this.featureData};this.gm.events.fire(`${_o}:draw`,t)}fireMarkerPointerUpdateEvent(){if(!this.gm.markerPointer.marker||!this.shape)return;const e=this.gm.markerPointer.marker,t={level:"system",variant:null,type:"draw",mode:this.shape,action:"update",markerData:{type:"dom",instance:e,position:{coordinate:e.getLngLat(),path:[-1]}},featureData:this.featureData};this.gm.events.fire(`${_o}:draw`,t)}fireMarkerPointerFinishEvent(){if(!this.shape)return;const e={level:"system",variant:null,type:"draw",mode:this.shape,action:"finish"};this.gm.events.fire(`${_o}:draw`,e)}forwardLineDrawerEvent(e){if(!Io(e)||!this.shape)return{next:!0};if("start"===e.action||"update"===e.action){const t={level:"system",type:"draw",mode:this.shape,variant:null,action:e.action,featureData:e.featureData,markerData:e.markerData};this.gm.events.fire(`${_o}:draw`,t)}else if("finish"===e.action||"cancel"===e.action){const t={level:"system",type:"draw",mode:this.shape,variant:null,action:e.action};this.gm.events.fire(`${_o}:draw`,t)}return{next:!0}}}const Po=11102230246251565e-32,Ao=134217729,Lo=(3+8*Po)*Po;function Do(e,t,i,n,r){let o,s,a,l,c=t[0],u=n[0],h=0,d=0;u>c==u>-c?(o=c,c=t[++h]):(o=u,u=n[++d]);let p=0;if(h<e&&d<i)for(u>c==u>-c?(s=c+o,a=o-(s-c),c=t[++h]):(s=u+o,a=o-(s-u),u=n[++d]),o=s,0!==a&&(r[p++]=a);h<e&&d<i;)u>c==u>-c?(s=o+c,l=s-o,a=o-(s-l)+(c-l),c=t[++h]):(s=o+u,l=s-o,a=o-(s-l)+(u-l),u=n[++d]),o=s,0!==a&&(r[p++]=a);for(;h<e;)s=o+c,l=s-o,a=o-(s-l)+(c-l),c=t[++h],o=s,0!==a&&(r[p++]=a);for(;d<i;)s=o+u,l=s-o,a=o-(s-l)+(u-l),u=n[++d],o=s,0!==a&&(r[p++]=a);return(0!==o||0===p)&&(r[p++]=o),p}function Ro(e){return new Float64Array(e)}const zo=(3+16*Po)*Po,Fo=(2+12*Po)*Po,Oo=(9+64*Po)*Po*Po,No=Ro(4),Bo=Ro(8),Go=Ro(12),jo=Ro(16),Vo=Ro(4);function Uo(e,t,i,n,r,o){const s=(t-o)*(i-r),a=(e-r)*(n-o),l=s-a,c=Math.abs(s+a);return Math.abs(l)>=zo*c?l:-function(e,t,i,n,r,o,s){let a,l,c,u,h,d,p,f,m,g,y,_,v,x,b,w,E,T;const S=e-r,I=i-r,k=t-o,M=n-o;x=S*M,d=Ao*S,p=d-(d-S),f=S-p,d=Ao*M,m=d-(d-M),g=M-m,b=f*g-(x-p*m-f*m-p*g),w=k*I,d=Ao*k,p=d-(d-k),f=k-p,d=Ao*I,m=d-(d-I),g=I-m,E=f*g-(w-p*m-f*m-p*g),y=b-E,h=b-y,No[0]=b-(y+h)+(h-E),_=x+y,h=_-x,v=x-(_-h)+(y-h),y=v-w,h=v-y,No[1]=v-(y+h)+(h-w),T=_+y,h=T-_,No[2]=_-(T-h)+(y-h),No[3]=T;let C=function(e,t){let i=t[0];for(let n=1;n<e;n++)i+=t[n];return i}(4,No),P=Fo*s;if(C>=P||-C>=P||(h=e-S,a=e-(S+h)+(h-r),h=i-I,c=i-(I+h)+(h-r),h=t-k,l=t-(k+h)+(h-o),h=n-M,u=n-(M+h)+(h-o),0===a&&0===l&&0===c&&0===u)||(P=Oo*s+Lo*Math.abs(C),C+=S*u+M*a-(k*c+I*l),C>=P||-C>=P))return C;x=a*M,d=Ao*a,p=d-(d-a),f=a-p,d=Ao*M,m=d-(d-M),g=M-m,b=f*g-(x-p*m-f*m-p*g),w=l*I,d=Ao*l,p=d-(d-l),f=l-p,d=Ao*I,m=d-(d-I),g=I-m,E=f*g-(w-p*m-f*m-p*g),y=b-E,h=b-y,Vo[0]=b-(y+h)+(h-E),_=x+y,h=_-x,v=x-(_-h)+(y-h),y=v-w,h=v-y,Vo[1]=v-(y+h)+(h-w),T=_+y,h=T-_,Vo[2]=_-(T-h)+(y-h),Vo[3]=T;const A=Do(4,No,4,Vo,Bo);x=S*u,d=Ao*S,p=d-(d-S),f=S-p,d=Ao*u,m=d-(d-u),g=u-m,b=f*g-(x-p*m-f*m-p*g),w=k*c,d=Ao*k,p=d-(d-k),f=k-p,d=Ao*c,m=d-(d-c),g=c-m,E=f*g-(w-p*m-f*m-p*g),y=b-E,h=b-y,Vo[0]=b-(y+h)+(h-E),_=x+y,h=_-x,v=x-(_-h)+(y-h),y=v-w,h=v-y,Vo[1]=v-(y+h)+(h-w),T=_+y,h=T-_,Vo[2]=_-(T-h)+(y-h),Vo[3]=T;const L=Do(A,Bo,4,Vo,Go);x=a*u,d=Ao*a,p=d-(d-a),f=a-p,d=Ao*u,m=d-(d-u),g=u-m,b=f*g-(x-p*m-f*m-p*g),w=l*c,d=Ao*l,p=d-(d-l),f=l-p,d=Ao*c,m=d-(d-c),g=c-m,E=f*g-(w-p*m-f*m-p*g),y=b-E,h=b-y,Vo[0]=b-(y+h)+(h-E),_=x+y,h=_-x,v=x-(_-h)+(y-h),y=v-w,h=v-y,Vo[1]=v-(y+h)+(h-w),T=_+y,h=T-_,Vo[2]=_-(T-h)+(y-h),Vo[3]=T;const D=Do(L,Go,4,Vo,jo);return jo[D-1]}(e,t,i,n,r,o,c)}function qo(e,t){var i,n,r,o,s,a,l,c,u,h=0,d=e[0],p=e[1],f=t.length;for(i=0;i<f;i++){n=0;var m=t[i],g=m.length-1;if((c=m[0])[0]!==m[g][0]&&c[1]!==m[g][1])throw new Error("First and last coordinates in a ring must be the same");for(o=c[0]-d,s=c[1]-p;n<g;n++){if(a=(u=m[n+1])[0]-d,l=u[1]-p,0===s&&0===l){if(a<=0&&o>=0||o<=0&&a>=0)return 0}else if(l>=0&&s<=0||l<=0&&s>=0){if(0===(r=Uo(o,a,s,l,0,0)))return 0;(r>0&&l>0&&s<=0||r<0&&l<=0&&s>0)&&h++}c=u,s=l,o=a}}return h%2!=0}function Zo(e,t,i={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const n=Re(e),r=Fe(t),o=r.type,s=t.bbox;let a=r.coordinates;if(s&&!1===function(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}(n,s))return!1;"Polygon"===o&&(a=[a]);let l=!1;for(var c=0;c<a.length;++c){const e=qo(n,a[c]);if(0===e)return!i.ignoreBoundary;e&&(l=!0)}return l}class $o{constructor(e=[],t=Ho){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:i}=this,n=t[e];for(;e>0;){const r=e-1>>1,o=t[r];if(i(n,o)>=0)break;t[e]=o,e=r}t[e]=n}_down(e){const{data:t,compare:i}=this,n=this.length>>1,r=t[e];for(;e<n;){let n=1+(e<<1),o=t[n];const s=n+1;if(s<this.length&&i(t[s],o)<0&&(n=s,o=t[s]),i(o,r)>=0)break;t[e]=o,e=n}t[e]=r}}function Ho(e,t){return e<t?-1:e>t?1:0}function Wo(e,t){return e.p.x>t.p.x?1:e.p.x<t.p.x?-1:e.p.y!==t.p.y?e.p.y>t.p.y?1:-1:1}function Xo(e,t){return e.rightSweepEvent.p.x>t.rightSweepEvent.p.x?1:e.rightSweepEvent.p.x<t.rightSweepEvent.p.x?-1:e.rightSweepEvent.p.y!==t.rightSweepEvent.p.y?e.rightSweepEvent.p.y<t.rightSweepEvent.p.y?1:-1:1}class Yo{constructor(e,t,i,n){this.p={x:e[0],y:e[1]},this.featureId=t,this.ringId=i,this.eventId=n,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(e){return this.p.x===e.p.x&&this.p.y===e.p.y}}let Jo=0,Ko=0,Qo=0;function es(e,t){const i="Feature"===e.type?e.geometry:e;let n=i.coordinates;("Polygon"===i.type||"MultiLineString"===i.type)&&(n=[n]),"LineString"===i.type&&(n=[[n]]);for(let e=0;e<n.length;e++)for(let i=0;i<n[e].length;i++){let r=n[e][i][0],o=null;Ko+=1;for(let s=0;s<n[e][i].length-1;s++){o=n[e][i][s+1];const a=new Yo(r,Jo,Ko,Qo),l=new Yo(o,Jo,Ko,Qo+1);a.otherEvent=l,l.otherEvent=a,Wo(a,l)>0?(l.isLeftEndpoint=!0,a.isLeftEndpoint=!1):(a.isLeftEndpoint=!0,l.isLeftEndpoint=!1),t.push(a),t.push(l),r=o,Qo+=1}}Jo+=1}let ts=class{constructor(e){this.leftSweepEvent=e,this.rightSweepEvent=e.otherEvent}};function is(e,t){if(null===e||null===t||e.leftSweepEvent.ringId===t.leftSweepEvent.ringId&&(e.rightSweepEvent.isSamePoint(t.leftSweepEvent)||e.rightSweepEvent.isSamePoint(t.leftSweepEvent)||e.rightSweepEvent.isSamePoint(t.rightSweepEvent)||e.leftSweepEvent.isSamePoint(t.leftSweepEvent)||e.leftSweepEvent.isSamePoint(t.rightSweepEvent)))return!1;const i=e.leftSweepEvent.p.x,n=e.leftSweepEvent.p.y,r=e.rightSweepEvent.p.x,o=e.rightSweepEvent.p.y,s=t.leftSweepEvent.p.x,a=t.leftSweepEvent.p.y,l=t.rightSweepEvent.p.x,c=t.rightSweepEvent.p.y,u=(c-a)*(r-i)-(l-s)*(o-n);if(0===u)return!1;const h=((l-s)*(n-a)-(c-a)*(i-s))/u,d=((r-i)*(n-a)-(o-n)*(i-s))/u;if(h>=0&&h<=1&&d>=0&&d<=1){return[i+h*(r-i),n+h*(o-n)]}return!1}var ns=function(e,t){const i=new $o([],Wo);return function(e,t){if("FeatureCollection"===e.type){const i=e.features;for(let e=0;e<i.length;e++)es(i[e],t)}else es(e,t)}(e,i),function(e,t){t=t||!1;const i=[],n=new $o([],Xo);for(;e.length;){const r=e.pop();if(r.isLeftEndpoint){const e=new ts(r);for(let o=0;o<n.data.length;o++){const s=n.data[o];if(t&&s.leftSweepEvent.featureId===r.featureId)continue;const a=is(e,s);!1!==a&&i.push(a)}n.push(e)}else!1===r.isLeftEndpoint&&n.pop()}return i}(i,t)};function rs(e,t,i={}){const{removeDuplicates:n=!0,ignoreSelfIntersections:r=!0}=i;let o=[];"FeatureCollection"===e.type?o=o.concat(e.features):"Feature"===e.type?o.push(e):("LineString"===e.type||"Polygon"===e.type||"MultiLineString"===e.type||"MultiPolygon"===e.type)&&o.push(me(e)),"FeatureCollection"===t.type?o=o.concat(t.features):"Feature"===t.type?o.push(t):("LineString"===t.type||"Polygon"===t.type||"MultiLineString"===t.type||"MultiPolygon"===t.type)&&o.push(me(t));const s=ns(ve(o),r);let a=[];if(n){const e={};s.forEach(t=>{const i=t.join(",");e[i]||(e[i]=!0,a.push(t))})}else a=s;return ve(a.map(e=>ge(e)))}var os=rs;function ss(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return as(e);case"FeatureCollection":return function(e){const t={type:"FeatureCollection"};return Object.keys(e).forEach(i=>{switch(i){case"type":case"features":return;default:t[i]=e[i]}}),t.features=e.features.map(e=>as(e)),t}(e);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return cs(e);default:throw new Error("unknown GeoJSON type")}}function as(e){const t={type:"Feature"};return Object.keys(e).forEach(i=>{switch(i){case"type":case"properties":case"geometry":return;default:t[i]=e[i]}}),t.properties=ls(e.properties),null==e.geometry?t.geometry=null:t.geometry=cs(e.geometry),t}function ls(e){const t={};return e&&Object.keys(e).forEach(i=>{const n=e[i];"object"==typeof n?null===n?t[i]=null:Array.isArray(n)?t[i]=n.map(e=>e):t[i]=ls(n):t[i]=n}),t}function cs(e){const t={type:e.type};return e.bbox&&(t.bbox=e.bbox),"GeometryCollection"===e.type?(t.geometries=e.geometries.map(e=>cs(e)),t):(t.coordinates=us(e.coordinates),t)}function us(e){const t=e;return"object"!=typeof t[0]?t.slice():t.map(e=>us(e))}var hs=ss;function ds(e){const t=ze(e);let i,n,r=0,o=1;for(;o<t.length;)i=n||t[0],n=t[o],r+=(n[0]-i[0])*(n[1]+i[1]),o++;return r>0}function ps(e,t){switch("Feature"===e.type?e.geometry.type:e.type){case"GeometryCollection":return Pe(e,function(e){ps(e,t)}),e;case"LineString":return fs(ze(e),t),e;case"Polygon":return ms(ze(e),t),e;case"MultiLineString":return ze(e).forEach(function(e){fs(e,t)}),e;case"MultiPolygon":return ze(e).forEach(function(e){ms(e,t)}),e;case"Point":case"MultiPoint":return e}}function fs(e,t){ds(e)===t&&e.reverse()}function ms(e,t){ds(e[0])!==t&&e[0].reverse();for(let i=1;i<e.length;i++)ds(e[i])===t&&e[i].reverse()}var gs=function(e,t={}){var i,n;if(!ke(t=t||{}))throw new Error("options is invalid");const r=null!=(i=t.mutate)&&i,o=null!=(n=t.reverse)&&n;if(!e)throw new Error("<geojson> is required");if("boolean"!=typeof o)throw new Error("<reverse> must be a boolean");if("boolean"!=typeof r)throw new Error("<mutate> must be a boolean");!r&&"Point"!==e.type&&"MultiPoint"!==e.type&&(e=ss(e));const s=[];switch(e.type){case"GeometryCollection":return Pe(e,function(e){ps(e,o)}),e;case"FeatureCollection":return Ce(e,function(e){Ce(ps(e,o),function(e){s.push(e)})}),ve(s)}return ps(e,o)};const ys=["Point","MultiPoint"],_s=["LineString","MultiLineString","Polygon","MultiPolygon"],vs=e=>ys.includes(e.geometry.type),xs=e=>_s.includes(e.geometry.type);var bs,ws={exports:{}};var Es=(bs||(bs=1,function(e){e.exports=function(){function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);i<t;i++)n[i]=e[i];return n}function t(e,t,i){return t=l(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,u()?Reflect.construct(t,i||[],l(e).constructor):t.apply(e,i))}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t,i){if(u())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var r=new(e.bind.apply(e,n));return i&&h(r,i.prototype),r}function r(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,f(n.key),n)}}function o(e,t,i){return t&&r(e.prototype,t),i&&r(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t){var i=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!i){if(Array.isArray(e)||(i=m(e))||t){i&&(e=i);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){i=i.call(e)},n:function(){var e=i.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==i.return||i.return()}finally{if(a)throw o}}}}function a(){return a=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(e,t,i){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=l(e)););return e}(e,t);if(n){var r=Object.getOwnPropertyDescriptor(n,t);return r.get?r.get.call(arguments.length<3?e:i):r.value}},a.apply(null,arguments)}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}function u(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(u=function(){return!!e})()}function h(e,t){return(h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function d(e,t,i,n){var r=a(l(1&n?e.prototype:e),t,i);return 2&n&&"function"==typeof r?function(e){return r.apply(i,e)}:r}function p(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(e){if(typeof Symbol<"u"&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||m(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function m(t,i){if(t){if("string"==typeof t)return e(t,i);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,i):void 0}}function g(e){var t="function"==typeof Map?new Map:void 0;return g=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch{return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return n(e,arguments,l(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),h(i,e)},g(e)}var y=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"getEndCapStyle",value:function(){return this._endCapStyle}},{key:"isSingleSided",value:function(){return this._isSingleSided}},{key:"setQuadrantSegments",value:function(t){this._quadrantSegments=t,0===this._quadrantSegments&&(this._joinStyle=e.JOIN_BEVEL),this._quadrantSegments<0&&(this._joinStyle=e.JOIN_MITRE,this._mitreLimit=Math.abs(this._quadrantSegments)),t<=0&&(this._quadrantSegments=1),this._joinStyle!==e.JOIN_ROUND&&(this._quadrantSegments=e.DEFAULT_QUADRANT_SEGMENTS)}},{key:"getJoinStyle",value:function(){return this._joinStyle}},{key:"setJoinStyle",value:function(e){this._joinStyle=e}},{key:"setSimplifyFactor",value:function(e){this._simplifyFactor=e<0?0:e}},{key:"getSimplifyFactor",value:function(){return this._simplifyFactor}},{key:"getQuadrantSegments",value:function(){return this._quadrantSegments}},{key:"setEndCapStyle",value:function(e){this._endCapStyle=e}},{key:"getMitreLimit",value:function(){return this._mitreLimit}},{key:"setMitreLimit",value:function(e){this._mitreLimit=e}},{key:"setSingleSided",value:function(e){this._isSingleSided=e}}],[{key:"constructor_",value:function(){if(this._quadrantSegments=e.DEFAULT_QUADRANT_SEGMENTS,this._endCapStyle=e.CAP_ROUND,this._joinStyle=e.JOIN_ROUND,this._mitreLimit=e.DEFAULT_MITRE_LIMIT,this._isSingleSided=!1,this._simplifyFactor=e.DEFAULT_SIMPLIFY_FACTOR,0!==arguments.length)if(1===arguments.length){var t=arguments[0];this.setQuadrantSegments(t)}else if(2===arguments.length){var i=arguments[0],n=arguments[1];this.setQuadrantSegments(i),this.setEndCapStyle(n)}else if(4===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2],a=arguments[3];this.setQuadrantSegments(r),this.setEndCapStyle(o),this.setJoinStyle(s),this.setMitreLimit(a)}}},{key:"bufferDistanceError",value:function(e){var t=Math.PI/2/e;return 1-Math.cos(t/2)}}])}();y.CAP_ROUND=1,y.CAP_FLAT=2,y.CAP_SQUARE=3,y.JOIN_ROUND=1,y.JOIN_MITRE=2,y.JOIN_BEVEL=3,y.DEFAULT_QUADRANT_SEGMENTS=8,y.DEFAULT_MITRE_LIMIT=5,y.DEFAULT_SIMPLIFY_FACTOR=.01;var _=function(e){function n(e){var r;return i(this,n),(r=t(this,n,[e])).name=Object.keys({Exception:n})[0],r}return c(n,e),o(n,[{key:"toString",value:function(){return this.message}}])}(g(Error)),v=function(e){function n(e){var r;return i(this,n),(r=t(this,n,[e])).name=Object.keys({IllegalArgumentException:n})[0],r}return c(n,e),o(n)}(_),x=o(function e(){i(this,e)},[{key:"filter",value:function(e){}}]);function b(){}function w(){}function E(){}var T,S,I,k,M,C,P,A,L=o(function e(){i(this,e)},null,[{key:"equalsWithTolerance",value:function(e,t,i){return Math.abs(e-t)<=i}}]),D=o(function e(t,n){i(this,e),this.low=n||0,this.high=t||0},null,[{key:"toBinaryString",value:function(e){var t,i="";for(t=2147483648;t>0;t>>>=1)i+=(e.high&t)===t?"1":"0";for(t=2147483648;t>0;t>>>=1)i+=(e.low&t)===t?"1":"0";return i}}]);function R(){}function z(){}R.NaN=NaN,R.isNaN=function(e){return Number.isNaN(e)},R.isInfinite=function(e){return!Number.isFinite(e)},R.MAX_VALUE=Number.MAX_VALUE,R.POSITIVE_INFINITY=Number.POSITIVE_INFINITY,R.NEGATIVE_INFINITY=Number.NEGATIVE_INFINITY,"function"==typeof Float64Array&&"function"==typeof Int32Array?(C=2146435072,P=new Float64Array(1),A=new Int32Array(P.buffer),R.doubleToLongBits=function(e){P[0]=e;var t=0|A[0],i=0|A[1];return(i&C)===C&&1048575&i&&0!==t&&(t=0,i=2146959360),new D(i,t)},R.longBitsToDouble=function(e){return A[0]=e.low,A[1]=e.high,P[0]}):(T=1023,S=Math.log2,I=Math.floor,k=Math.pow,M=function(){for(var e=53;e>0;e--){var t=k(2,e)-1;if(I(S(t))+1===e)return t}return 0}(),R.doubleToLongBits=function(e){var t,i,n,r,o,s,a,l,c;if(e<0||1/e===Number.NEGATIVE_INFINITY?(s=1<<31,e=-e):s=0,0===e)return new D(l=s,c=0);if(e===1/0)return new D(l=2146435072|s,c=0);if(e!=e)return new D(l=2146959360,c=0);if(r=0,c=0,(t=I(e))>1)if(t<=M)(r=I(S(t)))<=20?(c=0,l=t<<20-r&1048575):(c=t%(i=k(2,n=r-20))<<32-n,l=t/i&1048575);else for(n=t,c=0;0!==(n=I(i=n/2));)r++,c>>>=1,c|=(1&l)<<31,l>>>=1,i!==n&&(l|=524288);if(a=r+T,o=0===t,t=e-t,r<52&&0!==t)for(n=0;;){if((i=2*t)>=1?(t=i-1,o?(a--,o=!1):(n<<=1,n|=1,r++)):(t=i,o?0==--a&&(r++,o=!1):(n<<=1,r++)),20===r)l|=n,n=0;else if(52===r){c|=n;break}if(1===i){r<20?l|=n<<20-r:r<52&&(c|=n<<52-r);break}}return l|=a<<20,new D(l|=s,c)},R.longBitsToDouble=function(e){var t,i,n,r,o=e.high,s=e.low,a=o&1<<31?-1:1;for(n=((2146435072&o)>>20)-T,r=0,i=1<<19,t=1;t<=20;t++)o&i&&(r+=k(2,-t)),i>>>=1;for(i=1<<31,t=21;t<=52;t++)s&i&&(r+=k(2,-t)),i>>>=1;if(-1023===n){if(0===r)return 0*a;n=-1022}else{if(1024===n)return 0===r?a/0:NaN;r+=1}return a*r*k(2,n)});var F=function(e){function n(e){var r;return i(this,n),(r=t(this,n,[e])).name=Object.keys({RuntimeException:n})[0],r}return c(n,e),o(n)}(_),O=function(e){function n(){var e;return i(this,n),e=t(this,n),n.constructor_.apply(e,arguments),e}return c(n,e),o(n,null,[{key:"constructor_",value:function(){if(0===arguments.length)F.constructor_.call(this);else if(1===arguments.length){var e=arguments[0];F.constructor_.call(this,e)}}}])}(F),N=function(){function e(){i(this,e)}return o(e,null,[{key:"shouldNeverReachHere",value:function(){if(0===arguments.length)e.shouldNeverReachHere(null);else if(1===arguments.length){var t=arguments[0];throw new O("Should never reach here"+(null!==t?": "+t:""))}}},{key:"isTrue",value:function(){if(1===arguments.length){var t=arguments[0];e.isTrue(t,null)}else if(2===arguments.length){var i=arguments[1];if(!arguments[0])throw null===i?new O:new O(i)}}},{key:"equals",value:function(){if(2===arguments.length){var t=arguments[0],i=arguments[1];e.equals(t,i,null)}else if(3===arguments.length){var n=arguments[0],r=arguments[1],o=arguments[2];if(!r.equals(n))throw new O("Expected "+n+" but encountered "+r+(null!==o?": "+o:""))}}}])}(),B=new ArrayBuffer(8),G=new Float64Array(B),j=new Int32Array(B),V=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"getM",value:function(){return R.NaN}},{key:"setOrdinate",value:function(t,i){switch(t){case e.X:this.x=i;break;case e.Y:this.y=i;break;case e.Z:this.setZ(i);break;default:throw new v("Invalid ordinate index: "+t)}}},{key:"equals2D",value:function(){if(1===arguments.length){var e=arguments[0];return this.x===e.x&&this.y===e.y}if(2===arguments.length){var t=arguments[0],i=arguments[1];return!!L.equalsWithTolerance(this.x,t.x,i)&&!!L.equalsWithTolerance(this.y,t.y,i)}}},{key:"setM",value:function(t){throw new v("Invalid ordinate index: "+e.M)}},{key:"getZ",value:function(){return this.z}},{key:"getOrdinate",value:function(t){switch(t){case e.X:return this.x;case e.Y:return this.y;case e.Z:return this.getZ()}throw new v("Invalid ordinate index: "+t)}},{key:"equals3D",value:function(e){return this.x===e.x&&this.y===e.y&&(this.getZ()===e.getZ()||R.isNaN(this.getZ())&&R.isNaN(e.getZ()))}},{key:"equals",value:function(t){return t instanceof e&&this.equals2D(t)}},{key:"equalInZ",value:function(e,t){return L.equalsWithTolerance(this.getZ(),e.getZ(),t)}},{key:"setX",value:function(e){this.x=e}},{key:"compareTo",value:function(e){var t=e;return this.x<t.x?-1:this.x>t.x?1:this.y<t.y?-1:this.y>t.y?1:0}},{key:"getX",value:function(){return this.x}},{key:"setZ",value:function(e){this.z=e}},{key:"clone",value:function(){try{return null}catch(e){if(e instanceof CloneNotSupportedException)return N.shouldNeverReachHere("this shouldn't happen because this class is Cloneable"),null;throw e}}},{key:"copy",value:function(){return new e(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+", "+this.getZ()+")"}},{key:"distance3D",value:function(e){var t=this.x-e.x,i=this.y-e.y,n=this.getZ()-e.getZ();return Math.sqrt(t*t+i*i+n*n)}},{key:"getY",value:function(){return this.y}},{key:"setY",value:function(e){this.y=e}},{key:"distance",value:function(e){var t=this.x-e.x,i=this.y-e.y;return Math.sqrt(t*t+i*i)}},{key:"hashCode",value:function(){var t=17;return 37*(t=37*t+e.hashCode(this.x))+e.hashCode(this.y)}},{key:"setCoordinate",value:function(e){this.x=e.x,this.y=e.y,this.z=e.getZ()}},{key:"interfaces_",get:function(){return[b,w,E]}}],[{key:"constructor_",value:function(){if(this.x=null,this.y=null,this.z=null,0===arguments.length)e.constructor_.call(this,0,0);else if(1===arguments.length){var t=arguments[0];e.constructor_.call(this,t.x,t.y,t.getZ())}else if(2===arguments.length){var i=arguments[0],n=arguments[1];e.constructor_.call(this,i,n,e.NULL_ORDINATE)}else if(3===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2];this.x=r,this.y=o,this.z=s}}},{key:"hashCode",value:function(e){return G[0]=e,j[0]^j[1]}}])}(),U=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"compare",value:function(t,i){var n=e.compare(t.x,i.x);if(0!==n)return n;var r=e.compare(t.y,i.y);return 0!==r?r:this._dimensionsToTest<=2?0:e.compare(t.getZ(),i.getZ())}},{key:"interfaces_",get:function(){return[z]}}],[{key:"constructor_",value:function(){if(this._dimensionsToTest=2,0===arguments.length)e.constructor_.call(this,2);else if(1===arguments.length){var t=arguments[0];if(2!==t&&3!==t)throw new v("only 2 or 3 dimensions may be specified");this._dimensionsToTest=t}}},{key:"compare",value:function(e,t){return e<t?-1:e>t?1:R.isNaN(e)?R.isNaN(t)?0:-1:R.isNaN(t)?1:0}}])}();V.DimensionalComparator=U,V.NULL_ORDINATE=R.NaN,V.X=0,V.Y=1,V.Z=2,V.M=3;var q=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"getArea",value:function(){return this.getWidth()*this.getHeight()}},{key:"equals",value:function(t){if(!(t instanceof e))return!1;var i=t;return this.isNull()?i.isNull():this._maxx===i.getMaxX()&&this._maxy===i.getMaxY()&&this._minx===i.getMinX()&&this._miny===i.getMinY()}},{key:"intersection",value:function(t){if(this.isNull()||t.isNull()||!this.intersects(t))return new e;var i=this._minx>t._minx?this._minx:t._minx,n=this._miny>t._miny?this._miny:t._miny;return new e(i,this._maxx<t._maxx?this._maxx:t._maxx,n,this._maxy<t._maxy?this._maxy:t._maxy)}},{key:"isNull",value:function(){return this._maxx<this._minx}},{key:"getMaxX",value:function(){return this._maxx}},{key:"covers",value:function(){if(1===arguments.length){if(arguments[0]instanceof V){var t=arguments[0];return this.covers(t.x,t.y)}if(arguments[0]instanceof e){var i=arguments[0];return!this.isNull()&&!i.isNull()&&i.getMinX()>=this._minx&&i.getMaxX()<=this._maxx&&i.getMinY()>=this._miny&&i.getMaxY()<=this._maxy}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];return!this.isNull()&&n>=this._minx&&n<=this._maxx&&r>=this._miny&&r<=this._maxy}}},{key:"intersects",value:function(){if(1===arguments.length){if(arguments[0]instanceof e){var t=arguments[0];return!this.isNull()&&!t.isNull()&&!(t._minx>this._maxx||t._maxx<this._minx||t._miny>this._maxy||t._maxy<this._miny)}if(arguments[0]instanceof V){var i=arguments[0];return this.intersects(i.x,i.y)}}else if(2===arguments.length){if(arguments[0]instanceof V&&arguments[1]instanceof V){var n=arguments[0],r=arguments[1];return!(this.isNull()||(n.x<r.x?n.x:r.x)>this._maxx||(n.x>r.x?n.x:r.x)<this._minx||(n.y<r.y?n.y:r.y)>this._maxy||(n.y>r.y?n.y:r.y)<this._miny)}if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var o=arguments[0],s=arguments[1];return!this.isNull()&&!(o>this._maxx||o<this._minx||s>this._maxy||s<this._miny)}}}},{key:"getMinY",value:function(){return this._miny}},{key:"getDiameter",value:function(){if(this.isNull())return 0;var e=this.getWidth(),t=this.getHeight();return Math.sqrt(e*e+t*t)}},{key:"getMinX",value:function(){return this._minx}},{key:"expandToInclude",value:function(){if(1===arguments.length){if(arguments[0]instanceof V){var t=arguments[0];this.expandToInclude(t.x,t.y)}else if(arguments[0]instanceof e){var i=arguments[0];if(i.isNull())return null;this.isNull()?(this._minx=i.getMinX(),this._maxx=i.getMaxX(),this._miny=i.getMinY(),this._maxy=i.getMaxY()):(i._minx<this._minx&&(this._minx=i._minx),i._maxx>this._maxx&&(this._maxx=i._maxx),i._miny<this._miny&&(this._miny=i._miny),i._maxy>this._maxy&&(this._maxy=i._maxy))}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];this.isNull()?(this._minx=n,this._maxx=n,this._miny=r,this._maxy=r):(n<this._minx&&(this._minx=n),n>this._maxx&&(this._maxx=n),r<this._miny&&(this._miny=r),r>this._maxy&&(this._maxy=r))}}},{key:"minExtent",value:function(){if(this.isNull())return 0;var e=this.getWidth(),t=this.getHeight();return e<t?e:t}},{key:"getWidth",value:function(){return this.isNull()?0:this._maxx-this._minx}},{key:"compareTo",value:function(e){var t=e;return this.isNull()?t.isNull()?0:-1:t.isNull()?1:this._minx<t._minx?-1:this._minx>t._minx?1:this._miny<t._miny?-1:this._miny>t._miny?1:this._maxx<t._maxx?-1:this._maxx>t._maxx?1:this._maxy<t._maxy?-1:this._maxy>t._maxy?1:0}},{key:"translate",value:function(e,t){if(this.isNull())return null;this.init(this.getMinX()+e,this.getMaxX()+e,this.getMinY()+t,this.getMaxY()+t)}},{key:"copy",value:function(){return new e(this)}},{key:"toString",value:function(){return"Env["+this._minx+" : "+this._maxx+", "+this._miny+" : "+this._maxy+"]"}},{key:"setToNull",value:function(){this._minx=0,this._maxx=-1,this._miny=0,this._maxy=-1}},{key:"disjoint",value:function(e){return!(!this.isNull()&&!e.isNull())||e._minx>this._maxx||e._maxx<this._minx||e._miny>this._maxy||e._maxy<this._miny}},{key:"getHeight",value:function(){return this.isNull()?0:this._maxy-this._miny}},{key:"maxExtent",value:function(){if(this.isNull())return 0;var e=this.getWidth(),t=this.getHeight();return e>t?e:t}},{key:"expandBy",value:function(){if(1===arguments.length){var e=arguments[0];this.expandBy(e,e)}else if(2===arguments.length){var t=arguments[0],i=arguments[1];if(this.isNull())return null;this._minx-=t,this._maxx+=t,this._miny-=i,this._maxy+=i,(this._minx>this._maxx||this._miny>this._maxy)&&this.setToNull()}}},{key:"contains",value:function(){if(1===arguments.length){if(arguments[0]instanceof e){var t=arguments[0];return this.covers(t)}if(arguments[0]instanceof V){var i=arguments[0];return this.covers(i)}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];return this.covers(n,r)}}},{key:"centre",value:function(){return this.isNull()?null:new V((this.getMinX()+this.getMaxX())/2,(this.getMinY()+this.getMaxY())/2)}},{key:"init",value:function(){if(0===arguments.length)this.setToNull();else if(1===arguments.length){if(arguments[0]instanceof V){var t=arguments[0];this.init(t.x,t.x,t.y,t.y)}else if(arguments[0]instanceof e){var i=arguments[0];this._minx=i._minx,this._maxx=i._maxx,this._miny=i._miny,this._maxy=i._maxy}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];this.init(n.x,r.x,n.y,r.y)}else if(4===arguments.length){var o=arguments[0],s=arguments[1],a=arguments[2],l=arguments[3];o<s?(this._minx=o,this._maxx=s):(this._minx=s,this._maxx=o),a<l?(this._miny=a,this._maxy=l):(this._miny=l,this._maxy=a)}}},{key:"getMaxY",value:function(){return this._maxy}},{key:"distance",value:function(e){if(this.intersects(e))return 0;var t=0;this._maxx<e._minx?t=e._minx-this._maxx:this._minx>e._maxx&&(t=this._minx-e._maxx);var i=0;return this._maxy<e._miny?i=e._miny-this._maxy:this._miny>e._maxy&&(i=this._miny-e._maxy),0===t?i:0===i?t:Math.sqrt(t*t+i*i)}},{key:"hashCode",value:function(){var e=17;return 37*(e=37*(e=37*(e=37*e+V.hashCode(this._minx))+V.hashCode(this._maxx))+V.hashCode(this._miny))+V.hashCode(this._maxy)}},{key:"interfaces_",get:function(){return[b,E]}}],[{key:"constructor_",value:function(){if(this._minx=null,this._maxx=null,this._miny=null,this._maxy=null,0===arguments.length)this.init();else if(1===arguments.length){if(arguments[0]instanceof V){var t=arguments[0];this.init(t.x,t.x,t.y,t.y)}else if(arguments[0]instanceof e){var i=arguments[0];this.init(i)}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];this.init(n.x,r.x,n.y,r.y)}else if(4===arguments.length){var o=arguments[0],s=arguments[1],a=arguments[2],l=arguments[3];this.init(o,s,a,l)}}},{key:"intersects",value:function(){if(3===arguments.length){var e=arguments[0],t=arguments[1],i=arguments[2];return i.x>=(e.x<t.x?e.x:t.x)&&i.x<=(e.x>t.x?e.x:t.x)&&i.y>=(e.y<t.y?e.y:t.y)&&i.y<=(e.y>t.y?e.y:t.y)}if(4===arguments.length){var n=arguments[0],r=arguments[1],o=arguments[2],s=arguments[3],a=Math.min(o.x,s.x),l=Math.max(o.x,s.x),c=Math.min(n.x,r.x),u=Math.max(n.x,r.x);return!(c>l||u<a||(a=Math.min(o.y,s.y),l=Math.max(o.y,s.y),c=Math.min(n.y,r.y),u=Math.max(n.y,r.y),c>l||u<a))}}}])}(),Z=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"isGeometryCollection",value:function(){return this.getTypeCode()===e.TYPECODE_GEOMETRYCOLLECTION}},{key:"getFactory",value:function(){return this._factory}},{key:"getGeometryN",value:function(e){return this}},{key:"getArea",value:function(){return 0}},{key:"isRectangle",value:function(){return!1}},{key:"equalsExact",value:function(e){return this===e||this.equalsExact(e,0)}},{key:"geometryChanged",value:function(){this.apply(e.geometryChangedFilter)}},{key:"geometryChangedAction",value:function(){this._envelope=null}},{key:"equalsNorm",value:function(e){return null!==e&&this.norm().equalsExact(e.norm())}},{key:"getLength",value:function(){return 0}},{key:"getNumGeometries",value:function(){return 1}},{key:"compareTo",value:function(){var e;if(1===arguments.length){var t=arguments[0];return e=t,this.getTypeCode()!==e.getTypeCode()?this.getTypeCode()-e.getTypeCode():this.isEmpty()&&e.isEmpty()?0:this.isEmpty()?-1:e.isEmpty()?1:this.compareToSameClass(t)}if(2===arguments.length){var i=arguments[0],n=arguments[1];return e=i,this.getTypeCode()!==e.getTypeCode()?this.getTypeCode()-e.getTypeCode():this.isEmpty()&&e.isEmpty()?0:this.isEmpty()?-1:e.isEmpty()?1:this.compareToSameClass(i,n)}}},{key:"getUserData",value:function(){return this._userData}},{key:"getSRID",value:function(){return this._SRID}},{key:"getEnvelope",value:function(){return this.getFactory().toGeometry(this.getEnvelopeInternal())}},{key:"checkNotGeometryCollection",value:function(t){if(t.getTypeCode()===e.TYPECODE_GEOMETRYCOLLECTION)throw new v("This method does not support GeometryCollection arguments")}},{key:"equal",value:function(e,t,i){return 0===i?e.equals(t):e.distance(t)<=i}},{key:"norm",value:function(){var e=this.copy();return e.normalize(),e}},{key:"reverse",value:function(){var e=this.reverseInternal();return null!=this.envelope&&(e.envelope=this.envelope.copy()),e.setSRID(this.getSRID()),e}},{key:"copy",value:function(){var e=this.copyInternal();return e.envelope=null==this._envelope?null:this._envelope.copy(),e._SRID=this._SRID,e._userData=this._userData,e}},{key:"getPrecisionModel",value:function(){return this._factory.getPrecisionModel()}},{key:"getEnvelopeInternal",value:function(){return null===this._envelope&&(this._envelope=this.computeEnvelopeInternal()),new q(this._envelope)}},{key:"setSRID",value:function(e){this._SRID=e}},{key:"setUserData",value:function(e){this._userData=e}},{key:"compare",value:function(e,t){for(var i=e.iterator(),n=t.iterator();i.hasNext()&&n.hasNext();){var r=i.next(),o=n.next(),s=r.compareTo(o);if(0!==s)return s}return i.hasNext()?1:n.hasNext()?-1:0}},{key:"hashCode",value:function(){return this.getEnvelopeInternal().hashCode()}},{key:"isEquivalentClass",value:function(e){return this.getClass()===e.getClass()}},{key:"isGeometryCollectionOrDerived",value:function(){return this.getTypeCode()===e.TYPECODE_GEOMETRYCOLLECTION||this.getTypeCode()===e.TYPECODE_MULTIPOINT||this.getTypeCode()===e.TYPECODE_MULTILINESTRING||this.getTypeCode()===e.TYPECODE_MULTIPOLYGON}},{key:"interfaces_",get:function(){return[w,b,E]}},{key:"getClass",value:function(){return e}}],[{key:"hasNonEmptyElements",value:function(e){for(var t=0;t<e.length;t++)if(!e[t].isEmpty())return!0;return!1}},{key:"hasNullElements",value:function(e){for(var t=0;t<e.length;t++)if(null===e[t])return!0;return!1}}])}();Z.constructor_=function(e){e&&(this._envelope=null,this._userData=null,this._factory=e,this._SRID=e.getSRID())},Z.TYPECODE_POINT=0,Z.TYPECODE_MULTIPOINT=1,Z.TYPECODE_LINESTRING=2,Z.TYPECODE_LINEARRING=3,Z.TYPECODE_MULTILINESTRING=4,Z.TYPECODE_POLYGON=5,Z.TYPECODE_MULTIPOLYGON=6,Z.TYPECODE_GEOMETRYCOLLECTION=7,Z.TYPENAME_POINT="Point",Z.TYPENAME_MULTIPOINT="MultiPoint",Z.TYPENAME_LINESTRING="LineString",Z.TYPENAME_LINEARRING="LinearRing",Z.TYPENAME_MULTILINESTRING="MultiLineString",Z.TYPENAME_POLYGON="Polygon",Z.TYPENAME_MULTIPOLYGON="MultiPolygon",Z.TYPENAME_GEOMETRYCOLLECTION="GeometryCollection",Z.geometryChangedFilter={get interfaces_(){return[x]},filter:function(e){e.geometryChangedAction()}};var $=function(){function e(){i(this,e)}return o(e,null,[{key:"toLocationSymbol",value:function(t){switch(t){case e.EXTERIOR:return"e";case e.BOUNDARY:return"b";case e.INTERIOR:return"i";case e.NONE:return"-"}throw new v("Unknown location value: "+t)}}])}();$.INTERIOR=0,$.BOUNDARY=1,$.EXTERIOR=2,$.NONE=-1;var H=o(function e(){i(this,e)},[{key:"add",value:function(){}},{key:"addAll",value:function(){}},{key:"isEmpty",value:function(){}},{key:"iterator",value:function(){}},{key:"size",value:function(){}},{key:"toArray",value:function(){}},{key:"remove",value:function(){}}]),W=function(e){function n(e){var r;return i(this,n),(r=t(this,n,[e])).name=Object.keys({NoSuchElementException:n})[0],r}return c(n,e),o(n)}(_),X=function(e){function n(e){var r;return i(this,n),(r=t(this,n,[e])).name=Object.keys({UnsupportedOperationException:n})[0],r}return c(n,e),o(n)}(_),Y=function(e){function n(){return i(this,n),t(this,n,arguments)}return c(n,e),o(n,[{key:"contains",value:function(){}}])}(H),J=function(e){function n(e){var r;return i(this,n),(r=t(this,n)).map=new Map,e instanceof H&&r.addAll(e),r}return c(n,e),o(n,[{key:"contains",value:function(e){var t=e.hashCode?e.hashCode():e;return!!this.map.has(t)}},{key:"add",value:function(e){var t=e.hashCode?e.hashCode():e;return!this.map.has(t)&&!!this.map.set(t,e)}},{key:"addAll",value:function(e){var t,i=s(e);try{for(i.s();!(t=i.n()).done;){var n=t.value;this.add(n)}}catch(e){i.e(e)}finally{i.f()}return!0}},{key:"remove",value:function(){throw new X}},{key:"size",value:function(){return this.map.size}},{key:"isEmpty",value:function(){return 0===this.map.size}},{key:"toArray",value:function(){return Array.from(this.map.values())}},{key:"iterator",value:function(){return new K(this.map)}},{key:Symbol.iterator,value:function(){return this.map}}])}(Y),K=o(function e(t){i(this,e),this.iterator=t.values();var n=this.iterator.next(),r=n.done,o=n.value;this.done=r,this.value=o},[{key:"next",value:function(){if(this.done)throw new W;var e=this.value,t=this.iterator.next(),i=t.done,n=t.value;return this.done=i,this.value=n,e}},{key:"hasNext",value:function(){return!this.done}},{key:"remove",value:function(){throw new X}}]),Q=function(){function e(){i(this,e)}return o(e,null,[{key:"opposite",value:function(t){return t===e.LEFT?e.RIGHT:t===e.RIGHT?e.LEFT:t}}])}();Q.ON=0,Q.LEFT=1,Q.RIGHT=2;var ee=function(e){function n(e){var r;return i(this,n),(r=t(this,n,[e])).name=Object.keys({EmptyStackException:n})[0],r}return c(n,e),o(n)}(_),te=function(e){function n(e){var r;return i(this,n),(r=t(this,n,[e])).name=Object.keys({IndexOutOfBoundsException:n})[0],r}return c(n,e),o(n)}(_),ie=function(e){function n(){return i(this,n),t(this,n,arguments)}return c(n,e),o(n,[{key:"get",value:function(){}},{key:"set",value:function(){}},{key:"isEmpty",value:function(){}}])}(H),ne=function(e){function n(){var e;return i(this,n),(e=t(this,n)).array=[],e}return c(n,e),o(n,[{key:"add",value:function(e){return this.array.push(e),!0}},{key:"get",value:function(e){if(e<0||e>=this.size())throw new te;return this.array[e]}},{key:"push",value:function(e){return this.array.push(e),e}},{key:"pop",value:function(){if(0===this.array.length)throw new ee;return this.array.pop()}},{key:"peek",value:function(){if(0===this.array.length)throw new ee;return this.array[this.array.length-1]}},{key:"empty",value:function(){return 0===this.array.length}},{key:"isEmpty",value:function(){return this.empty()}},{key:"search",value:function(e){return this.array.indexOf(e)}},{key:"size",value:function(){return this.array.length}},{key:"toArray",value:function(){return this.array.slice()}}])}(ie);function re(e,t){return e.interfaces_&&e.interfaces_.indexOf(t)>-1}var oe=o(function e(t){i(this,e),this.str=t},[{key:"append",value:function(e){this.str+=e}},{key:"setCharAt",value:function(e,t){this.str=this.str.substr(0,e)+t+this.str.substr(e+1)}},{key:"toString",value:function(){return this.str}}]),se=function(){function e(t){i(this,e),this.value=t}return o(e,[{key:"intValue",value:function(){return this.value}},{key:"compareTo",value:function(e){return this.value<e?-1:this.value>e?1:0}}],[{key:"compare",value:function(e,t){return e<t?-1:e>t?1:0}},{key:"isNan",value:function(e){return Number.isNaN(e)}},{key:"valueOf",value:function(t){return new e(t)}}])}(),ae=o(function e(){i(this,e)},null,[{key:"isWhitespace",value:function(e){return e<=32&&e>=0||127===e}},{key:"toUpperCase",value:function(e){return e.toUpperCase()}}]),le=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"le",value:function(e){return this._hi<e._hi||this._hi===e._hi&&this._lo<=e._lo}},{key:"extractSignificantDigits",value:function(t,i){var n=this.abs(),r=e.magnitude(n._hi),o=e.TEN.pow(r);(n=n.divide(o)).gt(e.TEN)?(n=n.divide(e.TEN),r+=1):n.lt(e.ONE)&&(n=n.multiply(e.TEN),r-=1);for(var s=r+1,a=new oe,l=e.MAX_PRINT_DIGITS-1,c=0;c<=l;c++){t&&c===s&&a.append(".");var u=Math.trunc(n._hi);if(u<0)break;var h=!1,d=0;u>9?(h=!0,d="9"):d="0"+u,a.append(d),n=n.subtract(e.valueOf(u)).multiply(e.TEN),h&&n.selfAdd(e.TEN);var p=!0,f=e.magnitude(n._hi);if(f<0&&Math.abs(f)>=l-c&&(p=!1),!p)break}return i[0]=r,a.toString()}},{key:"sqr",value:function(){return this.multiply(this)}},{key:"doubleValue",value:function(){return this._hi+this._lo}},{key:"subtract",value:function(){if(arguments[0]instanceof e){var t=arguments[0];return this.add(t.negate())}if("number"==typeof arguments[0]){var i=arguments[0];return this.add(-i)}}},{key:"equals",value:function(){if(1===arguments.length&&arguments[0]instanceof e){var t=arguments[0];return this._hi===t._hi&&this._lo===t._lo}}},{key:"isZero",value:function(){return 0===this._hi&&0===this._lo}},{key:"selfSubtract",value:function(){if(arguments[0]instanceof e){var t=arguments[0];return this.isNaN()?this:this.selfAdd(-t._hi,-t._lo)}if("number"==typeof arguments[0]){var i=arguments[0];return this.isNaN()?this:this.selfAdd(-i,0)}}},{key:"getSpecialNumberString",value:function(){return this.isZero()?"0.0":this.isNaN()?"NaN ":null}},{key:"min",value:function(e){return this.le(e)?this:e}},{key:"selfDivide",value:function(){if(1===arguments.length){if(arguments[0]instanceof e){var t=arguments[0];return this.selfDivide(t._hi,t._lo)}if("number"==typeof arguments[0]){var i=arguments[0];return this.selfDivide(i,0)}}else if(2===arguments.length){var n,r,o,s,a=arguments[0],l=arguments[1],c=null,u=null,h=null,d=null;return o=this._hi/a,d=(c=(h=e.SPLIT*o)-(c=h-o))*(u=(d=e.SPLIT*a)-(u=d-a))-(s=o*a)+c*(r=a-u)+(n=o-c)*u+n*r,d=o+(h=(this._hi-s-d+this._lo-o*l)/a),this._hi=d,this._lo=o-d+h,this}}},{key:"dump",value:function(){return"DD<"+this._hi+", "+this._lo+">"}},{key:"divide",value:function(){if(arguments[0]instanceof e){var t,i,n,r,o=arguments[0],s=null,a=null,l=null,c=null;return t=(n=this._hi/o._hi)-(s=(l=e.SPLIT*n)-(s=l-n)),c=s*(a=(c=e.SPLIT*o._hi)-(a=c-o._hi))-(r=n*o._hi)+s*(i=o._hi-a)+t*a+t*i,new e(c=n+(l=(this._hi-r-c+this._lo-n*o._lo)/o._hi),n-c+l)}if("number"==typeof arguments[0]){var u=arguments[0];return R.isNaN(u)?e.createNaN():e.copy(this).selfDivide(u,0)}}},{key:"ge",value:function(e){return this._hi>e._hi||this._hi===e._hi&&this._lo>=e._lo}},{key:"pow",value:function(t){if(0===t)return e.valueOf(1);var i=new e(this),n=e.valueOf(1),r=Math.abs(t);if(r>1)for(;r>0;)r%2==1&&n.selfMultiply(i),(r/=2)>0&&(i=i.sqr());else n=i;return t<0?n.reciprocal():n}},{key:"ceil",value:function(){if(this.isNaN())return e.NaN;var t=Math.ceil(this._hi),i=0;return t===this._hi&&(i=Math.ceil(this._lo)),new e(t,i)}},{key:"compareTo",value:function(e){var t=e;return this._hi<t._hi?-1:this._hi>t._hi?1:this._lo<t._lo?-1:this._lo>t._lo?1:0}},{key:"rint",value:function(){return this.isNaN()?this:this.add(.5).floor()}},{key:"setValue",value:function(){if(arguments[0]instanceof e){var t=arguments[0];return this.init(t),this}if("number"==typeof arguments[0]){var i=arguments[0];return this.init(i),this}}},{key:"max",value:function(e){return this.ge(e)?this:e}},{key:"sqrt",value:function(){if(this.isZero())return e.valueOf(0);if(this.isNegative())return e.NaN;var t=1/Math.sqrt(this._hi),i=this._hi*t,n=e.valueOf(i),r=this.subtract(n.sqr())._hi*(.5*t);return n.add(r)}},{key:"selfAdd",value:function(){if(1===arguments.length){if(arguments[0]instanceof e){var t=arguments[0];return this.selfAdd(t._hi,t._lo)}if("number"==typeof arguments[0]){var i,n,r,o,s,a=arguments[0],l=null;return l=(r=this._hi+a)-(o=r-this._hi),n=(s=(l=a-o+(this._hi-l))+this._lo)+(r-(i=r+s)),this._hi=i+n,this._lo=n+(i-this._hi),this}}else if(2===arguments.length){var c,u,h,d,p=arguments[0],f=arguments[1],m=null,g=null,y=null;h=this._hi+p,u=this._lo+f,g=h-(y=h-this._hi),m=u-(d=u-this._lo);var _=(c=h+(y=(g=p-y+(this._hi-g))+u))+(y=(m=f-d+(this._lo-m))+(y+(h-c))),v=y+(c-_);return this._hi=_,this._lo=v,this}}},{key:"selfMultiply",value:function(){if(1===arguments.length){if(arguments[0]instanceof e){var t=arguments[0];return this.selfMultiply(t._hi,t._lo)}if("number"==typeof arguments[0]){var i=arguments[0];return this.selfMultiply(i,0)}}else if(2===arguments.length){var n,r,o=arguments[0],s=arguments[1],a=null,l=null,c=null,u=null;a=(c=e.SPLIT*this._hi)-this._hi,u=e.SPLIT*o,a=c-a,n=this._hi-a,l=u-o;var h=(c=this._hi*o)+(u=a*(l=u-l)-c+a*(r=o-l)+n*l+n*r+(this._hi*s+this._lo*o)),d=u+(a=c-h);return this._hi=h,this._lo=d,this}}},{key:"selfSqr",value:function(){return this.selfMultiply(this)}},{key:"floor",value:function(){if(this.isNaN())return e.NaN;var t=Math.floor(this._hi),i=0;return t===this._hi&&(i=Math.floor(this._lo)),new e(t,i)}},{key:"negate",value:function(){return this.isNaN()?this:new e(-this._hi,-this._lo)}},{key:"clone",value:function(){try{return null}catch(e){if(e instanceof CloneNotSupportedException)return null;throw e}}},{key:"multiply",value:function(){if(arguments[0]instanceof e){var t=arguments[0];return t.isNaN()?e.createNaN():e.copy(this).selfMultiply(t)}if("number"==typeof arguments[0]){var i=arguments[0];return R.isNaN(i)?e.createNaN():e.copy(this).selfMultiply(i,0)}}},{key:"isNaN",value:function(){return R.isNaN(this._hi)}},{key:"intValue",value:function(){return Math.trunc(this._hi)}},{key:"toString",value:function(){var t=e.magnitude(this._hi);return t>=-3&&t<=20?this.toStandardNotation():this.toSciNotation()}},{key:"toStandardNotation",value:function(){var t=this.getSpecialNumberString();if(null!==t)return t;var i=new Array(1).fill(null),n=this.extractSignificantDigits(!0,i),r=i[0]+1,o=n;if("."===n.charAt(0))o="0"+n;else if(r<0)o="0."+e.stringOfChar("0",-r)+n;else if(-1===n.indexOf(".")){var s=r-n.length;o=n+e.stringOfChar("0",s)+".0"}return this.isNegative()?"-"+o:o}},{key:"reciprocal",value:function(){var t,i,n,r,o=null,s=null,a=null,l=null;t=(n=1/this._hi)-(o=(a=e.SPLIT*n)-(o=a-n)),s=(l=e.SPLIT*this._hi)-this._hi;var c=n+(a=(1-(r=n*this._hi)-(l=o*(s=l-s)-r+o*(i=this._hi-s)+t*s+t*i)-n*this._lo)/this._hi);return new e(c,n-c+a)}},{key:"toSciNotation",value:function(){if(this.isZero())return e.SCI_NOT_ZERO;var t=this.getSpecialNumberString();if(null!==t)return t;var i=new Array(1).fill(null),n=this.extractSignificantDigits(!1,i),r=e.SCI_NOT_EXPONENT_CHAR+i[0];if("0"===n.charAt(0))throw new IllegalStateException("Found leading zero: "+n);var o="";n.length>1&&(o=n.substring(1));var s=n.charAt(0)+"."+o;return this.isNegative()?"-"+s+r:s+r}},{key:"abs",value:function(){return this.isNaN()?e.NaN:this.isNegative()?this.negate():new e(this)}},{key:"isPositive",value:function(){return this._hi>0||0===this._hi&&this._lo>0}},{key:"lt",value:function(e){return this._hi<e._hi||this._hi===e._hi&&this._lo<e._lo}},{key:"add",value:function(){if(arguments[0]instanceof e){var t=arguments[0];return e.copy(this).selfAdd(t)}if("number"==typeof arguments[0]){var i=arguments[0];return e.copy(this).selfAdd(i)}}},{key:"init",value:function(){if(1===arguments.length){if("number"==typeof arguments[0]){var t=arguments[0];this._hi=t,this._lo=0}else if(arguments[0]instanceof e){var i=arguments[0];this._hi=i._hi,this._lo=i._lo}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];this._hi=n,this._lo=r}}},{key:"gt",value:function(e){return this._hi>e._hi||this._hi===e._hi&&this._lo>e._lo}},{key:"isNegative",value:function(){return this._hi<0||0===this._hi&&this._lo<0}},{key:"trunc",value:function(){return this.isNaN()?e.NaN:this.isPositive()?this.floor():this.ceil()}},{key:"signum",value:function(){return this._hi>0?1:this._hi<0?-1:this._lo>0?1:this._lo<0?-1:0}},{key:"interfaces_",get:function(){return[E,b,w]}}],[{key:"constructor_",value:function(){if(this._hi=0,this._lo=0,0===arguments.length)this.init(0);else if(1===arguments.length){if("number"==typeof arguments[0]){var t=arguments[0];this.init(t)}else if(arguments[0]instanceof e){var i=arguments[0];this.init(i)}else if("string"==typeof arguments[0]){var n=arguments[0];e.constructor_.call(this,e.parse(n))}}else if(2===arguments.length){var r=arguments[0],o=arguments[1];this.init(r,o)}}},{key:"determinant",value:function(){if("number"==typeof arguments[3]&&"number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],i=arguments[1],n=arguments[2],r=arguments[3];return e.determinant(e.valueOf(t),e.valueOf(i),e.valueOf(n),e.valueOf(r))}if(arguments[3]instanceof e&&arguments[2]instanceof e&&arguments[0]instanceof e&&arguments[1]instanceof e){var o=arguments[1],s=arguments[2],a=arguments[3];return arguments[0].multiply(a).selfSubtract(o.multiply(s))}}},{key:"sqr",value:function(t){return e.valueOf(t).selfMultiply(t)}},{key:"valueOf",value:function(){if("string"==typeof arguments[0]){var t=arguments[0];return e.parse(t)}if("number"==typeof arguments[0])return new e(arguments[0])}},{key:"sqrt",value:function(t){return e.valueOf(t).sqrt()}},{key:"parse",value:function(t){for(var i=0,n=t.length;ae.isWhitespace(t.charAt(i));)i++;var r=!1;if(i<n){var o=t.charAt(i);"-"!==o&&"+"!==o||(i++,"-"===o&&(r=!0))}for(var s=new e,a=0,l=0,c=0,u=!1;!(i>=n);){var h=t.charAt(i);if(i++,ae.isDigit(h)){var d=h-"0";s.selfMultiply(e.TEN),s.selfAdd(d),a++}else{if("."!==h){if("e"===h||"E"===h){var p=t.substring(i);try{c=se.parseInt(p)}catch(e){throw e instanceof NumberFormatException?new NumberFormatException("Invalid exponent "+p+" in string "+t):e}break}throw new NumberFormatException("Unexpected character '"+h+"' at position "+i+" in string "+t)}l=a,u=!0}}var f=s;u||(l=a);var m=a-l-c;if(0===m)f=s;else if(m>0){var g=e.TEN.pow(m);f=s.divide(g)}else if(m<0){var y=e.TEN.pow(-m);f=s.multiply(y)}return r?f.negate():f}},{key:"createNaN",value:function(){return new e(R.NaN,R.NaN)}},{key:"copy",value:function(t){return new e(t)}},{key:"magnitude",value:function(e){var t=Math.abs(e),i=Math.log(t)/Math.log(10),n=Math.trunc(Math.floor(i));return 10*Math.pow(10,n)<=t&&(n+=1),n}},{key:"stringOfChar",value:function(e,t){for(var i=new oe,n=0;n<t;n++)i.append(e);return i.toString()}}])}();le.PI=new le(3.141592653589793,12246467991473532e-32),le.TWO_PI=new le(6.283185307179586,24492935982947064e-32),le.PI_2=new le(1.5707963267948966,6123233995736766e-32),le.E=new le(2.718281828459045,14456468917292502e-32),le.NaN=new le(R.NaN,R.NaN),le.EPS=123259516440783e-46,le.SPLIT=134217729,le.MAX_PRINT_DIGITS=32,le.TEN=le.valueOf(10),le.ONE=le.valueOf(1),le.SCI_NOT_EXPONENT_CHAR="E",le.SCI_NOT_ZERO="0.0E0";var ce=function(){function e(){i(this,e)}return o(e,null,[{key:"orientationIndex",value:function(t,i,n){var r=e.orientationIndexFilter(t,i,n);if(r<=1)return r;var o=le.valueOf(i.x).selfAdd(-t.x),s=le.valueOf(i.y).selfAdd(-t.y),a=le.valueOf(n.x).selfAdd(-i.x),l=le.valueOf(n.y).selfAdd(-i.y);return o.selfMultiply(l).selfSubtract(s.selfMultiply(a)).signum()}},{key:"signOfDet2x2",value:function(){if(arguments[3]instanceof le&&arguments[2]instanceof le&&arguments[0]instanceof le&&arguments[1]instanceof le){var e=arguments[1],t=arguments[2],i=arguments[3];return arguments[0].multiply(i).selfSubtract(e.multiply(t)).signum()}if("number"==typeof arguments[3]&&"number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){var n=arguments[0],r=arguments[1],o=arguments[2],s=arguments[3],a=le.valueOf(n),l=le.valueOf(r),c=le.valueOf(o),u=le.valueOf(s);return a.multiply(u).selfSubtract(l.multiply(c)).signum()}}},{key:"intersection",value:function(e,t,i,n){var r=new le(e.y).selfSubtract(t.y),o=new le(t.x).selfSubtract(e.x),s=new le(e.x).selfMultiply(t.y).selfSubtract(new le(t.x).selfMultiply(e.y)),a=new le(i.y).selfSubtract(n.y),l=new le(n.x).selfSubtract(i.x),c=new le(i.x).selfMultiply(n.y).selfSubtract(new le(n.x).selfMultiply(i.y)),u=o.multiply(c).selfSubtract(l.multiply(s)),h=a.multiply(s).selfSubtract(r.multiply(c)),d=r.multiply(l).selfSubtract(a.multiply(o)),p=u.selfDivide(d).doubleValue(),f=h.selfDivide(d).doubleValue();return R.isNaN(p)||R.isInfinite(p)||R.isNaN(f)||R.isInfinite(f)?null:new V(p,f)}},{key:"orientationIndexFilter",value:function(t,i,n){var r=null,o=(t.x-n.x)*(i.y-n.y),s=(t.y-n.y)*(i.x-n.x),a=o-s;if(o>0){if(s<=0)return e.signum(a);r=o+s}else{if(!(o<0)||s>=0)return e.signum(a);r=-o-s}var l=e.DP_SAFE_EPSILON*r;return a>=l||-a>=l?e.signum(a):2}},{key:"signum",value:function(e){return e>0?1:e<0?-1:0}}])}();ce.DP_SAFE_EPSILON=1e-15;var ue=o(function e(){i(this,e)},[{key:"getM",value:function(e){if(this.hasM()){var t=this.getDimension()-this.getMeasures();return this.getOrdinate(e,t)}return R.NaN}},{key:"setOrdinate",value:function(e,t,i){}},{key:"getZ",value:function(e){return this.hasZ()?this.getOrdinate(e,2):R.NaN}},{key:"size",value:function(){}},{key:"getOrdinate",value:function(e,t){}},{key:"getCoordinate",value:function(){}},{key:"getCoordinateCopy",value:function(e){}},{key:"createCoordinate",value:function(){}},{key:"getDimension",value:function(){}},{key:"hasM",value:function(){return this.getMeasures()>0}},{key:"getX",value:function(e){}},{key:"hasZ",value:function(){return this.getDimension()-this.getMeasures()>2}},{key:"getMeasures",value:function(){return 0}},{key:"expandEnvelope",value:function(e){}},{key:"copy",value:function(){}},{key:"getY",value:function(e){}},{key:"toCoordinateArray",value:function(){}},{key:"interfaces_",get:function(){return[w]}}]);ue.X=0,ue.Y=1,ue.Z=2,ue.M=3;var he=function(){function e(){i(this,e)}return o(e,null,[{key:"index",value:function(e,t,i){return ce.orientationIndex(e,t,i)}},{key:"isCCW",value:function(){if(arguments[0]instanceof Array){var t=arguments[0],i=t.length-1;if(i<3)throw new v("Ring has fewer than 4 points, so orientation cannot be determined");for(var n=t[0],r=0,o=1;o<=i;o++){var s=t[o];s.y>n.y&&(n=s,r=o)}var a=r;do{(a-=1)<0&&(a=i)}while(t[a].equals2D(n)&&a!==r);var l=r;do{l=(l+1)%i}while(t[l].equals2D(n)&&l!==r);var c=t[a],u=t[l];if(c.equals2D(n)||u.equals2D(n)||c.equals2D(u))return!1;var h=e.index(c,n,u);return 0===h?c.x>u.x:h>0}if(re(arguments[0],ue)){var d=arguments[0],p=d.size()-1;if(p<3)throw new v("Ring has fewer than 4 points, so orientation cannot be determined");for(var f=d.getCoordinate(0),m=0,g=1;g<=p;g++){var y=d.getCoordinate(g);y.y>f.y&&(f=y,m=g)}var _=null,x=m;do{(x-=1)<0&&(x=p),_=d.getCoordinate(x)}while(_.equals2D(f)&&x!==m);var b=null,w=m;do{w=(w+1)%p,b=d.getCoordinate(w)}while(b.equals2D(f)&&w!==m);if(_.equals2D(f)||b.equals2D(f)||_.equals2D(b))return!1;var E=e.index(_,f,b);return 0===E?_.x>b.x:E>0}}}])}();he.CLOCKWISE=-1,he.RIGHT=he.CLOCKWISE,he.COUNTERCLOCKWISE=1,he.LEFT=he.COUNTERCLOCKWISE,he.COLLINEAR=0,he.STRAIGHT=he.COLLINEAR;var de=o(function e(){i(this,e),e.constructor_.apply(this,arguments)},[{key:"getCoordinate",value:function(){return this._minCoord}},{key:"getRightmostSide",value:function(e,t){var i=this.getRightmostSideOfSegment(e,t);return i<0&&(i=this.getRightmostSideOfSegment(e,t-1)),i<0&&(this._minCoord=null,this.checkForRightmostCoordinate(e)),i}},{key:"findRightmostEdgeAtVertex",value:function(){var e=this._minDe.getEdge().getCoordinates();N.isTrue(this._minIndex>0&&this._minIndex<e.length,"rightmost point expected to be interior vertex of edge");var t=e[this._minIndex-1],i=e[this._minIndex+1],n=he.index(this._minCoord,i,t),r=!1;(t.y<this._minCoord.y&&i.y<this._minCoord.y&&n===he.COUNTERCLOCKWISE||t.y>this._minCoord.y&&i.y>this._minCoord.y&&n===he.CLOCKWISE)&&(r=!0),r&&(this._minIndex=this._minIndex-1)}},{key:"getRightmostSideOfSegment",value:function(e,t){var i=e.getEdge().getCoordinates();if(t<0||t+1>=i.length||i[t].y===i[t+1].y)return-1;var n=Q.LEFT;return i[t].y<i[t+1].y&&(n=Q.RIGHT),n}},{key:"getEdge",value:function(){return this._orientedDe}},{key:"checkForRightmostCoordinate",value:function(e){for(var t=e.getEdge().getCoordinates(),i=0;i<t.length-1;i++)(null===this._minCoord||t[i].x>this._minCoord.x)&&(this._minDe=e,this._minIndex=i,this._minCoord=t[i])}},{key:"findRightmostEdgeAtNode",value:function(){var e=this._minDe.getNode().getEdges();this._minDe=e.getRightmostEdge(),this._minDe.isForward()||(this._minDe=this._minDe.getSym(),this._minIndex=this._minDe.getEdge().getCoordinates().length-1)}},{key:"findEdge",value:function(e){for(var t=e.iterator();t.hasNext();){var i=t.next();i.isForward()&&this.checkForRightmostCoordinate(i)}N.isTrue(0!==this._minIndex||this._minCoord.equals(this._minDe.getCoordinate()),"inconsistency in rightmost processing"),0===this._minIndex?this.findRightmostEdgeAtNode():this.findRightmostEdgeAtVertex(),this._orientedDe=this._minDe,this.getRightmostSide(this._minDe,this._minIndex)===Q.LEFT&&(this._orientedDe=this._minDe.getSym())}}],[{key:"constructor_",value:function(){this._minIndex=-1,this._minCoord=null,this._minDe=null,this._orientedDe=null}}]),pe=function(e){function n(e,r){var o;return i(this,n),(o=t(this,n,[r?e+" [ "+r+" ]":e])).pt=r?new V(r):void 0,o.name=Object.keys({TopologyException:n})[0],o}return c(n,e),o(n,[{key:"getCoordinate",value:function(){return this.pt}}])}(F),fe=o(function e(){i(this,e),this.array=[]},[{key:"addLast",value:function(e){this.array.push(e)}},{key:"removeFirst",value:function(){return this.array.shift()}},{key:"isEmpty",value:function(){return 0===this.array.length}}]),me=function(e){function n(e){var r;return i(this,n),(r=t(this,n)).array=[],e instanceof H&&r.addAll(e),r}return c(n,e),o(n,[{key:"interfaces_",get:function(){return[ie,H]}},{key:"ensureCapacity",value:function(){}},{key:"add",value:function(e){return 1===arguments.length?this.array.push(e):this.array.splice(arguments[0],0,arguments[1]),!0}},{key:"clear",value:function(){this.array=[]}},{key:"addAll",value:function(e){var t,i=s(e);try{for(i.s();!(t=i.n()).done;){var n=t.value;this.array.push(n)}}catch(e){i.e(e)}finally{i.f()}}},{key:"set",value:function(e,t){var i=this.array[e];return this.array[e]=t,i}},{key:"iterator",value:function(){return new ge(this)}},{key:"get",value:function(e){if(e<0||e>=this.size())throw new te;return this.array[e]}},{key:"isEmpty",value:function(){return 0===this.array.length}},{key:"sort",value:function(e){e?this.array.sort(function(t,i){return e.compare(t,i)}):this.array.sort()}},{key:"size",value:function(){return this.array.length}},{key:"toArray",value:function(){return this.array.slice()}},{key:"remove",value:function(e){for(var t=0,i=this.array.length;t<i;t++)if(this.array[t]===e)return!!this.array.splice(t,1);return!1}},{key:Symbol.iterator,value:function(){return this.array.values()}}])}(ie),ge=o(function e(t){i(this,e),this.arrayList=t,this.position=0},[{key:"next",value:function(){if(this.position===this.arrayList.size())throw new W;return this.arrayList.get(this.position++)}},{key:"hasNext",value:function(){return this.position<this.arrayList.size()}},{key:"set",value:function(e){return this.arrayList.set(this.position-1,e)}},{key:"remove",value:function(){this.arrayList.remove(this.arrayList.get(this.position))}}]),ye=o(function e(){i(this,e),e.constructor_.apply(this,arguments)},[{key:"clearVisitedEdges",value:function(){for(var e=this._dirEdgeList.iterator();e.hasNext();)e.next().setVisited(!1)}},{key:"getRightmostCoordinate",value:function(){return this._rightMostCoord}},{key:"computeNodeDepth",value:function(e){for(var t=null,i=e.getEdges().iterator();i.hasNext();){var n=i.next();if(n.isVisited()||n.getSym().isVisited()){t=n;break}}if(null===t)throw new pe("unable to find edge to compute depths at "+e.getCoordinate());e.getEdges().computeDepths(t);for(var r=e.getEdges().iterator();r.hasNext();){var o=r.next();o.setVisited(!0),this.copySymDepths(o)}}},{key:"computeDepth",value:function(e){this.clearVisitedEdges();var t=this._finder.getEdge();t.getNode(),t.getLabel(),t.setEdgeDepths(Q.RIGHT,e),this.copySymDepths(t),this.computeDepths(t)}},{key:"create",value:function(e){this.addReachable(e),this._finder.findEdge(this._dirEdgeList),this._rightMostCoord=this._finder.getCoordinate()}},{key:"findResultEdges",value:function(){for(var e=this._dirEdgeList.iterator();e.hasNext();){var t=e.next();t.getDepth(Q.RIGHT)>=1&&t.getDepth(Q.LEFT)<=0&&!t.isInteriorAreaEdge()&&t.setInResult(!0)}}},{key:"computeDepths",value:function(e){var t=new J,i=new fe,n=e.getNode();for(i.addLast(n),t.add(n),e.setVisited(!0);!i.isEmpty();){var r=i.removeFirst();t.add(r),this.computeNodeDepth(r);for(var o=r.getEdges().iterator();o.hasNext();){var s=o.next().getSym();if(!s.isVisited()){var a=s.getNode();t.contains(a)||(i.addLast(a),t.add(a))}}}}},{key:"compareTo",value:function(e){var t=e;return this._rightMostCoord.x<t._rightMostCoord.x?-1:this._rightMostCoord.x>t._rightMostCoord.x?1:0}},{key:"getEnvelope",value:function(){if(null===this._env){for(var e=new q,t=this._dirEdgeList.iterator();t.hasNext();)for(var i=t.next().getEdge().getCoordinates(),n=0;n<i.length-1;n++)e.expandToInclude(i[n]);this._env=e}return this._env}},{key:"addReachable",value:function(e){var t=new ne;for(t.add(e);!t.empty();){var i=t.pop();this.add(i,t)}}},{key:"copySymDepths",value:function(e){var t=e.getSym();t.setDepth(Q.LEFT,e.getDepth(Q.RIGHT)),t.setDepth(Q.RIGHT,e.getDepth(Q.LEFT))}},{key:"add",value:function(e,t){e.setVisited(!0),this._nodes.add(e);for(var i=e.getEdges().iterator();i.hasNext();){var n=i.next();this._dirEdgeList.add(n);var r=n.getSym().getNode();r.isVisited()||t.push(r)}}},{key:"getNodes",value:function(){return this._nodes}},{key:"getDirectedEdges",value:function(){return this._dirEdgeList}},{key:"interfaces_",get:function(){return[b]}}],[{key:"constructor_",value:function(){this._finder=null,this._dirEdgeList=new me,this._nodes=new me,this._rightMostCoord=null,this._env=null,this._finder=new de}}]),_e=o(function e(){i(this,e)},null,[{key:"intersection",value:function(e,t,i,n){var r=e.x<t.x?e.x:t.x,o=e.y<t.y?e.y:t.y,s=e.x>t.x?e.x:t.x,a=e.y>t.y?e.y:t.y,l=i.x<n.x?i.x:n.x,c=i.y<n.y?i.y:n.y,u=i.x>n.x?i.x:n.x,h=i.y>n.y?i.y:n.y,d=((r>l?r:l)+(s<u?s:u))/2,p=((o>c?o:c)+(a<h?a:h))/2,f=e.x-d,m=e.y-p,g=t.x-d,y=t.y-p,_=i.x-d,v=i.y-p,x=n.x-d,b=n.y-p,w=m-y,E=g-f,T=f*y-g*m,S=v-b,I=x-_,k=_*b-x*v,M=w*I-S*E,C=(E*k-I*T)/M,P=(S*T-w*k)/M;return R.isNaN(C)||R.isInfinite(C)||R.isNaN(P)||R.isInfinite(P)?null:new V(C+d,P+p)}}]),ve=o(function e(){i(this,e)},null,[{key:"arraycopy",value:function(e,t,i,n,r){for(var o=0,s=t;s<t+r;s++)i[n+o]=e[s],o++}},{key:"getProperty",value:function(e){return{"line.separator":"\n"}[e]}}]),xe=function(){function e(){i(this,e)}return o(e,null,[{key:"log10",value:function(t){var i=Math.log(t);return R.isInfinite(i)||R.isNaN(i)?i:i/e.LOG_10}},{key:"min",value:function(e,t,i,n){var r=e;return t<r&&(r=t),i<r&&(r=i),n<r&&(r=n),r}},{key:"clamp",value:function(){if("number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){var e=arguments[0],t=arguments[1],i=arguments[2];return e<t?t:e>i?i:e}if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var n=arguments[0],r=arguments[1],o=arguments[2];return n<r?r:n>o?o:n}}},{key:"wrap",value:function(e,t){return e<0?t- -e%t:e%t}},{key:"max",value:function(){if(3===arguments.length){var e=arguments[1],t=arguments[2],i=arguments[0];return e>i&&(i=e),t>i&&(i=t),i}if(4===arguments.length){var n=arguments[1],r=arguments[2],o=arguments[3],s=arguments[0];return n>s&&(s=n),r>s&&(s=r),o>s&&(s=o),s}}},{key:"average",value:function(e,t){return(e+t)/2}}])}();xe.LOG_10=Math.log(10);var be=function(){function e(){i(this,e)}return o(e,null,[{key:"segmentToSegment",value:function(t,i,n,r){if(t.equals(i))return e.pointToSegment(t,n,r);if(n.equals(r))return e.pointToSegment(r,t,i);var o=!1;if(q.intersects(t,i,n,r)){var s=(i.x-t.x)*(r.y-n.y)-(i.y-t.y)*(r.x-n.x);if(0===s)o=!0;else{var a=(t.y-n.y)*(r.x-n.x)-(t.x-n.x)*(r.y-n.y),l=((t.y-n.y)*(i.x-t.x)-(t.x-n.x)*(i.y-t.y))/s,c=a/s;(c<0||c>1||l<0||l>1)&&(o=!0)}}else o=!0;return o?xe.min(e.pointToSegment(t,n,r),e.pointToSegment(i,n,r),e.pointToSegment(n,t,i),e.pointToSegment(r,t,i)):0}},{key:"pointToSegment",value:function(e,t,i){if(t.x===i.x&&t.y===i.y)return e.distance(t);var n=(i.x-t.x)*(i.x-t.x)+(i.y-t.y)*(i.y-t.y),r=((e.x-t.x)*(i.x-t.x)+(e.y-t.y)*(i.y-t.y))/n;if(r<=0)return e.distance(t);if(r>=1)return e.distance(i);var o=((t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y))/n;return Math.abs(o)*Math.sqrt(n)}},{key:"pointToLinePerpendicular",value:function(e,t,i){var n=(i.x-t.x)*(i.x-t.x)+(i.y-t.y)*(i.y-t.y),r=((t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y))/n;return Math.abs(r)*Math.sqrt(n)}},{key:"pointToSegmentString",value:function(t,i){if(0===i.length)throw new v("Line array must contain at least one vertex");for(var n=t.distance(i[0]),r=0;r<i.length-1;r++){var o=e.pointToSegment(t,i[r],i[r+1]);o<n&&(n=o)}return n}}])}(),we=o(function e(){i(this,e)},[{key:"create",value:function(){if(1===arguments.length)arguments[0]instanceof Array||re(arguments[0],ue);else if(2!==arguments.length&&3===arguments.length){var e=arguments[0],t=arguments[1];return this.create(e,t)}}}]),Ee=o(function e(){i(this,e)},[{key:"filter",value:function(e){}}]),Te=o(function e(){i(this,e)},null,[{key:"ofLine",value:function(e){var t=e.size();if(t<=1)return 0;var i=0,n=new V;e.getCoordinate(0,n);for(var r=n.x,o=n.y,s=1;s<t;s++){e.getCoordinate(s,n);var a=n.x,l=n.y,c=a-r,u=l-o;i+=Math.sqrt(c*c+u*u),r=a,o=l}return i}}]),Se=o(function e(){i(this,e)}),Ie=function(){function e(){i(this,e)}return o(e,null,[{key:"copyCoord",value:function(e,t,i,n){for(var r=Math.min(e.getDimension(),i.getDimension()),o=0;o<r;o++)i.setOrdinate(n,o,e.getOrdinate(t,o))}},{key:"isRing",value:function(e){var t=e.size();return 0===t||!(t<=3)&&e.getOrdinate(0,ue.X)===e.getOrdinate(t-1,ue.X)&&e.getOrdinate(0,ue.Y)===e.getOrdinate(t-1,ue.Y)}},{key:"scroll",value:function(){if(2===arguments.length){if(re(arguments[0],ue)&&Number.isInteger(arguments[1])){var t=arguments[0],i=arguments[1];e.scroll(t,i,e.isRing(t))}else if(re(arguments[0],ue)&&arguments[1]instanceof V){var n=arguments[0],r=arguments[1],o=e.indexOf(r,n);if(o<=0)return null;e.scroll(n,o)}}else if(3===arguments.length){var s=arguments[0],a=arguments[1],l=arguments[2];if(a<=0)return null;for(var c=s.copy(),u=l?s.size()-1:s.size(),h=0;h<u;h++)for(var d=0;d<s.getDimension();d++)s.setOrdinate(h,d,c.getOrdinate((a+h)%u,d));if(l)for(var p=0;p<s.getDimension();p++)s.setOrdinate(u,p,s.getOrdinate(0,p))}}},{key:"isEqual",value:function(e,t){var i=e.size();if(i!==t.size())return!1;for(var n=Math.min(e.getDimension(),t.getDimension()),r=0;r<i;r++)for(var o=0;o<n;o++){var s=e.getOrdinate(r,o),a=t.getOrdinate(r,o);if(!(e.getOrdinate(r,o)===t.getOrdinate(r,o)||R.isNaN(s)&&R.isNaN(a)))return!1}return!0}},{key:"minCoordinateIndex",value:function(){if(1===arguments.length){var t=arguments[0];return e.minCoordinateIndex(t,0,t.size()-1)}if(3===arguments.length){for(var i=arguments[0],n=arguments[2],r=-1,o=null,s=arguments[1];s<=n;s++){var a=i.getCoordinate(s);(null===o||o.compareTo(a)>0)&&(o=a,r=s)}return r}}},{key:"extend",value:function(t,i,n){var r=t.create(n,i.getDimension()),o=i.size();if(e.copy(i,0,r,0,o),o>0)for(var s=o;s<n;s++)e.copy(i,o-1,r,s,1);return r}},{key:"reverse",value:function(t){for(var i=t.size()-1,n=Math.trunc(i/2),r=0;r<=n;r++)e.swap(t,r,i-r)}},{key:"swap",value:function(e,t,i){if(t===i)return null;for(var n=0;n<e.getDimension();n++){var r=e.getOrdinate(t,n);e.setOrdinate(t,n,e.getOrdinate(i,n)),e.setOrdinate(i,n,r)}}},{key:"copy",value:function(t,i,n,r,o){for(var s=0;s<o;s++)e.copyCoord(t,i+s,n,r+s)}},{key:"ensureValidRing",value:function(t,i){var n=i.size();return 0===n?i:n<=3?e.createClosedRing(t,i,4):i.getOrdinate(0,ue.X)===i.getOrdinate(n-1,ue.X)&&i.getOrdinate(0,ue.Y)===i.getOrdinate(n-1,ue.Y)?i:e.createClosedRing(t,i,n+1)}},{key:"indexOf",value:function(e,t){for(var i=0;i<t.size();i++)if(e.x===t.getOrdinate(i,ue.X)&&e.y===t.getOrdinate(i,ue.Y))return i;return-1}},{key:"createClosedRing",value:function(t,i,n){var r=t.create(n,i.getDimension()),o=i.size();e.copy(i,0,r,0,o);for(var s=o;s<n;s++)e.copy(i,0,r,s,1);return r}},{key:"minCoordinate",value:function(e){for(var t=null,i=0;i<e.size();i++){var n=e.getCoordinate(i);(null===t||t.compareTo(n)>0)&&(t=n)}return t}}])}(),ke=function(){function e(){i(this,e)}return o(e,null,[{key:"toDimensionSymbol",value:function(t){switch(t){case e.FALSE:return e.SYM_FALSE;case e.TRUE:return e.SYM_TRUE;case e.DONTCARE:return e.SYM_DONTCARE;case e.P:return e.SYM_P;case e.L:return e.SYM_L;case e.A:return e.SYM_A}throw new v("Unknown dimension value: "+t)}},{key:"toDimensionValue",value:function(t){switch(ae.toUpperCase(t)){case e.SYM_FALSE:return e.FALSE;case e.SYM_TRUE:return e.TRUE;case e.SYM_DONTCARE:return e.DONTCARE;case e.SYM_P:return e.P;case e.SYM_L:return e.L;case e.SYM_A:return e.A}throw new v("Unknown dimension symbol: "+t)}}])}();ke.P=0,ke.L=1,ke.A=2,ke.FALSE=-1,ke.TRUE=-2,ke.DONTCARE=-3,ke.SYM_FALSE="F",ke.SYM_TRUE="T",ke.SYM_DONTCARE="*",ke.SYM_P="0",ke.SYM_L="1",ke.SYM_A="2";var Me=o(function e(){i(this,e)},[{key:"filter",value:function(e){}}]),Ce=o(function e(){i(this,e)},[{key:"filter",value:function(e,t){}},{key:"isDone",value:function(){}},{key:"isGeometryChanged",value:function(){}}]),Pe=function(e){function n(){var e;return i(this,n),e=t(this,n),n.constructor_.apply(e,arguments),e}return c(n,e),o(n,[{key:"computeEnvelopeInternal",value:function(){return this.isEmpty()?new q:this._points.expandEnvelope(new q)}},{key:"isRing",value:function(){return this.isClosed()&&this.isSimple()}},{key:"getCoordinates",value:function(){return this._points.toCoordinateArray()}},{key:"copyInternal",value:function(){return new n(this._points.copy(),this._factory)}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof Z){var e=arguments[0],t=arguments[1];if(!this.isEquivalentClass(e))return!1;var i=e;if(this._points.size()!==i._points.size())return!1;for(var r=0;r<this._points.size();r++)if(!this.equal(this._points.getCoordinate(r),i._points.getCoordinate(r),t))return!1;return!0}return d(n,"equalsExact",this,1).apply(this,arguments)}},{key:"normalize",value:function(){for(var e=0;e<Math.trunc(this._points.size()/2);e++){var t=this._points.size()-1-e;if(!this._points.getCoordinate(e).equals(this._points.getCoordinate(t))){if(this._points.getCoordinate(e).compareTo(this._points.getCoordinate(t))>0){var i=this._points.copy();Ie.reverse(i),this._points=i}return null}}}},{key:"getCoordinate",value:function(){return this.isEmpty()?null:this._points.getCoordinate(0)}},{key:"getBoundaryDimension",value:function(){return this.isClosed()?ke.FALSE:0}},{key:"isClosed",value:function(){return!this.isEmpty()&&this.getCoordinateN(0).equals2D(this.getCoordinateN(this.getNumPoints()-1))}},{key:"reverseInternal",value:function(){var e=this._points.copy();return Ie.reverse(e),this.getFactory().createLineString(e)}},{key:"getEndPoint",value:function(){return this.isEmpty()?null:this.getPointN(this.getNumPoints()-1)}},{key:"getTypeCode",value:function(){return Z.TYPECODE_LINESTRING}},{key:"getDimension",value:function(){return 1}},{key:"getLength",value:function(){return Te.ofLine(this._points)}},{key:"getNumPoints",value:function(){return this._points.size()}},{key:"compareToSameClass",value:function(){if(1===arguments.length){for(var e=arguments[0],t=0,i=0;t<this._points.size()&&i<e._points.size();){var n=this._points.getCoordinate(t).compareTo(e._points.getCoordinate(i));if(0!==n)return n;t++,i++}return t<this._points.size()?1:i<e._points.size()?-1:0}if(2===arguments.length){var r=arguments[0];return arguments[1].compare(this._points,r._points)}}},{key:"apply",value:function(){if(re(arguments[0],Ee))for(var e=arguments[0],t=0;t<this._points.size();t++)e.filter(this._points.getCoordinate(t));else if(re(arguments[0],Ce)){var i=arguments[0];if(0===this._points.size())return null;for(var n=0;n<this._points.size()&&(i.filter(this._points,n),!i.isDone());n++);i.isGeometryChanged()&&this.geometryChanged()}else(re(arguments[0],Me)||re(arguments[0],x))&&arguments[0].filter(this)}},{key:"getBoundary",value:function(){throw new X}},{key:"isEquivalentClass",value:function(e){return e instanceof n}},{key:"getCoordinateN",value:function(e){return this._points.getCoordinate(e)}},{key:"getGeometryType",value:function(){return Z.TYPENAME_LINESTRING}},{key:"getCoordinateSequence",value:function(){return this._points}},{key:"isEmpty",value:function(){return 0===this._points.size()}},{key:"init",value:function(e){if(null===e&&(e=this.getFactory().getCoordinateSequenceFactory().create([])),1===e.size())throw new v("Invalid number of points in LineString (found "+e.size()+" - must be 0 or >= 2)");this._points=e}},{key:"isCoordinate",value:function(e){for(var t=0;t<this._points.size();t++)if(this._points.getCoordinate(t).equals(e))return!0;return!1}},{key:"getStartPoint",value:function(){return this.isEmpty()?null:this.getPointN(0)}},{key:"getPointN",value:function(e){return this.getFactory().createPoint(this._points.getCoordinate(e))}},{key:"interfaces_",get:function(){return[Se]}}],[{key:"constructor_",value:function(){if(this._points=null,0!==arguments.length&&2===arguments.length){var e=arguments[0],t=arguments[1];Z.constructor_.call(this,t),this.init(e)}}}])}(Z),Ae=o(function e(){i(this,e)}),Le=function(e){function n(){var e;return i(this,n),e=t(this,n),n.constructor_.apply(e,arguments),e}return c(n,e),o(n,[{key:"computeEnvelopeInternal",value:function(){if(this.isEmpty())return new q;var e=new q;return e.expandToInclude(this._coordinates.getX(0),this._coordinates.getY(0)),e}},{key:"getCoordinates",value:function(){return this.isEmpty()?[]:[this.getCoordinate()]}},{key:"copyInternal",value:function(){return new n(this._coordinates.copy(),this._factory)}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof Z){var e=arguments[0],t=arguments[1];return!!this.isEquivalentClass(e)&&(!(!this.isEmpty()||!e.isEmpty())||this.isEmpty()===e.isEmpty()&&this.equal(e.getCoordinate(),this.getCoordinate(),t))}return d(n,"equalsExact",this,1).apply(this,arguments)}},{key:"normalize",value:function(){}},{key:"getCoordinate",value:function(){return 0!==this._coordinates.size()?this._coordinates.getCoordinate(0):null}},{key:"getBoundaryDimension",value:function(){return ke.FALSE}},{key:"reverseInternal",value:function(){return this.getFactory().createPoint(this._coordinates.copy())}},{key:"getTypeCode",value:function(){return Z.TYPECODE_POINT}},{key:"getDimension",value:function(){return 0}},{key:"getNumPoints",value:function(){return this.isEmpty()?0:1}},{key:"getX",value:function(){if(null===this.getCoordinate())throw new IllegalStateException("getX called on empty Point");return this.getCoordinate().x}},{key:"compareToSameClass",value:function(){if(1===arguments.length){var e=arguments[0];return this.getCoordinate().compareTo(e.getCoordinate())}if(2===arguments.length){var t=arguments[0];return arguments[1].compare(this._coordinates,t._coordinates)}}},{key:"apply",value:function(){if(re(arguments[0],Ee)){var e=arguments[0];if(this.isEmpty())return null;e.filter(this.getCoordinate())}else if(re(arguments[0],Ce)){var t=arguments[0];if(this.isEmpty())return null;t.filter(this._coordinates,0),t.isGeometryChanged()&&this.geometryChanged()}else(re(arguments[0],Me)||re(arguments[0],x))&&arguments[0].filter(this)}},{key:"getBoundary",value:function(){return this.getFactory().createGeometryCollection()}},{key:"getGeometryType",value:function(){return Z.TYPENAME_POINT}},{key:"getCoordinateSequence",value:function(){return this._coordinates}},{key:"getY",value:function(){if(null===this.getCoordinate())throw new IllegalStateException("getY called on empty Point");return this.getCoordinate().y}},{key:"isEmpty",value:function(){return 0===this._coordinates.size()}},{key:"init",value:function(e){null===e&&(e=this.getFactory().getCoordinateSequenceFactory().create([])),N.isTrue(e.size()<=1),this._coordinates=e}},{key:"isSimple",value:function(){return!0}},{key:"interfaces_",get:function(){return[Ae]}}],[{key:"constructor_",value:function(){this._coordinates=null;var e=arguments[0],t=arguments[1];Z.constructor_.call(this,t),this.init(e)}}])}(Z),De=function(){function e(){i(this,e)}return o(e,null,[{key:"ofRing",value:function(){if(arguments[0]instanceof Array){var t=arguments[0];return Math.abs(e.ofRingSigned(t))}if(re(arguments[0],ue)){var i=arguments[0];return Math.abs(e.ofRingSigned(i))}}},{key:"ofRingSigned",value:function(){if(arguments[0]instanceof Array){var e=arguments[0];if(e.length<3)return 0;for(var t=0,i=e[0].x,n=1;n<e.length-1;n++){var r=e[n].x-i,o=e[n+1].y;t+=r*(e[n-1].y-o)}return t/2}if(re(arguments[0],ue)){var s=arguments[0],a=s.size();if(a<3)return 0;var l=new V,c=new V,u=new V;s.getCoordinate(0,c),s.getCoordinate(1,u);var h=c.x;u.x-=h;for(var d=0,p=1;p<a-1;p++)l.y=c.y,c.x=u.x,c.y=u.y,s.getCoordinate(p+1,u),u.x-=h,d+=c.x*(l.y-u.y);return d/2}}}])}(),Re=o(function e(){i(this,e)},null,[{key:"sort",value:function(){var e=arguments,t=arguments[0];if(1===arguments.length)t.sort(function(e,t){return e.compareTo(t)});else if(2===arguments.length)t.sort(function(t,i){return e[1].compare(t,i)});else if(3===arguments.length){var i=t.slice(arguments[1],arguments[2]);i.sort();var n=t.slice(0,arguments[1]).concat(i,t.slice(arguments[2],t.length));t.splice(0,t.length);var r,o=s(n);try{for(o.s();!(r=o.n()).done;){var a=r.value;t.push(a)}}catch(e){o.e(e)}finally{o.f()}}else if(4===arguments.length){var l=t.slice(arguments[1],arguments[2]);l.sort(function(t,i){return e[3].compare(t,i)});var c=t.slice(0,arguments[1]).concat(l,t.slice(arguments[2],t.length));t.splice(0,t.length);var u,h=s(c);try{for(h.s();!(u=h.n()).done;){var d=u.value;t.push(d)}}catch(e){h.e(e)}finally{h.f()}}}},{key:"asList",value:function(e){var t,i=new me,n=s(e);try{for(n.s();!(t=n.n()).done;){var r=t.value;i.add(r)}}catch(e){n.e(e)}finally{n.f()}return i}},{key:"copyOf",value:function(e,t){return e.slice(0,t)}}]),ze=o(function e(){i(this,e)}),Fe=function(e){function n(){var e;return i(this,n),e=t(this,n),n.constructor_.apply(e,arguments),e}return c(n,e),o(n,[{key:"computeEnvelopeInternal",value:function(){return this._shell.getEnvelopeInternal()}},{key:"getCoordinates",value:function(){if(this.isEmpty())return[];for(var e=new Array(this.getNumPoints()).fill(null),t=-1,i=this._shell.getCoordinates(),n=0;n<i.length;n++)e[++t]=i[n];for(var r=0;r<this._holes.length;r++)for(var o=this._holes[r].getCoordinates(),s=0;s<o.length;s++)e[++t]=o[s];return e}},{key:"getArea",value:function(){var e=0;e+=De.ofRing(this._shell.getCoordinateSequence());for(var t=0;t<this._holes.length;t++)e-=De.ofRing(this._holes[t].getCoordinateSequence());return e}},{key:"copyInternal",value:function(){for(var e=this._shell.copy(),t=new Array(this._holes.length).fill(null),i=0;i<this._holes.length;i++)t[i]=this._holes[i].copy();return new n(e,t,this._factory)}},{key:"isRectangle",value:function(){if(0!==this.getNumInteriorRing()||null===this._shell||5!==this._shell.getNumPoints())return!1;for(var e=this._shell.getCoordinateSequence(),t=this.getEnvelopeInternal(),i=0;i<5;i++){var n=e.getX(i);if(n!==t.getMinX()&&n!==t.getMaxX())return!1;var r=e.getY(i);if(r!==t.getMinY()&&r!==t.getMaxY())return!1}for(var o=e.getX(0),s=e.getY(0),a=1;a<=4;a++){var l=e.getX(a),c=e.getY(a);if(l!==o==(c!==s))return!1;o=l,s=c}return!0}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof Z){var e=arguments[0],t=arguments[1];if(!this.isEquivalentClass(e))return!1;var i=e,r=this._shell,o=i._shell;if(!r.equalsExact(o,t)||this._holes.length!==i._holes.length)return!1;for(var s=0;s<this._holes.length;s++)if(!this._holes[s].equalsExact(i._holes[s],t))return!1;return!0}return d(n,"equalsExact",this,1).apply(this,arguments)}},{key:"normalize",value:function(){if(0===arguments.length){this._shell=this.normalized(this._shell,!0);for(var e=0;e<this._holes.length;e++)this._holes[e]=this.normalized(this._holes[e],!1);Re.sort(this._holes)}else if(2===arguments.length){var t=arguments[0],i=arguments[1];if(t.isEmpty())return null;var n=t.getCoordinateSequence(),r=Ie.minCoordinateIndex(n,0,n.size()-2);Ie.scroll(n,r,!0),he.isCCW(n)===i&&Ie.reverse(n)}}},{key:"getCoordinate",value:function(){return this._shell.getCoordinate()}},{key:"getNumInteriorRing",value:function(){return this._holes.length}},{key:"getBoundaryDimension",value:function(){return 1}},{key:"reverseInternal",value:function(){for(var e=this.getExteriorRing().reverse(),t=new Array(this.getNumInteriorRing()).fill(null),i=0;i<t.length;i++)t[i]=this.getInteriorRingN(i).reverse();return this.getFactory().createPolygon(e,t)}},{key:"getTypeCode",value:function(){return Z.TYPECODE_POLYGON}},{key:"getDimension",value:function(){return 2}},{key:"getLength",value:function(){var e=0;e+=this._shell.getLength();for(var t=0;t<this._holes.length;t++)e+=this._holes[t].getLength();return e}},{key:"getNumPoints",value:function(){for(var e=this._shell.getNumPoints(),t=0;t<this._holes.length;t++)e+=this._holes[t].getNumPoints();return e}},{key:"convexHull",value:function(){return this.getExteriorRing().convexHull()}},{key:"normalized",value:function(e,t){var i=e.copy();return this.normalize(i,t),i}},{key:"compareToSameClass",value:function(){if(1===arguments.length){var e=arguments[0],t=this._shell,i=e._shell;return t.compareToSameClass(i)}if(2===arguments.length){var n=arguments[1],r=arguments[0],o=this._shell,s=r._shell,a=o.compareToSameClass(s,n);if(0!==a)return a;for(var l=this.getNumInteriorRing(),c=r.getNumInteriorRing(),u=0;u<l&&u<c;){var h=this.getInteriorRingN(u),d=r.getInteriorRingN(u),p=h.compareToSameClass(d,n);if(0!==p)return p;u++}return u<l?1:u<c?-1:0}}},{key:"apply",value:function(){if(re(arguments[0],Ee)){var e=arguments[0];this._shell.apply(e);for(var t=0;t<this._holes.length;t++)this._holes[t].apply(e)}else if(re(arguments[0],Ce)){var i=arguments[0];if(this._shell.apply(i),!i.isDone())for(var n=0;n<this._holes.length&&(this._holes[n].apply(i),!i.isDone());n++);i.isGeometryChanged()&&this.geometryChanged()}else if(re(arguments[0],Me))arguments[0].filter(this);else if(re(arguments[0],x)){var r=arguments[0];r.filter(this),this._shell.apply(r);for(var o=0;o<this._holes.length;o++)this._holes[o].apply(r)}}},{key:"getBoundary",value:function(){if(this.isEmpty())return this.getFactory().createMultiLineString();var e=new Array(this._holes.length+1).fill(null);e[0]=this._shell;for(var t=0;t<this._holes.length;t++)e[t+1]=this._holes[t];return e.length<=1?this.getFactory().createLinearRing(e[0].getCoordinateSequence()):this.getFactory().createMultiLineString(e)}},{key:"getGeometryType",value:function(){return Z.TYPENAME_POLYGON}},{key:"getExteriorRing",value:function(){return this._shell}},{key:"isEmpty",value:function(){return this._shell.isEmpty()}},{key:"getInteriorRingN",value:function(e){return this._holes[e]}},{key:"interfaces_",get:function(){return[ze]}}],[{key:"constructor_",value:function(){this._shell=null,this._holes=null;var e=arguments[0],t=arguments[1],i=arguments[2];if(Z.constructor_.call(this,i),null===e&&(e=this.getFactory().createLinearRing()),null===t&&(t=[]),Z.hasNullElements(t))throw new v("holes must not contain null elements");if(e.isEmpty()&&Z.hasNonEmptyElements(t))throw new v("shell is empty but holes are not");this._shell=e,this._holes=t}}])}(Z),Oe=function(e){function n(){return i(this,n),t(this,n,arguments)}return c(n,e),o(n)}(Y),Ne=function(e){function n(e){var r;return i(this,n),(r=t(this,n)).array=[],e instanceof H&&r.addAll(e),r}return c(n,e),o(n,[{key:"contains",value:function(e){var t,i=s(this.array);try{for(i.s();!(t=i.n()).done;)if(0===t.value.compareTo(e))return!0}catch(e){i.e(e)}finally{i.f()}return!1}},{key:"add",value:function(e){if(this.contains(e))return!1;for(var t=0,i=this.array.length;t<i;t++)if(1===this.array[t].compareTo(e))return!!this.array.splice(t,0,e);return this.array.push(e),!0}},{key:"addAll",value:function(e){var t,i=s(e);try{for(i.s();!(t=i.n()).done;){var n=t.value;this.add(n)}}catch(e){i.e(e)}finally{i.f()}return!0}},{key:"remove",value:function(){throw new X}},{key:"size",value:function(){return this.array.length}},{key:"isEmpty",value:function(){return 0===this.array.length}},{key:"toArray",value:function(){return this.array.slice()}},{key:"iterator",value:function(){return new Be(this.array)}}])}(Oe),Be=o(function e(t){i(this,e),this.array=t,this.position=0},[{key:"next",value:function(){if(this.position===this.array.length)throw new W;return this.array[this.position++]}},{key:"hasNext",value:function(){return this.position<this.array.length}},{key:"remove",value:function(){throw new X}}]),Ge=function(e){function n(){var e;return i(this,n),e=t(this,n),n.constructor_.apply(e,arguments),e}return c(n,e),o(n,[{key:"computeEnvelopeInternal",value:function(){for(var e=new q,t=0;t<this._geometries.length;t++)e.expandToInclude(this._geometries[t].getEnvelopeInternal());return e}},{key:"getGeometryN",value:function(e){return this._geometries[e]}},{key:"getCoordinates",value:function(){for(var e=new Array(this.getNumPoints()).fill(null),t=-1,i=0;i<this._geometries.length;i++)for(var n=this._geometries[i].getCoordinates(),r=0;r<n.length;r++)e[++t]=n[r];return e}},{key:"getArea",value:function(){for(var e=0,t=0;t<this._geometries.length;t++)e+=this._geometries[t].getArea();return e}},{key:"copyInternal",value:function(){for(var e=new Array(this._geometries.length).fill(null),t=0;t<e.length;t++)e[t]=this._geometries[t].copy();return new n(e,this._factory)}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof Z){var e=arguments[0],t=arguments[1];if(!this.isEquivalentClass(e))return!1;var i=e;if(this._geometries.length!==i._geometries.length)return!1;for(var r=0;r<this._geometries.length;r++)if(!this._geometries[r].equalsExact(i._geometries[r],t))return!1;return!0}return d(n,"equalsExact",this,1).apply(this,arguments)}},{key:"normalize",value:function(){for(var e=0;e<this._geometries.length;e++)this._geometries[e].normalize();Re.sort(this._geometries)}},{key:"getCoordinate",value:function(){return this.isEmpty()?null:this._geometries[0].getCoordinate()}},{key:"getBoundaryDimension",value:function(){for(var e=ke.FALSE,t=0;t<this._geometries.length;t++)e=Math.max(e,this._geometries[t].getBoundaryDimension());return e}},{key:"reverseInternal",value:function(){for(var e=this._geometries.length,t=new me(e),i=0;i<e;i++)t.add(this._geometries[i].reverse());return this.getFactory().buildGeometry(t)}},{key:"getTypeCode",value:function(){return Z.TYPECODE_GEOMETRYCOLLECTION}},{key:"getDimension",value:function(){for(var e=ke.FALSE,t=0;t<this._geometries.length;t++)e=Math.max(e,this._geometries[t].getDimension());return e}},{key:"getLength",value:function(){for(var e=0,t=0;t<this._geometries.length;t++)e+=this._geometries[t].getLength();return e}},{key:"getNumPoints",value:function(){for(var e=0,t=0;t<this._geometries.length;t++)e+=this._geometries[t].getNumPoints();return e}},{key:"getNumGeometries",value:function(){return this._geometries.length}},{key:"compareToSameClass",value:function(){if(1===arguments.length){var e=arguments[0],t=new Ne(Re.asList(this._geometries)),i=new Ne(Re.asList(e._geometries));return this.compare(t,i)}if(2===arguments.length){for(var n=arguments[1],r=arguments[0],o=this.getNumGeometries(),s=r.getNumGeometries(),a=0;a<o&&a<s;){var l=this.getGeometryN(a),c=r.getGeometryN(a),u=l.compareToSameClass(c,n);if(0!==u)return u;a++}return a<o?1:a<s?-1:0}}},{key:"apply",value:function(){if(re(arguments[0],Ee))for(var e=arguments[0],t=0;t<this._geometries.length;t++)this._geometries[t].apply(e);else if(re(arguments[0],Ce)){var i=arguments[0];if(0===this._geometries.length)return null;for(var n=0;n<this._geometries.length&&(this._geometries[n].apply(i),!i.isDone());n++);i.isGeometryChanged()&&this.geometryChanged()}else if(re(arguments[0],Me)){var r=arguments[0];r.filter(this);for(var o=0;o<this._geometries.length;o++)this._geometries[o].apply(r)}else if(re(arguments[0],x)){var s=arguments[0];s.filter(this);for(var a=0;a<this._geometries.length;a++)this._geometries[a].apply(s)}}},{key:"getBoundary",value:function(){return Z.checkNotGeometryCollection(this),N.shouldNeverReachHere(),null}},{key:"getGeometryType",value:function(){return Z.TYPENAME_GEOMETRYCOLLECTION}},{key:"isEmpty",value:function(){for(var e=0;e<this._geometries.length;e++)if(!this._geometries[e].isEmpty())return!1;return!0}}],[{key:"constructor_",value:function(){if(this._geometries=null,0!==arguments.length&&2===arguments.length){var e=arguments[0],t=arguments[1];if(Z.constructor_.call(this,t),null===e&&(e=[]),Z.hasNullElements(e))throw new v("geometries must not contain null elements");this._geometries=e}}}])}(Z),je=function(e){function n(){var e;return i(this,n),e=t(this,n),n.constructor_.apply(e,arguments),e}return c(n,e),o(n,[{key:"copyInternal",value:function(){for(var e=new Array(this._geometries.length).fill(null),t=0;t<e.length;t++)e[t]=this._geometries[t].copy();return new n(e,this._factory)}},{key:"isValid",value:function(){return!0}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof Z){var e=arguments[0],t=arguments[1];return!!this.isEquivalentClass(e)&&d(n,"equalsExact",this,1).call(this,e,t)}return d(n,"equalsExact",this,1).apply(this,arguments)}},{key:"getCoordinate",value:function(){if(1===arguments.length&&Number.isInteger(arguments[0])){var e=arguments[0];return this._geometries[e].getCoordinate()}return d(n,"getCoordinate",this,1).apply(this,arguments)}},{key:"getBoundaryDimension",value:function(){return ke.FALSE}},{key:"getTypeCode",value:function(){return Z.TYPECODE_MULTIPOINT}},{key:"getDimension",value:function(){return 0}},{key:"getBoundary",value:function(){return this.getFactory().createGeometryCollection()}},{key:"getGeometryType",value:function(){return Z.TYPENAME_MULTIPOINT}},{key:"interfaces_",get:function(){return[Ae]}}],[{key:"constructor_",value:function(){var e=arguments[0],t=arguments[1];Ge.constructor_.call(this,e,t)}}])}(Ge),Ve=function(e){function n(){var e;return i(this,n),e=t(this,n),n.constructor_.apply(e,arguments),e}return c(n,e),o(n,[{key:"copyInternal",value:function(){return new n(this._points.copy(),this._factory)}},{key:"getBoundaryDimension",value:function(){return ke.FALSE}},{key:"isClosed",value:function(){return!!this.isEmpty()||d(n,"isClosed",this,1).call(this)}},{key:"reverseInternal",value:function(){var e=this._points.copy();return Ie.reverse(e),this.getFactory().createLinearRing(e)}},{key:"getTypeCode",value:function(){return Z.TYPECODE_LINEARRING}},{key:"validateConstruction",value:function(){if(!this.isEmpty()&&!d(n,"isClosed",this,1).call(this))throw new v("Points of LinearRing do not form a closed linestring");if(this.getCoordinateSequence().size()>=1&&this.getCoordinateSequence().size()<n.MINIMUM_VALID_SIZE)throw new v("Invalid number of points in LinearRing (found "+this.getCoordinateSequence().size()+" - must be 0 or >= 4)")}},{key:"getGeometryType",value:function(){return Z.TYPENAME_LINEARRING}}],[{key:"constructor_",value:function(){var e=arguments[0],t=arguments[1];Pe.constructor_.call(this,e,t),this.validateConstruction()}}])}(Pe);Ve.MINIMUM_VALID_SIZE=4;var Ue=function(e){function n(){var e;return i(this,n),e=t(this,n),n.constructor_.apply(e,arguments),e}return c(n,e),o(n,[{key:"setOrdinate",value:function(e,t){switch(e){case n.X:this.x=t;break;case n.Y:this.y=t;break;default:throw new v("Invalid ordinate index: "+e)}}},{key:"getZ",value:function(){return V.NULL_ORDINATE}},{key:"getOrdinate",value:function(e){switch(e){case n.X:return this.x;case n.Y:return this.y}throw new v("Invalid ordinate index: "+e)}},{key:"setZ",value:function(e){throw new v("CoordinateXY dimension 2 does not support z-ordinate")}},{key:"copy",value:function(){return new n(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+")"}},{key:"setCoordinate",value:function(e){this.x=e.x,this.y=e.y,this.z=e.getZ()}}],[{key:"constructor_",value:function(){if(0===arguments.length)V.constructor_.call(this);else if(1===arguments.length){if(arguments[0]instanceof n){var e=arguments[0];V.constructor_.call(this,e.x,e.y)}else if(arguments[0]instanceof V){var t=arguments[0];V.constructor_.call(this,t.x,t.y)}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];V.constructor_.call(this,i,r,V.NULL_ORDINATE)}}}])}(V);Ue.X=0,Ue.Y=1,Ue.Z=-1,Ue.M=-1;var qe=function(e){function n(){var e;return i(this,n),e=t(this,n),n.constructor_.apply(e,arguments),e}return c(n,e),o(n,[{key:"getM",value:function(){return this._m}},{key:"setOrdinate",value:function(e,t){switch(e){case n.X:this.x=t;break;case n.Y:this.y=t;break;case n.M:this._m=t;break;default:throw new v("Invalid ordinate index: "+e)}}},{key:"setM",value:function(e){this._m=e}},{key:"getZ",value:function(){return V.NULL_ORDINATE}},{key:"getOrdinate",value:function(e){switch(e){case n.X:return this.x;case n.Y:return this.y;case n.M:return this._m}throw new v("Invalid ordinate index: "+e)}},{key:"setZ",value:function(e){throw new v("CoordinateXY dimension 2 does not support z-ordinate")}},{key:"copy",value:function(){return new n(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+" m="+this.getM()+")"}},{key:"setCoordinate",value:function(e){this.x=e.x,this.y=e.y,this.z=e.getZ(),this._m=e.getM()}}],[{key:"constructor_",value:function(){if(this._m=null,0===arguments.length)V.constructor_.call(this),this._m=0;else if(1===arguments.length){if(arguments[0]instanceof n){var e=arguments[0];V.constructor_.call(this,e.x,e.y),this._m=e._m}else if(arguments[0]instanceof V){var t=arguments[0];V.constructor_.call(this,t.x,t.y),this._m=this.getM()}}else if(3===arguments.length){var i=arguments[0],r=arguments[1],o=arguments[2];V.constructor_.call(this,i,r,V.NULL_ORDINATE),this._m=o}}}])}(V);qe.X=0,qe.Y=1,qe.Z=-1,qe.M=2;var Ze=function(e){function n(){var e;return i(this,n),e=t(this,n),n.constructor_.apply(e,arguments),e}return c(n,e),o(n,[{key:"getM",value:function(){return this._m}},{key:"setOrdinate",value:function(e,t){switch(e){case V.X:this.x=t;break;case V.Y:this.y=t;break;case V.Z:this.z=t;break;case V.M:this._m=t;break;default:throw new v("Invalid ordinate index: "+e)}}},{key:"setM",value:function(e){this._m=e}},{key:"getOrdinate",value:function(e){switch(e){case V.X:return this.x;case V.Y:return this.y;case V.Z:return this.getZ();case V.M:return this.getM()}throw new v("Invalid ordinate index: "+e)}},{key:"copy",value:function(){return new n(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+", "+this.getZ()+" m="+this.getM()+")"}},{key:"setCoordinate",value:function(e){this.x=e.x,this.y=e.y,this.z=e.getZ(),this._m=e.getM()}}],[{key:"constructor_",value:function(){if(this._m=null,0===arguments.length)V.constructor_.call(this),this._m=0;else if(1===arguments.length){if(arguments[0]instanceof n){var e=arguments[0];V.constructor_.call(this,e),this._m=e._m}else if(arguments[0]instanceof V){var t=arguments[0];V.constructor_.call(this,t),this._m=this.getM()}}else if(4===arguments.length){var i=arguments[0],r=arguments[1],o=arguments[2],s=arguments[3];V.constructor_.call(this,i,r,o),this._m=s}}}])}(V),$e=function(){function e(){i(this,e)}return o(e,null,[{key:"measures",value:function(e){return e instanceof Ue?0:e instanceof qe||e instanceof Ze?1:0}},{key:"dimension",value:function(e){return e instanceof Ue?2:e instanceof qe?3:e instanceof Ze?4:3}},{key:"create",value:function(){if(1===arguments.length){var t=arguments[0];return e.create(t,0)}if(2===arguments.length){var i=arguments[0],n=arguments[1];return 2===i?new Ue:3===i&&0===n?new V:3===i&&1===n?new qe:4===i&&1===n?new Ze:new V}}}])}(),He=function(e){function n(){var e;return i(this,n),e=t(this,n),n.constructor_.apply(e,arguments),e}return c(n,e),o(n,[{key:"getCoordinate",value:function(e){return this.get(e)}},{key:"addAll",value:function(){if(2===arguments.length&&"boolean"==typeof arguments[1]&&re(arguments[0],H)){for(var e=arguments[1],t=!1,i=arguments[0].iterator();i.hasNext();)this.add(i.next(),e),t=!0;return t}return d(n,"addAll",this,1).apply(this,arguments)}},{key:"clone",value:function(){for(var e=d(n,"clone",this,1).call(this),t=0;t<this.size();t++)e.add(t,this.get(t).clone());return e}},{key:"toCoordinateArray",value:function(){if(0===arguments.length)return this.toArray(n.coordArrayType);if(1===arguments.length){if(arguments[0])return this.toArray(n.coordArrayType);for(var e=this.size(),t=new Array(e).fill(null),i=0;i<e;i++)t[i]=this.get(e-i-1);return t}}},{key:"add",value:function(){if(1===arguments.length){var e=arguments[0];return d(n,"add",this,1).call(this,e)}if(2===arguments.length){if(arguments[0]instanceof Array&&"boolean"==typeof arguments[1]){var t=arguments[0],i=arguments[1];return this.add(t,i,!0),!0}if(arguments[0]instanceof V&&"boolean"==typeof arguments[1]){var r=arguments[0];if(!arguments[1]&&this.size()>=1&&this.get(this.size()-1).equals2D(r))return null;d(n,"add",this,1).call(this,r)}else if(arguments[0]instanceof Object&&"boolean"==typeof arguments[1]){var o=arguments[0],s=arguments[1];return this.add(o,s),!0}}else if(3===arguments.length){if("boolean"==typeof arguments[2]&&arguments[0]instanceof Array&&"boolean"==typeof arguments[1]){var a=arguments[0],l=arguments[1];if(arguments[2])for(var c=0;c<a.length;c++)this.add(a[c],l);else for(var u=a.length-1;u>=0;u--)this.add(a[u],l);return!0}if("boolean"==typeof arguments[2]&&Number.isInteger(arguments[0])&&arguments[1]instanceof V){var h=arguments[0],p=arguments[1];if(!arguments[2]){var f=this.size();if(f>0&&(h>0&&this.get(h-1).equals2D(p)||h<f&&this.get(h).equals2D(p)))return null}d(n,"add",this,1).call(this,h,p)}}else if(4===arguments.length){var m=arguments[0],g=arguments[1],y=arguments[2],_=arguments[3],v=1;y>_&&(v=-1);for(var x=y;x!==_;x+=v)this.add(m[x],g);return!0}}},{key:"closeRing",value:function(){if(this.size()>0){var e=this.get(0).copy();this.add(e,!1)}}}],[{key:"constructor_",value:function(){if(0!==arguments.length)if(1===arguments.length){var e=arguments[0];this.ensureCapacity(e.length),this.add(e,!0)}else if(2===arguments.length){var t=arguments[0],i=arguments[1];this.ensureCapacity(t.length),this.add(t,i)}}}])}(me);He.coordArrayType=new Array(0).fill(null);var We=function(){function e(){i(this,e)}return o(e,null,[{key:"isRing",value:function(e){return!(e.length<4||!e[0].equals2D(e[e.length-1]))}},{key:"ptNotInList",value:function(t,i){for(var n=0;n<t.length;n++){var r=t[n];if(e.indexOf(r,i)<0)return r}return null}},{key:"scroll",value:function(t,i){var n=e.indexOf(i,t);if(n<0)return null;var r=new Array(t.length).fill(null);ve.arraycopy(t,n,r,0,t.length-n),ve.arraycopy(t,0,r,t.length-n,n),ve.arraycopy(r,0,t,0,t.length)}},{key:"equals",value:function(){if(2===arguments.length){var e=arguments[0],t=arguments[1];if(e===t)return!0;if(null===e||null===t||e.length!==t.length)return!1;for(var i=0;i<e.length;i++)if(!e[i].equals(t[i]))return!1;return!0}if(3===arguments.length){var n=arguments[0],r=arguments[1],o=arguments[2];if(n===r)return!0;if(null===n||null===r||n.length!==r.length)return!1;for(var s=0;s<n.length;s++)if(0!==o.compare(n[s],r[s]))return!1;return!0}}},{key:"intersection",value:function(e,t){for(var i=new He,n=0;n<e.length;n++)t.intersects(e[n])&&i.add(e[n],!0);return i.toCoordinateArray()}},{key:"measures",value:function(e){if(null===e||0===e.length)return 0;var t,i=0,n=s(e);try{for(n.s();!(t=n.n()).done;){var r=t.value;i=Math.max(i,$e.measures(r))}}catch(e){n.e(e)}finally{n.f()}return i}},{key:"hasRepeatedPoints",value:function(e){for(var t=1;t<e.length;t++)if(e[t-1].equals(e[t]))return!0;return!1}},{key:"removeRepeatedPoints",value:function(t){return e.hasRepeatedPoints(t)?new He(t,!1).toCoordinateArray():t}},{key:"reverse",value:function(e){for(var t=e.length-1,i=Math.trunc(t/2),n=0;n<=i;n++){var r=e[n];e[n]=e[t-n],e[t-n]=r}}},{key:"removeNull",value:function(e){for(var t=0,i=0;i<e.length;i++)null!==e[i]&&t++;var n=new Array(t).fill(null);if(0===t)return n;for(var r=0,o=0;o<e.length;o++)null!==e[o]&&(n[r++]=e[o]);return n}},{key:"copyDeep",value:function(){if(1===arguments.length){for(var e=arguments[0],t=new Array(e.length).fill(null),i=0;i<e.length;i++)t[i]=e[i].copy();return t}if(5===arguments.length)for(var n=arguments[0],r=arguments[1],o=arguments[2],s=arguments[3],a=arguments[4],l=0;l<a;l++)o[s+l]=n[r+l].copy()}},{key:"isEqualReversed",value:function(e,t){for(var i=0;i<e.length;i++){var n=e[i],r=t[e.length-i-1];if(0!==n.compareTo(r))return!1}return!0}},{key:"envelope",value:function(e){for(var t=new q,i=0;i<e.length;i++)t.expandToInclude(e[i]);return t}},{key:"toCoordinateArray",value:function(t){return t.toArray(e.coordArrayType)}},{key:"dimension",value:function(e){if(null===e||0===e.length)return 3;var t,i=0,n=s(e);try{for(n.s();!(t=n.n()).done;){var r=t.value;i=Math.max(i,$e.dimension(r))}}catch(e){n.e(e)}finally{n.f()}return i}},{key:"atLeastNCoordinatesOrNothing",value:function(e,t){return t.length>=e?t:[]}},{key:"indexOf",value:function(e,t){for(var i=0;i<t.length;i++)if(e.equals(t[i]))return i;return-1}},{key:"increasingDirection",value:function(e){for(var t=0;t<Math.trunc(e.length/2);t++){var i=e.length-1-t,n=e[t].compareTo(e[i]);if(0!==n)return n}return 1}},{key:"compare",value:function(e,t){for(var i=0;i<e.length&&i<t.length;){var n=e[i].compareTo(t[i]);if(0!==n)return n;i++}return i<t.length?-1:i<e.length?1:0}},{key:"minCoordinate",value:function(e){for(var t=null,i=0;i<e.length;i++)(null===t||t.compareTo(e[i])>0)&&(t=e[i]);return t}},{key:"extract",value:function(e,t,i){t=xe.clamp(t,0,e.length);var n=(i=xe.clamp(i,-1,e.length))-t+1;i<0&&(n=0),t>=e.length&&(n=0),i<t&&(n=0);var r=new Array(n).fill(null);if(0===n)return r;for(var o=0,s=t;s<=i;s++)r[o++]=e[s];return r}}])}(),Xe=o(function e(){i(this,e)},[{key:"compare",value:function(e,t){var i=e,n=t;return We.compare(i,n)}},{key:"interfaces_",get:function(){return[z]}}]),Ye=o(function e(){i(this,e)},[{key:"compare",value:function(e,t){var i=e,n=t;if(i.length<n.length)return-1;if(i.length>n.length)return 1;if(0===i.length)return 0;var r=We.compare(i,n);return We.isEqualReversed(i,n)?0:r}},{key:"OLDcompare",value:function(e,t){var i=e,n=t;if(i.length<n.length)return-1;if(i.length>n.length)return 1;if(0===i.length)return 0;for(var r=We.increasingDirection(i),o=We.increasingDirection(n),s=r>0?0:i.length-1,a=o>0?0:i.length-1,l=0;l<i.length;l++){var c=i[s].compareTo(n[a]);if(0!==c)return c;s+=r,a+=o}return 0}},{key:"interfaces_",get:function(){return[z]}}]);We.ForwardComparator=Xe,We.BidirectionalComparator=Ye,We.coordArrayType=new Array(0).fill(null);var Je=o(function e(t){i(this,e),this.str=t},[{key:"append",value:function(e){this.str+=e}},{key:"setCharAt",value:function(e,t){this.str=this.str.substr(0,e)+t+this.str.substr(e+1)}},{key:"toString",value:function(){return this.str}}]),Ke=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"getM",value:function(e){return this.hasM()?this._coordinates[e].getM():R.NaN}},{key:"setOrdinate",value:function(e,t,i){switch(t){case ue.X:this._coordinates[e].x=i;break;case ue.Y:this._coordinates[e].y=i;break;default:this._coordinates[e].setOrdinate(t,i)}}},{key:"getZ",value:function(e){return this.hasZ()?this._coordinates[e].getZ():R.NaN}},{key:"size",value:function(){return this._coordinates.length}},{key:"getOrdinate",value:function(e,t){switch(t){case ue.X:return this._coordinates[e].x;case ue.Y:return this._coordinates[e].y;default:return this._coordinates[e].getOrdinate(t)}}},{key:"getCoordinate",value:function(){if(1===arguments.length){var e=arguments[0];return this._coordinates[e]}if(2===arguments.length){var t=arguments[0];arguments[1].setCoordinate(this._coordinates[t])}}},{key:"getCoordinateCopy",value:function(e){var t=this.createCoordinate();return t.setCoordinate(this._coordinates[e]),t}},{key:"createCoordinate",value:function(){return $e.create(this.getDimension(),this.getMeasures())}},{key:"getDimension",value:function(){return this._dimension}},{key:"getX",value:function(e){return this._coordinates[e].x}},{key:"getMeasures",value:function(){return this._measures}},{key:"expandEnvelope",value:function(e){for(var t=0;t<this._coordinates.length;t++)e.expandToInclude(this._coordinates[t]);return e}},{key:"copy",value:function(){for(var t=new Array(this.size()).fill(null),i=0;i<this._coordinates.length;i++){var n=this.createCoordinate();n.setCoordinate(this._coordinates[i]),t[i]=n}return new e(t,this._dimension,this._measures)}},{key:"toString",value:function(){if(this._coordinates.length>0){var e=new Je(17*this._coordinates.length);e.append("("),e.append(this._coordinates[0]);for(var t=1;t<this._coordinates.length;t++)e.append(", "),e.append(this._coordinates[t]);return e.append(")"),e.toString()}return"()"}},{key:"getY",value:function(e){return this._coordinates[e].y}},{key:"toCoordinateArray",value:function(){return this._coordinates}},{key:"interfaces_",get:function(){return[ue,E]}}],[{key:"constructor_",value:function(){if(this._dimension=3,this._measures=0,this._coordinates=null,1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];e.constructor_.call(this,t,We.dimension(t),We.measures(t))}else if(Number.isInteger(arguments[0])){var i=arguments[0];this._coordinates=new Array(i).fill(null);for(var n=0;n<i;n++)this._coordinates[n]=new V}else if(re(arguments[0],ue)){var r=arguments[0];if(null===r)return this._coordinates=new Array(0).fill(null),null;this._dimension=r.getDimension(),this._measures=r.getMeasures(),this._coordinates=new Array(r.size()).fill(null);for(var o=0;o<this._coordinates.length;o++)this._coordinates[o]=r.getCoordinateCopy(o)}}else if(2===arguments.length){if(arguments[0]instanceof Array&&Number.isInteger(arguments[1])){var s=arguments[0],a=arguments[1];e.constructor_.call(this,s,a,We.measures(s))}else if(Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var l=arguments[0],c=arguments[1];this._coordinates=new Array(l).fill(null),this._dimension=c;for(var u=0;u<l;u++)this._coordinates[u]=$e.create(c)}}else if(3===arguments.length)if(Number.isInteger(arguments[2])&&arguments[0]instanceof Array&&Number.isInteger(arguments[1])){var h=arguments[0],d=arguments[1],p=arguments[2];this._dimension=d,this._measures=p,this._coordinates=null===h?new Array(0).fill(null):h}else if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var f=arguments[0],m=arguments[1],g=arguments[2];this._coordinates=new Array(f).fill(null),this._dimension=m,this._measures=g;for(var y=0;y<f;y++)this._coordinates[y]=this.createCoordinate()}}}])}(),Qe=function(){function e(){i(this,e)}return o(e,[{key:"readResolve",value:function(){return e.instance()}},{key:"create",value:function(){if(1===arguments.length){if(arguments[0]instanceof Array)return new Ke(arguments[0]);if(re(arguments[0],ue))return new Ke(arguments[0])}else{if(2===arguments.length){var e=arguments[1];return e>3&&(e=3),e<2&&(e=2),new Ke(arguments[0],e)}if(3===arguments.length){var t=arguments[2],i=arguments[1]-t;return t>1&&(t=1),i>3&&(i=3),i<2&&(i=2),new Ke(arguments[0],i+t,t)}}}},{key:"interfaces_",get:function(){return[we,E]}}],[{key:"instance",value:function(){return e.instanceObject}}])}();Qe.instanceObject=new Qe;var et=function(e){function n(){var e;return i(this,n),e=t(this,n),n.constructor_.apply(e,arguments),e}return c(n,e),o(n,[{key:"copyInternal",value:function(){for(var e=new Array(this._geometries.length).fill(null),t=0;t<e.length;t++)e[t]=this._geometries[t].copy();return new n(e,this._factory)}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof Z){var e=arguments[0],t=arguments[1];return!!this.isEquivalentClass(e)&&d(n,"equalsExact",this,1).call(this,e,t)}return d(n,"equalsExact",this,1).apply(this,arguments)}},{key:"getBoundaryDimension",value:function(){return 1}},{key:"getTypeCode",value:function(){return Z.TYPECODE_MULTIPOLYGON}},{key:"getDimension",value:function(){return 2}},{key:"getBoundary",value:function(){if(this.isEmpty())return this.getFactory().createMultiLineString();for(var e=new me,t=0;t<this._geometries.length;t++)for(var i=this._geometries[t].getBoundary(),n=0;n<i.getNumGeometries();n++)e.add(i.getGeometryN(n));var r=new Array(e.size()).fill(null);return this.getFactory().createMultiLineString(e.toArray(r))}},{key:"getGeometryType",value:function(){return Z.TYPENAME_MULTIPOLYGON}},{key:"interfaces_",get:function(){return[ze]}}],[{key:"constructor_",value:function(){var e=arguments[0],t=arguments[1];Ge.constructor_.call(this,e,t)}}])}(Ge),tt=o(function e(){i(this,e)},[{key:"get",value:function(){}},{key:"put",value:function(){}},{key:"size",value:function(){}},{key:"values",value:function(){}},{key:"entrySet",value:function(){}}]),it=function(e){function n(){var e;return i(this,n),(e=t(this,n)).map=new Map,e}return c(n,e),o(n,[{key:"get",value:function(e){return this.map.get(e)||null}},{key:"put",value:function(e,t){return this.map.set(e,t),t}},{key:"values",value:function(){for(var e=new me,t=this.map.values(),i=t.next();!i.done;)e.add(i.value),i=t.next();return e}},{key:"entrySet",value:function(){var e=new J;return this.map.entries().forEach(function(t){return e.add(t)}),e}},{key:"size",value:function(){return this.map.size()}}])}(tt),nt=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"equals",value:function(t){if(!(t instanceof e))return!1;var i=t;return this._modelType===i._modelType&&this._scale===i._scale}},{key:"compareTo",value:function(e){var t=e,i=this.getMaximumSignificantDigits(),n=t.getMaximumSignificantDigits();return se.compare(i,n)}},{key:"getScale",value:function(){return this._scale}},{key:"isFloating",value:function(){return this._modelType===e.FLOATING||this._modelType===e.FLOATING_SINGLE}},{key:"getType",value:function(){return this._modelType}},{key:"toString",value:function(){var t="UNKNOWN";return this._modelType===e.FLOATING?t="Floating":this._modelType===e.FLOATING_SINGLE?t="Floating-Single":this._modelType===e.FIXED&&(t="Fixed (Scale="+this.getScale()+")"),t}},{key:"makePrecise",value:function(){if("number"==typeof arguments[0]){var t=arguments[0];return R.isNaN(t)||this._modelType===e.FLOATING_SINGLE?t:this._modelType===e.FIXED?Math.round(t*this._scale)/this._scale:t}if(arguments[0]instanceof V){var i=arguments[0];if(this._modelType===e.FLOATING)return null;i.x=this.makePrecise(i.x),i.y=this.makePrecise(i.y)}}},{key:"getMaximumSignificantDigits",value:function(){var t=16;return this._modelType===e.FLOATING?t=16:this._modelType===e.FLOATING_SINGLE?t=6:this._modelType===e.FIXED&&(t=1+Math.trunc(Math.ceil(Math.log(this.getScale())/Math.log(10)))),t}},{key:"setScale",value:function(e){this._scale=Math.abs(e)}},{key:"interfaces_",get:function(){return[E,b]}}],[{key:"constructor_",value:function(){if(this._modelType=null,this._scale=null,0===arguments.length)this._modelType=e.FLOATING;else if(1===arguments.length)if(arguments[0]instanceof rt){var t=arguments[0];this._modelType=t,t===e.FIXED&&this.setScale(1)}else if("number"==typeof arguments[0]){var i=arguments[0];this._modelType=e.FIXED,this.setScale(i)}else if(arguments[0]instanceof e){var n=arguments[0];this._modelType=n._modelType,this._scale=n._scale}}},{key:"mostPrecise",value:function(e,t){return e.compareTo(t)>=0?e:t}}])}(),rt=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"readResolve",value:function(){return e.nameToTypeMap.get(this._name)}},{key:"toString",value:function(){return this._name}},{key:"interfaces_",get:function(){return[E]}}],[{key:"constructor_",value:function(){this._name=null;var t=arguments[0];this._name=t,e.nameToTypeMap.put(t,this)}}])}();rt.nameToTypeMap=new it,nt.Type=rt,nt.FIXED=new rt("FIXED"),nt.FLOATING=new rt("FLOATING"),nt.FLOATING_SINGLE=new rt("FLOATING SINGLE"),nt.maximumPreciseValue=9007199254740992;var ot=function(e){function n(){var e;return i(this,n),e=t(this,n),n.constructor_.apply(e,arguments),e}return c(n,e),o(n,[{key:"copyInternal",value:function(){for(var e=new Array(this._geometries.length).fill(null),t=0;t<e.length;t++)e[t]=this._geometries[t].copy();return new n(e,this._factory)}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof Z){var e=arguments[0],t=arguments[1];return!!this.isEquivalentClass(e)&&d(n,"equalsExact",this,1).call(this,e,t)}return d(n,"equalsExact",this,1).apply(this,arguments)}},{key:"getBoundaryDimension",value:function(){return this.isClosed()?ke.FALSE:0}},{key:"isClosed",value:function(){if(this.isEmpty())return!1;for(var e=0;e<this._geometries.length;e++)if(!this._geometries[e].isClosed())return!1;return!0}},{key:"getTypeCode",value:function(){return Z.TYPECODE_MULTILINESTRING}},{key:"getDimension",value:function(){return 1}},{key:"getBoundary",value:function(){throw new X}},{key:"getGeometryType",value:function(){return Z.TYPENAME_MULTILINESTRING}},{key:"interfaces_",get:function(){return[Se]}}],[{key:"constructor_",value:function(){var e=arguments[0],t=arguments[1];Ge.constructor_.call(this,e,t)}}])}(Ge),st=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"createEmpty",value:function(e){switch(e){case-1:return this.createGeometryCollection();case 0:return this.createPoint();case 1:return this.createLineString();case 2:return this.createPolygon();default:throw new v("Invalid dimension: "+e)}}},{key:"toGeometry",value:function(e){return e.isNull()?this.createPoint():e.getMinX()===e.getMaxX()&&e.getMinY()===e.getMaxY()?this.createPoint(new V(e.getMinX(),e.getMinY())):e.getMinX()===e.getMaxX()||e.getMinY()===e.getMaxY()?this.createLineString([new V(e.getMinX(),e.getMinY()),new V(e.getMaxX(),e.getMaxY())]):this.createPolygon(this.createLinearRing([new V(e.getMinX(),e.getMinY()),new V(e.getMinX(),e.getMaxY()),new V(e.getMaxX(),e.getMaxY()),new V(e.getMaxX(),e.getMinY()),new V(e.getMinX(),e.getMinY())]),null)}},{key:"createLineString",value:function(){if(0===arguments.length)return this.createLineString(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Array){var e=arguments[0];return this.createLineString(null!==e?this.getCoordinateSequenceFactory().create(e):null)}if(re(arguments[0],ue))return new Pe(arguments[0],this)}}},{key:"createMultiLineString",value:function(){return 0===arguments.length?new ot(null,this):1===arguments.length?new ot(arguments[0],this):void 0}},{key:"buildGeometry",value:function(t){for(var i=null,n=!1,r=!1,o=t.iterator();o.hasNext();){var s=o.next(),a=s.getTypeCode();null===i&&(i=a),a!==i&&(n=!0),s instanceof Ge&&(r=!0)}if(null===i)return this.createGeometryCollection();if(n||r)return this.createGeometryCollection(e.toGeometryArray(t));var l=t.iterator().next();if(t.size()>1){if(l instanceof Fe)return this.createMultiPolygon(e.toPolygonArray(t));if(l instanceof Pe)return this.createMultiLineString(e.toLineStringArray(t));if(l instanceof Le)return this.createMultiPoint(e.toPointArray(t));N.shouldNeverReachHere("Unhandled geometry type: "+l.getGeometryType())}return l}},{key:"createMultiPointFromCoords",value:function(e){return this.createMultiPoint(null!==e?this.getCoordinateSequenceFactory().create(e):null)}},{key:"createPoint",value:function(){if(0===arguments.length)return this.createPoint(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof V){var e=arguments[0];return this.createPoint(null!==e?this.getCoordinateSequenceFactory().create([e]):null)}if(re(arguments[0],ue))return new Le(arguments[0],this)}}},{key:"getCoordinateSequenceFactory",value:function(){return this._coordinateSequenceFactory}},{key:"createPolygon",value:function(){if(0===arguments.length)return this.createPolygon(null,null);if(1===arguments.length){if(re(arguments[0],ue)){var e=arguments[0];return this.createPolygon(this.createLinearRing(e))}if(arguments[0]instanceof Array){var t=arguments[0];return this.createPolygon(this.createLinearRing(t))}if(arguments[0]instanceof Ve){var i=arguments[0];return this.createPolygon(i,null)}}else if(2===arguments.length)return new Fe(arguments[0],arguments[1],this)}},{key:"getSRID",value:function(){return this._SRID}},{key:"createGeometryCollection",value:function(){return 0===arguments.length?new Ge(null,this):1===arguments.length?new Ge(arguments[0],this):void 0}},{key:"getPrecisionModel",value:function(){return this._precisionModel}},{key:"createLinearRing",value:function(){if(0===arguments.length)return this.createLinearRing(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Array){var e=arguments[0];return this.createLinearRing(null!==e?this.getCoordinateSequenceFactory().create(e):null)}if(re(arguments[0],ue))return new Ve(arguments[0],this)}}},{key:"createMultiPolygon",value:function(){return 0===arguments.length?new et(null,this):1===arguments.length?new et(arguments[0],this):void 0}},{key:"createMultiPoint",value:function(){if(0===arguments.length)return new je(null,this);if(1===arguments.length){if(arguments[0]instanceof Array)return new je(arguments[0],this);if(re(arguments[0],ue)){var e=arguments[0];if(null===e)return this.createMultiPoint(new Array(0).fill(null));for(var t=new Array(e.size()).fill(null),i=0;i<e.size();i++){var n=this.getCoordinateSequenceFactory().create(1,e.getDimension(),e.getMeasures());Ie.copy(e,i,n,0,1),t[i]=this.createPoint(n)}return this.createMultiPoint(t)}}}},{key:"interfaces_",get:function(){return[E]}}],[{key:"constructor_",value:function(){if(this._precisionModel=null,this._coordinateSequenceFactory=null,this._SRID=null,0===arguments.length)e.constructor_.call(this,new nt,0);else if(1===arguments.length){if(re(arguments[0],we)){var t=arguments[0];e.constructor_.call(this,new nt,0,t)}else if(arguments[0]instanceof nt){var i=arguments[0];e.constructor_.call(this,i,0,e.getDefaultCoordinateSequenceFactory())}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];e.constructor_.call(this,n,r,e.getDefaultCoordinateSequenceFactory())}else if(3===arguments.length){var o=arguments[0],s=arguments[1],a=arguments[2];this._precisionModel=o,this._coordinateSequenceFactory=a,this._SRID=s}}},{key:"toMultiPolygonArray",value:function(e){var t=new Array(e.size()).fill(null);return e.toArray(t)}},{key:"toGeometryArray",value:function(e){if(null===e)return null;var t=new Array(e.size()).fill(null);return e.toArray(t)}},{key:"getDefaultCoordinateSequenceFactory",value:function(){return Qe.instance()}},{key:"toMultiLineStringArray",value:function(e){var t=new Array(e.size()).fill(null);return e.toArray(t)}},{key:"toLineStringArray",value:function(e){var t=new Array(e.size()).fill(null);return e.toArray(t)}},{key:"toMultiPointArray",value:function(e){var t=new Array(e.size()).fill(null);return e.toArray(t)}},{key:"toLinearRingArray",value:function(e){var t=new Array(e.size()).fill(null);return e.toArray(t)}},{key:"toPointArray",value:function(e){var t=new Array(e.size()).fill(null);return e.toArray(t)}},{key:"toPolygonArray",value:function(e){var t=new Array(e.size()).fill(null);return e.toArray(t)}},{key:"createPointFromInternalCoord",value:function(e,t){return t.getPrecisionModel().makePrecise(e),t.getFactory().createPoint(e)}}])}(),at="XY",lt="XYZ",ct="XYM",ut="XYZM",ht={POINT:"Point",LINE_STRING:"LineString",LINEAR_RING:"LinearRing",POLYGON:"Polygon",MULTI_POINT:"MultiPoint",MULTI_LINE_STRING:"MultiLineString",MULTI_POLYGON:"MultiPolygon",GEOMETRY_COLLECTION:"GeometryCollection",CIRCLE:"Circle"},dt="EMPTY",pt=1,ft=2,mt=3,gt=4,yt=5,_t=6;for(var vt in ht)ht[vt].toUpperCase();var xt=o(function e(t){i(this,e),this.wkt=t,this.index_=-1},[{key:"isAlpha_",value:function(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}},{key:"isNumeric_",value:function(e,t){return e>="0"&&e<="9"||"."==e&&!(void 0!==t&&t)}},{key:"isWhiteSpace_",value:function(e){return" "==e||"\t"==e||"\r"==e||"\n"==e}},{key:"nextChar_",value:function(){return this.wkt.charAt(++this.index_)}},{key:"nextToken",value:function(){var e,t=this.nextChar_(),i=this.index_,n=t;if("("==t)e=ft;else if(","==t)e=yt;else if(")"==t)e=mt;else if(this.isNumeric_(t)||"-"==t)e=gt,n=this.readNumber_();else if(this.isAlpha_(t))e=pt,n=this.readText_();else{if(this.isWhiteSpace_(t))return this.nextToken();if(""!==t)throw new Error("Unexpected character: "+t);e=_t}return{position:i,value:n,type:e}}},{key:"readNumber_",value:function(){var e,t=this.index_,i=!1,n=!1;do{"."==e?i=!0:"e"!=e&&"E"!=e||(n=!0),e=this.nextChar_()}while(this.isNumeric_(e,i)||!n&&("e"==e||"E"==e)||n&&("-"==e||"+"==e));return parseFloat(this.wkt.substring(t,this.index_--))}},{key:"readText_",value:function(){var e,t=this.index_;do{e=this.nextChar_()}while(this.isAlpha_(e));return this.wkt.substring(t,this.index_--).toUpperCase()}}]),bt=o(function e(t,n){i(this,e),this.lexer_=t,this.layout_=at,this.factory=n},[{key:"consume_",value:function(){this.token_=this.lexer_.nextToken()}},{key:"isTokenType",value:function(e){return this.token_.type==e}},{key:"match",value:function(e){var t=this.isTokenType(e);return t&&this.consume_(),t}},{key:"parse",value:function(){return this.consume_(),this.parseGeometry_()}},{key:"parseGeometryLayout_",value:function(){var e=at,t=this.token_;if(this.isTokenType(pt)){var i=t.value;"Z"===i?e=lt:"M"===i?e=ct:"ZM"===i&&(e=ut),e!==at&&this.consume_()}return e}},{key:"parseGeometryCollectionText_",value:function(){if(this.match(ft)){var e=[];do{e.push(this.parseGeometry_())}while(this.match(yt));if(this.match(mt))return e}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePointText_",value:function(){if(this.match(ft)){var e=this.parsePoint_();if(this.match(mt))return e}else if(this.isEmptyGeometry_())return null;throw new Error(this.formatErrorMessage_())}},{key:"parseLineStringText_",value:function(){if(this.match(ft)){var e=this.parsePointList_();if(this.match(mt))return e}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePolygonText_",value:function(){if(this.match(ft)){var e=this.parseLineStringTextList_();if(this.match(mt))return e}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiPointText_",value:function(){var e;if(this.match(ft)){if(e=this.token_.type==ft?this.parsePointTextList_():this.parsePointList_(),this.match(mt))return e}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiLineStringText_",value:function(){if(this.match(ft)){var e=this.parseLineStringTextList_();if(this.match(mt))return e}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiPolygonText_",value:function(){if(this.match(ft)){var e=this.parsePolygonTextList_();if(this.match(mt))return e}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePoint_",value:function(){for(var e=[],t=this.layout_.length,i=0;i<t;++i){var n=this.token_;if(!this.match(gt))break;e.push(n.value)}if(e.length==t)return e;throw new Error(this.formatErrorMessage_())}},{key:"parsePointList_",value:function(){for(var e=[this.parsePoint_()];this.match(yt);)e.push(this.parsePoint_());return e}},{key:"parsePointTextList_",value:function(){for(var e=[this.parsePointText_()];this.match(yt);)e.push(this.parsePointText_());return e}},{key:"parseLineStringTextList_",value:function(){for(var e=[this.parseLineStringText_()];this.match(yt);)e.push(this.parseLineStringText_());return e}},{key:"parsePolygonTextList_",value:function(){for(var e=[this.parsePolygonText_()];this.match(yt);)e.push(this.parsePolygonText_());return e}},{key:"isEmptyGeometry_",value:function(){var e=this.isTokenType(pt)&&this.token_.value==dt;return e&&this.consume_(),e}},{key:"formatErrorMessage_",value:function(){return"Unexpected `"+this.token_.value+"` at position "+this.token_.position+" in `"+this.lexer_.wkt+"`"}},{key:"parseGeometry_",value:function(){var e=this.factory,t=function(e){return n(V,p(e))},i=function(i){var n=i.map(function(i){return e.createLinearRing(i.map(t))});return n.length>1?e.createPolygon(n[0],n.slice(1)):e.createPolygon(n[0])},r=this.token_;if(this.match(pt)){var o=r.value;if(this.layout_=this.parseGeometryLayout_(),"GEOMETRYCOLLECTION"==o){var s=this.parseGeometryCollectionText_();return e.createGeometryCollection(s)}switch(o){case"POINT":var a=this.parsePointText_();return a?e.createPoint(n(V,p(a))):e.createPoint();case"LINESTRING":var l=this.parseLineStringText_().map(t);return e.createLineString(l);case"LINEARRING":var c=this.parseLineStringText_().map(t);return e.createLinearRing(c);case"POLYGON":var u=this.parsePolygonText_();return u&&0!==u.length?i(u):e.createPolygon();case"MULTIPOINT":var h=this.parseMultiPointText_();if(!h||0===h.length)return e.createMultiPoint();var d=h.map(t).map(function(t){return e.createPoint(t)});return e.createMultiPoint(d);case"MULTILINESTRING":var f=this.parseMultiLineStringText_().map(function(i){return e.createLineString(i.map(t))});return e.createMultiLineString(f);case"MULTIPOLYGON":var m=this.parseMultiPolygonText_();if(!m||0===m.length)return e.createMultiPolygon();var g=m.map(i);return e.createMultiPolygon(g);default:throw new Error("Invalid geometry type: "+o)}}throw new Error(this.formatErrorMessage_())}}]);function wt(e){if(e.isEmpty())return"";var t=e.getCoordinate(),i=[t.x,t.y];return void 0===t.z||Number.isNaN(t.z)||i.push(t.z),void 0===t.m||Number.isNaN(t.m)||i.push(t.m),i.join(" ")}function Et(e){for(var t=e.getCoordinates().map(function(e){var t=[e.x,e.y];return void 0===e.z||Number.isNaN(e.z)||t.push(e.z),void 0===e.m||Number.isNaN(e.m)||t.push(e.m),t}),i=[],n=0,r=t.length;n<r;++n)i.push(t[n].join(" "));return i.join(", ")}function Tt(e){var t=[];t.push("("+Et(e.getExteriorRing())+")");for(var i=0,n=e.getNumInteriorRing();i<n;++i)t.push("("+Et(e.getInteriorRingN(i))+")");return t.join(", ")}var St={Point:wt,LineString:Et,LinearRing:Et,Polygon:Tt,MultiPoint:function(e){for(var t=[],i=0,n=e.getNumGeometries();i<n;++i)t.push("("+wt(e.getGeometryN(i))+")");return t.join(", ")},MultiLineString:function(e){for(var t=[],i=0,n=e.getNumGeometries();i<n;++i)t.push("("+Et(e.getGeometryN(i))+")");return t.join(", ")},MultiPolygon:function(e){for(var t=[],i=0,n=e.getNumGeometries();i<n;++i)t.push("("+Tt(e.getGeometryN(i))+")");return t.join(", ")},GeometryCollection:function(e){for(var t=[],i=0,n=e.getNumGeometries();i<n;++i)t.push(It(e.getGeometryN(i)));return t.join(", ")}};function It(e){var t=e.getGeometryType(),i=St[t];t=t.toUpperCase();var n=function(e){var t="";if(e.isEmpty())return t;var i=e.getCoordinate();return void 0===i.z||Number.isNaN(i.z)||(t+="Z"),void 0===i.m||Number.isNaN(i.m)||(t+="M"),t}(e);return n.length>0&&(t+=" "+n),e.isEmpty()?t+" "+dt:t+" ("+i(e)+")"}var kt=o(function e(t){i(this,e),this.geometryFactory=t||new st,this.precisionModel=this.geometryFactory.getPrecisionModel()},[{key:"read",value:function(e){var t=new xt(e);return new bt(t,this.geometryFactory).parse()}},{key:"write",value:function(e){return It(e)}}]),Mt=o(function e(t){i(this,e),this.parser=new kt(t)},[{key:"write",value:function(e){return this.parser.write(e)}}],[{key:"toLineString",value:function(e,t){if(2!==arguments.length)throw new Error("Not implemented");return"LINESTRING ( "+e.x+" "+e.y+", "+t.x+" "+t.y+" )"}}]),Ct=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"getIndexAlongSegment",value:function(e,t){return this.computeIntLineIndex(),this._intLineIndex[e][t]}},{key:"getTopologySummary",value:function(){var e=new Je;return this.isEndPoint()&&e.append(" endpoint"),this._isProper&&e.append(" proper"),this.isCollinear()&&e.append(" collinear"),e.toString()}},{key:"computeIntersection",value:function(e,t,i,n){this._inputLines[0][0]=e,this._inputLines[0][1]=t,this._inputLines[1][0]=i,this._inputLines[1][1]=n,this._result=this.computeIntersect(e,t,i,n)}},{key:"getIntersectionNum",value:function(){return this._result}},{key:"computeIntLineIndex",value:function(){if(0===arguments.length)null===this._intLineIndex&&(this._intLineIndex=Array(2).fill().map(function(){return Array(2)}),this.computeIntLineIndex(0),this.computeIntLineIndex(1));else if(1===arguments.length){var e=arguments[0];this.getEdgeDistance(e,0)>this.getEdgeDistance(e,1)?(this._intLineIndex[e][0]=0,this._intLineIndex[e][1]=1):(this._intLineIndex[e][0]=1,this._intLineIndex[e][1]=0)}}},{key:"isProper",value:function(){return this.hasIntersection()&&this._isProper}},{key:"setPrecisionModel",value:function(e){this._precisionModel=e}},{key:"isInteriorIntersection",value:function(){if(0===arguments.length)return!!this.isInteriorIntersection(0)||!!this.isInteriorIntersection(1);if(1===arguments.length){for(var e=arguments[0],t=0;t<this._result;t++)if(!this._intPt[t].equals2D(this._inputLines[e][0])&&!this._intPt[t].equals2D(this._inputLines[e][1]))return!0;return!1}}},{key:"getIntersection",value:function(e){return this._intPt[e]}},{key:"isEndPoint",value:function(){return this.hasIntersection()&&!this._isProper}},{key:"hasIntersection",value:function(){return this._result!==e.NO_INTERSECTION}},{key:"getEdgeDistance",value:function(t,i){return e.computeEdgeDistance(this._intPt[i],this._inputLines[t][0],this._inputLines[t][1])}},{key:"isCollinear",value:function(){return this._result===e.COLLINEAR_INTERSECTION}},{key:"toString",value:function(){return Mt.toLineString(this._inputLines[0][0],this._inputLines[0][1])+" - "+Mt.toLineString(this._inputLines[1][0],this._inputLines[1][1])+this.getTopologySummary()}},{key:"getEndpoint",value:function(e,t){return this._inputLines[e][t]}},{key:"isIntersection",value:function(e){for(var t=0;t<this._result;t++)if(this._intPt[t].equals2D(e))return!0;return!1}},{key:"getIntersectionAlongSegment",value:function(e,t){return this.computeIntLineIndex(),this._intPt[this._intLineIndex[e][t]]}}],[{key:"constructor_",value:function(){this._result=null,this._inputLines=Array(2).fill().map(function(){return Array(2)}),this._intPt=new Array(2).fill(null),this._intLineIndex=null,this._isProper=null,this._pa=null,this._pb=null,this._precisionModel=null,this._intPt[0]=new V,this._intPt[1]=new V,this._pa=this._intPt[0],this._pb=this._intPt[1],this._result=0}},{key:"computeEdgeDistance",value:function(e,t,i){var n=Math.abs(i.x-t.x),r=Math.abs(i.y-t.y),o=-1;if(e.equals(t))o=0;else if(e.equals(i))o=n>r?n:r;else{var s=Math.abs(e.x-t.x),a=Math.abs(e.y-t.y);0!==(o=n>r?s:a)||e.equals(t)||(o=Math.max(s,a))}return N.isTrue(!(0===o&&!e.equals(t)),"Bad distance calculation"),o}},{key:"nonRobustComputeEdgeDistance",value:function(e,t,i){var n=e.x-t.x,r=e.y-t.y,o=Math.sqrt(n*n+r*r);return N.isTrue(!(0===o&&!e.equals(t)),"Invalid distance calculation"),o}}])}();Ct.DONT_INTERSECT=0,Ct.DO_INTERSECT=1,Ct.COLLINEAR=2,Ct.NO_INTERSECTION=0,Ct.POINT_INTERSECTION=1,Ct.COLLINEAR_INTERSECTION=2;var Pt=function(e){function n(){return i(this,n),t(this,n)}return c(n,e),o(n,[{key:"isInSegmentEnvelopes",value:function(e){var t=new q(this._inputLines[0][0],this._inputLines[0][1]),i=new q(this._inputLines[1][0],this._inputLines[1][1]);return t.contains(e)&&i.contains(e)}},{key:"computeIntersection",value:function(){if(3!==arguments.length)return d(n,"computeIntersection",this,1).apply(this,arguments);var e=arguments[0],t=arguments[1],i=arguments[2];if(this._isProper=!1,q.intersects(t,i,e)&&0===he.index(t,i,e)&&0===he.index(i,t,e))return this._isProper=!0,(e.equals(t)||e.equals(i))&&(this._isProper=!1),this._result=Ct.POINT_INTERSECTION,null;this._result=Ct.NO_INTERSECTION}},{key:"intersection",value:function(e,t,i,r){var o=this.intersectionSafe(e,t,i,r);return this.isInSegmentEnvelopes(o)||(o=new V(n.nearestEndpoint(e,t,i,r))),null!==this._precisionModel&&this._precisionModel.makePrecise(o),o}},{key:"checkDD",value:function(e,t,i,n,r){var o=ce.intersection(e,t,i,n),s=this.isInSegmentEnvelopes(o);ve.out.println("DD in env = "+s+" --------------------- "+o),r.distance(o)>1e-4&&ve.out.println("Distance = "+r.distance(o))}},{key:"intersectionSafe",value:function(e,t,i,r){var o=_e.intersection(e,t,i,r);return null===o&&(o=n.nearestEndpoint(e,t,i,r)),o}},{key:"computeCollinearIntersection",value:function(e,t,i,n){var r=q.intersects(e,t,i),o=q.intersects(e,t,n),s=q.intersects(i,n,e),a=q.intersects(i,n,t);return r&&o?(this._intPt[0]=i,this._intPt[1]=n,Ct.COLLINEAR_INTERSECTION):s&&a?(this._intPt[0]=e,this._intPt[1]=t,Ct.COLLINEAR_INTERSECTION):r&&s?(this._intPt[0]=i,this._intPt[1]=e,!i.equals(e)||o||a?Ct.COLLINEAR_INTERSECTION:Ct.POINT_INTERSECTION):r&&a?(this._intPt[0]=i,this._intPt[1]=t,!i.equals(t)||o||s?Ct.COLLINEAR_INTERSECTION:Ct.POINT_INTERSECTION):o&&s?(this._intPt[0]=n,this._intPt[1]=e,!n.equals(e)||r||a?Ct.COLLINEAR_INTERSECTION:Ct.POINT_INTERSECTION):o&&a?(this._intPt[0]=n,this._intPt[1]=t,!n.equals(t)||r||s?Ct.COLLINEAR_INTERSECTION:Ct.POINT_INTERSECTION):Ct.NO_INTERSECTION}},{key:"computeIntersect",value:function(e,t,i,n){if(this._isProper=!1,!q.intersects(e,t,i,n))return Ct.NO_INTERSECTION;var r=he.index(e,t,i),o=he.index(e,t,n);if(r>0&&o>0||r<0&&o<0)return Ct.NO_INTERSECTION;var s=he.index(i,n,e),a=he.index(i,n,t);return s>0&&a>0||s<0&&a<0?Ct.NO_INTERSECTION:0===r&&0===o&&0===s&&0===a?this.computeCollinearIntersection(e,t,i,n):(0===r||0===o||0===s||0===a?(this._isProper=!1,e.equals2D(i)||e.equals2D(n)?this._intPt[0]=e:t.equals2D(i)||t.equals2D(n)?this._intPt[0]=t:0===r?this._intPt[0]=new V(i):0===o?this._intPt[0]=new V(n):0===s?this._intPt[0]=new V(e):0===a&&(this._intPt[0]=new V(t))):(this._isProper=!0,this._intPt[0]=this.intersection(e,t,i,n)),Ct.POINT_INTERSECTION)}}],[{key:"nearestEndpoint",value:function(e,t,i,n){var r=e,o=be.pointToSegment(e,i,n),s=be.pointToSegment(t,i,n);return s<o&&(o=s,r=t),(s=be.pointToSegment(i,e,t))<o&&(o=s,r=i),(s=be.pointToSegment(n,e,t))<o&&(o=s,r=n),r}}])}(Ct),At=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"countSegment",value:function(e,t){if(e.x<this._p.x&&t.x<this._p.x)return null;if(this._p.x===t.x&&this._p.y===t.y)return this._isPointOnSegment=!0,null;if(e.y===this._p.y&&t.y===this._p.y){var i=e.x,n=t.x;return i>n&&(i=t.x,n=e.x),this._p.x>=i&&this._p.x<=n&&(this._isPointOnSegment=!0),null}if(e.y>this._p.y&&t.y<=this._p.y||t.y>this._p.y&&e.y<=this._p.y){var r=he.index(e,t,this._p);if(r===he.COLLINEAR)return this._isPointOnSegment=!0,null;t.y<e.y&&(r=-r),r===he.LEFT&&this._crossingCount++}}},{key:"isPointInPolygon",value:function(){return this.getLocation()!==$.EXTERIOR}},{key:"getLocation",value:function(){return this._isPointOnSegment?$.BOUNDARY:this._crossingCount%2==1?$.INTERIOR:$.EXTERIOR}},{key:"isOnSegment",value:function(){return this._isPointOnSegment}}],[{key:"constructor_",value:function(){this._p=null,this._crossingCount=0,this._isPointOnSegment=!1;var e=arguments[0];this._p=e}},{key:"locatePointInRing",value:function(){if(arguments[0]instanceof V&&re(arguments[1],ue)){for(var t=arguments[1],i=new e(arguments[0]),n=new V,r=new V,o=1;o<t.size();o++)if(t.getCoordinate(o,n),t.getCoordinate(o-1,r),i.countSegment(n,r),i.isOnSegment())return i.getLocation();return i.getLocation()}if(arguments[0]instanceof V&&arguments[1]instanceof Array){for(var s=arguments[1],a=new e(arguments[0]),l=1;l<s.length;l++){var c=s[l],u=s[l-1];if(a.countSegment(c,u),a.isOnSegment())return a.getLocation()}return a.getLocation()}}}])}(),Lt=function(){function e(){i(this,e)}return o(e,null,[{key:"isOnLine",value:function(){if(arguments[0]instanceof V&&re(arguments[1],ue)){for(var e=arguments[0],t=arguments[1],i=new Pt,n=new V,r=new V,o=t.size(),s=1;s<o;s++)if(t.getCoordinate(s-1,n),t.getCoordinate(s,r),i.computeIntersection(e,n,r),i.hasIntersection())return!0;return!1}if(arguments[0]instanceof V&&arguments[1]instanceof Array){for(var a=arguments[0],l=arguments[1],c=new Pt,u=1;u<l.length;u++){var h=l[u-1],d=l[u];if(c.computeIntersection(a,h,d),c.hasIntersection())return!0}return!1}}},{key:"locateInRing",value:function(e,t){return At.locatePointInRing(e,t)}},{key:"isInRing",value:function(t,i){return e.locateInRing(t,i)!==$.EXTERIOR}}])}(),Dt=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"setAllLocations",value:function(e){for(var t=0;t<this.location.length;t++)this.location[t]=e}},{key:"isNull",value:function(){for(var e=0;e<this.location.length;e++)if(this.location[e]!==$.NONE)return!1;return!0}},{key:"setAllLocationsIfNull",value:function(e){for(var t=0;t<this.location.length;t++)this.location[t]===$.NONE&&(this.location[t]=e)}},{key:"isLine",value:function(){return 1===this.location.length}},{key:"merge",value:function(e){if(e.location.length>this.location.length){var t=new Array(3).fill(null);t[Q.ON]=this.location[Q.ON],t[Q.LEFT]=$.NONE,t[Q.RIGHT]=$.NONE,this.location=t}for(var i=0;i<this.location.length;i++)this.location[i]===$.NONE&&i<e.location.length&&(this.location[i]=e.location[i])}},{key:"getLocations",value:function(){return this.location}},{key:"flip",value:function(){if(this.location.length<=1)return null;var e=this.location[Q.LEFT];this.location[Q.LEFT]=this.location[Q.RIGHT],this.location[Q.RIGHT]=e}},{key:"toString",value:function(){var e=new oe;return this.location.length>1&&e.append($.toLocationSymbol(this.location[Q.LEFT])),e.append($.toLocationSymbol(this.location[Q.ON])),this.location.length>1&&e.append($.toLocationSymbol(this.location[Q.RIGHT])),e.toString()}},{key:"setLocations",value:function(e,t,i){this.location[Q.ON]=e,this.location[Q.LEFT]=t,this.location[Q.RIGHT]=i}},{key:"get",value:function(e){return e<this.location.length?this.location[e]:$.NONE}},{key:"isArea",value:function(){return this.location.length>1}},{key:"isAnyNull",value:function(){for(var e=0;e<this.location.length;e++)if(this.location[e]===$.NONE)return!0;return!1}},{key:"setLocation",value:function(){if(1===arguments.length){var e=arguments[0];this.setLocation(Q.ON,e)}else if(2===arguments.length){var t=arguments[0],i=arguments[1];this.location[t]=i}}},{key:"init",value:function(e){this.location=new Array(e).fill(null),this.setAllLocations($.NONE)}},{key:"isEqualOnSide",value:function(e,t){return this.location[t]===e.location[t]}},{key:"allPositionsEqual",value:function(e){for(var t=0;t<this.location.length;t++)if(this.location[t]!==e)return!1;return!0}}],[{key:"constructor_",value:function(){if(this.location=null,1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];this.init(t.length)}else if(Number.isInteger(arguments[0])){var i=arguments[0];this.init(1),this.location[Q.ON]=i}else if(arguments[0]instanceof e){var n=arguments[0];if(this.init(n.location.length),null!==n)for(var r=0;r<this.location.length;r++)this.location[r]=n.location[r]}}else if(3===arguments.length){var o=arguments[0],s=arguments[1],a=arguments[2];this.init(3),this.location[Q.ON]=o,this.location[Q.LEFT]=s,this.location[Q.RIGHT]=a}}}])}(),Rt=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"getGeometryCount",value:function(){var e=0;return this.elt[0].isNull()||e++,this.elt[1].isNull()||e++,e}},{key:"setAllLocations",value:function(e,t){this.elt[e].setAllLocations(t)}},{key:"isNull",value:function(e){return this.elt[e].isNull()}},{key:"setAllLocationsIfNull",value:function(){if(1===arguments.length){var e=arguments[0];this.setAllLocationsIfNull(0,e),this.setAllLocationsIfNull(1,e)}else if(2===arguments.length){var t=arguments[0],i=arguments[1];this.elt[t].setAllLocationsIfNull(i)}}},{key:"isLine",value:function(e){return this.elt[e].isLine()}},{key:"merge",value:function(e){for(var t=0;t<2;t++)null===this.elt[t]&&null!==e.elt[t]?this.elt[t]=new Dt(e.elt[t]):this.elt[t].merge(e.elt[t])}},{key:"flip",value:function(){this.elt[0].flip(),this.elt[1].flip()}},{key:"getLocation",value:function(){if(1===arguments.length){var e=arguments[0];return this.elt[e].get(Q.ON)}if(2===arguments.length){var t=arguments[0],i=arguments[1];return this.elt[t].get(i)}}},{key:"toString",value:function(){var e=new oe;return null!==this.elt[0]&&(e.append("A:"),e.append(this.elt[0].toString())),null!==this.elt[1]&&(e.append(" B:"),e.append(this.elt[1].toString())),e.toString()}},{key:"isArea",value:function(){if(0===arguments.length)return this.elt[0].isArea()||this.elt[1].isArea();if(1===arguments.length){var e=arguments[0];return this.elt[e].isArea()}}},{key:"isAnyNull",value:function(e){return this.elt[e].isAnyNull()}},{key:"setLocation",value:function(){if(2===arguments.length){var e=arguments[0],t=arguments[1];this.elt[e].setLocation(Q.ON,t)}else if(3===arguments.length){var i=arguments[0],n=arguments[1],r=arguments[2];this.elt[i].setLocation(n,r)}}},{key:"isEqualOnSide",value:function(e,t){return this.elt[0].isEqualOnSide(e.elt[0],t)&&this.elt[1].isEqualOnSide(e.elt[1],t)}},{key:"allPositionsEqual",value:function(e,t){return this.elt[e].allPositionsEqual(t)}},{key:"toLine",value:function(e){this.elt[e].isArea()&&(this.elt[e]=new Dt(this.elt[e].location[0]))}}],[{key:"constructor_",value:function(){if(this.elt=new Array(2).fill(null),1===arguments.length){if(Number.isInteger(arguments[0])){var t=arguments[0];this.elt[0]=new Dt(t),this.elt[1]=new Dt(t)}else if(arguments[0]instanceof e){var i=arguments[0];this.elt[0]=new Dt(i.elt[0]),this.elt[1]=new Dt(i.elt[1])}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];this.elt[0]=new Dt($.NONE),this.elt[1]=new Dt($.NONE),this.elt[n].setLocation(r)}else if(3===arguments.length){var o=arguments[0],s=arguments[1],a=arguments[2];this.elt[0]=new Dt(o,s,a),this.elt[1]=new Dt(o,s,a)}else if(4===arguments.length){var l=arguments[0],c=arguments[1],u=arguments[2],h=arguments[3];this.elt[0]=new Dt($.NONE,$.NONE,$.NONE),this.elt[1]=new Dt($.NONE,$.NONE,$.NONE),this.elt[l].setLocations(c,u,h)}}},{key:"toLineLabel",value:function(t){for(var i=new e($.NONE),n=0;n<2;n++)i.setLocation(n,t.getLocation(n));return i}}])}(),zt=o(function e(){i(this,e),e.constructor_.apply(this,arguments)},[{key:"computeRing",value:function(){if(null!==this._ring)return null;for(var e=new Array(this._pts.size()).fill(null),t=0;t<this._pts.size();t++)e[t]=this._pts.get(t);this._ring=this._geometryFactory.createLinearRing(e),this._isHole=he.isCCW(this._ring.getCoordinates())}},{key:"isIsolated",value:function(){return 1===this._label.getGeometryCount()}},{key:"computePoints",value:function(e){this._startDe=e;var t=e,i=!0;do{if(null===t)throw new pe("Found null DirectedEdge");if(t.getEdgeRing()===this)throw new pe("Directed Edge visited twice during ring-building at "+t.getCoordinate());this._edges.add(t);var n=t.getLabel();N.isTrue(n.isArea()),this.mergeLabel(n),this.addPoints(t.getEdge(),t.isForward(),i),i=!1,this.setEdgeRing(t,this),t=this.getNext(t)}while(t!==this._startDe)}},{key:"getLinearRing",value:function(){return this._ring}},{key:"getCoordinate",value:function(e){return this._pts.get(e)}},{key:"computeMaxNodeDegree",value:function(){this._maxNodeDegree=0;var e=this._startDe;do{var t=e.getNode().getEdges().getOutgoingDegree(this);t>this._maxNodeDegree&&(this._maxNodeDegree=t),e=this.getNext(e)}while(e!==this._startDe);this._maxNodeDegree*=2}},{key:"addPoints",value:function(e,t,i){var n=e.getCoordinates();if(t){var r=1;i&&(r=0);for(var o=r;o<n.length;o++)this._pts.add(n[o])}else{var s=n.length-2;i&&(s=n.length-1);for(var a=s;a>=0;a--)this._pts.add(n[a])}}},{key:"isHole",value:function(){return this._isHole}},{key:"setInResult",value:function(){var e=this._startDe;do{e.getEdge().setInResult(!0),e=e.getNext()}while(e!==this._startDe)}},{key:"containsPoint",value:function(e){var t=this.getLinearRing();if(!t.getEnvelopeInternal().contains(e)||!Lt.isInRing(e,t.getCoordinates()))return!1;for(var i=this._holes.iterator();i.hasNext();)if(i.next().containsPoint(e))return!1;return!0}},{key:"addHole",value:function(e){this._holes.add(e)}},{key:"isShell",value:function(){return null===this._shell}},{key:"getLabel",value:function(){return this._label}},{key:"getEdges",value:function(){return this._edges}},{key:"getMaxNodeDegree",value:function(){return this._maxNodeDegree<0&&this.computeMaxNodeDegree(),this._maxNodeDegree}},{key:"getShell",value:function(){return this._shell}},{key:"mergeLabel",value:function(){if(1===arguments.length){var e=arguments[0];this.mergeLabel(e,0),this.mergeLabel(e,1)}else if(2===arguments.length){var t=arguments[1],i=arguments[0].getLocation(t,Q.RIGHT);if(i===$.NONE)return null;if(this._label.getLocation(t)===$.NONE)return this._label.setLocation(t,i),null}}},{key:"setShell",value:function(e){this._shell=e,null!==e&&e.addHole(this)}},{key:"toPolygon",value:function(e){for(var t=new Array(this._holes.size()).fill(null),i=0;i<this._holes.size();i++)t[i]=this._holes.get(i).getLinearRing();return e.createPolygon(this.getLinearRing(),t)}}],[{key:"constructor_",value:function(){if(this._startDe=null,this._maxNodeDegree=-1,this._edges=new me,this._pts=new me,this._label=new Rt($.NONE),this._ring=null,this._isHole=null,this._shell=null,this._holes=new me,this._geometryFactory=null,0!==arguments.length&&2===arguments.length){var e=arguments[0],t=arguments[1];this._geometryFactory=t,this.computePoints(e),this.computeRing()}}}]),Ft=function(e){function n(){var e;return i(this,n),e=t(this,n),n.constructor_.apply(e,arguments),e}return c(n,e),o(n,[{key:"setEdgeRing",value:function(e,t){e.setMinEdgeRing(t)}},{key:"getNext",value:function(e){return e.getNextMin()}}],[{key:"constructor_",value:function(){var e=arguments[0],t=arguments[1];zt.constructor_.call(this,e,t)}}])}(zt),Ot=function(e){function n(){var e;return i(this,n),e=t(this,n),n.constructor_.apply(e,arguments),e}return c(n,e),o(n,[{key:"buildMinimalRings",value:function(){var e=new me,t=this._startDe;do{if(null===t.getMinEdgeRing()){var i=new Ft(t,this._geometryFactory);e.add(i)}t=t.getNext()}while(t!==this._startDe);return e}},{key:"setEdgeRing",value:function(e,t){e.setEdgeRing(t)}},{key:"linkDirectedEdgesForMinimalEdgeRings",value:function(){var e=this._startDe;do{e.getNode().getEdges().linkMinimalDirectedEdges(this),e=e.getNext()}while(e!==this._startDe)}},{key:"getNext",value:function(e){return e.getNext()}}],[{key:"constructor_",value:function(){var e=arguments[0],t=arguments[1];zt.constructor_.call(this,e,t)}}])}(zt),Nt=o(function e(){i(this,e),e.constructor_.apply(this,arguments)},[{key:"setVisited",value:function(e){this._isVisited=e}},{key:"setInResult",value:function(e){this._isInResult=e}},{key:"isCovered",value:function(){return this._isCovered}},{key:"isCoveredSet",value:function(){return this._isCoveredSet}},{key:"setLabel",value:function(e){this._label=e}},{key:"getLabel",value:function(){return this._label}},{key:"setCovered",value:function(e){this._isCovered=e,this._isCoveredSet=!0}},{key:"updateIM",value:function(e){N.isTrue(this._label.getGeometryCount()>=2,"found partial label"),this.computeIM(e)}},{key:"isInResult",value:function(){return this._isInResult}},{key:"isVisited",value:function(){return this._isVisited}}],[{key:"constructor_",value:function(){if(this._label=null,this._isInResult=!1,this._isCovered=!1,this._isCoveredSet=!1,this._isVisited=!1,0!==arguments.length&&1===arguments.length){var e=arguments[0];this._label=e}}}]),Bt=function(e){function n(){var e;return i(this,n),e=t(this,n),n.constructor_.apply(e,arguments),e}return c(n,e),o(n,[{key:"isIncidentEdgeInResult",value:function(){for(var e=this.getEdges().getEdges().iterator();e.hasNext();)if(e.next().getEdge().isInResult())return!0;return!1}},{key:"isIsolated",value:function(){return 1===this._label.getGeometryCount()}},{key:"getCoordinate",value:function(){return this._coord}},{key:"print",value:function(e){e.println("node "+this._coord+" lbl: "+this._label)}},{key:"computeIM",value:function(e){}},{key:"computeMergedLocation",value:function(e,t){var i=$.NONE;if(i=this._label.getLocation(t),!e.isNull(t)){var n=e.getLocation(t);i!==$.BOUNDARY&&(i=n)}return i}},{key:"setLabel",value:function(){if(2!==arguments.length||!Number.isInteger(arguments[1])||!Number.isInteger(arguments[0]))return d(n,"setLabel",this,1).apply(this,arguments);var e=arguments[0],t=arguments[1];null===this._label?this._label=new Rt(e,t):this._label.setLocation(e,t)}},{key:"getEdges",value:function(){return this._edges}},{key:"mergeLabel",value:function(){if(arguments[0]instanceof n){var e=arguments[0];this.mergeLabel(e._label)}else if(arguments[0]instanceof Rt)for(var t=arguments[0],i=0;i<2;i++){var r=this.computeMergedLocation(t,i);this._label.getLocation(i)===$.NONE&&this._label.setLocation(i,r)}}},{key:"add",value:function(e){this._edges.insert(e),e.setNode(this)}},{key:"setLabelBoundary",value:function(e){if(null===this._label)return null;var t=$.NONE;null!==this._label&&(t=this._label.getLocation(e));var i=null;switch(t){case $.BOUNDARY:i=$.INTERIOR;break;case $.INTERIOR:default:i=$.BOUNDARY}this._label.setLocation(e,i)}}],[{key:"constructor_",value:function(){this._coord=null,this._edges=null;var e=arguments[0],t=arguments[1];this._coord=e,this._edges=t,this._label=new Rt(0,$.NONE)}}])}(Nt),Gt=function(e){function n(){return i(this,n),t(this,n,arguments)}return c(n,e),o(n)}(tt);function jt(e){return null==e?0:e.color}function Vt(e){return null==e?null:e.parent}function Ut(e,t){null!==e&&(e.color=t)}function qt(e){return null==e?null:e.left}function Zt(e){return null==e?null:e.right}var $t=function(e){function n(){var e;return i(this,n),(e=t(this,n)).root_=null,e.size_=0,e}return c(n,e),o(n,[{key:"get",value:function(e){for(var t=this.root_;null!==t;){var i=e.compareTo(t.key);if(i<0)t=t.left;else{if(!(i>0))return t.value;t=t.right}}return null}},{key:"put",value:function(e,t){if(null===this.root_)return this.root_={key:e,value:t,left:null,right:null,parent:null,color:0,getValue:function(){return this.value},getKey:function(){return this.key}},this.size_=1,null;var i,n,r=this.root_;do{if(i=r,(n=e.compareTo(r.key))<0)r=r.left;else{if(!(n>0)){var o=r.value;return r.value=t,o}r=r.right}}while(null!==r);var s={key:e,left:null,right:null,value:t,parent:i,color:0,getValue:function(){return this.value},getKey:function(){return this.key}};return n<0?i.left=s:i.right=s,this.fixAfterInsertion(s),this.size_++,null}},{key:"fixAfterInsertion",value:function(e){var t;for(e.color=1;null!=e&&e!==this.root_&&1===e.parent.color;)Vt(e)===qt(Vt(Vt(e)))?1===jt(t=Zt(Vt(Vt(e))))?(Ut(Vt(e),0),Ut(t,0),Ut(Vt(Vt(e)),1),e=Vt(Vt(e))):(e===Zt(Vt(e))&&(e=Vt(e),this.rotateLeft(e)),Ut(Vt(e),0),Ut(Vt(Vt(e)),1),this.rotateRight(Vt(Vt(e)))):1===jt(t=qt(Vt(Vt(e))))?(Ut(Vt(e),0),Ut(t,0),Ut(Vt(Vt(e)),1),e=Vt(Vt(e))):(e===qt(Vt(e))&&(e=Vt(e),this.rotateRight(e)),Ut(Vt(e),0),Ut(Vt(Vt(e)),1),this.rotateLeft(Vt(Vt(e))));this.root_.color=0}},{key:"values",value:function(){var e=new me,t=this.getFirstEntry();if(null!==t)for(e.add(t.value);null!==(t=n.successor(t));)e.add(t.value);return e}},{key:"entrySet",value:function(){var e=new J,t=this.getFirstEntry();if(null!==t)for(e.add(t);null!==(t=n.successor(t));)e.add(t);return e}},{key:"rotateLeft",value:function(e){if(null!=e){var t=e.right;e.right=t.left,null!=t.left&&(t.left.parent=e),t.parent=e.parent,null==e.parent?this.root_=t:e.parent.left===e?e.parent.left=t:e.parent.right=t,t.left=e,e.parent=t}}},{key:"rotateRight",value:function(e){if(null!=e){var t=e.left;e.left=t.right,null!=t.right&&(t.right.parent=e),t.parent=e.parent,null==e.parent?this.root_=t:e.parent.right===e?e.parent.right=t:e.parent.left=t,t.right=e,e.parent=t}}},{key:"getFirstEntry",value:function(){var e=this.root_;if(null!=e)for(;null!=e.left;)e=e.left;return e}},{key:"size",value:function(){return this.size_}},{key:"containsKey",value:function(e){for(var t=this.root_;null!==t;){var i=e.compareTo(t.key);if(i<0)t=t.left;else{if(!(i>0))return!0;t=t.right}}return!1}}],[{key:"successor",value:function(e){var t;if(null===e)return null;if(null!==e.right){for(t=e.right;null!==t.left;)t=t.left;return t}t=e.parent;for(var i=e;null!==t&&i===t.right;)i=t,t=t.parent;return t}}])}(Gt),Ht=o(function e(){i(this,e),e.constructor_.apply(this,arguments)},[{key:"find",value:function(e){return this.nodeMap.get(e)}},{key:"addNode",value:function(){if(arguments[0]instanceof V){var e=arguments[0],t=this.nodeMap.get(e);return null===t&&(t=this.nodeFact.createNode(e),this.nodeMap.put(e,t)),t}if(arguments[0]instanceof Bt){var i=arguments[0],n=this.nodeMap.get(i.getCoordinate());return null===n?(this.nodeMap.put(i.getCoordinate(),i),i):(n.mergeLabel(i),n)}}},{key:"print",value:function(e){for(var t=this.iterator();t.hasNext();)t.next().print(e)}},{key:"iterator",value:function(){return this.nodeMap.values().iterator()}},{key:"values",value:function(){return this.nodeMap.values()}},{key:"getBoundaryNodes",value:function(e){for(var t=new me,i=this.iterator();i.hasNext();){var n=i.next();n.getLabel().getLocation(e)===$.BOUNDARY&&t.add(n)}return t}},{key:"add",value:function(e){var t=e.getCoordinate();this.addNode(t).add(e)}}],[{key:"constructor_",value:function(){this.nodeMap=new $t,this.nodeFact=null;var e=arguments[0];this.nodeFact=e}}]),Wt=function(){function e(){i(this,e)}return o(e,null,[{key:"isNorthern",value:function(t){return t===e.NE||t===e.NW}},{key:"isOpposite",value:function(e,t){return e!==t&&(e-t+4)%4==2}},{key:"commonHalfPlane",value:function(e,t){if(e===t)return e;if((e-t+4)%4==2)return-1;var i=e<t?e:t;return 0===i&&3===(e>t?e:t)?3:i}},{key:"isInHalfPlane",value:function(t,i){return i===e.SE?t===e.SE||t===e.SW:t===i||t===i+1}},{key:"quadrant",value:function(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],i=arguments[1];if(0===t&&0===i)throw new v("Cannot compute the quadrant for point ( "+t+", "+i+" )");return t>=0?i>=0?e.NE:e.SE:i>=0?e.NW:e.SW}if(arguments[0]instanceof V&&arguments[1]instanceof V){var n=arguments[0],r=arguments[1];if(r.x===n.x&&r.y===n.y)throw new v("Cannot compute the quadrant for two identical points "+n);return r.x>=n.x?r.y>=n.y?e.NE:e.SE:r.y>=n.y?e.NW:e.SW}}}])}();Wt.NE=0,Wt.NW=1,Wt.SW=2,Wt.SE=3;var Xt=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"compareDirection",value:function(e){return this._dx===e._dx&&this._dy===e._dy?0:this._quadrant>e._quadrant?1:this._quadrant<e._quadrant?-1:he.index(e._p0,e._p1,this._p1)}},{key:"getDy",value:function(){return this._dy}},{key:"getCoordinate",value:function(){return this._p0}},{key:"setNode",value:function(e){this._node=e}},{key:"print",value:function(e){var t=Math.atan2(this._dy,this._dx),i=this.getClass().getName(),n=i.lastIndexOf("."),r=i.substring(n+1);e.print(" "+r+": "+this._p0+" - "+this._p1+" "+this._quadrant+":"+t+" "+this._label)}},{key:"compareTo",value:function(e){var t=e;return this.compareDirection(t)}},{key:"getDirectedCoordinate",value:function(){return this._p1}},{key:"getDx",value:function(){return this._dx}},{key:"getLabel",value:function(){return this._label}},{key:"getEdge",value:function(){return this._edge}},{key:"getQuadrant",value:function(){return this._quadrant}},{key:"getNode",value:function(){return this._node}},{key:"toString",value:function(){var e=Math.atan2(this._dy,this._dx),t=this.getClass().getName(),i=t.lastIndexOf(".");return" "+t.substring(i+1)+": "+this._p0+" - "+this._p1+" "+this._quadrant+":"+e+" "+this._label}},{key:"computeLabel",value:function(e){}},{key:"init",value:function(e,t){this._p0=e,this._p1=t,this._dx=t.x-e.x,this._dy=t.y-e.y,this._quadrant=Wt.quadrant(this._dx,this._dy),N.isTrue(!(0===this._dx&&0===this._dy),"EdgeEnd with identical endpoints found")}},{key:"interfaces_",get:function(){return[b]}}],[{key:"constructor_",value:function(){if(this._edge=null,this._label=null,this._node=null,this._p0=null,this._p1=null,this._dx=null,this._dy=null,this._quadrant=null,1===arguments.length){var t=arguments[0];this._edge=t}else if(3===arguments.length){var i=arguments[0],n=arguments[1],r=arguments[2];e.constructor_.call(this,i,n,r,null)}else if(4===arguments.length){var o=arguments[0],s=arguments[1],a=arguments[2],l=arguments[3];e.constructor_.call(this,o),this.init(s,a),this._label=l}}}])}(),Yt=function(e){function n(){var e;return i(this,n),e=t(this,n),n.constructor_.apply(e,arguments),e}return c(n,e),o(n,[{key:"getNextMin",value:function(){return this._nextMin}},{key:"getDepth",value:function(e){return this._depth[e]}},{key:"setVisited",value:function(e){this._isVisited=e}},{key:"computeDirectedLabel",value:function(){this._label=new Rt(this._edge.getLabel()),this._isForward||this._label.flip()}},{key:"getNext",value:function(){return this._next}},{key:"setDepth",value:function(e,t){if(-999!==this._depth[e]&&this._depth[e]!==t)throw new pe("assigned depths do not match",this.getCoordinate());this._depth[e]=t}},{key:"isInteriorAreaEdge",value:function(){for(var e=!0,t=0;t<2;t++)this._label.isArea(t)&&this._label.getLocation(t,Q.LEFT)===$.INTERIOR&&this._label.getLocation(t,Q.RIGHT)===$.INTERIOR||(e=!1);return e}},{key:"setNextMin",value:function(e){this._nextMin=e}},{key:"print",value:function(e){d(n,"print",this,1).call(this,e),e.print(" "+this._depth[Q.LEFT]+"/"+this._depth[Q.RIGHT]),e.print(" ("+this.getDepthDelta()+")"),this._isInResult&&e.print(" inResult")}},{key:"setMinEdgeRing",value:function(e){this._minEdgeRing=e}},{key:"isLineEdge",value:function(){var e=this._label.isLine(0)||this._label.isLine(1),t=!this._label.isArea(0)||this._label.allPositionsEqual(0,$.EXTERIOR),i=!this._label.isArea(1)||this._label.allPositionsEqual(1,$.EXTERIOR);return e&&t&&i}},{key:"setEdgeRing",value:function(e){this._edgeRing=e}},{key:"getMinEdgeRing",value:function(){return this._minEdgeRing}},{key:"getDepthDelta",value:function(){var e=this._edge.getDepthDelta();return this._isForward||(e=-e),e}},{key:"setInResult",value:function(e){this._isInResult=e}},{key:"getSym",value:function(){return this._sym}},{key:"isForward",value:function(){return this._isForward}},{key:"getEdge",value:function(){return this._edge}},{key:"printEdge",value:function(e){this.print(e),e.print(" "),this._isForward?this._edge.print(e):this._edge.printReverse(e)}},{key:"setSym",value:function(e){this._sym=e}},{key:"setVisitedEdge",value:function(e){this.setVisited(e),this._sym.setVisited(e)}},{key:"setEdgeDepths",value:function(e,t){var i=this.getEdge().getDepthDelta();this._isForward||(i=-i);var n=1;e===Q.LEFT&&(n=-1);var r=Q.opposite(e),o=t+i*n;this.setDepth(e,t),this.setDepth(r,o)}},{key:"getEdgeRing",value:function(){return this._edgeRing}},{key:"isInResult",value:function(){return this._isInResult}},{key:"setNext",value:function(e){this._next=e}},{key:"isVisited",value:function(){return this._isVisited}}],[{key:"constructor_",value:function(){this._isForward=null,this._isInResult=!1,this._isVisited=!1,this._sym=null,this._next=null,this._nextMin=null,this._edgeRing=null,this._minEdgeRing=null,this._depth=[0,-999,-999];var e=arguments[0],t=arguments[1];if(Xt.constructor_.call(this,e),this._isForward=t,t)this.init(e.getCoordinate(0),e.getCoordinate(1));else{var i=e.getNumPoints()-1;this.init(e.getCoordinate(i),e.getCoordinate(i-1))}this.computeDirectedLabel()}},{key:"depthFactor",value:function(e,t){return e===$.EXTERIOR&&t===$.INTERIOR?1:e===$.INTERIOR&&t===$.EXTERIOR?-1:0}}])}(Xt),Jt=o(function e(){i(this,e)},[{key:"createNode",value:function(e){return new Bt(e,null)}}]),Kt=o(function e(){i(this,e),e.constructor_.apply(this,arguments)},[{key:"printEdges",value:function(e){e.println("Edges:");for(var t=0;t<this._edges.size();t++){e.println("edge "+t+":");var i=this._edges.get(t);i.print(e),i.eiList.print(e)}}},{key:"find",value:function(e){return this._nodes.find(e)}},{key:"addNode",value:function(){if(arguments[0]instanceof Bt){var e=arguments[0];return this._nodes.addNode(e)}if(arguments[0]instanceof V){var t=arguments[0];return this._nodes.addNode(t)}}},{key:"getNodeIterator",value:function(){return this._nodes.iterator()}},{key:"linkResultDirectedEdges",value:function(){for(var e=this._nodes.iterator();e.hasNext();)e.next().getEdges().linkResultDirectedEdges()}},{key:"debugPrintln",value:function(e){ve.out.println(e)}},{key:"isBoundaryNode",value:function(e,t){var i=this._nodes.find(t);if(null===i)return!1;var n=i.getLabel();return null!==n&&n.getLocation(e)===$.BOUNDARY}},{key:"linkAllDirectedEdges",value:function(){for(var e=this._nodes.iterator();e.hasNext();)e.next().getEdges().linkAllDirectedEdges()}},{key:"matchInSameDirection",value:function(e,t,i,n){return!!e.equals(i)&&he.index(e,t,n)===he.COLLINEAR&&Wt.quadrant(e,t)===Wt.quadrant(i,n)}},{key:"getEdgeEnds",value:function(){return this._edgeEndList}},{key:"debugPrint",value:function(e){ve.out.print(e)}},{key:"getEdgeIterator",value:function(){return this._edges.iterator()}},{key:"findEdgeInSameDirection",value:function(e,t){for(var i=0;i<this._edges.size();i++){var n=this._edges.get(i),r=n.getCoordinates();if(this.matchInSameDirection(e,t,r[0],r[1])||this.matchInSameDirection(e,t,r[r.length-1],r[r.length-2]))return n}return null}},{key:"insertEdge",value:function(e){this._edges.add(e)}},{key:"findEdgeEnd",value:function(e){for(var t=this.getEdgeEnds().iterator();t.hasNext();){var i=t.next();if(i.getEdge()===e)return i}return null}},{key:"addEdges",value:function(e){for(var t=e.iterator();t.hasNext();){var i=t.next();this._edges.add(i);var n=new Yt(i,!0),r=new Yt(i,!1);n.setSym(r),r.setSym(n),this.add(n),this.add(r)}}},{key:"add",value:function(e){this._nodes.add(e),this._edgeEndList.add(e)}},{key:"getNodes",value:function(){return this._nodes.values()}},{key:"findEdge",value:function(e,t){for(var i=0;i<this._edges.size();i++){var n=this._edges.get(i),r=n.getCoordinates();if(e.equals(r[0])&&t.equals(r[1]))return n}return null}}],[{key:"constructor_",value:function(){if(this._edges=new me,this._nodes=null,this._edgeEndList=new me,0===arguments.length)this._nodes=new Ht(new Jt);else if(1===arguments.length){var e=arguments[0];this._nodes=new Ht(e)}}},{key:"linkResultDirectedEdges",value:function(e){for(var t=e.iterator();t.hasNext();)t.next().getEdges().linkResultDirectedEdges()}}]),Qt=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"sortShellsAndHoles",value:function(e,t,i){for(var n=e.iterator();n.hasNext();){var r=n.next();r.isHole()?i.add(r):t.add(r)}}},{key:"computePolygons",value:function(e){for(var t=new me,i=e.iterator();i.hasNext();){var n=i.next().toPolygon(this._geometryFactory);t.add(n)}return t}},{key:"placeFreeHoles",value:function(t,i){for(var n=i.iterator();n.hasNext();){var r=n.next();if(null===r.getShell()){var o=e.findEdgeRingContaining(r,t);if(null===o)throw new pe("unable to assign hole to a shell",r.getCoordinate(0));r.setShell(o)}}}},{key:"buildMinimalEdgeRings",value:function(e,t,i){for(var n=new me,r=e.iterator();r.hasNext();){var o=r.next();if(o.getMaxNodeDegree()>2){o.linkDirectedEdgesForMinimalEdgeRings();var s=o.buildMinimalRings(),a=this.findShell(s);null!==a?(this.placePolygonHoles(a,s),t.add(a)):i.addAll(s)}else n.add(o)}return n}},{key:"buildMaximalEdgeRings",value:function(e){for(var t=new me,i=e.iterator();i.hasNext();){var n=i.next();if(n.isInResult()&&n.getLabel().isArea()&&null===n.getEdgeRing()){var r=new Ot(n,this._geometryFactory);t.add(r),r.setInResult()}}return t}},{key:"placePolygonHoles",value:function(e,t){for(var i=t.iterator();i.hasNext();){var n=i.next();n.isHole()&&n.setShell(e)}}},{key:"getPolygons",value:function(){return this.computePolygons(this._shellList)}},{key:"findShell",value:function(e){for(var t=0,i=null,n=e.iterator();n.hasNext();){var r=n.next();r.isHole()||(i=r,t++)}return N.isTrue(t<=1,"found two shells in MinimalEdgeRing list"),i}},{key:"add",value:function(){if(1===arguments.length){var e=arguments[0];this.add(e.getEdgeEnds(),e.getNodes())}else if(2===arguments.length){var t=arguments[0],i=arguments[1];Kt.linkResultDirectedEdges(i);var n=this.buildMaximalEdgeRings(t),r=new me,o=this.buildMinimalEdgeRings(n,this._shellList,r);this.sortShellsAndHoles(o,this._shellList,r),this.placeFreeHoles(this._shellList,r)}}}],[{key:"constructor_",value:function(){this._geometryFactory=null,this._shellList=new me;var e=arguments[0];this._geometryFactory=e}},{key:"findEdgeRingContaining",value:function(e,t){for(var i=e.getLinearRing(),n=i.getEnvelopeInternal(),r=i.getCoordinateN(0),o=null,s=null,a=t.iterator();a.hasNext();){var l=a.next(),c=l.getLinearRing(),u=c.getEnvelopeInternal();if(!u.equals(n)&&u.contains(n)){r=We.ptNotInList(i.getCoordinates(),c.getCoordinates());var h=!1;Lt.isInRing(r,c.getCoordinates())&&(h=!0),h&&(null===o||s.contains(u))&&(s=(o=l).getLinearRing().getEnvelopeInternal())}}return o}}])}(),ei=o(function e(){i(this,e)},[{key:"getBounds",value:function(){}}]),ti=o(function e(){i(this,e),e.constructor_.apply(this,arguments)},[{key:"getItem",value:function(){return this._item}},{key:"getBounds",value:function(){return this._bounds}},{key:"interfaces_",get:function(){return[ei,E]}}],[{key:"constructor_",value:function(){this._bounds=null,this._item=null;var e=arguments[0],t=arguments[1];this._bounds=e,this._item=t}}]),ii=o(function e(){i(this,e),e.constructor_.apply(this,arguments)},[{key:"poll",value:function(){if(this.isEmpty())return null;var e=this._items.get(1);return this._items.set(1,this._items.get(this._size)),this._size-=1,this.reorder(1),e}},{key:"size",value:function(){return this._size}},{key:"reorder",value:function(e){for(var t=null,i=this._items.get(e);2*e<=this._size&&((t=2*e)!==this._size&&this._items.get(t+1).compareTo(this._items.get(t))<0&&t++,this._items.get(t).compareTo(i)<0);e=t)this._items.set(e,this._items.get(t));this._items.set(e,i)}},{key:"clear",value:function(){this._size=0,this._items.clear()}},{key:"peek",value:function(){return this.isEmpty()?null:this._items.get(1)}},{key:"isEmpty",value:function(){return 0===this._size}},{key:"add",value:function(e){this._items.add(null),this._size+=1;var t=this._size;for(this._items.set(0,e);e.compareTo(this._items.get(Math.trunc(t/2)))<0;t/=2)this._items.set(t,this._items.get(Math.trunc(t/2)));this._items.set(t,e)}}],[{key:"constructor_",value:function(){this._size=null,this._items=null,this._size=0,this._items=new me,this._items.add(null)}}]),ni=o(function e(){i(this,e)},[{key:"insert",value:function(e,t){}},{key:"remove",value:function(e,t){}},{key:"query",value:function(){}}]),ri=o(function e(){i(this,e),e.constructor_.apply(this,arguments)},[{key:"getLevel",value:function(){return this._level}},{key:"size",value:function(){return this._childBoundables.size()}},{key:"getChildBoundables",value:function(){return this._childBoundables}},{key:"addChildBoundable",value:function(e){N.isTrue(null===this._bounds),this._childBoundables.add(e)}},{key:"isEmpty",value:function(){return this._childBoundables.isEmpty()}},{key:"getBounds",value:function(){return null===this._bounds&&(this._bounds=this.computeBounds()),this._bounds}},{key:"interfaces_",get:function(){return[ei,E]}}],[{key:"constructor_",value:function(){if(this._childBoundables=new me,this._bounds=null,this._level=null,0!==arguments.length&&1===arguments.length){var e=arguments[0];this._level=e}}}]),oi={reverseOrder:function(){return{compare:function(e,t){return t.compareTo(e)}}},min:function(e){return oi.sort(e),e.get(0)},sort:function(e,t){var i=e.toArray();t?Re.sort(i,t):Re.sort(i);for(var n=e.iterator(),r=0,o=i.length;r<o;r++)n.next(),n.set(i[r])},singletonList:function(e){var t=new me;return t.add(e),t}},si=function(){function e(){i(this,e)}return o(e,null,[{key:"maxDistance",value:function(t,i,n,r,o,s,a,l){var c=e.distance(t,i,o,s);return c=Math.max(c,e.distance(t,i,a,l)),c=Math.max(c,e.distance(n,r,o,s)),Math.max(c,e.distance(n,r,a,l))}},{key:"distance",value:function(e,t,i,n){var r=i-e,o=n-t;return Math.sqrt(r*r+o*o)}},{key:"maximumDistance",value:function(t,i){var n=Math.min(t.getMinX(),i.getMinX()),r=Math.min(t.getMinY(),i.getMinY()),o=Math.max(t.getMaxX(),i.getMaxX()),s=Math.max(t.getMaxY(),i.getMaxY());return e.distance(n,r,o,s)}},{key:"minMaxDistance",value:function(t,i){var n=t.getMinX(),r=t.getMinY(),o=t.getMaxX(),s=t.getMaxY(),a=i.getMinX(),l=i.getMinY(),c=i.getMaxX(),u=i.getMaxY(),h=e.maxDistance(n,r,n,s,a,l,a,u);return h=Math.min(h,e.maxDistance(n,r,n,s,a,l,c,l)),h=Math.min(h,e.maxDistance(n,r,n,s,c,u,a,u)),h=Math.min(h,e.maxDistance(n,r,n,s,c,u,c,l)),h=Math.min(h,e.maxDistance(n,r,o,r,a,l,a,u)),h=Math.min(h,e.maxDistance(n,r,o,r,a,l,c,l)),h=Math.min(h,e.maxDistance(n,r,o,r,c,u,a,u)),h=Math.min(h,e.maxDistance(n,r,o,r,c,u,c,l)),h=Math.min(h,e.maxDistance(o,s,n,s,a,l,a,u)),h=Math.min(h,e.maxDistance(o,s,n,s,a,l,c,l)),h=Math.min(h,e.maxDistance(o,s,n,s,c,u,a,u)),h=Math.min(h,e.maxDistance(o,s,n,s,c,u,c,l)),h=Math.min(h,e.maxDistance(o,s,o,r,a,l,a,u)),h=Math.min(h,e.maxDistance(o,s,o,r,a,l,c,l)),h=Math.min(h,e.maxDistance(o,s,o,r,c,u,a,u)),Math.min(h,e.maxDistance(o,s,o,r,c,u,c,l))}}])}(),ai=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"maximumDistance",value:function(){return si.maximumDistance(this._boundable1.getBounds(),this._boundable2.getBounds())}},{key:"expandToQueue",value:function(t,i){var n=e.isComposite(this._boundable1),r=e.isComposite(this._boundable2);if(n&&r)return e.area(this._boundable1)>e.area(this._boundable2)?(this.expand(this._boundable1,this._boundable2,!1,t,i),null):(this.expand(this._boundable2,this._boundable1,!0,t,i),null);if(n)return this.expand(this._boundable1,this._boundable2,!1,t,i),null;if(r)return this.expand(this._boundable2,this._boundable1,!0,t,i),null;throw new v("neither boundable is composite")}},{key:"isLeaves",value:function(){return!(e.isComposite(this._boundable1)||e.isComposite(this._boundable2))}},{key:"compareTo",value:function(e){var t=e;return this._distance<t._distance?-1:this._distance>t._distance?1:0}},{key:"expand",value:function(t,i,n,r,o){for(var s=t.getChildBoundables().iterator();s.hasNext();){var a=s.next(),l=null;(l=n?new e(i,a,this._itemDistance):new e(a,i,this._itemDistance)).getDistance()<o&&r.add(l)}}},{key:"getBoundable",value:function(e){return 0===e?this._boundable1:this._boundable2}},{key:"getDistance",value:function(){return this._distance}},{key:"distance",value:function(){return this.isLeaves()?this._itemDistance.distance(this._boundable1,this._boundable2):this._boundable1.getBounds().distance(this._boundable2.getBounds())}},{key:"interfaces_",get:function(){return[b]}}],[{key:"constructor_",value:function(){this._boundable1=null,this._boundable2=null,this._distance=null,this._itemDistance=null;var e=arguments[0],t=arguments[1],i=arguments[2];this._boundable1=e,this._boundable2=t,this._itemDistance=i,this._distance=this.distance()}},{key:"area",value:function(e){return e.getBounds().getArea()}},{key:"isComposite",value:function(e){return e instanceof ri}}])}(),li=o(function e(){i(this,e)},[{key:"visitItem",value:function(e){}}]),ci=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"queryInternal",value:function(){if(re(arguments[2],li)&&arguments[0]instanceof Object&&arguments[1]instanceof ri)for(var e=arguments[0],t=arguments[2],i=arguments[1].getChildBoundables(),n=0;n<i.size();n++){var r=i.get(n);this.getIntersectsOp().intersects(r.getBounds(),e)&&(r instanceof ri?this.queryInternal(e,r,t):r instanceof ti?t.visitItem(r.getItem()):N.shouldNeverReachHere())}else if(re(arguments[2],ie)&&arguments[0]instanceof Object&&arguments[1]instanceof ri)for(var o=arguments[0],s=arguments[2],a=arguments[1].getChildBoundables(),l=0;l<a.size();l++){var c=a.get(l);this.getIntersectsOp().intersects(c.getBounds(),o)&&(c instanceof ri?this.queryInternal(o,c,s):c instanceof ti?s.add(c.getItem()):N.shouldNeverReachHere())}}},{key:"getNodeCapacity",value:function(){return this._nodeCapacity}},{key:"lastNode",value:function(e){return e.get(e.size()-1)}},{key:"size",value:function(){if(0===arguments.length)return this.isEmpty()?0:(this.build(),this.size(this._root));if(1===arguments.length){for(var e=0,t=arguments[0].getChildBoundables().iterator();t.hasNext();){var i=t.next();i instanceof ri?e+=this.size(i):i instanceof ti&&(e+=1)}return e}}},{key:"removeItem",value:function(e,t){for(var i=null,n=e.getChildBoundables().iterator();n.hasNext();){var r=n.next();r instanceof ti&&r.getItem()===t&&(i=r)}return null!==i&&(e.getChildBoundables().remove(i),!0)}},{key:"itemsTree",value:function(){if(0===arguments.length){this.build();var e=this.itemsTree(this._root);return null===e?new me:e}if(1===arguments.length){for(var t=arguments[0],i=new me,n=t.getChildBoundables().iterator();n.hasNext();){var r=n.next();if(r instanceof ri){var o=this.itemsTree(r);null!==o&&i.add(o)}else r instanceof ti?i.add(r.getItem()):N.shouldNeverReachHere()}return i.size()<=0?null:i}}},{key:"insert",value:function(e,t){N.isTrue(!this._built,"Cannot insert items into an STR packed R-tree after it has been built."),this._itemBoundables.add(new ti(e,t))}},{key:"boundablesAtLevel",value:function(){if(1===arguments.length){var e=arguments[0],t=new me;return this.boundablesAtLevel(e,this._root,t),t}if(3===arguments.length){var i=arguments[0],n=arguments[1],r=arguments[2];if(N.isTrue(i>-2),n.getLevel()===i)return r.add(n),null;for(var o=n.getChildBoundables().iterator();o.hasNext();){var s=o.next();s instanceof ri?this.boundablesAtLevel(i,s,r):(N.isTrue(s instanceof ti),-1===i&&r.add(s))}return null}}},{key:"query",value:function(){if(1===arguments.length){var e=arguments[0];this.build();var t=new me;return this.isEmpty()||this.getIntersectsOp().intersects(this._root.getBounds(),e)&&this.queryInternal(e,this._root,t),t}if(2===arguments.length){var i=arguments[0],n=arguments[1];if(this.build(),this.isEmpty())return null;this.getIntersectsOp().intersects(this._root.getBounds(),i)&&this.queryInternal(i,this._root,n)}}},{key:"build",value:function(){if(this._built)return null;this._root=this._itemBoundables.isEmpty()?this.createNode(0):this.createHigherLevels(this._itemBoundables,-1),this._itemBoundables=null,this._built=!0}},{key:"getRoot",value:function(){return this.build(),this._root}},{key:"remove",value:function(){if(2===arguments.length){var e=arguments[0],t=arguments[1];return this.build(),!!this.getIntersectsOp().intersects(this._root.getBounds(),e)&&this.remove(e,this._root,t)}if(3===arguments.length){var i=arguments[0],n=arguments[1],r=arguments[2],o=this.removeItem(n,r);if(o)return!0;for(var s=null,a=n.getChildBoundables().iterator();a.hasNext();){var l=a.next();if(this.getIntersectsOp().intersects(l.getBounds(),i)&&l instanceof ri&&(o=this.remove(i,l,r))){s=l;break}}return null!==s&&s.getChildBoundables().isEmpty()&&n.getChildBoundables().remove(s),o}}},{key:"createHigherLevels",value:function(e,t){N.isTrue(!e.isEmpty());var i=this.createParentBoundables(e,t+1);return 1===i.size()?i.get(0):this.createHigherLevels(i,t+1)}},{key:"depth",value:function(){if(0===arguments.length)return this.isEmpty()?0:(this.build(),this.depth(this._root));if(1===arguments.length){for(var e=0,t=arguments[0].getChildBoundables().iterator();t.hasNext();){var i=t.next();if(i instanceof ri){var n=this.depth(i);n>e&&(e=n)}}return e+1}}},{key:"createParentBoundables",value:function(e,t){N.isTrue(!e.isEmpty());var i=new me;i.add(this.createNode(t));var n=new me(e);oi.sort(n,this.getComparator());for(var r=n.iterator();r.hasNext();){var o=r.next();this.lastNode(i).getChildBoundables().size()===this.getNodeCapacity()&&i.add(this.createNode(t)),this.lastNode(i).addChildBoundable(o)}return i}},{key:"isEmpty",value:function(){return this._built?this._root.isEmpty():this._itemBoundables.isEmpty()}},{key:"interfaces_",get:function(){return[E]}}],[{key:"constructor_",value:function(){if(this._root=null,this._built=!1,this._itemBoundables=new me,this._nodeCapacity=null,0===arguments.length)e.constructor_.call(this,e.DEFAULT_NODE_CAPACITY);else if(1===arguments.length){var t=arguments[0];N.isTrue(t>1,"Node capacity must be greater than 1"),this._nodeCapacity=t}}},{key:"compareDoubles",value:function(e,t){return e>t?1:e<t?-1:0}}])}();ci.IntersectsOp=function(){},ci.DEFAULT_NODE_CAPACITY=10;var ui=o(function e(){i(this,e)},[{key:"distance",value:function(e,t){}}]),hi=function(e){function n(){var e;return i(this,n),e=t(this,n),n.constructor_.apply(e,arguments),e}return c(n,e),o(n,[{key:"createParentBoundablesFromVerticalSlices",value:function(e,t){N.isTrue(e.length>0);for(var i=new me,n=0;n<e.length;n++)i.addAll(this.createParentBoundablesFromVerticalSlice(e[n],t));return i}},{key:"nearestNeighbourK",value:function(){if(2===arguments.length){var e=arguments[0],t=arguments[1];return this.nearestNeighbourK(e,R.POSITIVE_INFINITY,t)}if(3===arguments.length){var i=arguments[0],r=arguments[2],o=arguments[1],s=new ii;s.add(i);for(var a=new ii;!s.isEmpty()&&o>=0;){var l=s.poll(),c=l.getDistance();if(c>=o)break;l.isLeaves()?a.size()<r?a.add(l):(a.peek().getDistance()>c&&(a.poll(),a.add(l)),o=a.peek().getDistance()):l.expandToQueue(s,o)}return n.getItems(a)}}},{key:"createNode",value:function(e){return new di(e)}},{key:"size",value:function(){return 0===arguments.length?d(n,"size",this,1).call(this):d(n,"size",this,1).apply(this,arguments)}},{key:"insert",value:function(){if(!(2===arguments.length&&arguments[1]instanceof Object&&arguments[0]instanceof q))return d(n,"insert",this,1).apply(this,arguments);var e=arguments[0],t=arguments[1];if(e.isNull())return null;d(n,"insert",this,1).call(this,e,t)}},{key:"getIntersectsOp",value:function(){return n.intersectsOp}},{key:"verticalSlices",value:function(e,t){for(var i=Math.trunc(Math.ceil(e.size()/t)),n=new Array(t).fill(null),r=e.iterator(),o=0;o<t;o++){n[o]=new me;for(var s=0;r.hasNext()&&s<i;){var a=r.next();n[o].add(a),s++}}return n}},{key:"query",value:function(){if(1===arguments.length){var e=arguments[0];return d(n,"query",this,1).call(this,e)}if(2===arguments.length){var t=arguments[0],i=arguments[1];d(n,"query",this,1).call(this,t,i)}}},{key:"getComparator",value:function(){return n.yComparator}},{key:"createParentBoundablesFromVerticalSlice",value:function(e,t){return d(n,"createParentBoundables",this,1).call(this,e,t)}},{key:"remove",value:function(){if(2===arguments.length&&arguments[1]instanceof Object&&arguments[0]instanceof q){var e=arguments[0],t=arguments[1];return d(n,"remove",this,1).call(this,e,t)}return d(n,"remove",this,1).apply(this,arguments)}},{key:"depth",value:function(){return 0===arguments.length?d(n,"depth",this,1).call(this):d(n,"depth",this,1).apply(this,arguments)}},{key:"createParentBoundables",value:function(e,t){N.isTrue(!e.isEmpty());var i=Math.trunc(Math.ceil(e.size()/this.getNodeCapacity())),r=new me(e);oi.sort(r,n.xComparator);var o=this.verticalSlices(r,Math.trunc(Math.ceil(Math.sqrt(i))));return this.createParentBoundablesFromVerticalSlices(o,t)}},{key:"nearestNeighbour",value:function(){if(1===arguments.length){if(re(arguments[0],ui)){var e=arguments[0];if(this.isEmpty())return null;var t=new ai(this.getRoot(),this.getRoot(),e);return this.nearestNeighbour(t)}if(arguments[0]instanceof ai){var i=arguments[0],n=R.POSITIVE_INFINITY,r=null,o=new ii;for(o.add(i);!o.isEmpty()&&n>0;){var s=o.poll(),a=s.getDistance();if(a>=n)break;s.isLeaves()?(n=a,r=s):s.expandToQueue(o,n)}return null===r?null:[r.getBoundable(0).getItem(),r.getBoundable(1).getItem()]}}else{if(2===arguments.length){var l=arguments[0],c=arguments[1];if(this.isEmpty()||l.isEmpty())return null;var u=new ai(this.getRoot(),l.getRoot(),c);return this.nearestNeighbour(u)}if(3===arguments.length){var h=arguments[2],d=new ti(arguments[0],arguments[1]),p=new ai(this.getRoot(),d,h);return this.nearestNeighbour(p)[0]}if(4===arguments.length){var f=arguments[2],m=arguments[3],g=new ti(arguments[0],arguments[1]),y=new ai(this.getRoot(),g,f);return this.nearestNeighbourK(y,m)}}}},{key:"isWithinDistance",value:function(){if(2===arguments.length){var e=arguments[0],t=arguments[1],i=R.POSITIVE_INFINITY,n=new ii;for(n.add(e);!n.isEmpty();){var r=n.poll(),o=r.getDistance();if(o>t)return!1;if(r.maximumDistance()<=t)return!0;if(r.isLeaves()){if((i=o)<=t)return!0}else r.expandToQueue(n,i)}return!1}if(3===arguments.length){var s=arguments[0],a=arguments[1],l=arguments[2],c=new ai(this.getRoot(),s.getRoot(),a);return this.isWithinDistance(c,l)}}},{key:"interfaces_",get:function(){return[ni,E]}}],[{key:"constructor_",value:function(){if(0===arguments.length)n.constructor_.call(this,n.DEFAULT_NODE_CAPACITY);else if(1===arguments.length){var e=arguments[0];ci.constructor_.call(this,e)}}},{key:"centreX",value:function(e){return n.avg(e.getMinX(),e.getMaxX())}},{key:"avg",value:function(e,t){return(e+t)/2}},{key:"getItems",value:function(e){for(var t=new Array(e.size()).fill(null),i=0;!e.isEmpty();){var n=e.poll();t[i]=n.getBoundable(0).getItem(),i++}return t}},{key:"centreY",value:function(e){return n.avg(e.getMinY(),e.getMaxY())}}])}(ci),di=function(e){function n(){var e;return i(this,n),e=t(this,n),n.constructor_.apply(e,arguments),e}return c(n,e),o(n,[{key:"computeBounds",value:function(){for(var e=null,t=this.getChildBoundables().iterator();t.hasNext();){var i=t.next();null===e?e=new q(i.getBounds()):e.expandToInclude(i.getBounds())}return e}}],[{key:"constructor_",value:function(){var e=arguments[0];ri.constructor_.call(this,e)}}])}(ri);hi.STRtreeNode=di,hi.xComparator=new(o(function e(){i(this,e)},[{key:"interfaces_",get:function(){return[z]}},{key:"compare",value:function(e,t){return ci.compareDoubles(hi.centreX(e.getBounds()),hi.centreX(t.getBounds()))}}])),hi.yComparator=new(o(function e(){i(this,e)},[{key:"interfaces_",get:function(){return[z]}},{key:"compare",value:function(e,t){return ci.compareDoubles(hi.centreY(e.getBounds()),hi.centreY(t.getBounds()))}}])),hi.intersectsOp=new(o(function e(){i(this,e)},[{key:"interfaces_",get:function(){return[IntersectsOp]}},{key:"intersects",value:function(e,t){return e.intersects(t)}}])),hi.DEFAULT_NODE_CAPACITY=10;var pi=function(){function e(){i(this,e)}return o(e,null,[{key:"relativeSign",value:function(e,t){return e<t?-1:e>t?1:0}},{key:"compare",value:function(t,i,n){if(i.equals2D(n))return 0;var r=e.relativeSign(i.x,n.x),o=e.relativeSign(i.y,n.y);switch(t){case 0:return e.compareValue(r,o);case 1:return e.compareValue(o,r);case 2:return e.compareValue(o,-r);case 3:return e.compareValue(-r,o);case 4:return e.compareValue(-r,-o);case 5:return e.compareValue(-o,-r);case 6:return e.compareValue(-o,r);case 7:return e.compareValue(r,-o)}return N.shouldNeverReachHere("invalid octant value"),0}},{key:"compareValue",value:function(e,t){return e<0?-1:e>0?1:t<0?-1:t>0?1:0}}])}(),fi=o(function e(){i(this,e),e.constructor_.apply(this,arguments)},[{key:"getCoordinate",value:function(){return this.coord}},{key:"print",value:function(e){e.print(this.coord),e.print(" seg # = "+this.segmentIndex)}},{key:"compareTo",value:function(e){var t=e;return this.segmentIndex<t.segmentIndex?-1:this.segmentIndex>t.segmentIndex?1:this.coord.equals2D(t.coord)?0:this._isInterior?t._isInterior?pi.compare(this._segmentOctant,this.coord,t.coord):1:-1}},{key:"isEndPoint",value:function(e){return 0===this.segmentIndex&&!this._isInterior||this.segmentIndex===e}},{key:"toString",value:function(){return this.segmentIndex+":"+this.coord.toString()}},{key:"isInterior",value:function(){return this._isInterior}},{key:"interfaces_",get:function(){return[b]}}],[{key:"constructor_",value:function(){this._segString=null,this.coord=null,this.segmentIndex=null,this._segmentOctant=null,this._isInterior=null;var e=arguments[0],t=arguments[1],i=arguments[2],n=arguments[3];this._segString=e,this.coord=new V(t),this.segmentIndex=i,this._segmentOctant=n,this._isInterior=!t.equals2D(e.getCoordinate(i))}}]),mi=o(function e(){i(this,e)},[{key:"hasNext",value:function(){}},{key:"next",value:function(){}},{key:"remove",value:function(){}}]),gi=o(function e(){i(this,e),e.constructor_.apply(this,arguments)},[{key:"getSplitCoordinates",value:function(){var e=new He;this.addEndpoints();for(var t=this.iterator(),i=t.next();t.hasNext();){var n=t.next();this.addEdgeCoordinates(i,n,e),i=n}return e.toCoordinateArray()}},{key:"addCollapsedNodes",value:function(){var e=new me;this.findCollapsesFromInsertedNodes(e),this.findCollapsesFromExistingVertices(e);for(var t=e.iterator();t.hasNext();){var i=t.next().intValue();this.add(this._edge.getCoordinate(i),i)}}},{key:"createSplitEdgePts",value:function(e,t){var i=t.segmentIndex-e.segmentIndex+2;if(2===i)return[new V(e.coord),new V(t.coord)];var n=this._edge.getCoordinate(t.segmentIndex),r=t.isInterior()||!t.coord.equals2D(n);r||i--;var o=new Array(i).fill(null),s=0;o[s++]=new V(e.coord);for(var a=e.segmentIndex+1;a<=t.segmentIndex;a++)o[s++]=this._edge.getCoordinate(a);return r&&(o[s]=new V(t.coord)),o}},{key:"print",value:function(e){e.println("Intersections:");for(var t=this.iterator();t.hasNext();)t.next().print(e)}},{key:"findCollapsesFromExistingVertices",value:function(e){for(var t=0;t<this._edge.size()-2;t++){var i=this._edge.getCoordinate(t);this._edge.getCoordinate(t+1);var n=this._edge.getCoordinate(t+2);i.equals2D(n)&&e.add(se.valueOf(t+1))}}},{key:"addEdgeCoordinates",value:function(e,t,i){var n=this.createSplitEdgePts(e,t);i.add(n,!1)}},{key:"iterator",value:function(){return this._nodeMap.values().iterator()}},{key:"addSplitEdges",value:function(e){this.addEndpoints(),this.addCollapsedNodes();for(var t=this.iterator(),i=t.next();t.hasNext();){var n=t.next(),r=this.createSplitEdge(i,n);e.add(r),i=n}}},{key:"findCollapseIndex",value:function(e,t,i){if(!e.coord.equals2D(t.coord))return!1;var n=t.segmentIndex-e.segmentIndex;return t.isInterior()||n--,1===n&&(i[0]=e.segmentIndex+1,!0)}},{key:"findCollapsesFromInsertedNodes",value:function(e){for(var t=new Array(1).fill(null),i=this.iterator(),n=i.next();i.hasNext();){var r=i.next();this.findCollapseIndex(n,r,t)&&e.add(se.valueOf(t[0])),n=r}}},{key:"getEdge",value:function(){return this._edge}},{key:"addEndpoints",value:function(){var e=this._edge.size()-1;this.add(this._edge.getCoordinate(0),0),this.add(this._edge.getCoordinate(e),e)}},{key:"createSplitEdge",value:function(e,t){var i=this.createSplitEdgePts(e,t);return new xi(i,this._edge.getData())}},{key:"add",value:function(e,t){var i=new fi(this._edge,e,t,this._edge.getSegmentOctant(t)),n=this._nodeMap.get(i);return null!==n?(N.isTrue(n.coord.equals2D(e),"Found equal nodes with different coordinates"),n):(this._nodeMap.put(i,i),i)}},{key:"checkSplitEdgesCorrectness",value:function(e){var t=this._edge.getCoordinates(),i=e.get(0).getCoordinate(0);if(!i.equals2D(t[0]))throw new F("bad split edge start point at "+i);var n=e.get(e.size()-1).getCoordinates(),r=n[n.length-1];if(!r.equals2D(t[t.length-1]))throw new F("bad split edge end point at "+r)}}],[{key:"constructor_",value:function(){this._nodeMap=new $t,this._edge=null;var e=arguments[0];this._edge=e}}]),yi=function(){function e(){i(this,e)}return o(e,null,[{key:"octant",value:function(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],i=arguments[1];if(0===t&&0===i)throw new v("Cannot compute the octant for point ( "+t+", "+i+" )");var n=Math.abs(t),r=Math.abs(i);return t>=0?i>=0?n>=r?0:1:n>=r?7:6:i>=0?n>=r?3:2:n>=r?4:5}if(arguments[0]instanceof V&&arguments[1]instanceof V){var o=arguments[0],s=arguments[1],a=s.x-o.x,l=s.y-o.y;if(0===a&&0===l)throw new v("Cannot compute the octant for two identical points "+o);return e.octant(a,l)}}}])}(),_i=o(function e(){i(this,e)},[{key:"getCoordinates",value:function(){}},{key:"size",value:function(){}},{key:"getCoordinate",value:function(e){}},{key:"isClosed",value:function(){}},{key:"setData",value:function(e){}},{key:"getData",value:function(){}}]),vi=o(function e(){i(this,e)},[{key:"addIntersection",value:function(e,t){}},{key:"interfaces_",get:function(){return[_i]}}]),xi=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"getCoordinates",value:function(){return this._pts}},{key:"size",value:function(){return this._pts.length}},{key:"getCoordinate",value:function(e){return this._pts[e]}},{key:"isClosed",value:function(){return this._pts[0].equals(this._pts[this._pts.length-1])}},{key:"getSegmentOctant",value:function(e){return e===this._pts.length-1?-1:this.safeOctant(this.getCoordinate(e),this.getCoordinate(e+1))}},{key:"setData",value:function(e){this._data=e}},{key:"safeOctant",value:function(e,t){return e.equals2D(t)?0:yi.octant(e,t)}},{key:"getData",value:function(){return this._data}},{key:"addIntersection",value:function(){if(2===arguments.length){var e=arguments[0],t=arguments[1];this.addIntersectionNode(e,t)}else if(4===arguments.length){var i=arguments[1],n=arguments[3],r=new V(arguments[0].getIntersection(n));this.addIntersection(r,i)}}},{key:"toString",value:function(){return Mt.toLineString(new Ke(this._pts))}},{key:"getNodeList",value:function(){return this._nodeList}},{key:"addIntersectionNode",value:function(e,t){var i=t,n=i+1;if(n<this._pts.length){var r=this._pts[n];e.equals2D(r)&&(i=n)}return this._nodeList.add(e,i)}},{key:"addIntersections",value:function(e,t,i){for(var n=0;n<e.getIntersectionNum();n++)this.addIntersection(e,t,i,n)}},{key:"interfaces_",get:function(){return[vi]}}],[{key:"constructor_",value:function(){this._nodeList=new gi(this),this._pts=null,this._data=null;var e=arguments[0],t=arguments[1];this._pts=e,this._data=t}},{key:"getNodedSubstrings",value:function(){if(1===arguments.length){var t=arguments[0],i=new me;return e.getNodedSubstrings(t,i),i}if(2===arguments.length)for(var n=arguments[1],r=arguments[0].iterator();r.hasNext();)r.next().getNodeList().addSplitEdges(n)}}])}(),bi=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"minX",value:function(){return Math.min(this.p0.x,this.p1.x)}},{key:"orientationIndex",value:function(){if(arguments[0]instanceof e){var t=arguments[0],i=he.index(this.p0,this.p1,t.p0),n=he.index(this.p0,this.p1,t.p1);return i>=0&&n>=0||i<=0&&n<=0?Math.max(i,n):0}if(arguments[0]instanceof V){var r=arguments[0];return he.index(this.p0,this.p1,r)}}},{key:"toGeometry",value:function(e){return e.createLineString([this.p0,this.p1])}},{key:"isVertical",value:function(){return this.p0.x===this.p1.x}},{key:"equals",value:function(t){if(!(t instanceof e))return!1;var i=t;return this.p0.equals(i.p0)&&this.p1.equals(i.p1)}},{key:"intersection",value:function(e){var t=new Pt;return t.computeIntersection(this.p0,this.p1,e.p0,e.p1),t.hasIntersection()?t.getIntersection(0):null}},{key:"project",value:function(){if(arguments[0]instanceof V){var t=arguments[0];if(t.equals(this.p0)||t.equals(this.p1))return new V(t);var i=this.projectionFactor(t),n=new V;return n.x=this.p0.x+i*(this.p1.x-this.p0.x),n.y=this.p0.y+i*(this.p1.y-this.p0.y),n}if(arguments[0]instanceof e){var r=arguments[0],o=this.projectionFactor(r.p0),s=this.projectionFactor(r.p1);if(o>=1&&s>=1||o<=0&&s<=0)return null;var a=this.project(r.p0);o<0&&(a=this.p0),o>1&&(a=this.p1);var l=this.project(r.p1);return s<0&&(l=this.p0),s>1&&(l=this.p1),new e(a,l)}}},{key:"normalize",value:function(){this.p1.compareTo(this.p0)<0&&this.reverse()}},{key:"angle",value:function(){return Math.atan2(this.p1.y-this.p0.y,this.p1.x-this.p0.x)}},{key:"getCoordinate",value:function(e){return 0===e?this.p0:this.p1}},{key:"distancePerpendicular",value:function(e){return be.pointToLinePerpendicular(e,this.p0,this.p1)}},{key:"minY",value:function(){return Math.min(this.p0.y,this.p1.y)}},{key:"midPoint",value:function(){return e.midPoint(this.p0,this.p1)}},{key:"projectionFactor",value:function(e){if(e.equals(this.p0))return 0;if(e.equals(this.p1))return 1;var t=this.p1.x-this.p0.x,i=this.p1.y-this.p0.y,n=t*t+i*i;return n<=0?R.NaN:((e.x-this.p0.x)*t+(e.y-this.p0.y)*i)/n}},{key:"closestPoints",value:function(e){var t=this.intersection(e);if(null!==t)return[t,t];var i=new Array(2).fill(null),n=R.MAX_VALUE,r=null,o=this.closestPoint(e.p0);n=o.distance(e.p0),i[0]=o,i[1]=e.p0;var s=this.closestPoint(e.p1);(r=s.distance(e.p1))<n&&(n=r,i[0]=s,i[1]=e.p1);var a=e.closestPoint(this.p0);(r=a.distance(this.p0))<n&&(n=r,i[0]=this.p0,i[1]=a);var l=e.closestPoint(this.p1);return(r=l.distance(this.p1))<n&&(n=r,i[0]=this.p1,i[1]=l),i}},{key:"closestPoint",value:function(e){var t=this.projectionFactor(e);return t>0&&t<1?this.project(e):this.p0.distance(e)<this.p1.distance(e)?this.p0:this.p1}},{key:"maxX",value:function(){return Math.max(this.p0.x,this.p1.x)}},{key:"getLength",value:function(){return this.p0.distance(this.p1)}},{key:"compareTo",value:function(e){var t=e,i=this.p0.compareTo(t.p0);return 0!==i?i:this.p1.compareTo(t.p1)}},{key:"reverse",value:function(){var e=this.p0;this.p0=this.p1,this.p1=e}},{key:"equalsTopo",value:function(e){return this.p0.equals(e.p0)&&this.p1.equals(e.p1)||this.p0.equals(e.p1)&&this.p1.equals(e.p0)}},{key:"lineIntersection",value:function(e){return _e.intersection(this.p0,this.p1,e.p0,e.p1)}},{key:"maxY",value:function(){return Math.max(this.p0.y,this.p1.y)}},{key:"pointAlongOffset",value:function(e,t){var i=this.p0.x+e*(this.p1.x-this.p0.x),n=this.p0.y+e*(this.p1.y-this.p0.y),r=this.p1.x-this.p0.x,o=this.p1.y-this.p0.y,s=Math.sqrt(r*r+o*o),a=0,l=0;if(0!==t){if(s<=0)throw new IllegalStateException("Cannot compute offset from zero-length line segment");a=t*r/s,l=t*o/s}return new V(i-l,n+a)}},{key:"setCoordinates",value:function(){if(1===arguments.length){var e=arguments[0];this.setCoordinates(e.p0,e.p1)}else if(2===arguments.length){var t=arguments[0],i=arguments[1];this.p0.x=t.x,this.p0.y=t.y,this.p1.x=i.x,this.p1.y=i.y}}},{key:"segmentFraction",value:function(e){var t=this.projectionFactor(e);return t<0?t=0:(t>1||R.isNaN(t))&&(t=1),t}},{key:"toString",value:function(){return"LINESTRING( "+this.p0.x+" "+this.p0.y+", "+this.p1.x+" "+this.p1.y+")"}},{key:"isHorizontal",value:function(){return this.p0.y===this.p1.y}},{key:"reflect",value:function(e){var t=this.p1.getY()-this.p0.getY(),i=this.p0.getX()-this.p1.getX(),n=this.p0.getY()*(this.p1.getX()-this.p0.getX())-this.p0.getX()*(this.p1.getY()-this.p0.getY()),r=t*t+i*i,o=t*t-i*i,s=e.getX(),a=e.getY();return new V((-o*s-2*t*i*a-2*t*n)/r,(o*a-2*t*i*s-2*i*n)/r)}},{key:"distance",value:function(){if(arguments[0]instanceof e){var t=arguments[0];return be.segmentToSegment(this.p0,this.p1,t.p0,t.p1)}if(arguments[0]instanceof V){var i=arguments[0];return be.pointToSegment(i,this.p0,this.p1)}}},{key:"pointAlong",value:function(e){var t=new V;return t.x=this.p0.x+e*(this.p1.x-this.p0.x),t.y=this.p0.y+e*(this.p1.y-this.p0.y),t}},{key:"hashCode",value:function(){var e=R.doubleToLongBits(this.p0.x);e^=31*R.doubleToLongBits(this.p0.y);var t=Math.trunc(e)^Math.trunc(e>>32),i=R.doubleToLongBits(this.p1.x);return i^=31*R.doubleToLongBits(this.p1.y),t^Math.trunc(i)^Math.trunc(i>>32)}},{key:"interfaces_",get:function(){return[b,E]}}],[{key:"constructor_",value:function(){if(this.p0=null,this.p1=null,0===arguments.length)e.constructor_.call(this,new V,new V);else if(1===arguments.length){var t=arguments[0];e.constructor_.call(this,t.p0,t.p1)}else if(2===arguments.length){var i=arguments[0],n=arguments[1];this.p0=i,this.p1=n}else if(4===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2],a=arguments[3];e.constructor_.call(this,new V(r,o),new V(s,a))}}},{key:"midPoint",value:function(e,t){return new V((e.x+t.x)/2,(e.y+t.y)/2)}}])}(),wi=o(function e(){i(this,e),e.constructor_.apply(this,arguments)},[{key:"overlap",value:function(){if(2!==arguments.length&&4===arguments.length){var e=arguments[1],t=arguments[2],i=arguments[3];arguments[0].getLineSegment(e,this._overlapSeg1),t.getLineSegment(i,this._overlapSeg2),this.overlap(this._overlapSeg1,this._overlapSeg2)}}}],[{key:"constructor_",value:function(){this._overlapSeg1=new bi,this._overlapSeg2=new bi}}]),Ei=o(function e(){i(this,e),e.constructor_.apply(this,arguments)},[{key:"getLineSegment",value:function(e,t){t.p0=this._pts[e],t.p1=this._pts[e+1]}},{key:"computeSelect",value:function(e,t,i,n){var r=this._pts[t],o=this._pts[i];if(i-t==1)return n.select(this,t),null;if(!e.intersects(r,o))return null;var s=Math.trunc((t+i)/2);t<s&&this.computeSelect(e,t,s,n),s<i&&this.computeSelect(e,s,i,n)}},{key:"getCoordinates",value:function(){for(var e=new Array(this._end-this._start+1).fill(null),t=0,i=this._start;i<=this._end;i++)e[t++]=this._pts[i];return e}},{key:"computeOverlaps",value:function(){if(2===arguments.length){var e=arguments[0],t=arguments[1];this.computeOverlaps(this._start,this._end,e,e._start,e._end,t)}else if(6===arguments.length){var i=arguments[0],n=arguments[1],r=arguments[2],o=arguments[3],s=arguments[4],a=arguments[5];if(n-i==1&&s-o==1)return a.overlap(this,i,r,o),null;if(!this.overlaps(i,n,r,o,s))return null;var l=Math.trunc((i+n)/2),c=Math.trunc((o+s)/2);i<l&&(o<c&&this.computeOverlaps(i,l,r,o,c,a),c<s&&this.computeOverlaps(i,l,r,c,s,a)),l<n&&(o<c&&this.computeOverlaps(l,n,r,o,c,a),c<s&&this.computeOverlaps(l,n,r,c,s,a))}}},{key:"setId",value:function(e){this._id=e}},{key:"select",value:function(e,t){this.computeSelect(e,this._start,this._end,t)}},{key:"getEnvelope",value:function(){if(null===this._env){var e=this._pts[this._start],t=this._pts[this._end];this._env=new q(e,t)}return this._env}},{key:"overlaps",value:function(e,t,i,n,r){return q.intersects(this._pts[e],this._pts[t],i._pts[n],i._pts[r])}},{key:"getEndIndex",value:function(){return this._end}},{key:"getStartIndex",value:function(){return this._start}},{key:"getContext",value:function(){return this._context}},{key:"getId",value:function(){return this._id}}],[{key:"constructor_",value:function(){this._pts=null,this._start=null,this._end=null,this._env=null,this._context=null,this._id=null;var e=arguments[0],t=arguments[1],i=arguments[2],n=arguments[3];this._pts=e,this._start=t,this._end=i,this._context=n}}]),Ti=function(){function e(){i(this,e)}return o(e,null,[{key:"findChainEnd",value:function(e,t){for(var i=t;i<e.length-1&&e[i].equals2D(e[i+1]);)i++;if(i>=e.length-1)return e.length-1;for(var n=Wt.quadrant(e[i],e[i+1]),r=t+1;r<e.length&&(e[r-1].equals2D(e[r])||Wt.quadrant(e[r-1],e[r])===n);)r++;return r-1}},{key:"getChains",value:function(){if(1===arguments.length){var t=arguments[0];return e.getChains(t,null)}if(2===arguments.length){var i=arguments[0],n=arguments[1],r=new me,o=0;do{var s=e.findChainEnd(i,o),a=new Ei(i,o,s,n);r.add(a),o=s}while(o<i.length-1);return r}}}])}(),Si=o(function e(){i(this,e)},[{key:"computeNodes",value:function(e){}},{key:"getNodedSubstrings",value:function(){}}]),Ii=o(function e(){i(this,e),e.constructor_.apply(this,arguments)},[{key:"setSegmentIntersector",value:function(e){this._segInt=e}},{key:"interfaces_",get:function(){return[Si]}}],[{key:"constructor_",value:function(){if(this._segInt=null,0!==arguments.length&&1===arguments.length){var e=arguments[0];this.setSegmentIntersector(e)}}}]),ki=function(e){function n(){var e;return i(this,n),e=t(this,n),n.constructor_.apply(e,arguments),e}return c(n,e),o(n,[{key:"getMonotoneChains",value:function(){return this._monoChains}},{key:"getNodedSubstrings",value:function(){return xi.getNodedSubstrings(this._nodedSegStrings)}},{key:"getIndex",value:function(){return this._index}},{key:"add",value:function(e){for(var t=Ti.getChains(e.getCoordinates(),e).iterator();t.hasNext();){var i=t.next();i.setId(this._idCounter++),this._index.insert(i.getEnvelope(),i),this._monoChains.add(i)}}},{key:"computeNodes",value:function(e){this._nodedSegStrings=e;for(var t=e.iterator();t.hasNext();)this.add(t.next());this.intersectChains()}},{key:"intersectChains",value:function(){for(var e=new Mi(this._segInt),t=this._monoChains.iterator();t.hasNext();)for(var i=t.next(),n=this._index.query(i.getEnvelope()).iterator();n.hasNext();){var r=n.next();if(r.getId()>i.getId()&&(i.computeOverlaps(r,e),this._nOverlaps++),this._segInt.isDone())return null}}}],[{key:"constructor_",value:function(){if(this._monoChains=new me,this._index=new hi,this._idCounter=0,this._nodedSegStrings=null,this._nOverlaps=0,0!==arguments.length&&1===arguments.length){var e=arguments[0];Ii.constructor_.call(this,e)}}}])}(Ii),Mi=function(e){function n(){var e;return i(this,n),e=t(this,n),n.constructor_.apply(e,arguments),e}return c(n,e),o(n,[{key:"overlap",value:function(){if(4!==arguments.length)return d(n,"overlap",this,1).apply(this,arguments);var e=arguments[1],t=arguments[2],i=arguments[3],r=arguments[0].getContext(),o=t.getContext();this._si.processIntersections(r,e,o,i)}}],[{key:"constructor_",value:function(){this._si=null;var e=arguments[0];this._si=e}}])}(wi);ki.SegmentOverlapAction=Mi;var Ci=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"isDeletable",value:function(e,t,i,n){var r=this._inputLine[e],o=this._inputLine[t],s=this._inputLine[i];return!!this.isConcave(r,o,s)&&!!this.isShallow(r,o,s,n)&&this.isShallowSampled(r,o,e,i,n)}},{key:"deleteShallowConcavities",value:function(){for(var t=1,i=this.findNextNonDeletedIndex(t),n=this.findNextNonDeletedIndex(i),r=!1;n<this._inputLine.length;){var o=!1;this.isDeletable(t,i,n,this._distanceTol)&&(this._isDeleted[i]=e.DELETE,o=!0,r=!0),t=o?n:i,i=this.findNextNonDeletedIndex(t),n=this.findNextNonDeletedIndex(i)}return r}},{key:"isShallowConcavity",value:function(e,t,i,n){return he.index(e,t,i)===this._angleOrientation&&be.pointToSegment(t,e,i)<n}},{key:"isShallowSampled",value:function(t,i,n,r,o){var s=Math.trunc((r-n)/e.NUM_PTS_TO_CHECK);s<=0&&(s=1);for(var a=n;a<r;a+=s)if(!this.isShallow(t,i,this._inputLine[a],o))return!1;return!0}},{key:"isConcave",value:function(e,t,i){return he.index(e,t,i)===this._angleOrientation}},{key:"simplify",value:function(e){this._distanceTol=Math.abs(e),e<0&&(this._angleOrientation=he.CLOCKWISE),this._isDeleted=new Array(this._inputLine.length).fill(null);var t=!1;do{t=this.deleteShallowConcavities()}while(t);return this.collapseLine()}},{key:"findNextNonDeletedIndex",value:function(t){for(var i=t+1;i<this._inputLine.length&&this._isDeleted[i]===e.DELETE;)i++;return i}},{key:"isShallow",value:function(e,t,i,n){return be.pointToSegment(t,e,i)<n}},{key:"collapseLine",value:function(){for(var t=new He,i=0;i<this._inputLine.length;i++)this._isDeleted[i]!==e.DELETE&&t.add(this._inputLine[i]);return t.toCoordinateArray()}}],[{key:"constructor_",value:function(){this._inputLine=null,this._distanceTol=null,this._isDeleted=null,this._angleOrientation=he.COUNTERCLOCKWISE;var e=arguments[0];this._inputLine=e}},{key:"simplify",value:function(t,i){return new e(t).simplify(i)}}])}();Ci.INIT=0,Ci.DELETE=1,Ci.KEEP=1,Ci.NUM_PTS_TO_CHECK=10;var Pi=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"getCoordinates",value:function(){return this._ptList.toArray(e.COORDINATE_ARRAY_TYPE)}},{key:"setPrecisionModel",value:function(e){this._precisionModel=e}},{key:"addPt",value:function(e){var t=new V(e);if(this._precisionModel.makePrecise(t),this.isRedundant(t))return null;this._ptList.add(t)}},{key:"reverse",value:function(){}},{key:"addPts",value:function(e,t){if(t)for(var i=0;i<e.length;i++)this.addPt(e[i]);else for(var n=e.length-1;n>=0;n--)this.addPt(e[n])}},{key:"isRedundant",value:function(e){if(this._ptList.size()<1)return!1;var t=this._ptList.get(this._ptList.size()-1);return e.distance(t)<this._minimimVertexDistance}},{key:"toString",value:function(){return(new st).createLineString(this.getCoordinates()).toString()}},{key:"closeRing",value:function(){if(this._ptList.size()<1)return null;var e=new V(this._ptList.get(0)),t=this._ptList.get(this._ptList.size()-1);if(e.equals(t))return null;this._ptList.add(e)}},{key:"setMinimumVertexDistance",value:function(e){this._minimimVertexDistance=e}}],[{key:"constructor_",value:function(){this._ptList=null,this._precisionModel=null,this._minimimVertexDistance=0,this._ptList=new me}}])}();Pi.COORDINATE_ARRAY_TYPE=new Array(0).fill(null);var Ai=function(){function e(){i(this,e)}return o(e,null,[{key:"toDegrees",value:function(e){return 180*e/Math.PI}},{key:"normalize",value:function(t){for(;t>Math.PI;)t-=e.PI_TIMES_2;for(;t<=-Math.PI;)t+=e.PI_TIMES_2;return t}},{key:"angle",value:function(){if(1===arguments.length){var e=arguments[0];return Math.atan2(e.y,e.x)}if(2===arguments.length){var t=arguments[0],i=arguments[1],n=i.x-t.x,r=i.y-t.y;return Math.atan2(r,n)}}},{key:"isAcute",value:function(e,t,i){var n=e.x-t.x,r=e.y-t.y;return n*(i.x-t.x)+r*(i.y-t.y)>0}},{key:"isObtuse",value:function(e,t,i){var n=e.x-t.x,r=e.y-t.y;return n*(i.x-t.x)+r*(i.y-t.y)<0}},{key:"interiorAngle",value:function(t,i,n){var r=e.angle(i,t),o=e.angle(i,n);return Math.abs(o-r)}},{key:"normalizePositive",value:function(t){if(t<0){for(;t<0;)t+=e.PI_TIMES_2;t>=e.PI_TIMES_2&&(t=0)}else{for(;t>=e.PI_TIMES_2;)t-=e.PI_TIMES_2;t<0&&(t=0)}return t}},{key:"angleBetween",value:function(t,i,n){var r=e.angle(i,t),o=e.angle(i,n);return e.diff(r,o)}},{key:"diff",value:function(e,t){var i=null;return(i=e<t?t-e:e-t)>Math.PI&&(i=2*Math.PI-i),i}},{key:"toRadians",value:function(e){return e*Math.PI/180}},{key:"getTurn",value:function(t,i){var n=Math.sin(i-t);return n>0?e.COUNTERCLOCKWISE:n<0?e.CLOCKWISE:e.NONE}},{key:"angleBetweenOriented",value:function(t,i,n){var r=e.angle(i,t),o=e.angle(i,n)-r;return o<=-Math.PI?o+e.PI_TIMES_2:o>Math.PI?o-e.PI_TIMES_2:o}}])}();Ai.PI_TIMES_2=2*Math.PI,Ai.PI_OVER_2=Math.PI/2,Ai.PI_OVER_4=Math.PI/4,Ai.COUNTERCLOCKWISE=he.COUNTERCLOCKWISE,Ai.CLOCKWISE=he.CLOCKWISE,Ai.NONE=he.COLLINEAR;var Li=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"addNextSegment",value:function(e,t){if(this._s0=this._s1,this._s1=this._s2,this._s2=e,this._seg0.setCoordinates(this._s0,this._s1),this.computeOffsetSegment(this._seg0,this._side,this._distance,this._offset0),this._seg1.setCoordinates(this._s1,this._s2),this.computeOffsetSegment(this._seg1,this._side,this._distance,this._offset1),this._s1.equals(this._s2))return null;var i=he.index(this._s0,this._s1,this._s2),n=i===he.CLOCKWISE&&this._side===Q.LEFT||i===he.COUNTERCLOCKWISE&&this._side===Q.RIGHT;0===i?this.addCollinear(t):n?this.addOutsideTurn(i,t):this.addInsideTurn(i,t)}},{key:"addLineEndCap",value:function(e,t){var i=new bi(e,t),n=new bi;this.computeOffsetSegment(i,Q.LEFT,this._distance,n);var r=new bi;this.computeOffsetSegment(i,Q.RIGHT,this._distance,r);var o=t.x-e.x,s=t.y-e.y,a=Math.atan2(s,o);switch(this._bufParams.getEndCapStyle()){case y.CAP_ROUND:this._segList.addPt(n.p1),this.addDirectedFillet(t,a+Math.PI/2,a-Math.PI/2,he.CLOCKWISE,this._distance),this._segList.addPt(r.p1);break;case y.CAP_FLAT:this._segList.addPt(n.p1),this._segList.addPt(r.p1);break;case y.CAP_SQUARE:var l=new V;l.x=Math.abs(this._distance)*Math.cos(a),l.y=Math.abs(this._distance)*Math.sin(a);var c=new V(n.p1.x+l.x,n.p1.y+l.y),u=new V(r.p1.x+l.x,r.p1.y+l.y);this._segList.addPt(c),this._segList.addPt(u)}}},{key:"getCoordinates",value:function(){return this._segList.getCoordinates()}},{key:"addMitreJoin",value:function(e,t,i,n){var r=_e.intersection(t.p0,t.p1,i.p0,i.p1);if(null!==r&&(n<=0?1:r.distance(e)/Math.abs(n))<=this._bufParams.getMitreLimit())return this._segList.addPt(r),null;this.addLimitedMitreJoin(t,i,n,this._bufParams.getMitreLimit())}},{key:"addOutsideTurn",value:function(t,i){if(this._offset0.p1.distance(this._offset1.p0)<this._distance*e.OFFSET_SEGMENT_SEPARATION_FACTOR)return this._segList.addPt(this._offset0.p1),null;this._bufParams.getJoinStyle()===y.JOIN_MITRE?this.addMitreJoin(this._s1,this._offset0,this._offset1,this._distance):this._bufParams.getJoinStyle()===y.JOIN_BEVEL?this.addBevelJoin(this._offset0,this._offset1):(i&&this._segList.addPt(this._offset0.p1),this.addCornerFillet(this._s1,this._offset0.p1,this._offset1.p0,t,this._distance),this._segList.addPt(this._offset1.p0))}},{key:"createSquare",value:function(e){this._segList.addPt(new V(e.x+this._distance,e.y+this._distance)),this._segList.addPt(new V(e.x+this._distance,e.y-this._distance)),this._segList.addPt(new V(e.x-this._distance,e.y-this._distance)),this._segList.addPt(new V(e.x-this._distance,e.y+this._distance)),this._segList.closeRing()}},{key:"addSegments",value:function(e,t){this._segList.addPts(e,t)}},{key:"addFirstSegment",value:function(){this._segList.addPt(this._offset1.p0)}},{key:"addCornerFillet",value:function(e,t,i,n,r){var o=t.x-e.x,s=t.y-e.y,a=Math.atan2(s,o),l=i.x-e.x,c=i.y-e.y,u=Math.atan2(c,l);n===he.CLOCKWISE?a<=u&&(a+=2*Math.PI):a>=u&&(a-=2*Math.PI),this._segList.addPt(t),this.addDirectedFillet(e,a,u,n,r),this._segList.addPt(i)}},{key:"addLastSegment",value:function(){this._segList.addPt(this._offset1.p1)}},{key:"initSideSegments",value:function(e,t,i){this._s1=e,this._s2=t,this._side=i,this._seg1.setCoordinates(e,t),this.computeOffsetSegment(this._seg1,i,this._distance,this._offset1)}},{key:"addLimitedMitreJoin",value:function(e,t,i,n){var r=this._seg0.p1,o=Ai.angle(r,this._seg0.p0),s=Ai.angleBetweenOriented(this._seg0.p0,r,this._seg1.p1)/2,a=Ai.normalize(o+s),l=Ai.normalize(a+Math.PI),c=n*i,u=i-c*Math.abs(Math.sin(s)),h=r.x+c*Math.cos(l),d=r.y+c*Math.sin(l),p=new V(h,d),f=new bi(r,p),m=f.pointAlongOffset(1,u),g=f.pointAlongOffset(1,-u);this._side===Q.LEFT?(this._segList.addPt(m),this._segList.addPt(g)):(this._segList.addPt(g),this._segList.addPt(m))}},{key:"addDirectedFillet",value:function(e,t,i,n,r){var o=n===he.CLOCKWISE?-1:1,s=Math.abs(t-i),a=Math.trunc(s/this._filletAngleQuantum+.5);if(a<1)return null;for(var l=s/a,c=new V,u=0;u<a;u++){var h=t+o*u*l;c.x=e.x+r*Math.cos(h),c.y=e.y+r*Math.sin(h),this._segList.addPt(c)}}},{key:"computeOffsetSegment",value:function(e,t,i,n){var r=t===Q.LEFT?1:-1,o=e.p1.x-e.p0.x,s=e.p1.y-e.p0.y,a=Math.sqrt(o*o+s*s),l=r*i*o/a,c=r*i*s/a;n.p0.x=e.p0.x-c,n.p0.y=e.p0.y+l,n.p1.x=e.p1.x-c,n.p1.y=e.p1.y+l}},{key:"addInsideTurn",value:function(t,i){if(this._li.computeIntersection(this._offset0.p0,this._offset0.p1,this._offset1.p0,this._offset1.p1),this._li.hasIntersection())this._segList.addPt(this._li.getIntersection(0));else if(this._hasNarrowConcaveAngle=!0,this._offset0.p1.distance(this._offset1.p0)<this._distance*e.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR)this._segList.addPt(this._offset0.p1);else{if(this._segList.addPt(this._offset0.p1),this._closingSegLengthFactor>0){var n=new V((this._closingSegLengthFactor*this._offset0.p1.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset0.p1.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(n);var r=new V((this._closingSegLengthFactor*this._offset1.p0.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset1.p0.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(r)}else this._segList.addPt(this._s1);this._segList.addPt(this._offset1.p0)}}},{key:"createCircle",value:function(e){var t=new V(e.x+this._distance,e.y);this._segList.addPt(t),this.addDirectedFillet(e,0,2*Math.PI,-1,this._distance),this._segList.closeRing()}},{key:"addBevelJoin",value:function(e,t){this._segList.addPt(e.p1),this._segList.addPt(t.p0)}},{key:"init",value:function(t){this._distance=t,this._maxCurveSegmentError=t*(1-Math.cos(this._filletAngleQuantum/2)),this._segList=new Pi,this._segList.setPrecisionModel(this._precisionModel),this._segList.setMinimumVertexDistance(t*e.CURVE_VERTEX_SNAP_DISTANCE_FACTOR)}},{key:"addCollinear",value:function(e){this._li.computeIntersection(this._s0,this._s1,this._s1,this._s2),this._li.getIntersectionNum()>=2&&(this._bufParams.getJoinStyle()===y.JOIN_BEVEL||this._bufParams.getJoinStyle()===y.JOIN_MITRE?(e&&this._segList.addPt(this._offset0.p1),this._segList.addPt(this._offset1.p0)):this.addCornerFillet(this._s1,this._offset0.p1,this._offset1.p0,he.CLOCKWISE,this._distance))}},{key:"closeRing",value:function(){this._segList.closeRing()}},{key:"hasNarrowConcaveAngle",value:function(){return this._hasNarrowConcaveAngle}}],[{key:"constructor_",value:function(){this._maxCurveSegmentError=0,this._filletAngleQuantum=null,this._closingSegLengthFactor=1,this._segList=null,this._distance=0,this._precisionModel=null,this._bufParams=null,this._li=null,this._s0=null,this._s1=null,this._s2=null,this._seg0=new bi,this._seg1=new bi,this._offset0=new bi,this._offset1=new bi,this._side=0,this._hasNarrowConcaveAngle=!1;var t=arguments[0],i=arguments[1],n=arguments[2];this._precisionModel=t,this._bufParams=i,this._li=new Pt,this._filletAngleQuantum=Math.PI/2/i.getQuadrantSegments(),i.getQuadrantSegments()>=8&&i.getJoinStyle()===y.JOIN_ROUND&&(this._closingSegLengthFactor=e.MAX_CLOSING_SEG_LEN_FACTOR),this.init(n)}}])}();Li.OFFSET_SEGMENT_SEPARATION_FACTOR=.001,Li.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR=.001,Li.CURVE_VERTEX_SNAP_DISTANCE_FACTOR=1e-6,Li.MAX_CLOSING_SEG_LEN_FACTOR=80;var Di=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"getOffsetCurve",value:function(e,t){if(this._distance=t,0===t)return null;var i=t<0,n=Math.abs(t),r=this.getSegGen(n);e.length<=1?this.computePointCurve(e[0],r):this.computeOffsetCurve(e,i,r);var o=r.getCoordinates();return i&&We.reverse(o),o}},{key:"computeSingleSidedBufferCurve",value:function(e,t,i){var n=this.simplifyTolerance(this._distance);if(t){i.addSegments(e,!0);var r=Ci.simplify(e,-n),o=r.length-1;i.initSideSegments(r[o],r[o-1],Q.LEFT),i.addFirstSegment();for(var s=o-2;s>=0;s--)i.addNextSegment(r[s],!0)}else{i.addSegments(e,!1);var a=Ci.simplify(e,n),l=a.length-1;i.initSideSegments(a[0],a[1],Q.LEFT),i.addFirstSegment();for(var c=2;c<=l;c++)i.addNextSegment(a[c],!0)}i.addLastSegment(),i.closeRing()}},{key:"computeRingBufferCurve",value:function(e,t,i){var n=this.simplifyTolerance(this._distance);t===Q.RIGHT&&(n=-n);var r=Ci.simplify(e,n),o=r.length-1;i.initSideSegments(r[o-1],r[0],t);for(var s=1;s<=o;s++){var a=1!==s;i.addNextSegment(r[s],a)}i.closeRing()}},{key:"computeLineBufferCurve",value:function(e,t){var i=this.simplifyTolerance(this._distance),n=Ci.simplify(e,i),r=n.length-1;t.initSideSegments(n[0],n[1],Q.LEFT);for(var o=2;o<=r;o++)t.addNextSegment(n[o],!0);t.addLastSegment(),t.addLineEndCap(n[r-1],n[r]);var s=Ci.simplify(e,-i),a=s.length-1;t.initSideSegments(s[a],s[a-1],Q.LEFT);for(var l=a-2;l>=0;l--)t.addNextSegment(s[l],!0);t.addLastSegment(),t.addLineEndCap(s[1],s[0]),t.closeRing()}},{key:"computePointCurve",value:function(e,t){switch(this._bufParams.getEndCapStyle()){case y.CAP_ROUND:t.createCircle(e);break;case y.CAP_SQUARE:t.createSquare(e)}}},{key:"getLineCurve",value:function(e,t){if(this._distance=t,this.isLineOffsetEmpty(t))return null;var i=Math.abs(t),n=this.getSegGen(i);if(e.length<=1)this.computePointCurve(e[0],n);else if(this._bufParams.isSingleSided()){var r=t<0;this.computeSingleSidedBufferCurve(e,r,n)}else this.computeLineBufferCurve(e,n);return n.getCoordinates()}},{key:"getBufferParameters",value:function(){return this._bufParams}},{key:"simplifyTolerance",value:function(e){return e*this._bufParams.getSimplifyFactor()}},{key:"getRingCurve",value:function(t,i,n){if(this._distance=n,t.length<=2)return this.getLineCurve(t,n);if(0===n)return e.copyCoordinates(t);var r=this.getSegGen(n);return this.computeRingBufferCurve(t,i,r),r.getCoordinates()}},{key:"computeOffsetCurve",value:function(e,t,i){var n=this.simplifyTolerance(this._distance);if(t){var r=Ci.simplify(e,-n),o=r.length-1;i.initSideSegments(r[o],r[o-1],Q.LEFT),i.addFirstSegment();for(var s=o-2;s>=0;s--)i.addNextSegment(r[s],!0)}else{var a=Ci.simplify(e,n),l=a.length-1;i.initSideSegments(a[0],a[1],Q.LEFT),i.addFirstSegment();for(var c=2;c<=l;c++)i.addNextSegment(a[c],!0)}i.addLastSegment()}},{key:"isLineOffsetEmpty",value:function(e){return 0===e||e<0&&!this._bufParams.isSingleSided()}},{key:"getSegGen",value:function(e){return new Li(this._precisionModel,this._bufParams,e)}}],[{key:"constructor_",value:function(){this._distance=0,this._precisionModel=null,this._bufParams=null;var e=arguments[0],t=arguments[1];this._precisionModel=e,this._bufParams=t}},{key:"copyCoordinates",value:function(e){for(var t=new Array(e.length).fill(null),i=0;i<t.length;i++)t[i]=new V(e[i]);return t}}])}(),Ri=o(function e(){i(this,e),e.constructor_.apply(this,arguments)},[{key:"findStabbedSegments",value:function(){if(1===arguments.length){for(var e=arguments[0],t=new me,i=this._subgraphs.iterator();i.hasNext();){var n=i.next(),r=n.getEnvelope();e.y<r.getMinY()||e.y>r.getMaxY()||this.findStabbedSegments(e,n.getDirectedEdges(),t)}return t}if(3===arguments.length)if(re(arguments[2],ie)&&arguments[0]instanceof V&&arguments[1]instanceof Yt){for(var o=arguments[0],s=arguments[1],a=arguments[2],l=s.getEdge().getCoordinates(),c=0;c<l.length-1;c++)if(this._seg.p0=l[c],this._seg.p1=l[c+1],this._seg.p0.y>this._seg.p1.y&&this._seg.reverse(),!(Math.max(this._seg.p0.x,this._seg.p1.x)<o.x||this._seg.isHorizontal()||o.y<this._seg.p0.y||o.y>this._seg.p1.y||he.index(this._seg.p0,this._seg.p1,o)===he.RIGHT)){var u=s.getDepth(Q.LEFT);this._seg.p0.equals(l[c])||(u=s.getDepth(Q.RIGHT));var h=new zi(this._seg,u);a.add(h)}}else if(re(arguments[2],ie)&&arguments[0]instanceof V&&re(arguments[1],ie))for(var d=arguments[0],p=arguments[2],f=arguments[1].iterator();f.hasNext();){var m=f.next();m.isForward()&&this.findStabbedSegments(d,m,p)}}},{key:"getDepth",value:function(e){var t=this.findStabbedSegments(e);return 0===t.size()?0:oi.min(t)._leftDepth}}],[{key:"constructor_",value:function(){this._subgraphs=null,this._seg=new bi;var e=arguments[0];this._subgraphs=e}}]),zi=o(function e(){i(this,e),e.constructor_.apply(this,arguments)},[{key:"compareTo",value:function(e){var t=e;if(this._upwardSeg.minX()>=t._upwardSeg.maxX())return 1;if(this._upwardSeg.maxX()<=t._upwardSeg.minX())return-1;var i=this._upwardSeg.orientationIndex(t._upwardSeg);return 0!==i||0!=(i=-1*t._upwardSeg.orientationIndex(this._upwardSeg))?i:this._upwardSeg.compareTo(t._upwardSeg)}},{key:"compareX",value:function(e,t){var i=e.p0.compareTo(t.p0);return 0!==i?i:e.p1.compareTo(t.p1)}},{key:"toString",value:function(){return this._upwardSeg.toString()}},{key:"interfaces_",get:function(){return[b]}}],[{key:"constructor_",value:function(){this._upwardSeg=null,this._leftDepth=null;var e=arguments[0],t=arguments[1];this._upwardSeg=new bi(e),this._leftDepth=t}}]);Ri.DepthSegment=zi;var Fi=function(e){function n(){var e;return i(this,n),e=t(this,n),n.constructor_.apply(e,arguments),e}return c(n,e),o(n,null,[{key:"constructor_",value:function(){_.constructor_.call(this,"Projective point not representable on the Cartesian plane.")}}])}(_),Oi=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"getY",value:function(){var e=this.y/this.w;if(R.isNaN(e)||R.isInfinite(e))throw new Fi;return e}},{key:"getX",value:function(){var e=this.x/this.w;if(R.isNaN(e)||R.isInfinite(e))throw new Fi;return e}},{key:"getCoordinate",value:function(){var e=new V;return e.x=this.getX(),e.y=this.getY(),e}}],[{key:"constructor_",value:function(){if(this.x=null,this.y=null,this.w=null,0===arguments.length)this.x=0,this.y=0,this.w=1;else if(1===arguments.length){var t=arguments[0];this.x=t.x,this.y=t.y,this.w=1}else if(2===arguments.length){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var i=arguments[0],n=arguments[1];this.x=i,this.y=n,this.w=1}else if(arguments[0]instanceof e&&arguments[1]instanceof e){var r=arguments[0],o=arguments[1];this.x=r.y*o.w-o.y*r.w,this.y=o.x*r.w-r.x*o.w,this.w=r.x*o.y-o.x*r.y}else if(arguments[0]instanceof V&&arguments[1]instanceof V){var s=arguments[0],a=arguments[1];this.x=s.y-a.y,this.y=a.x-s.x,this.w=s.x*a.y-a.x*s.y}}else if(3===arguments.length){var l=arguments[0],c=arguments[1],u=arguments[2];this.x=l,this.y=c,this.w=u}else if(4===arguments.length){var h=arguments[0],d=arguments[1],p=arguments[2],f=arguments[3],m=h.y-d.y,g=d.x-h.x,y=h.x*d.y-d.x*h.y,_=p.y-f.y,v=f.x-p.x,x=p.x*f.y-f.x*p.y;this.x=g*x-v*y,this.y=_*y-m*x,this.w=m*v-_*g}}}])}(),Ni=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"area",value:function(){return e.area(this.p0,this.p1,this.p2)}},{key:"signedArea",value:function(){return e.signedArea(this.p0,this.p1,this.p2)}},{key:"interpolateZ",value:function(t){if(null===t)throw new v("Supplied point is null.");return e.interpolateZ(t,this.p0,this.p1,this.p2)}},{key:"longestSideLength",value:function(){return e.longestSideLength(this.p0,this.p1,this.p2)}},{key:"isAcute",value:function(){return e.isAcute(this.p0,this.p1,this.p2)}},{key:"circumcentre",value:function(){return e.circumcentre(this.p0,this.p1,this.p2)}},{key:"area3D",value:function(){return e.area3D(this.p0,this.p1,this.p2)}},{key:"centroid",value:function(){return e.centroid(this.p0,this.p1,this.p2)}},{key:"inCentre",value:function(){return e.inCentre(this.p0,this.p1,this.p2)}}],[{key:"constructor_",value:function(){this.p0=null,this.p1=null,this.p2=null;var e=arguments[0],t=arguments[1],i=arguments[2];this.p0=e,this.p1=t,this.p2=i}},{key:"area",value:function(e,t,i){return Math.abs(((i.x-e.x)*(t.y-e.y)-(t.x-e.x)*(i.y-e.y))/2)}},{key:"signedArea",value:function(e,t,i){return((i.x-e.x)*(t.y-e.y)-(t.x-e.x)*(i.y-e.y))/2}},{key:"det",value:function(e,t,i,n){return e*n-t*i}},{key:"interpolateZ",value:function(e,t,i,n){var r=t.x,o=t.y,s=i.x-r,a=n.x-r,l=i.y-o,c=n.y-o,u=s*c-a*l,h=e.x-r,d=e.y-o,p=(c*h-a*d)/u,f=(-l*h+s*d)/u;return t.getZ()+p*(i.getZ()-t.getZ())+f*(n.getZ()-t.getZ())}},{key:"longestSideLength",value:function(e,t,i){var n=e.distance(t),r=t.distance(i),o=i.distance(e),s=n;return r>s&&(s=r),o>s&&(s=o),s}},{key:"circumcentreDD",value:function(e,t,i){var n=le.valueOf(e.x).subtract(i.x),r=le.valueOf(e.y).subtract(i.y),o=le.valueOf(t.x).subtract(i.x),s=le.valueOf(t.y).subtract(i.y),a=le.determinant(n,r,o,s).multiply(2),l=n.sqr().add(r.sqr()),c=o.sqr().add(s.sqr()),u=le.determinant(r,l,s,c),h=le.determinant(n,l,o,c),d=le.valueOf(i.x).subtract(u.divide(a)).doubleValue(),p=le.valueOf(i.y).add(h.divide(a)).doubleValue();return new V(d,p)}},{key:"isAcute",value:function(e,t,i){return!!Ai.isAcute(e,t,i)&&!!Ai.isAcute(t,i,e)&&!!Ai.isAcute(i,e,t)}},{key:"circumcentre",value:function(t,i,n){var r=n.x,o=n.y,s=t.x-r,a=t.y-o,l=i.x-r,c=i.y-o,u=2*e.det(s,a,l,c),h=e.det(a,s*s+a*a,c,l*l+c*c),d=e.det(s,s*s+a*a,l,l*l+c*c);return new V(r-h/u,o+d/u)}},{key:"perpendicularBisector",value:function(e,t){var i=t.x-e.x,n=t.y-e.y,r=new Oi(e.x+i/2,e.y+n/2,1),o=new Oi(e.x-n+i/2,e.y+i+n/2,1);return new Oi(r,o)}},{key:"angleBisector",value:function(e,t,i){var n=t.distance(e),r=n/(n+t.distance(i)),o=i.x-e.x,s=i.y-e.y;return new V(e.x+r*o,e.y+r*s)}},{key:"area3D",value:function(e,t,i){var n=t.x-e.x,r=t.y-e.y,o=t.getZ()-e.getZ(),s=i.x-e.x,a=i.y-e.y,l=i.getZ()-e.getZ(),c=r*l-o*a,u=o*s-n*l,h=n*a-r*s,d=c*c+u*u+h*h;return Math.sqrt(d)/2}},{key:"centroid",value:function(e,t,i){var n=(e.x+t.x+i.x)/3,r=(e.y+t.y+i.y)/3;return new V(n,r)}},{key:"inCentre",value:function(e,t,i){var n=t.distance(i),r=e.distance(i),o=e.distance(t),s=n+r+o,a=(n*e.x+r*t.x+o*i.x)/s,l=(n*e.y+r*t.y+o*i.y)/s;return new V(a,l)}}])}(),Bi=o(function e(){i(this,e),e.constructor_.apply(this,arguments)},[{key:"addRingSide",value:function(e,t,i,n,r){if(0===t&&e.length<Ve.MINIMUM_VALID_SIZE)return null;var o=n,s=r;e.length>=Ve.MINIMUM_VALID_SIZE&&he.isCCW(e)&&(o=r,s=n,i=Q.opposite(i));var a=this._curveBuilder.getRingCurve(e,i,t);this.addCurve(a,o,s)}},{key:"addRingBothSides",value:function(e,t){this.addRingSide(e,t,Q.LEFT,$.EXTERIOR,$.INTERIOR),this.addRingSide(e,t,Q.RIGHT,$.INTERIOR,$.EXTERIOR)}},{key:"addPoint",value:function(e){if(this._distance<=0)return null;var t=e.getCoordinates(),i=this._curveBuilder.getLineCurve(t,this._distance);this.addCurve(i,$.EXTERIOR,$.INTERIOR)}},{key:"addPolygon",value:function(e){var t=this._distance,i=Q.LEFT;this._distance<0&&(t=-this._distance,i=Q.RIGHT);var n=e.getExteriorRing(),r=We.removeRepeatedPoints(n.getCoordinates());if(this._distance<0&&this.isErodedCompletely(n,this._distance)||this._distance<=0&&r.length<3)return null;this.addRingSide(r,t,i,$.EXTERIOR,$.INTERIOR);for(var o=0;o<e.getNumInteriorRing();o++){var s=e.getInteriorRingN(o),a=We.removeRepeatedPoints(s.getCoordinates());this._distance>0&&this.isErodedCompletely(s,-this._distance)||this.addRingSide(a,t,Q.opposite(i),$.INTERIOR,$.EXTERIOR)}}},{key:"isTriangleErodedCompletely",value:function(e,t){var i=new Ni(e[0],e[1],e[2]),n=i.inCentre();return be.pointToSegment(n,i.p0,i.p1)<Math.abs(t)}},{key:"addLineString",value:function(e){if(this._curveBuilder.isLineOffsetEmpty(this._distance))return null;var t=We.removeRepeatedPoints(e.getCoordinates());if(We.isRing(t)&&!this._curveBuilder.getBufferParameters().isSingleSided())this.addRingBothSides(t,this._distance);else{var i=this._curveBuilder.getLineCurve(t,this._distance);this.addCurve(i,$.EXTERIOR,$.INTERIOR)}}},{key:"addCurve",value:function(e,t,i){if(null===e||e.length<2)return null;var n=new xi(e,new Rt(0,$.BOUNDARY,t,i));this._curveList.add(n)}},{key:"getCurves",value:function(){return this.add(this._inputGeom),this._curveList}},{key:"add",value:function(e){if(e.isEmpty())return null;if(e instanceof Fe)this.addPolygon(e);else if(e instanceof Pe)this.addLineString(e);else if(e instanceof Le)this.addPoint(e);else if(e instanceof je)this.addCollection(e);else if(e instanceof ot)this.addCollection(e);else if(e instanceof et)this.addCollection(e);else{if(!(e instanceof Ge))throw new X(e.getGeometryType());this.addCollection(e)}}},{key:"isErodedCompletely",value:function(e,t){var i=e.getCoordinates();if(i.length<4)return t<0;if(4===i.length)return this.isTriangleErodedCompletely(i,t);var n=e.getEnvelopeInternal(),r=Math.min(n.getHeight(),n.getWidth());return t<0&&2*Math.abs(t)>r}},{key:"addCollection",value:function(e){for(var t=0;t<e.getNumGeometries();t++){var i=e.getGeometryN(t);this.add(i)}}}],[{key:"constructor_",value:function(){this._inputGeom=null,this._distance=null,this._curveBuilder=null,this._curveList=new me;var e=arguments[0],t=arguments[1],i=arguments[2];this._inputGeom=e,this._distance=t,this._curveBuilder=i}}]),Gi=o(function e(){i(this,e)},[{key:"locate",value:function(e){}}]),ji=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"next",value:function(){if(this._atStart)return this._atStart=!1,e.isAtomic(this._parent)&&this._index++,this._parent;if(null!==this._subcollectionIterator){if(this._subcollectionIterator.hasNext())return this._subcollectionIterator.next();this._subcollectionIterator=null}if(this._index>=this._max)throw new W;var t=this._parent.getGeometryN(this._index++);return t instanceof Ge?(this._subcollectionIterator=new e(t),this._subcollectionIterator.next()):t}},{key:"remove",value:function(){throw new X(this.getClass().getName())}},{key:"hasNext",value:function(){if(this._atStart)return!0;if(null!==this._subcollectionIterator){if(this._subcollectionIterator.hasNext())return!0;this._subcollectionIterator=null}return!(this._index>=this._max)}},{key:"interfaces_",get:function(){return[mi]}}],[{key:"constructor_",value:function(){this._parent=null,this._atStart=null,this._max=null,this._index=null,this._subcollectionIterator=null;var e=arguments[0];this._parent=e,this._atStart=!0,this._index=0,this._max=e.getNumGeometries()}},{key:"isAtomic",value:function(e){return!(e instanceof Ge)}}])}(),Vi=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"locate",value:function(t){return e.locate(t,this._geom)}},{key:"interfaces_",get:function(){return[Gi]}}],[{key:"constructor_",value:function(){this._geom=null;var e=arguments[0];this._geom=e}},{key:"locatePointInPolygon",value:function(t,i){if(i.isEmpty())return $.EXTERIOR;var n=i.getExteriorRing(),r=e.locatePointInRing(t,n);if(r!==$.INTERIOR)return r;for(var o=0;o<i.getNumInteriorRing();o++){var s=i.getInteriorRingN(o),a=e.locatePointInRing(t,s);if(a===$.BOUNDARY)return $.BOUNDARY;if(a===$.INTERIOR)return $.EXTERIOR}return $.INTERIOR}},{key:"locatePointInRing",value:function(e,t){return t.getEnvelopeInternal().intersects(e)?Lt.locateInRing(e,t.getCoordinates()):$.EXTERIOR}},{key:"containsPointInPolygon",value:function(t,i){return $.EXTERIOR!==e.locatePointInPolygon(t,i)}},{key:"locateInGeometry",value:function(t,i){if(i instanceof Fe)return e.locatePointInPolygon(t,i);if(i instanceof Ge)for(var n=new ji(i);n.hasNext();){var r=n.next();if(r!==i){var o=e.locateInGeometry(t,r);if(o!==$.EXTERIOR)return o}}return $.EXTERIOR}},{key:"isContained",value:function(t,i){return $.EXTERIOR!==e.locate(t,i)}},{key:"locate",value:function(t,i){return i.isEmpty()?$.EXTERIOR:i.getEnvelopeInternal().intersects(t)?e.locateInGeometry(t,i):$.EXTERIOR}}])}(),Ui=o(function e(){i(this,e),e.constructor_.apply(this,arguments)},[{key:"getNextCW",value:function(e){this.getEdges();var t=this._edgeList.indexOf(e),i=t-1;return 0===t&&(i=this._edgeList.size()-1),this._edgeList.get(i)}},{key:"propagateSideLabels",value:function(e){for(var t=$.NONE,i=this.iterator();i.hasNext();){var n=i.next().getLabel();n.isArea(e)&&n.getLocation(e,Q.LEFT)!==$.NONE&&(t=n.getLocation(e,Q.LEFT))}if(t===$.NONE)return null;for(var r=t,o=this.iterator();o.hasNext();){var s=o.next(),a=s.getLabel();if(a.getLocation(e,Q.ON)===$.NONE&&a.setLocation(e,Q.ON,r),a.isArea(e)){var l=a.getLocation(e,Q.LEFT),c=a.getLocation(e,Q.RIGHT);if(c!==$.NONE){if(c!==r)throw new pe("side location conflict",s.getCoordinate());l===$.NONE&&N.shouldNeverReachHere("found single null side (at "+s.getCoordinate()+")"),r=l}else N.isTrue(a.getLocation(e,Q.LEFT)===$.NONE,"found single null side"),a.setLocation(e,Q.RIGHT,r),a.setLocation(e,Q.LEFT,r)}}}},{key:"getCoordinate",value:function(){var e=this.iterator();return e.hasNext()?e.next().getCoordinate():null}},{key:"print",value:function(e){ve.out.println("EdgeEndStar: "+this.getCoordinate());for(var t=this.iterator();t.hasNext();)t.next().print(e)}},{key:"isAreaLabelsConsistent",value:function(e){return this.computeEdgeEndLabels(e.getBoundaryNodeRule()),this.checkAreaLabelsConsistent(0)}},{key:"checkAreaLabelsConsistent",value:function(e){var t=this.getEdges();if(t.size()<=0)return!0;var i=t.size()-1,n=t.get(i).getLabel().getLocation(e,Q.LEFT);N.isTrue(n!==$.NONE,"Found unlabelled area edge");for(var r=n,o=this.iterator();o.hasNext();){var s=o.next().getLabel();N.isTrue(s.isArea(e),"Found non-area edge");var a=s.getLocation(e,Q.LEFT),l=s.getLocation(e,Q.RIGHT);if(a===l||l!==r)return!1;r=a}return!0}},{key:"findIndex",value:function(e){this.iterator();for(var t=0;t<this._edgeList.size();t++)if(this._edgeList.get(t)===e)return t;return-1}},{key:"iterator",value:function(){return this.getEdges().iterator()}},{key:"getEdges",value:function(){return null===this._edgeList&&(this._edgeList=new me(this._edgeMap.values())),this._edgeList}},{key:"getLocation",value:function(e,t,i){return this._ptInAreaLocation[e]===$.NONE&&(this._ptInAreaLocation[e]=Vi.locate(t,i[e].getGeometry())),this._ptInAreaLocation[e]}},{key:"toString",value:function(){var e=new oe;e.append("EdgeEndStar: "+this.getCoordinate()),e.append("\n");for(var t=this.iterator();t.hasNext();){var i=t.next();e.append(i),e.append("\n")}return e.toString()}},{key:"computeEdgeEndLabels",value:function(e){for(var t=this.iterator();t.hasNext();)t.next().computeLabel(e)}},{key:"computeLabelling",value:function(e){this.computeEdgeEndLabels(e[0].getBoundaryNodeRule()),this.propagateSideLabels(0),this.propagateSideLabels(1);for(var t=[!1,!1],i=this.iterator();i.hasNext();)for(var n=i.next().getLabel(),r=0;r<2;r++)n.isLine(r)&&n.getLocation(r)===$.BOUNDARY&&(t[r]=!0);for(var o=this.iterator();o.hasNext();)for(var s=o.next(),a=s.getLabel(),l=0;l<2;l++)if(a.isAnyNull(l)){var c=$.NONE;if(t[l])c=$.EXTERIOR;else{var u=s.getCoordinate();c=this.getLocation(l,u,e)}a.setAllLocationsIfNull(l,c)}}},{key:"getDegree",value:function(){return this._edgeMap.size()}},{key:"insertEdgeEnd",value:function(e,t){this._edgeMap.put(e,t),this._edgeList=null}}],[{key:"constructor_",value:function(){this._edgeMap=new $t,this._edgeList=null,this._ptInAreaLocation=[$.NONE,$.NONE]}}]),qi=function(e){function n(){var e;return i(this,n),e=t(this,n),n.constructor_.apply(e,arguments),e}return c(n,e),o(n,[{key:"linkResultDirectedEdges",value:function(){this.getResultAreaEdges();for(var e=null,t=null,i=this._SCANNING_FOR_INCOMING,n=0;n<this._resultAreaEdgeList.size();n++){var r=this._resultAreaEdgeList.get(n),o=r.getSym();if(r.getLabel().isArea())switch(null===e&&r.isInResult()&&(e=r),i){case this._SCANNING_FOR_INCOMING:if(!o.isInResult())continue;t=o,i=this._LINKING_TO_OUTGOING;break;case this._LINKING_TO_OUTGOING:if(!r.isInResult())continue;t.setNext(r),i=this._SCANNING_FOR_INCOMING}}if(i===this._LINKING_TO_OUTGOING){if(null===e)throw new pe("no outgoing dirEdge found",this.getCoordinate());N.isTrue(e.isInResult(),"unable to link last incoming dirEdge"),t.setNext(e)}}},{key:"insert",value:function(e){var t=e;this.insertEdgeEnd(t,t)}},{key:"getRightmostEdge",value:function(){var e=this.getEdges(),t=e.size();if(t<1)return null;var i=e.get(0);if(1===t)return i;var n=e.get(t-1),r=i.getQuadrant(),o=n.getQuadrant();return Wt.isNorthern(r)&&Wt.isNorthern(o)?i:Wt.isNorthern(r)||Wt.isNorthern(o)?0!==i.getDy()?i:0!==n.getDy()?n:(N.shouldNeverReachHere("found two horizontal edges incident on node"),null):n}},{key:"print",value:function(e){ve.out.println("DirectedEdgeStar: "+this.getCoordinate());for(var t=this.iterator();t.hasNext();){var i=t.next();e.print("out "),i.print(e),e.println(),e.print("in "),i.getSym().print(e),e.println()}}},{key:"getResultAreaEdges",value:function(){if(null!==this._resultAreaEdgeList)return this._resultAreaEdgeList;this._resultAreaEdgeList=new me;for(var e=this.iterator();e.hasNext();){var t=e.next();(t.isInResult()||t.getSym().isInResult())&&this._resultAreaEdgeList.add(t)}return this._resultAreaEdgeList}},{key:"updateLabelling",value:function(e){for(var t=this.iterator();t.hasNext();){var i=t.next().getLabel();i.setAllLocationsIfNull(0,e.getLocation(0)),i.setAllLocationsIfNull(1,e.getLocation(1))}}},{key:"linkAllDirectedEdges",value:function(){this.getEdges();for(var e=null,t=null,i=this._edgeList.size()-1;i>=0;i--){var n=this._edgeList.get(i),r=n.getSym();null===t&&(t=r),null!==e&&r.setNext(e),e=n}t.setNext(e)}},{key:"computeDepths",value:function(){if(1===arguments.length){var e=arguments[0],t=this.findIndex(e),i=e.getDepth(Q.LEFT),n=e.getDepth(Q.RIGHT),r=this.computeDepths(t+1,this._edgeList.size(),i);if(this.computeDepths(0,t,r)!==n)throw new pe("depth mismatch at "+e.getCoordinate())}else if(3===arguments.length){for(var o=arguments[1],s=arguments[2],a=arguments[0];a<o;a++){var l=this._edgeList.get(a);l.setEdgeDepths(Q.RIGHT,s),s=l.getDepth(Q.LEFT)}return s}}},{key:"mergeSymLabels",value:function(){for(var e=this.iterator();e.hasNext();){var t=e.next();t.getLabel().merge(t.getSym().getLabel())}}},{key:"linkMinimalDirectedEdges",value:function(e){for(var t=null,i=null,n=this._SCANNING_FOR_INCOMING,r=this._resultAreaEdgeList.size()-1;r>=0;r--){var o=this._resultAreaEdgeList.get(r),s=o.getSym();switch(null===t&&o.getEdgeRing()===e&&(t=o),n){case this._SCANNING_FOR_INCOMING:if(s.getEdgeRing()!==e)continue;i=s,n=this._LINKING_TO_OUTGOING;break;case this._LINKING_TO_OUTGOING:if(o.getEdgeRing()!==e)continue;i.setNextMin(o),n=this._SCANNING_FOR_INCOMING}}n===this._LINKING_TO_OUTGOING&&(N.isTrue(null!==t,"found null for first outgoing dirEdge"),N.isTrue(t.getEdgeRing()===e,"unable to link last incoming dirEdge"),i.setNextMin(t))}},{key:"getOutgoingDegree",value:function(){if(0===arguments.length){for(var e=0,t=this.iterator();t.hasNext();)t.next().isInResult()&&e++;return e}if(1===arguments.length){for(var i=arguments[0],n=0,r=this.iterator();r.hasNext();)r.next().getEdgeRing()===i&&n++;return n}}},{key:"getLabel",value:function(){return this._label}},{key:"findCoveredLineEdges",value:function(){for(var e=$.NONE,t=this.iterator();t.hasNext();){var i=t.next(),n=i.getSym();if(!i.isLineEdge()){if(i.isInResult()){e=$.INTERIOR;break}if(n.isInResult()){e=$.EXTERIOR;break}}}if(e===$.NONE)return null;for(var r=e,o=this.iterator();o.hasNext();){var s=o.next(),a=s.getSym();s.isLineEdge()?s.getEdge().setCovered(r===$.INTERIOR):(s.isInResult()&&(r=$.EXTERIOR),a.isInResult()&&(r=$.INTERIOR))}}},{key:"computeLabelling",value:function(e){d(n,"computeLabelling",this,1).call(this,e),this._label=new Rt($.NONE);for(var t=this.iterator();t.hasNext();)for(var i=t.next().getEdge().getLabel(),r=0;r<2;r++){var o=i.getLocation(r);o!==$.INTERIOR&&o!==$.BOUNDARY||this._label.setLocation(r,$.INTERIOR)}}}],[{key:"constructor_",value:function(){this._resultAreaEdgeList=null,this._label=null,this._SCANNING_FOR_INCOMING=1,this._LINKING_TO_OUTGOING=2}}])}(Ui),Zi=function(e){function n(){return i(this,n),t(this,n)}return c(n,e),o(n,[{key:"createNode",value:function(e){return new Bt(e,new qi)}}])}(Jt),$i=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"compareTo",value:function(t){var i=t;return e.compareOriented(this._pts,this._orientation,i._pts,i._orientation)}},{key:"interfaces_",get:function(){return[b]}}],[{key:"constructor_",value:function(){this._pts=null,this._orientation=null;var t=arguments[0];this._pts=t,this._orientation=e.orientation(t)}},{key:"orientation",value:function(e){return 1===We.increasingDirection(e)}},{key:"compareOriented",value:function(e,t,i,n){for(var r=t?1:-1,o=n?1:-1,s=t?e.length:-1,a=n?i.length:-1,l=t?0:e.length-1,c=n?0:i.length-1;;){var u=e[l].compareTo(i[c]);if(0!==u)return u;var h=(l+=r)===s,d=(c+=o)===a;if(h&&!d)return-1;if(!h&&d)return 1;if(h&&d)return 0}}}])}(),Hi=o(function e(){i(this,e),e.constructor_.apply(this,arguments)},[{key:"print",value:function(e){e.print("MULTILINESTRING ( ");for(var t=0;t<this._edges.size();t++){var i=this._edges.get(t);t>0&&e.print(","),e.print("(");for(var n=i.getCoordinates(),r=0;r<n.length;r++)r>0&&e.print(","),e.print(n[r].x+" "+n[r].y);e.println(")")}e.print(") ")}},{key:"addAll",value:function(e){for(var t=e.iterator();t.hasNext();)this.add(t.next())}},{key:"findEdgeIndex",value:function(e){for(var t=0;t<this._edges.size();t++)if(this._edges.get(t).equals(e))return t;return-1}},{key:"iterator",value:function(){return this._edges.iterator()}},{key:"getEdges",value:function(){return this._edges}},{key:"get",value:function(e){return this._edges.get(e)}},{key:"findEqualEdge",value:function(e){var t=new $i(e.getCoordinates());return this._ocaMap.get(t)}},{key:"add",value:function(e){this._edges.add(e);var t=new $i(e.getCoordinates());this._ocaMap.put(t,e)}}],[{key:"constructor_",value:function(){this._edges=new me,this._ocaMap=new $t}}]),Wi=o(function e(){i(this,e)},[{key:"processIntersections",value:function(e,t,i,n){}},{key:"isDone",value:function(){}}]),Xi=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"isTrivialIntersection",value:function(t,i,n,r){if(t===n&&1===this._li.getIntersectionNum()){if(e.isAdjacentSegments(i,r))return!0;if(t.isClosed()){var o=t.size()-1;if(0===i&&r===o||0===r&&i===o)return!0}}return!1}},{key:"getProperIntersectionPoint",value:function(){return this._properIntersectionPoint}},{key:"hasProperInteriorIntersection",value:function(){return this._hasProperInterior}},{key:"getLineIntersector",value:function(){return this._li}},{key:"hasProperIntersection",value:function(){return this._hasProper}},{key:"processIntersections",value:function(e,t,i,n){if(e===i&&t===n)return null;this.numTests++;var r=e.getCoordinates()[t],o=e.getCoordinates()[t+1],s=i.getCoordinates()[n],a=i.getCoordinates()[n+1];this._li.computeIntersection(r,o,s,a),this._li.hasIntersection()&&(this.numIntersections++,this._li.isInteriorIntersection()&&(this.numInteriorIntersections++,this._hasInterior=!0),this.isTrivialIntersection(e,t,i,n)||(this._hasIntersection=!0,e.addIntersections(this._li,t,0),i.addIntersections(this._li,n,1),this._li.isProper()&&(this.numProperIntersections++,this._hasProper=!0,this._hasProperInterior=!0)))}},{key:"hasIntersection",value:function(){return this._hasIntersection}},{key:"isDone",value:function(){return!1}},{key:"hasInteriorIntersection",value:function(){return this._hasInterior}},{key:"interfaces_",get:function(){return[Wi]}}],[{key:"constructor_",value:function(){this._hasIntersection=!1,this._hasProper=!1,this._hasProperInterior=!1,this._hasInterior=!1,this._properIntersectionPoint=null,this._li=null,this._isSelfIntersection=null,this.numIntersections=0,this.numInteriorIntersections=0,this.numProperIntersections=0,this.numTests=0;var e=arguments[0];this._li=e}},{key:"isAdjacentSegments",value:function(e,t){return 1===Math.abs(e-t)}}])}(),Yi=o(function e(){i(this,e),e.constructor_.apply(this,arguments)},[{key:"getSegmentIndex",value:function(){return this.segmentIndex}},{key:"getCoordinate",value:function(){return this.coord}},{key:"print",value:function(e){e.print(this.coord),e.print(" seg # = "+this.segmentIndex),e.println(" dist = "+this.dist)}},{key:"compareTo",value:function(e){var t=e;return this.compare(t.segmentIndex,t.dist)}},{key:"isEndPoint",value:function(e){return 0===this.segmentIndex&&0===this.dist||this.segmentIndex===e}},{key:"toString",value:function(){return this.coord+" seg # = "+this.segmentIndex+" dist = "+this.dist}},{key:"getDistance",value:function(){return this.dist}},{key:"compare",value:function(e,t){return this.segmentIndex<e?-1:this.segmentIndex>e?1:this.dist<t?-1:this.dist>t?1:0}},{key:"interfaces_",get:function(){return[b]}}],[{key:"constructor_",value:function(){this.coord=null,this.segmentIndex=null,this.dist=null;var e=arguments[0],t=arguments[1],i=arguments[2];this.coord=new V(e),this.segmentIndex=t,this.dist=i}}]),Ji=o(function e(){i(this,e),e.constructor_.apply(this,arguments)},[{key:"print",value:function(e){e.println("Intersections:");for(var t=this.iterator();t.hasNext();)t.next().print(e)}},{key:"iterator",value:function(){return this._nodeMap.values().iterator()}},{key:"addSplitEdges",value:function(e){this.addEndpoints();for(var t=this.iterator(),i=t.next();t.hasNext();){var n=t.next(),r=this.createSplitEdge(i,n);e.add(r),i=n}}},{key:"addEndpoints",value:function(){var e=this.edge.pts.length-1;this.add(this.edge.pts[0],0,0),this.add(this.edge.pts[e],e,0)}},{key:"createSplitEdge",value:function(e,t){var i=t.segmentIndex-e.segmentIndex+2,n=this.edge.pts[t.segmentIndex],r=t.dist>0||!t.coord.equals2D(n);r||i--;var o=new Array(i).fill(null),s=0;o[s++]=new V(e.coord);for(var a=e.segmentIndex+1;a<=t.segmentIndex;a++)o[s++]=this.edge.pts[a];return r&&(o[s]=t.coord),new rn(o,new Rt(this.edge._label))}},{key:"add",value:function(e,t,i){var n=new Yi(e,t,i),r=this._nodeMap.get(n);return null!==r?r:(this._nodeMap.put(n,n),n)}},{key:"isIntersection",value:function(e){for(var t=this.iterator();t.hasNext();)if(t.next().coord.equals(e))return!0;return!1}}],[{key:"constructor_",value:function(){this._nodeMap=new $t,this.edge=null;var e=arguments[0];this.edge=e}}]),Ki=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"isIntersects",value:function(){return!this.isDisjoint()}},{key:"isCovers",value:function(){return(e.isTrue(this._matrix[$.INTERIOR][$.INTERIOR])||e.isTrue(this._matrix[$.INTERIOR][$.BOUNDARY])||e.isTrue(this._matrix[$.BOUNDARY][$.INTERIOR])||e.isTrue(this._matrix[$.BOUNDARY][$.BOUNDARY]))&&this._matrix[$.EXTERIOR][$.INTERIOR]===ke.FALSE&&this._matrix[$.EXTERIOR][$.BOUNDARY]===ke.FALSE}},{key:"isCoveredBy",value:function(){return(e.isTrue(this._matrix[$.INTERIOR][$.INTERIOR])||e.isTrue(this._matrix[$.INTERIOR][$.BOUNDARY])||e.isTrue(this._matrix[$.BOUNDARY][$.INTERIOR])||e.isTrue(this._matrix[$.BOUNDARY][$.BOUNDARY]))&&this._matrix[$.INTERIOR][$.EXTERIOR]===ke.FALSE&&this._matrix[$.BOUNDARY][$.EXTERIOR]===ke.FALSE}},{key:"set",value:function(){if(1===arguments.length)for(var e=arguments[0],t=0;t<e.length;t++){var i=Math.trunc(t/3),n=t%3;this._matrix[i][n]=ke.toDimensionValue(e.charAt(t))}else if(3===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2];this._matrix[r][o]=s}}},{key:"isContains",value:function(){return e.isTrue(this._matrix[$.INTERIOR][$.INTERIOR])&&this._matrix[$.EXTERIOR][$.INTERIOR]===ke.FALSE&&this._matrix[$.EXTERIOR][$.BOUNDARY]===ke.FALSE}},{key:"setAtLeast",value:function(){if(1===arguments.length)for(var e=arguments[0],t=0;t<e.length;t++){var i=Math.trunc(t/3),n=t%3;this.setAtLeast(i,n,ke.toDimensionValue(e.charAt(t)))}else if(3===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2];this._matrix[r][o]<s&&(this._matrix[r][o]=s)}}},{key:"setAtLeastIfValid",value:function(e,t,i){e>=0&&t>=0&&this.setAtLeast(e,t,i)}},{key:"isWithin",value:function(){return e.isTrue(this._matrix[$.INTERIOR][$.INTERIOR])&&this._matrix[$.INTERIOR][$.EXTERIOR]===ke.FALSE&&this._matrix[$.BOUNDARY][$.EXTERIOR]===ke.FALSE}},{key:"isTouches",value:function(t,i){return t>i?this.isTouches(i,t):(t===ke.A&&i===ke.A||t===ke.L&&i===ke.L||t===ke.L&&i===ke.A||t===ke.P&&i===ke.A||t===ke.P&&i===ke.L)&&this._matrix[$.INTERIOR][$.INTERIOR]===ke.FALSE&&(e.isTrue(this._matrix[$.INTERIOR][$.BOUNDARY])||e.isTrue(this._matrix[$.BOUNDARY][$.INTERIOR])||e.isTrue(this._matrix[$.BOUNDARY][$.BOUNDARY]))}},{key:"isOverlaps",value:function(t,i){return t===ke.P&&i===ke.P||t===ke.A&&i===ke.A?e.isTrue(this._matrix[$.INTERIOR][$.INTERIOR])&&e.isTrue(this._matrix[$.INTERIOR][$.EXTERIOR])&&e.isTrue(this._matrix[$.EXTERIOR][$.INTERIOR]):t===ke.L&&i===ke.L&&1===this._matrix[$.INTERIOR][$.INTERIOR]&&e.isTrue(this._matrix[$.INTERIOR][$.EXTERIOR])&&e.isTrue(this._matrix[$.EXTERIOR][$.INTERIOR])}},{key:"isEquals",value:function(t,i){return t===i&&e.isTrue(this._matrix[$.INTERIOR][$.INTERIOR])&&this._matrix[$.INTERIOR][$.EXTERIOR]===ke.FALSE&&this._matrix[$.BOUNDARY][$.EXTERIOR]===ke.FALSE&&this._matrix[$.EXTERIOR][$.INTERIOR]===ke.FALSE&&this._matrix[$.EXTERIOR][$.BOUNDARY]===ke.FALSE}},{key:"toString",value:function(){for(var e=new Je("123456789"),t=0;t<3;t++)for(var i=0;i<3;i++)e.setCharAt(3*t+i,ke.toDimensionSymbol(this._matrix[t][i]));return e.toString()}},{key:"setAll",value:function(e){for(var t=0;t<3;t++)for(var i=0;i<3;i++)this._matrix[t][i]=e}},{key:"get",value:function(e,t){return this._matrix[e][t]}},{key:"transpose",value:function(){var e=this._matrix[1][0];return this._matrix[1][0]=this._matrix[0][1],this._matrix[0][1]=e,e=this._matrix[2][0],this._matrix[2][0]=this._matrix[0][2],this._matrix[0][2]=e,e=this._matrix[2][1],this._matrix[2][1]=this._matrix[1][2],this._matrix[1][2]=e,this}},{key:"matches",value:function(t){if(9!==t.length)throw new v("Should be length 9: "+t);for(var i=0;i<3;i++)for(var n=0;n<3;n++)if(!e.matches(this._matrix[i][n],t.charAt(3*i+n)))return!1;return!0}},{key:"add",value:function(e){for(var t=0;t<3;t++)for(var i=0;i<3;i++)this.setAtLeast(t,i,e.get(t,i))}},{key:"isDisjoint",value:function(){return this._matrix[$.INTERIOR][$.INTERIOR]===ke.FALSE&&this._matrix[$.INTERIOR][$.BOUNDARY]===ke.FALSE&&this._matrix[$.BOUNDARY][$.INTERIOR]===ke.FALSE&&this._matrix[$.BOUNDARY][$.BOUNDARY]===ke.FALSE}},{key:"isCrosses",value:function(t,i){return t===ke.P&&i===ke.L||t===ke.P&&i===ke.A||t===ke.L&&i===ke.A?e.isTrue(this._matrix[$.INTERIOR][$.INTERIOR])&&e.isTrue(this._matrix[$.INTERIOR][$.EXTERIOR]):t===ke.L&&i===ke.P||t===ke.A&&i===ke.P||t===ke.A&&i===ke.L?e.isTrue(this._matrix[$.INTERIOR][$.INTERIOR])&&e.isTrue(this._matrix[$.EXTERIOR][$.INTERIOR]):t===ke.L&&i===ke.L&&0===this._matrix[$.INTERIOR][$.INTERIOR]}},{key:"interfaces_",get:function(){return[w]}}],[{key:"constructor_",value:function(){if(this._matrix=null,0===arguments.length)this._matrix=Array(3).fill().map(function(){return Array(3)}),this.setAll(ke.FALSE);else if(1===arguments.length)if("string"==typeof arguments[0]){var t=arguments[0];e.constructor_.call(this),this.set(t)}else if(arguments[0]instanceof e){var i=arguments[0];e.constructor_.call(this),this._matrix[$.INTERIOR][$.INTERIOR]=i._matrix[$.INTERIOR][$.INTERIOR],this._matrix[$.INTERIOR][$.BOUNDARY]=i._matrix[$.INTERIOR][$.BOUNDARY],this._matrix[$.INTERIOR][$.EXTERIOR]=i._matrix[$.INTERIOR][$.EXTERIOR],this._matrix[$.BOUNDARY][$.INTERIOR]=i._matrix[$.BOUNDARY][$.INTERIOR],this._matrix[$.BOUNDARY][$.BOUNDARY]=i._matrix[$.BOUNDARY][$.BOUNDARY],this._matrix[$.BOUNDARY][$.EXTERIOR]=i._matrix[$.BOUNDARY][$.EXTERIOR],this._matrix[$.EXTERIOR][$.INTERIOR]=i._matrix[$.EXTERIOR][$.INTERIOR],this._matrix[$.EXTERIOR][$.BOUNDARY]=i._matrix[$.EXTERIOR][$.BOUNDARY],this._matrix[$.EXTERIOR][$.EXTERIOR]=i._matrix[$.EXTERIOR][$.EXTERIOR]}}},{key:"matches",value:function(){if(Number.isInteger(arguments[0])&&"string"==typeof arguments[1]){var t=arguments[0],i=arguments[1];return i===ke.SYM_DONTCARE||i===ke.SYM_TRUE&&(t>=0||t===ke.TRUE)||i===ke.SYM_FALSE&&t===ke.FALSE||i===ke.SYM_P&&t===ke.P||i===ke.SYM_L&&t===ke.L||i===ke.SYM_A&&t===ke.A}if("string"==typeof arguments[0]&&"string"==typeof arguments[1]){var n=arguments[1];return new e(arguments[0]).matches(n)}}},{key:"isTrue",value:function(e){return e>=0||e===ke.TRUE}}])}(),Qi=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"size",value:function(){return this._size}},{key:"addAll",value:function(e){return null===e||0===e.length?null:(this.ensureCapacity(this._size+e.length),ve.arraycopy(e,0,this._data,this._size,e.length),void(this._size+=e.length))}},{key:"ensureCapacity",value:function(e){if(e<=this._data.length)return null;var t=Math.max(e,2*this._data.length);this._data=Re.copyOf(this._data,t)}},{key:"toArray",value:function(){var e=new Array(this._size).fill(null);return ve.arraycopy(this._data,0,e,0,this._size),e}},{key:"add",value:function(e){this.ensureCapacity(this._size+1),this._data[this._size]=e,++this._size}}],[{key:"constructor_",value:function(){if(this._data=null,this._size=0,0===arguments.length)e.constructor_.call(this,10);else if(1===arguments.length){var t=arguments[0];this._data=new Array(t).fill(null)}}}])}(),en=function(){function e(){i(this,e)}return o(e,[{key:"getChainStartIndices",value:function(e){var t=0,i=new Qi(Math.trunc(e.length/2));i.add(t);do{var n=this.findChainEnd(e,t);i.add(n),t=n}while(t<e.length-1);return i.toArray()}},{key:"findChainEnd",value:function(e,t){for(var i=Wt.quadrant(e[t],e[t+1]),n=t+1;n<e.length&&Wt.quadrant(e[n-1],e[n])===i;)n++;return n-1}},{key:"OLDgetChainStartIndices",value:function(t){var i=0,n=new me;n.add(i);do{var r=this.findChainEnd(t,i);n.add(r),i=r}while(i<t.length-1);return e.toIntArray(n)}}],[{key:"toIntArray",value:function(e){for(var t=new Array(e.size()).fill(null),i=0;i<t.length;i++)t[i]=e.get(i).intValue();return t}}])}(),tn=o(function e(){i(this,e),e.constructor_.apply(this,arguments)},[{key:"getCoordinates",value:function(){return this.pts}},{key:"getMaxX",value:function(e){var t=this.pts[this.startIndex[e]].x,i=this.pts[this.startIndex[e+1]].x;return t>i?t:i}},{key:"getMinX",value:function(e){var t=this.pts[this.startIndex[e]].x,i=this.pts[this.startIndex[e+1]].x;return t<i?t:i}},{key:"computeIntersectsForChain",value:function(){if(4===arguments.length){var e=arguments[0],t=arguments[1],i=arguments[2],n=arguments[3];this.computeIntersectsForChain(this.startIndex[e],this.startIndex[e+1],t,t.startIndex[i],t.startIndex[i+1],n)}else if(6===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2],a=arguments[3],l=arguments[4],c=arguments[5];if(o-r==1&&l-a==1)return c.addIntersections(this.e,r,s.e,a),null;if(!this.overlaps(r,o,s,a,l))return null;var u=Math.trunc((r+o)/2),h=Math.trunc((a+l)/2);r<u&&(a<h&&this.computeIntersectsForChain(r,u,s,a,h,c),h<l&&this.computeIntersectsForChain(r,u,s,h,l,c)),u<o&&(a<h&&this.computeIntersectsForChain(u,o,s,a,h,c),h<l&&this.computeIntersectsForChain(u,o,s,h,l,c))}}},{key:"overlaps",value:function(e,t,i,n,r){return q.intersects(this.pts[e],this.pts[t],i.pts[n],i.pts[r])}},{key:"getStartIndexes",value:function(){return this.startIndex}},{key:"computeIntersects",value:function(e,t){for(var i=0;i<this.startIndex.length-1;i++)for(var n=0;n<e.startIndex.length-1;n++)this.computeIntersectsForChain(i,e,n,t)}}],[{key:"constructor_",value:function(){this.e=null,this.pts=null,this.startIndex=null;var e=arguments[0];this.e=e,this.pts=e.getCoordinates();var t=new en;this.startIndex=t.getChainStartIndices(this.pts)}}]),nn=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"getDepth",value:function(e,t){return this._depth[e][t]}},{key:"setDepth",value:function(e,t,i){this._depth[e][t]=i}},{key:"isNull",value:function(){if(0===arguments.length){for(var t=0;t<2;t++)for(var i=0;i<3;i++)if(this._depth[t][i]!==e.NULL_VALUE)return!1;return!0}if(1===arguments.length){var n=arguments[0];return this._depth[n][1]===e.NULL_VALUE}if(2===arguments.length){var r=arguments[0],o=arguments[1];return this._depth[r][o]===e.NULL_VALUE}}},{key:"normalize",value:function(){for(var e=0;e<2;e++)if(!this.isNull(e)){var t=this._depth[e][1];this._depth[e][2]<t&&(t=this._depth[e][2]),t<0&&(t=0);for(var i=1;i<3;i++){var n=0;this._depth[e][i]>t&&(n=1),this._depth[e][i]=n}}}},{key:"getDelta",value:function(e){return this._depth[e][Q.RIGHT]-this._depth[e][Q.LEFT]}},{key:"getLocation",value:function(e,t){return this._depth[e][t]<=0?$.EXTERIOR:$.INTERIOR}},{key:"toString",value:function(){return"A: "+this._depth[0][1]+","+this._depth[0][2]+" B: "+this._depth[1][1]+","+this._depth[1][2]}},{key:"add",value:function(){if(1===arguments.length)for(var t=arguments[0],i=0;i<2;i++)for(var n=1;n<3;n++){var r=t.getLocation(i,n);r!==$.EXTERIOR&&r!==$.INTERIOR||(this.isNull(i,n)?this._depth[i][n]=e.depthAtLocation(r):this._depth[i][n]+=e.depthAtLocation(r))}else if(3===arguments.length){var o=arguments[0],s=arguments[1];arguments[2]===$.INTERIOR&&this._depth[o][s]++}}}],[{key:"constructor_",value:function(){this._depth=Array(2).fill().map(function(){return Array(3)});for(var t=0;t<2;t++)for(var i=0;i<3;i++)this._depth[t][i]=e.NULL_VALUE}},{key:"depthAtLocation",value:function(t){return t===$.EXTERIOR?0:t===$.INTERIOR?1:e.NULL_VALUE}}])}();nn.NULL_VALUE=-1;var rn=function(e){function n(){var e;return i(this,n),e=t(this,n),n.constructor_.apply(e,arguments),e}return c(n,e),o(n,[{key:"getDepth",value:function(){return this._depth}},{key:"getCollapsedEdge",value:function(){var e=new Array(2).fill(null);return e[0]=this.pts[0],e[1]=this.pts[1],new n(e,Rt.toLineLabel(this._label))}},{key:"isIsolated",value:function(){return this._isIsolated}},{key:"getCoordinates",value:function(){return this.pts}},{key:"setIsolated",value:function(e){this._isIsolated=e}},{key:"setName",value:function(e){this._name=e}},{key:"equals",value:function(e){if(!(e instanceof n))return!1;var t=e;if(this.pts.length!==t.pts.length)return!1;for(var i=!0,r=!0,o=this.pts.length,s=0;s<this.pts.length;s++)if(this.pts[s].equals2D(t.pts[s])||(i=!1),this.pts[s].equals2D(t.pts[--o])||(r=!1),!i&&!r)return!1;return!0}},{key:"getCoordinate",value:function(){if(0===arguments.length)return this.pts.length>0?this.pts[0]:null;if(1===arguments.length){var e=arguments[0];return this.pts[e]}}},{key:"print",value:function(e){e.print("edge "+this._name+": "),e.print("LINESTRING (");for(var t=0;t<this.pts.length;t++)t>0&&e.print(","),e.print(this.pts[t].x+" "+this.pts[t].y);e.print(") "+this._label+" "+this._depthDelta)}},{key:"computeIM",value:function(e){n.updateIM(this._label,e)}},{key:"isCollapsed",value:function(){return!!this._label.isArea()&&3===this.pts.length&&!!this.pts[0].equals(this.pts[2])}},{key:"isClosed",value:function(){return this.pts[0].equals(this.pts[this.pts.length-1])}},{key:"getMaximumSegmentIndex",value:function(){return this.pts.length-1}},{key:"getDepthDelta",value:function(){return this._depthDelta}},{key:"getNumPoints",value:function(){return this.pts.length}},{key:"printReverse",value:function(e){e.print("edge "+this._name+": ");for(var t=this.pts.length-1;t>=0;t--)e.print(this.pts[t]+" ");e.println("")}},{key:"getMonotoneChainEdge",value:function(){return null===this._mce&&(this._mce=new tn(this)),this._mce}},{key:"getEnvelope",value:function(){if(null===this._env){this._env=new q;for(var e=0;e<this.pts.length;e++)this._env.expandToInclude(this.pts[e])}return this._env}},{key:"addIntersection",value:function(e,t,i,n){var r=new V(e.getIntersection(n)),o=t,s=e.getEdgeDistance(i,n),a=o+1;if(a<this.pts.length){var l=this.pts[a];r.equals2D(l)&&(o=a,s=0)}this.eiList.add(r,o,s)}},{key:"toString",value:function(){var e=new Je;e.append("edge "+this._name+": "),e.append("LINESTRING (");for(var t=0;t<this.pts.length;t++)t>0&&e.append(","),e.append(this.pts[t].x+" "+this.pts[t].y);return e.append(") "+this._label+" "+this._depthDelta),e.toString()}},{key:"isPointwiseEqual",value:function(e){if(this.pts.length!==e.pts.length)return!1;for(var t=0;t<this.pts.length;t++)if(!this.pts[t].equals2D(e.pts[t]))return!1;return!0}},{key:"setDepthDelta",value:function(e){this._depthDelta=e}},{key:"getEdgeIntersectionList",value:function(){return this.eiList}},{key:"addIntersections",value:function(e,t,i){for(var n=0;n<e.getIntersectionNum();n++)this.addIntersection(e,t,i,n)}}],[{key:"constructor_",value:function(){if(this.pts=null,this._env=null,this.eiList=new Ji(this),this._name=null,this._mce=null,this._isIsolated=!0,this._depth=new nn,this._depthDelta=0,1===arguments.length){var e=arguments[0];n.constructor_.call(this,e,null)}else if(2===arguments.length){var t=arguments[0],i=arguments[1];this.pts=t,this._label=i}}},{key:"updateIM",value:function(){if(!(2===arguments.length&&arguments[1]instanceof Ki&&arguments[0]instanceof Rt))return d(n,"updateIM",this).apply(this,arguments);var e=arguments[0],t=arguments[1];t.setAtLeastIfValid(e.getLocation(0,Q.ON),e.getLocation(1,Q.ON),1),e.isArea()&&(t.setAtLeastIfValid(e.getLocation(0,Q.LEFT),e.getLocation(1,Q.LEFT),2),t.setAtLeastIfValid(e.getLocation(0,Q.RIGHT),e.getLocation(1,Q.RIGHT),2))}}])}(Nt),on=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"setWorkingPrecisionModel",value:function(e){this._workingPrecisionModel=e}},{key:"insertUniqueEdge",value:function(t){var i=this._edgeList.findEqualEdge(t);if(null!==i){var n=i.getLabel(),r=t.getLabel();i.isPointwiseEqual(t)||(r=new Rt(t.getLabel())).flip(),n.merge(r);var o=e.depthDelta(r),s=i.getDepthDelta()+o;i.setDepthDelta(s)}else this._edgeList.add(t),t.setDepthDelta(e.depthDelta(t.getLabel()))}},{key:"buildSubgraphs",value:function(e,t){for(var i=new me,n=e.iterator();n.hasNext();){var r=n.next(),o=r.getRightmostCoordinate(),s=new Ri(i).getDepth(o);r.computeDepth(s),r.findResultEdges(),i.add(r),t.add(r.getDirectedEdges(),r.getNodes())}}},{key:"createSubgraphs",value:function(e){for(var t=new me,i=e.getNodes().iterator();i.hasNext();){var n=i.next();if(!n.isVisited()){var r=new ye;r.create(n),t.add(r)}}return oi.sort(t,oi.reverseOrder()),t}},{key:"createEmptyResultGeometry",value:function(){return this._geomFact.createPolygon()}},{key:"getNoder",value:function(e){if(null!==this._workingNoder)return this._workingNoder;var t=new ki,i=new Pt;return i.setPrecisionModel(e),t.setSegmentIntersector(new Xi(i)),t}},{key:"buffer",value:function(e,t){var i=this._workingPrecisionModel;null===i&&(i=e.getPrecisionModel()),this._geomFact=e.getFactory();var n=new Di(i,this._bufParams),r=new Bi(e,t,n).getCurves();if(r.size()<=0)return this.createEmptyResultGeometry();this.computeNodedEdges(r,i),this._graph=new Kt(new Zi),this._graph.addEdges(this._edgeList.getEdges());var o=this.createSubgraphs(this._graph),s=new Qt(this._geomFact);this.buildSubgraphs(o,s);var a=s.getPolygons();return a.size()<=0?this.createEmptyResultGeometry():this._geomFact.buildGeometry(a)}},{key:"computeNodedEdges",value:function(e,t){var i=this.getNoder(t);i.computeNodes(e);for(var n=i.getNodedSubstrings().iterator();n.hasNext();){var r=n.next(),o=r.getCoordinates();if(2!==o.length||!o[0].equals2D(o[1])){var s=r.getData(),a=new rn(r.getCoordinates(),new Rt(s));this.insertUniqueEdge(a)}}}},{key:"setNoder",value:function(e){this._workingNoder=e}}],[{key:"constructor_",value:function(){this._bufParams=null,this._workingPrecisionModel=null,this._workingNoder=null,this._geomFact=null,this._graph=null,this._edgeList=new Hi;var e=arguments[0];this._bufParams=e}},{key:"depthDelta",value:function(e){var t=e.getLocation(0,Q.LEFT),i=e.getLocation(0,Q.RIGHT);return t===$.INTERIOR&&i===$.EXTERIOR?1:t===$.EXTERIOR&&i===$.INTERIOR?-1:0}},{key:"convertSegStrings",value:function(e){for(var t=new st,i=new me;e.hasNext();){var n=e.next(),r=t.createLineString(n.getCoordinates());i.add(r)}return t.buildGeometry(i)}}])}(),sn=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"rescale",value:function(){if(re(arguments[0],H))for(var e=arguments[0].iterator();e.hasNext();){var t=e.next();this.rescale(t.getCoordinates())}else if(arguments[0]instanceof Array){for(var i=arguments[0],n=0;n<i.length;n++)i[n].x=i[n].x/this._scaleFactor+this._offsetX,i[n].y=i[n].y/this._scaleFactor+this._offsetY;2===i.length&&i[0].equals2D(i[1])&&ve.out.println(i)}}},{key:"scale",value:function(){if(re(arguments[0],H)){for(var e=arguments[0],t=new me(e.size()),i=e.iterator();i.hasNext();){var n=i.next();t.add(new xi(this.scale(n.getCoordinates()),n.getData()))}return t}if(arguments[0]instanceof Array){for(var r=arguments[0],o=new Array(r.length).fill(null),s=0;s<r.length;s++)o[s]=new V(Math.round((r[s].x-this._offsetX)*this._scaleFactor),Math.round((r[s].y-this._offsetY)*this._scaleFactor),r[s].getZ());return We.removeRepeatedPoints(o)}}},{key:"isIntegerPrecision",value:function(){return 1===this._scaleFactor}},{key:"getNodedSubstrings",value:function(){var e=this._noder.getNodedSubstrings();return this._isScaled&&this.rescale(e),e}},{key:"computeNodes",value:function(e){var t=e;this._isScaled&&(t=this.scale(e)),this._noder.computeNodes(t)}},{key:"interfaces_",get:function(){return[Si]}}],[{key:"constructor_",value:function(){if(this._noder=null,this._scaleFactor=null,this._offsetX=null,this._offsetY=null,this._isScaled=!1,2===arguments.length){var t=arguments[0],i=arguments[1];e.constructor_.call(this,t,i,0,0)}else if(4===arguments.length){var n=arguments[0],r=arguments[1];this._noder=n,this._scaleFactor=r,this._isScaled=!this.isIntegerPrecision()}}}])}(),an=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"checkEndPtVertexIntersections",value:function(){if(0===arguments.length)for(var e=this._segStrings.iterator();e.hasNext();){var t=e.next().getCoordinates();this.checkEndPtVertexIntersections(t[0],this._segStrings),this.checkEndPtVertexIntersections(t[t.length-1],this._segStrings)}else if(2===arguments.length)for(var i=arguments[0],n=arguments[1].iterator();n.hasNext();)for(var r=n.next().getCoordinates(),o=1;o<r.length-1;o++)if(r[o].equals(i))throw new F("found endpt/interior pt intersection at index "+o+" :pt "+i)}},{key:"checkInteriorIntersections",value:function(){if(0===arguments.length)for(var e=this._segStrings.iterator();e.hasNext();)for(var t=e.next(),i=this._segStrings.iterator();i.hasNext();){var n=i.next();this.checkInteriorIntersections(t,n)}else if(2===arguments.length)for(var r=arguments[0],o=arguments[1],s=r.getCoordinates(),a=o.getCoordinates(),l=0;l<s.length-1;l++)for(var c=0;c<a.length-1;c++)this.checkInteriorIntersections(r,l,o,c);else if(4===arguments.length){var u=arguments[0],h=arguments[1],d=arguments[2],p=arguments[3];if(u===d&&h===p)return null;var f=u.getCoordinates()[h],m=u.getCoordinates()[h+1],g=d.getCoordinates()[p],y=d.getCoordinates()[p+1];if(this._li.computeIntersection(f,m,g,y),this._li.hasIntersection()&&(this._li.isProper()||this.hasInteriorIntersection(this._li,f,m)||this.hasInteriorIntersection(this._li,g,y)))throw new F("found non-noded intersection at "+f+"-"+m+" and "+g+"-"+y)}}},{key:"checkValid",value:function(){this.checkEndPtVertexIntersections(),this.checkInteriorIntersections(),this.checkCollapses()}},{key:"checkCollapses",value:function(){if(0===arguments.length)for(var e=this._segStrings.iterator();e.hasNext();){var t=e.next();this.checkCollapses(t)}else if(1===arguments.length)for(var i=arguments[0].getCoordinates(),n=0;n<i.length-2;n++)this.checkCollapse(i[n],i[n+1],i[n+2])}},{key:"hasInteriorIntersection",value:function(e,t,i){for(var n=0;n<e.getIntersectionNum();n++){var r=e.getIntersection(n);if(!r.equals(t)&&!r.equals(i))return!0}return!1}},{key:"checkCollapse",value:function(t,i,n){if(t.equals(n))throw new F("found non-noded collapse at "+e.fact.createLineString([t,i,n]))}}],[{key:"constructor_",value:function(){this._li=new Pt,this._segStrings=null;var e=arguments[0];this._segStrings=e}}])}();an.fact=new st;var ln=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"intersectsScaled",value:function(e,t){var i=Math.min(e.x,t.x),n=Math.max(e.x,t.x),r=Math.min(e.y,t.y),o=Math.max(e.y,t.y),s=this._maxx<i||this._minx>n||this._maxy<r||this._miny>o;if(s)return!1;var a=this.intersectsToleranceSquare(e,t);return N.isTrue(!(s&&a),"Found bad envelope test"),a}},{key:"initCorners",value:function(e){var t=.5;this._minx=e.x-t,this._maxx=e.x+t,this._miny=e.y-t,this._maxy=e.y+t,this._corner[0]=new V(this._maxx,this._maxy),this._corner[1]=new V(this._minx,this._maxy),this._corner[2]=new V(this._minx,this._miny),this._corner[3]=new V(this._maxx,this._miny)}},{key:"intersects",value:function(e,t){return 1===this._scaleFactor?this.intersectsScaled(e,t):(this.copyScaled(e,this._p0Scaled),this.copyScaled(t,this._p1Scaled),this.intersectsScaled(this._p0Scaled,this._p1Scaled))}},{key:"scale",value:function(e){return Math.round(e*this._scaleFactor)}},{key:"getCoordinate",value:function(){return this._originalPt}},{key:"copyScaled",value:function(e,t){t.x=this.scale(e.x),t.y=this.scale(e.y)}},{key:"getSafeEnvelope",value:function(){if(null===this._safeEnv){var t=e.SAFE_ENV_EXPANSION_FACTOR/this._scaleFactor;this._safeEnv=new q(this._originalPt.x-t,this._originalPt.x+t,this._originalPt.y-t,this._originalPt.y+t)}return this._safeEnv}},{key:"intersectsPixelClosure",value:function(e,t){return this._li.computeIntersection(e,t,this._corner[0],this._corner[1]),!!(this._li.hasIntersection()||(this._li.computeIntersection(e,t,this._corner[1],this._corner[2]),this._li.hasIntersection()||(this._li.computeIntersection(e,t,this._corner[2],this._corner[3]),this._li.hasIntersection()||(this._li.computeIntersection(e,t,this._corner[3],this._corner[0]),this._li.hasIntersection()))))}},{key:"intersectsToleranceSquare",value:function(e,t){var i=!1,n=!1;return this._li.computeIntersection(e,t,this._corner[0],this._corner[1]),!!(this._li.isProper()||(this._li.computeIntersection(e,t,this._corner[1],this._corner[2]),this._li.isProper()||(this._li.hasIntersection()&&(i=!0),this._li.computeIntersection(e,t,this._corner[2],this._corner[3]),this._li.isProper()||(this._li.hasIntersection()&&(n=!0),this._li.computeIntersection(e,t,this._corner[3],this._corner[0]),this._li.isProper()||i&&n||e.equals(this._pt)||t.equals(this._pt)))))}},{key:"addSnappedNode",value:function(e,t){var i=e.getCoordinate(t),n=e.getCoordinate(t+1);return!!this.intersects(i,n)&&(e.addIntersection(this.getCoordinate(),t),!0)}}],[{key:"constructor_",value:function(){this._li=null,this._pt=null,this._originalPt=null,this._ptScaled=null,this._p0Scaled=null,this._p1Scaled=null,this._scaleFactor=null,this._minx=null,this._maxx=null,this._miny=null,this._maxy=null,this._corner=new Array(4).fill(null),this._safeEnv=null;var e=arguments[0],t=arguments[1],i=arguments[2];if(this._originalPt=e,this._pt=e,this._scaleFactor=t,this._li=i,t<=0)throw new v("Scale factor must be non-zero");1!==t&&(this._pt=new V(this.scale(e.x),this.scale(e.y)),this._p0Scaled=new V,this._p1Scaled=new V),this.initCorners(this._pt)}}])}();ln.SAFE_ENV_EXPANSION_FACTOR=.75;var cn=o(function e(){i(this,e),e.constructor_.apply(this,arguments)},[{key:"select",value:function(){if(1!==arguments.length&&2===arguments.length){var e=arguments[1];arguments[0].getLineSegment(e,this.selectedSegment),this.select(this.selectedSegment)}}}],[{key:"constructor_",value:function(){this.selectedSegment=new bi}}]),un=o(function e(){i(this,e),e.constructor_.apply(this,arguments)},[{key:"snap",value:function(){if(1===arguments.length){var e=arguments[0];return this.snap(e,null,-1)}if(3===arguments.length){var t=arguments[0],n=arguments[1],r=arguments[2],s=t.getSafeEnvelope(),a=new hn(t,n,r);return this._index.query(s,new(o(function e(){i(this,e)},[{key:"interfaces_",get:function(){return[li]}},{key:"visitItem",value:function(e){e.select(s,a)}}]))),a.isNodeAdded()}}}],[{key:"constructor_",value:function(){this._index=null;var e=arguments[0];this._index=e}}]),hn=function(e){function n(){var e;return i(this,n),e=t(this,n),n.constructor_.apply(e,arguments),e}return c(n,e),o(n,[{key:"isNodeAdded",value:function(){return this._isNodeAdded}},{key:"select",value:function(){if(!(2===arguments.length&&Number.isInteger(arguments[1])&&arguments[0]instanceof Ei))return d(n,"select",this,1).apply(this,arguments);var e=arguments[1],t=arguments[0].getContext();if(this._parentEdge===t&&(e===this._hotPixelVertexIndex||e+1===this._hotPixelVertexIndex))return null;this._isNodeAdded|=this._hotPixel.addSnappedNode(t,e)}}],[{key:"constructor_",value:function(){this._hotPixel=null,this._parentEdge=null,this._hotPixelVertexIndex=null,this._isNodeAdded=!1;var e=arguments[0],t=arguments[1],i=arguments[2];this._hotPixel=e,this._parentEdge=t,this._hotPixelVertexIndex=i}}])}(cn);un.HotPixelSnapAction=hn;var dn=o(function e(){i(this,e),e.constructor_.apply(this,arguments)},[{key:"processIntersections",value:function(e,t,i,n){if(e===i&&t===n)return null;var r=e.getCoordinates()[t],o=e.getCoordinates()[t+1],s=i.getCoordinates()[n],a=i.getCoordinates()[n+1];if(this._li.computeIntersection(r,o,s,a),this._li.hasIntersection()&&this._li.isInteriorIntersection()){for(var l=0;l<this._li.getIntersectionNum();l++)this._interiorIntersections.add(this._li.getIntersection(l));e.addIntersections(this._li,t,0),i.addIntersections(this._li,n,1)}}},{key:"isDone",value:function(){return!1}},{key:"getInteriorIntersections",value:function(){return this._interiorIntersections}},{key:"interfaces_",get:function(){return[Wi]}}],[{key:"constructor_",value:function(){this._li=null,this._interiorIntersections=null;var e=arguments[0];this._li=e,this._interiorIntersections=new me}}]),pn=o(function e(){i(this,e),e.constructor_.apply(this,arguments)},[{key:"checkCorrectness",value:function(e){var t=xi.getNodedSubstrings(e),i=new an(t);try{i.checkValid()}catch(e){if(!(e instanceof _))throw e;e.printStackTrace()}}},{key:"getNodedSubstrings",value:function(){return xi.getNodedSubstrings(this._nodedSegStrings)}},{key:"snapRound",value:function(e,t){var i=this.findInteriorIntersections(e,t);this.computeIntersectionSnaps(i),this.computeVertexSnaps(e)}},{key:"findInteriorIntersections",value:function(e,t){var i=new dn(t);return this._noder.setSegmentIntersector(i),this._noder.computeNodes(e),i.getInteriorIntersections()}},{key:"computeVertexSnaps",value:function(){if(re(arguments[0],H))for(var e=arguments[0].iterator();e.hasNext();){var t=e.next();this.computeVertexSnaps(t)}else if(arguments[0]instanceof xi)for(var i=arguments[0],n=i.getCoordinates(),r=0;r<n.length;r++){var o=new ln(n[r],this._scaleFactor,this._li);this._pointSnapper.snap(o,i,r)&&i.addIntersection(n[r],r)}}},{key:"computeNodes",value:function(e){this._nodedSegStrings=e,this._noder=new ki,this._pointSnapper=new un(this._noder.getIndex()),this.snapRound(e,this._li)}},{key:"computeIntersectionSnaps",value:function(e){for(var t=e.iterator();t.hasNext();){var i=t.next(),n=new ln(i,this._scaleFactor,this._li);this._pointSnapper.snap(n)}}},{key:"interfaces_",get:function(){return[Si]}}],[{key:"constructor_",value:function(){this._pm=null,this._li=null,this._scaleFactor=null,this._noder=null,this._pointSnapper=null,this._nodedSegStrings=null;var e=arguments[0];this._pm=e,this._li=new Pt,this._li.setPrecisionModel(e),this._scaleFactor=e.getScale()}}]),fn=function(){function e(){i(this,e),e.constructor_.apply(this,arguments)}return o(e,[{key:"bufferFixedPrecision",value:function(e){var t=new sn(new pn(new nt(1)),e.getScale()),i=new on(this._bufParams);i.setWorkingPrecisionModel(e),i.setNoder(t),this._resultGeometry=i.buffer(this._argGeom,this._distance)}},{key:"bufferReducedPrecision",value:function(){if(0===arguments.length){for(var t=e.MAX_PRECISION_DIGITS;t>=0;t--){try{this.bufferReducedPrecision(t)}catch(e){if(!(e instanceof pe))throw e;this._saveException=e}if(null!==this._resultGeometry)return null}throw this._saveException}if(1===arguments.length){var i=arguments[0],n=e.precisionScaleFactor(this._argGeom,this._distance,i),r=new nt(n);this.bufferFixedPrecision(r)}}},{key:"computeGeometry",value:function(){if(this.bufferOriginalPrecision(),null!==this._resultGeometry)return null;var e=this._argGeom.getFactory().getPrecisionModel();e.getType()===nt.FIXED?this.bufferFixedPrecision(e):this.bufferReducedPrecision()}},{key:"setQuadrantSegments",value:function(e){this._bufParams.setQuadrantSegments(e)}},{key:"bufferOriginalPrecision",value:function(){try{var e=new on(this._bufParams);this._resultGeometry=e.buffer(this._argGeom,this._distance)}catch(e){if(!(e instanceof F))throw e;this._saveException=e}}},{key:"getResultGeometry",value:function(e){return this._distance=e,this.computeGeometry(),this._resultGeometry}},{key:"setEndCapStyle",value:function(e){this._bufParams.setEndCapStyle(e)}}],[{key:"constructor_",value:function(){if(this._argGeom=null,this._distance=null,this._bufParams=new y,this._resultGeometry=null,this._saveException=null,1===arguments.length){var e=arguments[0];this._argGeom=e}else if(2===arguments.length){var t=arguments[0],i=arguments[1];this._argGeom=t,this._bufParams=i}}},{key:"bufferOp",value:function(){if(2===arguments.length){var t=arguments[1];return new e(arguments[0]).getResultGeometry(t)}if(3===arguments.length){if(Number.isInteger(arguments[2])&&arguments[0]instanceof Z&&"number"==typeof arguments[1]){var i=arguments[1],n=arguments[2],r=new e(arguments[0]);return r.setQuadrantSegments(n),r.getResultGeometry(i)}if(arguments[2]instanceof y&&arguments[0]instanceof Z&&"number"==typeof arguments[1]){var o=arguments[1];return new e(arguments[0],arguments[2]).getResultGeometry(o)}}else if(4===arguments.length){var s=arguments[1],a=arguments[2],l=arguments[3],c=new e(arguments[0]);return c.setQuadrantSegments(a),c.setEndCapStyle(l),c.getResultGeometry(s)}}},{key:"precisionScaleFactor",value:function(e,t,i){var n=e.getEnvelopeInternal(),r=xe.max(Math.abs(n.getMaxX()),Math.abs(n.getMaxY()),Math.abs(n.getMinX()),Math.abs(n.getMinY()))+2*(t>0?t:0),o=i-Math.trunc(Math.log(r)/Math.log(10)+1);return Math.pow(10,o)}}])}();fn.CAP_ROUND=y.CAP_ROUND,fn.CAP_BUTT=y.CAP_FLAT,fn.CAP_FLAT=y.CAP_FLAT,fn.CAP_SQUARE=y.CAP_SQUARE,fn.MAX_PRECISION_DIGITS=12;var mn=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],gn=o(function e(t){i(this,e),this.geometryFactory=t||new st},[{key:"read",value:function(e){var t,i=(t="string"==typeof e?JSON.parse(e):e).type;if(!yn[i])throw new Error("Unknown GeoJSON type: "+t.type);return-1!==mn.indexOf(i)?yn[i].call(this,t.coordinates):"GeometryCollection"===i?yn[i].call(this,t.geometries):yn[i].call(this,t)}},{key:"write",value:function(e){var t=e.getGeometryType();if(!_n[t])throw new Error("Geometry is not supported");return _n[t].call(this,e)}}]),yn={Feature:function(e){var t={};for(var i in e)t[i]=e[i];if(e.geometry){var n=e.geometry.type;if(!yn[n])throw new Error("Unknown GeoJSON type: "+e.type);t.geometry=this.read(e.geometry)}return e.bbox&&(t.bbox=yn.bbox.call(this,e.bbox)),t},FeatureCollection:function(e){var t={};if(e.features){t.features=[];for(var i=0;i<e.features.length;++i)t.features.push(this.read(e.features[i]))}return e.bbox&&(t.bbox=this.parse.bbox.call(this,e.bbox)),t},coordinates:function(e){for(var t=[],i=0;i<e.length;++i){var r=e[i];t.push(n(V,p(r)))}return t},bbox:function(e){return this.geometryFactory.createLinearRing([new V(e[0],e[1]),new V(e[2],e[1]),new V(e[2],e[3]),new V(e[0],e[3]),new V(e[0],e[1])])},Point:function(e){var t=n(V,p(e));return this.geometryFactory.createPoint(t)},MultiPoint:function(e){for(var t=[],i=0;i<e.length;++i)t.push(yn.Point.call(this,e[i]));return this.geometryFactory.createMultiPoint(t)},LineString:function(e){var t=yn.coordinates.call(this,e);return this.geometryFactory.createLineString(t)},MultiLineString:function(e){for(var t=[],i=0;i<e.length;++i)t.push(yn.LineString.call(this,e[i]));return this.geometryFactory.createMultiLineString(t)},Polygon:function(e){for(var t=yn.coordinates.call(this,e[0]),i=this.geometryFactory.createLinearRing(t),n=[],r=1;r<e.length;++r){var o=e[r],s=yn.coordinates.call(this,o),a=this.geometryFactory.createLinearRing(s);n.push(a)}return this.geometryFactory.createPolygon(i,n)},MultiPolygon:function(e){for(var t=[],i=0;i<e.length;++i){var n=e[i];t.push(yn.Polygon.call(this,n))}return this.geometryFactory.createMultiPolygon(t)},GeometryCollection:function(e){for(var t=[],i=0;i<e.length;++i){var n=e[i];t.push(this.read(n))}return this.geometryFactory.createGeometryCollection(t)}},_n={coordinate:function(e){var t=[e.x,e.y];return e.z&&t.push(e.z),e.m&&t.push(e.m),t},Point:function(e){return{type:"Point",coordinates:_n.coordinate.call(this,e.getCoordinate())}},MultiPoint:function(e){for(var t=[],i=0;i<e._geometries.length;++i){var n=e._geometries[i],r=_n.Point.call(this,n);t.push(r.coordinates)}return{type:"MultiPoint",coordinates:t}},LineString:function(e){for(var t=[],i=e.getCoordinates(),n=0;n<i.length;++n){var r=i[n];t.push(_n.coordinate.call(this,r))}return{type:"LineString",coordinates:t}},MultiLineString:function(e){for(var t=[],i=0;i<e._geometries.length;++i){var n=e._geometries[i],r=_n.LineString.call(this,n);t.push(r.coordinates)}return{type:"MultiLineString",coordinates:t}},Polygon:function(e){var t=[],i=_n.LineString.call(this,e._shell);t.push(i.coordinates);for(var n=0;n<e._holes.length;++n){var r=e._holes[n],o=_n.LineString.call(this,r);t.push(o.coordinates)}return{type:"Polygon",coordinates:t}},MultiPolygon:function(e){for(var t=[],i=0;i<e._geometries.length;++i){var n=e._geometries[i],r=_n.Polygon.call(this,n);t.push(r.coordinates)}return{type:"MultiPolygon",coordinates:t}},GeometryCollection:function(e){for(var t=[],i=0;i<e._geometries.length;++i){var n=e._geometries[i],r=n.getGeometryType();t.push(_n[r].call(this,n))}return{type:"GeometryCollection",geometries:t}}};return{BufferOp:fn,GeoJSONReader:o(function e(t){i(this,e),this.parser=new gn(t||new st)},[{key:"read",value:function(e){return this.parser.read(e)}}]),GeoJSONWriter:o(function e(){i(this,e),this.parser=new gn(this.geometryFactory)},[{key:"write",value:function(e){return this.parser.write(e)}}])}}()}(ws)),ws.exports);const Ts=re(Es);function Ss(){return new Is}function Is(){this.reset()}Is.prototype={constructor:Is,reset:function(){this.s=this.t=0},add:function(e){Ms(ks,e,this.t),Ms(this,ks.s,this.s),this.s?this.t+=ks.t:this.s=ks.t},valueOf:function(){return this.s}};var ks=new Is;function Ms(e,t,i){var n=e.s=t+i,r=n-t,o=n-r;e.t=t-o+(i-r)}var Cs=1e-6,Ps=Math.PI,As=Ps/2,Ls=Ps/4,Ds=2*Ps,Rs=180/Ps,zs=Ps/180,Fs=Math.abs,Os=Math.atan,Ns=Math.atan2,Bs=Math.cos,Gs=Math.sin,js=Math.sqrt;function Vs(e){return e>1?0:e<-1?Ps:Math.acos(e)}function Us(e){return e>1?As:e<-1?-As:Math.asin(e)}function qs(){}function Zs(e,t){e&&Hs.hasOwnProperty(e.type)&&Hs[e.type](e,t)}var $s={Feature:function(e,t){Zs(e.geometry,t)},FeatureCollection:function(e,t){for(var i=e.features,n=-1,r=i.length;++n<r;)Zs(i[n].geometry,t)}},Hs={Sphere:function(e,t){t.sphere()},Point:function(e,t){e=e.coordinates,t.point(e[0],e[1],e[2])},MultiPoint:function(e,t){for(var i=e.coordinates,n=-1,r=i.length;++n<r;)e=i[n],t.point(e[0],e[1],e[2])},LineString:function(e,t){Ws(e.coordinates,t,0)},MultiLineString:function(e,t){for(var i=e.coordinates,n=-1,r=i.length;++n<r;)Ws(i[n],t,0)},Polygon:function(e,t){Xs(e.coordinates,t)},MultiPolygon:function(e,t){for(var i=e.coordinates,n=-1,r=i.length;++n<r;)Xs(i[n],t)},GeometryCollection:function(e,t){for(var i=e.geometries,n=-1,r=i.length;++n<r;)Zs(i[n],t)}};function Ws(e,t,i){var n,r=-1,o=e.length-i;for(t.lineStart();++r<o;)n=e[r],t.point(n[0],n[1],n[2]);t.lineEnd()}function Xs(e,t){var i=-1,n=e.length;for(t.polygonStart();++i<n;)Ws(e[i],t,1);t.polygonEnd()}function Ys(e){return[Ns(e[1],e[0]),Us(e[2])]}function Js(e){var t=e[0],i=e[1],n=Bs(i);return[n*Bs(t),n*Gs(t),Gs(i)]}function Ks(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Qs(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function ea(e,t){e[0]+=t[0],e[1]+=t[1],e[2]+=t[2]}function ta(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function ia(e){var t=js(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);e[0]/=t,e[1]/=t,e[2]/=t}function na(e,t){function i(i,n){return i=e(i,n),t(i[0],i[1])}return e.invert&&t.invert&&(i.invert=function(i,n){return(i=t.invert(i,n))&&e.invert(i[0],i[1])}),i}function ra(e,t){return[e>Ps?e-Ds:e<-Ps?e+Ds:e,t]}function oa(e){return function(t,i){return[(t+=e)>Ps?t-Ds:t<-Ps?t+Ds:t,i]}}function sa(e){var t=oa(e);return t.invert=oa(-e),t}function aa(e,t){var i=Bs(e),n=Gs(e),r=Bs(t),o=Gs(t);function s(e,t){var s=Bs(t),a=Bs(e)*s,l=Gs(e)*s,c=Gs(t),u=c*i+a*n;return[Ns(l*r-u*o,a*i-c*n),Us(u*r+l*o)]}return s.invert=function(e,t){var s=Bs(t),a=Bs(e)*s,l=Gs(e)*s,c=Gs(t),u=c*r-l*o;return[Ns(l*r+c*o,a*i+u*n),Us(u*i-a*n)]},s}function la(e,t){(t=Js(t))[0]-=e,ia(t);var i=Vs(-t[1]);return((-t[2]<0?-i:i)+Ds-Cs)%Ds}function ca(){var e,t=[];return{point:function(t,i){e.push([t,i])},lineStart:function(){t.push(e=[])},lineEnd:qs,rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))},result:function(){var i=t;return t=[],e=null,i}}}function ua(e,t){return Fs(e[0]-t[0])<Cs&&Fs(e[1]-t[1])<Cs}function ha(e,t,i,n){this.x=e,this.z=t,this.o=i,this.e=n,this.v=!1,this.n=this.p=null}function da(e,t,i,n,r){var o,s,a=[],l=[];if(e.forEach(function(e){if(!((t=e.length-1)<=0)){var t,i,n=e[0],s=e[t];if(ua(n,s)){for(r.lineStart(),o=0;o<t;++o)r.point((n=e[o])[0],n[1]);return void r.lineEnd()}a.push(i=new ha(n,e,null,!0)),l.push(i.o=new ha(n,null,i,!1)),a.push(i=new ha(s,e,null,!1)),l.push(i.o=new ha(s,null,i,!0))}}),a.length){for(l.sort(t),pa(a),pa(l),o=0,s=l.length;o<s;++o)l[o].e=i=!i;for(var c,u,h=a[0];;){for(var d=h,p=!0;d.v;)if((d=d.n)===h)return;c=d.z,r.lineStart();do{if(d.v=d.o.v=!0,d.e){if(p)for(o=0,s=c.length;o<s;++o)r.point((u=c[o])[0],u[1]);else n(d.x,d.n.x,1,r);d=d.n}else{if(p)for(c=d.p.z,o=c.length-1;o>=0;--o)r.point((u=c[o])[0],u[1]);else n(d.x,d.p.x,-1,r);d=d.p}c=(d=d.o).z,p=!p}while(!d.v);r.lineEnd()}}}function pa(e){if(t=e.length){for(var t,i,n=0,r=e[0];++n<t;)r.n=i=e[n],i.p=r,r=i;r.n=i=e[0],i.p=r}}function fa(e){for(var t,i,n,r=e.length,o=-1,s=0;++o<r;)s+=e[o].length;for(i=new Array(s);--r>=0;)for(t=(n=e[r]).length;--t>=0;)i[--s]=n[t];return i}Ss(),Ss(),Ss(),ra.invert=ra;var ma=1e9,ga=-1e9;function ya(e,t,i,n){function r(r,o){return e<=r&&r<=i&&t<=o&&o<=n}function o(r,o,a,c){var u=0,h=0;if(null==r||(u=s(r,a))!==(h=s(o,a))||l(r,o)<0^a>0)do{c.point(0===u||3===u?e:i,u>1?n:t)}while((u=(u+a+4)%4)!==h);else c.point(o[0],o[1])}function s(n,r){return Fs(n[0]-e)<Cs?r>0?0:3:Fs(n[0]-i)<Cs?r>0?2:1:Fs(n[1]-t)<Cs?r>0?1:0:r>0?3:2}function a(e,t){return l(e.x,t.x)}function l(e,t){var i=s(e,1),n=s(t,1);return i!==n?i-n:0===i?t[1]-e[1]:1===i?e[0]-t[0]:2===i?e[1]-t[1]:t[0]-e[0]}return function(s){var l,c,u,h,d,p,f,m,g,y,_,v=s,x=ca(),b={point:w,lineStart:function(){b.point=E,c&&c.push(u=[]),y=!0,g=!1,f=m=NaN},lineEnd:function(){l&&(E(h,d),p&&g&&x.rejoin(),l.push(x.result())),b.point=w,g&&v.lineEnd()},polygonStart:function(){v=x,l=[],c=[],_=!0},polygonEnd:function(){var t=function(){for(var t=0,i=0,r=c.length;i<r;++i)for(var o,s,a=c[i],l=1,u=a.length,h=a[0],d=h[0],p=h[1];l<u;++l)o=d,s=p,h=a[l],d=h[0],p=h[1],s<=n?p>n&&(d-o)*(n-s)>(p-s)*(e-o)&&++t:p<=n&&(d-o)*(n-s)<(p-s)*(e-o)&&--t;return t}(),i=_&&t,r=(l=fa(l)).length;(i||r)&&(s.polygonStart(),i&&(s.lineStart(),o(null,null,1,s),s.lineEnd()),r&&da(l,a,t,o,s),s.polygonEnd()),v=s,l=c=u=null}};function w(e,t){r(e,t)&&v.point(e,t)}function E(o,s){var a=r(o,s);if(c&&u.push([o,s]),y)h=o,d=s,p=a,y=!1,a&&(v.lineStart(),v.point(o,s));else if(a&&g)v.point(o,s);else{var l=[f=Math.max(ga,Math.min(ma,f)),m=Math.max(ga,Math.min(ma,m))],x=[o=Math.max(ga,Math.min(ma,o)),s=Math.max(ga,Math.min(ma,s))];!function(e,t,i,n,r,o){var s,a=e[0],l=e[1],c=0,u=1,h=t[0]-a,d=t[1]-l;if(s=i-a,h||!(s>0)){if(s/=h,h<0){if(s<c)return;s<u&&(u=s)}else if(h>0){if(s>u)return;s>c&&(c=s)}if(s=r-a,h||!(s<0)){if(s/=h,h<0){if(s>u)return;s>c&&(c=s)}else if(h>0){if(s<c)return;s<u&&(u=s)}if(s=n-l,d||!(s>0)){if(s/=d,d<0){if(s<c)return;s<u&&(u=s)}else if(d>0){if(s>u)return;s>c&&(c=s)}if(s=o-l,d||!(s<0)){if(s/=d,d<0){if(s>u)return;s>c&&(c=s)}else if(d>0){if(s<c)return;s<u&&(u=s)}return c>0&&(e[0]=a+c*h,e[1]=l+c*d),u<1&&(t[0]=a+u*h,t[1]=l+u*d),!0}}}}}(l,x,e,t,i,n)?a&&(v.lineStart(),v.point(o,s),_=!1):(g||(v.lineStart(),v.point(l[0],l[1])),v.point(x[0],x[1]),a||v.lineEnd(),_=!1)}f=o,m=s,g=a}return b}}var _a=Ss();function va(e){return e}Ss(),Ss(),Ss();var xa=1/0,ba=xa,wa=-xa,Ea=wa,Ta={point:function(e,t){e<xa&&(xa=e),e>wa&&(wa=e),t<ba&&(ba=t),t>Ea&&(Ea=t)},lineStart:qs,lineEnd:qs,polygonStart:qs,polygonEnd:qs,result:function(){var e=[[xa,ba],[wa,Ea]];return wa=Ea=-(ba=xa=1/0),e}};function Sa(e,t,i,n){return function(r,o){var s,a,l,c=t(o),u=r.invert(n[0],n[1]),h=ca(),d=t(h),p=!1,f={point:m,lineStart:y,lineEnd:_,polygonStart:function(){f.point=v,f.lineStart=x,f.lineEnd=b,a=[],s=[]},polygonEnd:function(){f.point=m,f.lineStart=y,f.lineEnd=_,a=fa(a);var e=function(e,t){var i=t[0],n=t[1],r=[Gs(i),-Bs(i),0],o=0,s=0;_a.reset();for(var a=0,l=e.length;a<l;++a)if(u=(c=e[a]).length)for(var c,u,h=c[u-1],d=h[0],p=h[1]/2+Ls,f=Gs(p),m=Bs(p),g=0;g<u;++g,d=_,f=x,m=b,h=y){var y=c[g],_=y[0],v=y[1]/2+Ls,x=Gs(v),b=Bs(v),w=_-d,E=w>=0?1:-1,T=E*w,S=T>Ps,I=f*x;if(_a.add(Ns(I*E*Gs(T),m*b+I*Bs(T))),o+=S?w+E*Ds:w,S^d>=i^_>=i){var k=Qs(Js(h),Js(y));ia(k);var M=Qs(r,k);ia(M);var C=(S^w>=0?-1:1)*Us(M[2]);(n>C||n===C&&(k[0]||k[1]))&&(s+=S^w>=0?1:-1)}}return(o<-1e-6||o<Cs&&_a<-1e-6)^1&s}(s,u);a.length?(p||(o.polygonStart(),p=!0),da(a,ka,e,i,o)):e&&(p||(o.polygonStart(),p=!0),o.lineStart(),i(null,null,1,o),o.lineEnd()),p&&(o.polygonEnd(),p=!1),a=s=null},sphere:function(){o.polygonStart(),o.lineStart(),i(null,null,1,o),o.lineEnd(),o.polygonEnd()}};function m(t,i){var n=r(t,i);e(t=n[0],i=n[1])&&o.point(t,i)}function g(e,t){var i=r(e,t);c.point(i[0],i[1])}function y(){f.point=g,c.lineStart()}function _(){f.point=m,c.lineEnd()}function v(e,t){l.push([e,t]);var i=r(e,t);d.point(i[0],i[1])}function x(){d.lineStart(),l=[]}function b(){v(l[0][0],l[0][1]),d.lineEnd();var e,t,i,n,r=d.clean(),c=h.result(),u=c.length;if(l.pop(),s.push(l),l=null,u){if(1&r){if((t=(i=c[0]).length-1)>0){for(p||(o.polygonStart(),p=!0),o.lineStart(),e=0;e<t;++e)o.point((n=i[e])[0],n[1]);o.lineEnd()}return}u>1&&2&r&&c.push(c.pop().concat(c.shift())),a.push(c.filter(Ia))}}return f}}function Ia(e){return e.length>1}function ka(e,t){return((e=e.x)[0]<0?e[1]-As-Cs:As-e[1])-((t=t.x)[0]<0?t[1]-As-Cs:As-t[1])}Ss();const Ma=Sa(function(){return!0},function(e){var t,i=NaN,n=NaN,r=NaN;return{lineStart:function(){e.lineStart(),t=1},point:function(o,s){var a=o>0?Ps:-Ps,l=Fs(o-i);Fs(l-Ps)<Cs?(e.point(i,n=(n+s)/2>0?As:-As),e.point(r,n),e.lineEnd(),e.lineStart(),e.point(a,n),e.point(o,n),t=0):r!==a&&l>=Ps&&(Fs(i-r)<Cs&&(i-=r*Cs),Fs(o-a)<Cs&&(o-=a*Cs),n=function(e,t,i,n){var r,o,s=Gs(e-i);return Fs(s)>Cs?Os((Gs(t)*(o=Bs(n))*Gs(i)-Gs(n)*(r=Bs(t))*Gs(e))/(r*o*s)):(t+n)/2}(i,n,o,s),e.point(r,n),e.lineEnd(),e.lineStart(),e.point(a,n),t=0),e.point(i=o,n=s),r=a},lineEnd:function(){e.lineEnd(),i=n=NaN},clean:function(){return 2-t}}},function(e,t,i,n){var r;if(null==e)r=i*As,n.point(-Ps,r),n.point(0,r),n.point(Ps,r),n.point(Ps,0),n.point(Ps,-r),n.point(0,-r),n.point(-Ps,-r),n.point(-Ps,0),n.point(-Ps,r);else if(Fs(e[0]-t[0])>Cs){var o=e[0]<t[0]?Ps:-Ps;r=i*o/2,n.point(-o,r),n.point(0,r),n.point(o,r)}else n.point(t[0],t[1])},[-Ps,-As]);function Ca(e,t){var i=Bs(e),n=i>0,r=Fs(i)>Cs;function o(e,t){return Bs(e)*Bs(t)>i}function s(e,t,n){var r=[1,0,0],o=Qs(Js(e),Js(t)),s=Ks(o,o),a=o[0],l=s-a*a;if(!l)return!n&&e;var c=i*s/l,u=-i*a/l,h=Qs(r,o),d=ta(r,c);ea(d,ta(o,u));var p=h,f=Ks(d,p),m=Ks(p,p),g=f*f-m*(Ks(d,d)-1);if(!(g<0)){var y=js(g),_=ta(p,(-f-y)/m);if(ea(_,d),_=Ys(_),!n)return _;var v,x=e[0],b=t[0],w=e[1],E=t[1];b<x&&(v=x,x=b,b=v);var T=b-x,S=Fs(T-Ps)<Cs;if(!S&&E<w&&(v=w,w=E,E=v),S||T<Cs?S?w+E>0^_[1]<(Fs(_[0]-x)<Cs?w:E):w<=_[1]&&_[1]<=E:T>Ps^(x<=_[0]&&_[0]<=b)){var I=ta(p,(-f+y)/m);return ea(I,d),[_,Ys(I)]}}}function a(t,i){var r=n?e:Ps-e,o=0;return t<-r?o|=1:t>r&&(o|=2),i<-r?o|=4:i>r&&(o|=8),o}return Sa(o,function(e){var t,i,l,c,u;return{lineStart:function(){c=l=!1,u=1},point:function(h,d){var p,f=[h,d],m=o(h,d),g=n?m?0:a(h,d):m?a(h+(h<0?Ps:-Ps),d):0;if(!t&&(c=l=m)&&e.lineStart(),m!==l&&((!(p=s(t,f))||ua(t,p)||ua(f,p))&&(f[0]+=Cs,f[1]+=Cs,m=o(f[0],f[1]))),m!==l)u=0,m?(e.lineStart(),p=s(f,t),e.point(p[0],p[1])):(p=s(t,f),e.point(p[0],p[1]),e.lineEnd()),t=p;else if(r&&t&&n^m){var y;!(g&i)&&(y=s(f,t,!0))&&(u=0,n?(e.lineStart(),e.point(y[0][0],y[0][1]),e.point(y[1][0],y[1][1]),e.lineEnd()):(e.point(y[1][0],y[1][1]),e.lineEnd(),e.lineStart(),e.point(y[0][0],y[0][1])))}m&&(!t||!ua(t,f))&&e.point(f[0],f[1]),t=f,l=m,i=g},lineEnd:function(){l&&e.lineEnd(),t=null},clean:function(){return u|(c&&l)<<1}}},function(i,n,r,o){!function(e,t,i,n,r,o){if(i){var s=Bs(t),a=Gs(t),l=n*i;null==r?(r=t+n*Ds,o=t-l/2):(r=la(s,r),o=la(s,o),(n>0?r<o:r>o)&&(r+=n*Ds));for(var c,u=r;n>0?u>o:u<o;u-=l)c=Ys([s,-a*Bs(u),-a*Gs(u)]),e.point(c[0],c[1])}}(o,e,t,r,i,n)},n?[0,-e]:[-Ps,e-Ps])}function Pa(e){return function(t){var i=new Aa;for(var n in e)i[n]=e[n];return i.stream=t,i}}function Aa(){}function La(e,t,i){var n=t[1][0]-t[0][0],r=t[1][1]-t[0][1],o=e.clipExtent&&e.clipExtent();e.scale(150).translate([0,0]),null!=o&&e.clipExtent(null),function(e,t){e&&$s.hasOwnProperty(e.type)?$s[e.type](e,t):Zs(e,t)}(i,e.stream(Ta));var s=Ta.result(),a=Math.min(n/(s[1][0]-s[0][0]),r/(s[1][1]-s[0][1])),l=+t[0][0]+(n-a*(s[1][0]+s[0][0]))/2,c=+t[0][1]+(r-a*(s[1][1]+s[0][1]))/2;return null!=o&&e.clipExtent(o),e.scale(150*a).translate([l,c])}Aa.prototype={constructor:Aa,point:function(e,t){this.stream.point(e,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};var Da=Bs(30*zs);function Ra(e,t){return+t?function(e,t){function i(n,r,o,s,a,l,c,u,h,d,p,f,m,g){var y=c-n,_=u-r,v=y*y+_*_;if(v>4*t&&m--){var x=s+d,b=a+p,w=l+f,E=js(x*x+b*b+w*w),T=Us(w/=E),S=Fs(Fs(w)-1)<Cs||Fs(o-h)<Cs?(o+h)/2:Ns(b,x),I=e(S,T),k=I[0],M=I[1],C=k-n,P=M-r,A=_*C-y*P;(A*A/v>t||Fs((y*C+_*P)/v-.5)>.3||s*d+a*p+l*f<Da)&&(i(n,r,o,s,a,l,k,M,S,x/=E,b/=E,w,m,g),g.point(k,M),i(k,M,S,x,b,w,c,u,h,d,p,f,m,g))}}return function(t){var n,r,o,s,a,l,c,u,h,d,p,f,m={point:g,lineStart:y,lineEnd:v,polygonStart:function(){t.polygonStart(),m.lineStart=x},polygonEnd:function(){t.polygonEnd(),m.lineStart=y}};function g(i,n){i=e(i,n),t.point(i[0],i[1])}function y(){u=NaN,m.point=_,t.lineStart()}function _(n,r){var o=Js([n,r]),s=e(n,r);i(u,h,c,d,p,f,u=s[0],h=s[1],c=n,d=o[0],p=o[1],f=o[2],16,t),t.point(u,h)}function v(){m.point=g,t.lineEnd()}function x(){y(),m.point=b,m.lineEnd=w}function b(e,t){_(n=e,t),r=u,o=h,s=d,a=p,l=f,m.point=_}function w(){i(u,h,c,d,p,f,r,o,n,s,a,l,16,t),m.lineEnd=v,v()}return m}}(e,t):function(e){return Pa({point:function(t,i){t=e(t,i),this.stream.point(t[0],t[1])}})}(e)}var za=Pa({point:function(e,t){this.stream.point(e*zs,t*zs)}});function Fa(e){return function(e){var t,i,n,r,o,s,a,l,c,u,h=150,d=480,p=250,f=0,m=0,g=0,y=0,_=0,v=null,x=Ma,b=null,w=va,E=.5,T=Ra(k,E);function S(e){return[(e=o(e[0]*zs,e[1]*zs))[0]*h+i,n-e[1]*h]}function I(e){return(e=o.invert((e[0]-i)/h,(n-e[1])/h))&&[e[0]*Rs,e[1]*Rs]}function k(e,r){return[(e=t(e,r))[0]*h+i,n-e[1]*h]}function M(){o=na(r=function(e,t,i){return(e%=Ds)?t||i?na(sa(e),aa(t,i)):sa(e):t||i?aa(t,i):ra}(g,y,_),t);var e=t(f,m);return i=d-e[0]*h,n=p+e[1]*h,C()}function C(){return c=u=null,S}return S.stream=function(e){return c&&u===e?c:c=za(x(r,T(w(u=e))))},S.clipAngle=function(e){return arguments.length?(x=+e?Ca(v=e*zs,6*zs):(v=null,Ma),C()):v*Rs},S.clipExtent=function(e){return arguments.length?(w=null==e?(b=s=a=l=null,va):ya(b=+e[0][0],s=+e[0][1],a=+e[1][0],l=+e[1][1]),C()):null==b?null:[[b,s],[a,l]]},S.scale=function(e){return arguments.length?(h=+e,M()):h},S.translate=function(e){return arguments.length?(d=+e[0],p=+e[1],M()):[d,p]},S.center=function(e){return arguments.length?(f=e[0]%360*zs,m=e[1]%360*zs,M()):[f*Rs,m*Rs]},S.rotate=function(e){return arguments.length?(g=e[0]%360*zs,y=e[1]%360*zs,_=e.length>2?e[2]%360*zs:0,M()):[g*Rs,y*Rs,_*Rs]},S.precision=function(e){return arguments.length?(T=Ra(k,E=e*e),C()):js(E)},S.fitExtent=function(e,t){return La(S,e,t)},S.fitSize=function(e,t){return function(e,t,i){return La(e,[[0,0],t],i)}(S,e,t)},function(){return t=e.apply(this,arguments),S.invert=t.invert&&I,M()}}(function(){return e})()}function Oa(e){return function(t,i){var n=Bs(t),r=Bs(i),o=e(n*r);return[o*r*Gs(t),o*Gs(i)]}}function Na(e){return function(t,i){var n=js(t*t+i*i),r=e(n),o=Gs(r),s=Bs(r);return[Ns(t*o,n*s),Us(n&&i*o/n)]}}var Ba=Oa(function(e){return js(2/(1+e))});Ba.invert=Na(function(e){return 2*Us(e/2)});var Ga=Oa(function(e){return(e=Vs(e))&&e/Gs(e)});function ja(e,t){return[e,t]}Ga.invert=Na(function(e){return e}),ja.invert=ja;var{BufferOp:Va,GeoJSONReader:Ua,GeoJSONWriter:qa}=Ts;function Za(e,t,i,n){var r=e.properties||{},o="Feature"===e.type?e.geometry:e;if("GeometryCollection"===o.type){var s=[];return Pe(e,function(e){var r=Za(e,t,i,n);r&&s.push(r)}),ve(s)}var a=function(e){var t=function(e,t={}){const i=Le(e);return ge([(i[0]+i[2])/2,(i[1]+i[3])/2],t.properties,t)}(e).geometry.coordinates,i=[-t[0],-t[1]];return Fa(Ga).scale(79.4188).clipAngle(179.999).rotate(i).scale(pe)}(o),l={type:o.type,coordinates:Ha(o.coordinates,a)},c=(new Ua).read(l),u=be(we(t,i),"meters"),h=Va.bufferOp(c,u,n);if(!$a((h=(new qa).write(h)).coordinates))return me({type:h.type,coordinates:Wa(h.coordinates,a)},r)}function $a(e){return Array.isArray(e[0])?$a(e[0]):isNaN(e[0])}function Ha(e,t){return"object"!=typeof e[0]?t(e):e.map(function(e){return Ha(e,t)})}function Wa(e,t){return"object"!=typeof e[0]?t.invert(e):e.map(function(e){return Wa(e,t)})}var Xa=function(e,t,i){var n=(i=i||{}).units||"kilometers",r=i.steps||8;if(!e)throw new Error("geojson is required");if("object"!=typeof i)throw new Error("options must be an object");if("number"!=typeof r)throw new Error("steps must be an number");if(void 0===t)throw new Error("radius is required");if(r<=0)throw new Error("steps must be greater than 0");var o=[];switch(e.type){case"GeometryCollection":return Pe(e,function(e){var i=Za(e,t,n,r);i&&o.push(i)}),ve(o);case"FeatureCollection":return Ce(e,function(e){var i=Za(e,t,n,r);i&&Ce(i,function(e){e&&o.push(e)})}),ve(o)}return Za(e,t,n,r)};const Ya=(e,t)=>{const i=$n(e.getGeoJson());return((e,t)=>{Yr(e,e=>{const i=e.coordinate;i[0]+=t.lng,i[1]+=t.lat})})(i,t),i},Ja=(e,t)=>{const i=((e,t)=>{try{Yr(e,e=>{if(!Zo(e.coordinate,t))throw new Error("stop")})}catch{return!1}return!0})(e,t);return vs(e)?i:!(!i||!xs(e))&&!os(e,t,{ignoreSelfIntersections:!0}).features.length},Ka=e=>{const t=e.getGeoJson();return"object"!=typeof t?null:oo(t)},Qa=["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout","contextmenu","touchstart","touchend","touchmove","touchcancel"],el=(e,t={warning:!1})=>{if(!e)return t.warning&&he.warn("Empty event",e),!1;const i="object"==typeof e&&"lngLat"in e&&"point"in e&&"type"in e&&"originalEvent"in e&&"string"==typeof e.type&&Qa.includes(e.type);return!i&&t.warning&&he.warn("Not a pointer event",e),i},tl={main:`${_o}_main`,temporary:`${_o}_temporary`,standby:`${_o}_standby`},il="_gmid";class nl{constructor(e){X(this,"gm"),X(this,"featureCounter",0),X(this,"featureStore",new Map),X(this,"featureStoreAllowedSources",[tl.main,tl.temporary]),X(this,"autoUpdatesEnabled",!0),X(this,"diffUpdatesEnabled",!0),X(this,"sources"),X(this,"defaultSourceName",tl.main),X(this,"updateStorage"),X(this,"delayedSourceUpdateMethods"),X(this,"layers"),this.gm=e,this.sources=Object.fromEntries(ie(tl).map(e=>[e,null])),this.updateStorage=Object.fromEntries(ie(tl).map(e=>[e,{add:[],remove:[],update:[]}])),this.delayedSourceUpdateMethods=Object.fromEntries(ie(tl).map(e=>[e,{throttled:this.getDelayedSourceUpdateMethod({sourceName:e,type:"throttled"}),debounced:this.getDelayedSourceUpdateMethod({sourceName:e,type:"debounced"})}])),this.layers=[]}init(){Object.values(this.sources).some(e=>null!==e)?he.warn("features.init(): features are already initialized"):(te(this.sources).forEach(e=>{this.sources[e]=this.createSource(e)}),this.layers=this.createLayers())}get forEach(){return this.filteredForEach(e=>!e.temporary)}get tmpForEach(){return this.filteredForEach(e=>e.temporary)}getNewFeatureId(){return this.featureCounter+=1,`feature-${this.featureCounter}`}filteredForEach(e){return t=>{this.featureStore.forEach((i,n,r)=>{e(i)&&t(i,n,r)})}}has(e,t){const i=this.featureStore.get(t);return!!i&&(null==i?void 0:i.source)===this.sources[e]}get(e,t){const i=this.featureStore.get(t)||null;return(null==i?void 0:i.source)===this.sources[e]?i:null}add(e){this.featureStore.has(e.id)?he.error(`features.add: feature with the id "${e.id}" already exists`):this.featureStoreAllowedSources.includes(e.source.id)&&this.featureStore.set(e.id,e)}setDefaultSourceName(e){this.defaultSourceName=e}getDelayedSourceUpdateMethod({sourceName:e,type:t}){if("throttled"===t)return jr(()=>this.updateSourceByStorage(e),2*this.gm.options.settings.throttlingDelay,{leading:!1,trailing:!0});if("debounced"===t)return wr(()=>this.updateSourceByStorage(e),2*this.gm.options.settings.throttlingDelay,{leading:!0,trailing:!1});throw new Error("Features: getDelayedSourceUpdateMethod: invalid type")}updateSourceByStorage(e){const t=this.sources[e],i=this.updateStorage[e],n=Object.values(i).some(e=>e.length);t&&n&&(t.updateData(i),this.resetDiffStorage(e))}resetDiffStorage(e){const t=this.updateStorage[e];t.add=[],t.remove=[],t.update=[]}withAtomicSourcesUpdate(e){try{return this.autoUpdatesEnabled=!1,e()}finally{ie(tl).forEach(e=>{this.updateSourceByStorage(e)}),this.autoUpdatesEnabled=!0}}updateSourceData({diff:e,sourceName:t}){this.gm.features.diffUpdatesEnabled?this.updateSourceDataWithDiff({diff:e,sourceName:t}):this.setSourceData({diff:e,sourceName:t})}updateSourceDataWithDiff({diff:e,sourceName:t}){const i=this.updateStorage[t];e.add&&(i.add=i.add.concat(e.add)),e.update&&(i.update=i.update.concat(e.update)),e.remove&&(i.remove=i.remove.concat(e.remove)),this.gm.features.autoUpdatesEnabled&&(this.delayedSourceUpdateMethods[t].throttled(),this.delayedSourceUpdateMethods[t].debounced())}setSourceData({sourceName:e}){he.warn("Review this Features.setSourceData() method");const t=this.getSourceGeoJson(e);t.features=t.features.filter(e=>!!e),this.setSourceGeoJson({geoJson:t,sourceName:e})}createSource(e){const t=this.gm.mapAdapter.addSource(e,{type:"FeatureCollection",features:[]});if(t)return t;throw new Error(`Features: failed to create the source: "${e}"`)}delete(e){let t;t=e instanceof po?e:this.featureStore.get(e)||null,t?(t.removeMarkers(),t.removeGeoJson(),this.featureStore.delete(t.id)):he.error(`features.delete: feature "${e}" not found`)}getFeatureByMouseEvent({event:e,sourceNames:t}){if(!el(e,{warning:!0}))return null;const i=[e.point.x,e.point.y],n=this.gm.mapAdapter.queryFeaturesByScreenCoordinates({queryCoordinates:i,sourceNames:t});return n.length?n[0]:null}getFeaturesByGeoJsonBounds({geoJson:e,sourceNames:t}){const i=io(e),n=this.gm.mapAdapter.coordBoundsToScreenBounds(i);return this.getFeaturesByScreenBounds({bounds:n,sourceNames:t})}getFeaturesByScreenBounds({bounds:e,sourceNames:t}){return this.gm.mapAdapter.queryFeaturesByScreenCoordinates({queryCoordinates:e,sourceNames:t})}createFeature({featureId:e,shapeGeoJson:t,parent:i,sourceName:n,imported:r}){const o=this.sources[n];if(!o)return he.error("Features.createFeature Missing source for feature creation"),null;const s=e||t.properties[il]||this.getNewFeatureId();if(this.featureStore.get(s))return he.error(`Features.createFeature: feature with the id "${s}" already exists`,this.featureStore.get(s)),null;const a=new po({gm:this.gm,id:s,parent:i||null,source:o,geoJsonShapeFeature:$n(t)});return this.add(a),!a.temporary&&!r&&this.fireFeatureCreatedEvent(a),this.featureCounter+=1,a}importGeoJson(e){const t="features"in e?e.features:[e],i={stats:{total:0,success:0,failed:0},addedFeatures:[]};return t.forEach(e=>{let t=null;i.stats.total+=1;const n=(e=>{if(xs(e)){const t=gs(e,{mutate:!1});if("Feature"===t.type&&xs(t))return{...t,properties:e.properties||{}}}return vs(e)?e:null})(e);n&&(t=this.importGeoJsonFeature(n)),t?(i.addedFeatures.push(t),i.stats.success+=1):i.stats.failed+=1}),i}importGeoJsonFeature(e){const t=this.defaultSourceName,i=this.getFeatureShapeByGeoJson(e);if(!i)return he.error("features.addGeoJsonFeature: unknown shape",i),null;const n=e.id||`${t}-feature-${this.featureCounter}`;return this.createFeature({featureId:e.id,shapeGeoJson:{...e,properties:{...e.properties,[il]:n,shape:i}},sourceName:t,imported:!0})}getAll(){return this.exportGeoJson()}exportGeoJson({allowedShapes:e}={allowedShapes:void 0}){return this.asGeoJsonFeatureCollection({sourceNames:[tl.main,tl.standby],shapeTypes:e||[...ko]})}getSourceGeoJson(e){const t=this.sources[e];if(!t)throw new Error(`getSourceGeoJson: missing source "${e}"`);return t.getGeoJson()}setSourceGeoJson({geoJson:e,sourceName:t}){const i=this.sources[t];if(!i)throw new Error(`setSourceGeoJson: missing source "${t}"`);i.setGeoJson(e)}asGeoJsonFeatureCollection({shapeTypes:e,sourceNames:t}){const i={type:"FeatureCollection",features:[]};return t.forEach(t=>{const n=this.sources[t];n&&n.getGeoJson().features.filter(e=>!!e).forEach(t=>{(void 0===e||e.includes(t.properties.shape))&&i.features.push(t)})}),i}convertSourceToGm(e){const t=[],i=e.getGeoJson(),n="features"in i?i.features:[i];return this.gm.mapAdapter.getSource(e.id).remove({removeLayers:!1}),n.forEach(e=>{const i=this.addGeoJsonFeature({shapeGeoJson:e,defaultSource:!0});i&&t.push(i)}),t}addGeoJsonFeature({shapeGeoJson:e,sourceName:t,defaultSource:i}){let n;if(i?(n=this.defaultSourceName,t&&he.warn("features.addGeoJsonFeature: default source is set, sourceName is ignored")):n=t||null,!n)return he.error("features.addGeoJsonFeature: missing sourceName"),null;const r=this.getFeatureShapeByGeoJson(e);return r?this.createFeature({featureId:e.id,shapeGeoJson:{...e,properties:{...e.properties,shape:r}},sourceName:n}):(he.error("features.addGeoJsonFeature: unknown shape",r),null)}createLayers(){const e=[];return te(this.gm.options.layerStyles).forEach(t=>{te(this.gm.options.layerStyles[t]).forEach(i=>{this.gm.options.layerStyles[t][i].forEach(n=>{const r=this.createGenericLayer({layerId:`${i}-${t}-${n.type}-layer`,partialStyle:n,shape:t,sourceName:i});r&&e.push(r)})})}),e}createGenericLayer({layerId:e,sourceName:t,partialStyle:i,shape:n}){const r={...i,id:e,source:t,filter:["in",["get","shape"],["literal",[n]]]};return this.gm.mapAdapter.addLayer(r)}getFeatureShapeByGeoJson(e){const t=e.properties;return null!=t&&t.shape&&ko.includes(null==t?void 0:t.shape)?null==t?void 0:t.shape:{Point:"marker",LineString:"line",Polygon:"polygon",MultiPolygon:"polygon"}[e.geometry.type]||null}createMarkerFeature({parentFeature:e,coordinate:t,type:i,sourceName:n}){return this.createFeature({sourceName:n,parent:e,shapeGeoJson:{type:"Feature",geometry:{type:"Point",coordinates:t},properties:{shape:`${i}_marker`}}})}updateMarkerFeaturePosition(e,t){e.updateGeoJsonGeometry({type:"Point",coordinates:t})}fireFeatureCreatedEvent(e){if(ne(e.shape,ko)){const t={level:"system",type:"draw",mode:e.shape,action:"feature_created",featureData:e};this.gm.events.fire(`${_o}:draw`,t)}}}const rl=e=>[{type:"circle",paint:{"circle-radius":e.circleMarkerRadius,"circle-color":e.fillColor,"circle-opacity":e.fillOpacity,"circle-stroke-color":e.lineColor,"circle-stroke-width":e.lineWidth,"circle-stroke-opacity":e.lineOpacity}}],ol=e=>[{type:"circle",paint:{"circle-radius":7,"circle-color":"#ffffff","circle-opacity":1,"circle-stroke-color":e.lineColor,"circle-stroke-width":2,"circle-stroke-opacity":1}}],sl=e=>[{type:"line",paint:{"line-color":e.lineColor,"line-opacity":e.lineOpacity,"line-width":e.lineWidth}}],al=e=>[{type:"fill",paint:{"fill-color":e.fillColor,"fill-opacity":e.fillOpacity}},{type:"line",paint:{"line-color":e.lineColor,"line-opacity":e.lineOpacity,"line-width":e.lineWidth}}],ll=e=>[{type:"circle",paint:{"circle-radius":6,"circle-color":"#ffffff","circle-opacity":.6,"circle-stroke-color":e.lineColor,"circle-stroke-width":2,"circle-stroke-opacity":1}}],cl={[tl.main]:{lineColor:"#278cda",lineOpacity:.8,lineWidth:3,fillColor:"#4fb3ff",fillOpacity:.4,circleMarkerRadius:10},[tl.temporary]:{lineColor:"#ff5600",lineOpacity:.8,lineWidth:3,fillColor:"#4fb3ff",fillOpacity:.4,circleMarkerRadius:10},[tl.standby]:{lineColor:"#787878",lineOpacity:.8,lineWidth:3,fillColor:"#a5a5a5",fillOpacity:.4,circleMarkerRadius:10}},ul={settings:{throttlingDelay:10,controlsPosition:"top-left"},layerStyles:{line:{[tl.main]:sl(cl[tl.main]),[tl.temporary]:sl(cl[tl.temporary]),[tl.standby]:sl(cl[tl.standby])},circle:{[tl.main]:al(cl[tl.main]),[tl.temporary]:al(cl[tl.temporary]),[tl.standby]:al(cl[tl.standby])},rectangle:{[tl.main]:al(cl[tl.main]),[tl.temporary]:al(cl[tl.temporary]),[tl.standby]:al(cl[tl.standby])},polygon:{[tl.main]:al(cl[tl.main]),[tl.temporary]:al(cl[tl.temporary]),[tl.standby]:al(cl[tl.standby])},marker:{[tl.temporary]:[{type:"symbol",layout:{"icon-image":"default-marker","icon-size":.18,"icon-allow-overlap":!0,"icon-anchor":"bottom"}}],[tl.main]:[{type:"symbol",layout:{"icon-image":"default-marker","icon-size":.18,"icon-allow-overlap":!0,"icon-anchor":"bottom"}}],[tl.standby]:[{type:"symbol",layout:{"icon-image":"default-marker","icon-size":.18,"icon-allow-overlap":!0,"icon-anchor":"bottom"}}]},circle_marker:{[tl.main]:rl(cl[tl.main]),[tl.temporary]:rl(cl[tl.temporary]),[tl.standby]:rl(cl[tl.standby])},text_marker:{[tl.main]:[{type:"symbol",layout:{"text-field":["get","text"],"text-justify":"center"},paint:{"text-color":"black","text-halo-color":"#fff","text-halo-width":2}}],[tl.temporary]:[{type:"symbol",layout:{"text-field":["get","text"],"text-justify":"center"},paint:{"text-color":"black","text-halo-color":"#fff","text-halo-width":2}}],[tl.standby]:[{type:"symbol",layout:{"text-field":["get","text"],"text-justify":"center"},paint:{"text-color":"black","text-halo-color":"#fff","text-halo-width":2}}]},dom_marker:{[tl.main]:[],[tl.temporary]:[],[tl.standby]:[]},center_marker:{[tl.main]:ol(cl[tl.main]),[tl.temporary]:ol(cl[tl.temporary]),[tl.standby]:ol(cl[tl.standby])},vertex_marker:{[tl.main]:ol(cl[tl.main]),[tl.temporary]:ol(cl[tl.temporary]),[tl.standby]:ol(cl[tl.standby])},edge_marker:{[tl.main]:ll(cl[tl.main]),[tl.temporary]:ll(cl[tl.temporary]),[tl.standby]:ll(cl[tl.standby])},snap_guide:{[tl.main]:[{type:"line",paint:{"line-color":"#00979f","line-width":1.8,"line-dasharray":[2,1]}}],[tl.temporary]:[{type:"line",paint:{"line-color":"#00979f","line-width":1.8,"line-dasharray":[2,1]}}],[tl.standby]:[{type:"line",paint:{"line-color":"#00979f","line-width":1.8,"line-dasharray":[2,1]}}]}},controls:{draw:{marker:{title:"Marker",icon:Q.marker,uiEnabled:!0,active:!1},circle_marker:{title:"Circle Marker",icon:Q.circle_marker,uiEnabled:!0,active:!1},text_marker:{title:"Text Marker",icon:Q.text_marker,uiEnabled:!0,active:!1},circle:{title:"Circle",icon:Q.circle,uiEnabled:!0,active:!1},line:{title:"Line",icon:Q.line,uiEnabled:!0,active:!1},rectangle:{title:"Rectangle",icon:Q.rectangle,uiEnabled:!0,active:!1},polygon:{title:"Polygon",icon:Q.polygon,uiEnabled:!0,active:!1}},edit:{drag:{title:"Drag",icon:Q.drag,uiEnabled:!0,active:!1},change:{title:"Change",icon:Q.change,uiEnabled:!0,active:!1},rotate:{title:"Rotate",icon:Q.rotate,uiEnabled:!0,active:!1},cut:{title:"Cut",icon:Q.cut,uiEnabled:!0,active:!1},delete:{title:"Delete",icon:Q.delete,uiEnabled:!0,active:!1}},helper:{shape_markers:{title:"Shape markers",icon:null,uiEnabled:!0,active:!1},snapping:{title:"Snapping",icon:Q.snapping,uiEnabled:!0,active:!1},zoom_to_features:{title:"Zoom to features",icon:Q.zoom_to_features,uiEnabled:!0,active:!1}}}},hl=()=>$n(ul);var dl=Array.isArray,pl=Array.prototype.indexOf,fl=Array.from,ml=Object.defineProperty,gl=Object.getOwnPropertyDescriptor,yl=Object.getOwnPropertyDescriptors,_l=Object.prototype,vl=Array.prototype,xl=Object.getPrototypeOf;const bl=()=>{};function wl(e){return e()}function El(e){for(var t=0;t<e.length;t++)e[t]()}const Tl=32,Sl=128,Il=256,kl=512,Ml=1024,Cl=2048,Pl=4096,Al=8192,Ll=16384,Dl=65536,Rl=1<<20,zl=Symbol("$state"),Fl=Symbol("");let Ol=[];function Nl(){var e=Ol;Ol=[],El(e)}function Bl(e){return e===this.v}function Gl(e,t){return e!=e?t==t:e!==t||null!==e&&"object"==typeof e||"function"==typeof e}function jl(e){return!Gl(e,this.v)}let Vl=!1;const Ul=Symbol();function ql(e){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}let Zl=null;function $l(e){Zl=e}function Hl(e){return(null===Zl&&ql(),Zl.c??(Zl.c=new Map(function(e){let t=e.p;for(;null!==t;){const e=t.c;if(null!==e)return e;t=t.p}return null}(Zl)||void 0))).get(e)}function Wl(e,t=!1,i){Zl={p:Zl,c:null,e:null,m:!1,s:e,x:null,l:null},Vl&&!t&&(Zl.l={s:null,u:null,r1:[],r2:Jl(!1)})}function Xl(e){const t=Zl;if(null!==t){const e=t.e;if(null!==e){var i=Lc,n=Cc;t.e=null;try{for(var r=0;r<e.length;r++){var o=e[r];Dc(o.effect),Ac(o.reaction),lu(o.fn)}}finally{Dc(i),Ac(n)}}Zl=t.p,t.m=!0}return{}}function Yl(){return!Vl||null!==Zl&&null===Zl.l}function Jl(e,t){return{f:0,v:e,reactions:null,equals:Bl,rv:0,wv:0}}function Kl(e){return ec(Jl(e))}function Ql(e,t=!1){var i;const n=Jl(e);return t||(n.equals=jl),Vl&&null!==Zl&&null!==Zl.l&&((i=Zl.l).s??(i.s=[])).push(n),n}function ec(e){return null!==Cc&&!Pc&&!!(2&Cc.f)&&(null===Rc?function(e){Rc=e}([e]):Rc.push(e)),e}function tc(e,t){return null!==Cc&&!Pc&&Yl()&&!!(18&Cc.f)&&(null===Rc||!Rc.includes(e))&&function(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}(),ic(e,t)}function ic(e,t){return e.equals(t)||(e.v=t,e.wv=jc(),nc(e,Cl),Yl()&&null!==Lc&&0!==(Lc.f&Ml)&&!(96&Lc.f)&&(null===Oc?function(e){Oc=e}([e]):Oc.push(e))),t}function nc(e,t){var i=e.reactions;if(null!==i)for(var n=Yl(),r=i.length,o=0;o<r;o++){var s=i[o],a=s.f;0===(a&Cl)&&(!n&&s===Lc||(nu(s,t),1280&a&&(2&a?nc(s,Pl):Kc(s))))}}function rc(e){var t=2050,i=null!==Cc&&2&Cc.f?Cc:null;return null===Lc||null!==i&&0!==(i.f&Il)?t|=Il:Lc.f|=Rl,{ctx:Zl,deps:null,effects:null,equals:Bl,f:t,fn:e,reactions:null,rv:0,v:null,wv:0,parent:i??Lc}}function oc(e){const t=rc(e);return t.equals=jl,t}function sc(e){var t=e.effects;if(null!==t){e.effects=null;for(var i=0;i<t.length;i+=1)mu(t[i])}}function ac(e){var t=function(e){var t,i=Lc;Dc(function(e){for(var t=e.parent;null!==t;){if(!(2&t.f))return t;t=t.parent}return null}(e));try{sc(e),t=Zc(e)}finally{Dc(i)}return t}(e);nu(e,!Gc&&0===(e.f&Il)||null===e.deps?Ml:Pl),e.equals(t)||(e.v=t,e.wv=jc())}function lc(e,t=null,i){if("object"!=typeof e||null===e||zl in e)return e;const n=xl(e);if(n!==_l&&n!==vl)return e;var r,o=new Map,s=dl(e),a=Jl(0);return s&&o.set("length",Jl(e.length)),new Proxy(e,{defineProperty(e,t,i){(!("value"in i)||!1===i.configurable||!1===i.enumerable||!1===i.writable)&&function(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}();var n=o.get(t);return void 0===n?(n=Jl(i.value),o.set(t,n)):tc(n,lc(i.value,r)),!0},deleteProperty(e,t){var i=o.get(t);if(void 0===i)t in e&&o.set(t,Jl(Ul));else{if(s&&"string"==typeof t){var n=o.get("length"),r=Number(t);Number.isInteger(r)&&r<n.v&&tc(n,r)}tc(i,Ul),cc(a)}return!0},get(t,i,n){var s;if(i===zl)return e;var a=o.get(i),l=i in t;if(void 0===a&&(!l||null!=(s=gl(t,i))&&s.writable)&&(a=Jl(lc(l?t[i]:Ul,r)),o.set(i,a)),void 0!==a){var c=eu(a);return c===Ul?void 0:c}return Reflect.get(t,i,n)},getOwnPropertyDescriptor(e,t){var i=Reflect.getOwnPropertyDescriptor(e,t);if(i&&"value"in i){var n=o.get(t);n&&(i.value=eu(n))}else if(void 0===i){var r=o.get(t),s=null==r?void 0:r.v;if(void 0!==r&&s!==Ul)return{enumerable:!0,configurable:!0,value:s,writable:!0}}return i},has(e,t){var i;if(t===zl)return!0;var n=o.get(t),s=void 0!==n&&n.v!==Ul||Reflect.has(e,t);if((void 0!==n||null!==Lc&&(!s||null!=(i=gl(e,t))&&i.writable))&&(void 0===n&&(n=Jl(s?lc(e[t],r):Ul),o.set(t,n)),eu(n)===Ul))return!1;return s},set(e,t,i,n){var l,c=o.get(t),u=t in e;if(s&&"length"===t)for(var h=i;h<c.v;h+=1){var d=o.get(h+"");void 0!==d?tc(d,Ul):h in e&&(d=Jl(Ul),o.set(h+"",d))}void 0===c?(!u||null!=(l=gl(e,t))&&l.writable)&&(tc(c=Jl(void 0),lc(i,r)),o.set(t,c)):(u=c.v!==Ul,tc(c,lc(i,r)));var p=Reflect.getOwnPropertyDescriptor(e,t);if(null!=p&&p.set&&p.set.call(n,i),!u){if(s&&"string"==typeof t){var f=o.get("length"),m=Number(t);Number.isInteger(m)&&m>=f.v&&tc(f,m+1)}cc(a)}return!0},ownKeys(e){eu(a);var t=Reflect.ownKeys(e).filter(e=>{var t=o.get(e);return void 0===t||t.v!==Ul});for(var[i,n]of o)n.v!==Ul&&!(i in e)&&t.push(i);return t},setPrototypeOf(){!function(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}()}})}function cc(e,t=1){tc(e,e.v+t)}function uc(e){return null!==e&&"object"==typeof e&&zl in e?e[zl]:e}function hc(e,t){return Object.is(uc(e),uc(t))}var dc,pc,fc,mc;function gc(e=""){return document.createTextNode(e)}function yc(e){return fc.call(e)}function _c(e){return mc.call(e)}function vc(e,t){return yc(e)}function xc(e,t){var i=yc(e);return i instanceof Comment&&""===i.data?_c(i):i}function bc(e,t=1,i=!1){let n=e;for(;t--;)n=_c(n);return n}let wc=!1,Ec=!1,Tc=null,Sc=!1,Ic=!1;function kc(e){Ic=e}let Mc=[],Cc=null,Pc=!1;function Ac(e){Cc=e}let Lc=null;function Dc(e){Lc=e}let Rc=null;let zc=null,Fc=0,Oc=null;let Nc=1,Bc=0,Gc=!1;function jc(){return++Nc}function Vc(e){var t,i=e.f;if(0!==(i&Cl))return!0;if(0!==(i&Pl)){var n=e.deps,r=0!==(i&Il);if(null!==n){var o,s,a=0!==(i&kl),l=r&&null!==Lc&&!Gc,c=n.length;if(a||l){var u=e,h=u.parent;for(o=0;o<c;o++)s=n[o],(a||null==(t=null==s?void 0:s.reactions)||!t.includes(u))&&(s.reactions??(s.reactions=[])).push(u);a&&(u.f^=kl),l&&null!==h&&0===(h.f&Il)&&(u.f^=Il)}for(o=0;o<c;o++)if(Vc(s=n[o])&&ac(s),s.wv>e.wv)return!0}(!r||null!==Lc&&!Gc)&&nu(e,Ml)}return!1}function Uc(e,t,i,n){if(wc){if(null===i&&(wc=!1),function(e){return 0===(e.f&Ll)&&(null===e.parent||0===(e.parent.f&Sl))}(t))throw e}else null!==i&&(wc=!0),function(e,t){for(var i=t;null!==i;){if(0!==(i.f&Sl))try{return void i.fn(e)}catch{i.f^=Sl}i=i.parent}throw wc=!1,e}(e,t)}function qc(e,t,i=!0){var n=e.reactions;if(null!==n)for(var r=0;r<n.length;r++){var o=n[r];2&o.f?qc(o,t,!1):t===o&&(i?nu(o,Cl):0!==(o.f&Ml)&&nu(o,Pl),Kc(o))}}function Zc(e){var t,i=zc,n=Fc,r=Oc,o=Cc,s=Gc,a=Rc,l=Zl,c=Pc,u=e.f;zc=null,Fc=0,Oc=null,Gc=0!==(u&Il)&&(Pc||!Sc||null===Cc),Cc=96&u?null:e,Rc=null,$l(e.ctx),Pc=!1,Bc++;try{var h=(0,e.fn)(),d=e.deps;if(null!==zc){var p;if(Hc(e,Fc),null!==d&&Fc>0)for(d.length=Fc+zc.length,p=0;p<zc.length;p++)d[Fc+p]=zc[p];else e.deps=d=zc;if(!Gc)for(p=Fc;p<d.length;p++)((t=d[p]).reactions??(t.reactions=[])).push(e)}else null!==d&&Fc<d.length&&(Hc(e,Fc),d.length=Fc);if(Yl()&&null!==Oc&&!Pc&&null!==d&&!(6146&e.f))for(p=0;p<Oc.length;p++)qc(Oc[p],e);return null!==o&&Bc++,h}finally{zc=i,Fc=n,Oc=r,Cc=o,Gc=s,Rc=a,$l(l),Pc=c}}function $c(e,t){let i=t.reactions;if(null!==i){var n=pl.call(i,e);if(-1!==n){var r=i.length-1;0===r?i=t.reactions=null:(i[n]=i[r],i.pop())}}null===i&&2&t.f&&(null===zc||!zc.includes(t))&&(nu(t,Pl),!(768&t.f)&&(t.f^=kl),sc(t),Hc(t,0))}function Hc(e,t){var i=e.deps;if(null!==i)for(var n=t;n<i.length;n++)$c(e,i[n])}function Wc(e){var t=e.f;if(0===(t&Ll)){nu(e,Ml);var i=Lc,n=Sc;Lc=e,Sc=!0;try{16&t?function(e){for(var t=e.first;null!==t;){var i=t.next;0===(t.f&Tl)&&mu(t),t=i}}(e):fu(e),pu(e);var r=Zc(e);e.teardown="function"==typeof r?r:null,e.wv=Nc;e.deps}catch(t){Uc(t,e,i)}finally{Sc=n,Lc=i}}}function Xc(){try{!function(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}()}catch(e){if(null===Tc)throw e;Uc(e,Tc,null)}}function Yc(){try{for(var e=0;Mc.length>0;){e++>1e3&&Xc();var t=Mc,i=t.length;Mc=[];for(var n=0;n<i;n++){var r=t[n];0===(r.f&Ml)&&(r.f^=Ml),Jc(Qc(r))}}}finally{Ec=!1,Tc=null}}function Jc(e){var t=e.length;if(0!==t)for(var i=0;i<t;i++){var n=e[i];if(!(24576&n.f))try{Vc(n)&&(Wc(n),null===n.deps&&null===n.first&&null===n.nodes_start&&(null===n.teardown?gu(n):n.fn=null))}catch(e){Uc(e,n,null)}}}function Kc(e){Ec||(Ec=!0,queueMicrotask(Yc));for(var t=Tc=e;null!==t.parent;){var i=(t=t.parent).f;if(96&i){if(0===(i&Ml))return;t.f^=Ml}}Mc.push(t)}function Qc(e){for(var t=[],i=e.first;null!==i;){var n=i.f,r=0!==(n&Tl);if(!(r&&0!==(n&Ml))&&0===(n&Al)){if(4&n)t.push(i);else if(r)i.f^=Ml;else{var o=Cc;try{Cc=i,Vc(i)&&Wc(i)}catch(e){Uc(e,i,null)}finally{Cc=o}}var s=i.first;if(null!==s){i=s;continue}}var a=i.parent;for(i=i.next;null===i&&null!==a;)i=a.next,a=a.parent}return t}function eu(e){var t=!!(2&e.f);if(null===Cc||Pc){if(t&&null===e.deps&&null===e.effects){var i=e,n=i.parent;null!==n&&0===(n.f&Il)&&(i.f^=Il)}}else{null!==Rc&&Rc.includes(e)&&function(){throw new Error("https://svelte.dev/e/state_unsafe_local_read")}();var r=Cc.deps;e.rv<Bc&&(e.rv=Bc,null===zc&&null!==r&&r[Fc]===e?Fc++:null===zc?zc=[e]:(!Gc||!zc.includes(e))&&zc.push(e))}return t&&(Vc(i=e)&&ac(i)),e.v}function tu(e){var t=Pc;try{return Pc=!0,e()}finally{Pc=t}}const iu=-7169;function nu(e,t){e.f=e.f&iu|t}function ru(e,t=new Set){if(!("object"!=typeof e||null===e||e instanceof EventTarget||t.has(e))){t.add(e),e instanceof Date&&e.getTime();for(let i in e)try{ru(e[i],t)}catch{}const i=xl(e);if(i!==Object.prototype&&i!==Array.prototype&&i!==Map.prototype&&i!==Set.prototype&&i!==Date.prototype){const t=yl(i);for(let i in t){const n=t[i].get;if(n)try{n.call(e)}catch{}}}}}function ou(e){null===Lc&&null===Cc&&function(){throw new Error("https://svelte.dev/e/effect_orphan")}(),null!==Cc&&0!==(Cc.f&Il)&&null===Lc&&function(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}(),Ic&&function(){throw new Error("https://svelte.dev/e/effect_in_teardown")}()}function su(e,t,i,n=!0){var r=!!(64&e),o=Lc,s={ctx:Zl,deps:null,nodes_start:null,nodes_end:null,f:e|Cl,first:null,fn:t,last:null,next:null,parent:r?null:o,prev:null,teardown:null,transitions:null,wv:0};if(i)try{Wc(s),s.f|=32768}catch(e){throw mu(s),e}else null!==t&&Kc(s);if(!(i&&null===s.deps&&null===s.first&&null===s.nodes_start&&null===s.teardown&&0===(s.f&(Rl|Sl)))&&!r&&n&&(null!==o&&function(e,t){var i=t.last;null===i?t.last=t.first=e:(i.next=e,e.prev=i,t.last=e)}(s,o),null!==Cc&&2&Cc.f)){var a=Cc;(a.effects??(a.effects=[])).push(s)}return s}function au(e){if(ou(),!(null!==Lc&&0!==(Lc.f&Tl)&&null!==Zl&&!Zl.m))return lu(e);var t=Zl;(t.e??(t.e=[])).push({fn:e,effect:Lc,reaction:Cc})}function lu(e){return su(4,e,!1)}function cu(e){return su(8,e,!0)}function uu(e,t=[],i=rc){const n=t.map(i);return hu(()=>e(...n.map(eu)))}function hu(e,t=0){return su(24|t,e,!0)}function du(e,t=!0){return su(40,e,!0,t)}function pu(e){var t=e.teardown;if(null!==t){const e=Ic,i=Cc;kc(!0),Ac(null);try{t.call(null)}finally{kc(e),Ac(i)}}}function fu(e,t=!1){var i=e.first;for(e.first=e.last=null;null!==i;){var n=i.next;mu(i,t),i=n}}function mu(e,t=!0){var i=!1;if((t||524288&e.f)&&null!==e.nodes_start){for(var n=e.nodes_start,r=e.nodes_end;null!==n;){var o=n===r?null:_c(n);n.remove(),n=o}i=!0}fu(e,t&&!i),Hc(e,0),nu(e,Ll);var s=e.transitions;if(null!==s)for(const e of s)e.stop();pu(e);var a=e.parent;null!==a&&null!==a.first&&gu(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes_start=e.nodes_end=null}function gu(e){var t=e.parent,i=e.prev,n=e.next;null!==i&&(i.next=n),null!==n&&(n.prev=i),null!==t&&(t.first===e&&(t.first=n),t.last===e&&(t.last=i))}function yu(e,t){var i=[];vu(e,i,!0),_u(i,()=>{mu(e),t&&t()})}function _u(e,t){var i=e.length;if(i>0){var n=()=>--i||t();for(var r of e)r.out(n)}else t()}function vu(e,t,i){if(0===(e.f&Al)){if(e.f^=Al,null!==e.transitions)for(const n of e.transitions)(n.is_global||i)&&t.push(n);for(var n=e.first;null!==n;){var r=n.next;vu(n,t,!!(0!==(n.f&Dl)||0!==(n.f&Tl))&&i),n=r}}}function xu(e){bu(e,!0)}function bu(e,t){if(0!==(e.f&Al)){e.f^=Al,0===(e.f&Ml)&&(e.f^=Ml),Vc(e)&&(nu(e,Cl),Kc(e));for(var i=e.first;null!==i;){var n=i.next;bu(i,!!(0!==(i.f&Dl)||0!==(i.f&Tl))&&t),i=n}if(null!==e.transitions)for(const i of e.transitions)(i.is_global||t)&&i.in()}}const wu=["touchstart","touchmove"];function Eu(e){return wu.includes(e)}let Tu=!1;function Su(e,t,i,n=i){e.addEventListener(t,()=>function(e){var t=Cc,i=Lc;Ac(null),Dc(null);try{return e()}finally{Ac(t),Dc(i)}}(i));const r=e.__on_r;e.__on_r=r?()=>{r(),n(!0)}:()=>n(!0),Tu||(Tu=!0,document.addEventListener("reset",e=>{Promise.resolve().then(()=>{var t;if(!e.defaultPrevented)for(const i of e.target.elements)null==(t=i.__on_r)||t.call(i)})},{capture:!0}))}const Iu=new Set,ku=new Set;function Mu(e){for(var t=0;t<e.length;t++)Iu.add(e[t]);for(var i of ku)i(e)}function Cu(e){var t,i=this,n=i.ownerDocument,r=e.type,o=(null==(t=e.composedPath)?void 0:t.call(e))||[],s=o[0]||e.target,a=0,l=e.__root;if(l){var c=o.indexOf(l);if(-1!==c&&(i===document||i===window))return void(e.__root=i);var u=o.indexOf(i);if(-1===u)return;c<=u&&(a=c)}if((s=o[a]||e.target)!==i){ml(e,"currentTarget",{configurable:!0,get:()=>s||n});var h=Cc,d=Lc;Ac(null),Dc(null);try{for(var p,f=[];null!==s;){var m=s.assignedSlot||s.parentNode||s.host||null;try{var g=s["__"+r];if(void 0!==g&&(!s.disabled||e.target===s))if(dl(g)){var[y,..._]=g;y.apply(s,[e,..._])}else g.call(s,e)}catch(e){p?f.push(e):p=e}if(e.cancelBubble||m===i||null===m)break;s=m}if(p){for(let e of f)queueMicrotask(()=>{throw e});throw p}}finally{e.__root=i,delete e.currentTarget,Ac(h),Dc(d)}}}function Pu(e){var t=document.createElement("template");return t.innerHTML=e,t.content}function Au(e,t){var i=Lc;null===i.nodes_start&&(i.nodes_start=e,i.nodes_end=t)}function Lu(e,t){var i,n=!!(1&t),r=!!(2&t),o=!e.startsWith("<!>");return()=>{void 0===i&&(i=Pu(o?e:"<!>"+e),n||(i=yc(i)));var t=r||pc?document.importNode(i,!0):i.cloneNode(!0);n?Au(yc(t),t.lastChild):Au(t,t);return t}}function Du(e=""){var t=gc(e+"");return Au(t,t),t}function Ru(){var e=document.createDocumentFragment(),t=document.createComment(""),i=gc();return e.append(t,i),Au(t,i),e}function zu(e,t){null!==e&&e.before(t)}function Fu(e,t){var i=null==t?"":"object"==typeof t?t+"":t;i!==(e.__t??(e.__t=e.nodeValue))&&(e.__t=i,e.nodeValue=i+"")}function Ou(e,t){return function(e,{target:t,anchor:i,props:n={},events:r,context:o,intro:s=!0}){!function(){if(void 0===dc){dc=window,pc=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype;fc=gl(t,"firstChild").get,mc=gl(t,"nextSibling").get,e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__styles=null,e.__e=void 0,Text.prototype.__t=void 0}}();var a=new Set,l=e=>{for(var i=0;i<e.length;i++){var n=e[i];if(!a.has(n)){a.add(n);var r=Eu(n);t.addEventListener(n,Cu,{passive:r});var o=Nu.get(n);void 0===o?(document.addEventListener(n,Cu,{passive:r}),Nu.set(n,1)):Nu.set(n,o+1)}}};l(fl(Iu)),ku.add(l);var c=void 0,u=function(e){const t=su(64,e,!0);return(e={})=>new Promise(i=>{e.outro?yu(t,()=>{mu(t),i(void 0)}):(mu(t),i(void 0))})}(()=>{var s=i??t.appendChild(gc());return du(()=>{o&&(Wl({}),Zl.c=o);r&&(n.$$events=r),c=e(s,n)||{},o&&Xl()}),()=>{var e;for(var n of a){t.removeEventListener(n,Cu);var r=Nu.get(n);0===--r?(document.removeEventListener(n,Cu),Nu.delete(n)):Nu.set(n,r)}ku.delete(l),s!==i&&(null==(e=s.parentNode)||e.removeChild(s))}});return Bu.set(c,u),c}(e,t)}const Nu=new Map;let Bu=new WeakMap;function Gu(e,t,[i,n]=[0,0]){var r=e,o=null,s=null,a=Ul,l=!1;const c=(e,t=!0)=>{l=!0,u(t,e)},u=(e,t)=>{a!==(a=e)&&(a?(o?xu(o):t&&(o=du(()=>t(r))),s&&yu(s,()=>{s=null})):(s?xu(s):t&&(s=du(()=>t(r,[i+1,n]))),o&&yu(o,()=>{o=null})))};hu(()=>{l=!1,t(c),l||u(null,null)},i>0?Dl:0)}function ju(e,t){return t}function Vu(e,t,i,n,r,o=null){var s=e,a={flags:t,items:new Map,first:null};!(4&t)||(s=e.appendChild(gc()));var l=null,c=!1,u=oc(()=>{var e=i();return dl(e)?e:null==e?[]:fl(e)});hu(()=>{var e=eu(u),h=e.length;c&&0===h||(c=0===h,function(e,t,i,n,r,o,s){var a,l,c,u,h,d,p,f,m,g,y=!!(8&r),_=!!(3&r),v=e.length,x=t.items,b=t.first,w=b,E=null,T=[],S=[];if(y)for(g=0;g<v;g+=1)p=e[g],f=o(p,g),void 0!==(m=x.get(f))&&(null==(a=m.a)||a.measure(),(d??(d=new Set)).add(m));for(g=0;g<v;g+=1)if(f=o(p=e[g],g),void 0!==(m=x.get(f))){if(_&&Uu(m,p,g,r),0!==(m.e.f&Al)&&(xu(m.e),y&&(null==(l=m.a)||l.unfix(),(d??(d=new Set)).delete(m))),m!==w){if(void 0!==h&&h.has(m)){if(T.length<S.length){var I,k=S[0];E=k.prev;var M=T[0],C=T[T.length-1];for(I=0;I<T.length;I+=1)Zu(T[I],k,i);for(I=0;I<S.length;I+=1)h.delete(S[I]);$u(t,M.prev,C.next),$u(t,E,M),$u(t,C,k),w=k,E=C,g-=1,T=[],S=[]}else h.delete(m),Zu(m,w,i),$u(t,m.prev,m.next),$u(t,m,null===E?t.first:E.next),$u(t,E,m),E=m;continue}for(T=[],S=[];null!==w&&w.k!==f;)0===(w.e.f&Al)&&(h??(h=new Set)).add(w),S.push(w),w=w.next;if(null===w)continue;m=w}T.push(m),E=m,w=m.next}else{E=qu(w?w.e.nodes_start:i,t,E,null===E?t.first:E.next,p,f,g,n,r,s),x.set(f,E),T=[],S=[],w=E.next}if(null!==w||void 0!==h){for(var P=void 0===h?[]:fl(h);null!==w;)0===(w.e.f&Al)&&P.push(w),w=w.next;var A=P.length;if(A>0){var L=4&r&&0===v?i:null;if(y){for(g=0;g<A;g+=1)null==(c=P[g].a)||c.measure();for(g=0;g<A;g+=1)null==(u=P[g].a)||u.fix()}!function(e,t,i,n){for(var r=[],o=t.length,s=0;s<o;s++)vu(t[s].e,r,!0);var a=o>0&&0===r.length&&null!==i;if(a){var l=i.parentNode;(function(e){e.textContent=""})(l),l.append(i),n.clear(),$u(e,t[0].prev,t[o-1].next)}_u(r,()=>{for(var i=0;i<o;i++){var r=t[i];a||(n.delete(r.k),$u(e,r.prev,r.next)),mu(r.e,!a)}})}(t,P,L,x)}}y&&function(e){0===Ol.length&&queueMicrotask(Nl),Ol.push(e)}(()=>{var e;if(void 0!==d)for(m of d)null==(e=m.a)||e.apply()}),Lc.first=t.first&&t.first.e,Lc.last=E&&E.e}(e,a,s,r,t,n,i),null!==o&&(0===h?l?xu(l):l=du(()=>o(s)):null!==l&&yu(l,()=>{l=null})),eu(u))})}function Uu(e,t,i,n){!!(1&n)&&ic(e.v,t),2&n?ic(e.i,i):e.i=i}function qu(e,t,i,n,r,o,s,a,l,c){var u=!!(1&l)?!(16&l)?Ql(r):Jl(r):r,h=2&l?Jl(s):s,d={i:h,v:u,k:o,a:null,e:null,prev:i,next:n};try{return d.e=du(()=>a(e,u,h,c),false),d.e.prev=i&&i.e,d.e.next=n&&n.e,null===i?t.first=d:(i.next=d,i.e.next=d.e),null!==n&&(n.prev=d,n.e.prev=d.e),d}finally{}}function Zu(e,t,i){for(var n=e.next?e.next.e.nodes_start:i,r=t?t.e.nodes_start:i,o=e.e.nodes_start;o!==n;){var s=_c(o);r.before(o),o=s}}function $u(e,t,i){null===t?e.first=i:(t.next=i,t.e.next=i&&i.e),null!==i&&(i.prev=t,i.e.prev=t&&t.e)}const Hu=[..." \t\n\r\f \v\ufeff"];function Wu(e,t,i,n,r,o){if(e.__className!==i){var s=function(e,t,i){var n=null==e?"":""+e;if(t&&(n=n?n+" "+t:t),i)for(var r in i)if(i[r])n=n?n+" "+r:r;else if(n.length)for(var o=r.length,s=0;(s=n.indexOf(r,s))>=0;){var a=s+o;0!==s&&!Hu.includes(n[s-1])||a!==n.length&&!Hu.includes(n[a])?s=a:n=(0===s?"":n.substring(0,s))+n.substring(a+1)}return""===n?null:n}(i,n,o);null==s?e.removeAttribute("class"):e.className=s,e.__className=i}else if(o)for(var a in o){var l=!!o[a];(null==r||l!==!!r[a])&&e.classList.toggle(a,l)}return o}function Xu(e,t,i,n){var r=e.__attributes??(e.__attributes={});r[t]!==(r[t]=i)&&("style"===t&&"__styles"in e&&(e.__styles={}),"loading"===t&&(e[Fl]=i),null==i?e.removeAttribute(t):"string"!=typeof i&&function(e){var t=Yu.get(e.nodeName);if(t)return t;Yu.set(e.nodeName,t=[]);for(var i,n=e,r=Element.prototype;r!==n;){for(var o in i=yl(n))i[o].set&&t.push(o);n=xl(n)}return t}(e).includes(t)?e[t]=i:e.setAttribute(t,i))}var Yu=new Map;function Ju(e,t,i){if(e.multiple)return function(e,t){for(var i of e.options)i.selected=~t.indexOf(Qu(i))}(e,t);for(var n of e.options){if(hc(Qu(n),t))return void(n.selected=!0)}(!i||void 0!==t)&&(e.selectedIndex=-1)}function Ku(e,t,i=t){var n=!0;Su(e,"change",t=>{var n,r=t?"[selected]":":checked";if(e.multiple)n=[].map.call(e.querySelectorAll(r),Qu);else{var o=e.querySelector(r)??e.querySelector("option:not([disabled])");n=o&&Qu(o)}i(n)}),lu(()=>{var r=t();if(Ju(e,r,n),n&&void 0===r){var o=e.querySelector(":checked");null!==o&&(r=Qu(o),i(r))}e.__value=r,n=!1}),function(e){lu(()=>{var t=new MutationObserver(()=>{var t=e.__value;Ju(e,t)});return t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),()=>{t.disconnect()}})}(e)}function Qu(e){return"__value"in e?e.__value:e.value}function eh(e=!1){const t=Zl,i=t.l.u;if(!i)return;let n=()=>function(e){if("object"==typeof e&&e&&!(e instanceof EventTarget))if(zl in e)ru(e);else if(!Array.isArray(e))for(let t in e){const i=e[t];"object"==typeof i&&i&&zl in i&&ru(i)}}(t.s);if(e){let e=0,i={};const r=rc(()=>{let n=!1;const r=t.s;for(const e in r)r[e]!==i[e]&&(i[e]=r[e],n=!0);return n&&e++,e});n=()=>eu(r)}i.b.length&&function(e){ou(),cu(e)}(()=>{th(t,n),El(i.b)}),au(()=>{const e=tu(()=>i.m.map(wl));return()=>{for(const t of e)"function"==typeof t&&t()}}),i.a.length&&au(()=>{th(t,n),El(i.a)})}function th(e,t){if(e.l.s)for(const t of e.l.s)eu(t);t()}let ih=Symbol();function nh(e,t,i){const n=i[t]??(i[t]={store:null,source:Ql(void 0),unsubscribe:bl});if(n.store!==e&&!(ih in i))if(n.unsubscribe(),n.store=e??null,null==e)n.source.v=void 0,n.unsubscribe=bl;else{var r=!0;n.unsubscribe=sh(e,e=>{r?n.source.v=e:tc(n.source,e)}),r=!1}return e&&ih in i?function(e){let t;return sh(e,e=>t=e)(),t}(e):eu(n.source)}function rh(){const e={};return[e,function(){!function(e){const t=su(8,null,!1);nu(t,Ml),t.teardown=e}(()=>{for(var t in e)e[t].unsubscribe();ml(e,ih,{enumerable:!1,value:!0})})}]}function oh(e){null===Zl&&ql(),Vl&&null!==Zl.l?function(e){var t=e.l;return t.u??(t.u={a:[],b:[],m:[]})}(Zl).m.push(e):au(()=>{const t=tu(e);if("function"==typeof t)return t})}function sh(e,t,i){if(null==e)return t(void 0),bl;const n=tu(()=>e.subscribe(t,i));return n.unsubscribe?()=>n.unsubscribe():n}const ah=[];const lh=function(e,t=bl){let i=null;const n=new Set;function r(t){if(Gl(e,t)&&(e=t,i)){const t=!ah.length;for(const t of n)t[1](),ah.push(t,e);if(t){for(let e=0;e<ah.length;e+=2)ah[e][0](ah[e+1]);ah.length=0}}}function o(t){r(t(e))}return{set:r,update:o,subscribe:function(s,a=bl){const l=[s,a];return n.add(l),1===n.size&&(i=t(r,o)||bl),s(e),()=>{n.delete(l),0===n.size&&i&&(i(),i=null)}}}}({controls:$n(J),options:hl().controls});typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add("5"),Vl=!0;const ch=(e,t,i)=>{var n,r;if(t.actionInstance&&t.actionOption){if("toggle"===(null==(n=t.actionOption)?void 0:n.type)){tc(i,lc(e.target.checked))}else if("select"===(null==(r=t.actionOption)?void 0:r.type)){tc(i,lc(e.target.value))}t.actionInstance.applyOptionValue(t.actionOption.name,eu(i))}else he.error("Can't apply option value",t.actionInstance,t.actionOption)};var uh=Lu("<option> </option>"),hh=Lu('<label class="svelte-1892xbw"> </label> <select class="svelte-1892xbw"></select>',1),dh=Lu('<label class="svelte-1892xbw"><input type="checkbox" class="svelte-1892xbw"> </label>'),ph=Lu("<span>Unknown type</span>"),fh=Lu('<div class="action-option svelte-1892xbw"><!></div>');function mh(e,t){Wl(t,!0);let i=Kl("");oh(()=>{t.actionOption&&("select"===t.actionOption.type?tc(i,lc(t.actionOption.value.value)):"toggle"===t.actionOption.type&&tc(i,lc(t.actionOption.value)))});var n=Ru(),r=xc(n),o=e=>{var n=fh(),r=vc(n),o=e=>{var n=hh(),r=xc(n),o=vc(r),s=bc(r,2);s.__change=[ch,t,i],Vu(s,21,()=>t.actionOption.choices,ju,(e,t)=>{var i=uh(),n={},r=vc(i);uu(()=>{n!==(n=eu(t).value)&&(i.value=null==(i.__value=eu(t).value)?"":eu(t).value),Fu(r,eu(t).title)}),zu(e,i)}),uu(()=>{Xu(r,"for",t.actionOption.name),Fu(o,t.actionOption.label),Xu(s,"id",t.actionOption.name)}),Ku(s,()=>eu(i),e=>tc(i,e)),zu(e,n)},s=(e,n)=>{var r=e=>{var n=dh(),r=vc(n);r.__change=[ch,t,i];var o=bc(r);uu(e=>{Xu(n,"for",t.actionOption.name),Xu(r,"id",e),Fu(o,` ${t.actionOption.label??""}`)},[()=>String(t.actionOption.name)]),function(e,t,i=t){Su(e,"change",t=>{var n=t?e.defaultChecked:e.checked;i(n)}),null==tu(t)&&i(e.checked),cu(()=>{var i=t();e.checked=!!i})}(r,()=>eu(i),e=>tc(i,e)),zu(e,n)},o=e=>{zu(e,ph())};Gu(e,e=>{"toggle"===t.actionOption.type&&"boolean"==typeof eu(i)?e(r):e(o,!1)},n)};Gu(r,e=>{"select"===t.actionOption.type?e(o):e(s,!1)}),zu(e,n)};Gu(r,e=>{t.actionOption&&e(o)}),zu(e,n),Xl()}Mu(["change"]);const gh=(e,t)=>{e.preventDefault(),t.actionInstance&&t.subAction?t.subAction.method():he.error("Can't run a SubAction",t.actionInstance,t.subAction)};var yh=Lu('<button type="submit" class="sub-action svelte-1x28ief"> </button>');Mu(["click"]);var _h=Lu("<!> <!>",1);function vh(e,t){Wl(t,!0);const i=Hl("gm"),n=t.control.type,r=t.control.targetMode;let o=Kl(null);n&&r&&tc(o,lc(i.actionInstances[`${n}__${r}`]||null));var s=Ru(),a=xc(s),l=e=>{var t=_h(),i=xc(t);Vu(i,17,()=>eu(o).options,ju,(e,t)=>{mh(e,{get actionInstance(){return eu(o)},get actionOption(){return eu(t)}})}),Vu(bc(i,2),17,()=>eu(o).actions,ju,(e,t)=>{!function(e,t){Wl(t,!0);var i=Ru(),n=xc(i),r=e=>{var i=yh();i.__click=[gh,t];var n=vc(i);uu(()=>{Xu(i,"title",t.subAction.label),Fu(n,t.subAction.label)}),zu(e,i)};Gu(n,e=>{t.subAction&&e(r)}),zu(e,i),Xl()}(e,{get actionInstance(){return eu(o)},get subAction(){return eu(t)}})}),zu(e,t)};Gu(a,e=>{eu(o)&&e(l)}),zu(e,s),Xl()}const{entries:xh,setPrototypeOf:bh,isFrozen:wh,getPrototypeOf:Eh,getOwnPropertyDescriptor:Th}=Object;let{freeze:Sh,seal:Ih,create:kh}=Object,{apply:Mh,construct:Ch}=typeof Reflect<"u"&&Reflect;Sh||(Sh=function(e){return e}),Ih||(Ih=function(e){return e}),Mh||(Mh=function(e,t,i){return e.apply(t,i)}),Ch||(Ch=function(e,t){return new e(...t)});const Ph=qh(Array.prototype.forEach),Ah=qh(Array.prototype.lastIndexOf),Lh=qh(Array.prototype.pop),Dh=qh(Array.prototype.push),Rh=qh(Array.prototype.splice),zh=qh(String.prototype.toLowerCase),Fh=qh(String.prototype.toString),Oh=qh(String.prototype.match),Nh=qh(String.prototype.replace),Bh=qh(String.prototype.indexOf),Gh=qh(String.prototype.trim),jh=qh(Object.prototype.hasOwnProperty),Vh=qh(RegExp.prototype.test),Uh=function(e){return function(){for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];return Ch(e,i)}}(TypeError);function qh(e){return function(t){for(var i=arguments.length,n=new Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];return Mh(e,t,n)}}function Zh(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:zh;bh&&bh(e,null);let n=t.length;for(;n--;){let r=t[n];if("string"==typeof r){const e=i(r);e!==r&&(wh(t)||(t[n]=e),r=e)}e[r]=!0}return e}function $h(e){for(let t=0;t<e.length;t++)jh(e,t)||(e[t]=null);return e}function Hh(e){const t=kh(null);for(const[i,n]of xh(e))jh(e,i)&&(Array.isArray(n)?t[i]=$h(n):n&&"object"==typeof n&&n.constructor===Object?t[i]=Hh(n):t[i]=n);return t}function Wh(e,t){for(;null!==e;){const i=Th(e,t);if(i){if(i.get)return qh(i.get);if("function"==typeof i.value)return qh(i.value)}e=Eh(e)}return function(){return null}}const Xh=Sh(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Yh=Sh(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Jh=Sh(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Kh=Sh(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Qh=Sh(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),ed=Sh(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),td=Sh(["#text"]),id=Sh(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),nd=Sh(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),rd=Sh(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),od=Sh(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),sd=Ih(/\{\{[\w\W]*|[\w\W]*\}\}/gm),ad=Ih(/<%[\w\W]*|[\w\W]*%>/gm),ld=Ih(/\$\{[\w\W]*/gm),cd=Ih(/^data-[\-\w.\u00B7-\uFFFF]+$/),ud=Ih(/^aria-[\-\w]+$/),hd=Ih(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),dd=Ih(/^(?:\w+script|data):/i),pd=Ih(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),fd=Ih(/^html$/i),md=Ih(/^[a-z][.\w]*(-[.\w]+)+$/i);var gd=Object.freeze({__proto__:null,ARIA_ATTR:ud,ATTR_WHITESPACE:pd,CUSTOM_ELEMENT:md,DATA_ATTR:cd,DOCTYPE_NAME:fd,ERB_EXPR:ad,IS_ALLOWED_URI:hd,IS_SCRIPT_OR_DATA:dd,MUSTACHE_EXPR:sd,TMPLIT_EXPR:ld});const yd=1,_d=3,vd=7,xd=8,bd=9;var wd=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:typeof window>"u"?null:window;const i=t=>e(t);if(i.version="3.2.4",i.removed=[],!t||!t.document||t.document.nodeType!==bd||!t.Element)return i.isSupported=!1,i;let{document:n}=t;const r=n,o=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:a,Node:l,Element:c,NodeFilter:u,NamedNodeMap:h=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:d,DOMParser:p,trustedTypes:f}=t,m=c.prototype,g=Wh(m,"cloneNode"),y=Wh(m,"remove"),_=Wh(m,"nextSibling"),v=Wh(m,"childNodes"),x=Wh(m,"parentNode");if("function"==typeof a){const e=n.createElement("template");e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let b,w="";const{implementation:E,createNodeIterator:T,createDocumentFragment:S,getElementsByTagName:I}=n,{importNode:k}=r;let M={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};i.isSupported="function"==typeof xh&&"function"==typeof x&&E&&void 0!==E.createHTMLDocument;const{MUSTACHE_EXPR:C,ERB_EXPR:P,TMPLIT_EXPR:A,DATA_ATTR:L,ARIA_ATTR:D,IS_SCRIPT_OR_DATA:R,ATTR_WHITESPACE:z,CUSTOM_ELEMENT:F}=gd;let{IS_ALLOWED_URI:O}=gd,N=null;const B=Zh({},[...Xh,...Yh,...Jh,...Qh,...td]);let G=null;const j=Zh({},[...id,...nd,...rd,...od]);let V=Object.seal(kh(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),U=null,q=null,Z=!0,$=!0,H=!1,W=!0,X=!1,Y=!0,J=!1,K=!1,Q=!1,ee=!1,te=!1,ie=!1,ne=!0,re=!1,oe=!0,se=!1,ae={},le=null;const ce=Zh({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let ue=null;const he=Zh({},["audio","video","img","source","image","track"]);let de=null;const pe=Zh({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),fe="http://www.w3.org/1998/Math/MathML",me="http://www.w3.org/2000/svg",ge="http://www.w3.org/1999/xhtml";let ye=ge,_e=!1,ve=null;const xe=Zh({},[fe,me,ge],Fh);let be=Zh({},["mi","mo","mn","ms","mtext"]),we=Zh({},["annotation-xml"]);const Ee=Zh({},["title","style","font","a","script"]);let Te=null;const Se=["application/xhtml+xml","text/html"];let Ie=null,ke=null;const Me=n.createElement("form"),Ce=function(e){return e instanceof RegExp||e instanceof Function},Pe=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!ke||ke!==e){if((!e||"object"!=typeof e)&&(e={}),e=Hh(e),Te=-1===Se.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,Ie="application/xhtml+xml"===Te?Fh:zh,N=jh(e,"ALLOWED_TAGS")?Zh({},e.ALLOWED_TAGS,Ie):B,G=jh(e,"ALLOWED_ATTR")?Zh({},e.ALLOWED_ATTR,Ie):j,ve=jh(e,"ALLOWED_NAMESPACES")?Zh({},e.ALLOWED_NAMESPACES,Fh):xe,de=jh(e,"ADD_URI_SAFE_ATTR")?Zh(Hh(pe),e.ADD_URI_SAFE_ATTR,Ie):pe,ue=jh(e,"ADD_DATA_URI_TAGS")?Zh(Hh(he),e.ADD_DATA_URI_TAGS,Ie):he,le=jh(e,"FORBID_CONTENTS")?Zh({},e.FORBID_CONTENTS,Ie):ce,U=jh(e,"FORBID_TAGS")?Zh({},e.FORBID_TAGS,Ie):{},q=jh(e,"FORBID_ATTR")?Zh({},e.FORBID_ATTR,Ie):{},ae=!!jh(e,"USE_PROFILES")&&e.USE_PROFILES,Z=!1!==e.ALLOW_ARIA_ATTR,$=!1!==e.ALLOW_DATA_ATTR,H=e.ALLOW_UNKNOWN_PROTOCOLS||!1,W=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,X=e.SAFE_FOR_TEMPLATES||!1,Y=!1!==e.SAFE_FOR_XML,J=e.WHOLE_DOCUMENT||!1,ee=e.RETURN_DOM||!1,te=e.RETURN_DOM_FRAGMENT||!1,ie=e.RETURN_TRUSTED_TYPE||!1,Q=e.FORCE_BODY||!1,ne=!1!==e.SANITIZE_DOM,re=e.SANITIZE_NAMED_PROPS||!1,oe=!1!==e.KEEP_CONTENT,se=e.IN_PLACE||!1,O=e.ALLOWED_URI_REGEXP||hd,ye=e.NAMESPACE||ge,be=e.MATHML_TEXT_INTEGRATION_POINTS||be,we=e.HTML_INTEGRATION_POINTS||we,V=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&Ce(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(V.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&Ce(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(V.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(V.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),X&&($=!1),te&&(ee=!0),ae&&(N=Zh({},td),G=[],!0===ae.html&&(Zh(N,Xh),Zh(G,id)),!0===ae.svg&&(Zh(N,Yh),Zh(G,nd),Zh(G,od)),!0===ae.svgFilters&&(Zh(N,Jh),Zh(G,nd),Zh(G,od)),!0===ae.mathMl&&(Zh(N,Qh),Zh(G,rd),Zh(G,od))),e.ADD_TAGS&&(N===B&&(N=Hh(N)),Zh(N,e.ADD_TAGS,Ie)),e.ADD_ATTR&&(G===j&&(G=Hh(G)),Zh(G,e.ADD_ATTR,Ie)),e.ADD_URI_SAFE_ATTR&&Zh(de,e.ADD_URI_SAFE_ATTR,Ie),e.FORBID_CONTENTS&&(le===ce&&(le=Hh(le)),Zh(le,e.FORBID_CONTENTS,Ie)),oe&&(N["#text"]=!0),J&&Zh(N,["html","head","body"]),N.table&&(Zh(N,["tbody"]),delete U.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw Uh('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw Uh('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');b=e.TRUSTED_TYPES_POLICY,w=b.createHTML("")}else void 0===b&&(b=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let i=null;const n="data-tt-policy-suffix";t&&t.hasAttribute(n)&&(i=t.getAttribute(n));const r="dompurify"+(i?"#"+i:"");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch{return null}}(f,o)),null!==b&&"string"==typeof w&&(w=b.createHTML(""));Sh&&Sh(e),ke=e}},Ae=Zh({},[...Yh,...Jh,...Kh]),Le=Zh({},[...Qh,...ed]),De=function(e){Dh(i.removed,{element:e});try{x(e).removeChild(e)}catch{y(e)}},Re=function(e,t){try{Dh(i.removed,{attribute:t.getAttributeNode(e),from:t})}catch{Dh(i.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(ee||te)try{De(t)}catch{}else try{t.setAttribute(e,"")}catch{}},ze=function(e){let t=null,i=null;if(Q)e="<remove></remove>"+e;else{const t=Oh(e,/^[\r\n\t ]+/);i=t&&t[0]}"application/xhtml+xml"===Te&&ye===ge&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const r=b?b.createHTML(e):e;if(ye===ge)try{t=(new p).parseFromString(r,Te)}catch{}if(!t||!t.documentElement){t=E.createDocument(ye,"template",null);try{t.documentElement.innerHTML=_e?w:r}catch{}}const o=t.body||t.documentElement;return e&&i&&o.insertBefore(n.createTextNode(i),o.childNodes[0]||null),ye===ge?I.call(t,J?"html":"body")[0]:J?t.documentElement:o},Fe=function(e){return T.call(e.ownerDocument||e,e,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Oe=function(e){return e instanceof d&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof h)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},Ne=function(e){return"function"==typeof l&&e instanceof l};function Be(e,t,n){Ph(e,e=>{e.call(i,t,n,ke)})}const Ge=function(e){let t=null;if(Be(M.beforeSanitizeElements,e,null),Oe(e))return De(e),!0;const n=Ie(e.nodeName);if(Be(M.uponSanitizeElement,e,{tagName:n,allowedTags:N}),e.hasChildNodes()&&!Ne(e.firstElementChild)&&Vh(/<[/\w]/g,e.innerHTML)&&Vh(/<[/\w]/g,e.textContent)||e.nodeType===vd||Y&&e.nodeType===xd&&Vh(/<[/\w]/g,e.data))return De(e),!0;if(!N[n]||U[n]){if(!U[n]&&Ve(n)&&(V.tagNameCheck instanceof RegExp&&Vh(V.tagNameCheck,n)||V.tagNameCheck instanceof Function&&V.tagNameCheck(n)))return!1;if(oe&&!le[n]){const t=x(e)||e.parentNode,i=v(e)||e.childNodes;if(i&&t){for(let n=i.length-1;n>=0;--n){const r=g(i[n],!0);r.__removalCount=(e.__removalCount||0)+1,t.insertBefore(r,_(e))}}}return De(e),!0}return e instanceof c&&!function(e){let t=x(e);(!t||!t.tagName)&&(t={namespaceURI:ye,tagName:"template"});const i=zh(e.tagName),n=zh(t.tagName);return!!ve[e.namespaceURI]&&(e.namespaceURI===me?t.namespaceURI===ge?"svg"===i:t.namespaceURI===fe?"svg"===i&&("annotation-xml"===n||be[n]):!!Ae[i]:e.namespaceURI===fe?t.namespaceURI===ge?"math"===i:t.namespaceURI===me?"math"===i&&we[n]:!!Le[i]:e.namespaceURI===ge?!(t.namespaceURI===me&&!we[n]||t.namespaceURI===fe&&!be[n])&&!Le[i]&&(Ee[i]||!Ae[i]):!("application/xhtml+xml"!==Te||!ve[e.namespaceURI]))}(e)||("noscript"===n||"noembed"===n||"noframes"===n)&&Vh(/<\/no(script|embed|frames)/i,e.innerHTML)?(De(e),!0):(X&&e.nodeType===_d&&(t=e.textContent,Ph([C,P,A],e=>{t=Nh(t,e," ")}),e.textContent!==t&&(Dh(i.removed,{element:e.cloneNode()}),e.textContent=t)),Be(M.afterSanitizeElements,e,null),!1)},je=function(e,t,i){if(ne&&("id"===t||"name"===t)&&(i in n||i in Me))return!1;if((!$||q[t]||!Vh(L,t))&&(!Z||!Vh(D,t)))if(!G[t]||q[t]){if(!(Ve(e)&&(V.tagNameCheck instanceof RegExp&&Vh(V.tagNameCheck,e)||V.tagNameCheck instanceof Function&&V.tagNameCheck(e))&&(V.attributeNameCheck instanceof RegExp&&Vh(V.attributeNameCheck,t)||V.attributeNameCheck instanceof Function&&V.attributeNameCheck(t))||"is"===t&&V.allowCustomizedBuiltInElements&&(V.tagNameCheck instanceof RegExp&&Vh(V.tagNameCheck,i)||V.tagNameCheck instanceof Function&&V.tagNameCheck(i))))return!1}else if(!de[t]&&!Vh(O,Nh(i,z,""))&&("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==Bh(i,"data:")||!ue[e])&&(!H||Vh(R,Nh(i,z,"")))&&i)return!1;return!0},Ve=function(e){return"annotation-xml"!==e&&Oh(e,F)},Ue=function(e){Be(M.beforeSanitizeAttributes,e,null);const{attributes:t}=e;if(!t||Oe(e))return;const n={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:G,forceKeepAttr:void 0};let r=t.length;for(;r--;){const o=t[r],{name:s,namespaceURI:a,value:l}=o,c=Ie(s);let u="value"===s?l:Gh(l);if(n.attrName=c,n.attrValue=u,n.keepAttr=!0,n.forceKeepAttr=void 0,Be(M.uponSanitizeAttribute,e,n),u=n.attrValue,re&&("id"===c||"name"===c)&&(Re(s,e),u="user-content-"+u),Y&&Vh(/((--!?|])>)|<\/(style|title)/i,u)){Re(s,e);continue}if(n.forceKeepAttr||(Re(s,e),!n.keepAttr))continue;if(!W&&Vh(/\/>/i,u)){Re(s,e);continue}X&&Ph([C,P,A],e=>{u=Nh(u,e," ")});const h=Ie(e.nodeName);if(je(h,c,u)){if(b&&"object"==typeof f&&"function"==typeof f.getAttributeType&&!a)switch(f.getAttributeType(h,c)){case"TrustedHTML":u=b.createHTML(u);break;case"TrustedScriptURL":u=b.createScriptURL(u)}try{a?e.setAttributeNS(a,s,u):e.setAttribute(s,u),Oe(e)?De(e):Lh(i.removed)}catch{}}}Be(M.afterSanitizeAttributes,e,null)},qe=function e(t){let i=null;const n=Fe(t);for(Be(M.beforeSanitizeShadowDOM,t,null);i=n.nextNode();)Be(M.uponSanitizeShadowNode,i,null),Ge(i),Ue(i),i.content instanceof s&&e(i.content);Be(M.afterSanitizeShadowDOM,t,null)};return i.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,o=null,a=null,c=null;if(_e=!e,_e&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Ne(e)){if("function"!=typeof e.toString)throw Uh("toString is not a function");if("string"!=typeof(e=e.toString()))throw Uh("dirty is not a string, aborting")}if(!i.isSupported)return e;if(K||Pe(t),i.removed=[],"string"==typeof e&&(se=!1),se){if(e.nodeName){const t=Ie(e.nodeName);if(!N[t]||U[t])throw Uh("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof l)n=ze("\x3c!----\x3e"),o=n.ownerDocument.importNode(e,!0),o.nodeType===yd&&"BODY"===o.nodeName||"HTML"===o.nodeName?n=o:n.appendChild(o);else{if(!ee&&!X&&!J&&-1===e.indexOf("<"))return b&&ie?b.createHTML(e):e;if(n=ze(e),!n)return ee?null:ie?w:""}n&&Q&&De(n.firstChild);const u=Fe(se?e:n);for(;a=u.nextNode();)Ge(a),Ue(a),a.content instanceof s&&qe(a.content);if(se)return e;if(ee){if(te)for(c=S.call(n.ownerDocument);n.firstChild;)c.appendChild(n.firstChild);else c=n;return(G.shadowroot||G.shadowrootmode)&&(c=k.call(r,c,!0)),c}let h=J?n.outerHTML:n.innerHTML;return J&&N["!doctype"]&&n.ownerDocument&&n.ownerDocument.doctype&&n.ownerDocument.doctype.name&&Vh(fd,n.ownerDocument.doctype.name)&&(h="<!DOCTYPE "+n.ownerDocument.doctype.name+">\n"+h),X&&Ph([C,P,A],e=>{h=Nh(h,e," ")}),b&&ie?b.createHTML(h):h},i.setConfig=function(){Pe(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),K=!0},i.clearConfig=function(){ke=null,K=!1},i.isValidAttribute=function(e,t,i){ke||Pe({});const n=Ie(e),r=Ie(t);return je(n,r,i)},i.addHook=function(e,t){"function"==typeof t&&Dh(M[e],t)},i.removeHook=function(e,t){if(void 0!==t){const i=Ah(M[e],t);return-1===i?void 0:Rh(M[e],i,1)[0]}return Lh(M[e])},i.removeHooks=function(e){M[e]=[]},i.removeAllHooks=function(){M={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},i}();const Ed=(e,t,i)=>{t.control&&t.controlOptions?i.options.toggleMode(t.control.type,t.control.targetMode):he.error("Control or controlOptions not defined",t.control,t.controlOptions)};var Td=Lu("<div><!></div>"),Sd=Lu('<div class="control-container svelte-1rd72r"><button type="button"><!></button> <!></div>');function Id(e,t){var i;Wl(t,!0);const n=null!=(i=t.controlOptions)&&i.icon?wd.sanitize(t.controlOptions.icon.trim()):null,r=Hl("gm"),o=r.control.getDefaultPosition();var s=Ru(),a=xc(s),l=e=>{var i=Sd(),s=vc(i);let a;s.__click=[Ed,t,r];var l=vc(s),c=e=>{var t=Ru();(function(e,t){var i,n=e,r="";hu(()=>{r!==(r=t()??"")&&(void 0!==i&&(mu(i),i=void 0),""!==r&&(i=du(()=>{var e=Pu(r+"");Au(yc(e),e.lastChild),n.before(e)})))})})(xc(t),()=>n),zu(e,t)},u=(e,i)=>{var n=e=>{var i=Du();uu(e=>Fu(i,e),[()=>t.controlOptions.title.slice(0,2)]),zu(e,i)},r=e=>{var i=Du();uu(()=>Fu(i,t.control.targetMode)),zu(e,i)};Gu(e,e=>{t.controlOptions.title?e(n):e(r,!1)},i)};Gu(l,e=>{t.controlOptions.icon?e(c):e(u,!1)});var h=bc(s,2),d=e=>{var i=Td();let n;vh(vc(i),{get control(){return t.control}}),uu((e,t)=>n=Wu(i,0,"control-menu svelte-1rd72r",null,n,{"menu-right":e,"menu-left":t}),[()=>o.endsWith("left"),()=>o.endsWith("right")]),zu(e,i)};Gu(h,e=>{t.controlOptions.active&&e(d)}),uu(()=>{Xu(s,"id",`id_${t.control.type}_${t.control.targetMode}`),a=Wu(s,0,`gm-control-button ${t.control.type}-${t.control.targetMode}`,"svelte-1rd72r",a,{active:t.controlOptions.active}),Xu(s,"title",t.controlOptions.title)}),zu(e,i)};Gu(a,e=>{t.control&&t.controlOptions&&t.controlOptions.uiEnabled&&e(l)}),zu(e,s),Xl()}Mu(["click"]);var kd=Lu("<div></div>"),Md=Lu('<div class="gm-reactive-controls svelte-blwgmu"></div>');function Cd(e,t){Wl(t,!1);const[i,n]=rh(),r=`${Hl("gm").mapAdapter.mapType}gl`;let o=nh(lh,"$controlsStore",i),s=o.controls,a=function(e,t=!1){return ec(Ql(e,t))}(o.options);!function(e){null===Zl&&ql(),oh(()=>()=>tu(e))}(lh.subscribe(e=>{s=e.controls,tc(a,e.options)}));eh();var l=Md();Vu(l,5,()=>Object.entries(eu(a)),ju,(e,t)=>{let i=()=>eu(t)[0];var n=kd();Vu(n,5,()=>Object.entries(eu(t)[1]),ju,(e,t)=>{var n=Ru();const r=oc(()=>((e,t)=>{const i=null==s?void 0:s[e];return(null==i?void 0:i[t])||null})(i(),eu(t)[0]));var o=xc(n),a=e=>{Id(e,{get control(){return eu(r)},get controlOptions(){return eu(t)[1]}})};Gu(o,e=>{eu(r)&&e(a)}),zu(e,n)}),uu(()=>Wu(n,0,`${r}-ctrl ${r}-ctrl-group group-${i()}`,"svelte-blwgmu")),zu(e,n)}),zu(e,l),Xl(),n()}class Pd{constructor(e){X(this,"gm"),this.gm=e}}class Ad extends Pd{constructor(){super(...arguments),X(this,"controls",$n(J)),X(this,"reactiveControls",null),X(this,"container"),X(this,"mapEventHandlers",{[`${_o}:draw`]:this.handleModeEvent.bind(this),[`${_o}:edit`]:this.handleModeEvent.bind(this),[`${_o}:helper`]:this.handleModeEvent.bind(this)})}onAdd(){if(this.createControls(),this.gm.events.bus.attachEvents(this.mapEventHandlers),!this.container)throw new Error("Controls container is not initialized");return this.container}createControls(e=void 0){this.controlsAdded()?he.warn("Can't add controls: controls already added"):(this.container=e||this.createHtmlContainer(),this.createReactivePanel())}onRemove(){this.gm.events.bus.detachEvents(this.mapEventHandlers),this.reactiveControls&&(function(e,t){const i=Bu.get(e);i?(Bu.delete(e),i(t)):Promise.resolve()}(this.reactiveControls),this.reactiveControls=null),this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0}handleModeEvent(e){return yo(e)?(["mode_started","mode_ended"].includes(e.action)&&this.updateReactivePanel(),{next:!0}):{next:!0}}controlsAdded(){return!!this.reactiveControls}createReactivePanel(){if(!this.container)return void he.error("Can't create reactive panel: container is not initialized");this.syncModeStates();const e=new Map;e.set("gm",this.gm),this.reactiveControls=Ou(Cd,{target:this.container,context:e}),this.updateReactivePanel()}updateReactivePanel(){lh.update(()=>({controls:this.controls,options:this.gm.options.controls}))}createHtmlContainer(){const e=document.createElement("div");return e.classList.add("geoman-controls"),e}syncModeStates(){this.eachControlWithOptions(({control:e})=>{this.gm.options.syncModeState(e.type,e.targetMode)})}eachControlWithOptions(e){return te(this.controls).forEach(t=>{const i=this.controls[t];return Object.keys(i).forEach(i=>{const n=i,r=this.getControl({actionType:t,modeName:n}),o=this.gm.options.getControlOptions({actionType:t,modeName:n});r&&o&&e({control:r,controlOptions:o})})})}getControl({actionType:e,modeName:t}){return e&&t&&this.controls[e][t]||null}getDefaultPosition(){return this.gm.options.settings.controlsPosition}}const Ld=`_${_o}`;class Dd{constructor(e){X(this,"gm"),X(this,"globalEventsListener",null),this.gm=e}get map(){return this.gm.mapAdapter.getMapInstance()}processEvent(e,t){this.fireToMap("system",e.split(":")[1],{...t,level:"user"}),"mode_start"===t.action||"mode_end"===t.action?this.forwardModeToggledEvent(t):"feature_created"===t.action?this.forwardFeatureCreated(t):"feature_removed"===t.action?this.forwardFeatureRemoved(t):"feature_updated"===t.action?this.forwardFeatureUpdated(t):"feature_edit_start"===t.action?this.forwardFeatureEditStart(t):"feature_edit_end"===t.action?this.forwardFeatureEditEnd(t):("loaded"===t.action||"unloaded"===t.action)&&this.forwardGeomanLoaded(t)}forwardModeToggledEvent(e){const t="mode_start"===e.action;let i;if("draw"===e.type){const n="globaldrawmodetoggled";i={enabled:t,shape:e.mode,map:this.map},this.fireToMap("converted",n,i),i={shape:e.mode,map:this.map},this.fireToMap("converted",t?"drawstart":"drawend",i)}else if("edit"===e.type){const n=this.getConvertedEditModeName(e.mode);i={enabled:t,map:this.map},this.fireToMap("converted",`global${n}modetoggled`,i)}else"helper"===e.type&&(i={enabled:t,map:this.map},this.fireToMap("converted",`global${e.mode}modetoggled`,i))}forwardFeatureCreated(e){const t={shape:e.mode,feature:e.featureData,map:this.map};this.fireToMap("converted","create",t)}forwardFeatureRemoved(e){const t={shape:e.mode,feature:e.featureData,map:this.map};this.fireToMap("converted","remove",t)}forwardFeatureUpdated(e){const t=["lasso"],i={map:this.map};1!==e.sourceFeatures.length||t.includes(e.mode)?i.originalFeatures=e.sourceFeatures:i.originalFeature=e.sourceFeatures[0],1!==e.targetFeatures.length||t.includes(e.mode)?i.features=e.targetFeatures:(i.feature=e.targetFeatures[0],i.shape=i.feature.shape);const n=this.getConvertedEditModeName(e.mode);this.fireToMap("converted",`${n}`,i)}forwardFeatureEditStart(e){const t=this.getConvertedEditModeName(e.mode),i={shape:e.feature.shape,feature:e.feature,map:this.map};this.fireToMap("converted",`${t}start`,i)}forwardFeatureEditEnd(e){const t=this.getConvertedEditModeName(e.mode),i={shape:e.feature.shape,feature:e.feature,map:this.map};this.fireToMap("converted",`${t}end`,i)}forwardGeomanLoaded(e){this.fireToMap("converted",`${e.action}`,{map:this.map,[_o]:this.gm})}fireToMap(e,t,i){const n=`${"system"===e?Ld:_o}:${t}`;this.globalEventsListener&&this.globalEventsListener({type:e,name:n,payload:i}),this.gm.mapAdapter.fire(n,i)}getConvertedEditModeName(e){return"change"===e?"edit":e}}class Rd{constructor(e){X(this,"gm"),X(this,"forwarder"),X(this,"mapEventHandlers",{}),X(this,"gmEventHandlers",{}),this.gm=e,this.forwarder=new Dd(e)}fireEvent(e,t){const i=this.gmEventHandlers[e];if(!i)return;const{controlHandler:n}=i;n(t),this.forwarder.processEvent(e,t)}attachEvents(e){te(e).forEach(t=>{const i=e[t];i&&this.on(t,i)})}detachEvents(e){te(e).forEach(t=>{const i=e[t];i&&this.off(t,i)})}detachAllEvents(){te(this.gmEventHandlers).forEach(e=>{var t;Array.from((null==(t=this.gmEventHandlers[e])?void 0:t.handlers)||[]).forEach(t=>{this.off(e,t)})}),te(this.mapEventHandlers).forEach(e=>{var t;Array.from((null==(t=this.mapEventHandlers[e])?void 0:t.handlers)||[]).forEach(t=>{this.off(e,t)})})}on(e,t){e.startsWith(_o)?this.onGmEvent(e,t):this.onMapEvent(e,t)}onGmEvent(e,t){var i;this.gmEventHandlers[e]||(this.gmEventHandlers[e]=this.createEventSection(e)),null==(i=this.gmEventHandlers[e])||i.handlers.unshift(t)}onMapEvent(e,t){var i;if(!this.mapEventHandlers[e]){const t=this.createEventSection(e);this.gm.mapAdapter.on(e,t.controlHandler),this.mapEventHandlers[e]=t}null==(i=this.mapEventHandlers[e])||i.handlers.unshift(t)}off(e,t){e.startsWith(`${_o}`)?this.offGmEvent(e,t):this.offMapEvent(e,t)}offGmEvent(e,t){var i;const n=(null==(i=this.gmEventHandlers[e])?void 0:i.handlers)||[],r=n.findIndex(e=>t===e);-1===r?he.warn("MapEvents: handler not found",e,t):(n.splice(r,1),0===n.length&&delete this.gmEventHandlers[e])}offMapEvent(e,t){var i,n;const r=(null==(i=this.mapEventHandlers[e])?void 0:i.handlers)||[],o=r.findIndex(e=>t===e);if(-1===o)he.warn("MapEvents: handler not found",e,t);else if(r.splice(o,1),0===r.length){const t=null==(n=this.mapEventHandlers[e])?void 0:n.controlHandler;t&&this.gm.mapAdapter.off(e,t),delete this.mapEventHandlers[e]}}createEventSection(e){return{handlers:[],controlHandler:t=>{let i;i=go(t)&&e.startsWith(`${_o}`)?this.gmEventHandlers[e]:this.mapEventHandlers[e],i?i.handlers.some(e=>{let i;return i=e(t),i&&"object"==typeof i&&"next"in i?!i.next:(he.error('EventsBus: handler should return an object with a "next" property'),!1)}):he.debug(`No handlers for eventName: "${e}"`)}}}}class zd extends vo{constructor(e,t){super(e),X(this,"mapEventHandlers",{[`${_o}:control`]:this.handleControlEvent.bind(this)}),t.attachEvents(this.mapEventHandlers)}handleControlEvent(e){return mo(e)?(this.getControl(e)||he.error("Control not found, event payload",e),{next:!0}):{next:!0}}}const Fd=["drag","change","rotate","scale","copy","cut","split","union","difference","line_simplification","lasso","delete"];class Od extends To{constructor(){super(...arguments),X(this,"actionType","edit"),X(this,"featureData",null),X(this,"cursorExcludedLayerIds",["rectangle-line","polygon-line","circle-line"]),X(this,"layerEventHandlersData",[])}startAction(){this.setEventsForLayers("mouseenter",this.setCursorToPointer.bind(this)),this.setEventsForLayers("mouseleave",this.setCursorToEmpty.bind(this)),super.startAction()}endAction(){this.clearEventsForLayers(),super.endAction()}setCursorToPointer(){this.gm.mapAdapter.setCursor("pointer")}setCursorToEmpty(){this.gm.mapAdapter.setCursor("")}setEventsForLayers(e,t){this.gm.features.layers.map(e=>e.id).filter(e=>!this.cursorExcludedLayerIds.some(t=>e.includes(t))).forEach(i=>{this.gm.mapAdapter.on(e,i,t),this.layerEventHandlersData.push({eventName:e,layerId:i,callback:t})})}clearEventsForLayers(){this.layerEventHandlersData.forEach(({eventName:e,layerId:t,callback:i})=>{this.gm.mapAdapter.off(e,t,i)}),this.layerEventHandlersData=[]}updateFeatureGeoJson({featureData:e,featureGeoJson:t,forceMode:i}){return!!this.flags.featureUpdateAllowed&&("circle"===e.shape&&t.properties.center&&e.setShapeProperty("center",t.properties.center),e.updateGeoJsonGeometry(t.geometry),this.fireFeatureUpdatedEvent({sourceFeatures:[e],targetFeatures:[e],forceMode:i}),!0)}fireFeatureUpdatedEvent({sourceFeatures:e,targetFeatures:t,markerData:i,forceMode:n}){const r={level:"system",type:"edit",action:"feature_updated",mode:n||this.mode,sourceFeatures:e,targetFeatures:t,markerData:i||null};this.gm.events.fire(`${_o}:edit`,r)}fireFeatureEditStartEvent({feature:e,forceMode:t}){const i={level:"system",type:"edit",action:"feature_edit_start",mode:t||this.mode,feature:e};this.gm.events.fire(`${_o}:edit`,i)}fireFeatureEditEndEvent({feature:e,forceMode:t}){const i={level:"system",type:"edit",action:"feature_edit_end",mode:t||this.mode,feature:e};this.gm.events.fire(`${_o}:edit`,i)}fireMarkerPointerUpdateEvent(){if(!this.gm.markerPointer.marker)return;const e=this.gm.markerPointer.marker,t={level:"system",variant:null,type:"draw",mode:this.getLineDrawerMode(),action:"update",markerData:{type:"dom",instance:e,position:{coordinate:e.getLngLat(),path:[-1]}},featureData:null};this.gm.events.fire(`${_o}:draw`,t)}forwardLineDrawerEvent(e){if(!Io(e)||!["cut","split"].includes(this.mode))return{next:!0};if("start"===e.action||"update"===e.action){const t={level:"system",type:"draw",mode:this.getLineDrawerMode(),variant:null,action:e.action,featureData:e.featureData,markerData:e.markerData};this.gm.events.fire(`${_o}:draw`,t)}else if("finish"===e.action||"cancel"===e.action){const t={level:"system",type:"draw",mode:this.getLineDrawerMode(),variant:null,action:e.action};this.gm.events.fire(`${_o}:draw`,t)}return{next:!0}}fireFeatureRemovedEvent(e){if(ne(e.shape,ko)){const t={level:"system",type:"edit",mode:e.shape,action:"feature_removed",featureData:e};this.gm.events.fire(`${_o}:edit`,t)}}getLineDrawerMode(){return"cut"===this.mode?"polygon":"line"}}const Nd=["shape_markers","pin","snapping","snap_guides","measurements","auto_trace","geofencing","zoom_to_features","click_to_edit"];class Bd extends To{constructor(){super(...arguments),X(this,"actionType","helper")}}const Gd=e=>go(e)&&"edit"===e.type,jd=e=>(e=>Mo.includes(e))(e)||(e=>Fd.includes(e))(e)||(e=>Nd.includes(e))(e);class Vd extends vo{constructor(e,t){super(e),X(this,"mapEventHandlers",{[`${_o}:draw`]:this.handleDrawEvent.bind(this)}),t.attachEvents(this.mapEventHandlers)}handleDrawEvent(e){if(!So(e))return{next:!0};const t=`${e.type}__${e.mode}`;return"mode_start"===e.action?(this.trackExclusiveModes(e),this.start(t,e),this.trackRelatedModes(e)):"mode_end"===e.action&&(this.trackRelatedModes(e),this.end(t)),{next:!0}}start(e,t){const i=this.gm.createDrawInstance(t.mode);i&&(e in this.gm.actionInstances&&he.error(`Action instance "${e}" already exists`),this.gm.actionInstances[e]=i,i.startAction())}end(e){const t=this.gm.actionInstances[e];t instanceof Co&&(t.endAction(),delete this.gm.actionInstances[e])}}class Ud extends vo{constructor(e,t){super(e),X(this,"mapEventHandlers",{[`${_o}:edit`]:this.handleEditEvent.bind(this)}),t.attachEvents(this.mapEventHandlers)}handleEditEvent(e){if(!Gd(e))return{next:!0};const t=`${e.type}__${e.mode}`;return"mode_start"===e.action?(this.trackExclusiveModes(e),this.start(t,e),this.trackRelatedModes(e)):"mode_end"===e.action&&(this.trackRelatedModes(e),this.end(t)),{next:!0}}start(e,t){if("mode_start"!==t.action)return;const i=this.gm.createEditInstance(t.mode);i&&(e in this.gm.actionInstances&&he.error(`Action instance "${e}" already exists`),this.gm.actionInstances[e]=i,i.startAction())}end(e){const t=this.gm.actionInstances[e];t instanceof Od&&(t.endAction(),delete this.gm.actionInstances[e])}}class qd extends vo{constructor(e,t){super(e),X(this,"mapEventHandlers",{[`${_o}:helper`]:this.handleHelperEvent.bind(this)}),t.attachEvents(this.mapEventHandlers)}handleHelperEvent(e){if(!wo(e))return{next:!0};const t=`${e.type}__${e.mode}`;return"mode_start"===e.action?(this.trackExclusiveModes(e),this.start(t,e),this.trackRelatedModes(e)):"mode_end"===e.action&&(this.trackRelatedModes(e),this.end(t)),{next:!0}}start(e,t){const i=this.gm.createHelperInstance(t.mode);i&&(e in this.gm.actionInstances&&he.error(`Action instance "${e}" already exists`),this.gm.actionInstances[e]=i,i.startAction())}end(e){const t=this.gm.actionInstances[e];t instanceof Bd&&(t.endAction(),delete this.gm.actionInstances[e])}}class Zd{constructor(e){X(this,"gm"),X(this,"bus"),X(this,"listeners",{}),this.gm=e,this.bus=new Rd(this.gm),this.listeners={draw:new Vd(this.gm,this.bus),edit:new Ud(this.gm,this.bus),helper:new qd(this.gm,this.bus),control:new zd(this.gm,this.bus)}}fire(e,t){this.listeners[t.type]||he.error(`Can't find event listener for "${t.type}" event type`),this.bus.fireEvent(e,t)}}class $d{getEuclideanNearestLngLat(e,t){const i=this.project(t);let n=[0,0],r=1/0;return Jr(e,e=>{const t=((e,t,i)=>{const[n,r]=[e[0],e[1]],[o,s]=[t[0],t[1]],[a,l]=[i[0],i[1]],c=o-n,u=s-r;let h=((a-n)*c+(l-r)*u)/(c*c+u*u);return h=Math.max(0,Math.min(1,h)),[n+h*c,r+h*u]})(this.project(e.start.coordinate),this.project(e.end.coordinate),i),o=so(i,t);o<r&&(r=o,n=[t[0],t[1]])}),this.unproject(n)}getDistance(e,t){return je(e,t,{units:"meters"})}}class Hd{isInstanceAvailable(){return!!this.layerInstance||(he.error("layerInstance is not available"),!1)}}class Wd extends Hd{constructor({gm:e,layerId:t,options:i}){super(),X(this,"gm"),X(this,"layerInstance",null),X(this,"mapInstance"),this.gm=e,this.mapInstance=this.gm.mapAdapter.mapInstance,this.layerInstance=i?this.createLayer(i):this.mapInstance.getLayer(t)||null}get id(){if(!this.isInstanceAvailable())throw new Error("Layer instance is not available");return this.layerInstance.id}get source(){if(!this.isInstanceAvailable())throw new Error("Layer instance is not available");return this.layerInstance.source}createLayer(e){return this.mapInstance.addLayer(e),this.mapInstance.getLayer(e.id)||null}remove(){this.isInstanceAvailable()&&this.mapInstance.removeLayer(this.id),this.layerInstance=null}}class Xd extends de{constructor({mapInstance:e,options:t,lngLat:i}){super(),X(this,"markerInstance"),this.markerInstance=new o.Marker(t).setLngLat(i).addTo(e)}getElement(){var e;return this.isMarkerInstanceAvailable()&&(null==(e=this.markerInstance)?void 0:e.getElement())||null}setLngLat(e){var t;this.isMarkerInstanceAvailable()&&(null==(t=this.markerInstance)||t.setLngLat(e))}getLngLat(){var e;return this.isMarkerInstanceAvailable()&&(null==(e=this.markerInstance)?void 0:e.getLngLat().toArray())||[0,0]}remove(){var e;null==(e=this.markerInstance)||e.remove()}}class Yd{isInstanceAvailable(){return!!this.popupInstance||(he.error("Popup instance is not available"),!1)}}class Jd extends Yd{constructor({mapInstance:e,options:t,lngLat:i}){super(),X(this,"popupInstance"),this.popupInstance=new o.Popup(t).addTo(e),i&&this.setLngLat(i)}getLngLat(){return this.isInstanceAvailable()&&this.popupInstance.getLngLat().toArray()||[0,0]}setLngLat(e){this.isInstanceAvailable()&&this.popupInstance.setLngLat(e)}setHtml(e){this.isInstanceAvailable()&&this.popupInstance.setHTML(e)}remove(){this.isInstanceAvailable()&&this.popupInstance.remove()}}class Kd extends xo{constructor({gm:e,geoJson:t,sourceId:i}){super(),X(this,"gm"),X(this,"mapInstance"),X(this,"sourceInstance"),this.gm=e,this.mapInstance=this.gm.mapAdapter.mapInstance,this.sourceInstance=t?this.createSource({geoJson:t,sourceId:i}):this.mapInstance.getSource(i)||null}get id(){if(!this.isInstanceAvailable())throw new Error("Source instance is not available");return this.sourceInstance.id}createSource({geoJson:e,sourceId:t}){return this.mapInstance.addSource(t,{type:"geojson",data:e,promoteId:il}),this.mapInstance.getSource(t)||null}getGeoJson(){if(!this.isInstanceAvailable())throw new Error("Source instance is not available");return this.sourceInstance.serialize().data}setGeoJson(e){if(!this.isInstanceAvailable())throw new Error("Source instance is not available");return this.sourceInstance.setData(e)}updateData(e){if(!this.isInstanceAvailable())return;const t=this.convertGeoJsonDiffToMlDiff(e);this.sourceInstance.updateData(t)}convertGeoJsonDiffToMlDiff(e){return{add:e.add,update:e.update.map(this.convertFeatureToMlUpdateDiff.bind(this)),remove:e.remove}}convertFeatureToMlUpdateDiff(e){const t=Object.entries(e.properties||{}).map(e=>({key:e[0],value:e[1]}));return{id:e.id,newGeometry:e.geometry,addOrUpdateProperties:t}}remove({removeLayers:e}){this.isInstanceAvailable()&&(e&&this.gm.mapAdapter.eachLayer(e=>{e.source===this.sourceInstance.id&&this.gm.mapAdapter.removeLayer(e.id)}),this.mapInstance.removeSource(this.sourceInstance.id))}}const Qd=["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout","contextmenu","touchstart","touchend","touchcancel"],ep=e=>Qd.includes(e);class tp extends $d{constructor(e,t){super(),X(this,"gm"),X(this,"mapType","_ml"),X(this,"mapInstance"),this.gm=t,this.mapInstance=e}getMapInstance(){return this.mapInstance}isLoaded(){return this.mapInstance.loaded()}getContainer(){return this.mapInstance.getContainer()}getCanvas(){return this.mapInstance.getCanvas()}addControl(e){this.mapInstance.addControl(e)}removeControl(e){this.mapInstance.removeControl(e)}async loadImage({id:e,image:t}){const i=await this.mapInstance.loadImage(t);this.mapInstance.addImage(e,i.data)}getBounds(){return this.mapInstance.getBounds().toArray()}fitBounds(e,t){this.mapInstance.fitBounds(e,t)}setCursor(e){this.mapInstance.getCanvas().style.cursor=e}disableMapInteractions(e){e.forEach(e=>{this.mapInstance[e].disable()})}enableMapInteractions(e){e.forEach(e=>{this.mapInstance[e].enable()})}setDragPan(e){e?this.mapInstance.dragPan.enable():this.mapInstance.dragPan.disable()}queryFeaturesByScreenCoordinates({queryCoordinates:e,sourceNames:t}){return Ur(this.mapInstance.queryRenderedFeatures(e).map(e=>({featureId:e.properties[il],featureSourceName:e.source})),zr).map(({featureId:e,featureSourceName:i})=>void 0!==e&&t.includes(i)&&this.gm.features.get(i,e)||null).filter(e=>!!e)}queryGeoJsonFeatures({queryCoordinates:e,sourceNames:t}){return Ur(this.mapInstance.queryRenderedFeatures(e).map(e=>{const t=this.convertToGeoJsonImportFeature(e);return t?{id:e.properties[il],sourceName:e.source,geoJson:t}:null}),(e,t)=>(null==e?void 0:e.id)===(null==t?void 0:t.id)).filter(e=>!!e&&void 0!==e.id&&e.geoJson&&t.includes(e.sourceName))}convertToGeoJsonImportFeature(e){const t=e.properties[il];return void 0===t||"GeometryCollection"===e.geometry.type?null:{id:t,type:"Feature",properties:e.properties,geometry:e.geometry}}addSource(e,t){return new Kd({gm:this.gm,sourceId:e,geoJson:t})}getSource(e){return new Kd({gm:this.gm,sourceId:e})}addLayer(e){const t=e.id;return new Wd({gm:this.gm,layerId:t,options:e})}getLayer(e){return new Wd({gm:this.gm,layerId:e})}removeLayer(e){const t=this.getLayer(e);t&&t.remove()}eachLayer(e){this.mapInstance.getStyle().layers.forEach(t=>{e(new Wd({gm:this.gm,layerId:t.id}))})}createDomMarker(e,t){return new Xd({mapInstance:this.mapInstance,options:e,lngLat:t})}createPopup(e,t){return new Jd({mapInstance:this.mapInstance,options:e,lngLat:t})}project(e){const t=this.mapInstance.project(e);return[t.x,t.y]}unproject(e){const t=this.mapInstance.unproject(e);return[t.lng,t.lat]}coordBoundsToScreenBounds(e){const t=new o.LngLatBounds(e);return[this.project(t.getSouthWest().toArray()),this.project(t.getNorthEast().toArray())]}fire(e,t){this.mapInstance.fire(e,t)}on(e,t,i){if("string"==typeof t&&i&&ep(e))this.mapInstance.on(e,t,i);else{if("function"!=typeof t)throw new Error("Invalid arguments passed to 'on' method");this.mapInstance.on(e,t)}}once(e,t,i){if("string"==typeof t&&i&&ep(e))this.mapInstance.once(e,t,i);else{if("function"!=typeof t)throw new Error("Invalid arguments passed to 'once' method.");this.mapInstance.once(e,t)}}off(e,t,i){if("string"==typeof t&&i&&ep(e))this.mapInstance.off(e,t,i);else{if("function"!=typeof t)throw new Error("Invalid arguments passed to 'off' method");this.mapInstance.off(e,t)}}}const ip=(e,t)=>{if(Array.isArray(e)&&Array.isArray(t)){const i=Fr(e,"type");return t.forEach(e=>{i[e.type]?Or(i[e.type],e):i[e.type]=$n(e)}),Ar(i)}};class np{constructor(e,t){X(this,"gm"),X(this,"settings"),X(this,"controls"),X(this,"layerStyles"),this.gm=e;const i=this.getMergedOptions(t);this.settings=i.settings,this.controls=i.controls,this.layerStyles=i.layerStyles}getMergedOptions(e={}){return Cr(hl(),e,ip)}enableMode(e,t){const i=this.isModeEnabled(e,t),n=this.isModeAvailable(e,t);if(n||he.warn(`Unable to enable mode, "${e}:${t}" is not available`),i||!n)return;const r=this.controls[e][t];r?(r.active=!0,this.fireModeEvent(e,t,"mode_start"),this.fireControlEvent(e,t,"on"),this.fireModeEvent(e,t,"mode_started")):he.error("Can't find control section for",e,t)}disableMode(e,t){const i=this.isModeEnabled(e,t),n=this.isModeAvailable(e,t);if(!i||!n)return;const r=this.controls[e][t];r?(r.active=!1,this.fireModeEvent(e,t,"mode_end"),this.fireControlEvent(e,t,"off"),this.fireModeEvent(e,t,"mode_ended")):he.error("Can't find control section for",e,t)}syncModeState(e,t){const i=this.controls[e][t],n=this.isModeAvailable(e,t);i&&(n?i.active?this.enableMode(e,t):this.disableMode(e,t):(i.active=!1,i.uiEnabled=!1))}toggleMode(e,t){this.isModeEnabled(e,t)?this.disableMode(e,t):this.enableMode(e,t)}isModeEnabled(e,t){return!!Object.entries(this.gm.actionInstances).find(([i,n])=>i===`${e}__${t}`&&n)}isModeAvailable(e,t){return"draw"===e&&ne(t,Mo)?!!this.gm.drawClassMap[t]:"edit"===e&&ne(t,Fd)?!!this.gm.editClassMap[t]:!("helper"!==e||!ne(t,Nd))&&!!this.gm.helperClassMap[t]}getControlOptions({actionType:e,modeName:t}){return e&&t&&this.controls[e][t]||null}fireModeEvent(e,t,i){const n={level:"system",type:e,mode:t,action:i};yo(n)&&(So(n)||Gd(n)||wo(n))&&this.gm.events.fire(`${_o}:${e}`,n)}fireControlEvent(e,t,i){const n={level:"system",type:"control",section:e,target:t,action:i};this.gm.events.fire(`${_o}:control`,n)}}class rp extends Co{constructor(){super(...arguments),X(this,"mode","circle"),X(this,"shape","circle"),X(this,"circleCenterPoint",null),X(this,"circleCenterLngLat",null),X(this,"mapEventHandlers",{mousemove:this.onMouseMove.bind(this),click:this.onMouseClick.bind(this)})}onStartAction(){this.gm.markerPointer.enable()}onEndAction(){this.removeTmpFeature(),this.gm.markerPointer.disable(),this.fireFinishEvent()}createFeature(){const e=this.gm.features.createFeature({shapeGeoJson:this.getFeatureGeoJson(this.circleCenterLngLat||[0,0]),sourceName:tl.temporary});return e&&this.circleCenterLngLat&&e.setShapeProperty("center",this.circleCenterLngLat),e}getFeatureGeoJson(e){return{type:"Feature",properties:{shape:this.shape},geometry:{type:"Point",coordinates:e}}}createMarker(){const e=document.createElement("div");e.innerHTML=K;const t=e.firstChild;return t.style.color="#278cda",t.style.width="28px",t.style.height="28px",t.style.pointerEvents="none",this.gm.mapAdapter.createDomMarker({draggable:!1,anchor:"center",element:t},[0,0])}getControlMarkerData(){const e=this.gm.markerPointer.marker;return e?{type:"dom",instance:e,position:{coordinate:e.getLngLat(),path:[-1]}}:null}fireStartEvent(e,t){const i={level:"system",type:"draw",mode:this.shape,variant:null,action:"start",featureData:e,markerData:t};this.gm.events.fire(`${_o}:draw`,i)}fireUpdateEvent(e,t){const i={level:"system",type:"draw",mode:this.shape,variant:null,action:"update",featureData:e,markerData:t};this.gm.events.fire(`${_o}:draw`,i)}fireFinishEvent(){const e={level:"system",type:"draw",mode:this.shape,variant:null,action:"finish"};this.gm.events.fire(`${_o}:draw`,e)}}const op=(e,t,i=10)=>{const n={...e};return te(e).forEach(r=>{const o=e[r];"function"==typeof o?n[r]=jr(o.bind(t),i,{leading:!0,trailing:!1}):he.error("convertToThrottled: item is not a function",e[r])}),n};const sp={dom:'<svg xmlns="http://www.w3.org/2000/svg" width="21" height="21">\n <circle cx="10.5" cy="10.5" r="9.213" fill="#fff" stroke="#278cda" stroke-width="2.303"/>\n</svg>\n'},ap=(e,t=void 0)=>{const i=document.createElement("div");i.classList.add("marker-wrapper"),i.style.lineHeight="0",i.innerHTML=sp[e];const n=i.firstChild;return t&&Object.assign(n.style,t),i};function lp(e,t,i,n){t=t||("Feature"===e.type?e.properties:{});var r=Fe(e),o=r.coordinates,s=r.type;if(!o.length)throw new Error("line must contain coordinates");switch(s){case"LineString":return i&&(o=cp(o)),ye([o],t);case"MultiLineString":var a=[],l=0;return o.forEach(function(e){if(i&&(e=cp(e)),n){var t=function(e){var t=e[0],i=e[1],n=e[2],r=e[3];return Math.abs(t-n)*Math.abs(i-r)}(Le(_e(e)));t>l?(a.unshift(e),l=t):a.push(e)}else a.push(e)}),ye(a,t);default:throw new Error("geometry type "+s+" is not supported")}}function cp(e){var t=e[0],i=t[0],n=t[1],r=e[e.length-1],o=r[0],s=r[1];return(i!==o||n!==s)&&e.push(t),e}var up=function(e,t={}){var i,n,r,o=t.properties,s=null==(i=t.autoComplete)||i,a=null==(n=t.orderCoords)||n;if("FeatureCollection"===(null!=(r=t.mutate)&&r||(e=ss(e)),e.type)){var l=[];return e.features.forEach(function(e){l.push(ze(lp(e,{},s,a)))}),xe(l,o)}return lp(e,o,s,a)};const hp=e=>!!e&&"object"==typeof e&&e instanceof Bd&&"removeSnapGuides"in e&&"updateSnapGuides"in e&&"snap_guides"===e.mode&&"function"==typeof e.removeSnapGuides&&"function"==typeof e.updateSnapGuides,dp=e=>!!e&&"object"==typeof e&&e instanceof Bd&&"getShortestPath"in e&&"auto_trace"===e.mode&&"function"==typeof e.getShortestPath,pp=e=>!!e&&"object"==typeof e&&e instanceof Bd&&"getSharedMarkers"in e&&"pin"===e.mode&&"function"==typeof e.getSharedMarkers;class fp extends Co{constructor(e,t={snappingMarkers:"none",targetShape:"line"}){super(e),X(this,"mode","line"),X(this,"snappingKey","line_drawer"),X(this,"drawOptions"),X(this,"shapeLngLats",[]),X(this,"throttledMethods",op({onMouseMove:this.onMouseMove},this,this.gm.options.settings.throttlingDelay)),X(this,"mapEventHandlers",{[`${_o}:helper`]:this.handleGmHelperEvent.bind(this),click:this.onMouseClick.bind(this),mousemove:this.throttledMethods.onMouseMove.bind(this)}),X(this,"drawerEventHandlers",{firstMarkerClick:null,lastMarkerClick:null,nMarkerClick:null}),this.drawOptions=t}get snapGuidesInstance(){const e=this.gm.actionInstances.helper__snap_guides;return hp(e)?e:null}get autoTraceEnabled(){var e;return(null==(e=this.gm.options.controls.helper.auto_trace)?void 0:e.active)||!1}get autoTraceHelperInstance(){return this.autoTraceEnabled&&Object.values(this.gm.actionInstances).find(dp)||null}onStartAction(){this.gm.markerPointer.enable()}onEndAction(){var e;this.gm.markerPointer.disable(),this.endShape(),null==(e=this.snapGuidesInstance)||e.removeSnapGuides()}handleGmHelperEvent(e){return wo(e)?("snap_guides"===e.mode&&"mode_start"===e.action&&this.updateSnapGuides(),{next:!0}):(he.error("LineDrawer.handleGmHelperEvent: invalid event",e),{next:!0})}updateSnapGuides(){var e;if(this.snapGuidesInstance){const t=null==(e=this.featureData)?void 0:e.getGeoJson();t&&t.geometry.coordinates.pop(),this.snapGuidesInstance.updateSnapGuides(t||null,this.shapeLngLats.at(-1)||null,!0)}}on(e,t){this.drawerEventHandlers[e]=t}onMouseClick(e){var t;if(!el(e,{warning:!0}))return{next:!0};const i=(null==(t=this.gm.markerPointer.marker)?void 0:t.getLngLat())||e.lngLat.toArray();if(this.featureData){const t=this.getClickedMarkerInfo(e);this.handleNextVertex(i,t)}else this.isFeatureAllowed(((e,t="marker")=>({type:"Feature",properties:{shape:t},geometry:{type:"Point",coordinates:e}}))(i))&&this.startShape(i);return this.updateSnapGuides(),{next:!0}}handleNextVertex(e,t){var i,n,r,o,s,a;if(!this.featureData)return void he.error("LineDrawer.handleNextVertex: no featureData");const l=this.featureData.markers.size,c=this.getMarkerClickEventData(t.index);t.index<l-1&&this.addPoint(e,t),-1!==t.index&&(0===t.index?null==(n=(i=this.drawerEventHandlers).firstMarkerClick)||n.call(i,c):t.index>0&&t.index===l-1&&(null==(o=(r=this.drawerEventHandlers).lastMarkerClick)||o.call(r,c)),t.index>=0&&(null==(a=(s=this.drawerEventHandlers).nMarkerClick)||a.call(s,c)))}getMarkerClickEventData(e){const t=this.getFeatureGeoJson({withControlMarker:!1});return{markerIndex:e,shapeCoordinates:this.getShapeCoordinates({withControlMarker:!1}),geoJson:t,bounds:io(t)}}onMouseMove(e){return el(e,{warning:!0})?(this.featureData&&this.shapeLngLats.length&&this.updateFeatureSource(),{next:!0}):{next:!0}}startShape(e){this.shapeLngLats=[e],this.featureData=this.gm.features.createFeature({shapeGeoJson:this.getFeatureGeoJson({withControlMarker:!0}),sourceName:tl.temporary});const t={type:"dom",instance:this.createMarker(e),position:{coordinate:e,path:["geometry","coordinates",0]}};this.featureData&&(this.featureData.markers.set(t.position.path.join("."),t),this.setSnapping(),this.fireStartEvent(this.featureData,t)),this.gm.mapAdapter.disableMapInteractions(["doubleClickZoom"])}endShape(){const e=this.getFeatureGeoJson({withControlMarker:!1});this.removeSnapping(),this.removeTmpFeature(),this.shapeLngLats=[],this.gm.mapAdapter.enableMapInteractions(["doubleClickZoom"]),this.fireStopEvent(e)}setSnapping(){if(!this.snappingHelper)return;const e=this.drawOptions.snappingMarkers;"none"===e?this.snappingHelper.setCustomSnappingCoordinates(this.snappingKey,[]):"all"===e&&this.shapeLngLats.length?this.snappingHelper.setCustomSnappingCoordinates(this.snappingKey,this.shapeLngLats):"first"===e&&this.shapeLngLats.length?this.snappingHelper.setCustomSnappingCoordinates(this.snappingKey,[this.shapeLngLats[0]]):"last"===e&&this.shapeLngLats.length?this.snappingHelper.setCustomSnappingCoordinates(this.snappingKey,[this.shapeLngLats[this.shapeLngLats.length-1]]):he.error("LineDrawer.setSnapping: invalid data",e,this.shapeLngLats)}removeSnapping(){this.snappingHelper&&this.snappingHelper.clearCustomSnappingCoordinates(this.snappingKey)}getClickedMarkerInfo(e){if(!this.featureData)return{index:-1,path:null};let t=0,i=null;try{this.featureData.markers.forEach((n,r)=>{if(n.instance instanceof de){const t=n.instance.getElement()||null,o=e.originalEvent.target,s=o instanceof Element?o:null;if(t&&t.contains(s))throw i=r,new Error("stop")}t+=1})}catch{if(i)return{index:t,path:i}}return{index:-1,path:null}}addPoint(e,t){const i=this.featureData;if(!i)return void he.error("LineDrawer.addPoint: no featureData");const n=this.getAddedLngLats(e,t),r=this.getFeatureGeoJsonWithType({withControlMarker:!0,coordinates:this.shapeLngLats.concat(n)});this.isFeatureAllowed(r)&&(n.forEach(e=>{this.shapeLngLats.push(e);const t=this.addMarker(e,i);this.fireUpdateEvent(i,t)}),this.updateFeatureSource())}isFeatureAllowed(e){return!this.gm.getActiveDrawModes().length||(this.fireBeforeFeatureCreate({geoJsonFeatures:[e]}),this.flags.featureCreateAllowed)}getAddedLngLats(e,t){if(!this.featureData)return he.error("LineDrawer.getCurrentLngLats: no featureData"),[];const i=this.getMarkerInfoLngLat(t)||e,n=this.getAutoTracePath(i);return[...(null==n?void 0:n.slice(1,-1))||[],i]}getAutoTracePath(e){const t=this.shapeLngLats.at(-1);return this.autoTraceEnabled&&this.autoTraceHelperInstance&&t&&this.autoTraceHelperInstance.getShortestPath(t,e)||null}getMarkerInfoLngLat(e){if(this.featureData&&e.path){const t=this.featureData.markers.get(e.path);if(t&&"dom"===t.type)return t.instance.getLngLat();he.error("LineDrawer.addPoint: no markerData",e)}return null}addMarker(e,t){const i={type:"dom",instance:this.createMarker(e),position:{coordinate:e,path:["geometry","coordinates",this.shapeLngLats.length]}};return t.markers.set(i.position.path.join("."),{type:"dom",instance:i.instance,position:{coordinate:e,path:[]}}),i}createMarker(e){return this.gm.mapAdapter.createDomMarker({element:ap("dom",{pointerEvents:"auto",cursor:"pointer"}),anchor:"center"},e)}updateFeatureSource(){if(this.featureData&&(this.featureData.updateGeoJsonGeometry(this.getFeatureGeoJson({withControlMarker:!0}).geometry),this.gm.markerPointer.marker)){const e={type:"dom",instance:this.gm.markerPointer.marker,position:{coordinate:this.gm.markerPointer.marker.getLngLat(),path:["geometry","coordinates",this.shapeLngLats.length]}};this.fireUpdateEvent(this.featureData,e)}}getFeatureGeoJson({withControlMarker:e,coordinates:t}){return{type:"Feature",properties:{shape:"line"},geometry:{type:"LineString",coordinates:t||this.getShapeCoordinates({withControlMarker:e})}}}getFeatureGeoJsonWithType({withControlMarker:e,coordinates:t}){const i=this.getFeatureGeoJson({withControlMarker:e,coordinates:t});return"polygon"===this.drawOptions.targetShape&&i.geometry.coordinates.length>3?up(i,{properties:i.properties}):i}getShapeCoordinates({withControlMarker:e}){const t=[...this.shapeLngLats];return e&&this.gm.markerPointer.marker&&t.push(this.gm.markerPointer.marker.getLngLat()),t}fireStartEvent(e,t){this.gm.events.fire(`${_o}:draw`,{level:"system",type:"draw",mode:"line",variant:"line_drawer",action:"start",featureData:e,markerData:t})}fireUpdateEvent(e,t){this.gm.events.fire(`${_o}:draw`,{level:"system",type:"draw",mode:"line",variant:"line_drawer",action:"update",featureData:e,markerData:t})}fireStopEvent(e){this.gm.events.fire(`${_o}:draw`,{level:"system",type:"draw",mode:"line",action:"finish",variant:"line_drawer",geoJsonFeature:e})}}var mp=function(e){var t={MultiPoint:{coordinates:[],properties:[]},MultiLineString:{coordinates:[],properties:[]},MultiPolygon:{coordinates:[],properties:[]}};return Ce(e,e=>{var i;switch(null==(i=e.geometry)?void 0:i.type){case"Point":t.MultiPoint.coordinates.push(e.geometry.coordinates),t.MultiPoint.properties.push(e.properties);break;case"MultiPoint":t.MultiPoint.coordinates.push(...e.geometry.coordinates),t.MultiPoint.properties.push(e.properties);break;case"LineString":t.MultiLineString.coordinates.push(e.geometry.coordinates),t.MultiLineString.properties.push(e.properties);break;case"MultiLineString":t.MultiLineString.coordinates.push(...e.geometry.coordinates),t.MultiLineString.properties.push(e.properties);break;case"Polygon":t.MultiPolygon.coordinates.push(e.geometry.coordinates),t.MultiPolygon.properties.push(e.properties);break;case"MultiPolygon":t.MultiPolygon.coordinates.push(...e.geometry.coordinates),t.MultiPolygon.properties.push(e.properties)}}),ve(Object.keys(t).filter(function(e){return t[e].coordinates.length}).sort().map(function(e){return me({type:e,coordinates:t[e].coordinates},{collectedProperties:t[e].properties})}))};function gp(e,t,i,n,r){yp(e,t,i||0,n||e.length-1,r||vp)}function yp(e,t,i,n,r){for(;n>i;){if(n-i>600){var o=n-i+1,s=t-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);yp(e,t,Math.max(i,Math.floor(t-s*l/o+c)),Math.min(n,Math.floor(t+(o-s)*l/o+c)),r)}var u=e[t],h=i,d=n;for(_p(e,i,t),r(e[n],u)>0&&_p(e,i,n);h<d;){for(_p(e,h,d),h++,d--;r(e[h],u)<0;)h++;for(;r(e[d],u)>0;)d--}0===r(e[i],u)?_p(e,i,d):_p(e,++d,n),d<=t&&(i=d+1),t<=d&&(n=d-1)}}function _p(e,t,i){var n=e[t];e[t]=e[i],e[i]=n}function vp(e,t){return e<t?-1:e>t?1:0}class xp{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data;const i=[];if(!Lp(e,t))return i;const n=this.toBBox,r=[];for(;t;){for(let o=0;o<t.children.length;o++){const s=t.children[o],a=t.leaf?n(s):s;Lp(e,a)&&(t.leaf?i.push(s):Ap(e,a)?this._all(s,i):r.push(s))}t=r.pop()}return i}collides(e){let t=this.data;if(!Lp(e,t))return!1;const i=[];for(;t;){for(let n=0;n<t.children.length;n++){const r=t.children[n],o=t.leaf?this.toBBox(r):r;if(Lp(e,o)){if(t.leaf||Ap(e,o))return!0;i.push(r)}}t=i.pop()}return!1}load(e){if(!e||!e.length)return this;if(e.length<this._minEntries){for(let t=0;t<e.length;t++)this.insert(e[t]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){const e=this.data;this.data=t,t=e}this._insert(t,this.data.height-t.height-1,!0)}else this.data=t;return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=Dp([]),this}remove(e,t){if(!e)return this;let i=this.data;const n=this.toBBox(e),r=[],o=[];let s,a,l;for(;i||r.length;){if(i||(i=r.pop(),a=r[r.length-1],s=o.pop(),l=!0),i.leaf){const n=bp(e,i.children,t);if(-1!==n)return i.children.splice(n,1),r.push(i),this._condense(r),this}l||i.leaf||!Ap(i,n)?a?(s++,i=a.children[s],l=!1):i=null:(r.push(i),o.push(s),s=0,a=i,i=i.children[0])}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){const i=[];for(;e;)e.leaf?t.push(...e.children):i.push(...e.children),e=i.pop();return t}_build(e,t,i,n){const r=i-t+1;let o,s=this._maxEntries;if(r<=s)return o=Dp(e.slice(t,i+1)),wp(o,this.toBBox),o;n||(n=Math.ceil(Math.log(r)/Math.log(s)),s=Math.ceil(r/Math.pow(s,n-1))),o=Dp([]),o.leaf=!1,o.height=n;const a=Math.ceil(r/s),l=a*Math.ceil(Math.sqrt(s));Rp(e,t,i,l,this.compareMinX);for(let r=t;r<=i;r+=l){const t=Math.min(r+l-1,i);Rp(e,r,t,a,this.compareMinY);for(let i=r;i<=t;i+=a){const r=Math.min(i+a-1,t);o.children.push(this._build(e,i,r,n-1))}}return wp(o,this.toBBox),o}_chooseSubtree(e,t,i,n){for(;n.push(t),!t.leaf&&n.length-1!==i;){let i,n=1/0,r=1/0;for(let o=0;o<t.children.length;o++){const s=t.children[o],a=kp(s),l=Cp(e,s)-a;l<r?(r=l,n=a<n?a:n,i=s):l===r&&a<n&&(n=a,i=s)}t=i||t.children[0]}return t}_insert(e,t,i){const n=i?e:this.toBBox(e),r=[],o=this._chooseSubtree(n,this.data,t,r);for(o.children.push(e),Tp(o,n);t>=0&&r[t].children.length>this._maxEntries;)this._split(r,t),t--;this._adjustParentBBoxes(n,r,t)}_split(e,t){const i=e[t],n=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,n);const o=this._chooseSplitIndex(i,r,n),s=Dp(i.children.splice(o,i.children.length-o));s.height=i.height,s.leaf=i.leaf,wp(i,this.toBBox),wp(s,this.toBBox),t?e[t-1].children.push(s):this._splitRoot(i,s)}_splitRoot(e,t){this.data=Dp([e,t]),this.data.height=e.height+1,this.data.leaf=!1,wp(this.data,this.toBBox)}_chooseSplitIndex(e,t,i){let n,r=1/0,o=1/0;for(let s=t;s<=i-t;s++){const t=Ep(e,0,s,this.toBBox),a=Ep(e,s,i,this.toBBox),l=Pp(t,a),c=kp(t)+kp(a);l<r?(r=l,n=s,o=c<o?c:o):l===r&&c<o&&(o=c,n=s)}return n||i-t}_chooseSplitAxis(e,t,i){const n=e.leaf?this.compareMinX:Sp,r=e.leaf?this.compareMinY:Ip;this._allDistMargin(e,t,i,n)<this._allDistMargin(e,t,i,r)&&e.children.sort(n)}_allDistMargin(e,t,i,n){e.children.sort(n);const r=this.toBBox,o=Ep(e,0,t,r),s=Ep(e,i-t,i,r);let a=Mp(o)+Mp(s);for(let n=t;n<i-t;n++){const t=e.children[n];Tp(o,e.leaf?r(t):t),a+=Mp(o)}for(let n=i-t-1;n>=t;n--){const t=e.children[n];Tp(s,e.leaf?r(t):t),a+=Mp(s)}return a}_adjustParentBBoxes(e,t,i){for(let n=i;n>=0;n--)Tp(t[n],e)}_condense(e){for(let t,i=e.length-1;i>=0;i--)0===e[i].children.length?i>0?(t=e[i-1].children,t.splice(t.indexOf(e[i]),1)):this.clear():wp(e[i],this.toBBox)}}function bp(e,t,i){if(!i)return t.indexOf(e);for(let n=0;n<t.length;n++)if(i(e,t[n]))return n;return-1}function wp(e,t){Ep(e,0,e.children.length,t,e)}function Ep(e,t,i,n,r){r||(r=Dp(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(let o=t;o<i;o++){const t=e.children[o];Tp(r,e.leaf?n(t):t)}return r}function Tp(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function Sp(e,t){return e.minX-t.minX}function Ip(e,t){return e.minY-t.minY}function kp(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function Mp(e){return e.maxX-e.minX+(e.maxY-e.minY)}function Cp(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function Pp(e,t){const i=Math.max(e.minX,t.minX),n=Math.max(e.minY,t.minY),r=Math.min(e.maxX,t.maxX),o=Math.min(e.maxY,t.maxY);return Math.max(0,r-i)*Math.max(0,o-n)}function Ap(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function Lp(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function Dp(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Rp(e,t,i,n,r){const o=[t,i];for(;o.length;){if((i=o.pop())-(t=o.pop())<=n)continue;const s=t+Math.ceil((i-t)/n/2)*n;gp(e,s,t,i,r),o.push(t,s,s,i)}}function zp(e){return function(e,t,i){var n=i;return Pe(e,function(e,i,r,o,s){n=t(n,e,i,r,o,s)}),n}(e,(e,t)=>e+function(e){let t,i=0;switch(e.type){case"Polygon":return Fp(e.coordinates);case"MultiPolygon":for(t=0;t<e.coordinates.length;t++)i+=Fp(e.coordinates[t]);return i;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}(t),0)}function Fp(e){let t=0;if(e&&e.length>0){t+=Math.abs(Bp(e[0]));for(let i=1;i<e.length;i++)t-=Math.abs(Bp(e[i]))}return t}var Op=pe*pe/2,Np=Math.PI/180;function Bp(e){const t=e.length-1;if(t<=2)return 0;let i=0,n=0;for(;n<t;){const r=e[n],o=e[n+1===t?0:n+1],s=e[n+2>=t?(n+2)%t:n+2],a=r[0]*Np,l=o[1]*Np;i+=(s[0]*Np-a)*Math.sin(l),n++}return i*Op}function Gp(e,t,i){if("Polygon"!==e.geometry.type)throw new Error("The input feature must be a Polygon");void 0===i&&(i=1);var n=e.geometry.coordinates,r=[],o={};if(i){for(var s=[],a=0;a<n.length;a++)for(var l=0;l<n[a].length-1;l++)s.push(m(a,l));var c=new xp;c.load(s)}for(var u=0;u<n.length;u++)for(var h=0;h<n[u].length-1;h++)if(i){c.search(m(u,h)).forEach(function(e){var t=e.ring,i=e.edge;f(u,h,t,i)})}else for(var d=0;d<n.length;d++)for(var p=0;p<n[d].length-1;p++)f(u,h,d,p);return t||(r={type:"Feature",geometry:{type:"MultiPoint",coordinates:r}}),r;function f(e,i,s,a){var l,c,u=n[e][i],h=n[e][i+1],d=n[s][a],p=n[s][a+1],f=function(e,t,i,n){if(jp(e,i)||jp(e,n)||jp(t,i)||jp(n,i))return null;var r=e[0],o=e[1],s=t[0],a=t[1],l=i[0],c=i[1],u=n[0],h=n[1],d=(r-s)*(c-h)-(o-a)*(l-u);if(0===d)return null;var p=((r*a-o*s)*(l-u)-(r-s)*(l*h-c*u))/d,f=((r*a-o*s)*(c-h)-(o-a)*(l*h-c*u))/d;return[p,f]}(u,h,d,p);if(null!==f&&(l=h[0]!==u[0]?(f[0]-u[0])/(h[0]-u[0]):(f[1]-u[1])/(h[1]-u[1]),c=p[0]!==d[0]?(f[0]-d[0])/(p[0]-d[0]):(f[1]-d[1])/(p[1]-d[1]),!(l>=1||l<=0||c>=1||c<=0))){var m=f,g=!o[m];g&&(o[m]=!0),t?r.push(t(f,e,i,u,h,l,s,a,d,p,c,g)):r.push(f)}}function m(e,t){var i,r,o,s,a=n[e][t],l=n[e][t+1];return a[0]<l[0]?(i=a[0],r=l[0]):(i=l[0],r=a[0]),a[1]<l[1]?(o=a[1],s=l[1]):(o=l[1],s=a[1]),{minX:i,minY:o,maxX:r,maxY:s,ring:e,edge:t}}}function jp(e,t){if(!e||!t||e.length!==t.length)return!1;for(var i=0,n=e.length;i<n;i++)if(e[i]instanceof Array&&t[i]instanceof Array){if(!jp(e[i],t[i]))return!1}else if(e[i]!==t[i])return!1;return!0}function Vp(e){if("Feature"!=e.type)throw new Error("The input must a geojson object of type Feature");if(void 0===e.geometry||null==e.geometry)throw new Error("The input must a geojson object with a non-empty geometry");if("Polygon"!=e.geometry.type)throw new Error("The input must be a geojson Polygon");for(var t=e.geometry.coordinates.length,i=[],n=0;n<t;n++){var r=e.geometry.coordinates[n];Hp(r[0],r[r.length-1])||r.push(r[0]);for(var o=0;o<r.length-1;o++)i.push(r[o])}if(!function(e){for(var t={},i=1,n=0,r=e.length;n<r;++n){if(Object.prototype.hasOwnProperty.call(t,e[n])){i=0;break}t[e[n]]=1}return i}(i))throw new Error("The input polygon may not have duplicate vertices (except for the first and last vertex of each ring)");var s=i.length,a=Gp(e,function(e,t,i,n,r,o,s,a,l,c,u,h){return[e,t,i,n,r,o,s,a,l,c,u,h]}),l=a.length;if(0==l){var c=[];for(n=0;n<t;n++)c.push(ye([e.geometry.coordinates[n]],{parent:-1,winding:$p(e.geometry.coordinates[n])}));var u=ve(c);return F(),O(),u}var h=[],d=[];for(n=0;n<t;n++){h.push([]);for(o=0;o<e.geometry.coordinates[n].length-1;o++)h[n].push([new Up(e.geometry.coordinates[n][Wp(o+1,e.geometry.coordinates[n].length-1)],1,[n,o],[n,Wp(o+1,e.geometry.coordinates[n].length-1)],void 0)]),d.push(new qp(e.geometry.coordinates[n][o],[n,Wp(o-1,e.geometry.coordinates[n].length-1)],[n,o],void 0,void 0,!1,!0))}for(n=0;n<l;n++)h[a[n][1]][a[n][2]].push(new Up(a[n][0],a[n][5],[a[n][1],a[n][2]],[a[n][6],a[n][7]],void 0)),a[n][11]&&d.push(new qp(a[n][0],[a[n][1],a[n][2]],[a[n][6],a[n][7]],void 0,void 0,!0,!0));var p=d.length;for(n=0;n<h.length;n++)for(o=0;o<h[n].length;o++)h[n][o].sort(function(e,t){return e.param<t.param?-1:1});var f=[];for(n=0;n<p;n++)f.push({minX:d[n].coord[0],minY:d[n].coord[1],maxX:d[n].coord[0],maxY:d[n].coord[1],index:n});var m=new xp;m.load(f);for(n=0;n<h.length;n++)for(o=0;o<h[n].length;o++)for(var g=0;g<h[n][o].length;g++){_=g==h[n][o].length-1?h[n][Wp(o+1,e.geometry.coordinates[n].length-1)][0].coord:h[n][o][g+1].coord;var y=m.search({minX:_[0],minY:_[1],maxX:_[0],maxY:_[1]})[0];h[n][o][g].nxtIsectAlongEdgeIn=y.index}for(n=0;n<h.length;n++)for(o=0;o<h[n].length;o++)for(g=0;g<h[n][o].length;g++){var _=h[n][o][g].coord,v=(y=m.search({minX:_[0],minY:_[1],maxX:_[0],maxY:_[1]})[0]).index;v<s?d[v].nxtIsectAlongRingAndEdge2=h[n][o][g].nxtIsectAlongEdgeIn:Hp(d[v].ringAndEdge1,h[n][o][g].ringAndEdgeIn)?d[v].nxtIsectAlongRingAndEdge1=h[n][o][g].nxtIsectAlongEdgeIn:d[v].nxtIsectAlongRingAndEdge2=h[n][o][g].nxtIsectAlongEdgeIn}var x=[];for(n=0,o=0;o<t;o++){var b=n;for(g=0;g<e.geometry.coordinates[o].length-1;g++)d[n].coord[0]<d[b].coord[0]&&(b=n),n++;var w=d[b].nxtIsectAlongRingAndEdge2;for(g=0;g<d.length;g++)if(d[g].nxtIsectAlongRingAndEdge1==b||d[g].nxtIsectAlongRingAndEdge2==b){var E=g;break}var T=Zp([d[E].coord,d[b].coord,d[w].coord],!0)?1:-1;x.push({isect:b,parent:-1,winding:T})}x.sort(function(e,t){return d[e.isect].coord>d[t.isect].coord?-1:1});for(c=[];x.length>0;){var S=x.pop(),I=S.isect,k=S.parent,M=S.winding,C=c.length,P=[d[I].coord],A=I;if(d[I].ringAndEdge1Walkable)var L=d[I].ringAndEdge1,D=d[I].nxtIsectAlongRingAndEdge1;else L=d[I].ringAndEdge2,D=d[I].nxtIsectAlongRingAndEdge2;for(;!Hp(d[I].coord,d[D].coord);){P.push(d[D].coord);var R=void 0;for(n=0;n<x.length;n++)if(x[n].isect==D){R=n;break}if(null!=R&&x.splice(R,1),Hp(L,d[D].ringAndEdge1)){if(L=d[D].ringAndEdge2,d[D].ringAndEdge2Walkable=!1,d[D].ringAndEdge1Walkable){var z={isect:D};Zp([d[A].coord,d[D].coord,d[d[D].nxtIsectAlongRingAndEdge2].coord],1==M)?(z.parent=k,z.winding=-M):(z.parent=C,z.winding=M),x.push(z)}A=D,D=d[D].nxtIsectAlongRingAndEdge2}else{if(L=d[D].ringAndEdge1,d[D].ringAndEdge1Walkable=!1,d[D].ringAndEdge2Walkable){z={isect:D};Zp([d[A].coord,d[D].coord,d[d[D].nxtIsectAlongRingAndEdge1].coord],1==M)?(z.parent=k,z.winding=-M):(z.parent=C,z.winding=M),x.push(z)}A=D,D=d[D].nxtIsectAlongRingAndEdge1}}P.push(d[D].coord),c.push(ye([P],{index:C,parent:k,winding:M,netWinding:void 0}))}u=ve(c);function F(){for(var e=[],t=0;t<u.features.length;t++)-1==u.features[t].properties.parent&&e.push(t);if(e.length>1)for(t=0;t<e.length;t++){for(var i=-1,n=1/0,r=0;r<u.features.length;r++)e[t]!=r&&Zo(u.features[e[t]].geometry.coordinates[0][0],u.features[r],{ignoreBoundary:!0})&&zp(u.features[r])<n&&(i=r);u.features[e[t]].properties.parent=i}}function O(){for(var e=0;e<u.features.length;e++)if(-1==u.features[e].properties.parent){var t=u.features[e].properties.winding;u.features[e].properties.netWinding=t,N(e,t)}}function N(e,t){for(var i=0;i<u.features.length;i++)if(u.features[i].properties.parent==e){var n=t+u.features[i].properties.winding;u.features[i].properties.netWinding=n,N(i,n)}}return F(),O(),u}var Up=function(e,t,i,n,r){this.coord=e,this.param=t,this.ringAndEdgeIn=i,this.ringAndEdgeOut=n,this.nxtIsectAlongEdgeIn=r},qp=function(e,t,i,n,r,o,s){this.coord=e,this.ringAndEdge1=t,this.ringAndEdge2=i,this.nxtIsectAlongRingAndEdge1=n,this.nxtIsectAlongRingAndEdge2=r,this.ringAndEdge1Walkable=o,this.ringAndEdge2Walkable=s};function Zp(e,t){if(typeof t>"u"&&(t=!0),3!=e.length)throw new Error("This function requires an array of three points [x,y]");return(e[1][0]-e[0][0])*(e[2][1]-e[0][1])-(e[1][1]-e[0][1])*(e[2][0]-e[0][0])>=0==t}function $p(e){for(var t=0,i=0;i<e.length-1;i++)e[i][0]<e[t][0]&&(t=i);if(Zp([e[Wp(t-1,e.length-1)],e[t],e[Wp(t+1,e.length-1)]],!0))var n=1;else n=-1;return n}function Hp(e,t){if(!e||!t||e.length!=t.length)return!1;for(var i=0,n=e.length;i<n;i++)if(e[i]instanceof Array&&t[i]instanceof Array){if(!Hp(e[i],t[i]))return!1}else if(e[i]!=t[i])return!1;return!0}function Wp(e,t){return(e%t+t)%t}var Xp=function(e){var t=[];return Ae(e,function(e){"Polygon"===e.geometry.type&&Ce(Vp(e),function(i){t.push(ye(i.geometry.coordinates,e.properties))})}),ve(t)};const Yp={marker:class extends Co{constructor(){super(...arguments),X(this,"mode","marker"),X(this,"shape","marker"),X(this,"mapEventHandlers",{click:this.onMouseClick.bind(this),mousemove:this.onMouseMove.bind(this)})}onStartAction(){const e=this.createMarker();this.gm.markerPointer.enable({customMarker:e}),this.fireMarkerPointerStartEvent()}onEndAction(){this.gm.markerPointer.disable(),this.fireMarkerPointerFinishEvent()}onMouseClick(e){return el(e)&&(this.featureData=this.createFeature(e),this.featureData&&this.saveFeature()),{next:!1}}onMouseMove(e){return el(e)&&this.gm.markerPointer.marker?(this.fireMarkerPointerUpdateEvent(),{next:!0}):{next:!0}}createMarker(){const e=document.createElement("div");return e.style.backgroundImage=`url("${Y}")`,e.style.width="36px",e.style.height="36px",e.style.backgroundSize="cover",e.style.pointerEvents="none",this.gm.mapAdapter.createDomMarker({draggable:!1,anchor:"bottom",element:e},[0,0])}createFeature(e){var t;const i=(null==(t=this.gm.markerPointer.marker)?void 0:t.getLngLat())||e.lngLat.toArray(),n=this.getFeatureGeoJson(i);return n&&(this.fireBeforeFeatureCreate({geoJsonFeatures:[n]}),this.flags.featureCreateAllowed)?this.gm.features.createFeature({shapeGeoJson:n,sourceName:tl.temporary}):null}getFeatureGeoJson(e){return{type:"Feature",properties:{shape:this.shape},geometry:{type:"Point",coordinates:e}}}},circle:class extends rp{constructor(){super(...arguments),X(this,"mode","circle"),X(this,"shape","circle"),X(this,"throttledMethods",op({updateFeatureGeoJson:this.updateFeatureGeoJson},this,this.gm.options.settings.throttlingDelay))}onMouseClick(e){var t;if(!el(e))return{next:!0};const i=(null==(t=this.gm.markerPointer.marker)?void 0:t.getLngLat())||e.lngLat.toArray();if(this.circleCenterPoint&&this.circleCenterLngLat)this.fireBeforeFeatureCreate({geoJsonFeatures:[this.getCircleGeoJson(this.circleCenterLngLat,i)]}),this.flags.featureCreateAllowed&&(this.saveCircleFeature(i),this.circleCenterLngLat=null,this.circleCenterPoint=null,this.fireFinishEvent());else if(this.fireBeforeFeatureCreate({geoJsonFeatures:[this.getFeatureGeoJson(i)]}),this.flags.featureCreateAllowed){this.circleCenterLngLat=i,this.circleCenterPoint=this.gm.mapAdapter.project(this.circleCenterLngLat),this.featureData=this.createFeature();const e=this.getControlMarkerData();this.featureData&&e&&this.fireStartEvent(this.featureData,e)}return{next:!1}}onMouseMove(){if(this.circleCenterLngLat&&this.gm.markerPointer.marker){const e=this.gm.markerPointer.marker.getLngLat();this.fireBeforeFeatureCreate({geoJsonFeatures:[this.getCircleGeoJson(this.circleCenterLngLat,e)]}),this.flags.featureCreateAllowed&&this.throttledMethods.updateFeatureGeoJson(e)}return this.circleCenterPoint||this.fireMarkerPointerUpdateEvent(),{next:!1}}updateFeatureGeoJson(e){if(this.featureData&&this.circleCenterLngLat){const t=this.getCircleGeoJson(this.circleCenterLngLat,e);this.featureData.updateGeoJsonGeometry(t.geometry);const i=this.getControlMarkerData();i&&this.fireUpdateEvent(this.featureData,i)}}saveCircleFeature(e){var t;if(this.circleCenterLngLat&&this.featureData){const i=(null==(t=this.gm.markerPointer.marker)?void 0:t.getLngLat())||e;this.updateFeatureGeoJson(i),this.featureData.setShapeProperty("center",this.circleCenterLngLat),this.isFeatureGeoJsonValid()?this.saveFeature():this.removeTmpFeature()}}isFeatureGeoJsonValid(){return!!this.featureData&&ro(this.featureData.getGeoJson())}getCircleGeoJson(e,t){const i=this.gm.mapAdapter.getDistance(e,t);return{...lo({center:e,radius:i}),properties:{shape:this.shape}}}},circle_marker:class extends rp{constructor(){super(...arguments),X(this,"mode","circle_marker"),X(this,"shape","circle_marker")}onStartAction(){this.gm.markerPointer.enable({customMarker:this.createMarker()})}onEndAction(){this.fireMarkerPointerFinishEvent(),super.onEndAction()}onMouseMove(){return this.fireMarkerPointerUpdateEvent(),{next:!0}}onMouseClick(e){var t;const i=(null==(t=this.gm.markerPointer.marker)?void 0:t.getLngLat())||e.lngLat.toArray();return this.fireBeforeFeatureCreate({geoJsonFeatures:[this.getFeatureGeoJson(i)]}),this.flags.featureCreateAllowed&&(this.featureData=this.createFeature(),this.circleCenterLngLat=i,this.circleCenterPoint=this.gm.mapAdapter.project(this.circleCenterLngLat),this.updateFeaturePosition(this.circleCenterLngLat),this.saveFeature()),{next:!1}}updateFeaturePosition(e){if(!this.featureData)return;const t=this.getFeatureGeoJson(e);this.featureData.updateGeoJsonGeometry(t.geometry)}},text_marker:class extends Co{constructor(){super(...arguments),X(this,"mode","text_marker"),X(this,"shape","text_marker"),X(this,"textarea",null),X(this,"mapEventHandlers",{click:this.onMouseClick.bind(this),mousemove:this.onMouseMove.bind(this)})}onStartAction(){this.gm.markerPointer.enable({invisibleMarker:!0})}onEndAction(){this.removeTextarea(),this.removeTmpFeature(),this.featureData=null,this.gm.markerPointer.disable(),this.fireMarkerPointerFinishEvent()}onMouseMove(e){return el(e,{warning:!0})?(this.fireMarkerPointerUpdateEvent(),{next:!0}):{next:!0}}onMouseClick(e){var t;if(!el(e,{warning:!0}))return{next:!0};if(this.textarea)this.endShape(),this.gm.markerPointer.enable({invisibleMarker:!0,lngLat:e.lngLat.toArray()}),this.fireMarkerPointerUpdateEvent();else{const i=(null==(t=this.gm.markerPointer.marker)?void 0:t.getLngLat())||e.lngLat.toArray();this.fireBeforeFeatureCreate({geoJsonFeatures:[this.getFeatureGeoJson(i)]}),this.flags.featureCreateAllowed&&(this.featureData=this.createFeature(i),this.gm.markerPointer.disable(),this.fireMarkerPointerFinishEvent())}return{next:!1}}createFeature(e){const t=this.gm.mapAdapter.project(e);return this.createTextarea(t),this.gm.features.createFeature({shapeGeoJson:this.getFeatureGeoJson(e),sourceName:tl.temporary})}endShape(){var e;const t=(null==(e=this.textarea)?void 0:e.value)||"";this.removeTextarea(),t.trim()?(this.updateFeatureSource(t),this.saveFeature()):this.removeTmpFeature()}createTextarea(e){this.textarea=document.createElement("textarea"),this.textarea.style.position="absolute",this.textarea.style.left=`${e[0]}px`,this.textarea.style.top=`${e[1]}px`,this.textarea.style.opacity="0.7",this.gm.mapAdapter.getContainer().appendChild(this.textarea),this.textarea.focus()}removeTextarea(){var e;null==(e=this.textarea)||e.remove(),this.textarea=null}getFeatureGeoJson(e){return{type:"Feature",properties:{shape:this.shape,text:""},geometry:{type:"Point",coordinates:e}}}updateFeatureSource(e){this.featureData&&this.featureData.updateGeoJsonProperties({shape:this.shape,text:e})}},line:class extends Co{constructor(){super(...arguments),X(this,"mode","line"),X(this,"shape","line"),X(this,"lineDrawer",new fp(this.gm,{snappingMarkers:"first",targetShape:"line"})),X(this,"mapEventHandlers",{[`${_o}:draw`]:this.forwardLineDrawerEvent.bind(this),mousemove:this.onMouseMove.bind(this)})}onStartAction(){this.lineDrawer.startAction(),this.lineDrawer.on("nMarkerClick",this.lineFinished.bind(this))}onEndAction(){this.lineDrawer.endAction()}onMouseMove(e){return el(e)?(this.lineDrawer.featureData||this.fireMarkerPointerUpdateEvent(),{next:!0}):{next:!0}}lineFinished(e){this.lineDrawer.endShape();let t=e.shapeCoordinates;return e.markerIndex>0&&(t=t.slice(0,e.markerIndex+1)),t.length<2?null:this.gm.features.createFeature({shapeGeoJson:this.getFeatureGeoJson(t),sourceName:tl.main})}getFeatureGeoJson(e){return{type:"Feature",properties:{shape:this.shape},geometry:{type:"LineString",coordinates:e}}}},rectangle:class extends Co{constructor(){super(...arguments),X(this,"mode","rectangle"),X(this,"shape","rectangle"),X(this,"startLngLat",null),X(this,"mapEventHandlers",{mousemove:this.onMouseMove.bind(this),click:this.onMouseClick.bind(this)}),X(this,"throttledMethods",op({updateFeaturePosition:this.updateFeaturePosition},this,this.gm.options.settings.throttlingDelay))}onStartAction(){this.gm.markerPointer.enable()}onEndAction(){this.removeTmpFeature(),this.startLngLat=null,this.gm.markerPointer.disable(),this.fireFinishEvent()}onMouseClick(e){var t;if(!el(e,{warning:!0}))return{next:!1};const i=(null==(t=this.gm.markerPointer.marker)?void 0:t.getLngLat())||e.lngLat.toArray();if(this.startLngLat){const e=this.getFeatureGeoJson(Qr(this.startLngLat,i));this.fireBeforeFeatureCreate({geoJsonFeatures:[e]}),this.flags.featureCreateAllowed&&this.finishShape(i)}else{const e=this.getFeatureGeoJson(Qr(i,i));if(this.fireBeforeFeatureCreate({geoJsonFeatures:[e]}),this.flags.featureCreateAllowed){const e=this.startShape(i);if(e){const t=this.getControlMarkerData(["geometry","coordinates",4]);this.fireStartEvent(e,t)}}}return{next:!1}}onMouseMove(e){var t;if(!el(e,{warning:!0}))return{next:!1};if(!this.startLngLat)return this.fireMarkerPointerUpdateEvent(),{next:!1};const i=(null==(t=this.gm.markerPointer.marker)?void 0:t.getLngLat())||e.lngLat.toArray(),n=Qr(this.startLngLat,i),r=this.getFeatureGeoJson(n);return this.fireBeforeFeatureCreate({geoJsonFeatures:[r]}),this.flags.featureCreateAllowed&&this.throttledMethods.updateFeaturePosition(n),{next:!1}}startShape(e){this.startLngLat=e;const t=Qr(this.startLngLat,this.startLngLat);return this.featureData=this.createFeature(t),this.featureData}finishShape(e){if(this.startLngLat){const t=Qr(this.startLngLat,e);this.throttledMethods.updateFeaturePosition(t)}this.featureData&&(this.isFeatureGeoJsonValid()?this.saveFeature():this.removeTmpFeature()),this.startLngLat=null,this.fireFinishEvent()}createFeature(e){return this.gm.features.createFeature({shapeGeoJson:this.getFeatureGeoJson(e),sourceName:tl.temporary})}isFeatureGeoJsonValid(){return!!this.featureData&&ro(this.featureData.getGeoJson())}getFeatureGeoJson(e){return{...eo([e[0],e[2]],[e[2],e[3]]),properties:{shape:this.shape}}}updateFeaturePosition(e){if(!this.featureData)return;const t=eo([e[0],e[1]],[e[2],e[3]]);this.featureData.updateGeoJsonGeometry(t.geometry);const i=this.getControlMarkerData(["geometry","coordinates",4]);this.fireUpdateEvent(this.featureData,i)}getControlMarkerData(e){const t=this.gm.markerPointer.marker;return t?{type:"dom",instance:t,position:{coordinate:t.getLngLat(),path:e}}:null}fireStartEvent(e,t){const i={level:"system",type:"draw",mode:this.shape,variant:null,action:"start",featureData:e,markerData:t};this.gm.events.fire(`${_o}:draw`,i)}fireUpdateEvent(e,t){const i={level:"system",type:"draw",mode:this.shape,variant:null,action:"update",featureData:e,markerData:t};this.gm.events.fire(`${_o}:draw`,i)}fireFinishEvent(){const e={level:"system",type:"draw",mode:this.shape,variant:null,action:"finish"};this.gm.events.fire(`${_o}:draw`,e)}},polygon:class extends Co{constructor(){super(...arguments),X(this,"mode","polygon"),X(this,"shape","polygon"),X(this,"lineDrawer",new fp(this.gm,{snappingMarkers:"first",targetShape:"polygon"})),X(this,"mapEventHandlers",{[`${_o}:draw`]:this.forwardLineDrawerEvent.bind(this),mousemove:this.onMouseMove.bind(this)})}onEndAction(){this.lineDrawer.endAction()}onStartAction(){this.lineDrawer.startAction(),this.lineDrawer.on("firstMarkerClick",this.polygonFinished.bind(this))}onMouseMove(e){return el(e)?(this.lineDrawer.featureData||this.fireMarkerPointerUpdateEvent(),{next:!0}):{next:!0}}polygonFinished(e){if(this.lineDrawer.endShape(),e.shapeCoordinates.length<3)return;const t=this.fixShapeGeoJson(up(e.geoJson));t&&this.gm.features.createFeature({shapeGeoJson:{...t,properties:{...t.properties,shape:this.shape}},sourceName:tl.main})}fixShapeGeoJson(e){try{return hs(mp(Xp(e))).features[0]}catch{return null}}},freehand:null,custom_shape:null};class Jp extends Od{constructor(){super(...arguments),X(this,"mode","drag"),X(this,"isDragging",!1),X(this,"previousLngLat",null),X(this,"pointBasedShapes",["marker","circle_marker","text_marker"]),X(this,"throttledMethods",op({onMouseMove:this.onMouseMove},this,this.gm.options.settings.throttlingDelay)),X(this,"mapEventHandlers",{[`${_o}:edit`]:this.handleGmEdit.bind(this),mousedown:this.onMouseDown.bind(this),touchstart:this.onMouseDown.bind(this),mousemove:this.throttledMethods.onMouseMove.bind(this),touchmove:this.throttledMethods.onMouseMove.bind(this),mouseup:this.onMouseUp.bind(this),touchend:this.onMouseUp.bind(this)}),X(this,"getUpdatedGeoJsonHandlers",{marker:this.moveSource.bind(this),circle:this.moveCircle.bind(this),circle_marker:this.moveSource.bind(this),text_marker:this.moveSource.bind(this),line:this.moveSource.bind(this),rectangle:this.moveSource.bind(this),polygon:this.moveSource.bind(this)})}onMouseDown(e){var t;return this.featureData=this.gm.features.getFeatureByMouseEvent({event:e,sourceNames:[tl.main]}),this.featureData&&this.getUpdatedGeoJsonHandlers[this.featureData.shape]?(this.featureData.changeSource({sourceName:tl.temporary,atomic:!0}),this.gm.mapAdapter.setDragPan(!1),this.isDragging=!0,null==(t=this.snappingHelper)||t.addExcludedFeature(this.featureData),this.isPointBasedShape()&&this.alignShapeCenterWithControlMarker(this.featureData,e),this.fireFeatureEditStartEvent({feature:this.featureData,forceMode:"drag"}),{next:!1}):{next:!0}}onMouseUp(){var e;return this.featureData?(null==(e=this.snappingHelper)||e.clearExcludedFeatures(),this.featureData.changeSource({sourceName:tl.main,atomic:!0}),this.isDragging=!1,this.previousLngLat=null,this.gm.mapAdapter.setDragPan(!0),this.fireFeatureEditEndEvent({feature:this.featureData,forceMode:"drag"}),this.featureData=null,{next:!0}):{next:!0}}onMouseMove(e){var t;if(!this.isDragging||!el(e,{warning:!0}))return{next:!0};if(this.featureData){const i=(null==(t=this.gm.markerPointer.marker)?void 0:t.getLngLat())||e.lngLat.toArray();this.moveFeature(this.featureData,i)}return{next:!1}}isPointBasedShape(){return!!this.featureData&&this.pointBasedShapes.includes(this.featureData.shape)}alignShapeCenterWithControlMarker(e,t){var i;const n=Ka(e);n&&(null==(i=this.gm.markerPointer.marker)||i.setLngLat(n),this.onMouseMove(t))}moveFeature(e,t){if(!this.isDragging)return;if(!this.previousLngLat)return void(this.previousLngLat=t);const i=this.getUpdatedGeoJsonHandlers[e.shape];if(i){const n=i(e,this.previousLngLat,t);if(!n)return void he.error("BaseDrag.moveFeature: invalid updatedGeoJson",e);this.fireBeforeFeatureUpdate({features:[e],geoJsonFeatures:[n],forceMode:"drag"}),this.updateFeatureGeoJson({featureData:e,featureGeoJson:n,forceMode:"drag"})&&(this.previousLngLat=t)}}moveSource(e,t,i){const n=Wr(t,i);return Ya(e,n)}moveCircle(e,t,i){if("circle"!==e.shape)return he.error("BaseDrag.moveCircle: invalid shape type",e),null;const n=e.getShapeProperty("center");if(!n)return he.error("BaseDrag.moveCircle: missing center in the featureData",e),null;const r=e.getGeoJson(),o=Wr(t,i),s=oo(r);if(!s)return he.error("BaseDrag.moveCircle: missing center circleRimLngLat"),null;const a=[n[0]+o.lng,n[1]+o.lat];return{type:"Feature",properties:{shape:"circle",center:a},geometry:lo({center:a,radius:this.gm.mapAdapter.getDistance(n,s)}).geometry}}}function Kp(e,t,{ignoreSelfIntersections:i=!0}={ignoreSelfIntersections:!0}){let n=!0;return Ae(e,e=>{Ae(t,t=>{if(!1===n)return!1;n=function(e,t,i){switch(e.type){case"Point":switch(t.type){case"Point":return!function(e,t){return e[0]===t[0]&&e[1]===t[1]}(e.coordinates,t.coordinates);case"LineString":return!Qp(t,e);case"Polygon":return!Zo(e,t)}break;case"LineString":switch(t.type){case"Point":return!Qp(e,t);case"LineString":return!function(e,t,i){return rs(e,t,{ignoreSelfIntersections:i}).features.length>0}(e,t,i);case"Polygon":return!ef(t,e,i)}break;case"Polygon":switch(t.type){case"Point":return!Zo(t,e);case"LineString":return!ef(e,t,i);case"Polygon":return!function(e,t,i){for(const i of e.coordinates[0])if(Zo(i,t))return!0;for(const i of t.coordinates[0])if(Zo(i,e))return!0;return rs(Ve(e),Ve(t),{ignoreSelfIntersections:i}).features.length>0}(t,e,i)}}return!1}(e.geometry,t.geometry,i)})}),n}function Qp(e,t){for(let i=0;i<e.coordinates.length-1;i++)if(tf(e.coordinates[i],e.coordinates[i+1],t.coordinates))return!0;return!1}function ef(e,t,i){for(const i of t.coordinates)if(Zo(i,e))return!0;return rs(t,Ve(e),{ignoreSelfIntersections:i}).features.length>0}function tf(e,t,i){const n=i[0]-e[0],r=i[1]-e[1],o=t[0]-e[0],s=t[1]-e[1];return n*s-r*o===0&&(Math.abs(o)>=Math.abs(s)?o>0?e[0]<=i[0]&&i[0]<=t[0]:t[0]<=i[0]&&i[0]<=e[0]:s>0?e[1]<=i[1]&&i[1]<=t[1]:t[1]<=i[1]&&i[1]<=e[1])}var nf=function(e,t,{ignoreSelfIntersections:i=!0}={}){let n=!1;return Ae(e,e=>{Ae(t,t=>{if(!0===n)return!0;n=!Kp(e.geometry,t.geometry,{ignoreSelfIntersections:i})})}),n},rf=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,of=Math.ceil,sf=Math.floor,af="[BigNumber Error] ",lf=af+"Number primitive has more than 15 significant digits: ",cf=1e14,uf=14,hf=9007199254740991,df=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],pf=1e7,ff=1e9;function mf(e){var t=0|e;return e>0||e===t?t:t-1}function gf(e){for(var t,i,n=1,r=e.length,o=e[0]+"";n<r;){for(t=e[n++]+"",i=uf-t.length;i--;t="0"+t);o+=t}for(r=o.length;48===o.charCodeAt(--r););return o.slice(0,r+1||1)}function yf(e,t){var i,n,r=e.c,o=t.c,s=e.s,a=t.s,l=e.e,c=t.e;if(!s||!a)return null;if(i=r&&!r[0],n=o&&!o[0],i||n)return i?n?0:-a:s;if(s!=a)return s;if(i=s<0,n=l==c,!r||!o)return n?0:!r^i?1:-1;if(!n)return l>c^i?1:-1;for(a=(l=r.length)<(c=o.length)?l:c,s=0;s<a;s++)if(r[s]!=o[s])return r[s]>o[s]^i?1:-1;return l==c?0:l>c^i?1:-1}function _f(e,t,i,n){if(e<t||e>i||e!==sf(e))throw Error(af+(n||"Argument")+("number"==typeof e?e<t||e>i?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function vf(e){var t=e.c.length-1;return mf(e.e/uf)==t&&e.c[t]%2!=0}function xf(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function bf(e,t,i){var n,r;if(t<0){for(r=i+".";++t;r+=i);e=r+e}else if(++t>(n=e.length)){for(r=i,t-=n;--t;r+=i);e+=r}else t<n&&(e=e.slice(0,t)+"."+e.slice(t));return e}var wf,Ef,Tf=function e(t){var i,n,r,o,s,a=b.prototype={constructor:b,toString:null,valueOf:null},l=new b(1),c=20,u=4,h=-7,d=21,p=-1e7,f=1e7,m=!1,g=1,y=0,_={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},v="0123456789abcdefghijklmnopqrstuvwxyz",x=!0;function b(e,t){var i,o,s,a,l,h,d,m,g=this;if(!(g instanceof b))return new b(e,t);if(null==t){if(e&&!0===e._isBigNumber)return g.s=e.s,void(!e.c||e.e>f?g.c=g.e=null:e.e<p?g.c=[g.e=0]:(g.e=e.e,g.c=e.c.slice()));if((h="number"==typeof e)&&0*e==0){if(g.s=1/e<0?(e=-e,-1):1,e===~~e){for(a=0,l=e;l>=10;l/=10,a++);return void(a>f?g.c=g.e=null:(g.e=a,g.c=[e]))}m=String(e)}else{if(!rf.test(m=String(e)))return r(g,m,h);g.s=45==m.charCodeAt(0)?(m=m.slice(1),-1):1}(a=m.indexOf("."))>-1&&(m=m.replace(".","")),(l=m.search(/e/i))>0?(a<0&&(a=l),a+=+m.slice(l+1),m=m.substring(0,l)):a<0&&(a=m.length)}else{if(_f(t,2,v.length,"Base"),10==t&&x)return S(g=new b(e),c+g.e+1,u);if(m=String(e),h="number"==typeof e){if(0*e!=0)return r(g,m,h,t);if(g.s=1/e<0?(m=m.slice(1),-1):1,b.DEBUG&&m.replace(/^0\.0*|\./,"").length>15)throw Error(lf+e)}else g.s=45===m.charCodeAt(0)?(m=m.slice(1),-1):1;for(i=v.slice(0,t),a=l=0,d=m.length;l<d;l++)if(i.indexOf(o=m.charAt(l))<0){if("."==o){if(l>a){a=d;continue}}else if(!s&&(m==m.toUpperCase()&&(m=m.toLowerCase())||m==m.toLowerCase()&&(m=m.toUpperCase()))){s=!0,l=-1,a=0;continue}return r(g,String(e),h,t)}h=!1,(a=(m=n(m,t,10,g.s)).indexOf("."))>-1?m=m.replace(".",""):a=m.length}for(l=0;48===m.charCodeAt(l);l++);for(d=m.length;48===m.charCodeAt(--d););if(m=m.slice(l,++d)){if(d-=l,h&&b.DEBUG&&d>15&&(e>hf||e!==sf(e)))throw Error(lf+g.s*e);if((a=a-l-1)>f)g.c=g.e=null;else if(a<p)g.c=[g.e=0];else{if(g.e=a,g.c=[],l=(a+1)%uf,a<0&&(l+=uf),l<d){for(l&&g.c.push(+m.slice(0,l)),d-=uf;l<d;)g.c.push(+m.slice(l,l+=uf));l=uf-(m=m.slice(l)).length}else l-=d;for(;l--;m+="0");g.c.push(+m)}}else g.c=[g.e=0]}function w(e,t,i,n){var r,o,s,a,l;if(null==i?i=u:_f(i,0,8),!e.c)return e.toString();if(r=e.c[0],s=e.e,null==t)l=gf(e.c),l=1==n||2==n&&(s<=h||s>=d)?xf(l,s):bf(l,s,"0");else if(o=(e=S(new b(e),t,i)).e,a=(l=gf(e.c)).length,1==n||2==n&&(t<=o||o<=h)){for(;a<t;l+="0",a++);l=xf(l,o)}else if(t-=s,l=bf(l,o,"0"),o+1>a){if(--t>0)for(l+=".";t--;l+="0");}else if((t+=o-a)>0)for(o+1==a&&(l+=".");t--;l+="0");return e.s<0&&r?"-"+l:l}function E(e,t){for(var i,n,r=1,o=new b(e[0]);r<e.length;r++)(!(n=new b(e[r])).s||(i=yf(o,n))===t||0===i&&o.s===t)&&(o=n);return o}function T(e,t,i){for(var n=1,r=t.length;!t[--r];t.pop());for(r=t[0];r>=10;r/=10,n++);return(i=n+i*uf-1)>f?e.c=e.e=null:i<p?e.c=[e.e=0]:(e.e=i,e.c=t),e}function S(e,t,i,n){var r,o,s,a,l,c,u,h=e.c,d=df;if(h){e:{for(r=1,a=h[0];a>=10;a/=10,r++);if((o=t-r)<0)o+=uf,s=t,l=h[c=0],u=sf(l/d[r-s-1]%10);else if((c=of((o+1)/uf))>=h.length){if(!n)break e;for(;h.length<=c;h.push(0));l=u=0,r=1,s=(o%=uf)-uf+1}else{for(l=a=h[c],r=1;a>=10;a/=10,r++);u=(s=(o%=uf)-uf+r)<0?0:sf(l/d[r-s-1]%10)}if(n=n||t<0||null!=h[c+1]||(s<0?l:l%d[r-s-1]),n=i<4?(u||n)&&(0==i||i==(e.s<0?3:2)):u>5||5==u&&(4==i||n||6==i&&(o>0?s>0?l/d[r-s]:0:h[c-1])%10&1||i==(e.s<0?8:7)),t<1||!h[0])return h.length=0,n?(t-=e.e+1,h[0]=d[(uf-t%uf)%uf],e.e=-t||0):h[0]=e.e=0,e;if(0==o?(h.length=c,a=1,c--):(h.length=c+1,a=d[uf-o],h[c]=s>0?sf(l/d[r-s]%d[s])*a:0),n)for(;;){if(0==c){for(o=1,s=h[0];s>=10;s/=10,o++);for(s=h[0]+=a,a=1;s>=10;s/=10,a++);o!=a&&(e.e++,h[0]==cf&&(h[0]=1));break}if(h[c]+=a,h[c]!=cf)break;h[c--]=0,a=1}for(o=h.length;0===h[--o];h.pop());}e.e>f?e.c=e.e=null:e.e<p&&(e.c=[e.e=0])}return e}function I(e){var t,i=e.e;return null===i?e.toString():(t=gf(e.c),t=i<=h||i>=d?xf(t,i):bf(t,i,"0"),e.s<0?"-"+t:t)}return b.clone=e,b.ROUND_UP=0,b.ROUND_DOWN=1,b.ROUND_CEIL=2,b.ROUND_FLOOR=3,b.ROUND_HALF_UP=4,b.ROUND_HALF_DOWN=5,b.ROUND_HALF_EVEN=6,b.ROUND_HALF_CEIL=7,b.ROUND_HALF_FLOOR=8,b.EUCLID=9,b.config=b.set=function(e){var t,i;if(null!=e){if("object"!=typeof e)throw Error(af+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(_f(i=e[t],0,ff,t),c=i),e.hasOwnProperty(t="ROUNDING_MODE")&&(_f(i=e[t],0,8,t),u=i),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((i=e[t])&&i.pop?(_f(i[0],-1e9,0,t),_f(i[1],0,ff,t),h=i[0],d=i[1]):(_f(i,-1e9,ff,t),h=-(d=i<0?-i:i))),e.hasOwnProperty(t="RANGE"))if((i=e[t])&&i.pop)_f(i[0],-1e9,-1,t),_f(i[1],1,ff,t),p=i[0],f=i[1];else{if(_f(i,-1e9,ff,t),!i)throw Error(af+t+" cannot be zero: "+i);p=-(f=i<0?-i:i)}if(e.hasOwnProperty(t="CRYPTO")){if((i=e[t])!==!!i)throw Error(af+t+" not true or false: "+i);if(i){if(!(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes)))throw m=!i,Error(af+"crypto unavailable");m=i}else m=i}if(e.hasOwnProperty(t="MODULO_MODE")&&(_f(i=e[t],0,9,t),g=i),e.hasOwnProperty(t="POW_PRECISION")&&(_f(i=e[t],0,ff,t),y=i),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(i=e[t]))throw Error(af+t+" not an object: "+i);_=i}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(i=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(i))throw Error(af+t+" invalid: "+i);x="0123456789"==i.slice(0,10),v=i}}return{DECIMAL_PLACES:c,ROUNDING_MODE:u,EXPONENTIAL_AT:[h,d],RANGE:[p,f],CRYPTO:m,MODULO_MODE:g,POW_PRECISION:y,FORMAT:_,ALPHABET:v}},b.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!b.DEBUG)return!0;var t,i,n=e.c,r=e.e,o=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===o||-1===o)&&r>=-1e9&&r<=ff&&r===sf(r)){if(0===n[0]){if(0===r&&1===n.length)return!0;break e}if((t=(r+1)%uf)<1&&(t+=uf),String(n[0]).length==t){for(t=0;t<n.length;t++)if((i=n[t])<0||i>=cf||i!==sf(i))break e;if(0!==i)return!0}}}else if(null===n&&null===r&&(null===o||1===o||-1===o))return!0;throw Error(af+"Invalid BigNumber: "+e)},b.maximum=b.max=function(){return E(arguments,-1)},b.minimum=b.min=function(){return E(arguments,1)},b.random=(o=9007199254740992,s=Math.random()*o&2097151?function(){return sf(Math.random()*o)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,i,n,r,o,a=0,u=[],h=new b(l);if(null==e?e=c:_f(e,0,ff),r=of(e/uf),m)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(r*=2));a<r;)(o=131072*t[a]+(t[a+1]>>>11))>=9e15?(i=crypto.getRandomValues(new Uint32Array(2)),t[a]=i[0],t[a+1]=i[1]):(u.push(o%1e14),a+=2);a=r/2}else{if(!crypto.randomBytes)throw m=!1,Error(af+"crypto unavailable");for(t=crypto.randomBytes(r*=7);a<r;)(o=281474976710656*(31&t[a])+1099511627776*t[a+1]+4294967296*t[a+2]+16777216*t[a+3]+(t[a+4]<<16)+(t[a+5]<<8)+t[a+6])>=9e15?crypto.randomBytes(7).copy(t,a):(u.push(o%1e14),a+=7);a=r/7}if(!m)for(;a<r;)(o=s())<9e15&&(u[a++]=o%1e14);for(r=u[--a],e%=uf,r&&e&&(o=df[uf-e],u[a]=sf(r/o)*o);0===u[a];u.pop(),a--);if(a<0)u=[n=0];else{for(n=-1;0===u[0];u.splice(0,1),n-=uf);for(a=1,o=u[0];o>=10;o/=10,a++);a<uf&&(n-=uf-a)}return h.e=n,h.c=u,h}),b.sum=function(){for(var e=1,t=arguments,i=new b(t[0]);e<t.length;)i=i.plus(t[e++]);return i},n=function(){var e="0123456789";function t(e,t,i,n){for(var r,o,s=[0],a=0,l=e.length;a<l;){for(o=s.length;o--;s[o]*=t);for(s[0]+=n.indexOf(e.charAt(a++)),r=0;r<s.length;r++)s[r]>i-1&&(null==s[r+1]&&(s[r+1]=0),s[r+1]+=s[r]/i|0,s[r]%=i)}return s.reverse()}return function(n,r,o,s,a){var l,h,d,p,f,m,g,_,x=n.indexOf("."),w=c,E=u;for(x>=0&&(p=y,y=0,n=n.replace(".",""),m=(_=new b(r)).pow(n.length-x),y=p,_.c=t(bf(gf(m.c),m.e,"0"),10,o,e),_.e=_.c.length),d=p=(g=t(n,r,o,a?(l=v,e):(l=e,v))).length;0==g[--p];g.pop());if(!g[0])return l.charAt(0);if(x<0?--d:(m.c=g,m.e=d,m.s=s,g=(m=i(m,_,w,E,o)).c,f=m.r,d=m.e),x=g[h=d+w+1],p=o/2,f=f||h<0||null!=g[h+1],f=E<4?(null!=x||f)&&(0==E||E==(m.s<0?3:2)):x>p||x==p&&(4==E||f||6==E&&1&g[h-1]||E==(m.s<0?8:7)),h<1||!g[0])n=f?bf(l.charAt(1),-w,l.charAt(0)):l.charAt(0);else{if(g.length=h,f)for(--o;++g[--h]>o;)g[h]=0,h||(++d,g=[1].concat(g));for(p=g.length;!g[--p];);for(x=0,n="";x<=p;n+=l.charAt(g[x++]));n=bf(n,d,l.charAt(0))}return n}}(),i=function(){function e(e,t,i){var n,r,o,s,a=0,l=e.length,c=t%pf,u=t/pf|0;for(e=e.slice();l--;)a=((r=c*(o=e[l]%pf)+(n=u*o+(s=e[l]/pf|0)*c)%pf*pf+a)/i|0)+(n/pf|0)+u*s,e[l]=r%i;return a&&(e=[a].concat(e)),e}function t(e,t,i,n){var r,o;if(i!=n)o=i>n?1:-1;else for(r=o=0;r<i;r++)if(e[r]!=t[r]){o=e[r]>t[r]?1:-1;break}return o}function i(e,t,i,n){for(var r=0;i--;)e[i]-=r,r=e[i]<t[i]?1:0,e[i]=r*n+e[i]-t[i];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(n,r,o,s,a){var l,c,u,h,d,p,f,m,g,y,_,v,x,w,E,T,I,k=n.s==r.s?1:-1,M=n.c,C=r.c;if(!(M&&M[0]&&C&&C[0]))return new b(n.s&&r.s&&(M?!C||M[0]!=C[0]:C)?M&&0==M[0]||!C?0*k:k/0:NaN);for(g=(m=new b(k)).c=[],k=o+(c=n.e-r.e)+1,a||(a=cf,c=mf(n.e/uf)-mf(r.e/uf),k=k/uf|0),u=0;C[u]==(M[u]||0);u++);if(C[u]>(M[u]||0)&&c--,k<0)g.push(1),h=!0;else{for(w=M.length,T=C.length,u=0,k+=2,(d=sf(a/(C[0]+1)))>1&&(C=e(C,d,a),M=e(M,d,a),T=C.length,w=M.length),x=T,_=(y=M.slice(0,T)).length;_<T;y[_++]=0);I=C.slice(),I=[0].concat(I),E=C[0],C[1]>=a/2&&E++;do{if(d=0,(l=t(C,y,T,_))<0){if(v=y[0],T!=_&&(v=v*a+(y[1]||0)),(d=sf(v/E))>1)for(d>=a&&(d=a-1),f=(p=e(C,d,a)).length,_=y.length;1==t(p,y,f,_);)d--,i(p,T<f?I:C,f,a),f=p.length,l=1;else 0==d&&(l=d=1),f=(p=C.slice()).length;if(f<_&&(p=[0].concat(p)),i(y,p,_,a),_=y.length,-1==l)for(;t(C,y,T,_)<1;)d++,i(y,T<_?I:C,_,a),_=y.length}else 0===l&&(d++,y=[0]);g[u++]=d,y[0]?y[_++]=M[x]||0:(y=[M[x]],_=1)}while((x++<w||null!=y[0])&&k--);h=null!=y[0],g[0]||g.splice(0,1)}if(a==cf){for(u=1,k=g[0];k>=10;k/=10,u++);S(m,o+(m.e=u+c*uf-1)+1,s,h)}else m.e=c,m.r=+h;return m}}(),r=function(){var e=/^(-?)0([xbo])(?=\w[\w.]*$)/i,t=/^([^.]+)\.$/,i=/^\.([^.]+)$/,n=/^-?(Infinity|NaN)$/,r=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(o,s,a,l){var c,u=a?s:s.replace(r,"");if(n.test(u))o.s=isNaN(u)?null:u<0?-1:1;else{if(!a&&(u=u.replace(e,function(e,t,i){return c="x"==(i=i.toLowerCase())?16:"b"==i?2:8,l&&l!=c?e:t}),l&&(c=l,u=u.replace(t,"$1").replace(i,"0.$1")),s!=u))return new b(u,c);if(b.DEBUG)throw Error(af+"Not a"+(l?" base "+l:"")+" number: "+s);o.s=null}o.c=o.e=null}}(),a.absoluteValue=a.abs=function(){var e=new b(this);return e.s<0&&(e.s=1),e},a.comparedTo=function(e,t){return yf(this,new b(e,t))},a.decimalPlaces=a.dp=function(e,t){var i,n,r,o=this;if(null!=e)return _f(e,0,ff),null==t?t=u:_f(t,0,8),S(new b(o),e+o.e+1,t);if(!(i=o.c))return null;if(n=((r=i.length-1)-mf(this.e/uf))*uf,r=i[r])for(;r%10==0;r/=10,n--);return n<0&&(n=0),n},a.dividedBy=a.div=function(e,t){return i(this,new b(e,t),c,u)},a.dividedToIntegerBy=a.idiv=function(e,t){return i(this,new b(e,t),0,1)},a.exponentiatedBy=a.pow=function(e,t){var i,n,r,o,s,a,c,h,d=this;if((e=new b(e)).c&&!e.isInteger())throw Error(af+"Exponent not an integer: "+I(e));if(null!=t&&(t=new b(t)),s=e.e>14,!d.c||!d.c[0]||1==d.c[0]&&!d.e&&1==d.c.length||!e.c||!e.c[0])return h=new b(Math.pow(+I(d),s?e.s*(2-vf(e)):+I(e))),t?h.mod(t):h;if(a=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new b(NaN);(n=!a&&d.isInteger()&&t.isInteger())&&(d=d.mod(t))}else{if(e.e>9&&(d.e>0||d.e<-1||(0==d.e?d.c[0]>1||s&&d.c[1]>=24e7:d.c[0]<8e13||s&&d.c[0]<=9999975e7)))return o=d.s<0&&vf(e)?-0:0,d.e>-1&&(o=1/o),new b(a?1/o:o);y&&(o=of(y/uf+2))}for(s?(i=new b(.5),a&&(e.s=1),c=vf(e)):c=(r=Math.abs(+I(e)))%2,h=new b(l);;){if(c){if(!(h=h.times(d)).c)break;o?h.c.length>o&&(h.c.length=o):n&&(h=h.mod(t))}if(r){if(0===(r=sf(r/2)))break;c=r%2}else if(S(e=e.times(i),e.e+1,1),e.e>14)c=vf(e);else{if(0===(r=+I(e)))break;c=r%2}d=d.times(d),o?d.c&&d.c.length>o&&(d.c.length=o):n&&(d=d.mod(t))}return n?h:(a&&(h=l.div(h)),t?h.mod(t):o?S(h,y,u,undefined):h)},a.integerValue=function(e){var t=new b(this);return null==e?e=u:_f(e,0,8),S(t,t.e+1,e)},a.isEqualTo=a.eq=function(e,t){return 0===yf(this,new b(e,t))},a.isFinite=function(){return!!this.c},a.isGreaterThan=a.gt=function(e,t){return yf(this,new b(e,t))>0},a.isGreaterThanOrEqualTo=a.gte=function(e,t){return 1===(t=yf(this,new b(e,t)))||0===t},a.isInteger=function(){return!!this.c&&mf(this.e/uf)>this.c.length-2},a.isLessThan=a.lt=function(e,t){return yf(this,new b(e,t))<0},a.isLessThanOrEqualTo=a.lte=function(e,t){return-1===(t=yf(this,new b(e,t)))||0===t},a.isNaN=function(){return!this.s},a.isNegative=function(){return this.s<0},a.isPositive=function(){return this.s>0},a.isZero=function(){return!!this.c&&0==this.c[0]},a.minus=function(e,t){var i,n,r,o,s=this,a=s.s;if(t=(e=new b(e,t)).s,!a||!t)return new b(NaN);if(a!=t)return e.s=-t,s.plus(e);var l=s.e/uf,c=e.e/uf,h=s.c,d=e.c;if(!l||!c){if(!h||!d)return h?(e.s=-t,e):new b(d?s:NaN);if(!h[0]||!d[0])return d[0]?(e.s=-t,e):new b(h[0]?s:3==u?-0:0)}if(l=mf(l),c=mf(c),h=h.slice(),a=l-c){for((o=a<0)?(a=-a,r=h):(c=l,r=d),r.reverse(),t=a;t--;r.push(0));r.reverse()}else for(n=(o=(a=h.length)<(t=d.length))?a:t,a=t=0;t<n;t++)if(h[t]!=d[t]){o=h[t]<d[t];break}if(o&&(r=h,h=d,d=r,e.s=-e.s),(t=(n=d.length)-(i=h.length))>0)for(;t--;h[i++]=0);for(t=cf-1;n>a;){if(h[--n]<d[n]){for(i=n;i&&!h[--i];h[i]=t);--h[i],h[n]+=cf}h[n]-=d[n]}for(;0==h[0];h.splice(0,1),--c);return h[0]?T(e,h,c):(e.s=3==u?-1:1,e.c=[e.e=0],e)},a.modulo=a.mod=function(e,t){var n,r,o=this;return e=new b(e,t),!o.c||!e.s||e.c&&!e.c[0]?new b(NaN):!e.c||o.c&&!o.c[0]?new b(o):(9==g?(r=e.s,e.s=1,n=i(o,e,0,3),e.s=r,n.s*=r):n=i(o,e,0,g),!(e=o.minus(n.times(e))).c[0]&&1==g&&(e.s=o.s),e)},a.multipliedBy=a.times=function(e,t){var i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,y=this,_=y.c,v=(e=new b(e,t)).c;if(!(_&&v&&_[0]&&v[0]))return!y.s||!e.s||_&&!_[0]&&!v||v&&!v[0]&&!_?e.c=e.e=e.s=null:(e.s*=y.s,_&&v?(e.c=[0],e.e=0):e.c=e.e=null),e;for(n=mf(y.e/uf)+mf(e.e/uf),e.s*=y.s,(l=_.length)<(h=v.length)&&(f=_,_=v,v=f,r=l,l=h,h=r),r=l+h,f=[];r--;f.push(0));for(m=cf,g=pf,r=h;--r>=0;){for(i=0,d=v[r]%g,p=v[r]/g|0,o=r+(s=l);o>r;)i=((c=d*(c=_[--s]%g)+(a=p*c+(u=_[s]/g|0)*d)%g*g+f[o]+i)/m|0)+(a/g|0)+p*u,f[o--]=c%m;f[o]=i}return i?++n:f.splice(0,1),T(e,f,n)},a.negated=function(){var e=new b(this);return e.s=-e.s||null,e},a.plus=function(e,t){var i,n=this,r=n.s;if(t=(e=new b(e,t)).s,!r||!t)return new b(NaN);if(r!=t)return e.s=-t,n.minus(e);var o=n.e/uf,s=e.e/uf,a=n.c,l=e.c;if(!o||!s){if(!a||!l)return new b(r/0);if(!a[0]||!l[0])return l[0]?e:new b(a[0]?n:0*r)}if(o=mf(o),s=mf(s),a=a.slice(),r=o-s){for(r>0?(s=o,i=l):(r=-r,i=a),i.reverse();r--;i.push(0));i.reverse()}for((r=a.length)-(t=l.length)<0&&(i=l,l=a,a=i,t=r),r=0;t;)r=(a[--t]=a[t]+l[t]+r)/cf|0,a[t]=cf===a[t]?0:a[t]%cf;return r&&(a=[r].concat(a),++s),T(e,a,s)},a.precision=a.sd=function(e,t){var i,n,r,o=this;if(null!=e&&e!==!!e)return _f(e,1,ff),null==t?t=u:_f(t,0,8),S(new b(o),e,t);if(!(i=o.c))return null;if(n=(r=i.length-1)*uf+1,r=i[r]){for(;r%10==0;r/=10,n--);for(r=i[0];r>=10;r/=10,n++);}return e&&o.e+1>n&&(n=o.e+1),n},a.shiftedBy=function(e){return _f(e,-9007199254740991,hf),this.times("1e"+e)},a.squareRoot=a.sqrt=function(){var e,t,n,r,o,s=this,a=s.c,l=s.s,h=s.e,d=c+4,p=new b("0.5");if(1!==l||!a||!a[0])return new b(!l||l<0&&(!a||a[0])?NaN:a?s:1/0);if(0==(l=Math.sqrt(+I(s)))||l==1/0?(((t=gf(a)).length+h)%2==0&&(t+="0"),l=Math.sqrt(+t),h=mf((h+1)/2)-(h<0||h%2),l==1/0?t="5e"+h:t=(t=l.toExponential()).slice(0,t.indexOf("e")+1)+h,n=new b(t)):n=new b(l+""),n.c[0])for((l=(h=n.e)+d)<3&&(l=0);;)if(o=n,n=p.times(o.plus(i(s,o,d,1))),gf(o.c).slice(0,l)===(t=gf(n.c)).slice(0,l)){if(n.e<h&&--l,"9999"!=(t=t.slice(l-3,l+1))&&(r||"4999"!=t)){(!+t||!+t.slice(1)&&"5"==t.charAt(0))&&(S(n,n.e+c+2,1),e=!n.times(n).eq(s));break}if(!r&&(S(o,o.e+c+2,0),o.times(o).eq(s))){n=o;break}d+=4,l+=4,r=1}return S(n,n.e+c+1,u,e)},a.toExponential=function(e,t){return null!=e&&(_f(e,0,ff),e++),w(this,e,t,1)},a.toFixed=function(e,t){return null!=e&&(_f(e,0,ff),e=e+this.e+1),w(this,e,t)},a.toFormat=function(e,t,i){var n,r=this;if(null==i)null!=e&&t&&"object"==typeof t?(i=t,t=null):e&&"object"==typeof e?(i=e,e=t=null):i=_;else if("object"!=typeof i)throw Error(af+"Argument not an object: "+i);if(n=r.toFixed(e,t),r.c){var o,s=n.split("."),a=+i.groupSize,l=+i.secondaryGroupSize,c=i.groupSeparator||"",u=s[0],h=s[1],d=r.s<0,p=d?u.slice(1):u,f=p.length;if(l&&(o=a,a=l,l=o,f-=o),a>0&&f>0){for(o=f%a||a,u=p.substr(0,o);o<f;o+=a)u+=c+p.substr(o,a);l>0&&(u+=c+p.slice(o)),d&&(u="-"+u)}n=h?u+(i.decimalSeparator||"")+((l=+i.fractionGroupSize)?h.replace(new RegExp("\\d{"+l+"}\\B","g"),"$&"+(i.fractionGroupSeparator||"")):h):u}return(i.prefix||"")+n+(i.suffix||"")},a.toFraction=function(e){var t,n,r,o,s,a,c,h,d,p,m,g,y=this,_=y.c;if(null!=e&&(!(c=new b(e)).isInteger()&&(c.c||1!==c.s)||c.lt(l)))throw Error(af+"Argument "+(c.isInteger()?"out of range: ":"not an integer: ")+I(c));if(!_)return new b(y);for(t=new b(l),d=n=new b(l),r=h=new b(l),g=gf(_),s=t.e=g.length-y.e-1,t.c[0]=df[(a=s%uf)<0?uf+a:a],e=!e||c.comparedTo(t)>0?s>0?t:d:c,a=f,f=1/0,c=new b(g),h.c[0]=0;p=i(c,t,0,1),1!=(o=n.plus(p.times(r))).comparedTo(e);)n=r,r=o,d=h.plus(p.times(o=d)),h=o,t=c.minus(p.times(o=t)),c=o;return o=i(e.minus(n),r,0,1),h=h.plus(o.times(d)),n=n.plus(o.times(r)),h.s=d.s=y.s,m=i(d,r,s*=2,u).minus(y).abs().comparedTo(i(h,n,s,u).minus(y).abs())<1?[d,r]:[h,n],f=a,m},a.toNumber=function(){return+I(this)},a.toPrecision=function(e,t){return null!=e&&_f(e,1,ff),w(this,e,t,2)},a.toString=function(e){var t,i=this,r=i.s,o=i.e;return null===o?r?(t="Infinity",r<0&&(t="-"+t)):t="NaN":(null==e?t=o<=h||o>=d?xf(gf(i.c),o):bf(gf(i.c),o,"0"):10===e&&x?t=bf(gf((i=S(new b(i),c+o+1,u)).c),i.e,"0"):(_f(e,2,v.length,"Base"),t=n(bf(gf(i.c),o,"0"),10,e,r,!0)),r<0&&i.c[0]&&(t="-"+t)),t},a.valueOf=a.toJSON=function(){return I(this)},a._isBigNumber=!0,a[Symbol.toStringTag]="BigNumber",a[Symbol.for("nodejs.util.inspect.custom")]=a.valueOf,null!=t&&b.set(t),b}(),Sf=class{constructor(e){X(this,"key"),X(this,"left",null),X(this,"right",null),this.key=e}},If=class extends Sf{constructor(e){super(e)}},kf=class{constructor(){X(this,"size",0),X(this,"modificationCount",0),X(this,"splayCount",0)}splay(e){const t=this.root;if(null==t)return this.compare(e,e),-1;let i=null,n=null,r=null,o=null,s=t;const a=this.compare;let l;for(;;)if(l=a(s.key,e),l>0){let t=s.left;if(null==t||(l=a(t.key,e),l>0&&(s.left=t.right,t.right=s,s=t,t=s.left,null==t)))break;null==i?n=s:i.left=s,i=s,s=t}else{if(!(l<0))break;{let t=s.right;if(null==t||(l=a(t.key,e),l<0&&(s.right=t.left,t.left=s,s=t,t=s.right,null==t)))break;null==r?o=s:r.right=s,r=s,s=t}}return null!=r&&(r.right=s.left,s.left=o),null!=i&&(i.left=s.right,s.right=n),this.root!==s&&(this.root=s,this.splayCount++),l}splayMin(e){let t=e,i=t.left;for(;null!=i;){const e=i;t.left=e.right,e.right=t,t=e,i=t.left}return t}splayMax(e){let t=e,i=t.right;for(;null!=i;){const e=i;t.right=e.left,e.left=t,t=e,i=t.right}return t}_delete(e){if(null==this.root||0!=this.splay(e))return null;let t=this.root;const i=t,n=t.left;if(this.size--,null==n)this.root=t.right;else{const e=t.right;t=this.splayMax(n),t.right=e,this.root=t}return this.modificationCount++,i}addNewRoot(e,t){this.size++,this.modificationCount++;const i=this.root;null!=i?(t<0?(e.left=i,e.right=i.right,i.right=null):(e.right=i,e.left=i.left,i.left=null),this.root=e):this.root=e}_first(){const e=this.root;return null==e?null:(this.root=this.splayMin(e),this.root)}_last(){const e=this.root;return null==e?null:(this.root=this.splayMax(e),this.root)}clear(){this.root=null,this.size=0,this.modificationCount++}has(e){return this.validKey(e)&&0==this.splay(e)}defaultCompare(){return(e,t)=>e<t?-1:e>t?1:0}wrap(){return{getRoot:()=>this.root,setRoot:e=>{this.root=e},getSize:()=>this.size,getModificationCount:()=>this.modificationCount,getSplayCount:()=>this.splayCount,setSplayCount:e=>{this.splayCount=e},splay:e=>this.splay(e),has:e=>this.has(e)}}},Mf=class e extends kf{constructor(e,t){super(),X(this,"root",null),X(this,"compare"),X(this,"validKey"),X(this,wf,"[object Set]"),this.compare=e??this.defaultCompare(),this.validKey=t??(e=>null!=e&&null!=e)}delete(e){return!!this.validKey(e)&&null!=this._delete(e)}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){const t=this[Symbol.iterator]();let i;for(;i=t.next(),!i.done;)e(i.value,i.value,this)}add(e){const t=this.splay(e);return 0!=t&&this.addNewRoot(new If(e),t),this}addAndReturn(e){const t=this.splay(e);return 0!=t&&this.addNewRoot(new If(e),t),this.root.key}addAll(e){for(const t of e)this.add(t)}isEmpty(){return null==this.root}isNotEmpty(){return null!=this.root}single(){if(0==this.size)throw"Bad state: No element";if(this.size>1)throw"Bad state: Too many element";return this.root.key}first(){if(0==this.size)throw"Bad state: No element";return this._first().key}last(){if(0==this.size)throw"Bad state: No element";return this._last().key}lastBefore(e){if(null==e)throw"Invalid arguments(s)";if(null==this.root)return null;if(this.splay(e)<0)return this.root.key;let t=this.root.left;if(null==t)return null;let i=t.right;for(;null!=i;)t=i,i=t.right;return t.key}firstAfter(e){if(null==e)throw"Invalid arguments(s)";if(null==this.root)return null;if(this.splay(e)>0)return this.root.key;let t=this.root.right;if(null==t)return null;let i=t.left;for(;null!=i;)t=i,i=t.left;return t.key}retainAll(t){const i=new e(this.compare,this.validKey),n=this.modificationCount;for(const e of t){if(n!=this.modificationCount)throw"Concurrent modification during iteration.";this.validKey(e)&&0==this.splay(e)&&i.add(this.root.key)}i.size!=this.size&&(this.root=i.root,this.size=i.size,this.modificationCount++)}lookup(e){return this.validKey(e)&&0==this.splay(e)?this.root.key:null}intersection(t){const i=new e(this.compare,this.validKey);for(const e of this)t.has(e)&&i.add(e);return i}difference(t){const i=new e(this.compare,this.validKey);for(const e of this)t.has(e)||i.add(e);return i}union(e){const t=this.clone();return t.addAll(e),t}clone(){const t=new e(this.compare,this.validKey);return t.size=this.size,t.root=this.copyNode(this.root),t}copyNode(e){if(null==e)return null;const t=new If(e.key);return function e(t,i){let n,r;do{if(n=t.left,r=t.right,null!=n){const t=new If(n.key);i.left=t,e(n,t)}if(null!=r){const e=new If(r.key);i.right=e,t=r,i=e}}while(null!=r)}(e,t),t}toSet(){return this.clone()}entries(){return new Af(this.wrap())}keys(){return this[Symbol.iterator]()}values(){return this[Symbol.iterator]()}[(Ef=Symbol.iterator,wf=Symbol.toStringTag,Ef)](){return new Pf(this.wrap())}},Cf=class{constructor(e){X(this,"tree"),X(this,"path",new Array),X(this,"modificationCount",null),X(this,"splayCount"),this.tree=e,this.splayCount=e.getSplayCount()}[Symbol.iterator](){return this}next(){return this.moveNext()?{done:!1,value:this.current()}:{done:!0,value:null}}current(){if(!this.path.length)return null;const e=this.path[this.path.length-1];return this.getValue(e)}rebuildPath(e){this.path.splice(0,this.path.length),this.tree.splay(e),this.path.push(this.tree.getRoot()),this.splayCount=this.tree.getSplayCount()}findLeftMostDescendent(e){for(;null!=e;)this.path.push(e),e=e.left}moveNext(){if(this.modificationCount!=this.tree.getModificationCount()){if(null==this.modificationCount){this.modificationCount=this.tree.getModificationCount();let e=this.tree.getRoot();for(;null!=e;)this.path.push(e),e=e.left;return this.path.length>0}throw"Concurrent modification during iteration."}if(!this.path.length)return!1;this.splayCount!=this.tree.getSplayCount()&&this.rebuildPath(this.path[this.path.length-1].key);let e=this.path[this.path.length-1],t=e.right;if(null!=t){for(;null!=t;)this.path.push(t),t=t.left;return!0}for(this.path.pop();this.path.length&&this.path[this.path.length-1].right===e;)e=this.path.pop();return this.path.length>0}},Pf=class extends Cf{getValue(e){return e.key}},Af=class extends Cf{getValue(e){return[e.key,e.key]}},Lf=e=>()=>e,Df=e=>{const t=e?(t,i)=>i.minus(t).abs().isLessThanOrEqualTo(e):Lf(!1);return(e,i)=>t(e,i)?0:e.comparedTo(i)};function Rf(e){const t=e?(t,i,n,r,o)=>t.exponentiatedBy(2).isLessThanOrEqualTo(r.minus(i).exponentiatedBy(2).plus(o.minus(n).exponentiatedBy(2)).times(e)):Lf(!1);return(e,i,n)=>{const r=e.x,o=e.y,s=n.x,a=n.y,l=o.minus(a).times(i.x.minus(s)).minus(r.minus(s).times(i.y.minus(a)));return t(l,r,o,s,a)?0:l.comparedTo(0)}}var zf=e=>e,Ff=e=>{if(e){const t=new Mf(Df(e)),i=new Mf(Df(e)),n=(e,t)=>t.addAndReturn(e),r=e=>({x:n(e.x,t),y:n(e.y,i)});return r({x:new Tf(0),y:new Tf(0)}),r}return zf},Of=e=>({set:e=>{Nf=Of(e)},reset:()=>Of(e),compare:Df(e),snap:Ff(e),orient:Rf(e)}),Nf=Of(),Bf=(e,t)=>e.ll.x.isLessThanOrEqualTo(t.x)&&t.x.isLessThanOrEqualTo(e.ur.x)&&e.ll.y.isLessThanOrEqualTo(t.y)&&t.y.isLessThanOrEqualTo(e.ur.y),Gf=(e,t)=>{if(t.ur.x.isLessThan(e.ll.x)||e.ur.x.isLessThan(t.ll.x)||t.ur.y.isLessThan(e.ll.y)||e.ur.y.isLessThan(t.ll.y))return null;const i=e.ll.x.isLessThan(t.ll.x)?t.ll.x:e.ll.x,n=e.ur.x.isLessThan(t.ur.x)?e.ur.x:t.ur.x;return{ll:{x:i,y:e.ll.y.isLessThan(t.ll.y)?t.ll.y:e.ll.y},ur:{x:n,y:e.ur.y.isLessThan(t.ur.y)?e.ur.y:t.ur.y}}},jf=(e,t)=>e.x.times(t.y).minus(e.y.times(t.x)),Vf=(e,t)=>e.x.times(t.x).plus(e.y.times(t.y)),Uf=e=>Vf(e,e).sqrt(),qf=(e,t,i)=>{const n={x:t.x.minus(e.x),y:t.y.minus(e.y)},r={x:i.x.minus(e.x),y:i.y.minus(e.y)};return jf(r,n).div(Uf(r)).div(Uf(n))},Zf=(e,t,i)=>{const n={x:t.x.minus(e.x),y:t.y.minus(e.y)},r={x:i.x.minus(e.x),y:i.y.minus(e.y)};return Vf(r,n).div(Uf(r)).div(Uf(n))},$f=(e,t,i)=>t.y.isZero()?null:{x:e.x.plus(t.x.div(t.y).times(i.minus(e.y))),y:i},Hf=(e,t,i)=>t.x.isZero()?null:{x:i,y:e.y.plus(t.y.div(t.x).times(i.minus(e.x)))},Wf=class e{constructor(e,t){X(this,"point"),X(this,"isLeft"),X(this,"segment"),X(this,"otherSE"),X(this,"consumedBy"),void 0===e.events?e.events=[this]:e.events.push(this),this.point=e,this.isLeft=t}static compare(t,i){const n=e.comparePoints(t.point,i.point);return 0!==n?n:(t.point!==i.point&&t.link(i),t.isLeft!==i.isLeft?t.isLeft?1:-1:im.compare(t.segment,i.segment))}static comparePoints(e,t){return e.x.isLessThan(t.x)?-1:e.x.isGreaterThan(t.x)?1:e.y.isLessThan(t.y)?-1:e.y.isGreaterThan(t.y)?1:0}link(e){if(e.point===this.point)throw new Error("Tried to link already linked events");const t=e.point.events;for(let e=0,i=t.length;e<i;e++){const i=t[e];this.point.events.push(i),i.point=this.point}this.checkForConsuming()}checkForConsuming(){const e=this.point.events.length;for(let t=0;t<e;t++){const i=this.point.events[t];if(void 0===i.segment.consumedBy)for(let n=t+1;n<e;n++){const e=this.point.events[n];void 0===e.consumedBy&&i.otherSE.point.events===e.otherSE.point.events&&i.segment.consume(e.segment)}}}getAvailableLinkedEvents(){const e=[];for(let t=0,i=this.point.events.length;t<i;t++){const i=this.point.events[t];i!==this&&!i.segment.ringOut&&i.segment.isInResult()&&e.push(i)}return e}getLeftmostComparator(e){const t=new Map,i=i=>{const n=i.otherSE;t.set(i,{sine:qf(this.point,e.point,n.point),cosine:Zf(this.point,e.point,n.point)})};return(e,n)=>{t.has(e)||i(e),t.has(n)||i(n);const{sine:r,cosine:o}=t.get(e),{sine:s,cosine:a}=t.get(n);return r.isGreaterThanOrEqualTo(0)&&s.isGreaterThanOrEqualTo(0)?o.isLessThan(a)?1:o.isGreaterThan(a)?-1:0:r.isLessThan(0)&&s.isLessThan(0)?o.isLessThan(a)?-1:o.isGreaterThan(a)?1:0:s.isLessThan(r)?-1:s.isGreaterThan(r)?1:0}}},Xf=class e{constructor(e){X(this,"events"),X(this,"poly"),X(this,"_isExteriorRing"),X(this,"_enclosingRing"),this.events=e;for(let t=0,i=e.length;t<i;t++)e[t].segment.ringOut=this;this.poly=null}static factory(t){const i=[];for(let n=0,r=t.length;n<r;n++){const r=t[n];if(!r.isInResult()||r.ringOut)continue;let o=null,s=r.leftSE,a=r.rightSE;const l=[s],c=s.point,u=[];for(;o=s,s=a,l.push(s),s.point!==c;)for(;;){const t=s.getAvailableLinkedEvents();if(0===t.length){const e=l[0].point,t=l[l.length-1].point;throw new Error(`Unable to complete output ring starting at [${e.x}, ${e.y}]. Last matching segment found ends at [${t.x}, ${t.y}].`)}if(1===t.length){a=t[0].otherSE;break}let n=null;for(let e=0,t=u.length;e<t;e++)if(u[e].point===s.point){n=e;break}if(null!==n){const t=u.splice(n)[0],r=l.splice(t.index);r.unshift(r[0].otherSE),i.push(new e(r.reverse()));continue}u.push({index:l.length,point:s.point});const r=s.getLeftmostComparator(o);a=t.sort(r)[0].otherSE;break}i.push(new e(l))}return i}getGeom(){let e=this.events[0].point;const t=[e];for(let i=1,n=this.events.length-1;i<n;i++){const n=this.events[i].point,r=this.events[i+1].point;0!==Nf.orient(n,e,r)&&(t.push(n),e=n)}if(1===t.length)return null;const i=t[0],n=t[1];0===Nf.orient(i,e,n)&&t.shift(),t.push(t[0]);const r=this.isExteriorRing()?1:-1,o=this.isExteriorRing()?0:t.length-1,s=this.isExteriorRing()?t.length:-1,a=[];for(let e=o;e!=s;e+=r)a.push([t[e].x.toNumber(),t[e].y.toNumber()]);return a}isExteriorRing(){if(void 0===this._isExteriorRing){const e=this.enclosingRing();this._isExteriorRing=!e||!e.isExteriorRing()}return this._isExteriorRing}enclosingRing(){return void 0===this._enclosingRing&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}_calcEnclosingRing(){var e,t;let i=this.events[0];for(let e=1,t=this.events.length;e<t;e++){const t=this.events[e];Wf.compare(i,t)>0&&(i=t)}let n=i.segment.prevInResult(),r=n?n.prevInResult():null;for(;;){if(!n)return null;if(!r)return n.ringOut;if(r.ringOut!==n.ringOut)return(null==(e=r.ringOut)?void 0:e.enclosingRing())!==n.ringOut?n.ringOut:null==(t=n.ringOut)?void 0:t.enclosingRing();n=r.prevInResult(),r=n?n.prevInResult():null}}},Yf=class{constructor(e){X(this,"exteriorRing"),X(this,"interiorRings"),this.exteriorRing=e,e.poly=this,this.interiorRings=[]}addInterior(e){this.interiorRings.push(e),e.poly=this}getGeom(){const e=this.exteriorRing.getGeom();if(null===e)return null;const t=[e];for(let e=0,i=this.interiorRings.length;e<i;e++){const i=this.interiorRings[e].getGeom();null!==i&&t.push(i)}return t}},Jf=class{constructor(e){X(this,"rings"),X(this,"polys"),this.rings=e,this.polys=this._composePolys(e)}getGeom(){const e=[];for(let t=0,i=this.polys.length;t<i;t++){const i=this.polys[t].getGeom();null!==i&&e.push(i)}return e}_composePolys(e){var t;const i=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];if(!r.poly)if(r.isExteriorRing())i.push(new Yf(r));else{const e=r.enclosingRing();null!=e&&e.poly||i.push(new Yf(e)),null==(t=null==e?void 0:e.poly)||t.addInterior(r)}}return i}},Kf=class{constructor(e,t=im.compare){X(this,"queue"),X(this,"tree"),X(this,"segments"),this.queue=e,this.tree=new Mf(t),this.segments=[]}process(e){const t=e.segment,i=[];if(e.consumedBy)return e.isLeft?this.queue.delete(e.otherSE):this.tree.delete(t),i;e.isLeft&&this.tree.add(t);let n=t,r=t;do{n=this.tree.lastBefore(n)}while(null!=n&&null!=n.consumedBy);do{r=this.tree.firstAfter(r)}while(null!=r&&null!=r.consumedBy);if(e.isLeft){let o=null;if(n){const e=n.getIntersection(t);if(null!==e&&(t.isAnEndpoint(e)||(o=e),!n.isAnEndpoint(e))){const t=this._splitSafely(n,e);for(let e=0,n=t.length;e<n;e++)i.push(t[e])}}let s=null;if(r){const e=r.getIntersection(t);if(null!==e&&(t.isAnEndpoint(e)||(s=e),!r.isAnEndpoint(e))){const t=this._splitSafely(r,e);for(let e=0,n=t.length;e<n;e++)i.push(t[e])}}if(null!==o||null!==s){let e=null;e=null===o?s:null===s||Wf.comparePoints(o,s)<=0?o:s,this.queue.delete(t.rightSE),i.push(t.rightSE);const n=t.split(e);for(let e=0,t=n.length;e<t;e++)i.push(n[e])}i.length>0?(this.tree.delete(t),i.push(e)):(this.segments.push(t),t.prev=n)}else{if(n&&r){const e=n.getIntersection(r);if(null!==e){if(!n.isAnEndpoint(e)){const t=this._splitSafely(n,e);for(let e=0,n=t.length;e<n;e++)i.push(t[e])}if(!r.isAnEndpoint(e)){const t=this._splitSafely(r,e);for(let e=0,n=t.length;e<n;e++)i.push(t[e])}}}this.tree.delete(t)}return i}_splitSafely(e,t){this.tree.delete(e);const i=e.rightSE;this.queue.delete(i);const n=e.split(t);return n.push(i),void 0===e.consumedBy&&this.tree.add(e),n}},Qf=new class{constructor(){X(this,"type"),X(this,"numMultiPolys")}run(e,t,i){Qf.type=e;const n=[new om(t,!0)];for(let e=0,t=i.length;e<t;e++)n.push(new om(i[e],!1));if(Qf.numMultiPolys=n.length,"difference"===Qf.type){const e=n[0];let t=1;for(;t<n.length;)null!==Gf(n[t].bbox,e.bbox)?t++:n.splice(t,1)}if("intersection"===Qf.type)for(let e=0,t=n.length;e<t;e++){const t=n[e];for(let i=e+1,r=n.length;i<r;i++)if(null===Gf(t.bbox,n[i].bbox))return[]}const r=new Mf(Wf.compare);for(let e=0,t=n.length;e<t;e++){const t=n[e].getSweepEvents();for(let e=0,i=t.length;e<i;e++)r.add(t[e])}const o=new Kf(r);let s=null;for(0!=r.size&&(s=r.first(),r.delete(s));s;){const e=o.process(s);for(let t=0,i=e.length;t<i;t++){const i=e[t];void 0===i.consumedBy&&r.add(i)}0!=r.size?(s=r.first(),r.delete(s)):s=null}Nf.reset();const a=Xf.factory(o.segments);return new Jf(a).getGeom()}},em=Qf,tm=0,im=class e{constructor(e,t,i,n){X(this,"id"),X(this,"leftSE"),X(this,"rightSE"),X(this,"rings"),X(this,"windings"),X(this,"ringOut"),X(this,"consumedBy"),X(this,"prev"),X(this,"_prevInResult"),X(this,"_beforeState"),X(this,"_afterState"),X(this,"_isInResult"),this.id=++tm,this.leftSE=e,e.segment=this,e.otherSE=t,this.rightSE=t,t.segment=this,t.otherSE=e,this.rings=i,this.windings=n}static compare(e,t){const i=e.leftSE.point.x,n=t.leftSE.point.x,r=e.rightSE.point.x,o=t.rightSE.point.x;if(o.isLessThan(i))return 1;if(r.isLessThan(n))return-1;const s=e.leftSE.point.y,a=t.leftSE.point.y,l=e.rightSE.point.y,c=t.rightSE.point.y;if(i.isLessThan(n)){if(a.isLessThan(s)&&a.isLessThan(l))return 1;if(a.isGreaterThan(s)&&a.isGreaterThan(l))return-1;const i=e.comparePoint(t.leftSE.point);if(i<0)return 1;if(i>0)return-1;const n=t.comparePoint(e.rightSE.point);return 0!==n?n:-1}if(i.isGreaterThan(n)){if(s.isLessThan(a)&&s.isLessThan(c))return-1;if(s.isGreaterThan(a)&&s.isGreaterThan(c))return 1;const i=t.comparePoint(e.leftSE.point);if(0!==i)return i;const n=e.comparePoint(t.rightSE.point);return n<0?1:n>0?-1:1}if(s.isLessThan(a))return-1;if(s.isGreaterThan(a))return 1;if(r.isLessThan(o)){const i=t.comparePoint(e.rightSE.point);if(0!==i)return i}if(r.isGreaterThan(o)){const i=e.comparePoint(t.rightSE.point);if(i<0)return 1;if(i>0)return-1}if(!r.eq(o)){const e=l.minus(s),t=r.minus(i),u=c.minus(a),h=o.minus(n);if(e.isGreaterThan(t)&&u.isLessThan(h))return 1;if(e.isLessThan(t)&&u.isGreaterThan(h))return-1}return r.isGreaterThan(o)?1:r.isLessThan(o)||l.isLessThan(c)?-1:l.isGreaterThan(c)?1:e.id<t.id?-1:e.id>t.id?1:0}static fromRing(t,i,n){let r,o,s;const a=Wf.comparePoints(t,i);if(a<0)r=t,o=i,s=1;else{if(!(a>0))throw new Error(`Tried to create degenerate segment at [${t.x}, ${t.y}]`);r=i,o=t,s=-1}const l=new Wf(r,!0),c=new Wf(o,!1);return new e(l,c,[n],[s])}replaceRightSE(e){this.rightSE=e,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){const e=this.leftSE.point.y,t=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:e.isLessThan(t)?e:t},ur:{x:this.rightSE.point.x,y:e.isGreaterThan(t)?e:t}}}vector(){return{x:this.rightSE.point.x.minus(this.leftSE.point.x),y:this.rightSE.point.y.minus(this.leftSE.point.y)}}isAnEndpoint(e){return e.x.eq(this.leftSE.point.x)&&e.y.eq(this.leftSE.point.y)||e.x.eq(this.rightSE.point.x)&&e.y.eq(this.rightSE.point.y)}comparePoint(e){return Nf.orient(this.leftSE.point,e,this.rightSE.point)}getIntersection(e){const t=this.bbox(),i=e.bbox(),n=Gf(t,i);if(null===n)return null;const r=this.leftSE.point,o=this.rightSE.point,s=e.leftSE.point,a=e.rightSE.point,l=Bf(t,s)&&0===this.comparePoint(s),c=Bf(i,r)&&0===e.comparePoint(r),u=Bf(t,a)&&0===this.comparePoint(a),h=Bf(i,o)&&0===e.comparePoint(o);if(c&&l)return h&&!u?o:!h&&u?a:null;if(c)return u&&r.x.eq(a.x)&&r.y.eq(a.y)?null:r;if(l)return h&&o.x.eq(s.x)&&o.y.eq(s.y)?null:s;if(h&&u)return null;if(h)return o;if(u)return a;const d=((e,t,i,n)=>{if(t.x.isZero())return Hf(i,n,e.x);if(n.x.isZero())return Hf(e,t,i.x);if(t.y.isZero())return $f(i,n,e.y);if(n.y.isZero())return $f(e,t,i.y);const r=jf(t,n);if(r.isZero())return null;const o={x:i.x.minus(e.x),y:i.y.minus(e.y)},s=jf(o,t).div(r),a=jf(o,n).div(r),l=e.x.plus(a.times(t.x)),c=i.x.plus(s.times(n.x)),u=e.y.plus(a.times(t.y)),h=i.y.plus(s.times(n.y));return{x:l.plus(c).div(2),y:u.plus(h).div(2)}})(r,this.vector(),s,e.vector());return null!==d&&Bf(n,d)?Nf.snap(d):null}split(t){const i=[],n=void 0!==t.events,r=new Wf(t,!0),o=new Wf(t,!1),s=this.rightSE;this.replaceRightSE(o),i.push(o),i.push(r);const a=new e(r,s,this.rings.slice(),this.windings.slice());return Wf.comparePoints(a.leftSE.point,a.rightSE.point)>0&&a.swapEvents(),Wf.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),n&&(r.checkForConsuming(),o.checkForConsuming()),i}swapEvents(){const e=this.rightSE;this.rightSE=this.leftSE,this.leftSE=e,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let e=0,t=this.windings.length;e<t;e++)this.windings[e]*=-1}consume(t){let i=this,n=t;for(;i.consumedBy;)i=i.consumedBy;for(;n.consumedBy;)n=n.consumedBy;const r=e.compare(i,n);if(0!==r){if(r>0){const e=i;i=n,n=e}if(i.prev===n){const e=i;i=n,n=e}for(let e=0,t=n.rings.length;e<t;e++){const t=n.rings[e],r=n.windings[e],o=i.rings.indexOf(t);-1===o?(i.rings.push(t),i.windings.push(r)):i.windings[o]+=r}n.rings=null,n.windings=null,n.consumedBy=i,n.leftSE.consumedBy=i.leftSE,n.rightSE.consumedBy=i.rightSE}}prevInResult(){return void 0!==this._prevInResult||(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null),this._prevInResult}beforeState(){if(void 0!==this._beforeState)return this._beforeState;if(this.prev){const e=this.prev.consumedBy||this.prev;this._beforeState=e.afterState()}else this._beforeState={rings:[],windings:[],multiPolys:[]};return this._beforeState}afterState(){if(void 0!==this._afterState)return this._afterState;const e=this.beforeState();this._afterState={rings:e.rings.slice(0),windings:e.windings.slice(0),multiPolys:[]};const t=this._afterState.rings,i=this._afterState.windings,n=this._afterState.multiPolys;for(let e=0,n=this.rings.length;e<n;e++){const n=this.rings[e],r=this.windings[e],o=t.indexOf(n);-1===o?(t.push(n),i.push(r)):i[o]+=r}const r=[],o=[];for(let e=0,n=t.length;e<n;e++){if(0===i[e])continue;const n=t[e],s=n.poly;if(-1===o.indexOf(s))if(n.isExterior)r.push(s);else{-1===o.indexOf(s)&&o.push(s);const e=r.indexOf(n.poly);-1!==e&&r.splice(e,1)}}for(let e=0,t=r.length;e<t;e++){const t=r[e].multiPoly;-1===n.indexOf(t)&&n.push(t)}return this._afterState}isInResult(){if(this.consumedBy)return!1;if(void 0!==this._isInResult)return this._isInResult;const e=this.beforeState().multiPolys,t=this.afterState().multiPolys;switch(em.type){case"union":{const i=0===e.length,n=0===t.length;this._isInResult=i!==n;break}case"intersection":{let i,n;e.length<t.length?(i=e.length,n=t.length):(i=t.length,n=e.length),this._isInResult=n===em.numMultiPolys&&i<n;break}case"xor":{const i=Math.abs(e.length-t.length);this._isInResult=i%2==1;break}case"difference":{const i=e=>1===e.length&&e[0].isSubject;this._isInResult=i(e)!==i(t);break}}return this._isInResult}},nm=class{constructor(e,t,i){if(X(this,"poly"),X(this,"isExterior"),X(this,"segments"),X(this,"bbox"),!Array.isArray(e)||0===e.length)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=t,this.isExterior=i,this.segments=[],"number"!=typeof e[0][0]||"number"!=typeof e[0][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const n=Nf.snap({x:new Tf(e[0][0]),y:new Tf(e[0][1])});this.bbox={ll:{x:n.x,y:n.y},ur:{x:n.x,y:n.y}};let r=n;for(let t=1,i=e.length;t<i;t++){if("number"!=typeof e[t][0]||"number"!=typeof e[t][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const i=Nf.snap({x:new Tf(e[t][0]),y:new Tf(e[t][1])});i.x.eq(r.x)&&i.y.eq(r.y)||(this.segments.push(im.fromRing(r,i,this)),i.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=i.x),i.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=i.y),i.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=i.x),i.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=i.y),r=i)}(!n.x.eq(r.x)||!n.y.eq(r.y))&&this.segments.push(im.fromRing(r,n,this))}getSweepEvents(){const e=[];for(let t=0,i=this.segments.length;t<i;t++){const i=this.segments[t];e.push(i.leftSE),e.push(i.rightSE)}return e}},rm=class{constructor(e,t){if(X(this,"multiPoly"),X(this,"exteriorRing"),X(this,"interiorRings"),X(this,"bbox"),!Array.isArray(e))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new nm(e[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(let t=1,i=e.length;t<i;t++){const i=new nm(e[t],this,!1);i.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=i.bbox.ll.x),i.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=i.bbox.ll.y),i.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=i.bbox.ur.x),i.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=i.bbox.ur.y),this.interiorRings.push(i)}this.multiPoly=t}getSweepEvents(){const e=this.exteriorRing.getSweepEvents();for(let t=0,i=this.interiorRings.length;t<i;t++){const i=this.interiorRings[t].getSweepEvents();for(let t=0,n=i.length;t<n;t++)e.push(i[t])}return e}},om=class{constructor(e,t){if(X(this,"isSubject"),X(this,"polys"),X(this,"bbox"),!Array.isArray(e))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{"number"==typeof e[0][0][0]&&(e=[e])}catch{}this.polys=[],this.bbox={ll:{x:new Tf(Number.POSITIVE_INFINITY),y:new Tf(Number.POSITIVE_INFINITY)},ur:{x:new Tf(Number.NEGATIVE_INFINITY),y:new Tf(Number.NEGATIVE_INFINITY)}};for(let t=0,i=e.length;t<i;t++){const i=new rm(e[t],this);i.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=i.bbox.ll.x),i.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=i.bbox.ll.y),i.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=i.bbox.ur.x),i.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=i.bbox.ur.y),this.polys.push(i)}this.isSubject=t}getSweepEvents(){const e=[];for(let t=0,i=this.polys.length;t<i;t++){const i=this.polys[t].getSweepEvents();for(let t=0,n=i.length;t<n;t++)e.push(i[t])}return e}};var sm=function(e){const t=[];if(Pe(e,e=>{t.push(e.coordinates)}),t.length<2)throw new Error("Must have at least two features");const i=e.features[0].properties||{},n=((e,...t)=>em.run("difference",e,t))(t[0],...t.slice(1));return 0===n.length?null:1===n.length?ye(n[0],i):xe(n,i)};function am(e){var t=new xp(e);return t.insert=function(e){if("Feature"!==e.type)throw new Error("invalid feature");return e.bbox=e.bbox?e.bbox:Le(e),xp.prototype.insert.call(this,e)},t.load=function(e){var t=[];return Array.isArray(e)?e.forEach(function(e){if("Feature"!==e.type)throw new Error("invalid features");e.bbox=e.bbox?e.bbox:Le(e),t.push(e)}):Ce(e,function(e){if("Feature"!==e.type)throw new Error("invalid features");e.bbox=e.bbox?e.bbox:Le(e),t.push(e)}),xp.prototype.load.call(this,t)},t.remove=function(e,t){if("Feature"!==e.type)throw new Error("invalid feature");return e.bbox=e.bbox?e.bbox:Le(e),xp.prototype.remove.call(this,e,t)},t.clear=function(){return xp.prototype.clear.call(this)},t.search=function(e){return ve(xp.prototype.search.call(this,this.toBBox(e)))},t.collides=function(e){return xp.prototype.collides.call(this,this.toBBox(e))},t.all=function(){return ve(xp.prototype.all.call(this))},t.toJSON=function(){return xp.prototype.toJSON.call(this)},t.fromJSON=function(e){return xp.prototype.fromJSON.call(this,e)},t.toBBox=function(e){var t;if(e.bbox)t=e.bbox;else if(Array.isArray(e)&&4===e.length)t=e;else if(Array.isArray(e)&&6===e.length)t=[e[0],e[1],e[3],e[4]];else if("Feature"===e.type)t=Le(e);else{if("FeatureCollection"!==e.type)throw new Error("invalid geojson");t=Le(e)}return{minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]}},t}function lm(e,t){if(!ke(t=t??{}))throw new Error("options is invalid");var i=t.precision,n=t.coordinates,r=t.mutate;if(i=null==i||isNaN(i)?6:i,n=null==n||isNaN(n)?3:n,!e)throw new Error("<geojson> is required");if("number"!=typeof i)throw new Error("<precision> must be a number");if("number"!=typeof n)throw new Error("<coordinates> must be a number");(!1===r||void 0===r)&&(e=JSON.parse(JSON.stringify(e)));var o=Math.pow(10,i);return Me(e,function(e){!function(e,t,i){e.length>i&&e.splice(i,e.length);for(var n=0;n<e.length;n++)e[n]=Math.round(e[n]*t)/t}(e,o,n)}),e}function cm(e){if(!e)throw new Error("geojson is required");const t=[];return Ae(e,e=>{!function(e,t){let i=[];const n=e.geometry;if(null!==n){switch(n.type){case"Polygon":i=ze(n);break;case"LineString":i=[ze(n)]}i.forEach(i=>{(function(e,t){const i=[];return e.reduce((e,n)=>{const r=_e([e,n],t);return r.bbox=function(e,t){const i=e[0],n=e[1],r=t[0],o=t[1],s=i<r?i:r,a=n<o?n:o,l=i>r?i:r,c=n>o?n:o;return[s,a,l,c]}(e,n),i.push(r),n}),i})(i,e.properties).forEach(e=>{e.id=t.length,t.push(e)})})}}(e,t)}),ve(t)}var um=Object.defineProperty,hm=Object.defineProperties,dm=Object.getOwnPropertyDescriptors,pm=Object.getOwnPropertySymbols,fm=Object.prototype.hasOwnProperty,mm=Object.prototype.propertyIsEnumerable,gm=(e,t,i)=>t in e?um(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,ym=(e,t)=>{for(var i in t||(t={}))fm.call(t,i)&&gm(e,i,t[i]);if(pm)for(var i of pm(t))mm.call(t,i)&&gm(e,i,t[i]);return e},_m=(e,t)=>hm(e,dm(t));function vm(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2))}function xm(e,t){const i=function(e,t){const[i,n,r]=e,[o,s,a]=t;return i*o+n*s+r*a}(e,t)/(vm(e)*vm(t));return Math.acos(Math.min(Math.max(i,-1),1))}function bm(e){const t=Te(e[1]),i=Te(e[0]);return[Math.cos(t)*Math.cos(i),Math.cos(t)*Math.sin(i),Math.sin(t)]}function wm(e){const[t,i,n]=e,r=Ee(Math.asin(n));return[Ee(Math.atan2(i,t)),r]}function Em(e,t,i){const n=bm(e),r=bm(t),o=bm(i),[s,a,l]=o,[c,u,h]=function(e,t){const[i,n,r]=e,[o,s,a]=t;return[n*a-r*s,r*o-i*a,i*s-n*o]}(n,r),d=u*l-h*a,p=h*s-c*l,f=c*a-u*s,m=f*u-p*h,g=d*h-f*c,y=p*c-d*u,_=1/Math.sqrt(Math.pow(m,2)+Math.pow(g,2)+Math.pow(y,2)),v=[m*_,g*_,y*_],x=[-1*m*_,-1*g*_,-1*y*_],b=xm(n,r),w=xm(n,v),E=xm(r,v),T=xm(n,x),S=xm(r,x);let I;return I=w<T&&w<S||E<T&&E<S?v:x,xm(n,I)>b||xm(r,I)>b?Ge(wm(I),wm(n))<=Ge(wm(I),wm(r))?[wm(n),!0,!1]:[wm(r),!1,!0]:[wm(I),!1,!1]}function Tm(e,t){var i=[],n=am();return Ae(t,function(t){if(i.forEach(function(e,t){e.id=t}),i.length){var r=n.search(t);if(r.features.length){var o=Im(t,r);i=i.filter(function(e){return e.id!==o.id}),n.remove(o),Ce(Sm(o,t),function(e){i.push(e),n.insert(e)})}}else(i=Sm(e,t).features).forEach(function(e){e.bbox||(e.bbox=function(e){var t=e[0],i=e[1],n=e[2],r=e[3];if(Ge(e.slice(0,2),[n,i])>=Ge(e.slice(0,2),[t,r])){var o=(i+r)/2;return[t,o-(n-t)/2,n,o+(n-t)/2]}var s=(t+n)/2;return[s-(r-i)/2,i,s+(r-i)/2,r]}(Le(e)))}),n.load(ve(i))}),ve(i)}function Sm(e,t){var i=[],n=ze(e)[0],r=ze(e)[e.geometry.coordinates.length-1];if(km(n,Re(t))||km(r,Re(t)))return ve([e]);var o=am(),s=cm(e);o.load(s);var a=o.search(t);if(!a.features.length)return ve([e]);var l=Im(t,a),c=function(e,t,i){var n=i;return Ce(e,function(e,r){n=0===r&&void 0===i?e:t(n,e,r)}),n}(s,function(e,n,r){var o=ze(n)[1],s=Re(t);return r===l.id?(e.push(s),i.push(_e(e)),km(s,o)?[s]:[s,o]):(e.push(o),e)},[n]);return c.length>1&&i.push(_e(c)),ve(i)}function Im(e,t){if(!t.features.length)throw new Error("lines must contain features");if(1===t.features.length)return t.features[0];var i,n=1/0;return Ce(t,function(t){var r=function(e,t,i={}){if(!e||!t)throw new Error("lines and pt are required arguments");const n=Re(t);let r=ge([1/0,1/0],{dist:1/0,index:-1,multiFeatureIndex:-1,location:-1}),o=0;return Ae(e,function(e,s,a){const l=ze(e);for(let e=0;e<l.length-1;e++){const s=ge(l[e]);s.properties.dist=Ge(t,s,i);const c=Re(s),u=ge(l[e+1]);u.properties.dist=Ge(t,u,i);const h=Re(u),d=Ge(s,u,i);let p,f,m;c[0]===n[0]&&c[1]===n[1]?[p,,f]=[c,void 0,!1]:h[0]===n[0]&&h[1]===n[1]?[p,,f]=[h,void 0,!0]:[p,,f]=Em(s.geometry.coordinates,u.geometry.coordinates,Re(t)),p&&(m=ge(p,{dist:Ge(t,p,i),multiFeatureIndex:a,location:o+Ge(s,p,i)})),m&&m.properties.dist<r.properties.dist&&(r=_m(ym({},m),{properties:_m(ym({},m.properties),{index:f?e+1:e})})),o+=d}}),r}(t,e),o=r.properties.dist;o<n&&(i=t,n=o)}),i}function km(e,t){return e[0]===t[0]&&e[1]===t[1]}var Mm=function(e,t){if(!e)throw new Error("line is required");if(!t)throw new Error("splitter is required");var i=Oe(e),n=Oe(t);if("LineString"!==i)throw new Error("line must be LineString");if("FeatureCollection"===n)throw new Error("splitter cannot be a FeatureCollection");if("GeometryCollection"===n)throw new Error("splitter cannot be a GeometryCollection");var r=lm(t,{precision:7});switch(n){case"Point":return Sm(e,r);case"MultiPoint":return Tm(e,r);case"LineString":case"MultiLineString":case"Polygon":case"MultiPolygon":return Tm(e,rs(e,r,{ignoreSelfIntersections:!0}))}};function Cm(e,t,i={}){if(!0===i.final)return function(e,t){let i=Cm(t,e);return i=(i+180)%360,i}(e,t);const n=Re(e),r=Re(t),o=Te(n[0]),s=Te(r[0]),a=Te(n[1]),l=Te(r[1]),c=Math.sin(s-o)*Math.cos(l),u=Math.cos(a)*Math.sin(l)-Math.sin(a)*Math.cos(l)*Math.cos(s-o);return Ee(Math.atan2(c,u))}var Pm=Cm;function Am(e,t){const i=Te(e[1]),n=Te(t[1]);let r=Te(t[0]-e[0]);r>Math.PI&&(r-=2*Math.PI),r<-Math.PI&&(r+=2*Math.PI);const o=Math.log(Math.tan(n/2+Math.PI/4)/Math.tan(i/2+Math.PI/4));return(Ee(Math.atan2(r,o))+360)%360}function Lm(e,t,i={}){const n=Re(e),r=Re(t);r[0]+=r[0]-n[0]>180?-360:n[0]-r[0]>180?360:0;const o=function(e,t,i){i=void 0===i?pe:Number(i);const n=i,r=e[1]*Math.PI/180,o=t[1]*Math.PI/180,s=o-r;let a=Math.abs(t[0]-e[0])*Math.PI/180;a>Math.PI&&(a-=2*Math.PI);const l=Math.log(Math.tan(o/2+Math.PI/4)/Math.tan(r/2+Math.PI/4)),c=Math.abs(l)>1e-11?s/l:Math.cos(r);return Math.sqrt(s*s+c*c*a*a)*n}(n,r);return Se(o,"meters",i.units)}function Dm(e,t,i,n={}){const r=t<0;let o=Se(Math.abs(t),n.units,"meters");r&&(o=-Math.abs(o));const s=Re(e),a=function(e,t,i,n){n=void 0===n?pe:Number(n);const r=t/n,o=e[0]*Math.PI/180,s=Te(e[1]),a=Te(i),l=r*Math.cos(a);let c=s+l;Math.abs(c)>Math.PI/2&&(c=c>0?Math.PI-c:-Math.PI-c);const u=Math.log(Math.tan(c/2+Math.PI/4)/Math.tan(s/2+Math.PI/4)),h=Math.abs(u)>1e-11?l/u:Math.cos(s),d=r*Math.sin(a)/h;return[(180*(o+d)/Math.PI+540)%360-180,180*c/Math.PI]}(s,o,i);return a[0]+=a[0]-s[0]>180?-360:s[0]-a[0]>180?360:0,ge(a,n.properties)}var Rm=function(e,t,i){if(!ke(i=i||{}))throw new Error("options is invalid");const n=i.pivot,r=i.mutate;if(!e)throw new Error("geojson is required");if(null==t||isNaN(t))throw new Error("angle is required");if(0===t)return e;const o=n??co(e);return(!1===r||void 0===r)&&(e=ss(e)),Me(e,function(e){const i=function(e,t,i={}){let n;return n=i.final?Am(Re(t),Re(e)):Am(Re(e),Re(t)),n>180?-(360-n):n}(o,e)+t,n=Lm(o,e),r=ze(Dm(o,n,i));e[0]=r[0],e[1]=r[1]}),e};const zm={drag:class extends Jp{constructor(){super(...arguments),X(this,"mode","drag")}onStartAction(){}onEndAction(){}handleGmEdit(e){return Gd(e)?"marker_move"===e.action&&e.lngLatStart&&e.lngLatEnd?(this.previousLngLat||(this.previousLngLat=e.lngLatStart),this.moveFeature(e.featureData,e.lngLatEnd),{next:!1}):("marker_captured"===e.action?(this.isDragging=!0,e.featureData.changeSource({sourceName:tl.temporary,atomic:!0}),this.fireFeatureEditStartEvent({feature:e.featureData})):"marker_released"===e.action&&(this.previousLngLat=null,this.isDragging=!1,e.featureData.changeSource({sourceName:tl.main,atomic:!0}),this.fireFeatureEditEndEvent({feature:e.featureData})),{next:!0}):(he.error("EditDrag.handleGmEdit: not an edit event",e),{next:!0})}},change:class extends Jp{constructor(){super(...arguments),X(this,"mode","change"),X(this,"cutVertexShapeTypes",["line","polygon","rectangle"]),X(this,"markerData",null),X(this,"shapeUpdateHandlers",{marker:this.updateSingleVertex.bind(this),circle:this.updateCircle.bind(this),circle_marker:this.updateSingleVertex.bind(this),text_marker:this.updateSingleVertex.bind(this),line:this.updateSingleVertex.bind(this),rectangle:this.updateRectangle.bind(this),polygon:this.updateSingleVertex.bind(this)})}get snapGuidesInstance(){const e=this.gm.actionInstances.helper__snap_guides;return hp(e)?e:null}onStartAction(){}onEndAction(){var e;null==(e=this.snapGuidesInstance)||e.removeSnapGuides()}handleGmEdit(e){var t;if(!Gd(e))return{next:!0};if("marker_move"===e.action&&e.lngLatStart&&e.markerData){if("vertex"===e.markerData.type)return this.moveVertex(e),{next:!1};if(e.lngLatEnd)return this.moveSource(e.featureData,e.lngLatStart,e.lngLatEnd),{next:!1}}return"marker_right_click"===e.action?(this.cutVertex(e),this.fireFeatureEditEndEvent({feature:e.featureData})):"edge_marker_click"===e.action?this.insertVertex(e):"marker_captured"===e.action?(e.featureData.changeSource({sourceName:tl.temporary,atomic:!0}),this.fireFeatureEditStartEvent({feature:e.featureData})):"marker_released"===e.action&&(this.markerData=null,null==(t=this.snapGuidesInstance)||t.removeSnapGuides(),e.featureData.changeSource({sourceName:tl.main,atomic:!0}),this.fireFeatureEditEndEvent({feature:e.featureData})),{next:!0}}moveVertex(e){var t,i,n;this.markerData||(this.markerData=e.markerData||null,null==(t=this.snapGuidesInstance)||t.updateSnapGuides(e.featureData.getGeoJson(),e.lngLatStart));const r=e.featureData,o=r.shape,s=(null==(n=(i=this.shapeUpdateHandlers)[o])?void 0:n.call(i,e))||null;s?(this.fireBeforeFeatureUpdate({features:[r],geoJsonFeatures:[s]}),this.updateFeatureGeoJson({featureData:r,featureGeoJson:s})):he.error("EditChange.moveVertex: invalid geojson",s,e)}cutVertex(e){const t=e.featureData;if("vertex"!==e.markerData.type||!this.cutVertexShapeTypes.includes(t.shape))return;let i=!1;const n=t.getGeoJson(),r=e.markerData.instance;if(Zr(n)){if(no(n)<=2)return void this.gm.features.delete(t)}else if(Hr(n)){if(no(n)<=3)return void this.gm.features.delete(t)}else if($r(n)&&no(n)<=3)return void this.gm.features.delete(t);const o=Ka(r);o&&(i=ao(n,o)),i?(t.convertToPolygon(),t.updateGeoJsonGeometry(n.geometry),this.fireFeatureUpdatedEvent({sourceFeatures:[t],targetFeatures:[t],markerData:e.markerData})):he.error("EditChange.cutVertex: feature not updated",e)}insertVertex(e){if("edge"!==e.markerData.type)return;const t=e.featureData.getGeoJson(),i=e.markerData.segment.end.path,n=i.pop(),r=Hi(t,i);"number"==typeof n&&(r.splice(n,0,[...e.markerData.position.coordinate]),e.featureData.updateGeoJsonGeometry(t.geometry),e.featureData.convertToPolygon(),this.fireFeatureUpdatedEvent({sourceFeatures:[e.featureData],targetFeatures:[e.featureData],markerData:e.markerData}))}updateSingleVertex({featureData:e,lngLatEnd:t,markerData:i}){const n=$n(e.getGeoJson()),r=$n(i.position.path),o=r.pop(),s=Hi(n,r);return Array.isArray(s)&&"number"==typeof o?(s[o]=[...t],0===o&&"polygon"===e.shape&&(s[s.length-1]=[...t])):he.error("BaseDrag.moveSingleVertex: invalid coordinates",n,r),n}updateCircle({featureData:e,lngLatEnd:t}){if("circle"!==e.shape||null===e.shapeProperties.center)return he.error("BaseDrag.moveCircle: invalid shape type / missing center",e),null;const i=e.shapeProperties.center;return{type:"Feature",properties:{shape:"circle",center:i},geometry:lo({center:i,radius:this.gm.mapAdapter.getDistance(i,t)}).geometry}}updateRectangle({featureData:e,lngLatStart:t,lngLatEnd:i}){const n=e.getGeoJson(),r=n.geometry.coordinates[0],{absCoordIndex:o}=Kr(n,t);if(-1===o)return he.error("EditChange.updateRectangle: start vertex not found",e),null;const s=((e,t)=>(e%t+t)%t)(o-2,4),a=r[s];return eo(i,a)}},rotate:class extends Jp{constructor(){super(...arguments),X(this,"mode","rotate"),X(this,"convertFeaturesTypes",["rectangle"])}onStartAction(){}onEndAction(){}handleGmEdit(e){var t;return Gd(e)?"marker_move"===e.action&&e.lngLatStart&&e.lngLatEnd?("vertex"===(null==(t=e.markerData)?void 0:t.type)?this.moveVertex(e):this.moveSource(e.featureData,e.lngLatStart,e.lngLatEnd),{next:!1}):("marker_captured"===e.action?(e.featureData.changeSource({sourceName:tl.temporary,atomic:!0}),this.fireFeatureEditStartEvent({feature:e.featureData})):"marker_released"===e.action&&(e.featureData.changeSource({sourceName:tl.main,atomic:!0}),this.fireFeatureEditEndEvent({feature:e.featureData})),{next:!0}):(he.error("EditChange.handleGmEdit: not an edit event",e),{next:!1})}moveVertex(e){this.rotateFeature(e.featureData,e)}rotateFeature(e,t){const i=$n(e.getGeoJson()),n=to(uo(i)),r=this.calculateRotationAngle(n,t.lngLatStart,t.lngLatEnd);i.geometry=Rm(i,r,{pivot:n}).geometry,this.fireBeforeFeatureUpdate({features:[e],geoJsonFeatures:[i]}),this.updateFeatureGeoJson({featureData:e,featureGeoJson:i})&&e.convertToPolygon()}calculateRotationAngle(e,t,i){const n=Pm(e,t);return(Pm(e,i)-n+360)%360}},scale:null,copy:null,cut:class extends Od{constructor(){super(...arguments),X(this,"mode","cut"),X(this,"lineDrawer",new fp(this.gm,{snappingMarkers:"first",targetShape:"polygon"})),X(this,"cutShapesAllowed",["circle","line","rectangle","polygon"]),X(this,"mapEventHandlers",{[`${_o}:draw`]:this.forwardLineDrawerEvent.bind(this),mousemove:this.onMouseMove.bind(this)})}onStartAction(){this.lineDrawer.startAction(),this.lineDrawer.on("firstMarkerClick",this.cutPolygonFinished.bind(this))}onEndAction(){this.lineDrawer.endAction()}onMouseMove(e){return el(e)?(this.lineDrawer.featureData||this.fireMarkerPointerUpdateEvent(),{next:!0}):{next:!0}}cutPolygonFinished(e){this.lineDrawer.endShape();const t=up(e.geoJson),i=this.getBBoxFeaturesByPolygon(t);this.cutFeaturesByPolygon(i,t)}getBBoxFeaturesByPolygon(e){const t=io(e),i=this.gm.mapAdapter.coordBoundsToScreenBounds(t);return this.gm.mapAdapter.queryFeaturesByScreenCoordinates({queryCoordinates:i,sourceNames:[tl.main]})}cutFeaturesByPolygon(e,t){e.forEach(e=>{if(Ja(e.getGeoJson(),t))return this.gm.features.delete(e),void this.fireFeatureRemovedEvent(e);if(nf(e.getGeoJson(),t)&&this.cutShapesAllowed.includes(e.shape)){if("line"===e.shape)return void this.cutLineFeatureByPolygon(e,t);this.cutPolygonFeatureByPolygon(e.id,t)}})}cutLineFeatureByPolygon(e,t){const i=e.getGeoJson(),n=((e,t)=>{const i=e.getBounds(),n=je(i[0],i[1],{units:"meters"});return Xa(t,1e-4*n,{units:"meters"})||null})(this.gm.mapAdapter,t),r=Mm(i,t);if(!n||0===r.features.length)return;const o=[];r.features.filter(e=>!Ja(e,n)).forEach(e=>{const t=this.createLineFeature(hs(e));t&&o.push(t)}),this.gm.features.delete(e),(e=>e.length>0)(o)?this.fireFeatureUpdatedEvent({sourceFeatures:[e],targetFeatures:o}):he.error("cutLineFeatureByPolygon: resultFeatures not found",r)}createLineFeature(e){const t={...e,properties:{shape:"line"}};return this.gm.features.createFeature({shapeGeoJson:t,sourceName:tl.main})}cutPolygonFeatureByPolygon(e,t){const i=this.gm.features.get(tl.main,e);if(!i)return void he.warn("cutPolygonFeatureByPolygon: featureData not found",e);i.convertToPolygon();const n=i.getGeoJson(),r=this.getGeoJsonDifference(n,t);r&&(i.updateGeoJsonGeometry(r.geometry),this.fireFeatureUpdatedEvent({sourceFeatures:[i],targetFeatures:[i]}))}getGeoJsonDifference(e,t){const i=ve([e,t]),n=sm(i);return n?"Feature"===n.type?n:("FeatureCollection"===n.type&&he.error("getGeoJsonDifference: FeatureCollection detected (not supported)",n),null):null}},split:null,union:null,difference:null,line_simplification:null,lasso:null,delete:class extends Od{constructor(){super(...arguments),X(this,"mode","delete"),X(this,"mapEventHandlers",{click:this.onMouseClick.bind(this)})}onStartAction(){this.gm.markerPointer.enable({invisibleMarker:!0}),this.gm.markerPointer.pauseSnapping()}onEndAction(){this.gm.markerPointer.resumeSnapping(),this.gm.markerPointer.disable()}onMouseClick(e){if(!el(e,{warning:!0}))return{next:!1};const t=this.gm.features.getFeatureByMouseEvent({event:e,sourceNames:[tl.main]});return t&&(this.gm.features.delete(t),this.fireFeatureRemovedEvent(t)),{next:!1}}}};var Fm;const Om={shape_markers:class extends Bd{constructor(){super(...arguments),X(this,"mode","shape_markers"),X(this,"pinEnabled",(null==(Fm=this.gm.options.controls.helper.pin)?void 0:Fm.active)||!1),X(this,"previousPosition",null),X(this,"activeMarker",null),X(this,"activeFeatureData",null),X(this,"sharedMarkers",[]),X(this,"allowedShapes",["circle","line","rectangle","polygon"]),X(this,"edgeMarkersAllowed",!1),X(this,"edgeMarkerAllowedShapes",["line","rectangle","polygon"]),X(this,"shapeMarkerAllowedModes",["drag","change","cut","split"]),X(this,"mapEventHandlers",{[`${_o}:draw`]:this.handleGmDraw.bind(this),[`${_o}:edit`]:this.handleGmEdit.bind(this),mousedown:this.onMouseDown.bind(this),touchstart:this.onMouseDown.bind(this),mouseup:this.onMouseUp.bind(this),touchend:this.onMouseUp.bind(this),mousemove:this.onMouseMove.bind(this),touchmove:this.onMouseMove.bind(this),contextmenu:this.onMouseRightButtonClick.bind(this)}),X(this,"throttledMethods",op({sendMarkerMoveEvent:this.sendMarkerMoveEvent,sendMarkerRightClickEvent:this.sendMarkerRightClickEvent},this,this.gm.options.settings.throttlingDelay)),X(this,"debouncedMethods",((e,t,i=10)=>{const n={...e};return te(e).forEach(r=>{const o=e[r];"function"==typeof o?n[r]=wr(o.bind(t),i,{leading:!1,trailing:!0}):he.error("convertToDebounced: item is not a function",e[r])}),n})({refreshMarkers:this.refreshMarkers},this,10*this.gm.options.settings.throttlingDelay))}onStartAction(){this.isShapeMarkerAllowed()&&this.gm.markerPointer.enable({invisibleMarker:!0}),this.edgeMarkersAllowed=this.gm.getActiveEditModes().includes("change"),this.addMarkers()}onEndAction(){this.gm.markerPointer.disable(),this.removeMarkers()}setPin(e){this.pinEnabled=e}onMouseDown(e){var t;if(!el(e,{warning:!0})||!["mousedown","touchstart"].includes(e.type))return{next:!0};if("mousedown"===e.type&&0!==e.originalEvent.button)return{next:!0};const i=this.getFeatureMarkerByMouseEvent(e);return this.activeMarker=i||null,this.activeFeatureData=(null==i?void 0:i.instance.parent)||null,this.activeMarker&&this.activeFeatureData?(this.previousPosition=Ka(this.activeMarker.instance),this.gm.mapAdapter.setDragPan(!1),"edge"===this.activeMarker.type&&this.sendMarkerEvent("edge_marker_click",this.activeFeatureData,this.activeMarker),this.pinEnabled&&this.pinHelperInstance?(this.sharedMarkers=this.pinHelperInstance.getSharedMarkers(this.activeMarker.position.coordinate),this.sharedMarkers.forEach(e=>{var t;return null==(t=this.snappingHelper)?void 0:t.addExcludedFeature(e.featureData)})):null==(t=this.snappingHelper)||t.addExcludedFeature(this.activeFeatureData),this.sendMarkerEvent("marker_captured",this.activeFeatureData,this.activeMarker),{next:!1}):{next:!0}}onMouseUp(){var e;if(!this.activeMarker)return{next:!0};const t={featureData:this.activeFeatureData,markerData:this.activeMarker};return this.activeMarker=null,this.activeFeatureData=null,this.sharedMarkers=[],null==(e=this.snappingHelper)||e.clearExcludedFeatures(),this.previousPosition=null,this.gm.mapAdapter.setDragPan(!0),t.featureData&&t.markerData?(this.sendMarkerEvent("marker_released",t.featureData,t.markerData),{next:!1}):(he.debug("ShapeMarkersHelper.onMouseUp: no active marker or featureData",t),{next:!0})}onMouseMove(e){return this.activeMarker&&el(e,{warning:!0})?(this.throttledMethods.sendMarkerMoveEvent(e),{next:!1}):{next:!0}}onMouseRightButtonClick(e){const t=this.getFeatureMarkerByMouseEvent(e);return t&&t.instance.parent?(this.throttledMethods.sendMarkerRightClickEvent(t.instance.parent,t),{next:!1}):{next:!0}}get pinHelperInstance(){return this.pinEnabled&&Object.values(this.gm.actionInstances).find(pp)||null}isShapeMarkerAllowed(){return Rr(this.shapeMarkerAllowedModes,this.gm.getActiveEditModes()).length>0}convertToVertexMarker(e){if("edge"===e.type&&e.instance.parent){const t=e.position,i=e.instance.parent;this.removeMarker(e);const n=this.createMarker({type:"vertex",positionData:t,parentFeature:i}),r=((e,t)=>{let i={coordinate:[0,0],path:[]},n=-1;try{Yr(e,(e,r)=>{if(t[0]===e.coordinate[0]&&t[1]===e.coordinate[1])throw n=r,i=e,new Error("stop")})}catch{if(i)return{index:n,coordinate:i.coordinate,path:i.path}}return null})(i.getGeoJson(),t.coordinate);if(r){const e=r.path.join("."),t=i.markers.get(e);return t&&this.removeMarker(t),i.markers.set(e,n),n}}return he.error("ShapeMarkersHelper.convertToVertexMarker: invalid marker type",e),e}getFeatureMarkerByMouseEvent(e){var t;const i=this.gm.features.getFeatureByMouseEvent({event:e,sourceNames:[tl.main]});if(null!=(t=null==i?void 0:i.parent)&&t.markers){const e=((e,t)=>{let i=null;try{e.forEach(e=>{if(t(e))throw i=e,new Error("found")})}catch{}return i})(i.parent.markers,e=>e.instance===i);if("dom"!==(null==e?void 0:e.type))return e}return null}addMarkers(){this.gm.features.forEach(e=>{if(!e||!this.allowedShapes.includes(e.shape))return;this.addCenterMarker(e);const t=this.getAllShapeSegments(e);t.forEach((i,n)=>{if(this.isMarkerIndexAllowed(e.shape,n,t.length)){const r=this.createOrUpdateVertexMarker(i.segment.start,e);if(e.markers.set(r.markerKey,r.markerData),"line"===e.shape&&n===t.length-1){const t=this.createOrUpdateVertexMarker(i.segment.end,e);e.markers.set(t.markerKey,t.markerData)}}if(this.isEdgeMarkerAllowed(e)){const t=this.createOrUpdateEdgeMarker(i,e);e.markers.set(t.markerKey,t.markerData)}})})}addCenterMarker(e){if(e.shapeProperties.center){const t=this.createMarker({type:"center",positionData:{path:[],coordinate:e.shapeProperties.center},parentFeature:e});e.markers.set("center",t)}}getAllShapeSegments(e){const t=e.getGeoJson(),i=[];return Jr(t,(e,t)=>{i.push({segment:e,middle:this.getSegmentMiddlePosition(e),edgeMarkerKey:this.getEdgeMarkerKey(t)})}),i}isEdgeMarkerAllowed(e){return this.edgeMarkersAllowed&&this.edgeMarkerAllowedShapes.includes(e.shape)}isMarkerIndexAllowed(e,t,i){const n=Math.floor(i/4);return"circle"!==e||(t+n/2)%n===0}getEdgeMarkerKey(e){return`edge.${e}`}getSegmentMiddlePosition(e){const t=this.gm.mapAdapter.project(e.start.coordinate),i=this.gm.mapAdapter.project(e.end.coordinate),n=[(t[0]+i[0])/2,(t[1]+i[1])/2],r=e.start.path.slice(0,e.start.path.length-1).concat([-1]);return{coordinate:this.gm.mapAdapter.unproject(n),path:r}}removeMarkers(){this.gm.features.forEach((e,t)=>{const i=this.gm.features.get(tl.main,t);i&&(i.markers.forEach(e=>{"dom"!==e.type?this.gm.features.delete(e.instance):he.error("Non a FeatureData marker",e)}),i.markers=new Map)})}removeMarker(e){if("dom"===e.type)return void he.error("Wrong marker type",e);const t=e.instance.parent;if(t)try{t.markers.forEach((i,n)=>{if(i===e)throw this.gm.features.delete(i.instance),t.markers.delete(n),new Error("break")})}catch{}else he.error("Missing parent feature data",e)}createMarker({type:e,segment:t,positionData:i,parentFeature:n}){const r=i.coordinate,o=this.gm.features.createMarkerFeature({sourceName:n.sourceName,parentFeature:n,type:e,coordinate:r});if(!o)throw new Error(`Missine feature data for the "${e}" marker`);if("edge"===e&&t)return{type:e,instance:o,position:$n(i),segment:t};if("vertex"===e||"center"===e)return{type:e,instance:o,position:$n(i)};throw new Error(`Invalid marker type "${e}" with segment: ${t}`)}handleGmDraw(e){return So(e)?("feature_created"===e.action&&this.debouncedMethods.refreshMarkers(),{next:!0}):(he.error("ShapeMarkersHelper.handleGmDraw: not a draw event",e),{next:!0})}refreshMarkers(){this.removeMarkers(),this.addMarkers()}handleGmEdit(e){return Gd(e)?("feature_updated"===e.action&&this.gm.features.withAtomicSourcesUpdate(()=>{this.handleShapeUpdate(e)}),{next:!0}):(he.error("ShapeMarkersHelper.handleGmEdit: not an edit event",e),{next:!0})}handleShapeUpdate(e){var t;const i=e.targetFeatures[0];if(!i)return void he.error("ShapeMarkersHelper.handleShapeUpdate: no featureData",e);"edge"===(null==(t=this.activeMarker)?void 0:t.type)&&(this.activeMarker=this.convertToVertexMarker(this.activeMarker));const n=this.getAllShapeSegments(i),r=new Set(i.markers.keys());n.forEach((e,t)=>{if(this.isMarkerIndexAllowed(i.shape,t,n.length)){const o=this.createOrUpdateVertexMarker(e.segment.start,i);if(r.delete(o.markerKey),"line"===i.shape&&t===n.length-1){const t=this.createOrUpdateVertexMarker(e.segment.end,i);r.delete(t.markerKey)}}if(this.isEdgeMarkerAllowed(i)){const t=this.createOrUpdateEdgeMarker(e,i);r.delete(t.markerKey)}}),this.updateCenterMarkerPosition(i),r.delete("center"),r.forEach(e=>{const t=i.markers.get(e);t&&"dom"!==t.type?this.gm.features.delete(t.instance):he.error("Non a FeatureData marker"),i.markers.delete(e)})}createOrUpdateVertexMarker(e,t){const i=e.path.join(".");let n=t.markers.get(i)||null;if(n&&"vertex"!==(null==n?void 0:n.type))throw new Error(`Invalid marker type "${null==n?void 0:n.type}" for edge marker`);return n?(qr(n.position.coordinate,e.coordinate)||this.gm.features.updateMarkerFeaturePosition(n.instance,e.coordinate),n.position=e):(n=this.createMarker({type:"vertex",positionData:e,parentFeature:t}),t.markers.set(i,n)),{markerKey:i,markerData:n}}createOrUpdateEdgeMarker(e,t){let i=t.markers.get(e.edgeMarkerKey)||null;if(i&&"edge"!==(null==i?void 0:i.type))throw new Error(`Invalid marker type "${null==i?void 0:i.type}" for edge marker`);return i?(qr(i.position.coordinate,e.middle.coordinate)||i.instance.updateGeoJsonGeometry({type:"Point",coordinates:e.middle.coordinate}),i.position=e.middle,i.segment=e.segment):(i=this.createMarker({type:"edge",positionData:e.middle,segment:e.segment,parentFeature:t}),t.markers.set(e.edgeMarkerKey,i)),{markerKey:e.edgeMarkerKey,markerData:i}}updateCenterMarkerPosition(e){const t=e.markers.get("center")||null;t&&"dom"!==t.type&&e.shapeProperties.center&&(t.instance.updateGeoJsonGeometry({type:"Point",coordinates:e.shapeProperties.center}),t.position.coordinate=e.shapeProperties.center)}sendMarkerEvent(e,t,i){const n={level:"system",type:"edit",mode:"change",action:e,featureData:t,markerData:i};this.gm.events.fire(`${_o}:edit`,n)}sendMarkerRightClickEvent(e,t){const i={level:"system",type:"edit",mode:"change",action:"marker_right_click",featureData:e,markerData:t};this.gm.events.fire(`${_o}:edit`,i)}sendMarkerMoveEvent(e){var t;const i=(null==(t=this.gm.markerPointer.marker)?void 0:t.getLngLat())||e.lngLat.toArray();this.activeMarker&&this.activeFeatureData&&(this.pinEnabled?this.sharedMarkers:[{markerData:this.activeMarker,featureData:this.activeFeatureData}]).forEach(e=>{if(this.previousPosition){const t={level:"system",type:"edit",mode:"drag",action:"marker_move",featureData:e.featureData,markerData:e.markerData,lngLatStart:this.previousPosition,lngLatEnd:i};this.gm.events.fire(`${_o}:edit`,t)}}),this.previousPosition=i}},pin:null,snapping:class extends Bd{constructor(){super(...arguments),X(this,"mode","snapping"),X(this,"tolerance",18),X(this,"excludedFeature",new Set),X(this,"customSnappingLngLats",new Map),X(this,"customSnappingFeatures",new Set),X(this,"lineSnappingShapes",["circle","line","rectangle","polygon","snap_guide"]),X(this,"mapEventHandlers",{}),X(this,"shapeSnappingHandlers",{marker:this.getPointsSnapping.bind(this),circle:this.getLineSnapping.bind(this),circle_marker:this.getPointsSnapping.bind(this),text_marker:this.getPointsSnapping.bind(this),line:this.getLineSnapping.bind(this),rectangle:this.getLineSnapping.bind(this),polygon:this.getLineSnapping.bind(this),snap_guide:this.getLineSnapping.bind(this)})}onStartAction(){this.gm.markerPointer.setSnapping(!0)}onEndAction(){this.gm.markerPointer.setSnapping(!1)}addExcludedFeature(e){this.excludedFeature.add(e)}clearExcludedFeatures(){this.excludedFeature.clear()}addCustomSnappingFeature(e){this.customSnappingFeatures.add(e)}removeCustomSnappingFeature(e){this.customSnappingFeatures.delete(e)}clearCustomSnappingFeature(){this.customSnappingFeatures.clear()}setCustomSnappingCoordinates(e,t){this.customSnappingLngLats.set(e,t)}clearCustomSnappingCoordinates(e){this.customSnappingLngLats.delete(e)}getSnappedLngLat(e,t){let i=this.getCustomLngLatsSnapping(t);if(i)return i;const n=this.getFeaturesInPointBounds(t).filter(e=>!this.excludedFeature.has(e));return i=this.getFeaturePointsSnapping(n,e,t),i||(i=this.getFeatureLinesSnapping(n,e,t),i)?i:e}getCustomLngLatsSnapping(e){const t={distance:1/0,lngLat:null};return this.customSnappingLngLats.forEach(i=>{i.forEach(i=>{const n=this.gm.mapAdapter.project(i),r=so(e,n);r<this.tolerance&&r<t.distance&&(t.distance=r,t.lngLat=i)})}),t.lngLat}getFeaturePointsSnapping(e,t,i){let n=e.map(e=>({shape:e.shape,...this.getPointsSnapping(e,t,i)})).filter(e=>e.distance<this.tolerance);return n.length?(n=Gr(n,["distance"]),n[0].lngLat):null}getFeatureLinesSnapping(e,t,i){let n=e.filter(e=>this.lineSnappingShapes.includes(e.shape)).map(e=>{const n=this.shapeSnappingHandlers[e.shape];return n?{shape:e.shape,...n(e,t,i)}:null}).filter(e=>null!==e&&e.distance<this.tolerance);return n.length?(n=Gr(n,["distance"]),n[0].lngLat):null}getFeaturesInPointBounds(e){const t=[[e[0]-this.tolerance,e[1]-this.tolerance],[e[0]+this.tolerance,e[1]+this.tolerance]];return this.gm.features.getFeaturesByScreenBounds({bounds:t,sourceNames:[tl.main,tl.temporary]}).filter(e=>!e.temporary||this.customSnappingFeatures.has(e))||[]}getPointsSnapping(e,t,i){const n=e.getGeoJson(),r={distance:1/0,coord:null};return Yr(n,e=>{const t=this.gm.mapAdapter.project(e.coordinate),n=so(i,t);n<this.tolerance&&n<r.distance&&(r.distance=n,r.coord=e.coordinate)},!0),{lngLat:r.coord?r.coord:t,distance:r.distance}}getLineSnapping(e,t,i){const n=e.getGeoJson();return this.getNearestLinePointData(n,t,i)}getNearestLinePointData(e,t,i){const n={lngLat:t,distance:1/0},r=this.gm.mapAdapter.getEuclideanNearestLngLat(e,t),o=this.gm.mapAdapter.project(r);return n.distance=so(o,i),n.distance<this.tolerance&&(n.lngLat=r),n}},snap_guides:null,measurements:null,auto_trace:null,geofencing:null,zoom_to_features:class extends Bd{constructor(){super(...arguments),X(this,"mode","zoom_to_features"),X(this,"mapEventHandlers",{})}onStartAction(){this.fitMapToFeatures(),setTimeout(()=>{this.gm.options.disableMode("helper","zoom_to_features")})}onEndAction(){}fitMapToFeatures(){const e=this.gm.features.asGeoJsonFeatureCollection({sourceNames:[tl.main,tl.standby]}),t=De(e),i=[[t[0],t[1]],[t[2],t[3]]];try{this.gm.mapAdapter.fitBounds(i,{padding:20})}catch{he.warn("Wrong bounds for zooming to features",i,e)}}},click_to_edit:null};class Nm{constructor(e){X(this,"gm"),X(this,"marker",null),X(this,"tmpMarker",null),X(this,"snapping",!1),X(this,"oldSnapping"),this.gm=e,this.initEventHandlers()}initEventHandlers(){this.throttledMethods=op({onMouseMove:this.onMouseMove},this,this.gm.options.settings.throttlingDelay),this.mapEventHandlers={mousemove:this.throttledMethods.onMouseMove.bind(this)}}get snappingHelper(){return this.gm.actionInstances.helper__snapping||null}setSnapping(e){!e||this.snappingHelper?this.snapping=e:he.error("MarkerPointer: snapping is not available")}pauseSnapping(){void 0!==this.oldSnapping&&he.error("MarkerPointer: snapping is already paused"),this.oldSnapping=this.snapping,this.setSnapping(!1)}resumeSnapping(){void 0===this.oldSnapping?(he.error("MarkerPointer: resumeSnapping is called before pauseSnapping"),this.setSnapping(!0)):(this.setSnapping(this.oldSnapping),this.oldSnapping=void 0)}enable({lngLat:e,customMarker:t,invisibleMarker:i}={lngLat:[0,0],customMarker:void 0,invisibleMarker:!1}){if(!("ontouchstart"in window||navigator.maxTouchPoints>0||matchMedia("(hover: none)").matches||"msMaxTouchPoints"in navigator&&"number"==typeof navigator.msMaxTouchPoints&&navigator.msMaxTouchPoints>0)){if(t&&i)throw new Error("MarkerPointer: customMarker and invisibleMarker can't be used together");if(this.marker)throw new Error("MarkerPointer: marker is already enabled");this.gm.events.bus.attachEvents(this.mapEventHandlers),this.marker=i?this.createInvisibleMarker(e||[0,0]):t||this.createMarker(e||[0,0]),this.gm.getActiveDrawModes().length&&this.gm.mapAdapter.setCursor("crosshair")}}disable(){this.marker&&(this.gm.events.bus.detachEvents(this.mapEventHandlers),this.marker.remove(),this.marker=null),this.gm.mapAdapter.setCursor("")}createMarker(e=[0,0]){return this.gm.mapAdapter.createDomMarker({anchor:"center",element:ap("dom",{pointerEvents:"none"})},e)}createInvisibleMarker(e=[0,0]){const t=document.createElement("div");return t.style.width="0px",t.style.height="0px",this.gm.mapAdapter.createDomMarker({anchor:"center",element:t},e)}onMouseMove(e){if(el(e,{warning:!0})&&this.marker)if(this.snapping&&this.snappingHelper){const t=[e.point.x,e.point.y],i=this.snappingHelper.getSnappedLngLat(e.lngLat.toArray(),t);this.marker.setLngLat(i)}else this.marker.setLngLat(e.lngLat.toArray());return{next:!0}}syncTmpMarker(e){this.tmpMarker||(this.tmpMarker=this.createMarker(e)),this.tmpMarker.setLngLat(e)}}class Bm{constructor(e,t={}){X(this,"mapAdapterInstance",null),X(this,"globalLngLatBounds",this.getGlobalLngLatBounds()),X(this,"features"),X(this,"loaded",!1),X(this,"options"),X(this,"events"),X(this,"control"),X(this,"actionInstances",{}),X(this,"markerPointer");const i=Object.assign(e,{gm:this});this.options=this.initCoreOptions(t),this.events=this.initCoreEvents(),this.features=this.initCoreFeatures(),this.control=this.initCoreControls(),this.markerPointer=this.initMarkerPointer(),(e=>!(!e||"object"!=typeof e||!("once"in e)||"function"!=typeof e.once))(e)&&(this.isMapInstanceLoaded(e)?this.init(i).then():e.once("load",async()=>{await this.init(i)}))}initCoreOptions(e={}){return new np(this,e)}initCoreEvents(){return new Zd(this)}initCoreFeatures(){return new nl(this)}initCoreControls(){return new Ad(this)}initMarkerPointer(){return new Nm(this)}get drawClassMap(){return Yp}get editClassMap(){return zm}get helperClassMap(){return Om}get mapAdapter(){if(this.mapAdapterInstance)return this.mapAdapterInstance;throw he.trace("Map adapter is not initialized"),new Error("Map adapter is not initialized")}addControls(e=void 0){return new Promise(t=>{(async()=>{e?this.control.createControls(e):this.mapAdapter.addControl(this.control),await this.onMapLoad(),t()})().then()})}isMapInstanceLoaded(e){return"_fullyLoaded"in e&&e._fullyLoaded}async init(e){this.mapAdapterInstance=await(async(e,t)=>new tp(t,e))(this,e),this.features.init(),await this.addControls()}destroy(){this.removeControls(),this.events.bus.detachAllEvents(),"gm"in this.mapAdapter.mapInstance&&delete this.mapAdapter.mapInstance.gm}removeControls(){this.disableAllModes(),this.mapAdapter.removeControl(this.control)}async onMapLoad(){this.loaded||(await this.mapAdapter.loadImage({id:"default-marker",image:Y}),this.events.fire(`${_o}:control`,{level:"system",type:"control",action:"loaded"}),this.loaded=!0)}disableAllModes(){te(this.actionInstances).forEach(e=>{const[t,i]=e.split("__");(e=>Eo.includes(e))(t)&&jd(i)&&this.options.disableMode(t,i)})}getActiveDrawModes(){return te(this.actionInstances).map(e=>{const t=this.actionInstances[e];return t instanceof Co?t.mode:null}).filter(e=>null!==e)}getActiveEditModes(){return te(this.actionInstances).map(e=>{const t=this.actionInstances[e];return t instanceof Od?t.mode:null}).filter(e=>null!==e)}getActiveHelperModes(){return te(this.actionInstances).map(e=>{const t=this.actionInstances[e];return t instanceof Bd?t.mode:null}).filter(e=>null!==e)}getGlobalLngLatBounds(){return[[-179.99999,-85.051129],[179.99999,85.051129]]}createDrawInstance(e){return this.drawClassMap[e]?new this.drawClassMap[e](this):(he.error(`Draw "${e}" is not available`),null)}createEditInstance(e){return this.editClassMap[e]?new this.editClassMap[e](this):(he.error(`Edit "${e}" is not available`),null)}createHelperInstance(e){return this.helperClassMap[e]?new this.helperClassMap[e](this):(he.error(`Helper "${e}" is not available`),null)}setGlobalEventsListener(e=null){this.events.bus.forwarder.globalEventsListener=e}enableMode(e,t){this.options.enableMode(e,t)}disableMode(e,t){this.options.disableMode(e,t)}toggleMode(e,t){this.options.toggleMode(e,t)}isModeEnabled(e,t){return this.options.isModeEnabled(e,t)}enableDraw(e){this.options.enableMode("draw",e)}disableDraw(){this.getActiveDrawModes().forEach(e=>this.options.disableMode("draw",e))}toggleDraw(e){this.options.toggleMode("draw",e)}drawEnabled(e){return this.options.isModeEnabled("draw",e)}enableGlobalDragMode(){this.options.enableMode("edit","drag")}disableGlobalDragMode(){this.options.disableMode("edit","drag")}toggleGlobalDragMode(){this.options.toggleMode("edit","drag")}globalDragModeEnabled(){return this.options.isModeEnabled("edit","drag")}enableGlobalEditMode(){this.options.enableMode("edit","change")}disableGlobalEditMode(){this.options.disableMode("edit","change")}toggleGlobalEditMode(){this.options.toggleMode("edit","change")}globalEditModeEnabled(){return this.options.isModeEnabled("edit","change")}enableGlobalRotateMode(){this.options.enableMode("edit","rotate")}disableGlobalRotateMode(){this.options.disableMode("edit","rotate")}toggleGlobalRotateMode(){this.options.toggleMode("edit","rotate")}globalRotateModeEnabled(){return this.options.isModeEnabled("edit","rotate")}enableGlobalCutMode(){this.options.enableMode("edit","cut")}disableGlobalCutMode(){this.options.disableMode("edit","cut")}toggleGlobalCutMode(){this.options.toggleMode("edit","cut")}globalCutModeEnabled(){return this.options.isModeEnabled("edit","cut")}enableGlobalRemovalMode(){this.options.enableMode("edit","delete")}disableGlobalRemovalMode(){this.options.disableMode("edit","delete")}toggleGlobalRemovalMode(){this.options.toggleMode("edit","delete")}globalRemovalModeEnabled(){return this.options.isModeEnabled("edit","delete")}}e.API=M,e.AviationChart=H,e.CHART_THEMES=q,e.DEFAULT_LAYER_VISIBILITY=p,e.DrawPlugin=class{constructor(){this.name="draw",this.version="1.0.0",this.sdk=null,this.geoman=null}install(e){this.sdk=e;this.geoman=new Bm(this.sdk?.map,{settings:{throttlingDelay:10,controlsPosition:"top-left"},layerStyles:{line:{gm_main:[{type:"line",paint:{"line-color":"#278cda","line-opacity":.8,"line-width":3}}],gm_temporary:[{type:"line",paint:{"line-color":"#ff5600","line-opacity":.8,"line-width":3}}],gm_standby:[{type:"line",paint:{"line-color":"#787878","line-opacity":.8,"line-width":3}}]},circle:{gm_main:[{type:"fill",paint:{"fill-color":"#4fb3ff","fill-opacity":.4}},{type:"line",paint:{"line-color":"#278cda","line-opacity":.8,"line-width":3}}],gm_temporary:[{type:"fill",paint:{"fill-color":"#4fb3ff","fill-opacity":.4}},{type:"line",paint:{"line-color":"#ff5600","line-opacity":.8,"line-width":3}}],gm_standby:[{type:"fill",paint:{"fill-color":"#efb253","fill-opacity":.4}},{type:"line",paint:{"line-color":"#787878","line-opacity":.8,"line-width":3}}]},rectangle:{gm_main:[{type:"fill",paint:{"fill-color":"#4fb3ff","fill-opacity":.4}},{type:"line",paint:{"line-color":"#278cda","line-opacity":.8,"line-width":3}}],gm_temporary:[{type:"fill",paint:{"fill-color":"#4fb3ff","fill-opacity":.4}},{type:"line",paint:{"line-color":"#ff5600","line-opacity":.8,"line-width":3}}],gm_standby:[{type:"fill",paint:{"fill-color":"#a5a5a5","fill-opacity":.4}},{type:"line",paint:{"line-color":"#787878","line-opacity":.8,"line-width":3}}]},polygon:{gm_main:[{type:"fill",paint:{"fill-color":"#4fb3ff","fill-opacity":.4}},{type:"line",paint:{"line-color":"#278cda","line-opacity":.8,"line-width":3}}],gm_temporary:[{type:"fill",paint:{"fill-color":"#4fb3ff","fill-opacity":.4}},{type:"line",paint:{"line-color":"#ff5600","line-opacity":.8,"line-width":3}}],gm_standby:[{type:"fill",paint:{"fill-color":"#a5a5a5","fill-opacity":.4}},{type:"line",paint:{"line-color":"#787878","line-opacity":.8,"line-width":3}}]},marker:{gm_temporary:[{type:"symbol",layout:{"icon-image":"default-marker","icon-size":.18,"icon-allow-overlap":!0,"icon-anchor":"bottom"}}],gm_main:[{type:"symbol",layout:{"icon-image":"default-marker","icon-size":.18,"icon-allow-overlap":!0,"icon-anchor":"bottom"}}],gm_standby:[{type:"symbol",layout:{"icon-image":"default-marker","icon-size":.18,"icon-allow-overlap":!0,"icon-anchor":"bottom"}}]},circle_marker:{gm_main:[{type:"circle",paint:{"circle-radius":10,"circle-color":"#4fb3ff","circle-opacity":.4,"circle-stroke-color":"#278cda","circle-stroke-width":3,"circle-stroke-opacity":.8}}],gm_temporary:[{type:"circle",paint:{"circle-radius":10,"circle-color":"#4fb3ff","circle-opacity":.4,"circle-stroke-color":"#ff5600","circle-stroke-width":3,"circle-stroke-opacity":.8}}],gm_standby:[{type:"circle",paint:{"circle-radius":10,"circle-color":"#a5a5a5","circle-opacity":.4,"circle-stroke-color":"#787878","circle-stroke-width":3,"circle-stroke-opacity":.8}}]},text_marker:{gm_main:[{type:"symbol",layout:{"text-field":["get","text"],"text-justify":"center"},paint:{"text-color":"black","text-halo-color":"#fff","text-halo-width":2}}],gm_temporary:[{type:"symbol",layout:{"text-field":["get","text"],"text-justify":"center"},paint:{"text-color":"black","text-halo-color":"#fff","text-halo-width":2}}],gm_standby:[{type:"symbol",layout:{"text-field":["get","text"],"text-justify":"center"},paint:{"text-color":"black","text-halo-color":"#fff","text-halo-width":2}}]},dom_marker:{gm_main:[],gm_temporary:[],gm_standby:[]},center_marker:{gm_main:[{type:"circle",paint:{"circle-radius":7,"circle-color":"#ffffff","circle-opacity":1,"circle-stroke-color":"#278cda","circle-stroke-width":2,"circle-stroke-opacity":1}}],gm_temporary:[{type:"circle",paint:{"circle-radius":7,"circle-color":"#ffffff","circle-opacity":1,"circle-stroke-color":"#ff5600","circle-stroke-width":2,"circle-stroke-opacity":1}}],gm_standby:[{type:"circle",paint:{"circle-radius":7,"circle-color":"#ffffff","circle-opacity":1,"circle-stroke-color":"#787878","circle-stroke-width":2,"circle-stroke-opacity":1}}]},vertex_marker:{gm_main:[{type:"circle",paint:{"circle-radius":7,"circle-color":"#ffffff","circle-opacity":1,"circle-stroke-color":"#278cda","circle-stroke-width":2,"circle-stroke-opacity":1}}],gm_temporary:[{type:"circle",paint:{"circle-radius":7,"circle-color":"#ffffff","circle-opacity":1,"circle-stroke-color":"#ff5600","circle-stroke-width":2,"circle-stroke-opacity":1}}],gm_standby:[{type:"circle",paint:{"circle-radius":7,"circle-color":"#ffffff","circle-opacity":1,"circle-stroke-color":"#787878","circle-stroke-width":2,"circle-stroke-opacity":1}}]},edge_marker:{gm_main:[{type:"circle",paint:{"circle-radius":6,"circle-color":"#ffffff","circle-opacity":.6,"circle-stroke-color":"#278cda","circle-stroke-width":2,"circle-stroke-opacity":1}}],gm_temporary:[{type:"circle",paint:{"circle-radius":6,"circle-color":"#ffffff","circle-opacity":.6,"circle-stroke-color":"#ff5600","circle-stroke-width":2,"circle-stroke-opacity":1}}],gm_standby:[{type:"circle",paint:{"circle-radius":6,"circle-color":"#ffffff","circle-opacity":.6,"circle-stroke-color":"#787878","circle-stroke-width":2,"circle-stroke-opacity":1}}]},snap_guide:{gm_main:[{type:"line",paint:{"line-color":"#00979f","line-width":1.8,"line-dasharray":[2,1]}}],gm_temporary:[{type:"line",paint:{"line-color":"#00979f","line-width":1.8,"line-dasharray":[2,1]}}],gm_standby:[{type:"line",paint:{"line-color":"#00979f","line-width":1.8,"line-dasharray":[2,1]}}]}},controls:{draw:{marker:{title:"Marker",icon:'<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 64 64">\n <path d="M32 62.81s23.107-21.898 23.107-38.512a23.107 23.107 0 0 0-46.214 0C8.893 40.912 32 62.809 32 62.809m0-26.958a11.554 11.554 0 1 1 0-23.107 11.554 11.554 0 0 1 0 23.107"/>\n</svg>\n',uiEnabled:!1,active:!1},circle_marker:{title:"Circle Marker",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="none" d="M0 0h24v24H0Z"/>\n <circle cx="32" cy="32" r="26" fill="currentColor" fill-opacity=".15" stroke="currentColor"\n style="stroke-width:7"/>\n <circle cx="32" cy="32" r="5" fill="currentColor"/>\n</svg>\n',uiEnabled:!1,active:!1},text_marker:{title:"Text Marker",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="none" d="M0 0h24v24H0Z"/>\n <path fill="currentColor"\n d="M6.962 3.385h50.076a3.577 3.577 0 0 1 3.577 3.577v50.076a3.577 3.577 0 0 1-3.577 3.577H6.962a3.577 3.577 0 0 1-3.577-3.577V6.962a3.577 3.577 0 0 1 3.577-3.577Zm3.577 7.154v42.922h42.922V10.539Zm7.154 7.154h28.614v7.153H17.693Zm0 14.307h28.614v7.154H17.693Z"\n style="stroke-width:4"/>\n</svg>\n',uiEnabled:!1,active:!1},circle:{title:"Circle",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="none" d="M0 0h24v24H0Z"/>\n <circle cx="32" cy="32" r="26" fill="currentColor" fill-opacity=".15" stroke="currentColor" style="stroke-width:7"/>\n <line x1="6" y1="32" x2="58" y2="32" stroke="currentColor" stroke-width="4" stroke-dasharray="3"/>\n <line x1="32" y1="6" x2="32" y2="58" stroke="currentColor" stroke-width="4" stroke-dasharray="3"/>\n</svg>\n',uiEnabled:!1,active:!1},line:{title:"Line",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <line x1="8" y1="50" x2="24" y2="20" stroke="currentColor" stroke-width="8"/>\n <line x1="24" y1="20" x2="40" y2="54" stroke="currentColor" stroke-width="8"/>\n <line x1="40" y1="54" x2="54" y2="10" stroke="currentColor" stroke-width="8"/>\n <circle cx="8" cy="50" r="6" fill="white" stroke="currentColor" stroke-width="4.5"/>\n <circle cx="24" cy="20" r="6" fill="white" stroke="currentColor" stroke-width="4.5"/>\n <circle cx="40" cy="54" r="6" fill="white" stroke="currentColor" stroke-width="4.5"/>\n <circle cx="54" cy="10" r="6" fill="white" stroke="currentColor" stroke-width="4.5"/>\n</svg>\n',uiEnabled:!1,active:!1},rectangle:{title:"Rectangle",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n \x3c!-- Rectangle --\x3e\n <polygon points="10,10 54,10 54,54 10,54" fill="none" stroke="currentColor" stroke-width="8"/>\n\n \x3c!-- Vertex Circles --\x3e\n <circle cx="10" cy="10" r="6" fill="white" stroke="currentColor" stroke-width="4.5"/>\n <circle cx="54" cy="10" r="6" fill="white" stroke="currentColor" stroke-width="4.5"/>\n <circle cx="54" cy="54" r="6" fill="white" stroke="currentColor" stroke-width="4.5"/>\n <circle cx="10" cy="54" r="6" fill="white" stroke="currentColor" stroke-width="4.5"/>\n</svg>\n',uiEnabled:!1,active:!1},polygon:{title:"Polygon",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n \x3c!-- Polygon --\x3e\n <polygon points="8,28 40,6 55,35 51,55 18,54" fill="none" stroke="currentColor" stroke-width="8"/>\n\n \x3c!-- Vertex Circles --\x3e\n <circle cx="9" cy="28" r="6" fill="white" stroke="currentColor" stroke-width="4.5"/>\n <circle cx="40" cy="8" r="6" fill="white" stroke="currentColor" stroke-width="4.5"/>\n <circle cx="55" cy="35" r="6" fill="white" stroke="currentColor" stroke-width="4.5"/>\n <circle cx="50" cy="55" r="6" fill="white" stroke="currentColor" stroke-width="4.5"/>\n <circle cx="18" cy="54" r="6" fill="white" stroke="currentColor" stroke-width="4.5"/>\n</svg>\n',uiEnabled:!1,active:!1},freehand:{title:"Freehand",icon:'<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 64 64">\n <path d="M44.698 2.661a1.644 1.644 0 0 1 2.328 0l9.866 9.866a1.644 1.644 0 0 1 0 2.329L24.004 47.744a1.644 1.644 0 0 1-.552.362L7.008 54.683a1.644 1.644 0 0 1-2.138-2.138l6.578-16.444a1.644 1.644 0 0 1 .362-.552zm-3.089 7.742 7.542 7.541 4.252-4.252-7.541-7.541zm5.216 9.866-7.54-7.54-21.378 21.376v.964h1.644a1.644 1.644 0 0 1 1.645 1.644v1.645h1.644a1.644 1.644 0 0 1 1.645 1.644v1.644h.963zM14.724 37.29l-.35.348L9.35 50.204l12.566-5.025.349-.35a1.644 1.644 0 0 1-1.07-1.538v-1.645h-1.644a1.644 1.644 0 0 1-1.644-1.644v-1.644h-1.644a1.644 1.644 0 0 1-1.54-1.07"/>\n <path stroke="currentColor" stroke-width="5.107"\n d="M6.298 59.53c3.44-1.692 6.88-3.384 10.558-4.319s7.594-1.111 11.719-.298c4.125.814 8.459 2.617 13.483 2.655 5.023.038 10.737-1.689 16.45-3.415"/>\n</svg>\n',uiEnabled:!1,active:!1},custom_shape:{title:"Custom shape",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <circle cx="49.754" cy="50.219" r="10.098" fill="none" stroke="currentColor" stroke-width="5.1"/>\n <path fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="4.491"\n d="M44.516 26.657H17.842l6.669-11.55 6.668-11.55 6.669 11.55Z"/>\n <path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="6"\n stroke-width="4.683" d="M4.481 40.605h20.761v19.093H4.481z"/>\n</svg>\n',uiEnabled:!1,active:!1,options:[{type:"select",label:"Shape",name:"shape",value:{title:"Triangle",value:'{"type":"Feature","properties":{"shape":"polygon"},"geometry":{"type":"MultiPolygon","coordinates":[[[[4,51.2],[5.4,52.4],[6.8,51.2],[4,51.2]]]]}}'},choices:[{title:"Triangle",value:'{"type":"Feature","properties":{"shape":"polygon"},"geometry":{"type":"MultiPolygon","coordinates":[[[[4,51.2],[5.4,52.4],[6.8,51.2],[4,51.2]]]]}}'},{title:"Rectangle",value:'{"type":"Feature","properties":{"shape":"rectangle"},"geometry":{"type":"Polygon","coordinates":[[[-0.47,51.67],[1.43,51.67],[1.43,53.32],[-0.47,53.32],[-0.47,51.67]]]}}'}]}]}},edit:{drag:{title:"Drag",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path\n fill="currentColor"\n d="M32 61.4 19.85 49.42l3.28-3.235 6.634 6.542V34.205H10.98l6.26 6.174-3.279 3.234L2.185 32l11.852-11.686 3.28 3.234-6.336 6.247h18.783V11.273l-6.261 6.174-3.28-3.234L32 2.6l11.777 11.613-3.28 3.234-6.26-6.174v18.522h18.782l-6.26-6.174 3.279-3.234L61.815 32 50.038 43.613l-3.28-3.234 6.261-6.174H34.236v18.522l6.634-6.542 3.28 3.234z"\n />\n</svg>\n',uiEnabled:!1,active:!1},change:{title:"Change",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path d="m22.775 29.562 6.75-6.75-5.625-5.625-3.6 3.6-3.15-3.15 3.6-3.6-5.626-5.55-6.75 6.75zm25.95 26.101 6.75-6.825-5.624-5.625-3.6 3.6-3.15-3.15 3.6-3.6-5.55-5.55-6.75 6.75zm.6-46.126 5.25 5.25ZM16.7 59.039H5v-11.7l14.55-14.551L2 15.237l13.05-13.2L32.75 19.661 46.1 6.312q.676-.676 1.5-.976.826-.3 1.65-.3.826 0 1.65.3.826.3 1.5.976l5.326 5.325q.675.675.975 1.5.3.825.3 1.65t-.3 1.65q-.3.825-.975 1.5l-13.35 13.35L62 48.913l-13.125 13.05-17.551-17.55Zm-7.2-4.5h5.25l29.476-29.552-5.25-5.25L9.5 49.288ZM41.6 22.361l-2.625-2.625 5.25 5.25Z"\n fill="currentColor"\n style="stroke-width:.0750028"/>\n</svg>\n',uiEnabled:!1,active:!1},rotate:{title:"Rotate",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="currentColor"\n d="M58.709 17.724c-.3-.6-.601-.901-.902-1.502l-.3-.601c-.301-.601-.602-.902-.902-1.503l-.3-.601c-.301-.601-.602-.902-1.203-1.503l-.6-.901 8.414-9.317-13.825.3-13.824.301 1.502 13.524 1.503 13.524 9.617-10.819v.3l.3.602c.301.3.301.6.602.6l.3.602c0 .6 0 .901.3 1.202.903 2.104 1.804 4.208 2.105 6.311.6 4.208 0 8.716-1.804 12.623l-.6 1.202-.301.3-.902 1.503-.3.601c-.601.601-1.202 1.503-1.804 2.104-1.502 1.503-3.305 3.005-5.109 3.907-1.803 1.202-3.907 1.803-6.311 2.404-2.104.301-4.508.601-6.612.301-2.404-.3-4.508-.902-6.612-1.503-2.103-.901-3.907-2.104-5.71-3.606l-1.202-1.202-.601-.902-.601-.601c-.3-.3-.601-.601-.601-.902l-.902-1.202-.3-.3-.602-1.203c0-.3-.3-.3-.3-.6l-.902-1.503-.3-.601-.902-2.705q-.901-3.607-.901-7.213V27.04c0-.601 0-.901.3-1.202l.3-1.803.602-1.803c.901-2.405 2.103-4.509 3.606-6.612q2.254-3.156 5.41-5.41c.6-.3.901-1.202.3-1.803-.3-.3-.6-.601-.901-.601h-.601l-.3.3c-2.706 1.202-4.81 3.006-6.913 4.809-2.104 2.104-3.607 4.508-5.11 7.213-2.704 5.41-3.606 11.42-2.404 17.431.3 1.503.601 2.705.902 4.207l.902 2.405c.3.3.6.6.6 1.202l.602 1.202c0 .3.3.601.3.601l.902 1.503c.3.601.6.901.901 1.503l.301.6c.3.301.601.902.902 1.203l2.103 1.803c2.104 2.104 4.809 3.907 7.514 5.41q4.057 2.254 9.016 2.705c1.503.3 3.005.3 4.508.3 1.803 0 3.306 0 4.809-.3 3.005-.602 6.311-1.503 9.016-3.006l.6-.3c.602-.3.903-.601 1.504-.902l2.103-1.202c.601-.3.902-.601 1.203-.902l.6-.6a3.622 3.622 0 0 0 1.503-1.504l.3-.3c.902-.902 2.105-2.104 2.706-3.005l1.803-2.705 1.202-1.804c3.005-5.71 4.208-12.322 3.306-18.633-.601-3.306-1.503-6.612-3.005-9.317z"/>\n</svg>\n',uiEnabled:!1,active:!1},scale:{title:"Scale",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <g fill="currentColor" stroke="currentColor">\n <path d="m37.62 5.028-.337.284-4.039 4.068 3.547 3.523L39.875 9.8l2.846.596 1.025-4.893-4.176-.877Zm9.995 6.393 9.787 2.053 1.026-4.895-9.787-2.05zm14.68 3.078 9.787 2.05 1.025-4.892-9.787-2.053zm-39.623 5.522 3.547 3.523 7.049-7.094-3.547-3.523zm-10.57 10.642 3.546 3.524 7.047-7.094-3.547-3.524zM1.529 41.306l3.55 3.523 7.046-7.096-3.547-3.523Zm70.977 4.027 3.91 3.115 3.44-4.387-1.118-6.55zM.947 48.319l5.617 8.274 4.137-2.809-5.617-8.273Zm62.211 8.744 3.91 3.116 6.233-7.82-3.91-3.116zM9.373 60.73l5.62 8.272 4.134-2.809-5.617-8.271zm44.438 8.067 3.91 3.115 6.232-7.82-3.91-3.117zM17.8 73.138l5.617 8.273 4.137-2.808-5.617-8.274zm26.662 7.388 3.91 3.116 6.232-7.82-3.91-3.116zm-18.236 5.022 5.617 8.273 4.136-2.81-5.617-8.272zm8.888 6.709 3.91 3.117 6.233-7.822-3.91-3.115z"\n stroke-width="3"\n transform="translate(2.517 1.586) scale(.60827)"/>\n <path d="M22.672 20.02a3.5 3.5 0 0 0-2.506 1.034L-.514 41.872a3.5 3.5 0 0 0-.412 4.434L18 74.176a3.5 3.5 0 0 0 5.633.216l33.494-42.038a3.5 3.5 0 0 0-2.018-5.605l-31.742-6.654a3.5 3.5 0 0 0-.695-.074zm1.121 7.317 24.32 5.098-26.992 33.877L6.484 44.759Z"\n stroke-width="3"\n transform="translate(2.517 1.586) scale(.60827)"/>\n <path d="m78.734 7.668 2.61 11.396-18.145 4.154 2.705 11.816L84.05 30.88l2.609 11.396L100 21.011Z"\n stroke-width="3"\n transform="translate(1.586 1.586) scale(.60827)"/>\n </g>\n</svg>\n',uiEnabled:!1,active:!1},copy:{title:"Copy",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="currentColor"\n d="M41.687.926a2.173 2.173 0 0 0-.433.045c-4.075.232-7.358 3.618-7.358 7.747 0 .084.01.164.012.246l-12.987 4.261a7.842 7.842 0 0 0-6.126-3.563 2.173 2.173 0 0 0-.424-.043 2.173 2.173 0 0 0-.435.044c-4.073.232-7.358 3.618-7.358 7.747 0 3.143 1.901 5.869 4.604 7.097L8.377 35.11a2.173 2.173 0 0 0-.028.007C4.274 35.35.99 38.736.99 42.865c0 4.277 3.514 7.791 7.791 7.791 2.497 0 4.727-1.201 6.157-3.048l12.887 6.235a7.67 7.67 0 0 0-.139 1.44c0 4.277 3.515 7.791 7.792 7.791 4.278 0 7.793-3.514 7.793-7.792a7.67 7.67 0 0 0-1.885-5.027l.508-1.05-3.263-1.579 4.505-29.969.888-.29-.368-1.122a7.78 7.78 0 0 0 2.28-1.018l.447 1.364 4.72-1.547-.774-2.359-2.522.826a7.73 7.73 0 0 0 1.672-4.793c0-4.132-3.288-7.52-7.368-7.748a2.173 2.173 0 0 0-.424-.044zm0 4.346a3.414 3.414 0 0 1 3.447 3.446 3.415 3.415 0 0 1-3.446 3.447 3.414 3.414 0 0 1-3.446-3.447 3.414 3.414 0 0 1 3.445-3.446zm20.076 3.725a1.242 1.242 0 0 0-.382.062l-1.612.528.578 1.76-.293 1.94 2.456.37.486-3.234a1.242 1.242 0 0 0-1.233-1.426Zm-4.354 1.364-4.72 1.548.775 2.36 4.719-1.548-.774-2.36zm-22.153 2.732a7.877 7.877 0 0 0 3.735 2.922l-.062.408-.397.13.26.793-4.255 28.298-3.818-1.847-1.082 2.235 3.718 1.798a7.841 7.841 0 0 0-3.543 2.147l-13.272-6.42c.02-.23.035-.458.035-.692 0-2.888-1.609-5.408-3.969-6.745l2.912-11.012c3.74-.562 6.645-3.81 6.645-7.698l-.001-.02 13.094-4.297zm-20.885.87a3.414 3.414 0 0 1 3.445 3.447 3.414 3.414 0 0 1-3.445 3.447 3.414 3.414 0 0 1-3.447-3.447 3.414 3.414 0 0 1 3.446-3.446zm45.314 1.78-.738 4.912 2.456.37.738-4.912zM36.172 17.33l-1.793.588a1.242 1.242 0 0 0-.813.862l-.788 2.978 2.401.634.615-2.325 1.15-.377-.773-2.36zm22.405 5.781-.737 4.913 2.455.368.739-4.91zm-26.432 1.048-1.27 4.802 2.401.634 1.27-4.802zm25.325 6.32-.739 4.913 2.457.368.738-4.911-2.456-.37zm-27.23.882-1.27 4.802 2.402.634 1.27-4.801zm26.124 6.486-.739 4.91 2.455.37.74-4.912-2.457-.368zm-28.027.717-1.27 4.803 2.4.634 1.27-4.802-2.401-.634zm-19.555.856a3.414 3.414 0 0 1 3.446 3.446 3.414 3.414 0 0 1-3.446 3.447 3.414 3.414 0 0 1-3.445-3.447 3.414 3.414 0 0 1 3.445-3.446zm46.473 5.795-.739 4.91 2.456.37.74-4.911zm-11.124 5.072-1.082 2.236 4.47 2.164 1.083-2.237zm-8.651 1.55a3.414 3.414 0 0 1 3.445 3.446 3.414 3.414 0 0 1-3.445 3.447 3.414 3.414 0 0 1-3.447-3.447 3.414 3.414 0 0 1 3.446-3.446zm18.669.745-.358 2.378-2.953-1.428-1.083 2.236 4.472 2.163.541-1.117 1.228.183.608-4.046-2.455-.37z"/>\n</svg>\n',uiEnabled:!1,active:!1},cut:{title:"Cut",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path stroke="currentColor" fill="currentColor" stroke-width="2"\n d="M44.095 2.247a2.285 2.285 0 0 0-.135.04L12.025 12.762a2.285 2.285 0 0 0-1.497 1.588l-7.772 29.4a2.285 2.285 0 0 0 1.213 2.641L35.397 61.6a2.285 2.285 0 0 0 2.873-.754l22.64-32.582a2.285 2.285 0 0 0 .05-2.534L46.6 3.23a2.285 2.285 0 0 0-2.504-.982ZM43.7 7.182l12.203 19.12-5.167 1.76 1.052 3.09 2.031-.693L38.07 53.122l.01-1.375-3.262-.023-.034 4.5-27.13-13.127 6.975-26.38Zm3.946 21.932-6.18 2.105 1.052 3.09 6.18-2.105zm-9.27 3.157-2.329.793a1.632 1.632 0 0 0-1.105 1.534l-.03 4.068 3.265.024.02-2.91 1.232-.419zm-3.488 9.66-.047 6.529 3.264.023.048-6.528z"/>\n</svg>\n',uiEnabled:!1,active:!1},split:{title:"Split",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <g fill="currentColor">\n <path d="m4.879 2.684-2.832 2.8L7.65 11.15l2.832-2.801Zm8.403 8.495-2.832 2.802 5.603 5.662 2.831-2.802zm8.404 8.494-2.832 2.8 5.602 5.664 2.832-2.802z"\n />\n <path d="M27.814 7.408a3.576 3.576 0 0 0-1.161-.176 3.2 3.2 0 0 0-.878.138l7.963 26.068L7.18 27.3c-.543 2.352 1.67 6.055 4.962 6.816l23.054 5.297 2.326 6.42c-2.27-.175-4.279 1.912-4.908 3.805-.535 1.698-.512 3.656.085 5.61.597 1.954 1.671 3.59 3.064 4.7 1.393 1.11 3.238 1.71 5.023 1.164 8.064-3.039 2.135-15.793.467-20.58 5.917 1.023 18.77 5.88 20.578-1.979.42-1.819-.306-3.616-1.509-4.929-1.203-1.313-2.909-2.27-4.9-2.73-1.99-.46-3.866-.547-5.602.303-1.737.849-3.768 2.642-3.468 4.73a6.17 6.17 0 0 0 .012.43l-6.563-1.794-6.88-22.632c-.702-2.297-3.445-3.99-5.108-4.523Zm26.824 26.88c1.36.315 2.472.99 3.116 1.692.644.703.795 1.307.684 1.79-.112.482-.511.956-1.399 1.305-.887.348-2.182.467-3.542.152-1.361-.314-2.472-.99-3.116-1.693-.644-.703-.797-1.304-.686-1.787.112-.482.513-.956 1.4-1.305a5.198 5.198 0 0 1 1.594-.327 6.98 6.98 0 0 1 1.949.173zM37.846 49.174c.333.069.71.25 1.13.585.746.594 1.497 1.654 1.905 2.99.408 1.335.379 2.635.092 3.545-.287.91-.731 1.34-1.205 1.484-.473.145-1.085.036-1.831-.558-.746-.594-1.496-1.655-1.904-2.99-.407-1.336-.378-2.637-.092-3.546.287-.91.732-1.342 1.206-1.486.118-.036.245-.057.38-.058.102 0 .207.011.319.034z"\n />\n </g>\n</svg>\n',uiEnabled:!1,active:!1},union:{title:"Union",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="currentColor"\n d="M41.233 7.917c-5.5 0-10.519 2.077-14.328 5.482a21.443 21.443 0 0 0-4.138-.404c-11.88 0-21.544 9.664-21.544 21.544s9.664 21.544 21.544 21.544c5.5 0 10.519-2.077 14.328-5.482 1.34.263 2.722.404 4.138.404 11.88 0 21.544-9.664 21.544-21.544S53.113 7.917 41.233 7.917zm-9.969 6.791a21.61 21.61 0 0 1 5.598 3.499l-2.01 2.33a18.557 18.557 0 0 0-4.8-2.999Zm-7.927 2.765 2.557 1.714a18.558 18.558 0 0 0-2.396 5.128l-2.955-.86a21.614 21.614 0 0 1 2.794-5.982zm15.86 3.08a21.413 21.413 0 0 1 3.46 5.628l-2.839 1.188a18.357 18.357 0 0 0-2.963-4.817zm-19.334 6.142 3.053.399a18.348 18.348 0 0 0 .144 5.654l-3.027.552a21.407 21.407 0 0 1-.17-6.605Zm23.834 2.63a21.81 21.81 0 0 1 .548 3.263c.1 1.1.115 2.207.044 3.31l-3.07-.195c.12-1.888-.056-3.8-.511-5.64zm-19.918 6.172a18.37 18.37 0 0 0 2.64 5.003l-2.466 1.84a21.427 21.427 0 0 1-3.083-5.84Zm17.042 3.016 3.004.666a21.486 21.486 0 0 1-2.404 6.15l-2.66-1.547a18.434 18.434 0 0 0 2.06-5.27zm-12.535 4.124a18.554 18.554 0 0 0 4.6 3.302l-1.392 2.744a21.611 21.611 0 0 1-5.363-3.85Z"/>\n</svg>\n',uiEnabled:!1,active:!1},difference:{title:"Difference",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="currentColor"\n d="m41.478 7.967-.033 3.069c1.887.02 3.772.337 5.561.933l.97-2.913a21.337 21.337 0 0 0-6.498-1.09Zm-3.294.215a21.567 21.567 0 0 0-6.298 1.915l1.332 2.766a18.518 18.518 0 0 1 5.401-1.641zm12.836 2.155-1.402 2.73a18.497 18.497 0 0 1 4.572 3.312l2.16-2.179a21.548 21.548 0 0 0-5.331-3.863ZM22.783 13.06c-11.848 0-21.486 9.638-21.486 21.486 0 11.849 9.638 21.486 21.486 21.486a21.37 21.37 0 0 0 14.288-5.466c.003 0 .006 0 .009.002.04-.036.078-.075.117-.11l.077-.072a21.285 21.285 0 0 0 1.51-1.532 22.128 22.128 0 0 0 .867-1.025 19.557 19.557 0 0 1-.88-.095c-.196-.025-.389-.058-.582-.09-.097-.015-.194-.028-.29-.045a18.378 18.378 0 0 1-1.576-.359l-.118-.03c-7.753-2.172-13.422-9.271-13.422-17.728a18.34 18.34 0 0 1 5.867-13.478c.1-.093.199-.185.3-.276.153-.136.31-.268.467-.4.097-.08.193-.163.291-.242.255-.203.514-.402.78-.592a21.534 21.534 0 0 0-1.76-.592l-.018-.005c-.176-.05-.355-.095-.533-.141-.132-.035-.263-.073-.397-.105-.213-.051-.43-.095-.646-.14-.077-.016-.153-.035-.231-.05H26.9a21.37 21.37 0 0 0-4.118-.4Zm35.728 3.64-2.472 1.82a18.424 18.424 0 0 1 2.61 5.004l2.907-.986a21.474 21.474 0 0 0-3.045-5.839Zm3.864 9.034-3.022.534c.328 1.86.37 3.772.118 5.642l3.042.409a21.448 21.448 0 0 0-.138-6.585zm-3.496 8.943a18.539 18.539 0 0 1-2.416 5.104l2.543 1.72a21.586 21.586 0 0 0 2.815-5.952zM54.703 42a18.288 18.288 0 0 1-4.428 3.492l1.505 2.675a21.348 21.348 0 0 0 5.173-4.08zm-6.995 4.69a18.512 18.512 0 0 1-5.526 1.158l.163 3.065a21.56 21.56 0 0 0 6.444-1.35z"/>\n</svg>\n',uiEnabled:!1,active:!1},line_simplification:{title:"Line simplification",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="currentColor"\n d="M1.947 25.554c-2.176 3.77-.867 8.656 2.903 10.832 2.126 1.229 4.607 1.346 6.757.539l8.252 12.152a7.79 7.79 0 0 0-.701 1.005c-2.176 3.77-.867 8.656 2.903 10.833 3.77 2.177 8.655.867 10.832-2.903 2.1-3.64.93-8.294-2.543-10.572a2.211 2.211 0 0 0-.36-.26 2.211 2.211 0 0 0-.404-.181 7.955 7.955 0 0 0-6.086-.432l-8.348-12.292c.19-.252.369-.512.53-.79 1.457-2.526 1.339-5.537-.03-7.907l8.202-8.256c3.494 1.335 7.562.025 9.575-3.229l13.899 2.913c.266 2.435 1.634 4.721 3.899 6.03 3.77 2.176 8.655.866 10.832-2.904 2.101-3.64.93-8.294-2.543-10.572a2.211 2.211 0 0 0-.36-.26 2.211 2.211 0 0 0-.403-.181c-3.71-1.87-8.328-.556-10.429 3.083-.084.147-.155.297-.228.446l-13.5-2.83c-.053-2.55-1.329-5.023-3.58-6.499a2.211 2.211 0 0 0-.358-.259 2.211 2.211 0 0 0-.405-.181c-3.708-1.87-8.326-.556-10.428 3.083-1.61 2.79-1.307 6.19.486 8.652l-7.84 7.892a2.211 2.211 0 0 0-.094-.036c-3.71-1.87-8.328-.556-10.429 3.084zm3.83 2.211a3.473 3.473 0 0 1 4.79-1.282 3.472 3.472 0 0 1 1.284 4.789 3.473 3.473 0 0 1-4.79 1.284 3.475 3.475 0 0 1-1.283-4.79ZM23.656 8.173a3.474 3.474 0 0 1 4.79-1.283 3.472 3.472 0 0 1 1.283 4.79 3.473 3.473 0 0 1-4.789 1.284 3.475 3.475 0 0 1-1.284-4.791zm-.666 44.12a3.474 3.474 0 0 1 4.79-1.283 3.472 3.472 0 0 1 1.283 4.79 3.473 3.473 0 0 1-4.79 1.284 3.475 3.475 0 0 1-1.283-4.791zm29.166-37.88a3.474 3.474 0 0 1 4.79-1.283 3.472 3.472 0 0 1 1.283 4.79 3.473 3.473 0 0 1-4.79 1.284 3.475 3.475 0 0 1-1.283-4.791z"/>\n <path fill="currentColor"\n d="M12.9 13.516c-.63.177-.685.37-.88.95l-1.069 3.18 2.995 1.006.844-2.506 2.074-.882-1.236-2.908zm19.209 5.25 4.378 4.554 2.277-2.19-4.379-4.554zm8.132 3.106 1.441 2.812 5.623-2.882-1.441-2.812zM5.448 46.082l3.144.304.608-6.29-3.145-.303zm4.623 3.728 5.762 2.592 1.297-2.88-5.762-2.593z"/>\n</svg>\n',uiEnabled:!1,active:!1},lasso:{title:"Lasso select",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <ellipse cx="4.907" cy="-32.051" fill="none" stroke="currentColor" stroke-dasharray="13.7543, 6.87718"\n stroke-width="5.489" rx="20.4" ry="13.713" transform="matrix(-.71127 .70292 -.86047 -.5095 0 0)"/>\n <path fill="currentColor"\n d="M34.597 25.275a1.934 1.934 0 0 0-2.04 2.165l2.922 31.37c.188 1.523 1.989 2.235 3.165 1.249l6.169-5.004 2.765 4.79c1.59 2.756 4.115 3.431 6.87 1.841 2.756-1.59 3.433-4.114 1.841-6.87l-2.755-4.773 7.31-2.803c1.443-.525 1.728-2.44.503-3.365L35.64 25.66a1.93 1.93 0 0 0-1.042-.383z"/>\n</svg>\n',uiEnabled:!1,active:!1},delete:{title:"Delete",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="currentColor"\n d="M39.063 42.14 22.288 28.12 7.96 44.603l11.338 9.854h9.059zm-3.498 12.317h25.941v5.465h-44.25L4.377 48.726a5.465 5.465 0 0 1-.542-7.711L34.311 5.958a5.465 5.465 0 0 1 7.712-.538l16.496 14.343a5.465 5.465 0 0 1 .541 7.709z"\n style="stroke-width:2.73262"/>\n</svg>\n',uiEnabled:!1,active:!1}},helper:{shape_markers:{title:"Shape markers",icon:null,uiEnabled:!1,active:!1},snapping:{title:"Snapping",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="currentColor" fill-rule="evenodd"\n d="M19.435 3.417c-4.478 0-8.96 1.693-12.343 5.076-6.766 6.766-6.766 17.913 0 24.679h.006c2.754 2.749 5.563 5.561 8.357 8.357 1.857 1.859 3.696 3.696 5.553 5.553l.949.949 1.892 1.898 9.496-9.49-1.898-1.898-6.502-6.502c-2.796-2.797-5.6-5.606-8.363-8.362-1.65-1.653-1.652-4.042 0-5.694 1.653-1.653 4.047-1.653 5.7 0l8.357 8.362 6.502 6.502 1.898 1.893 9.49-9.49-1.893-1.893-6.507-6.502-8.357-8.362c-3.384-3.383-7.86-5.076-12.337-5.076Zm0 2.68c3.789 0 7.577 1.432 10.439 4.294l8.357 8.362-5.694 5.694-8.357-8.362a6.7 6.7 0 0 0-9.496 0 6.697 6.697 0 0 0 0 9.49c2.76 2.755 5.566 5.564 8.363 8.362l-5.694 5.694c-2.795-2.796-5.601-5.607-8.357-8.357H8.99c-5.724-5.724-5.724-15.16 0-20.883 2.861-2.862 6.655-4.294 10.444-4.294ZM57.709 29.03a4.266 4.266 0 0 0-4.268 4.268c0 1.594.881 2.973 2.176 3.707-.714 4.997-1.424 10.107-2.176 15.037-.934 0-1.792.309-2.495.818l-7.115-5.07a4.25 4.25 0 0 0 .115-.965 4.27 4.27 0 1 0-4.268 4.268 4.23 4.23 0 0 0 2.732-1.012l6.973 4.965a4.22 4.22 0 0 0-.215 1.269 4.27 4.27 0 0 0 4.273 4.268 4.266 4.266 0 0 0 4.268-4.268 4.247 4.247 0 0 0-1.657-3.356l2.208-15.446c2.095-.273 3.722-2.045 3.722-4.215a4.27 4.27 0 0 0-4.273-4.268z"\n />\n</svg>\n',uiEnabled:!1,active:!1},pin:{title:"Pin",icon:'\ufeff<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="currentColor"\n d="M42.012 2.106a4.092 4.092 0 0 0-5.741.735 4.092 4.092 0 0 0 .572 5.607L23.964 23.45a8.185 8.185 0 0 0-10.458 2.142l5.18 4.005 5.454 4.218L7.87 59.22a1.124 7.304 37.712 0 0 1.54 1.19l20.494-22.138 5.454 4.217 5.18 4.005a8.185 8.185 0 0 0-.558-10.66l11.277-16.24a4.092 4.092 0 0 0 5.572-.858 4.092 4.092 0 0 0-.735-5.74z"/>\n</svg>\n',uiEnabled:!1,active:!1},snap_guides:{title:"Snap guides",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path stroke="currentColor"\n stroke-width="3.8"\n d="m2.155 32.345 42.35-29.82M18.963 60.919l42.35-29.82M31.443 2.332l29.82 42.35M2.207 19.515l29.82 42.35"/>\n</svg>\n',uiEnabled:!1,active:!1},measurements:{title:"Measurements",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="currentColor"\n d="M1.717 38.645a2.675 2.668 79.7 0 0-.307 3.769L16.754 60.55a2.675 2.668 79.7 0 0 3.76.312l41.769-35.508a2.675 2.668 79.7 0 0 .307-3.769L47.246 3.45a2.675 2.668 79.7 0 0-3.76-.312zm5.486 2.352 37.702-32.05 11.892 14.056-2.717 2.31-4.458-5.269-2.033 1.729 4.457 5.269-3.11 2.643-4.457-5.268-2.034 1.728 4.458 5.27-3.106 2.64-4.458-5.27-2.033 1.73 4.457 5.268-3.11 2.644-6.194-7.32-2.033 1.728 6.193 7.32-3.11 2.645-4.457-5.269-2.034 1.729 4.458 5.268-3.106 2.64-4.458-5.268-2.033 1.73 4.457 5.268-3.11 2.643-4.457-5.268-2.034 1.729 4.458 5.268-2.098 1.783z"/>\n</svg>\n',uiEnabled:!1,active:!1},auto_trace:{title:"Auto trace line",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="currentColor"\n d="M16.862 2.13 7.297 21.17a2.091 2.091 0 0 0-.193 1.288l4.107 24.166-7.618 13.15 3.619 2.096 7.997-13.804a2.091 2.091 0 0 0 .252-1.397l-4.119-24.235 9.256-18.428Zm40.876.255-1.25 2.49 2.668 1.341 1.25-2.49zm-2.593 5.16-2.68 5.337 2.668 1.341 2.682-5.338zm-4.022 8.007-2.682 5.338 2.67 1.34 2.681-5.337zm-18.67 5.83.055 6.984-11.118.087.056 7.242 11.12-.088.054 6.985 10.521-10.688zm18.927 2.817-2.945.5 1.001 5.89 2.945-.5zm1.502 8.835-2.945.5 1.001 5.89 2.945-.5zm1.502 8.834-2.945.5.74 4.355-.24.413 2.585 1.499.51-.881a1.494 1.494 0 0 0 .18-1zm-3.943 7.854-2.994 5.17 2.584 1.496 2.994-5.169zm-4.492 7.754-1.497 2.584 2.584 1.497 1.498-2.584z"/>\n</svg>\n',uiEnabled:!1,active:!1},geofencing:{title:"Geofencing",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="currentColor"\n d="M31.226 17.87c-4.69 0-8.532 3.832-8.532 8.508 0 1.812.58 3.495 1.558 4.88l5.932 10.255c.831 1.085 1.383.879 2.074-.058l6.543-11.135c.132-.24.236-.493.327-.753a8.396 8.396 0 0 0 .628-3.19c0-4.675-3.841-8.506-8.53-8.506zm0 3.987a4.5 4.5 0 0 1 4.532 4.52 4.5 4.5 0 0 1-4.532 4.521 4.5 4.5 0 0 1-4.534-4.52 4.5 4.5 0 0 1 4.533-4.52z"/>\n <path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="6"\n stroke-width="5" d="M8.97 53.509 4.423 19.145 35.698 4.199l23.88 25.127L43.06 59.801Z"/>\n</svg>\n',uiEnabled:!1,active:!1},zoom_to_features:{title:"Zoom to features",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">\n <path fill="currentColor"\n d="M1.585 1.585V13.75h5.17v1.52H8.58v-1.52h5.17V1.585Zm3.041 3.041h6.083v6.083H4.626Zm9.429 2.13V8.58h3.65V6.755Zm5.475 0V8.58h3.65V6.755Zm5.474 0V8.58h3.65V6.755Zm5.475 0V8.58h3.65V6.755Zm5.475 0V8.58h3.65V6.755Zm5.475 0v1.597a1.521 1.521 0 0 0-.325.152l-15.686 9.758a1.52 1.52 0 0 0-.199 2.437l23.512 20.553a1.52 1.52 0 0 0 2.477-.78l4.212-17.037v.352h1.825v-3.65H55.42v1.524a1.52 1.52 0 0 0-.222-.296L43.002 8.741a1.521 1.521 0 0 0-.182-.16h2.259V6.754Zm5.475 0V8.58h3.65V6.755Zm5.474 0V8.58h3.65V6.755Zm3.042 2.432v3.65h1.825v-3.65Zm-13.752 2.549 10.757 11.137-3.57 14.446-20.087-17.559Zm13.752 2.926v3.65h1.825v-3.65ZM6.755 17.096v3.65H8.58v-3.65zm0 5.475v3.65h1.628a1.52 1.52 0 0 0 1.02.909l12.683 3.406 7.905 12.694c.168.27.417.481.712.602l13.39 4.576a1.52 1.52 0 0 0 1.157-2.814l-12.936-4.389L24.35 28.42a1.52 1.52 0 0 0-.896-.664L10.19 24.193a1.52 1.52 0 0 0-1.61.557v-2.178zm48.665 3.042v3.65h1.825v-3.65ZM6.755 28.046v3.65H8.58v-3.65zm48.665 3.042v3.65h1.825v-3.65ZM6.755 33.52v3.65H8.58v-3.65zm48.665 3.041v3.65h1.825v-3.65ZM6.755 38.996v3.65H8.58v-3.65zm48.665 3.041v3.65h1.825v-3.65zm-35.382.913c-3.454 0-6.287 2.833-6.287 6.287 0 3.076 2.248 5.654 5.179 6.183h-1.225v1.825h3.65V55.42h-.206c2.712-.5 4.777-2.796 5.055-5.59l.002-.002a1.52 1.52 0 0 0 0-1.18c-.314-3.168-2.922-5.698-6.168-5.698zM6.755 44.47v3.65H8.58v-3.65zm13.283 1.521a3.223 3.223 0 0 1 3.246 3.246 3.223 3.223 0 0 1-3.246 3.246 3.223 3.223 0 0 1-3.246-3.246 3.223 3.223 0 0 1 3.246-3.246zm35.382 1.52v2.738h-5.17v12.166h12.165V50.25h-5.17v-2.737ZM6.755 49.946v3.65H8.58v-3.65zm46.536 3.346h6.083v6.083H53.29ZM6.755 55.42v1.825h3.65V55.42H7.668Zm5.475 0v1.825h3.65V55.42zm10.95 0v1.825h3.65V55.42zm5.474 0v1.825h3.65V55.42zm5.475 0v1.825h3.65V55.42zm5.475 0v1.825h3.65V55.42zm5.475 0v1.825h3.65V55.42z"/>\n</svg>\n',uiEnabled:!1,active:!1},click_to_edit:{title:"Click to edit",icon:'<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 64 64">\n <path d="M7.839 34.833c-7.104-9.763-5.332-23.33 4.2-30.266C21.572-2.369 35.03.123 42.13 9.882L56.166 29.17c7.098 9.755 5.329 23.325-4.204 30.262-9.533 6.936-22.989 4.444-30.09-5.315L7.841 34.836Zm5.063-25.476c-6.079 5.766-7.006 15.598-1.634 22.98l.778 1.07 12.002-8.732zm3.43-2.495L27.476 22.18l12.002-8.733-.781-1.073c-5.37-7.38-15.01-9.522-22.367-5.512m25.643 10.014L14.54 36.836l10.762 14.79c5.818 7.997 16.653 9.842 24.163 4.378 7.51-5.465 9.088-16.342 3.267-24.342z"/>\n</svg>\n',uiEnabled:!1,active:!1}}}}),this.sdk.on("gm:loaded",()=>{})}uninstall(){this.sdk=null}enableDrag(){this.geoman.enableGlobalDragMode()}disableDrag(){this.geoman?.disableGlobalDragMode()}enableEdit(){this.geoman?.enableMode("edit","change")}disableEdit(){this.geoman?.disableMode("edit","change")}},e.ErrorManager=class{constructor(){this.errorHandlers=[],this.errorHistory=[],this.maxErrorHistory=100,this.hooks={}}createError(e,t,i,n=!0){const r=new Error(e);return r.code=t,r.details=i,r.recoverable=n,r}addErrorHandler(e){this.errorHandlers.push(e)}removeErrorHandler(e){const t=this.errorHandlers.indexOf(e);t>-1&&this.errorHandlers.splice(t,1)}async handleError(e){this.recordError(e),await this.triggerHook("onError",{error:e});const t=this.errorHandlers.map(t=>{try{return Promise.resolve(t(e))}catch(e){return Promise.resolve()}});if(await Promise.all(t),0===this.errorHandlers.length)throw e}recordError(e){this.errorHistory.push(e),this.errorHistory.length>this.maxErrorHistory&&this.errorHistory.shift()}getErrorHistory(){return[...this.errorHistory]}clearErrorHistory(){this.errorHistory=[]}getErrorStats(){const e=this.errorHistory.length,t=this.errorHistory.filter(e=>e.recoverable).length;return{total:e,recoverable:t,nonRecoverable:e-t}}addHook(e,t){this.hooks[e]||(this.hooks[e]=[]),this.hooks[e].push(t)}removeHook(e,t){if(this.hooks[e]){const i=this.hooks[e].indexOf(t);i>-1&&this.hooks[e].splice(i,1)}}async triggerHook(e,t){if(this.hooks[e]){const i=this.hooks[e].map(e=>{try{return Promise.resolve(e(t))}catch(e){return Promise.resolve()}});await Promise.all(i)}}setupGlobalErrorHandling(){window.addEventListener("unhandledrejection",e=>{const t=this.createError("Unhandled Promise Rejection","UNHANDLED_PROMISE_REJECTION",{reason:e.reason},!1);this.handleError(t)}),window.addEventListener("error",e=>{const t=this.createError(e.message||"Global Error","GLOBAL_ERROR",{filename:e.filename,lineno:e.lineno,colno:e.colno,error:e.error},!1);this.handleError(t)})}destroy(){this.errorHandlers=[],this.errorHistory=[],this.hooks={}}},e.GROUP_ALIASES=f,e.GeoJSONManager=g,e.LAYER_GROUPS={adiz:["adiz-line","adiz-label"],airspace:["airspaceLayer","airspaceLayer_line","airspace_label_center_layer","airspace_label_side_layer"],restricted:["restrictedLayer","restrictedLayer_stroke","restricted_line_label"],controlled:["controlledLayer","controlledLayer_stroke","controlled_line_label"],airline:["airline_radial","airline","airline_label","airline_point"],waypointOffAirway:["waypoint-off-airway-symbol"],vor:["vor_icon_dial","vor_label","vor_icon"],ndb:["ndb_icon"],airport:["airport"],runway:["runway-line","runway-line-amm","runway-label"]},e.LAYER_LABELS={adiz:"防空识别区",airspace:"情报区",restricted:"限制区",controlled:"管制区",airline:"航线",waypointOffAirway:"非航路点",vor:"VOR",ndb:"NDB",airport:"机场",runway:"跑道"},e.LayerManager=m,e.LngLat=r.LngLat,e.LngLatBounds=r.LngLatBounds,e.MapEngine=s,e.MapSDK=H,e.Marker=r.Marker,e.MeasurePlugin=class{constructor(){this.name="measure",this.version="1.0.0",this.sdk=null,this.isActive=!1,this.measureMode=null,this.measurePoints=[],this.measureLayerId="measure-layer"}install(e){this.sdk=e,this.setupEventListeners()}uninstall(e){this.cleanup(),this.sdk=null}enable(e){this.sdk&&(this.isActive=!0,this.measureMode=e,this.measurePoints=[])}disable(){this.isActive=!1,this.measureMode=null,this.measurePoints=[],this.cleanup()}setupEventListeners(){this.sdk&&(this.sdk.on("click",e=>{if(!this.isActive)return;const t=e.lngLat.toArray();this.addMeasurePoint(t)}),this.sdk.on("dblclick",e=>{this.isActive&&(e.preventDefault(),this.finishMeasurement())}))}addMeasurePoint(e){if(this.sdk&&(this.measurePoints.push(e),this.sdk.addPoint(e,{},{paint:{"circle-radius":6,"circle-color":"#ff0000","circle-stroke-width":2,"circle-stroke-color":"#ffffff"}}),this.measurePoints.length>1)){const e=this.measurePoints.slice(-2);this.sdk.addLine(e,{},{paint:{"line-color":"#ff0000","line-width":2,"line-dasharray":[2,2]}})}}finishMeasurement(){if(this.sdk&&!(this.measurePoints.length<2)){if("distance"===this.measureMode){const e=this.calculateDistance();alert(`测量距离: ${e.toFixed(2)} km`)}else if("area"===this.measureMode){const e=this.calculateArea();alert(`测量面积: ${e.toFixed(2)} km²`)}this.cleanup(),this.measurePoints=[]}}calculateDistance(){let e=0;for(let t=1;t<this.measurePoints.length;t++){const[i,n]=this.measurePoints[t-1],[r,o]=this.measurePoints[t];e+=this.haversineDistance(n,i,o,r)}return e}calculateArea(){if(this.measurePoints.length<3)return 0;let e=0;const t=this.measurePoints.length;for(let i=0;i<t;i++){const[n,r]=this.measurePoints[i],[o,s]=this.measurePoints[(i+1)%t];e+=(o-n)*(2+Math.sin(r*Math.PI/180)+Math.sin(s*Math.PI/180))}return e=6371*Math.abs(e)*6371/2,e}haversineDistance(e,t,i,n){const r=(i-e)*Math.PI/180,o=(n-t)*Math.PI/180,s=Math.sin(r/2)*Math.sin(r/2)+Math.cos(e*Math.PI/180)*Math.cos(i*Math.PI/180)*Math.sin(o/2)*Math.sin(o/2);return 6371*(2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s)))}cleanup(){this.sdk}getStatus(){return{isActive:this.isActive,mode:this.measureMode,pointsCount:this.measurePoints.length}}},e.NOTAM=C,e.PerformanceManager=y,e.PluginManager=_,e.Popup=r.Popup,e.TYPEMAP=d,e.WindManager=$,e.default=H,e.globalConfig=T,Object.defineProperty(e,"__esModule",{value:!0})});