mapbox-gl
Version:
A WebGL interactive maps library
1 lines • 357 kB
JavaScript
var mapboxgl=function(){"use strict";var t=e;function e(t,e){this.x=t,this.y=e}function r(t,e,r){return Math.min(r,Math.max(e,t))}function n(t){var e=[];for(var r in t)e.push(t[r]);return e}function i(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];for(var n=0,i=e;n<i.length;n+=1){var o=i[n];for(var a in o)t[a]=o[a]}return t}function o(){return function t(e){return e?(e^16*Math.random()>>e/4).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}function a(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 s(t,e){return-1!==t.indexOf(e,t.length-e.length)}function u(t,e,r){var n={};for(var i in t)n[i]=e.call(r||this,t[i],i,t);return n}function l(t){return Array.isArray(t)?t.map(l):"object"==typeof t&&t?u(t,l):t}e.prototype={clone:function(){return new e(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}},e.convert=function(t){return t instanceof e?t:Array.isArray(t)?new e(t[0],t[1]):t};var p={};function c(t){p[t]||("undefined"!=typeof console&&console.warn(t),p[t]=!0)}function h(t,e,r){return(r.y-t.y)*(e.x-t.x)>(e.y-t.y)*(r.x-t.x)}function f(t){for(var e=0,r=0,n=t.length,i=n-1,o=void 0,a=void 0;r<n;i=r++)e+=((a=t[i]).x-(o=t[r]).x)*(o.y+a.y);return e}function y(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}function d(t){var e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(function(t,r,n,i){var o=n||i;return e[r]=!o||o.toLowerCase(),""})),e["max-age"]){var r=parseInt(e["max-age"],10);isNaN(r)?delete e["max-age"]:e["max-age"]=r}return e}var m=null;function v(t){if(null==m){var e=t.navigator?t.navigator.userAgent:null;m=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return m}function g(t){try{var e=self[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return!1}}var x=w,b=3;function w(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 o=0;o<this.d*this.d;o++){var a=i[b+o],s=i[b+o+1];n.push(a===s?null:i.subarray(a,s))}var u=i[b+n.length+1];this.keys=i.subarray(i[b+n.length],u),this.bboxes=i.subarray(u),this.insert=this._insertReadonly}else{this.d=e+2*r;for(var l=0;l<this.d*this.d;l++)n.push([]);this.keys=[],this.bboxes=[]}this.n=e,this.extent=t,this.padding=r,this.scale=e/t,this.uid=0;var p=r/e*t;this.min=-p,this.max=t+p}function _(t,e){return t(e={exports:{}},e.exports),e.exports}w.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)},w.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},w.prototype._insertCell=function(t,e,r,n,i,o){this.cells[i].push(o)},w.prototype.query=function(t,e,r,n,i){var o=this.min,a=this.max;if(t<=o&&e<=o&&a<=r&&a<=n&&!i)return Array.prototype.slice.call(this.keys);var s=[];return this._forEachCell(t,e,r,n,this._queryCell,s,{},i),s},w.prototype._queryCell=function(t,e,r,n,i,o,a,s){var u=this.cells[i];if(null!==u)for(var l=this.keys,p=this.bboxes,c=0;c<u.length;c++){var h=u[c];if(void 0===a[h]){var f=4*h;(s?s(p[f+0],p[f+1],p[f+2],p[f+3]):t<=p[f+2]&&e<=p[f+3]&&r>=p[f+0]&&n>=p[f+1])?(a[h]=!0,o.push(l[h])):a[h]=!1}}},w.prototype._forEachCell=function(t,e,r,n,i,o,a,s){for(var u=this._convertToCellCoord(t),l=this._convertToCellCoord(e),p=this._convertToCellCoord(r),c=this._convertToCellCoord(n),h=u;h<=p;h++)for(var f=l;f<=c;f++){var y=this.d*f+h;if((!s||s(this._convertFromCellCoord(h),this._convertFromCellCoord(f),this._convertFromCellCoord(h+1),this._convertFromCellCoord(f+1)))&&i.call(this,t,e,r,n,y,o,a,s))return}},w.prototype._convertFromCellCoord=function(t){return(t-this.padding)/this.scale},w.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},w.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 o=e,a=0;a<t.length;a++){var s=t[a];i[b+a]=o,i.set(s,o),o+=s.length}return i[b+t.length]=o,i.set(this.keys,o),i[b+t.length+1]=o+=this.keys.length,i.set(this.bboxes,o),o+=this.bboxes.length,i.buffer};var S=_((function(t,e){var 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 n(t){return(t=Math.round(t))<0?0:t>255?255:t}function i(t){return n("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function o(t){return(e="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e}function a(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{e.parseCSSColor=function(t){var e,s=t.replace(/ /g,"").toLowerCase();if(s in r)return r[s].slice();if("#"===s[0])return 4===s.length?(e=parseInt(s.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===s.length&&(e=parseInt(s.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var u=s.indexOf("("),l=s.indexOf(")");if(-1!==u&&l+1===s.length){var p=s.substr(0,u),c=s.substr(u+1,l-(u+1)).split(","),h=1;switch(p){case"rgba":if(4!==c.length)return null;h=o(c.pop());case"rgb":return 3!==c.length?null:[i(c[0]),i(c[1]),i(c[2]),h];case"hsla":if(4!==c.length)return null;h=o(c.pop());case"hsl":if(3!==c.length)return null;var f=(parseFloat(c[0])%360+360)%360/360,y=o(c[1]),d=o(c[2]),m=d<=.5?d*(y+1):d+y-d*y,v=2*d-m;return[n(255*a(v,m,f+1/3)),n(255*a(v,m,f)),n(255*a(v,m,f-1/3)),h];default:return null}}return null}}catch(t){}})).parseCSSColor,k=function(t,e,r,n){void 0===n&&(n=1),this.r=t,this.g=e,this.b=r,this.a=n};function I(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];for(var n=0,i=e;n<i.length;n+=1){var o=i[n];for(var a in o)t[a]=o[a]}return t}k.parse=function(t){if(t){if(t instanceof k)return t;if("string"==typeof t){var e=S(t);if(e)return new k(e[0]/255*e[3],e[1]/255*e[3],e[2]/255*e[3],e[3])}}},k.prototype.toString=function(){var t=this.toArray(),e=t[1],r=t[2],n=t[3];return"rgba("+Math.round(t[0])+","+Math.round(e)+","+Math.round(r)+","+n+")"},k.prototype.toArray=function(){var t=this.a;return 0===t?[0,0,0,0]:[255*this.r/t,255*this.g/t,255*this.b/t,t]},k.black=new k(0,0,0,1),k.white=new k(1,1,1,1),k.transparent=new k(0,0,0,0),k.red=new k(1,0,0,1);var A=function(t){function e(e,r){t.call(this,r),this.message=r,this.key=e}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e}(Error),z=function(t,e){void 0===e&&(e=[]),this.parent=t,this.bindings={};for(var r=0,n=e;r<n.length;r+=1){var i=n[r];this.bindings[i[0]]=i[1]}};z.prototype.concat=function(t){return new z(this,t)},z.prototype.get=function(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.")},z.prototype.has=function(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)};var M={kind:"null"},C={kind:"number"},P={kind:"string"},B={kind:"boolean"},V={kind:"color"},T={kind:"object"},E={kind:"value"},D={kind:"collator"},F={kind:"formatted"},L={kind:"resolvedImage"};function O(t,e){return{kind:"array",itemType:t,N:e}}function j(t){if("array"===t.kind){var e=j(t.itemType);return"number"==typeof t.N?"array<"+e+", "+t.N+">":"value"===t.itemType.kind?"array":"array<"+e+">"}return t.kind}var R=[M,C,P,B,V,F,T,O(E),L];function q(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!q(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(var r=0,n=R;r<n.length;r+=1)if(!q(n[r],e))return null}return"Expected "+j(t)+" but found "+j(e)+" instead."}var U=function(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"})};U.prototype.compare=function(t,e){return this.collator.compare(t,e)},U.prototype.resolvedLocale=function(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale};var N=function(t,e,r,n,i){this.text=t,this.image=e,this.scale=r,this.fontStack=n,this.textColor=i},Z=function(t){this.sections=t};Z.fromString=function(t){return new Z([new N(t,null,null,null,null)])},Z.prototype.isEmpty=function(){return 0===this.sections.length||!this.sections.some((function(t){return 0!==t.text.length||t.image&&0!==t.image.name.length}))},Z.factory=function(t){return t instanceof Z?t:Z.fromString(t)},Z.prototype.toString=function(){return 0===this.sections.length?"":this.sections.map((function(t){return t.text})).join("")},Z.prototype.serialize=function(){for(var t=["format"],e=0,r=this.sections;e<r.length;e+=1){var n=r[e];if(n.image)t.push(["image",n.image.name]);else{t.push(n.text);var i={};n.fontStack&&(i["text-font"]=["literal",n.fontStack.split(",")]),n.scale&&(i["font-scale"]=n.scale),n.textColor&&(i["text-color"]=["rgba"].concat(n.textColor.toArray())),t.push(i)}}return t};var K=function(t){this.name=t.name,this.available=t.available};function J(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 G(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 k)return!0;if(t instanceof U)return!0;if(t instanceof Z)return!0;if(t instanceof K)return!0;if(Array.isArray(t)){for(var e=0,r=t;e<r.length;e+=1)if(!G(r[e]))return!1;return!0}if("object"==typeof t){for(var n in t)if(!G(t[n]))return!1;return!0}return!1}function X(t){if(null===t)return M;if("string"==typeof t)return P;if("boolean"==typeof t)return B;if("number"==typeof t)return C;if(t instanceof k)return V;if(t instanceof U)return D;if(t instanceof Z)return F;if(t instanceof K)return L;if(Array.isArray(t)){for(var e,r=t.length,n=0,i=t;n<i.length;n+=1){var o=X(i[n]);if(e){if(e===o)continue;e=E;break}e=o}return O(e||E,r)}return T}function Y(t){var e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof k||t instanceof Z||t instanceof K?t.toString():JSON.stringify(t)}K.prototype.toString=function(){return this.name},K.fromString=function(t){return t?new K({name:t,available:!1}):null},K.prototype.serialize=function(){return["image",this.name]};var H=function(t,e){this.type=t,this.value=e};H.parse=function(t,e){if(2!==t.length)return e.error("'literal' expression requires exactly one argument, but found "+(t.length-1)+" instead.");if(!G(t[1]))return e.error("invalid value");var r=t[1],n=X(r),i=e.expectedType;return"array"!==n.kind||0!==n.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(n=i),new H(n,r)},H.prototype.evaluate=function(){return this.value},H.prototype.eachChild=function(){},H.prototype.outputDefined=function(){return!0},H.prototype.serialize=function(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof k?["rgba"].concat(this.value.toArray()):this.value instanceof Z?this.value.serialize():this.value};var W=function(t){this.name="ExpressionEvaluationError",this.message=t};W.prototype.toJSON=function(){return this.message};var $={string:P,number:C,boolean:B,object:T},Q=function(t,e){this.type=t,this.args=e};Q.parse=function(t,e){if(t.length<2)return e.error("Expected at least one argument.");var r,n=1,i=t[0];if("array"===i){var o,a;if(t.length>2){var s=t[1];if("string"!=typeof s||!(s in $)||"object"===s)return e.error('The item type argument of "array" must be one of string, number, boolean',1);o=$[s],n++}else o=E;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);a=t[2],n++}r=O(o,a)}else r=$[i];for(var u=[];n<t.length;n++){var l=e.parse(t[n],n,E);if(!l)return null;u.push(l)}return new Q(r,u)},Q.prototype.evaluate=function(t){for(var e=0;e<this.args.length;e++){var r=this.args[e].evaluate(t);if(!q(this.type,X(r)))return r;if(e===this.args.length-1)throw new W("Expected value to be of type "+j(this.type)+", but found "+j(X(r))+" instead.")}return null},Q.prototype.eachChild=function(t){this.args.forEach(t)},Q.prototype.outputDefined=function(){return this.args.every((function(t){return t.outputDefined()}))},Q.prototype.serialize=function(){var t=this.type,e=[t.kind];if("array"===t.kind){var r=t.itemType;if("string"===r.kind||"number"===r.kind||"boolean"===r.kind){e.push(r.kind);var n=t.N;("number"==typeof n||this.args.length>1)&&e.push(n)}}return e.concat(this.args.map((function(t){return t.serialize()})))};var tt=function(t){this.type=F,this.sections=t};tt.parse=function(t,e){if(t.length<2)return e.error("Expected at least one argument.");var r=t[1];if(!Array.isArray(r)&&"object"==typeof r)return e.error("First argument must be an image or text section.");for(var n=[],i=!1,o=1;o<=t.length-1;++o){var a=t[o];if(i&&"object"==typeof a&&!Array.isArray(a)){i=!1;var s=null;if(a["font-scale"]&&!(s=e.parse(a["font-scale"],1,C)))return null;var u=null;if(a["text-font"]&&!(u=e.parse(a["text-font"],1,O(P))))return null;var l=null;if(a["text-color"]&&!(l=e.parse(a["text-color"],1,V)))return null;var p=n[n.length-1];p.scale=s,p.font=u,p.textColor=l}else{var c=e.parse(t[o],1,E);if(!c)return null;var h=c.type.kind;if("string"!==h&&"value"!==h&&"null"!==h&&"resolvedImage"!==h)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,n.push({content:c,scale:null,font:null,textColor:null})}}return new tt(n)},tt.prototype.evaluate=function(t){return new Z(this.sections.map((function(e){var r=e.content.evaluate(t);return X(r)===L?new N("",r,null,null,null):new N(Y(r),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))},tt.prototype.eachChild=function(t){for(var e=0,r=this.sections;e<r.length;e+=1){var n=r[e];t(n.content),n.scale&&t(n.scale),n.font&&t(n.font),n.textColor&&t(n.textColor)}},tt.prototype.outputDefined=function(){return!1},tt.prototype.serialize=function(){for(var t=["format"],e=0,r=this.sections;e<r.length;e+=1){var n=r[e];t.push(n.content.serialize());var i={};n.scale&&(i["font-scale"]=n.scale.serialize()),n.font&&(i["text-font"]=n.font.serialize()),n.textColor&&(i["text-color"]=n.textColor.serialize()),t.push(i)}return t};var et=function(t){this.type=L,this.input=t};et.parse=function(t,e){if(2!==t.length)return e.error("Expected two arguments.");var r=e.parse(t[1],1,P);return r?new et(r):e.error("No image name provided.")},et.prototype.evaluate=function(t){var e=this.input.evaluate(t),r=K.fromString(e);return r&&t.availableImages&&(r.available=t.availableImages.indexOf(e)>-1),r},et.prototype.eachChild=function(t){t(this.input)},et.prototype.outputDefined=function(){return!1},et.prototype.serialize=function(){return["image",this.input.serialize()]};var rt={"to-boolean":B,"to-color":V,"to-number":C,"to-string":P},nt=function(t,e){this.type=t,this.args=e};nt.parse=function(t,e){if(t.length<2)return e.error("Expected at least one argument.");var r=t[0];if(("to-boolean"===r||"to-string"===r)&&2!==t.length)return e.error("Expected one argument.");for(var n=rt[r],i=[],o=1;o<t.length;o++){var a=e.parse(t[o],o,E);if(!a)return null;i.push(a)}return new nt(n,i)},nt.prototype.evaluate=function(t){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(t));if("color"===this.type.kind){for(var e,r,n=0,i=this.args;n<i.length;n+=1){if(r=null,(e=i[n].evaluate(t))instanceof k)return e;if("string"==typeof e){var o=t.parseColor(e);if(o)return o}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.":J(e[0],e[1],e[2],e[3])))return new k(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new W(r||"Could not parse color from value '"+("string"==typeof e?e:String(JSON.stringify(e)))+"'")}if("number"===this.type.kind){for(var a=null,s=0,u=this.args;s<u.length;s+=1){if(null===(a=u[s].evaluate(t)))return 0;var l=Number(a);if(!isNaN(l))return l}throw new W("Could not convert "+JSON.stringify(a)+" to number.")}return"formatted"===this.type.kind?Z.fromString(Y(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?K.fromString(Y(this.args[0].evaluate(t))):Y(this.args[0].evaluate(t))},nt.prototype.eachChild=function(t){this.args.forEach(t)},nt.prototype.outputDefined=function(){return this.args.every((function(t){return t.outputDefined()}))},nt.prototype.serialize=function(){if("formatted"===this.type.kind)return new tt([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new et(this.args[0]).serialize();var t=["to-"+this.type.kind];return this.eachChild((function(e){t.push(e.serialize())})),t};var it=["Unknown","Point","LineString","Polygon"],ot=function(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null};ot.prototype.id=function(){return this.feature&&"id"in this.feature?this.feature.id:null},ot.prototype.geometryType=function(){return this.feature?"number"==typeof this.feature.type?it[this.feature.type]:this.feature.type:null},ot.prototype.geometry=function(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null},ot.prototype.canonicalID=function(){return this.canonical},ot.prototype.properties=function(){return this.feature&&this.feature.properties||{}},ot.prototype.parseColor=function(t){var e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=k.parse(t)),e};var at=function(t,e,r,n){this.name=t,this.type=e,this._evaluate=r,this.args=n};at.prototype.evaluate=function(t){return this._evaluate(t,this.args)},at.prototype.eachChild=function(t){this.args.forEach(t)},at.prototype.outputDefined=function(){return!1},at.prototype.serialize=function(){return[this.name].concat(this.args.map((function(t){return t.serialize()})))},at.parse=function(t,e){var r,n=t[0],i=at.definitions[n];if(!i)return e.error('Unknown expression "'+n+'". If you wanted a literal array, use ["literal", [...]].',0);for(var o=Array.isArray(i)?i[0]:i.type,a=Array.isArray(i)?[[i[1],i[2]]]:i.overloads,s=a.filter((function(e){var r=e[0];return!Array.isArray(r)||r.length===t.length-1})),u=null,l=0,p=s;l<p.length;l+=1){var c=p[l],h=c[0],f=c[1];u=new Vt(e.registry,e.path,null,e.scope);for(var y=[],d=!1,m=1;m<t.length;m++){var v=t[m],g=Array.isArray(h)?h[m-1]:h.type,x=u.parse(v,1+y.length,g);if(!x){d=!0;break}y.push(x)}if(!d)if(Array.isArray(h)&&h.length!==y.length)u.error("Expected "+h.length+" arguments, but found "+y.length+" instead.");else{for(var b=0;b<y.length;b++){var w=Array.isArray(h)?h[b]:h.type,_=y[b];u.concat(b+1).checkSubtype(w,_.type)}if(0===u.errors.length)return new at(n,o,f,y)}}if(1===s.length)(r=e.errors).push.apply(r,u.errors);else{for(var S=(s.length?s:a).map((function(t){var e;return e=t[0],Array.isArray(e)?"("+e.map(j).join(", ")+")":"("+j(e.type)+"...)"})).join(" | "),k=[],I=1;I<t.length;I++){var A=e.parse(t[I],1+k.length);if(!A)return null;k.push(j(A.type))}e.error("Expected arguments of type "+S+", but found ("+k.join(", ")+") instead.")}return null},at.register=function(t,e){for(var r in at.definitions=e,e)t[r]=at};var st=function(t,e,r){this.type=D,this.locale=r,this.caseSensitive=t,this.diacriticSensitive=e};st.parse=function(t,e){if(2!==t.length)return e.error("Expected one argument.");var r=t[1];if("object"!=typeof r||Array.isArray(r))return e.error("Collator options argument must be an object.");var n=e.parse(void 0!==r["case-sensitive"]&&r["case-sensitive"],1,B);if(!n)return null;var i=e.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,B);if(!i)return null;var o=null;return r.locale&&!(o=e.parse(r.locale,1,P))?null:new st(n,i,o)},st.prototype.evaluate=function(t){return new U(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)},st.prototype.eachChild=function(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)},st.prototype.outputDefined=function(){return!1},st.prototype.serialize=function(){var t={};return t["case-sensitive"]=this.caseSensitive.serialize(),t["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(t.locale=this.locale.serialize()),["collator",t]};var ut=function(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1]))};ut.prototype.setNorthEast=function(t){return this._ne=t instanceof lt?new lt(t.lng,t.lat):lt.convert(t),this},ut.prototype.setSouthWest=function(t){return this._sw=t instanceof lt?new lt(t.lng,t.lat):lt.convert(t),this},ut.prototype.extend=function(t){var e,r,n=this._sw,i=this._ne;if(t instanceof lt)e=t,r=t;else{if(!(t instanceof ut))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(ut.convert(t)):this.extend(lt.convert(t)):this;if(r=t._ne,!(e=t._sw)||!r)return this}return n||i?(n.lng=Math.min(e.lng,n.lng),n.lat=Math.min(e.lat,n.lat),i.lng=Math.max(r.lng,i.lng),i.lat=Math.max(r.lat,i.lat)):(this._sw=new lt(e.lng,e.lat),this._ne=new lt(r.lng,r.lat)),this},ut.prototype.getCenter=function(){return new lt((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)},ut.prototype.getSouthWest=function(){return this._sw},ut.prototype.getNorthEast=function(){return this._ne},ut.prototype.getNorthWest=function(){return new lt(this.getWest(),this.getNorth())},ut.prototype.getSouthEast=function(){return new lt(this.getEast(),this.getSouth())},ut.prototype.getWest=function(){return this._sw.lng},ut.prototype.getSouth=function(){return this._sw.lat},ut.prototype.getEast=function(){return this._ne.lng},ut.prototype.getNorth=function(){return this._ne.lat},ut.prototype.toArray=function(){return[this._sw.toArray(),this._ne.toArray()]},ut.prototype.toString=function(){return"LngLatBounds("+this._sw.toString()+", "+this._ne.toString()+")"},ut.prototype.isEmpty=function(){return!(this._sw&&this._ne)},ut.prototype.contains=function(t){var e=lt.convert(t),r=e.lng,n=e.lat,i=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(i=this._sw.lng>=r&&r>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&i},ut.convert=function(t){return!t||t instanceof ut?t:new ut(t)};var lt=function(t,e){if(isNaN(t)||isNaN(e))throw new Error("Invalid LngLat object: ("+t+", "+e+")");if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")};lt.prototype.wrap=function(){return new lt(-180==(t=((this.lng- -180)%360+360)%360-180)?180:t,this.lat);var t},lt.prototype.toArray=function(){return[this.lng,this.lat]},lt.prototype.toString=function(){return"LngLat("+this.lng+", "+this.lat+")"},lt.prototype.distanceTo=function(t){var e=Math.PI/180,r=this.lat*e,n=t.lat*e,i=Math.sin(r)*Math.sin(n)+Math.cos(r)*Math.cos(n)*Math.cos((t.lng-this.lng)*e);return 6371008.8*Math.acos(Math.min(i,1))},lt.prototype.toBounds=function(t){void 0===t&&(t=0);var e=360*t/40075017,r=e/Math.cos(Math.PI/180*this.lat);return new ut(new lt(this.lng-r,this.lat-e),new lt(this.lng+r,this.lat+e))},lt.convert=function(t){if(t instanceof lt)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new lt(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new lt(Number("lng"in t?t.lng:t.lon),Number(t.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>]")};var pt=2*Math.PI*6371008.8;function ct(t){return pt*Math.cos(t*Math.PI/180)}function ht(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}var ft=function(t,e,r){void 0===r&&(r=0),this.x=+t,this.y=+e,this.z=+r};ft.fromLngLat=function(t,e){void 0===e&&(e=0);var r=lt.convert(t);return new ft((180+r.lng)/360,(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+r.lat*Math.PI/360)))/360,function(t,e){return t/ct(e)}(e,r.lat))},ft.prototype.toLngLat=function(){return new lt(360*this.x-180,ht(this.y))},ft.prototype.toAltitude=function(){return this.z*ct(ht(this.y))},ft.prototype.meterInMercatorCoordinateUnits=function(){return 1/pt*(t=ht(this.y),1/Math.cos(t*Math.PI/180));var t};var yt=8192;function dt(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 mt(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function vt(t,e){var r=ft.fromLngLat({lng:t[0],lat:t[1]},0),n=Math.pow(2,e.z);return[Math.round(r.x*n*yt),Math.round(r.y*n*yt)]}function gt(t,e,r){return e[1]>t[1]!=r[1]>t[1]&&t[0]<(r[0]-e[0])*(t[1]-e[1])/(r[1]-e[1])+e[0]}function xt(t,e){for(var r,n,i,o,a,s,u,l=!1,p=0,c=e.length;p<c;p++)for(var h=e[p],f=0,y=h.length;f<y-1;f++){if((o=(r=t)[0]-(n=h[f])[0])*(u=r[1]-(i=h[f+1])[1])-(s=r[0]-i[0])*(a=r[1]-n[1])==0&&o*s<=0&&a*u<=0)return!1;gt(t,h[f],h[f+1])&&(l=!l)}return l}function bt(t,e){for(var r=0;r<e.length;r++)if(xt(t,e[r]))return!0;return!1}function wt(t,e,r,n){var i=n[0]-r[0],o=n[1]-r[1];return((t[0]-r[0])*o-i*(t[1]-r[1]))*((e[0]-r[0])*o-i*(e[1]-r[1]))<0}function _t(t,e,r){for(var n=0,i=r;n<i.length;n+=1)for(var o=i[n],a=0;a<o.length-1;++a)if(0!=(c=[(p=o[a+1])[0]-(l=o[a])[0],p[1]-l[1]])[0]*(h=[(u=e)[0]-(s=t)[0],u[1]-s[1]])[1]-c[1]*h[0]&&wt(s,u,l,p)&&wt(l,p,s,u))return!0;var s,u,l,p,c,h;return!1}function St(t,e){for(var r=0;r<t.length;++r)if(!xt(t[r],e))return!1;for(var n=0;n<t.length-1;++n)if(_t(t[n],t[n+1],e))return!1;return!0}function kt(t,e){for(var r=0;r<e.length;r++)if(St(t,e[r]))return!0;return!1}function It(t,e,r){for(var n=[],i=0;i<t.length;i++){for(var o=[],a=0;a<t[i].length;a++){var s=vt(t[i][a],r);dt(e,s),o.push(s)}n.push(o)}return n}function At(t,e,r){for(var n=[],i=0;i<t.length;i++){var o=It(t[i],e,r);n.push(o)}return n}var zt=function(t,e){this.type=B,this.geojson=t,this.geometries=e};function Mt(t){if(t instanceof at){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 zt)return!1;var e=!0;return t.eachChild((function(t){e&&!Mt(t)&&(e=!1)})),e}function Ct(t){if(t instanceof at&&"feature-state"===t.name)return!1;var e=!0;return t.eachChild((function(t){e&&!Ct(t)&&(e=!1)})),e}function Pt(t,e){if(t instanceof at&&e.indexOf(t.name)>=0)return!1;var r=!0;return t.eachChild((function(t){r&&!Pt(t,e)&&(r=!1)})),r}zt.parse=function(t,e){if(2!==t.length)return e.error("'within' expression requires exactly one argument, but found "+(t.length-1)+" instead.");if(G(t[1])){var r=t[1];if("FeatureCollection"===r.type)for(var n=0;n<r.features.length;++n){var i=r.features[n].geometry.type;if("Polygon"===i||"MultiPolygon"===i)return new zt(r,r.features[n].geometry)}else if("Feature"===r.type){var o=r.geometry.type;if("Polygon"===o||"MultiPolygon"===o)return new zt(r,r.geometry)}else if("Polygon"===r.type||"MultiPolygon"===r.type)return new zt(r,r)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")},zt.prototype.evaluate=function(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){for(var r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=t.canonicalID(),o=[i.x*yt,i.y*yt],a=[],s=0,u=t.geometry();s<u.length;s+=1)for(var l=0,p=u[s];l<p.length;l+=1){var c=p[l],h=[c.x+o[0],c.y+o[1]];dt(r,h),a.push(h)}if("Polygon"===e.type){var f=It(e.coordinates,n,i);if(!mt(r,n))return!1;for(var y=0,d=a;y<d.length;y+=1)if(!xt(d[y],f))return!1}if("MultiPolygon"===e.type){var m=At(e.coordinates,n,i);if(!mt(r,n))return!1;for(var v=0,g=a;v<g.length;v+=1)if(!bt(g[v],m))return!1}return!0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){for(var r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=t.canonicalID(),o=[i.x*yt,i.y*yt],a=[],s=0,u=t.geometry();s<u.length;s+=1){for(var l=[],p=0,c=u[s];p<c.length;p+=1){var h=c[p],f=[h.x+o[0],h.y+o[1]];dt(r,f),l.push(f)}a.push(l)}if("Polygon"===e.type){var y=It(e.coordinates,n,i);if(!mt(r,n))return!1;for(var d=0,m=a;d<m.length;d+=1)if(!St(m[d],y))return!1}if("MultiPolygon"===e.type){var v=At(e.coordinates,n,i);if(!mt(r,n))return!1;for(var g=0,x=a;g<x.length;g+=1)if(!kt(x[g],v))return!1}return!0}(t,this.geometries)}return!1},zt.prototype.eachChild=function(){},zt.prototype.outputDefined=function(){return!0},zt.prototype.serialize=function(){return["within",this.geojson]};var Bt=function(t,e){this.type=e.type,this.name=t,this.boundExpression=e};Bt.parse=function(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");var r=t[1];return e.scope.has(r)?new Bt(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)},Bt.prototype.evaluate=function(t){return this.boundExpression.evaluate(t)},Bt.prototype.eachChild=function(){},Bt.prototype.outputDefined=function(){return!1},Bt.prototype.serialize=function(){return["var",this.name]};var Vt=function(t,e,r,n,i){void 0===e&&(e=[]),void 0===n&&(n=new z),void 0===i&&(i=[]),this.registry=t,this.path=e,this.key=e.map((function(t){return"["+t+"]"})).join(""),this.scope=n,this.errors=i,this.expectedType=r};function Tt(t,e){for(var r,n=t.length-1,i=0,o=n,a=0;i<=o;)if((r=t[a=Math.floor((i+o)/2)])<=e){if(a===n||e<t[a+1])return a;i=a+1}else{if(!(r>e))throw new W("Input is not a number.");o=a-1}return 0}Vt.prototype.parse=function(t,e,r,n,i){return void 0===i&&(i={}),e?this.concat(e,r,n)._parse(t,i):this._parse(t,i)},Vt.prototype._parse=function(t,e){function r(t,e,r){return"assert"===r?new Q(e,[t]):"coerce"===r?new nt(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", []].');var n=t[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;var i=this.registry[n];if(i){var o=i.parse(t,this);if(!o)return null;if(this.expectedType){var a=this.expectedType,s=o.type;if("string"!==a.kind&&"number"!==a.kind&&"boolean"!==a.kind&&"object"!==a.kind&&"array"!==a.kind||"value"!==s.kind)if("color"!==a.kind&&"formatted"!==a.kind&&"resolvedImage"!==a.kind||"value"!==s.kind&&"string"!==s.kind){if(this.checkSubtype(a,s))return null}else o=r(o,a,e.typeAnnotation||"coerce");else o=r(o,a,e.typeAnnotation||"assert")}if(!(o instanceof H)&&"resolvedImage"!==o.type.kind&&function t(e){if(e instanceof Bt)return t(e.boundExpression);if(e instanceof at&&"error"===e.name)return!1;if(e instanceof st)return!1;if(e instanceof zt)return!1;var r=e instanceof nt||e instanceof Q,n=!0;return e.eachChild((function(e){n=r?n&&t(e):n&&e instanceof H})),!!n&&Mt(e)&&Pt(e,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}(o)){var u=new ot;try{o=new H(o.type,o.evaluate(u))}catch(t){return this.error(t.message),null}}return o}return this.error('Unknown expression "'+n+'". If you wanted a literal array, use ["literal", [...]].',0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':"Expected an array, but found "+typeof t+" instead.")},Vt.prototype.concat=function(t,e,r){var n="number"==typeof t?this.path.concat(t):this.path,i=r?this.scope.concat(r):this.scope;return new Vt(this.registry,n,e||null,i,this.errors)},Vt.prototype.error=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];var n=""+this.key+e.map((function(t){return"["+t+"]"})).join("");this.errors.push(new A(n,t))},Vt.prototype.checkSubtype=function(t,e){var r=q(t,e);return r&&this.error(r),r};var Et=function(t,e,r){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(var n=0,i=r;n<i.length;n+=1){var o=i[n],a=o[1];this.labels.push(o[0]),this.outputs.push(a)}};Et.parse=function(t,e){if(t.length-1<4)return e.error("Expected at least 4 arguments, but found only "+(t.length-1)+".");if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");var r=e.parse(t[1],1,C);if(!r)return null;var n=[],i=null;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);for(var o=1;o<t.length;o+=2){var a=1===o?-1/0:t[o],s=t[o+1],u=o,l=o+1;if("number"!=typeof a)return e.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',u);if(n.length&&n[n.length-1][0]>=a)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',u);var p=e.parse(s,l,i);if(!p)return null;i=i||p.type,n.push([a,p])}return new Et(i,r,n)},Et.prototype.evaluate=function(t){var e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);var n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);var i=e.length;return n>=e[i-1]?r[i-1].evaluate(t):r[Tt(e,n)].evaluate(t)},Et.prototype.eachChild=function(t){t(this.input);for(var e=0,r=this.outputs;e<r.length;e+=1)t(r[e])},Et.prototype.outputDefined=function(){return this.outputs.every((function(t){return t.outputDefined()}))},Et.prototype.serialize=function(){for(var t=["step",this.input.serialize()],e=0;e<this.labels.length;e++)e>0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t};var Dt=Ft;function Ft(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=n,this.p2x=r,this.p2y=n}function Lt(t,e,r){return t*(1-r)+e*r}Ft.prototype.sampleCurveX=function(t){return((this.ax*t+this.bx)*t+this.cx)*t},Ft.prototype.sampleCurveY=function(t){return((this.ay*t+this.by)*t+this.cy)*t},Ft.prototype.sampleCurveDerivativeX=function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},Ft.prototype.solveCurveX=function(t,e){var r,n,i,o,a;for(void 0===e&&(e=1e-6),i=t,a=0;a<8;a++){if(o=this.sampleCurveX(i)-t,Math.abs(o)<e)return i;var s=this.sampleCurveDerivativeX(i);if(Math.abs(s)<1e-6)break;i-=o/s}if((i=t)<(r=0))return r;if(i>(n=1))return n;for(;r<n;){if(o=this.sampleCurveX(i),Math.abs(o-t)<e)return i;t>o?r=i:n=i,i=.5*(n-r)+r}return i},Ft.prototype.solve=function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))};var Ot=Object.freeze({__proto__:null,number:Lt,color:function(t,e,r){return new k(Lt(t.r,e.r,r),Lt(t.g,e.g,r),Lt(t.b,e.b,r),Lt(t.a,e.a,r))},array:function(t,e,r){return t.map((function(t,n){return Lt(t,e[n],r)}))}}),jt=.95047,Rt=1,qt=1.08883,Ut=4/29,Nt=6/29,Zt=3*Nt*Nt,Kt=Nt*Nt*Nt,Jt=Math.PI/180,Gt=180/Math.PI;function Xt(t){return t>Kt?Math.pow(t,1/3):t/Zt+Ut}function Yt(t){return t>Nt?t*t*t:Zt*(t-Ut)}function Ht(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Wt(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function $t(t){var e=Wt(t.r),r=Wt(t.g),n=Wt(t.b),i=Xt((.4124564*e+.3575761*r+.1804375*n)/jt),o=Xt((.2126729*e+.7151522*r+.072175*n)/Rt);return{l:116*o-16,a:500*(i-o),b:200*(o-Xt((.0193339*e+.119192*r+.9503041*n)/qt)),alpha:t.a}}function Qt(t){var e=(t.l+16)/116,r=isNaN(t.a)?e:e+t.a/500,n=isNaN(t.b)?e:e-t.b/200;return e=Rt*Yt(e),r=jt*Yt(r),n=qt*Yt(n),new k(Ht(3.2404542*r-1.5371385*e-.4985314*n),Ht(-.969266*r+1.8760108*e+.041556*n),Ht(.0556434*r-.2040259*e+1.0572252*n),t.alpha)}function te(t,e,r){var n=e-t;return t+r*(n>180||n<-180?n-360*Math.round(n/360):n)}var ee={forward:$t,reverse:Qt,interpolate:function(t,e,r){return{l:Lt(t.l,e.l,r),a:Lt(t.a,e.a,r),b:Lt(t.b,e.b,r),alpha:Lt(t.alpha,e.alpha,r)}}},re={forward:function(t){var e=$t(t),r=e.l,n=e.a,i=e.b,o=Math.atan2(i,n)*Gt;return{h:o<0?o+360:o,c:Math.sqrt(n*n+i*i),l:r,alpha:t.a}},reverse:function(t){var e=t.h*Jt,r=t.c;return Qt({l:t.l,a:Math.cos(e)*r,b:Math.sin(e)*r,alpha:t.alpha})},interpolate:function(t,e,r){return{h:te(t.h,e.h,r),c:Lt(t.c,e.c,r),l:Lt(t.l,e.l,r),alpha:Lt(t.alpha,e.alpha,r)}}},ne=Object.freeze({__proto__:null,lab:ee,hcl:re}),ie=function(t,e,r,n,i){this.type=t,this.operator=e,this.interpolation=r,this.input=n,this.labels=[],this.outputs=[];for(var o=0,a=i;o<a.length;o+=1){var s=a[o],u=s[1];this.labels.push(s[0]),this.outputs.push(u)}};function oe(t,e,r,n){var i=n-r,o=t-r;return 0===i?0:1===e?o/i:(Math.pow(e,o)-1)/(Math.pow(e,i)-1)}ie.interpolationFactor=function(t,e,r,n){var i=0;if("exponential"===t.name)i=oe(e,t.base,r,n);else if("linear"===t.name)i=oe(e,1,r,n);else if("cubic-bezier"===t.name){var o=t.controlPoints;i=new Dt(o[0],o[1],o[2],o[3]).solve(oe(e,1,r,n))}return i},ie.parse=function(t,e){var r=t[0],n=t[1],i=t[2],o=t.slice(3);if(!Array.isArray(n)||0===n.length)return e.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){var a=n[1];if("number"!=typeof a)return e.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:a}}else{if("cubic-bezier"!==n[0])return e.error("Unknown interpolation type "+String(n[0]),1,0);var s=n.slice(1);if(4!==s.length||s.some((function(t){return"number"!=typeof t||t<0||t>1})))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:s}}if(t.length-1<4)return e.error("Expected at least 4 arguments, but found only "+(t.length-1)+".");if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(!(i=e.parse(i,2,C)))return null;var u=[],l=null;"interpolate-hcl"===r||"interpolate-lab"===r?l=V:e.expectedType&&"value"!==e.expectedType.kind&&(l=e.expectedType);for(var p=0;p<o.length;p+=2){var c=o[p],h=o[p+1],f=p+3,y=p+4;if("number"!=typeof c)return e.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',f);if(u.length&&u[u.length-1][0]>=c)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',f);var d=e.parse(h,y,l);if(!d)return null;l=l||d.type,u.push([c,d])}return"number"===l.kind||"color"===l.kind||"array"===l.kind&&"number"===l.itemType.kind&&"number"==typeof l.N?new ie(l,r,n,i,u):e.error("Type "+j(l)+" is not interpolatable.")},ie.prototype.evaluate=function(t){var e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);var n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);var i=e.length;if(n>=e[i-1])return r[i-1].evaluate(t);var o=Tt(e,n),a=ie.interpolationFactor(this.interpolation,n,e[o],e[o+1]),s=r[o].evaluate(t),u=r[o+1].evaluate(t);return"interpolate"===this.operator?Ot[this.type.kind.toLowerCase()](s,u,a):"interpolate-hcl"===this.operator?re.reverse(re.interpolate(re.forward(s),re.forward(u),a)):ee.reverse(ee.interpolate(ee.forward(s),ee.forward(u),a))},ie.prototype.eachChild=function(t){t(this.input);for(var e=0,r=this.outputs;e<r.length;e+=1)t(r[e])},ie.prototype.outputDefined=function(){return this.outputs.every((function(t){return t.outputDefined()}))},ie.prototype.serialize=function(){var t;t="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);for(var e=[this.operator,t,this.input.serialize()],r=0;r<this.labels.length;r++)e.push(this.labels[r],this.outputs[r].serialize());return e};var ae=function(t,e){this.type=t,this.args=e};ae.parse=function(t,e){if(t.length<2)return e.error("Expectected at least one argument.");var r=null,n=e.expectedType;n&&"value"!==n.kind&&(r=n);for(var i=[],o=0,a=t.slice(1);o<a.length;o+=1){var s=e.parse(a[o],1+i.length,r,void 0,{typeAnnotation:"omit"});if(!s)return null;r=r||s.type,i.push(s)}var u=n&&i.some((function(t){return q(n,t.type)}));return new ae(u?E:r,i)},ae.prototype.evaluate=function(t){for(var e,r=null,n=0,i=0,o=this.args;i<o.length&&(n++,(r=o[i].evaluate(t))&&r instanceof K&&!r.available&&(e||(e=r.name),r=null,n===this.args.length&&(r=e)),null===r);i+=1);return r},ae.prototype.eachChild=function(t){this.args.forEach(t)},ae.prototype.outputDefined=function(){return this.args.every((function(t){return t.outputDefined()}))},ae.prototype.serialize=function(){var t=["coalesce"];return this.eachChild((function(e){t.push(e.serialize())})),t};var se=function(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e};se.prototype.evaluate=function(t){return this.result.evaluate(t)},se.prototype.eachChild=function(t){for(var e=0,r=this.bindings;e<r.length;e+=1)t(r[e][1]);t(this.result)},se.parse=function(t,e){if(t.length<4)return e.error("Expected at least 3 arguments, but found "+(t.length-1)+" instead.");for(var r=[],n=1;n<t.length-1;n+=2){var i=t[n];if("string"!=typeof i)return e.error("Expected string, but found "+typeof i+" instead.",n);if(/[^a-zA-Z0-9_]/.test(i))return e.error("Variable names must contain only alphanumeric characters or '_'.",n);var o=e.parse(t[n+1],n+1);if(!o)return null;r.push([i,o])}var a=e.parse(t[t.length-1],t.length-1,e.expectedType,r);return a?new se(r,a):null},se.prototype.outputDefined=function(){return this.result.outputDefined()},se.prototype.serialize=function(){for(var t=["let"],e=0,r=this.bindings;e<r.length;e+=1){var n=r[e];t.push(n[0],n[1].serialize())}return t.push(this.result.serialize()),t};var ue=function(t,e,r){this.type=t,this.index=e,this.input=r};ue.parse=function(t,e){if(3!==t.length)return e.error("Expected 2 arguments, but found "+(t.length-1)+" instead.");var r=e.parse(t[1],1,C),n=e.parse(t[2],2,O(e.expectedType||E));return r&&n?new ue(n.type.itemType,r,n):null},ue.prototype.evaluate=function(t){var e=this.index.evaluate(t),r=this.input.evaluate(t);if(e<0)throw new W("Array index out of bounds: "+e+" < 0.");if(e>=r.length)throw new W("Array index out of bounds: "+e+" > "+(r.length-1)+".");if(e!==Math.floor(e))throw new W("Array index must be an integer, but found "+e+" instead.");return r[e]},ue.prototype.eachChild=function(t){t(this.index),t(this.input)},ue.prototype.outputDefined=function(){return!1},ue.prototype.serialize=function(){return["at",this.index.serialize(),this.input.serialize()]};var le=function(t,e){this.type=B,this.needle=t,this.haystack=e};le.parse=function(t,e){if(3!==t.length)return e.error("Expected 2 arguments, but found "+(t.length-1)+" instead.");var r,n=e.parse(t[1],1,E),i=e.parse(t[2],2,E);return n&&i?"boolean"!==(r=n.type).kind&&"string"!==r.kind&&"number"!==r.kind&&"null"!==r.kind&&"value"!==r.kind?e.error("Expected first argument to be of type boolean, string, number or null, but found "+j(n.type)+" instead"):new le(n,i):null},le.prototype.evaluate=function(t){var e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(null==e||!r)return!1;if(!function(t){return"boolean"==typeof t||"string"==typeof t||"number"==typeof t}(e))throw new W("Expected first argument to be of type boolean, string or number, but found "+j(X(e))+" instead.");if(!function(t){return Array.isArray(t)||"string"==typeof t}(r))throw new W("Expected second argument to be of type array or string, but found "+j(X(r))+" instead.");return r.indexOf(e)>=0},le.prototype.eachChild=function(t){t(this.needle),t(this.haystack)},le.prototype.outputDefined=function(){return!0},le.prototype.serialize=function(){return["in",this.needle.serialize(),this.haystack.serialize()]};var pe=function(t,e,r,n,i,o