mapbox-gl
Version:
A WebGL interactive maps library
1 lines • 669 kB
JavaScript
!function(){var t=1e-6,e="undefined"!=typeof Float32Array?Float32Array:Array;function r(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],u=e[7],c=e[8];return t[0]=o*c-a*u,t[1]=i*u-n*c,t[2]=n*a-i*o,t[3]=a*l-s*c,t[4]=r*c-i*l,t[5]=i*s-r*a,t[6]=s*u-o*l,t[7]=n*l-r*u,t[8]=r*o-n*s,t}function n(t,e,r){var n=e[0],i=e[1],s=e[2],o=e[3],a=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=r[0],d=r[1],f=r[2],m=r[3],y=r[4],g=r[5],x=r[6],v=r[7],b=r[8];return t[0]=p*n+d*o+f*u,t[1]=p*i+d*a+f*c,t[2]=p*s+d*l+f*h,t[3]=m*n+y*o+g*u,t[4]=m*i+y*a+g*c,t[5]=m*s+y*l+g*h,t[6]=x*n+v*o+b*u,t[7]=x*i+v*a+b*c,t[8]=x*s+v*l+b*h,t}function i(){var t=new e(16);return e!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function s(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function o(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],u=e[7],c=e[8],h=e[9],p=e[10],d=e[11],f=e[12],m=e[13],y=e[14],g=e[15],x=r*a-n*o,v=r*l-i*o,b=r*u-s*o,w=n*l-i*a,_=n*u-s*a,A=i*u-s*l,S=c*m-h*f,I=c*y-p*f,P=c*g-d*f,M=h*y-p*m,E=h*g-d*m,D=p*g-d*y,C=x*D-v*E+b*M+w*P-_*I+A*S;return C?(t[0]=(a*D-l*E+u*M)*(C=1/C),t[1]=(i*E-n*D-s*M)*C,t[2]=(m*A-y*_+g*w)*C,t[3]=(p*_-h*A-d*w)*C,t[4]=(l*P-o*D-u*I)*C,t[5]=(r*D-i*P+s*I)*C,t[6]=(y*b-f*A-g*v)*C,t[7]=(c*A-p*b+d*v)*C,t[8]=(o*E-a*P+u*S)*C,t[9]=(n*P-r*E-s*S)*C,t[10]=(f*_-m*b+g*x)*C,t[11]=(h*b-c*_-d*x)*C,t[12]=(a*I-o*M-l*S)*C,t[13]=(r*M-n*I+i*S)*C,t[14]=(m*v-f*w-y*x)*C,t[15]=(c*w-h*v+p*x)*C,t):null}function a(t,e,r){var n=e[0],i=e[1],s=e[2],o=e[3],a=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],d=e[10],f=e[11],m=e[12],y=e[13],g=e[14],x=e[15],v=r[0],b=r[1],w=r[2],_=r[3];return t[0]=v*n+b*a+w*h+_*m,t[1]=v*i+b*l+w*p+_*y,t[2]=v*s+b*u+w*d+_*g,t[3]=v*o+b*c+w*f+_*x,t[4]=(v=r[4])*n+(b=r[5])*a+(w=r[6])*h+(_=r[7])*m,t[5]=v*i+b*l+w*p+_*y,t[6]=v*s+b*u+w*d+_*g,t[7]=v*o+b*c+w*f+_*x,t[8]=(v=r[8])*n+(b=r[9])*a+(w=r[10])*h+(_=r[11])*m,t[9]=v*i+b*l+w*p+_*y,t[10]=v*s+b*u+w*d+_*g,t[11]=v*o+b*c+w*f+_*x,t[12]=(v=r[12])*n+(b=r[13])*a+(w=r[14])*h+(_=r[15])*m,t[13]=v*i+b*l+w*p+_*y,t[14]=v*s+b*u+w*d+_*g,t[15]=v*o+b*c+w*f+_*x,t}function l(t,e,r){var n,i,s,o,a,l,u,c,h,p,d,f,m=r[0],y=r[1],g=r[2];return e===t?(t[12]=e[0]*m+e[4]*y+e[8]*g+e[12],t[13]=e[1]*m+e[5]*y+e[9]*g+e[13],t[14]=e[2]*m+e[6]*y+e[10]*g+e[14],t[15]=e[3]*m+e[7]*y+e[11]*g+e[15]):(i=e[1],s=e[2],o=e[3],a=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],d=e[10],f=e[11],t[0]=n=e[0],t[1]=i,t[2]=s,t[3]=o,t[4]=a,t[5]=l,t[6]=u,t[7]=c,t[8]=h,t[9]=p,t[10]=d,t[11]=f,t[12]=n*m+a*y+h*g+e[12],t[13]=i*m+l*y+p*g+e[13],t[14]=s*m+u*y+d*g+e[14],t[15]=o*m+c*y+f*g+e[15]),t}function u(t,e,r){var n=r[0],i=r[1],s=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*s,t[9]=e[9]*s,t[10]=e[10]*s,t[11]=e[11]*s,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function c(t,e,r){var n=Math.sin(r),i=Math.cos(r),s=e[4],o=e[5],a=e[6],l=e[7],u=e[8],c=e[9],h=e[10],p=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=s*i+u*n,t[5]=o*i+c*n,t[6]=a*i+h*n,t[7]=l*i+p*n,t[8]=u*i-s*n,t[9]=c*i-o*n,t[10]=h*i-a*n,t[11]=p*i-l*n,t}function h(t,e,r){var n=Math.sin(r),i=Math.cos(r),s=e[0],o=e[1],a=e[2],l=e[3],u=e[8],c=e[9],h=e[10],p=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*i-u*n,t[1]=o*i-c*n,t[2]=a*i-h*n,t[3]=l*i-p*n,t[8]=s*n+u*i,t[9]=o*n+c*i,t[10]=a*n+h*i,t[11]=l*n+p*i,t}function p(){var t=new e(3);return e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function d(t){var r=new e(3);return r[0]=t[0],r[1]=t[1],r[2]=t[2],r}function f(t){return Math.hypot(t[0],t[1],t[2])}function m(t,r,n){var i=new e(3);return i[0]=t,i[1]=r,i[2]=n,i}function y(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function g(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function x(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function v(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function b(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function w(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t}function _(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return r*r+n*n+i*i}function A(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function S(t,e){var r=e[0],n=e[1],i=e[2],s=r*r+n*n+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t}function I(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function P(t,e,r){var n=e[0],i=e[1],s=e[2],o=r[0],a=r[1],l=r[2];return t[0]=i*l-s*a,t[1]=s*o-n*l,t[2]=n*a-i*o,t}function M(t,e,r,n){var i=e[0],s=e[1],o=e[2];return t[0]=i+n*(r[0]-i),t[1]=s+n*(r[1]-s),t[2]=o+n*(r[2]-o),t}function E(t,e,r){var n=e[0],i=e[1],s=e[2],o=r[3]*n+r[7]*i+r[11]*s+r[15];return t[0]=(r[0]*n+r[4]*i+r[8]*s+r[12])/(o=o||1),t[1]=(r[1]*n+r[5]*i+r[9]*s+r[13])/o,t[2]=(r[2]*n+r[6]*i+r[10]*s+r[14])/o,t}function D(t,e,r){var n=e[0],i=e[1],s=e[2];return t[0]=n*r[0]+i*r[3]+s*r[6],t[1]=n*r[1]+i*r[4]+s*r[7],t[2]=n*r[2]+i*r[5]+s*r[8],t}function C(t,e,r){var n=r[0],i=r[1],s=r[2],o=e[0],a=e[1],l=e[2],u=i*l-s*a,c=s*o-n*l,h=n*a-i*o,p=i*h-s*c,d=s*u-n*h,f=n*c-i*u,m=2*r[3];return c*=m,h*=m,d*=2,f*=2,t[0]=o+(u*=m)+(p*=2),t[1]=a+c+d,t[2]=l+h+f,t}function T(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var k=g,z=f;function B(t,e,r){var n=e[0],i=e[1],s=e[2],o=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*s+r[12]*o,t[1]=r[1]*n+r[5]*i+r[9]*s+r[13]*o,t[2]=r[2]*n+r[6]*i+r[10]*s+r[14]*o,t[3]=r[3]*n+r[7]*i+r[11]*s+r[15]*o,t}function L(){var t=new e(4);return e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}p(),function(){var t;t=new e(4),e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0)}();var V,F,R,O,N,U,j=(V=p(),F=m(1,0,0),R=m(0,1,0),function(t,e,r){var n=I(e,r);return n<-.999999?(P(V,F,e),z(V)<1e-6&&P(V,R,e),S(V,V),function(t,e,r){r*=.5;var n=Math.sin(r);t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r)}(t,V,Math.PI),t):n>.999999?(t[0]=0,t[1]=0,t[2]=0,t[3]=1,t):(P(V,e,r),t[0]=V[0],t[1]=V[1],t[2]=V[2],t[3]=1+n,function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=r*r+n*n+i*i+s*s;return o>0&&(o=1/Math.sqrt(o)),t[0]=r*o,t[1]=n*o,t[2]=i*o,t[3]=s*o,t}(t,t))});function G(){var t=new e(2);return e!=Float32Array&&(t[0]=0,t[1]=0),t}function $(t,r){var n=new e(2);return n[0]=t,n[1]=r,n}function q(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t}function X(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function H(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t}function Z(t){return Math.hypot(t[0],t[1])}function W(t,e){var r=e[0],n=e[1],i=r*r+n*n;return i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i,t}function Y(t,e){return t[0]*e[0]+t[1]*e[1]}function J(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}L(),L(),O=new e(9),e!=Float32Array&&(O[1]=0,O[2]=0,O[3]=0,O[5]=0,O[6]=0,O[7]=0),O[0]=1,O[4]=1,O[8]=1,G();var K,Q,tt=function(){if(U)return N;function t(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}return U=1,N=t,t.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 o=0,a=1;for(r=t,n=0;n<20&&(i=this.sampleCurveX(r),!(Math.abs(i-t)<e));n++)t>i?o=r:a=r,r=.5*(a-o)+o;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},N}(),et=J(tt);function rt(){if(Q)return K;function t(t,e){this.x=t,this.y=e}return Q=1,K=t,t.prototype={clone:function(){return new t(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}},t.convert=function(e){return e instanceof t?e:Array.isArray(e)?new t(e[0],e[1]):e},K}var nt=J(rt());function it(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!it(t[r],e[r]))return!1;return!0}if("object"==typeof t&&null!==t&&null!==e){if("object"!=typeof e)return!1;if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const r in t)if(!it(t[r],e[r]))return!1;return!0}return t===e}const st=Math.PI/180,ot=180/Math.PI;function at(t){return t*st}function lt(t){return t*ot}function ut(t,e,r){return Math.min(r,Math.max(e,t))}function ct(t,e,r){return(r=ut((r-t)/(e-t),0,1))*r*(3-2*r)}function ht(t,e,r){const n=r-e,i=((t-e)%n+n)%n+e;return i===e?r:i}function pt(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}function dt(t,e){t.forEach((t=>{e[t]&&(e[t]=e[t].bind(e))}))}function ft(t,e,r){const n={};for(const r in t)n[r]=e.call(this,t[r],r,t);return n}function mt(t){return Array.isArray(t)?t.map(mt):"object"==typeof t&&t?ft(t,mt):t}function yt(t,e){for(let r=0;r<t.length;r++)if(e.indexOf(t[r])>=0)return!0;return!1}new et(.25,.1,.25,1);const gt={};function xt(t){gt[t]||("undefined"!=typeof console&&console.warn(t),gt[t]=!0)}function vt(t,e,r){return(r.y-t.y)*(e.x-t.x)>(e.y-t.y)*(r.x-t.x)}function bt(t){let e=0;for(let r,n,i=0,s=t.length,o=s-1;i<s;o=i++)r=t[i],n=t[o],e+=(n.x-r.x)*(r.y+n.y);return e}function wt(t){return("undefined"!=typeof self||void 0!==t)&&"undefined"!=typeof WorkerGlobalScope&&(void 0!==t?t:self)instanceof WorkerGlobalScope}function _t(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 St(t,e){return[t[4*e],t[4*e+1],t[4*e+2],t[4*e+3]]}function It(t,e,r,n){for(;e<r;){const i=e+r>>1;t[i]<n?e=i+1:r=i}return e}function Pt(t,e,r,n){for(;e<r;){const i=e+r>>1;t[i]<=n?e=i+1:r=i}return e}function Mt(t,e,r){return(t-e.min)*(r.max-r.min)/(e.max-e.min)+r.min}var Et,Dt,Ct,Tt=function(){if(Dt)return Et;Dt=1,Et=e;var t=3;function e(e,r,n){var i=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;var s=new Int32Array(this.arrayBuffer);e=s[0],this.d=(r=s[1])+2*(n=s[2]);for(var o=0;o<this.d*this.d;o++){var a=s[t+o],l=s[t+o+1];i.push(a===l?null:s.subarray(a,l))}var u=s[t+i.length+1];this.keys=s.subarray(s[t+i.length],u),this.bboxes=s.subarray(u),this.insert=this._insertReadonly}else{this.d=r+2*n;for(var c=0;c<this.d*this.d;c++)i.push([]);this.keys=[],this.bboxes=[]}this.n=r,this.extent=e,this.padding=n,this.scale=r/e,this.uid=0;var h=n/r*e;this.min=-h,this.max=e+h}return e.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)},e.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},e.prototype._insertCell=function(t,e,r,n,i,s){this.cells[i].push(s)},e.prototype.query=function(t,e,r,n,i){var s=this.min,o=this.max;if(t<=s&&e<=s&&o<=r&&o<=n&&!i)return Array.prototype.slice.call(this.keys);var a=[];return this._forEachCell(t,e,r,n,this._queryCell,a,{},i),a},e.prototype._queryCell=function(t,e,r,n,i,s,o,a){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===o[p]){var d=4*p;(a?a(c[d+0],c[d+1],c[d+2],c[d+3]):t<=c[d+2]&&e<=c[d+3]&&r>=c[d+0]&&n>=c[d+1])?(o[p]=!0,s.push(u[p])):o[p]=!1}}},e.prototype._forEachCell=function(t,e,r,n,i,s,o,a){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 d=u;d<=h;d++){var f=this.d*d+p;if((!a||a(this._convertFromCellCoord(p),this._convertFromCellCoord(d),this._convertFromCellCoord(p+1),this._convertFromCellCoord(d+1)))&&i.call(this,t,e,r,n,f,s,o,a))return}},e.prototype._convertFromCellCoord=function(t){return(t-this.padding)/this.scale},e.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},e.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var e=this.cells,r=t+this.cells.length+1+1,n=0,i=0;i<this.cells.length;i++)n+=this.cells[i].length;var s=new Int32Array(r+n+this.keys.length+this.bboxes.length);s[0]=this.extent,s[1]=this.n,s[2]=this.padding;for(var o=r,a=0;a<e.length;a++){var l=e[a];s[t+a]=o,s.set(l,o),o+=l.length}return s[t+e.length]=o,s.set(this.keys,o),s[t+e.length+1]=o+=this.keys.length,s.set(this.bboxes,o),o+=this.bboxes.length,s.buffer},Et}(),kt=J(Tt),zt={},Bt=function(){if(Ct)return zt;Ct=1;var t={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 e(t){return(t=Math.round(t))<0?0:t>255?255:t}function r(t){return e("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function n(t){return(e="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e}function i(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{zt.parseCSSColor=function(s){var o,a=s.replace(/ /g,"").toLowerCase();if(a in t)return t[a].slice();if("#"===a[0])return 4===a.length?(o=parseInt(a.substr(1),16))>=0&&o<=4095?[(3840&o)>>4|(3840&o)>>8,240&o|(240&o)>>4,15&o|(15&o)<<4,1]:null:7===a.length&&(o=parseInt(a.substr(1),16))>=0&&o<=16777215?[(16711680&o)>>16,(65280&o)>>8,255&o,1]:null;var l=a.indexOf("("),u=a.indexOf(")");if(-1!==l&&u+1===a.length){var c=a.substr(0,l),h=a.substr(l+1,u-(l+1)).split(","),p=1;switch(c){case"rgba":if(4!==h.length)return null;p=n(h.pop());case"rgb":return 3!==h.length?null:[r(h[0]),r(h[1]),r(h[2]),p];case"hsla":if(4!==h.length)return null;p=n(h.pop());case"hsl":if(3!==h.length)return null;var d=(parseFloat(h[0])%360+360)%360/360,f=n(h[1]),m=n(h[2]),y=m<=.5?m*(f+1):m+f-m*f,g=2*m-y;return[e(255*i(g,y,d+1/3)),e(255*i(g,y,d)),e(255*i(g,y,d-1/3)),p];default:return null}}return null}}catch(t){}return zt}();function Lt(t,e,r){return t*(1-r)+e*r}var Vt=Object.freeze({__proto__:null,array:function(t,e,r){return t.map(((t,n)=>Lt(t,e[n],r)))},color:function(t,e,r){return new Color(Lt(t.r,e.r,r),Lt(t.g,e.g,r),Lt(t.b,e.b,r),Lt(t.a,e.a,r))},number:Lt});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=Bt.parseCSSColor(t);return e?new Color(e[0]/255,e[1]/255,e[2]/255,e[3]):void 0}toString(){const[t,e,r,n]=[this.r,this.g,this.b,this.a];return`rgba(${Math.round(255*t)},${Math.round(255*e)},${Math.round(255*r)},${n})`}toNonPremultipliedRenderColor(t){const{r:e,g:r,b:n,a:i}=this;return new NonPremultipliedRenderColor(t,e,r,n,i)}toPremultipliedRenderColor(t){const{r:e,g:r,b:n,a:i}=this;return new PremultipliedRenderColor(t,e*i,r*i,n*i,i)}clone(){return new Color(this.r,this.g,this.b,this.a)}}class RenderColor{constructor(t,e,r,n,i,s=!1){if(this.premultiplied=!1,this.premultiplied=s,t){const s=t.image.height,o=s*s;this.premultiplied?(e=0===i?0:e/i*(s-1),r=0===i?0:r/i*(s-1),n=0===i?0:n/i*(s-1)):(e*=s-1,r*=s-1,n*=s-1);const a=Math.floor(e),l=Math.floor(r),u=Math.floor(n),c=Math.ceil(e),h=Math.ceil(r),p=Math.ceil(n),d=e-a,f=r-l,m=n-u,y=t.image.data,g=4*(a+l*o+u*s),x=4*(a+l*o+p*s),v=4*(a+h*o+u*s),b=4*(a+h*o+p*s),w=4*(c+l*o+u*s),_=4*(c+l*o+p*s),A=4*(c+h*o+u*s),S=4*(c+h*o+p*s);if(g<0||S>=y.length)throw new Error("out of range");this.r=Lt(Lt(Lt(y[g],y[x],m),Lt(y[v],y[b],m),f),Lt(Lt(y[w],y[_],m),Lt(y[A],y[S],m),f),d)/255*(this.premultiplied?i:1),this.g=Lt(Lt(Lt(y[g+1],y[x+1],m),Lt(y[v+1],y[b+1],m),f),Lt(Lt(y[w+1],y[_+1],m),Lt(y[A+1],y[S+1],m),f),d)/255*(this.premultiplied?i:1),this.b=Lt(Lt(Lt(y[g+2],y[x+2],m),Lt(y[v+2],y[b+2],m),f),Lt(Lt(y[w+2],y[_+2],m),Lt(y[A+2],y[S+2],m),f),d)/255*(this.premultiplied?i:1),this.a=i}else this.r=e,this.g=r,this.b=n,this.a=i}toArray(){const{r:t,g:e,b:r,a:n}=this;return[255*t,255*e,255*r,n]}toHslaArray(){let{r:t,g:e,b:r,a:n}=this;if(this.premultiplied){if(0===n)return[0,0,0,0];t/=n,e/=n,r/=n}const i=Math.min(Math.max(t,0),1),s=Math.min(Math.max(e,0),1),o=Math.min(Math.max(r,0),1),a=Math.min(i,s,o),l=Math.max(i,s,o),u=(a+l)/2;if(a===l)return[0,0,100*u,n];const c=l-a,h=u>.5?c/(2-l-a):c/(l+a);let p=0;return l===i?p=(s-o)/c+(s<o?6:0):l===s?p=(o-i)/c+2:l===o&&(p=(i-s)/c+4),p*=60,[Math.min(Math.max(p,0),360),Math.min(Math.max(100*h,0),100),Math.min(Math.max(100*u,0),100),n]}toArray01(){const{r:t,g:e,b:r,a:n}=this;return[t,e,r,n]}toArray01Scaled(t){const{r:e,g:r,b:n}=this;return[e*t,r*t,n*t]}toArray01Linear(){const{r:t,g:e,b:r,a:n}=this;return[Math.pow(t,2.2),Math.pow(e,2.2),Math.pow(r,2.2),n]}}class NonPremultipliedRenderColor extends RenderColor{constructor(t,e,r,n,i){super(t,e,r,n,i,!1)}}class PremultipliedRenderColor extends RenderColor{constructor(t,e,r,n,i){super(t,e,r,n,i,!0)}}function Ft(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}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);class ParsingError extends Error{constructor(t,e){super(e),this.message=e,this.key=t}}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)}}const Rt={kind:"null"},Ot={kind:"number"},Nt={kind:"string"},Ut={kind:"boolean"},jt={kind:"color"},Gt={kind:"object"},$t={kind:"value"},qt={kind:"collator"},Xt={kind:"formatted"},Ht={kind:"resolvedImage"};function Zt(t,e){return{kind:"array",itemType:t,N:e}}function Wt(t){if("array"===t.kind){const e=Wt(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const Yt=[Rt,Ot,Nt,Ut,jt,Xt,Gt,Zt($t),Ht];function Jt(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Jt(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 Yt)if(!Jt(t,e))return null}return`Expected ${Wt(t)} but found ${Wt(e)} instead.`}function Kt(t,e){return e.some((e=>e.kind===t.kind))}function Qt(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))}function te(t,e){return"array"===t.kind&&"array"===e.kind?t.N===e.N&&te(t.itemType,e.itemType):t.kind===e.kind}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&&t.image.hasPrimary()))}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){const r=e.image.getPrimary().id.toString();t.push(["image",r]);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.toNonPremultipliedRenderColor(null).toArray())),t.push(r)}return t}}class ImageId{constructor(t){"string"==typeof t?this.name=t:(this.name=t.name,this.iconsetId=t.iconsetId)}static from(t){return new ImageId(t)}static toString(t){return t.iconsetId?`${t.name}${t.iconsetId}`:t.name}static parse(t){const[e,r]=t.split("");return new ImageId({name:e,iconsetId:r})}static isEqual(t,e){return t.name===e.name&&t.iconsetId===e.iconsetId}toString(){return ImageId.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}class ImageVariant{constructor(t,e={}){if(this.id=ImageId.from(t),this.options=Object.assign({},e),e.transform){const{a:t,b:r,c:n,d:i,e:s,f:o}=e.transform;this.options.transform=new DOMMatrix([t,r,n,i,s,o])}else this.options.transform=new DOMMatrix([1,0,0,1,0,0])}toString(){const{a:t,b:e,c:r,d:n,e:i,f:s}=this.options.transform;return JSON.stringify({name:this.id.name,iconsetId:this.id.iconsetId,params:this.options.params,transform:{a:t,b:e,c:r,d:n,e:i,f:s}})}static parse(t){let e,r,n,i;try{({name:e,iconsetId:r,params:n,transform:i}=JSON.parse(t)||{})}catch(t){return null}if(!e)return null;const{a:s,b:o,c:a,d:l,e:u,f:c}=i||{};return new ImageVariant({name:e,iconsetId:r},{params:n,transform:new DOMMatrix([s,o,a,l,u,c])})}scaleSelf(t,e){return this.options.transform.scaleSelf(t,e),this}}class ResolvedImage{constructor(t,e,r,n,i=!1){this.primaryId=ImageId.from(t),this.primaryOptions=e,r&&(this.secondaryId=ImageId.from(r)),this.secondaryOptions=n,this.available=i}toString(){return this.primaryId&&this.secondaryId?`[${this.primaryId.name},${this.secondaryId.name}]`:this.primaryId.name}hasPrimary(){return!!this.primaryId}getPrimary(){return new ImageVariant(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new ImageVariant(this.secondaryId,this.secondaryOptions):null}static from(t){return"string"==typeof t?ResolvedImage.build({name:t}):t}static build(t,e,r,n){return!t||"object"==typeof t&&!("name"in t)?null:new ResolvedImage(t,r,e,n)}}function ee(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 re(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 Color)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(!re(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!re(t[e]))return!1;return!0}return!1}function ne(t){if(null===t)return Rt;if("string"==typeof t)return Nt;if("boolean"==typeof t)return Ut;if("number"==typeof t)return Ot;if(t instanceof Color)return jt;if(t instanceof Collator)return qt;if(t instanceof Formatted)return Xt;if(t instanceof ResolvedImage)return Ht;if(Array.isArray(t)){const e=t.length;let r;for(const e of t){const t=ne(e);if(r){if(r===t)continue;r=$t;break}r=t}return Zt(r||$t,e)}return Gt}function ie(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof Formatted||t instanceof ResolvedImage||t instanceof Color?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(!re(t[1]))return e.error("invalid value");const r=t[1];let n=ne(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 Color?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof Formatted?this.value.serialize():this.value}}class RuntimeError{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}}const se={string:Nt,number:Ot,boolean:Ut,object:Gt};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 se)||"object"===r)return e.error('The item type argument of "array" must be one of string, number, boolean',1);i=se[r],n++}else i=$t;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=Zt(i,s)}else r=se[i];const s=[];for(;n<t.length;n++){const r=e.parse(t[n],n,$t);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(!Jt(this.type,ne(r)))return r;if(e===this.args.length-1)throw new RuntimeError(`The expression ${JSON.stringify(this.args[e].serialize())} evaluated to ${Wt(ne(r))} but was expected to be of type ${Wt(this.type)}.`)}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())))}}class FormatExpression{constructor(t){this.type=Xt,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.parseObjectValue(s["font-scale"],r,"font-scale",Ot),!t))return null;let o=null;if(s["text-font"]&&(o=e.parseObjectValue(s["text-font"],r,"text-font",Zt(Nt)),!o))return null;let a=null;if(s["text-color"]&&(a=e.parseObjectValue(s["text-color"],r,"text-color",jt),!a))return null;const l=n[n.length-1];l.scale=t,l.font=o,l.textColor=a}else{const s=e.parse(t[r],r,$t);if(!s)return null;const o=s.type.kind;if("string"!==o&&"value"!==o&&"null"!==o&&"resolvedImage"!==o)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 te(ne(r),Ht)?new FormattedSection("",r,null,null,null):new FormattedSection(ie(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,r,n){this._imageWarnHistory={},this.type=Ht,this.namePrimary=t,this.nameSecondary=e,r&&(this.paramsPrimary=r.params,this.iconsetIdPrimary=r.iconset?r.iconset.id:void 0),n&&(this.paramsSecondary=n.params,this.iconsetIdSecondary=n.iconset?n.iconset.id:void 0)}static parse(t,e){if(t.length<2)return e.error("Expected two or more arguments.");let r=1;const n=[];function i(){if(r<t.length){const i=e.parse(t[r],r++,Nt);return i?(n.push({image:i,options:{}}),!0):(e.error(n.length?"Secondary image variant is not a string.":"No image name provided."),!1)}return!0}function s(){if(r<t.length){const s=t[r];if(null===(i=s)||"object"!=typeof i||Array.isArray(i))return!0;const o=s.params,a=s.iconset,l=e.concat(r);if(!o&&!a)return r++,!0;if(o){if("object"!=typeof o||o.constructor!==Object)return l.error('Image options "params" should be an object'),!1;const t={},e=l.concat(void 0,"params");for(const r in o){if(!r)return e.error("Image parameter name should be non-empty"),!1;const n=e.concat(void 0,r).parse(o[r],void 0,jt,void 0,{typeAnnotation:"coerce"});if(!n)return!1;t[r]=n}n[n.length-1].options.params=t}if(a){if("object"!=typeof a||a.constructor!==Object)return l.error('Image options "iconset" should be an object'),!1;if(!a.id)return l.error('Image options "iconset" should have an "id" property'),!1;n[n.length-1].options.iconset=a}return r++,!0}var i;return!0}for(let t=0;t<2;t++)if(!i()||!s())return;return new ImageExpression(n[0].image,n[1]?n[1].image:void 0,n[0].options,n[1]?n[1].options:void 0)}evaluateParams(t,e){const r={};if(e){for(const n in e)if(e[n])try{r[n]=e[n].evaluate(t)}catch(t){continue}if(0!==Object.keys(r).length)return{params:r}}}evaluate(t){const e={name:this.namePrimary.evaluate(t),iconsetId:this.iconsetIdPrimary},r=this.nameSecondary?{name:this.nameSecondary.evaluate(t),iconsetId:this.iconsetIdSecondary}:void 0,n=ResolvedImage.build(e,r,this.paramsPrimary?this.evaluateParams(t,this.paramsPrimary):void 0,this.paramsSecondary?this.evaluateParams(t,this.paramsSecondary):void 0);if(n&&t.availableImages){const e=n.getPrimary().id;if(n.available=t.availableImages.some((t=>ImageId.isEqual(t,e))),n.available){const e=n.getSecondary()?n.getSecondary().id:null;e&&(n.available=t.availableImages.some((t=>ImageId.isEqual(t,e))))}}return n}eachChild(t){if(t(this.namePrimary),this.paramsPrimary)for(const e in this.paramsPrimary)this.paramsPrimary[e]&&t(this.paramsPrimary[e]);if(this.nameSecondary&&(t(this.nameSecondary),this.paramsSecondary))for(const e in this.paramsSecondary)this.paramsSecondary[e]&&t(this.paramsSecondary[e])}outputDefined(){return!1}serializeOptions(t,e){const r={};if(e&&(r.iconset={id:e}),t){r.params={};for(const e in t)t[e]&&(r.params[e]=t[e].serialize())}return Object.keys(r).length>0?r:void 0}serialize(){const t=["image",this.namePrimary.serialize()];if(this.paramsPrimary||this.iconsetIdPrimary){const e=this.serializeOptions(this.paramsPrimary,this.iconsetIdPrimary);e&&t.push(e)}if(this.nameSecondary&&(t.push(this.nameSecondary.serialize()),this.paramsSecondary||this.iconsetIdSecondary)){const e=this.serializeOptions(this.paramsSecondary,this.iconsetIdSecondary);e&&t.push(e)}return t}}function oe(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}const ae={"to-boolean":Ut,"to-color":jt,"to-number":Ot,"to-string":Nt};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=Rt;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=Zt(e.expectedType.itemType,r)}else{if(!(r>0&&re(t[1][0])))return null;i=Zt(ne(t[1][0]),r)}for(let s=0;s<r;s++){const r=t[1][s];let o;if("array"===oe(r))o=e.parse(r,void 0,i.itemType);else{const t=oe(r);if(t!==i.itemType.kind)return e.error(`Expected ${i.itemType.kind} but found ${t}.`);o=e.registry.literal.parse(["literal",void 0===r?null:r],e)}if(!o)return null;n.push(o)}}else{if(("to-boolean"===r||"to-string"===r)&&2!==t.length)return e.error("Expected one argument.");i=ae[r];for(let r=1;r<t.length;r++){const i=e.parse(t[r],r,$t);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 Color)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.`:ee(e[0],e[1],e[2],e[3]),!r))return new Color(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new RuntimeError(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 RuntimeError(`Could not convert ${JSON.stringify(e)} to number.`)}return"formatted"===this.type.kind?Formatted.fromString(ie(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?ResolvedImage.build(ie(this.args[0].evaluate(t))):"array"===this.type.kind?this.args.map((e=>e.evaluate(t))):ie(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}}const le=["Unknown","Point","LineString","Polygon"];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?le[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]=Color.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,o=[];let a=null,l=-1;for(const[n,u]of s){if(Array.isArray(n)&&n.length!==t.length-1)continue;o.push(n),l++,a=new ParsingContext(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,o=a.parse(r,1+s.length,i);if(!o){c=!0;break}s.push(o)}if(!c)if(Array.isArray(n)&&n.length!==s.length)a.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];a.concat(t+1).checkSubtype(e,r.type)}if(0===a.errors.length)return new CompoundExpression(r,i,u,s,l)}}if(1===o.length)e.errors.push(...a.errors);else{const r=(o.length?o:s.map((([t])=>t))).map(ue).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(Wt(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 ue(t){return Array.isArray(t)?`(${t.map(Wt).join(", ")})`:`(${Wt(t.type)}...)`}class CollatorExpression{constructor(t,e,r){this.type=qt,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=void 0===r["case-sensitive"]?e.parse(!1,1,Ut):e.parseObjectValue(r["case-sensitive"],1,"case-sensitive",Ut);if(!n)return null;const i=void 0===r["diacritic-sensitive"]?e.parse(!1,1,Ut):e.parseObjectValue(r["diacritic-sensitive"],1,"diacritic-sensitive",Ut);if(!i)return null;let s=null;return r.locale&&(s=e.parseObjectValue(r.locale,1,"locale",Nt),!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]}}function ce(t,e,r=0,n=t.length-1,i=pe){for(;n>r;){if(n-r>600){const s=n-r+1,o=e-r+1,a=Math.log(s),l=.5*Math.exp(2*a/3),u=.5*Math.sqrt(a*l*(s-l)/s)*(o-s/2<0?-1:1);ce(t,e,Math.max(r,Math.floor(e-o*l/s+u)),Math.min(n,Math.floor(e+(s-o)*l/s+u)),i)}const s=t[e];let o=r,a=n;for(he(t,r,e),i(t[n],s)>0&&he(t,r,n);o<a;){for(he(t,o,a),o++,a--;i(t[o],s)<0;)o++;for(;i(t[a],s)>0;)a--}0===i(t[r],s)?he(t,r,a):(a++,he(t,a,n)),a<=e&&(r=a+1),e<=a&&(n=a-1)}}function he(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function pe(t,e){return t<e?-1:t>e?1:0}function de(t){let e=0;for(let r,n,i=0,s=t.length,o=s-1;i<s;o=i++)r=t[i],n=t[o],e+=(n.x-r.x)*(r.y+n.y);return e}function fe(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 me(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function ye(t,e,r){const n=t[0]-e[0],i=t[1]-e[1],s=t[0]-r[0],o=t[1]-r[1];return n*o-s*i==0&&n*s<=0&&i*o<=0}function ge(t,e,r=!1){let n=!1;for(let a=0,l=e.length;a<l;a++){const l=e[a];for(let e=0,a=l.length,u=a-1;e<a;u=e++){const a=l[u],c=l[e];if(ye(t,a,c))return r;(s=a)[1]>(i=t)[1]!=(o=c)[1]>i[1]&&i[0]<(o[0]-s[0])*(i[1]-s[1])/(o[1]-s[1])+s[0]&&(n=!n)}}var i,s,o;return n}function xe(t,e,r,n){const i=n[0]-r[0],s=n[1]-r[1],o=(t[0]-r[0])*s-i*(t[1]-r[1]),a=(e[0]-r[0])*s-i*(e[1]-r[1]);return o>0&&a<0||o<0&&a>0}function ve(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]&&!(!xe(t,e,r,n)||!xe(r,n,t,e));var i,s}function be(t){const e=new nt(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),r=new nt(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const n of t[0])e.x>n.x&&(e.x=n.x),e.y>n.y&&(e.y=n.y),r.x<n.x&&(r.x=n.x),r.y<n.y&&(r.y=n.y);return{min:e,max:r}}const we=8192;function _e(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*we),Math.round(n*i*we)]}function Ae(t,e){for(let r=0;r<e.length;r++)if(ge(t,e[r]))return!0;return!1}function Se(t,e,r){for(const n of r)for(let r=0,i=n.length,s=i-1;r<i;s=r++)if(ve(t,e,n[s],n[r]))return!0;return!1}function Ie(t,e){for(let r=0;r<t.length;++r)if(!ge(t[r],e))return!1;for(let r=0;r<t.length-1;++r)if(Se(t[r],t[r+1],e))return!1;return!0}function Pe(t,e){for(let r=0;r<e.length;r++)if(Ie(t,e[r]))return!0;return!1}function Me(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 o=_e(t[i][n],r);fe(e,o),s.push(o)}n.push(s)}return n}function Ee(t,e,r){const n=[];for(let i=0;i<t.length;i++){const s=Me(t[i],e,r);n.push(s)}return n}function De(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}fe(e,t)}function Ce(t,e,r,n){const i=Math.pow(2,n.z)*we,s=[n.x*we,n.y*we],o=[];if(!t)return o;for(const n of t)for(const t of n){const n=[t.x+s[0],t.y+s[1]];De(n,e,r,i),o.push(n)}return o}function Te(t,e,r,n){const i=Math.pow(2,n.z)*we,s=[n.x*we,n.y*we],o=[];if(!t)return o;for(const r of t){const t=[];for(const n of r){const r=[n.x+s[0],n.y+s[1]];fe(e,r),t.push(r)}o.push(t)}if(e[2]-e[0]<=i/2){(a=e)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const t of o)for(const n of t)De(n,e,r,i)}var a;return o}class Within{constructor(t,e){this.type=Ut,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(re(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=Me(e.coordinates,n,i),o=Ce(t.geometry(),r,n,i);if(!me(r,n))return!1;for(const t of o)if(!ge(t,s))return!1}if("MultiPolygon"===e.type){const s=Ee(e.coordinates,n,i),o=Ce(t.geometry(),r,n,i);if(!me(r,n))return!1;for(const t of o)if(!Ae(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=Me(e.coordinates,n,i),o=Te(t.geometry(),r,n,i);if(!me(r,n))return!1;for(const t of o)if(!Ie(t,s))return!1}if("MultiPolygon"===e.type){const s=Ee(e.coordinates,n,i),o=Te(t.geometry(),r,n,i);if(!me(r,n))return!1;for(const t of o)if(!Pe(t,s))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}const ke={kilometers:1,miles:1e3/1609.344,nauticalmiles:1e3/1852,meters:1e3,metres:1e3,yards:1e3/.9144,feet:1e3/.3048,inches:1e3/.0254},ze=1/298.257223563,Be=ze*(2-ze),Le=Math.PI/180;class CheapRuler{static fromTile(t,e,r){const n=Math.PI*(1-2*(t+.5)/Math.pow(2,e)),i=Math.atan(.5*(Math.exp(n)-Math.exp(-n)))/Le;return new CheapRuler(i,r)}static get units(){return ke}constructor(t,e){if(void 0===t)throw new Error("No latitude given.");if(e&&!ke[e])throw new Error(`Unknown unit ${e}. Use one of: ${Object.keys(ke).join(", ")}`);const r=6378.137*Le*(e?ke[e]:1),n=Math.cos(t*Le),i=1/(1-Be*(1-n*n)),s=Math.sqrt(i);this.kx=r*s*n,this.ky=r*s*i*(1-Be)}distance(t,e){const r=Re(t[0]-e[0])*this.kx,n=(t[1]-e[1])*this.ky;return Math.sqrt(r*r+n*n)}bearing(t,e){const r=Re(e[0]-t[0])*this.kx;return Math.atan2(r,(e[1]-t[1])*this.ky)/Le}destination(t,e,r){const n=r*Le;return this.offset(t,Math.sin(n)*e,Math.cos(n)*e)}offset(t,e,r){return[t[0]+e/this.kx,t[1]+r/this.ky]}lineDistance(t){let e=0;for(let r=0;r<t.length-1;r++)e+=this.distance(t[r],t[r+1]);return e}area(t){let e=0;for(let r=0;r<t.length;r++){const n=t[r];for(let t=0,i=n.length,s=i-1;t<i;s=t++)e+=Re(n[t][0]-n[s][0])*(n[t][1]+n[s][1])*(r?-1:1)}return Math.abs(e)/2*this.kx*this.ky}along(t,e){let r=0;if(e<=0)return t[0];for(let n=0;n<t.length-1;n++){const i=t[n],s=t[n+1],o=this.distance(i,s);if(r+=o,r>e)return Fe(i,s,(e-(r-o))/o)}return t[t.length-1]}pointToSegmentDistance(t,e,r){let[n,i]=e,s=Re(r[0]-n)*this.kx,o=(r[1]-i)*this.ky;if(0!==s||0!==o){const e=(Re(t[0]-n)*this.kx*s+(t[1]-i)*this.ky*o)/(s*s+o*o);e>1?(n=r[0],i=r[1]):e>0&&(n+=s/this.kx*e,i+=o/this.ky