mapbox-gl
Version:
A WebGL interactive maps library
1 lines • 625 kB
JavaScript
var mapboxgl=function(){"use strict";function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var e=r;function r(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=r,this.p2y=n}r.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)<e)return r;var s=this.sampleCurveDerivativeX(r);if(Math.abs(s)<1e-6)break;r-=i/s}var a=0,o=1;for(r=t,n=0;n<20&&(i=this.sampleCurveX(r),!(Math.abs(i-t)<e));n++)t>i?a=r:o=r,r=.5*(o-a)+a;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};var n=t(e),i=s;function s(t,e){this.x=t,this.y=e}s.prototype={clone:function(){return new s(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),n=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=n,this},_rotateAround:function(t,e){var r=Math.cos(t),n=Math.sin(t),i=e.y+n*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-n*(this.y-e.y),this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},s.convert=function(t){return t instanceof s?t:Array.isArray(t)?new s(t[0],t[1]):t};var a=t(i);const o=Math.PI/180,l=180/Math.PI;function u(t){return t*o}function c(t){return t*l}function h(t,e,r){return Math.min(r,Math.max(e,t))}function p(t,e,r){const n=r-e,i=((t-e)%n+n)%n+e;return i===e?r:i}function f(t){const e=[];for(const r in t)e.push(t[r]);return e}function d(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}new n(.25,.1,.25,1);let y=1;function m(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}function g(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)}function x(t,e){t.forEach((t=>{e[t]&&(e[t]=e[t].bind(e))}))}function v(t,e){return-1!==t.indexOf(e,t.length-e.length)}function b(t,e,r){const n={};for(const i in t)n[i]=e.call(r||this,t[i],i,t);return n}function w(t){return Array.isArray(t)?t.map(w):"object"==typeof t&&t?b(t,w):t}const _={};function A(t){_[t]||("undefined"!=typeof console&&console.warn(t),_[t]=!0)}function S(t,e,r){return(r.y-t.y)*(e.x-t.x)>(e.y-t.y)*(r.x-t.x)}function M(t){let e=0;for(let r,n,i=0,s=t.length,a=s-1;i<s;a=i++)r=t[i],n=t[a],e+=(n.x-r.x)*(r.y+n.y);return e}function P(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}function I(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,r,n,i)=>{const s=n||i;return e[r]=!s||s.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t}return e}function T(t){try{const e=self[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}}function k(t,e){return[t[4*e],t[4*e+1],t[4*e+2],t[4*e+3]]}function E(t,e,r,n){for(;e<r;){const i=e+r>>1;t[i]<n?e=i+1:r=i}return e}function D(t,e,r,n){for(;e<r;){const i=e+r>>1;t[i]<=n?e=i+1:r=i}return e}var C=z,B=3;function z(t,e,r){var n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var i=new Int32Array(this.arrayBuffer);t=i[0],this.d=(e=i[1])+2*(r=i[2]);for(var s=0;s<this.d*this.d;s++){var a=i[B+s],o=i[B+s+1];n.push(a===o?null:i.subarray(a,o))}var l=i[B+n.length+1];this.keys=i.subarray(i[B+n.length],l),this.bboxes=i.subarray(l),this.insert=this._insertReadonly}else{this.d=e+2*r;for(var u=0;u<this.d*this.d;u++)n.push([]);this.keys=[],this.bboxes=[]}this.n=e,this.extent=t,this.padding=r,this.scale=e/t,this.uid=0;var c=r/e*t;this.min=-c,this.max=t+c}z.prototype.insert=function(t,e,r,n,i){this._forEachCell(e,r,n,i,this._insertCell,this.uid++),this.keys.push(t),this.bboxes.push(e),this.bboxes.push(r),this.bboxes.push(n),this.bboxes.push(i)},z.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},z.prototype._insertCell=function(t,e,r,n,i,s){this.cells[i].push(s)},z.prototype.query=function(t,e,r,n,i){var s=this.min,a=this.max;if(t<=s&&e<=s&&a<=r&&a<=n&&!i)return Array.prototype.slice.call(this.keys);var o=[];return this._forEachCell(t,e,r,n,this._queryCell,o,{},i),o},z.prototype._queryCell=function(t,e,r,n,i,s,a,o){var l=this.cells[i];if(null!==l)for(var u=this.keys,c=this.bboxes,h=0;h<l.length;h++){var p=l[h];if(void 0===a[p]){var f=4*p;(o?o(c[f+0],c[f+1],c[f+2],c[f+3]):t<=c[f+2]&&e<=c[f+3]&&r>=c[f+0]&&n>=c[f+1])?(a[p]=!0,s.push(u[p])):a[p]=!1}}},z.prototype._forEachCell=function(t,e,r,n,i,s,a,o){for(var l=this._convertToCellCoord(t),u=this._convertToCellCoord(e),c=this._convertToCellCoord(r),h=this._convertToCellCoord(n),p=l;p<=c;p++)for(var f=u;f<=h;f++){var d=this.d*f+p;if((!o||o(this._convertFromCellCoord(p),this._convertFromCellCoord(f),this._convertFromCellCoord(p+1),this._convertFromCellCoord(f+1)))&&i.call(this,t,e,r,n,d,s,a,o))return}},z.prototype._convertFromCellCoord=function(t){return(t-this.padding)/this.scale},z.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},z.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=B+this.cells.length+1+1,r=0,n=0;n<this.cells.length;n++)r+=this.cells[n].length;var i=new Int32Array(e+r+this.keys.length+this.bboxes.length);i[0]=this.extent,i[1]=this.n,i[2]=this.padding;for(var s=e,a=0;a<t.length;a++){var o=t[a];i[B+a]=s,i.set(o,s),s+=o.length}return i[B+t.length]=s,i.set(this.keys,s),i[B+t.length+1]=s+=this.keys.length,i.set(this.bboxes,s),s+=this.bboxes.length,i.buffer};var L,V=t(C),R={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function O(t){return(t=Math.round(t))<0?0:t>255?255:t}function F(t){return O("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function j(t){return(e="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e}function U(t,e,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?t+(e-t)*r*6:2*r<1?e:3*r<2?t+(e-t)*(2/3-r)*6:t}try{L={}.parseCSSColor=function(t){var e,r=t.replace(/ /g,"").toLowerCase();if(r in R)return R[r].slice();if("#"===r[0])return 4===r.length?(e=parseInt(r.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:7===r.length&&(e=parseInt(r.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var n=r.indexOf("("),i=r.indexOf(")");if(-1!==n&&i+1===r.length){var s=r.substr(0,n),a=r.substr(n+1,i-(n+1)).split(","),o=1;switch(s){case"rgba":if(4!==a.length)return null;o=j(a.pop());case"rgb":return 3!==a.length?null:[F(a[0]),F(a[1]),F(a[2]),o];case"hsla":if(4!==a.length)return null;o=j(a.pop());case"hsl":if(3!==a.length)return null;var l=(parseFloat(a[0])%360+360)%360/360,u=j(a[1]),c=j(a[2]),h=c<=.5?c*(u+1):c+u-c*u,p=2*c-h;return[O(255*U(p,h,l+1/3)),O(255*U(p,h,l)),O(255*U(p,h,l-1/3)),o];default:return null}}return null}}catch(t){}class Color{constructor(t,e,r,n=1){this.r=t,this.g=e,this.b=r,this.a=n}static parse(t){if(!t)return;if(t instanceof Color)return t;if("string"!=typeof t)return;const e=L(t);return e?new Color(e[0]/255*e[3],e[1]/255*e[3],e[2]/255*e[3],e[3]):void 0}toString(){const[t,e,r,n]=this.toArray();return`rgba(${Math.round(t)},${Math.round(e)},${Math.round(r)},${n})`}toArray(){const{r:t,g:e,b:r,a:n}=this;return 0===n?[0,0,0,0]:[255*t/n,255*e/n,255*r/n,n]}toArray01(){const{r:t,g:e,b:r,a:n}=this;return 0===n?[0,0,0,0]:[t/n,e/n,r/n,n]}toArray01Scaled(t){const{r:e,g:r,b:n,a:i}=this;return 0===i?[0,0,0]:[e/i*t,r/i*t,n/i*t]}toArray01PremultipliedAlpha(){const{r:t,g:e,b:r,a:n}=this;return[t,e,r,n]}toArray01Linear(){const{r:t,g:e,b:r,a:n}=this;return 0===n?[0,0,0,0]:[Math.pow(t/n,2.2),Math.pow(e/n,2.2),Math.pow(r/n,2.2),n]}}Color.black=new Color(0,0,0,1),Color.white=new Color(1,1,1,1),Color.transparent=new Color(0,0,0,0),Color.red=new Color(1,0,0,1),Color.blue=new Color(0,0,1,1);var N=Color;function q(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}class ParsingError extends Error{constructor(t,e){super(e),this.message=e,this.key=t}}var $=ParsingError;class Scope{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,r]of e)this.bindings[t]=r}concat(t){return new Scope(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}var G=Scope;const Y={kind:"null"},Z={kind:"number"},X={kind:"string"},W={kind:"boolean"},K={kind:"color"},J={kind:"object"},H={kind:"value"},Q={kind:"collator"},tt={kind:"formatted"},et={kind:"resolvedImage"};function rt(t,e){return{kind:"array",itemType:t,N:e}}function nt(t){if("array"===t.kind){const e=nt(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const it=[Y,Z,X,W,K,tt,J,rt(H),et];function st(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!st(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of it)if(!st(t,e))return null}return`Expected ${nt(t)} but found ${nt(e)} instead.`}function at(t,e){return e.some((e=>e.kind===t.kind))}function ot(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}class Collator{constructor(t,e,r){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class FormattedSection{constructor(t,e,r,n,i){this.text=t.normalize?t.normalize():t,this.image=e,this.scale=r,this.fontStack=n,this.textColor=i}}class Formatted{constructor(t){this.sections=t}static fromString(t){return new Formatted([new FormattedSection(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.namePrimary.length))}static factory(t){return t instanceof Formatted?t:Formatted.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}serialize(){const t=["format"];for(const e of this.sections){if(e.image){t.push(["image",e.image.namePrimary]);continue}t.push(e.text);const r={};e.fontStack&&(r["text-font"]=["literal",e.fontStack.split(",")]),e.scale&&(r["font-scale"]=e.scale),e.textColor&&(r["text-color"]=["rgba"].concat(e.textColor.toArray())),t.push(r)}return t}}class ResolvedImage{constructor(t){this.namePrimary=t.namePrimary,t.nameSecondary&&(this.nameSecondary=t.nameSecondary),this.available=t.available}toString(){return this.nameSecondary?`[${this.namePrimary},${this.nameSecondary}]`:this.namePrimary}static fromString(t,e){return t?new ResolvedImage({namePrimary:t,nameSecondary:e,available:!1}):null}serialize(){return this.nameSecondary?["image",this.namePrimary,this.nameSecondary]:["image",this.namePrimary]}}function lt(t,e,r,n){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[t,e,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function ut(t){if(null===t)return!0;if("string"==typeof t)return!0;if("boolean"==typeof t)return!0;if("number"==typeof t)return!0;if(t instanceof N)return!0;if(t instanceof Collator)return!0;if(t instanceof Formatted)return!0;if(t instanceof ResolvedImage)return!0;if(Array.isArray(t)){for(const e of t)if(!ut(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!ut(t[e]))return!1;return!0}return!1}function ct(t){if(null===t)return Y;if("string"==typeof t)return X;if("boolean"==typeof t)return W;if("number"==typeof t)return Z;if(t instanceof N)return K;if(t instanceof Collator)return Q;if(t instanceof Formatted)return tt;if(t instanceof ResolvedImage)return et;if(Array.isArray(t)){const e=t.length;let r;for(const e of t){const t=ct(e);if(r){if(r===t)continue;r=H;break}r=t}return rt(r||H,e)}return J}function ht(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof N||t instanceof Formatted||t instanceof ResolvedImage?t.toString():JSON.stringify(t)}class Literal{constructor(t,e){this.type=t,this.value=e}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!ut(t[1]))return e.error("invalid value");const r=t[1];let n=ct(r);const i=e.expectedType;return"array"!==n.kind||0!==n.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(n=i),new Literal(n,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof N?["rgba"].concat(this.value.toArray()):this.value instanceof Formatted?this.value.serialize():this.value}}var pt=Literal,ft=class RuntimeError{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}};const dt={string:X,number:Z,boolean:W,object:J};class Assertion{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let r,n=1;const i=t[0];if("array"===i){let i,s;if(t.length>2){const r=t[1];if("string"!=typeof r||!(r in dt)||"object"===r)return e.error('The item type argument of "array" must be one of string, number, boolean',1);i=dt[r],n++}else i=H;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);s=t[2],n++}r=rt(i,s)}else r=dt[i];const s=[];for(;n<t.length;n++){const r=e.parse(t[n],n,H);if(!r)return null;s.push(r)}return new Assertion(r,s)}evaluate(t){for(let e=0;e<this.args.length;e++){const r=this.args[e].evaluate(t);if(!st(this.type,ct(r)))return r;if(e===this.args.length-1)throw new ft(`Expected value to be of type ${nt(this.type)}, but found ${nt(ct(r))} instead.`)}return null}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=this.type,e=[t.kind];if("array"===t.kind){const r=t.itemType;if("string"===r.kind||"number"===r.kind||"boolean"===r.kind){e.push(r.kind);const n=t.N;("number"==typeof n||this.args.length>1)&&e.push(n)}}return e.concat(this.args.map((t=>t.serialize())))}}var yt=Assertion;class FormatExpression{constructor(t){this.type=tt,this.sections=t}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[1];if(!Array.isArray(r)&&"object"==typeof r)return e.error("First argument must be an image or text section.");const n=[];let i=!1;for(let r=1;r<=t.length-1;++r){const s=t[r];if(i&&"object"==typeof s&&!Array.isArray(s)){i=!1;let t=null;if(s["font-scale"]&&(t=e.parse(s["font-scale"],1,Z),!t))return null;let r=null;if(s["text-font"]&&(r=e.parse(s["text-font"],1,rt(X)),!r))return null;let a=null;if(s["text-color"]&&(a=e.parse(s["text-color"],1,K),!a))return null;const o=n[n.length-1];o.scale=t,o.font=r,o.textColor=a}else{const s=e.parse(t[r],1,H);if(!s)return null;const a=s.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,n.push({content:s,scale:null,font:null,textColor:null})}}return new FormatExpression(n)}evaluate(t){return new Formatted(this.sections.map((e=>{const r=e.content.evaluate(t);return ct(r)===et?new FormattedSection("",r,null,null,null):new FormattedSection(ht(r),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor)}outputDefined(){return!1}serialize(){const t=["format"];for(const e of this.sections){t.push(e.content.serialize());const r={};e.scale&&(r["font-scale"]=e.scale.serialize()),e.font&&(r["text-font"]=e.font.serialize()),e.textColor&&(r["text-color"]=e.textColor.serialize()),t.push(r)}return t}}class ImageExpression{constructor(t,e){this.type=et,this.inputPrimary=t,this.inputSecondary=e}static parse(t,e){if(t.length<2)return e.error("Expected two or more arguments.");const r=e.parse(t[1],1,X);if(!r)return e.error("No image name provided.");if(2===t.length)return new ImageExpression(r);const n=e.parse(t[2],1,X);return n?new ImageExpression(r,n):e.error("Secondary image variant is not a string.")}evaluate(t){const e=ResolvedImage.fromString(this.inputPrimary.evaluate(t),this.inputSecondary?this.inputSecondary.evaluate(t):void 0);return e&&t.availableImages&&(e.available=t.availableImages.indexOf(e.namePrimary)>-1,e.nameSecondary&&e.available&&t.availableImages&&(e.available=t.availableImages.indexOf(e.nameSecondary)>-1)),e}eachChild(t){t(this.inputPrimary),this.inputSecondary&&t(this.inputSecondary)}outputDefined(){return!1}serialize(){return this.inputSecondary?["image",this.inputPrimary.serialize(),this.inputSecondary.serialize()]:["image",this.inputPrimary.serialize()]}}function mt(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}const gt={"to-boolean":W,"to-color":K,"to-number":Z,"to-string":X};class Coercion{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[0],n=[];let i=Y;if("to-array"===r){if(!Array.isArray(t[1]))return null;const r=t[1].length;if(e.expectedType){if("array"!==e.expectedType.kind)return e.error(`Expected ${e.expectedType.kind} but found array.`);i=rt(e.expectedType.itemType,r)}else{if(!(r>0&&ut(t[1][0])))return null;i=rt(ct(t[1][0]),r)}for(let s=0;s<r;s++){const r=t[1][s];let a;if("array"===mt(r))a=e.parse(r,void 0,i.itemType);else{const t=mt(r);if(t!==i.itemType.kind)return e.error(`Expected ${i.itemType.kind} but found ${t}.`);a=e.registry.literal.parse(["literal",void 0===r?null:r],e)}if(!a)return null;n.push(a)}}else{if(("to-boolean"===r||"to-string"===r)&&2!==t.length)return e.error("Expected one argument.");i=gt[r];for(let r=1;r<t.length;r++){const i=e.parse(t[r],r,H);if(!i)return null;n.push(i)}}return new Coercion(i,n)}evaluate(t){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(t));if("color"===this.type.kind){let e,r;for(const n of this.args){if(e=n.evaluate(t),r=null,e instanceof N)return e;if("string"==typeof e){const r=t.parseColor(e);if(r)return r}else if(Array.isArray(e)&&(r=e.length<3||e.length>4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:lt(e[0],e[1],e[2],e[3]),!r))return new N(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new ft(r||`Could not parse color from value '${"string"==typeof e?e:String(JSON.stringify(e))}'`)}if("number"===this.type.kind){let e=null;for(const r of this.args){if(e=r.evaluate(t),null===e)return 0;const n=Number(e);if(!isNaN(n))return n}throw new ft(`Could not convert ${JSON.stringify(e)} to number.`)}return"formatted"===this.type.kind?Formatted.fromString(ht(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?ResolvedImage.fromString(ht(this.args[0].evaluate(t))):"array"===this.type.kind?this.args.map((e=>e.evaluate(t))):ht(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new FormatExpression([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new ImageExpression(this.args[0]).serialize();const t="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild((e=>{t.push(e.serialize())})),t}}var xt=Coercion;const vt=["Unknown","Point","LineString","Polygon"];var bt=class EvaluationContext{constructor(t,e){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=t,this.options=e}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?vt[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}measureLight(t){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const t=this.featureDistanceData.center,e=this.featureDistanceData.scale,{x:r,y:n}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(r*e-t[0])+this.featureDistanceData.bearing[1]*(n*e-t[1])}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=N.parse(t)),e}getConfig(t){return this.options?this.options.get(t):null}};class CompoundExpression{constructor(t,e,r,n,i){this.name=t,this.type=e,this._evaluate=r,this.args=n,this._overloadIndex=i}evaluate(t){if(!this._evaluate){const t=CompoundExpression.definitions[this.name];this._evaluate=Array.isArray(t)?t[2]:t.overloads[this._overloadIndex][1]}return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((t=>t.serialize())))}static parse(t,e){const r=t[0],n=CompoundExpression.definitions[r];if(!n)return e.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);const i=Array.isArray(n)?n[0]:n.type,s=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,a=[];let o=null,l=-1;for(const[n,u]of s){if(Array.isArray(n)&&n.length!==t.length-1)continue;a.push(n),l++,o=new ke(e.registry,e.path,null,e.scope,void 0,e._scope,e.options);const s=[];let c=!1;for(let e=1;e<t.length;e++){const r=t[e],i=Array.isArray(n)?n[e-1]:n.type,a=o.parse(r,1+s.length,i);if(!a){c=!0;break}s.push(a)}if(!c)if(Array.isArray(n)&&n.length!==s.length)o.error(`Expected ${n.length} arguments, but found ${s.length} instead.`);else{for(let t=0;t<s.length;t++){const e=Array.isArray(n)?n[t]:n.type,r=s[t];o.concat(t+1).checkSubtype(e,r.type)}if(0===o.errors.length)return new CompoundExpression(r,i,u,s,l)}}if(1===a.length)e.errors.push(...o.errors);else{const r=(a.length?a:s.map((([t])=>t))).map(wt).join(" | "),n=[];for(let r=1;r<t.length;r++){const i=e.parse(t[r],1+n.length);if(!i)return null;n.push(nt(i.type))}e.error(`Expected arguments of type ${r}, but found (${n.join(", ")}) instead.`)}return null}static register(t,e){CompoundExpression.definitions=e;for(const r in e)t[r]=CompoundExpression}}function wt(t){return Array.isArray(t)?`(${t.map(nt).join(", ")})`:`(${nt(t.type)}...)`}var _t=CompoundExpression;class CollatorExpression{constructor(t,e,r){this.type=Q,this.locale=r,this.caseSensitive=t,this.diacriticSensitive=e}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const r=t[1];if("object"!=typeof r||Array.isArray(r))return e.error("Collator options argument must be an object.");const n=e.parse(void 0!==r["case-sensitive"]&&r["case-sensitive"],1,W);if(!n)return null;const i=e.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,W);if(!i)return null;let s=null;return r.locale&&(s=e.parse(r.locale,1,X),!s)?null:new CollatorExpression(n,i,s)}evaluate(t){return new Collator(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}serialize(){const t={};return t["case-sensitive"]=this.caseSensitive.serialize(),t["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(t.locale=this.locale.serialize()),["collator",t]}}var St={exports:{}};St.exports=function(){function t(r,n,i,s,a){for(;s>i;){if(s-i>600){var o=s-i+1,l=n-i+1,u=Math.log(o),c=.5*Math.exp(2*u/3),h=.5*Math.sqrt(u*c*(o-c)/o)*(l-o/2<0?-1:1);t(r,n,Math.max(i,Math.floor(n-l*c/o+h)),Math.min(s,Math.floor(n+(o-l)*c/o+h)),a)}var p=r[n],f=i,d=s;for(e(r,i,n),a(r[s],p)>0&&e(r,i,s);f<d;){for(e(r,f,d),f++,d--;a(r[f],p)<0;)f++;for(;a(r[d],p)>0;)d--}0===a(r[i],p)?e(r,i,d):e(r,++d,s),d<=n&&(i=d+1),n<=d&&(s=d-1)}}function e(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function r(t,e){return t<e?-1:t>e?1:0}return function(e,n,i,s,a){t(e,n,i||0,s||e.length-1,a||r)}}();var Mt=t(St.exports);function Pt(t){let e=0;for(let r,n,i=0,s=t.length,a=s-1;i<s;a=i++)r=t[i],n=t[a],e+=(n.x-r.x)*(r.y+n.y);return e}function It(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1])}function Tt(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function kt(t,e,r){const n=t[0]-e[0],i=t[1]-e[1],s=t[0]-r[0],a=t[1]-r[1];return n*a-s*i==0&&n*s<=0&&i*a<=0}function Et(t,e,r=!1){let n=!1;for(let o=0,l=e.length;o<l;o++){const l=e[o];for(let e=0,o=l.length,u=o-1;e<o;u=e++){const o=l[u],c=l[e];if(kt(t,o,c))return r;(s=o)[1]>(i=t)[1]!=(a=c)[1]>i[1]&&i[0]<(a[0]-s[0])*(i[1]-s[1])/(a[1]-s[1])+s[0]&&(n=!n)}}var i,s,a;return n}function Dt(t,e,r,n){const i=n[0]-r[0],s=n[1]-r[1],a=(t[0]-r[0])*s-i*(t[1]-r[1]),o=(e[0]-r[0])*s-i*(e[1]-r[1]);return a>0&&o<0||a<0&&o>0}function Ct(t,e,r,n){return 0!=(i=[n[0]-r[0],n[1]-r[1]])[0]*(s=[e[0]-t[0],e[1]-t[1]])[1]-i[1]*s[0]&&!(!Dt(t,e,r,n)||!Dt(r,n,t,e));var i,s}const Bt=8192;function zt(t,e){const r=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,i=Math.pow(2,e.z);return[Math.round(r*i*Bt),Math.round(n*i*Bt)]}function Lt(t,e){for(let r=0;r<e.length;r++)if(Et(t,e[r]))return!0;return!1}function Vt(t,e,r){for(const n of r)for(let r=0,i=n.length,s=i-1;r<i;s=r++)if(Ct(t,e,n[s],n[r]))return!0;return!1}function Rt(t,e){for(let r=0;r<t.length;++r)if(!Et(t[r],e))return!1;for(let r=0;r<t.length-1;++r)if(Vt(t[r],t[r+1],e))return!1;return!0}function Ot(t,e){for(let r=0;r<e.length;r++)if(Rt(t,e[r]))return!0;return!1}function Ft(t,e,r){const n=[];for(let i=0;i<t.length;i++){const s=[];for(let n=0;n<t[i].length;n++){const a=zt(t[i][n],r);It(e,a),s.push(a)}n.push(s)}return n}function jt(t,e,r){const n=[];for(let i=0;i<t.length;i++){const s=Ft(t[i],e,r);n.push(s)}return n}function Ut(t,e,r,n){if(t[0]<r[0]||t[0]>r[2]){const e=.5*n;let i=t[0]-r[0]>e?-n:r[0]-t[0]>e?n:0;0===i&&(i=t[0]-r[2]>e?-n:r[2]-t[0]>e?n:0),t[0]+=i}It(e,t)}function Nt(t,e,r,n){const i=Math.pow(2,n.z)*Bt,s=[n.x*Bt,n.y*Bt],a=[];if(!t)return a;for(const n of t)for(const t of n){const n=[t.x+s[0],t.y+s[1]];Ut(n,e,r,i),a.push(n)}return a}function qt(t,e,r,n){const i=Math.pow(2,n.z)*Bt,s=[n.x*Bt,n.y*Bt],a=[];if(!t)return a;for(const r of t){const t=[];for(const n of r){const r=[n.x+s[0],n.y+s[1]];It(e,r),t.push(r)}a.push(t)}if(e[2]-e[0]<=i/2){(o=e)[0]=o[1]=1/0,o[2]=o[3]=-1/0;for(const t of a)for(const n of t)Ut(n,e,r,i)}var o;return a}class Within{constructor(t,e){this.type=W,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(ut(t[1])){const e=t[1];if("FeatureCollection"===e.type)for(let t=0;t<e.features.length;++t){const r=e.features[t].geometry.type;if("Polygon"===r||"MultiPolygon"===r)return new Within(e,e.features[t].geometry)}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new Within(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new Within(e,e)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if(!i)return!1;if("Polygon"===e.type){const s=Ft(e.coordinates,n,i),a=Nt(t.geometry(),r,n,i);if(!Tt(r,n))return!1;for(const t of a)if(!Et(t,s))return!1}if("MultiPolygon"===e.type){const s=jt(e.coordinates,n,i),a=Nt(t.geometry(),r,n,i);if(!Tt(r,n))return!1;for(const t of a)if(!Lt(t,s))return!1}return!0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if(!i)return!1;if("Polygon"===e.type){const s=Ft(e.coordinates,n,i),a=qt(t.geometry(),r,n,i);if(!Tt(r,n))return!1;for(const t of a)if(!Rt(t,s))return!1}if("MultiPolygon"===e.type){const s=jt(e.coordinates,n,i),a=qt(t.geometry(),r,n,i);if(!Tt(r,n))return!1;for(const t of a)if(!Ot(t,s))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}var $t=Within,Gt={exports:{}};Gt.exports=function(){var t={kilometers:1,miles:1e3/1609.344,nauticalmiles:1e3/1852,meters:1e3,metres:1e3,yards:1e3/.9144,feet:1e3/.3048,inches:1e3/.0254},e=1/298.257223563,r=e*(2-e),n=Math.PI/180,i=function(e,i){if(void 0===e)throw new Error("No latitude given.");if(i&&!t[i])throw new Error("Unknown unit "+i+". Use one of: "+Object.keys(t).join(", "));var s=6378.137*n*(i?t[i]:1),a=Math.cos(e*n),o=1/(1-r*(1-a*a)),l=Math.sqrt(o);this.kx=s*l*a,this.ky=s*l*o*(1-r)},s={units:{configurable:!0}};function a(t,e){return t[0]===e[0]&&t[1]===e[1]}function o(t,e,r){var n=l(e[0]-t[0]);return[t[0]+n*r,t[1]+(e[1]-t[1])*r]}function l(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}return i.fromTile=function(t,e,r){var s=Math.PI*(1-2*(t+.5)/Math.pow(2,e)),a=Math.atan(.5*(Math.exp(s)-Math.exp(-s)))/n;return new i(a,r)},s.units.get=function(){return t},i.prototype.distance=function(t,e){var r=l(t[0]-e[0])*this.kx,n=(t[1]-e[1])*this.ky;return Math.sqrt(r*r+n*n)},i.prototype.bearing=function(t,e){var r=l(e[0]-t[0])*this.kx;return Math.atan2(r,(e[1]-t[1])*this.ky)/n},i.prototype.destination=function(t,e,r){var i=r*n;return this.offset(t,Math.sin(i)*e,Math.cos(i)*e)},i.prototype.offset=function(t,e,r){return[t[0]+e/this.kx,t[1]+r/this.ky]},i.prototype.lineDistance=function(t){for(var e=0,r=0;r<t.length-1;r++)e+=this.distance(t[r],t[r+1]);return e},i.prototype.area=function(t){for(var e=0,r=0;r<t.length;r++)for(var n=t[r],i=0,s=n.length,a=s-1;i<s;a=i++)e+=l(n[i][0]-n[a][0])*(n[i][1]+n[a][1])*(r?-1:1);return Math.abs(e)/2*this.kx*this.ky},i.prototype.along=function(t,e){var r=0;if(e<=0)return t[0];for(var n=0;n<t.length-1;n++){var i=t[n],s=t[n+1],a=this.distance(i,s);if((r+=a)>e)return o(i,s,(e-(r-a))/a)}return t[t.length-1]},i.prototype.pointToSegmentDistance=function(t,e,r){var n=e[0],i=e[1],s=l(r[0]-n)*this.kx,a=(r[1]-i)*this.ky,o=0;return 0===s&&0===a||((o=(l(t[0]-n)*this.kx*s+(t[1]-i)*this.ky*a)/(s*s+a*a))>1?(n=r[0],i=r[1]):o>0&&(n+=s/this.kx*o,i+=a/this.ky*o)),s=l(t[0]-n)*this.kx,a=(t[1]-i)*this.ky,Math.sqrt(s*s+a*a)},i.prototype.pointOnLine=function(t,e){for(var r,n,i,s,a=1/0,o=0;o<t.length-1;o++){var u=t[o][0],c=t[o][1],h=l(t[o+1][0]-u)*this.kx,p=(t[o+1][1]-c)*this.ky,f=0;0===h&&0===p||((f=(l(e[0]-u)*this.kx*h+(e[1]-c)*this.ky*p)/(h*h+p*p))>1?(u=t[o+1][0],c=t[o+1][1]):f>0&&(u+=h/this.kx*f,c+=p/this.ky*f));var d=(h=l(e[0]-u)*this.kx)*h+(p=(e[1]-c)*this.ky)*p;d<a&&(a=d,r=u,n=c,i=o,s=f)}return{point:[r,n],index:i,t:Math.max(0,Math.min(1,s))}},i.prototype.lineSlice=function(t,e,r){var n=this.pointOnLine(r,t),i=this.pointOnLine(r,e);if(n.index>i.index||n.index===i.index&&n.t>i.t){var s=n;n=i,i=s}var o=[n.point],l=n.index+1,u=i.index;!a(r[l],o[0])&&l<=u&&o.push(r[l]);for(var c=l+1;c<=u;c++)o.push(r[c]);return a(r[u],i.point)||o.push(i.point),o},i.prototype.lineSliceAlong=function(t,e,r){for(var n=0,i=[],s=0;s<r.length-1;s++){var a=r[s],l=r[s+1],u=this.distance(a,l);if((n+=u)>t&&0===i.length&&i.push(o(a,l,(t-(n-u))/u)),n>=e)return i.push(o(a,l,(e-(n-u))/u)),i;n>t&&i.push(l)}return i},i.prototype.bufferPoint=function(t,e){var r=e/this.ky,n=e/this.kx;return[t[0]-n,t[1]-r,t[0]+n,t[1]+r]},i.prototype.bufferBBox=function(t,e){var r=e/this.ky,n=e/this.kx;return[t[0]-n,t[1]-r,t[2]+n,t[3]+r]},i.prototype.insideBBox=function(t,e){return l(t[0]-e[0])>=0&&l(t[0]-e[2])<=0&&t[1]>=e[1]&&t[1]<=e[3]},Object.defineProperties(i,s),i}();var Yt=t(Gt.exports),Zt={exports:{}};Zt.exports=function(){var t=function(t,r){if(void 0===t&&(t=[]),void 0===r&&(r=e),this.data=t,this.length=this.data.length,this.compare=r,this.length>0)for(var n=(this.length>>1)-1;n>=0;n--)this._down(n)};function e(t,e){return t<e?-1:t>e?1:0}return t.prototype.push=function(t){this.data.push(t),this.length++,this._up(this.length-1)},t.prototype.pop=function(){if(0!==this.length){var t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}},t.prototype.peek=function(){return this.data[0]},t.prototype._up=function(t){for(var e=this.data,r=this.compare,n=e[t];t>0;){var i=t-1>>1,s=e[i];if(r(n,s)>=0)break;e[t]=s,t=i}e[t]=n},t.prototype._down=function(t){for(var e=this.data,r=this.compare,n=this.length>>1,i=e[t];t<n;){var s=1+(t<<1),a=e[s],o=s+1;if(o<this.length&&r(e[o],a)<0&&(s=o,a=e[o]),r(a,i)>=0)break;e[t]=a,t=s}e[t]=i},t}();var Xt=t(Zt.exports),Wt=8192;function Kt(t,e){return e.dist-t.dist}const Jt=100,Ht=50;function Qt(t){const e=[1/0,1/0,-1/0,-1/0];if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function te(t){return t[1]-t[0]+1}function ee(t,e){const r=t[1]>=t[0]&&t[1]<e;return r||console.warn("Distance Expression: Index is out of range"),r}function re(t,e){if(t[0]>t[1])return[null,null];const r=te(t);if(e){if(2===r)return[t,null];const e=Math.floor(r/2);return[[t[0],t[0]+e],[t[0]+e,t[1]]]}{if(1===r)return[t,null];const e=Math.floor(r/2)-1;return[[t[0],t[0]+e],[t[0]+e+1,t[1]]]}}function ne(t,e){const r=[1/0,1/0,-1/0,-1/0];if(!ee(e,t.length))return r;for(let n=e[0];n<=e[1];++n)It(r,t[n]);return r}function ie(t){const e=[1/0,1/0,-1/0,-1/0];for(let r=0;r<t.length;++r)for(let n=0;n<t[r].length;++n)It(e,t[r][n]);return e}function se(t,e,r){if(Qt(t)||Qt(e))return NaN;let n=0,i=0;return t[2]<e[0]&&(n=e[0]-t[2]),t[0]>e[2]&&(n=t[0]-e[2]),t[1]>e[3]&&(i=t[1]-e[3]),t[3]<e[1]&&(i=e[1]-t[3]),r.distance([0,0],[n,i])}function ae(t,e){const r=Math.pow(2,e.z);return[(i=(t.x/Wt+e.x)/r,360*i-180),(n=(t.y/Wt+e.y)/r,360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90)];var n,i}function oe(t,e){const r=[];for(let n=0;n<t.length;++n)r.push(ae(t[n],e));return r}function le(t,e,r){const n=r.pointOnLine(e,t).point;return r.distance(t,n)}function ue(t,e,r,n,i){const s=r.slice(n[0],n[1]+1);let a=1/0;for(let r=e[0];r<=e[1];++r)if(0===(a=Math.min(a,le(t[r],s,i))))return 0;return a}function ce(t,e,r,n,i){const s=Math.min(i.pointToSegmentDistance(t,r,n),i.pointToSegmentDistance(e,r,n)),a=Math.min(i.pointToSegmentDistance(r,t,e),i.pointToSegmentDistance(n,t,e));return Math.min(s,a)}function he(t,e,r,n,i){if(!ee(e,t.length)||!ee(n,r.length))return NaN;let s=1/0;for(let a=e[0];a<e[1];++a)for(let e=n[0];e<n[1];++e){if(Ct(t[a],t[a+1],r[e],r[e+1]))return 0;s=Math.min(s,ce(t[a],t[a+1],r[e],r[e+1],i))}return s}function pe(t,e,r,n,i){if(!ee(e,t.length)||!ee(n,r.length))return NaN;let s=1/0;for(let a=e[0];a<=e[1];++a)for(let e=n[0];e<=n[1];++e)if(0===(s=Math.min(s,i.distance(t[a],r[e]))))return s;return s}function fe(t,e,r){if(Et(t,e,!0))return 0;let n=1/0;for(const i of e){const e=i.length;if(e<2)return console.warn("Distance Expression: Invalid polygon!"),NaN;if(i[0]!==i[e-1]&&0===(n=Math.min(n,r.pointToSegmentDistance(t,i[e-1],i[0]))))return n;if(0===(n=Math.min(n,le(t,i,r))))return n}return n}function de(t,e,r,n){if(!ee(e,t.length))return NaN;for(let n=e[0];n<=e[1];++n)if(Et(t[n],r,!0))return 0;let i=1/0;for(let s=e[0];s<e[1];++s)for(const e of r)for(let r=0,a=e.length,o=a-1;r<a;o=r++){if(Ct(t[s],t[s+1],e[o],e[r]))return 0;i=Math.min(i,ce(t[s],t[s+1],e[o],e[r],n))}return i}function ye(t,e){for(const r of t)for(let t=0;t<=r.length-1;++t)if(Et(r[t],e,!0))return!0;return!1}function me(t,e,r,n=1/0){const i=ie(t),s=ie(e);if(n!==1/0&&se(i,s,r)>=n)return n;if(Tt(i,s)){if(ye(t,e))return 0}else if(ye(e,t))return 0;let a=n;for(const n of t)for(let t=0,i=n.length,s=i-1;t<i;s=t++)for(const i of e)for(let e=0,o=i.length,l=o-1;e<o;l=e++){if(Ct(n[s],n[t],i[l],i[e]))return 0;a=Math.min(a,ce(n[s],n[t],i[l],i[e],r))}return a}function ge(t,e,r,n,i,s,a){if(null===s||null===a)return;const o=se(ne(n,s),ne(i,a),r);o<e&&t.push({dist:o,range1:s,range2:a})}function xe(t,e,r,n,i=1/0){let s=Math.min(n.distance(t[0],r[0][0]),i);if(0===s)return s;const a=new Xt([{dist:0,range1:[0,t.length-1],range2:[0,0]}],Kt),o=e?Ht:Jt,l=ie(r);for(;a.length;){const i=a.pop();if(i.dist>=s)continue;const u=i.range1;if(te(u)<=o){if(!ee(u,t.length))return NaN;if(e){const e=de(t,u,r,n);if(0===(s=Math.min(s,e)))return s}else for(let e=u[0];e<=u[1];++e){const i=fe(t[e],r,n);if(0===(s=Math.min(s,i)))return s}}else{const r=re(u,e);if(null!==r[0]){const e=se(ne(t,r[0]),l,n);e<s&&a.push({dist:e,range1:r[0],range2:[0,0]})}if(null!==r[1]){const e=se(ne(t,r[1]),l,n);e<s&&a.push({dist:e,range1:r[1],range2:[0,0]})}}}return s}function ve(t,e,r,n,i,s=1/0){let a=Math.min(s,i.distance(t[0],r[0]));if(0===a)return a;const o=new Xt([{dist:0,range1:[0,t.length-1],range2:[0,r.length-1]}],Kt),l=e?Ht:Jt,u=n?Ht:Jt;for(;o.length;){const s=o.pop();if(s.dist>=a)continue;const c=s.range1,h=s.range2;if(te(c)<=l&&te(h)<=u){if(!ee(c,t.length)||!ee(h,r.length))return NaN;if(e&&n?a=Math.min(a,he(t,c,r,h,i)):e||n?e&&!n?a=Math.min(a,ue(r,h,t,c,i)):!e&&n&&(a=Math.min(a,ue(t,c,r,h,i))):a=Math.min(a,pe(t,c,r,h,i)),0===a)return a}else{const s=re(c,e),l=re(h,n);ge(o,a,i,t,r,s[0],l[0]),ge(o,a,i,t,r,s[0],l[1]),ge(o,a,i,t,r,s[1],l[0]),ge(o,a,i,t,r,s[1],l[1])}}return a}function be(t,e,r,n,i=1/0){let s=i;const a=ne(t,[0,t.length-1]);for(const i of r)if(!(s!==1/0&&se(a,ne(i,[0,i.length-1]),n)>=s)&&(s=Math.min(s,ve(t,e,i,!0,n,s)),0===s))return s;return s}function we(t,e,r,n,i=1/0){let s=i;const a=ne(t,[0,t.length-1]);for(const i of r){if(s!==1/0&&se(a,ie(i),n)>=s)continue;const r=xe(t,e,i,n,s);if(isNaN(r))return r;if(0===(s=Math.min(s,r)))return s}return s}function _e(t){return"Point"===t||"MultiPoint"===t||"LineString"===t||"MultiLineString"===t||"Polygon"===t||"MultiPolygon"===t}class Distance{constructor(t,e){this.type=Z,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires either one argument, but found ' ${t.length-1} instead.`);if(ut(t[1])){const e=t[1];if("FeatureCollection"===e.type){for(let t=0;t<e.features.length;++t)if(_e(e.features[t].geometry.type))return new Distance(e,e.features[t].geometry)}else if("Feature"===e.type){if(_e(e.geometry.type))return new Distance(e,e.geometry)}else if(_e(e.type))return new Distance(e,e)}return e.error("'distance' expression needs to be an array with format ['Distance', GeoJSONObj].")}evaluate(t){const e=t.geometry(),r=t.canonicalID();if(null!=e&&null!=r){if("Point"===t.geometryType())return function(t,e,r){const n=[];for(const r of t)for(const t of r)n.push(ae(t,e));const i=new Yt(n[0][1],"meters");return"Point"===r.type||"MultiPoint"===r.type||"LineString"===r.type?ve(n,!1,"Point"===r.type?[r.coordinates]:r.coordinates,"LineString"===r.type,i):"MultiLineString"===r.type?be(n,!1,r.coordinates,i):"Polygon"===r.type||"MultiPolygon"===r.type?we(n,!1,"Polygon"===r.type?[r.coordinates]:r.coordinates,i):null}(e,r,this.geometries);if("LineString"===t.geometryType())return function(t,e,r){const n=[];for(const r of t){const t=[];for(const n of r)t.push(ae(n,e));n.push(t)}const i=new Yt(n[0][0][1],"meters");if("Point"===r.type||"MultiPoint"===r.type||"LineString"===r.type)return be("Point"===r.type?[r.coordinates]:r.coordinates,"LineString"===r.type,n,i);if("MultiLineString"===r.type){let t=1/0;for(let e=0;e<r.coordinates.length;e++){const s=be(r.coordinates[e],!0,n,i,t);if(isNaN(s))return s;if(0===(t=Math.min(t,s)))return t}return t}if("Polygon"===r.type||"MultiPolygon"===r.type){let t=1/0;for(let e=0;e<n.length;e++){const s=we(n[e],!0,"Polygon"===r.type?[r.coordinates]:r.coordinates,i,t);if(isNaN(s))return s;if(0===(t=Math.min(t,s)))return t}return t}return null}(e,r,this.geometries);if("Polygon"===t.geometryType())return function(t,e,r){const n=[];for(const r of function(t,e){const r=t.length;if(r<=1)return[t];const n=[];let i,s;for(let e=0;e<r;e++){const r=Pt(t[e]);0!==r&&(t[e].area=Math.abs(r),void 0===s&&(s=r<0),s===r<0?(i&&n.push(i),i=[t[e]]):i.push(t[e]))}return i&&n.push(i),n}(t)){const t=[];for(let n=0;n<r.length;++n)t.push(oe(r[n],e));n.push(t)}const i=new Yt(n[0][0][0][1],"meters");if("Point"===r.type||"MultiPoint"===r.type||"LineString"===r.type)return we("Point"===r.type?[r.coordinates]:r.coordinates,"LineString"===r.type,n,i);if("MultiLineString"===r.type){let t=1/0;for(let e=0;e<r.coordinates.length;e++){const s=we(r.coordinates[e],!0,n,i,t);if(isNaN(s))return s;if(0===(t=Math.min(t,s)))return t}return t}return"Polygon"===r.type||"MultiPolygon"===r.type?function(t,e,r){let n=1/0;for(const i of t)for(const t of e){const e=me(i,t,r,n);if(isNaN(e))return e;if(0===(n=Math.min(n,e)))return n}return n}("Polygon"===r.type?[r.coordinates]:r.coordinates,n,i):null}(e,r,this.geometries);console.warn("Distance Expression: currently only evaluates valid Point/LineString/Polygon geometries.")}else console.warn("Distance Expression: requirs valid feature and canonical information.");return null}eachChild(){}outputDefined(){return!0}serialize(){return["distance",this.geojson]}}var Ae=Distance;function Se(t){if(t instanceof _t){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof $t)return!1;if(t instanceof Ae)return!1;let e=!0;return t.eachChild((t=>{e&&!Se(t)&&(e=!1)})),e}function Me(t){if(t instanceof _t&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!Me(t)&&(e=!1)})),e}function Pe(t){if(t instanceof _t&&"config"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!Pe(t)&&(e=!1)})),e}function Ie(t,e){if(t instanceof _t&&e.indexOf(t.name)>=0)return!1;let r=!0;return t.eachChild((t=>{r&&!Ie(t,e)&&(r=!1)})),r}class Var{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const r=t[1];return e.scope.has(r)?new Var(r,e.scope.get(r)):e.error(`Unknown variable "${r}". Make sure "${r}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}var Te=Var;class ParsingContext{constructor(t,e=[],r,n=new G,i=[],s,a){this.registry=t,this.path=e,this.key=e.map((t=>`[${t}]`)).join(""),this.scope=n,this.errors=i,this.expectedType=r,this._scope=s,this.options=a}parse(t,e,r,n,i={}){return e||r?this.concat(e,r,n)._parse(t,i):this._parse(t,i)}_parse(t,e){function r(t,e,r){return"assert"===r?new yt(e,[t]):"coerce"===r?new xt(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n="string"==typeof t[0]?this.registry[t[0]]:void 0;if(n){let i=n.parse(t,this);if(!i)return null;if(this.expectedType){const t=this.expectedType,n=i.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==n.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==n.kind&&"string"!==n.kind){if(this.checkSubtype(t,n))return null}else i=r(i,t,e.typeAnnotation||"coerce");else i=r(i,t,e.typeAnnotation||"assert")}if(!(i instanceof pt)&&"resolvedImage"!==i.type.kind&&Ee(i)){const t=new bt(this._scope,this.options);try{i=new pt(i.type,i.evaluate(t))}catch(t){return this.e