import{a as b,f as Y,l as rt}from"./StyleDefinition.d56936e4.js";import{T as et}from"./enums.54326430.js";import{t as jt,b1 as I,e7 as ne}from"./index.6c049565.js";import{C as g}from"./enums.2d9e6f64.js";import{t as A}from"./VertexElementDescriptor.1fdca6da.js";import{v as Kt,p as qt,z as Wt}from"./colorUtils.bb6424b7.js";import{b as P}from"./GeometryUtils.4f19e772.js";import{s as wt}from"./Geometry.d049a63c.js";import{a3 as oe}from"./enums.0295eb81.js";class le{constructor(t){this._array=[],t<=0&&console.error("strideInBytes must be positive!"),this._stride=t}get array(){return this._array}get index(){return 4*this._array.length/this._stride}get itemSize(){return this._stride}get sizeInBytes(){return 4*this._array.length}reset(){this.array.length=0}toBuffer(){return new Uint32Array(this._array).buffer}static i1616to32(t,e){return 65535&t|e<<16}static i8888to32(t,e,r,s){return 255&t|(255&e)<<8|(255&r)<<16|s<<24}static i8816to32(t,e,r){return 255&t|(255&e)<<8|r<<16}}var h,J;(function(i){i[i.R8_SIGNED=0]="R8_SIGNED",i[i.R8_UNSIGNED=1]="R8_UNSIGNED",i[i.R16_SIGNED=2]="R16_SIGNED",i[i.R16_UNSIGNED=3]="R16_UNSIGNED",i[i.R8G8_SIGNED=4]="R8G8_SIGNED",i[i.R8G8_UNSIGNED=5]="R8G8_UNSIGNED",i[i.R16G16_SIGNED=6]="R16G16_SIGNED",i[i.R16G16_UNSIGNED=7]="R16G16_UNSIGNED",i[i.R8G8B8A8_SIGNED=8]="R8G8B8A8_SIGNED",i[i.R8G8B8A8_UNSIGNED=9]="R8G8B8A8_UNSIGNED",i[i.R8G8B8A8_COLOR=10]="R8G8B8A8_COLOR",i[i.R16G16B16A16_DASHARRAY=11]="R16G16B16A16_DASHARRAY",i[i.R16G16B16A16_PATTERN=12]="R16G16B16A16_PATTERN"})(h||(h={})),function(i){i[i.UNIFORM=0]="UNIFORM",i[i.DATA_DRIVEN=1]="DATA_DRIVEN",i[i.INTERPOLATED_DATA_DRIVEN=2]="INTERPOLATED_DATA_DRIVEN",i[i.UNUSED=3]="UNUSED"}(J||(J={}));class C{constructor(t){this._locations=new Map,this._key=t}get key(){return this._key}get type(){return 7&this._key}defines(){return[]}getStride(){return this._layoutInfo||this._buildAttributesInfo(),this._stride}getAttributeLocations(){return this._locations.size===0&&this._buildAttributesInfo(),this._locations}getLayoutInfo(){return this._layoutInfo||this._buildAttributesInfo(),this._layoutInfo}getEncodingInfos(){return this._propertyEncodingInfo||this._buildAttributesInfo(),this._propertyEncodingInfo}getUniforms(){return this._uniforms||this._buildAttributesInfo(),this._uniforms}getShaderHeader(){return this._shaderHeader||this._buildAttributesInfo(),this._shaderHeader}getShaderMain(){return this._shaderMain||this._buildAttributesInfo(),this._shaderMain}setDataUniforms(t,e,r,s,a){const o=this.getUniforms();for(const n of o){const{name:l,type:u,getValue:p}=n,c=p(r,e,s,a);if(c!==null)switch(u){case"float":t.setUniform1f(l,c);break;case"vec2":t.setUniform2fv(l,c);break;case"vec4":t.setUniform4fv(l,c)}}}encodeAttributes(t,e,r,s){var p;const a=this.attributesInfo(),o=this.getEncodingInfos(),n=[];let l=0,u=0;for(const c of Object.keys(o)){const f=o[c],{type:_,precisionFactor:d,isLayout:G}=a[c],R=G?r.getLayoutProperty(c):r.getPaintProperty(c),q=(p=R.interpolator)==null?void 0:p.getInterpolationRange(e);let T=0;for(const S of f){const{offset:E,bufferElementsToAdd:k}=S;if(k>0){for(let D=0;D4)s++,D={dataIndex:s,count:0,offset:0},S!==4&&(r[v]=D),t.push({location:-1,name:"a_data_"+s,count:S,type:q,normalized:E}),z=Math.ceil(Math.max(k/4,1));else{const F=t[D.dataIndex];F.count+=S,z=Math.ceil(Math.max(F.count*T/4,1))-Math.ceil(Math.max(D.offset/4,1))}d.push({dataIndex:D.dataIndex,offset:D.offset,bufferElementsToAdd:z}),D.offset+=k,D.count+=S}}for(const c of t)switch(c.type){case g.BYTE:case g.UNSIGNED_BYTE:c.count=4;break;case g.SHORT:case g.UNSIGNED_SHORT:c.count+=c.count%2}this._buildVertexBufferLayout(t);let l=0;const u=this._layoutInfo.geometry;for(const c of u)this._locations.set(c.name,l++);const p=this._layoutInfo.opacity;if(p)for(const c of p)this._locations.set(c.name,l++);this._buildShaderInfo(t,e),this._propertyEncodingInfo=e}_buildVertexBufferLayout(t){const e={},r=this.geometryInfo();let s=r[0].stride;if(t.length===0)e.geometry=r;else{const a=[];let o=s;for(const n of t)s+=Zt(n.type)*n.count;for(const n of r)a.push(new A(n.name,n.count,n.type,n.offset,s,n.normalized));for(const n of t)a.push(new A(n.name,n.count,n.type,o,s,n.normalized)),o+=Zt(n.type)*n.count;e.geometry=a}this.opacityInfo()&&(e.opacity=this.opacityInfo()),this._layoutInfo=e,this._stride=s}_buildShaderInfo(t,e){let r=` `,s=` `;const a=[];for(const u of t)r+=`attribute ${this._getType(u.count)} ${u.name}; `;const o=this.attributes(),n=this.attributesInfo();let l=-1;for(const u of o){l++;const{name:p,type:c,precisionFactor:f,isLayout:_}=n[u],d=f&&f!==1?" * "+1/f:"",{bytesPerElement:G,count:R}=C._encodingInfo[c],q=T=>`a_data_${T.dataIndex}${ue(R,T.offset,G)}`;switch(this.getAtributeState(l)){case J.UNIFORM:{const T=this._getType(R),S=`u_${p}`;a.push({name:S,type:T,getValue:(E,k,v,D)=>{const z=_?E.getLayoutValue(u,k):E.getPaintValue(u,k);if(c===h.R16G16B16A16_DASHARRAY){const F=E.getDashKey(z,E.getLayoutValue("line-cap",k)),it=D.getMosaicItemPosition(F,!1);if(jt(it))return null;const{tl:nt,br:Ht}=it;return[nt[0],Ht[1],Ht[0],nt[1]]}if(c===h.R16G16B16A16_PATTERN){const F=D.getMosaicItemPosition(z,!u.includes("line-"));if(jt(F))return null;const{tl:it,br:nt}=F;return[it[0],nt[1],nt[0],it[1]]}if(c===h.R8G8B8A8_COLOR){const F=z[3];return[F*z[0],F*z[1],F*z[2],F]}return z}}),r+=`uniform ${T} ${S}; `,s+=`${T} ${p} = ${S}; `}break;case J.DATA_DRIVEN:{const T=q(e[u][0]);s+=`${this._getType(R)} ${p} = ${T}${d}; `}break;case J.INTERPOLATED_DATA_DRIVEN:{const T=`u_t_${p}`;a.push({name:T,type:"float",getValue:(k,v,D,z)=>(_?k.getLayoutProperty(u):k.getPaintProperty(u)).interpolator.interpolationUniformValue(D,v)}),r+=`uniform float ${T}; `;const S=q(e[u][0]),E=q(e[u][1]);s+=`${this._getType(R)} ${p} = mix(${S}${d}, ${E}${d}, ${T}); `}}}this._shaderHeader=r,this._shaderMain=s,this._uniforms=a}_bit(t){return(this._key&1<>t}_getType(t){switch(t){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4"}throw new Error("Invalid count")}_encodeColor(t){const e=255*t[3];return le.i8888to32(t[0]*e,t[1]*e,t[2]*e,e)}_encodePattern(t,e,r){if(!r||!r.rect)return;const s=2,a=r.rect,o=r.width,n=r.height;e[t]=this._encodeShort(a.x+s,0),e[t]|=this._encodeShort(a.y+s+n,16),e[t+1]=this._encodeShort(a.x+s+o,0),e[t+1]|=this._encodeShort(a.y+s,16)}_encodeByte(t,e){return(255&t)<{switch(i){case g.FLOAT:case g.INT:case g.UNSIGNED_INT:return 4;case g.SHORT:case g.UNSIGNED_SHORT:return 2;case g.BYTE:case g.UNSIGNED_BYTE:return 1}},ue=(i,t,e)=>{const r=t/e;if(i===1)switch(r){case 0:return".x";case 1:return".y";case 2:return".z";case 3:return".w"}else if(i===2)switch(r){case 0:return".xy";case 1:return".yz";case 2:return".zw"}else if(i===3)switch(r){case 0:return".xyz";case 1:return".yzw"}return""};class $ extends C{constructor(t){super(t)}geometryInfo(){return $.GEOMETRY_LAYOUT}opacityInfo(){return null}attributes(){return $.ATTRIBUTES}attributesInfo(){return $.ATTRIBUTES_INFO}}$.ATTRIBUTES=[],$.GEOMETRY_LAYOUT=[new A("a_pos",2,g.BYTE,0,2)],$.ATTRIBUTES_INFO={};class H extends C{constructor(t){super(t)}geometryInfo(){return H.GEOMETRY_LAYOUT}opacityInfo(){return null}attributes(){return H.ATTRIBUTES}attributesInfo(){return H.ATTRIBUTES_INFO}}H.ATTRIBUTES=["circle-radius","circle-color","circle-opacity","circle-stroke-width","circle-stroke-color","circle-stroke-opacity","circle-blur"],H.GEOMETRY_LAYOUT=[new A("a_pos",2,g.SHORT,0,4)],H.ATTRIBUTES_INFO={"circle-radius":{name:"radius",type:h.R8_UNSIGNED},"circle-color":{name:"color",type:h.R8G8B8A8_COLOR},"circle-opacity":{name:"opacity",type:h.R8_UNSIGNED,precisionFactor:100},"circle-stroke-width":{name:"stroke_width",type:h.R8_UNSIGNED,precisionFactor:4},"circle-stroke-color":{name:"stroke_color",type:h.R8G8B8A8_COLOR},"circle-stroke-opacity":{name:"stroke_opacity",type:h.R8_UNSIGNED,precisionFactor:100},"circle-blur":{name:"blur",type:h.R8_UNSIGNED,precisionFactor:32}};class j extends C{constructor(t){super(t)}geometryInfo(){return j.GEOMETRY_LAYOUT}opacityInfo(){return null}attributes(){return j.ATTRIBUTES}attributesInfo(){return j.ATTRIBUTES_INFO}}j.ATTRIBUTES=["fill-color","fill-opacity","fill-pattern"],j.GEOMETRY_LAYOUT=[new A("a_pos",2,g.SHORT,0,4)],j.ATTRIBUTES_INFO={"fill-color":{name:"color",type:h.R8G8B8A8_COLOR},"fill-opacity":{name:"opacity",type:h.R8_UNSIGNED,precisionFactor:100},"fill-pattern":{name:"tlbr",type:h.R16G16B16A16_PATTERN,isOptional:!0}};class x extends C{constructor(t,e){super(t),this._usefillColor=e}geometryInfo(){return x.GEOMETRY_LAYOUT}opacityInfo(){return null}attributes(){return this._usefillColor?x.ATTRIBUTES_FILL:x.ATTRIBUTES_OUTLINE}attributesInfo(){return this._usefillColor?x.ATTRIBUTES_INFO_FILL:x.ATTRIBUTES_INFO_OUTLINE}}x.ATTRIBUTES_OUTLINE=["fill-outline-color","fill-opacity"],x.ATTRIBUTES_FILL=["fill-color","fill-opacity"],x.GEOMETRY_LAYOUT=[new A("a_pos",2,g.SHORT,0,8),new A("a_offset",2,g.BYTE,4,8),new A("a_xnormal",2,g.BYTE,6,8)],x.ATTRIBUTES_INFO_OUTLINE={"fill-outline-color":{name:"color",type:h.R8G8B8A8_COLOR},"fill-opacity":{name:"opacity",type:h.R8_UNSIGNED,precisionFactor:100}},x.ATTRIBUTES_INFO_FILL={"fill-color":{name:"color",type:h.R8G8B8A8_COLOR},"fill-opacity":{name:"opacity",type:h.R8_UNSIGNED,precisionFactor:100}};class K extends C{constructor(t){super(t)}geometryInfo(){return K.GEOMETRY_LAYOUT}opacityInfo(){return null}attributes(){return K.ATTRIBUTES}attributesInfo(){return K.ATTRIBUTES_INFO}}K.ATTRIBUTES=["line-blur","line-color","line-gap-width","line-offset","line-opacity","line-width","line-pattern","line-dasharray"],K.GEOMETRY_LAYOUT=[new A("a_pos",2,g.SHORT,0,16),new A("a_extrude_offset",4,g.BYTE,4,16),new A("a_dir_normal",4,g.BYTE,8,16),new A("a_accumulatedDistance",2,g.UNSIGNED_SHORT,12,16)],K.ATTRIBUTES_INFO={"line-width":{name:"width",type:h.R8_UNSIGNED,precisionFactor:2},"line-gap-width":{name:"gap_width",type:h.R8_UNSIGNED,precisionFactor:2},"line-offset":{name:"offset",type:h.R8_SIGNED,precisionFactor:2},"line-color":{name:"color",type:h.R8G8B8A8_COLOR},"line-opacity":{name:"opacity",type:h.R8_UNSIGNED,precisionFactor:100},"line-blur":{name:"blur",type:h.R8_UNSIGNED,precisionFactor:4},"line-pattern":{name:"tlbr",type:h.R16G16B16A16_PATTERN,isOptional:!0},"line-dasharray":{name:"tlbr",type:h.R16G16B16A16_DASHARRAY,isOptional:!0}};const re=[new A("a_pos",2,g.SHORT,0,16),new A("a_vertexOffset",2,g.SHORT,4,16),new A("a_texAngleRange",4,g.UNSIGNED_BYTE,8,16),new A("a_levelInfo",4,g.UNSIGNED_BYTE,12,16)],se=[new A("a_opacityInfo",1,g.UNSIGNED_BYTE,0,1)];class Q extends C{constructor(t){super(t)}geometryInfo(){return re}opacityInfo(){return se}attributes(){return Q.ATTRIBUTES}attributesInfo(){return Q.ATTRIBUTES_INFO}}Q.ATTRIBUTES=["icon-color","icon-opacity","icon-halo-blur","icon-halo-color","icon-halo-width","icon-size"],Q.ATTRIBUTES_INFO={"icon-color":{name:"color",type:h.R8G8B8A8_COLOR},"icon-opacity":{name:"opacity",type:h.R8_UNSIGNED,precisionFactor:100},"icon-halo-color":{name:"halo_color",type:h.R8G8B8A8_COLOR},"icon-halo-width":{name:"halo_width",type:h.R8_UNSIGNED,precisionFactor:4},"icon-halo-blur":{name:"halo_blur",type:h.R8_UNSIGNED,precisionFactor:4},"icon-size":{name:"size",type:h.R8_UNSIGNED,precisionFactor:32,isLayout:!0}};class X extends C{constructor(t){super(t)}geometryInfo(){return re}opacityInfo(){return se}attributes(){return X.ATTRIBUTES}attributesInfo(){return X.ATTRIBUTES_INFO}}X.ATTRIBUTES=["text-color","text-opacity","text-halo-blur","text-halo-color","text-halo-width","text-size"],X.ATTRIBUTES_INFO={"text-color":{name:"color",type:h.R8G8B8A8_COLOR},"text-opacity":{name:"opacity",type:h.R8_UNSIGNED,precisionFactor:100},"text-halo-color":{name:"halo_color",type:h.R8G8B8A8_COLOR},"text-halo-width":{name:"halo_width",type:h.R8_UNSIGNED,precisionFactor:4},"text-halo-blur":{name:"halo_blur",type:h.R8_UNSIGNED,precisionFactor:4},"text-size":{name:"size",type:h.R8_UNSIGNED,isLayout:!0}};const ae={kind:"null"},w={kind:"number"},O={kind:"string"},N={kind:"boolean"},Z={kind:"color"},_t={kind:"object"},W={kind:"value"};function ut(i,t){return{kind:"array",itemType:i,n:t}}const ce=[ae,w,O,N,Z,_t,ut(W)];function st(i){if(i.kind==="array"){const t=st(i.itemType);return typeof i.n=="number"?`array<${t}, ${i.n}>`:i.itemType.kind==="value"?"array":`array<${t}>`}return i.kind}function dt(i){if(i===null)return ae;if(typeof i=="string")return O;if(typeof i=="boolean")return N;if(typeof i=="number")return w;if(i instanceof I)return Z;if(Array.isArray(i)){let t;for(const e of i){const r=dt(e);if(t){if(t!==r){t=W;break}}else t=r}return ut(t||W,i.length)}return typeof i=="object"?_t:W}function Et(i,t){if(t.kind==="array")return i.kind==="array"&&(i.n===0&&i.itemType.kind==="value"||Et(i.itemType,t.itemType))&&(typeof t.n!="number"||t.n===i.n);if(t.kind==="value"){for(const e of ce)if(Et(i,e))return!0}return t.kind===i.kind}function bt(i){if(i===null)return"";const t=typeof i;return t==="string"?i:t==="number"||t==="boolean"?String(i):i instanceof I?i.toString():JSON.stringify(i)}class he{constructor(t){this._parent=t,this._vars={}}add(t,e){this._vars[t]=e}get(t){return this._vars[t]?this._vars[t]:this._parent?this._parent.get(t):null}}class It{constructor(){this.type=W}static parse(t){if(t.length>1)throw new Error('"id" does not expect arguments');return new It}evaluate(t,e){return t==null?void 0:t.id}}class Tt{constructor(){this.type=O}static parse(t){if(t.length>1)throw new Error('"geometry-type" does not expect arguments');return new Tt}evaluate(t,e){if(!t)return null;switch(t.type){case wt.Point:return"Point";case wt.LineString:return"LineString";case wt.Polygon:return"Polygon";default:return null}}}class vt{constructor(){this.type=_t}static parse(t){if(t.length>1)throw new Error('"properties" does not expect arguments');return new vt}evaluate(t,e){return t==null?void 0:t.values}}class mt{constructor(){this.type=w}static parse(t){if(t.length>1)throw new Error('"zoom" does not expect arguments');return new mt}evaluate(t,e){return e}}class B{constructor(t,e,r){this._lhs=t,this._rhs=e,this._compare=r,this.type=N}static parse(t,e,r){if(t.length!==3&&t.length!==4)throw new Error(`"${t[0]}" expects 2 or 3 arguments`);if(t.length===4)throw new Error(`"${t[0]}" collator not supported`);return new B(y(t[1],e),y(t[2],e),r)}evaluate(t,e){return this._compare(this._lhs.evaluate(t,e),this._rhs.evaluate(t,e))}}class pe extends B{static parse(t,e){return B.parse(t,e,(r,s)=>r===s)}}class ye extends B{static parse(t,e){return B.parse(t,e,(r,s)=>r!==s)}}class fe extends B{static parse(t,e){return B.parse(t,e,(r,s)=>rr<=s)}}class _e extends B{static parse(t,e){return B.parse(t,e,(r,s)=>r>s)}}class de extends B{static parse(t,e){return B.parse(t,e,(r,s)=>r>=s)}}class Dt{constructor(t){this._arg=t,this.type=N}static parse(t,e){if(t.length!==2)throw new Error('"!" expects 1 argument');return new Dt(y(t[1],e))}evaluate(t,e){return!this._arg.evaluate(t,e)}}class Rt{constructor(t){this._args=t,this.type=N}static parse(t,e){const r=[];for(let s=1;s1)throw new Error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1")}break;default:throw new Error(`"${t[0]}" unknown interpolation type "${a[0]}"`)}if(t.length%2!=1)throw new Error(`"${s}" expects an even number of arguments`);const o=y(t[2],e,w);let n;s==="interpolate-hcl"||s==="interpolate-lab"?n=Z:r&&r.kind!=="value"&&(n=r);const l=[];for(let u=3;u=p)throw new Error(`"${s}" requires strictly ascending stop inputs`);const c=y(t[u+1],e,n);n||(n=c.type),l.push([p,c])}if(n&&n!==Z&&n!==w&&(n.kind!=="array"||n.itemType!==w))throw new Error(`"${s}" cannot interpolate type ${st(n)}`);return new M(s,n,a,o,l)}evaluate(t,e){const r=this._stops;if(r.length===1)return r[0][1].evaluate(t,e);const s=this.input.evaluate(t,e);if(s<=r[0][0])return r[0][1].evaluate(t,e);if(s>=r[r.length-1][0])return r[r.length-1][1].evaluate(t,e);let a=0;for(;++aP(c,p[f],l));if(this.type.kind==="color"&&u instanceof I&&p instanceof I){const c=new I(u),f=new I(p);return new I([P(c.r,f.r,l),P(c.g,f.g,l),P(c.b,f.b,l),P(c.a,f.a,l)])}if(this.type.kind==="number"&&typeof u=="number"&&typeof p=="number")return P(u,p,l);throw new Error(`"${this._operator}" cannot interpolate type ${st(this.type)}`)}if(this._operator==="interpolate-hcl"){const c=Kt(u),f=Kt(p),_=f.h-c.h,d=qt({h:c.h+l*(_>180||_<-180?_-360*Math.round(_/360):_),c:P(c.c,f.c,l),l:P(c.l,f.l,l)});return new I({a:P(u.a,p.a,l),...d})}if(this._operator==="interpolate-lab"){const c=Wt(u),f=Wt(p),_=qt({l:P(c.l,f.l,l),a:P(c.a,f.a,l),b:P(c.b,f.b,l)});return new I({a:P(u.a,p.a,l),..._})}throw new Error(`Unexpected operator "${this._operator}"`)}interpolationUniformValue(t,e){const r=this._stops;if(r.length===1||t>=r[r.length-1][0])return 0;let s=0;for(;++s=r)return[r,r];let s=0;for(;++s1&&(a=1),a}static _exponentialInterpolationRatio(t,e,r,s){const a=s-r;if(a===0)return 0;const o=t-r;return e===1?o/a:(e**o-1)/(e**a-1)}}class Lt{constructor(t,e,r){this.type=t,this._input=e,this._stops=r}static parse(t,e){if(t.length<5)throw new Error('"step" expects at least 4 arguments');if(t.length%2!=1)throw new Error('"step" expects an even number of arguments');const r=y(t[1],e,w);let s;const a=[];a.push([-1/0,y(t[2],e)]);for(let o=3;o=n)throw new Error('"step" requires strictly ascending stop inputs');const l=y(t[o+1],e);s||(s=l.type),a.push([n,l])}return new Lt(s,r,a)}evaluate(t,e){const r=this._stops;if(r.length===1)return r[0][1].evaluate(t,e);const s=this._input.evaluate(t,e);let a=0;for(;++a=s.length)throw new Error('"at" index out of bounds');if(r!==Math.floor(r))throw new Error('"at" index must be an integer');return s[r]}}class ht{constructor(t,e){this._key=t,this._obj=e,this.type=W}static parse(t,e){let r,s;switch(t.length){case 2:return r=y(t[1],e),new ht(r);case 3:return r=y(t[1],e),s=y(t[2],e),new ht(r,s);default:throw new Error('"get" expects 1 or 2 arguments')}}evaluate(t,e){const r=this._key.evaluate(t,e);return this._obj?this._obj.evaluate(t,e)[r]:t==null?void 0:t.values[r]}}class pt{constructor(t,e){this._key=t,this._obj=e,this.type=N}static parse(t,e){let r,s;switch(t.length){case 2:return r=y(t[1],e),new pt(r);case 3:return r=y(t[1],e),s=y(t[2],e),new pt(r,s);default:throw new Error('"has" expects 1 or 2 arguments')}}evaluate(t,e){const r=this._key.evaluate(t,e);return this._obj?r in this._obj.evaluate(t,e):!!(t!=null&&t.values[r])}}class Gt{constructor(t,e){this._key=t,this._vals=e,this.type=N}static parse(t,e){if(t.length!==3)throw new Error('"in" expects 2 arguments');return new Gt(y(t[1],e),y(t[2],e))}evaluate(t,e){const r=this._key.evaluate(t,e);return this._vals.evaluate(t,e).includes(r)}}class yt{constructor(t,e,r){this._item=t,this._array=e,this._from=r,this.type=w}static parse(t,e){if(t.length<3||t.length>4)throw new Error('"index-of" expects 3 or 4 arguments');const r=y(t[1],e),s=y(t[2],e);if(t.length===4){const a=y(t[3],e,w);return new yt(r,s,a)}return new yt(r,s)}evaluate(t,e){const r=this._item.evaluate(t,e),s=this._array.evaluate(t,e);if(this._from){const a=this._from.evaluate(t,e);if(a!==Math.floor(a))throw new Error('"index-of" index must be an integer');return s.indexOf(r,a)}return s.indexOf(r)}}class kt{constructor(t){this._arg=t,this.type=w}static parse(t,e){if(t.length!==2)throw new Error('"length" expects 2 arguments');const r=y(t[1],e);return new kt(r)}evaluate(t,e){const r=this._arg.evaluate(t,e);if(typeof r=="string"||Array.isArray(r))return r.length;throw new Error('"length" expects string or array')}}class ft{constructor(t,e,r,s){this.type=t,this._array=e,this._from=r,this._to=s}static parse(t,e){if(t.length<3||t.length>4)throw new Error('"slice" expects 2 or 3 arguments');const r=y(t[1],e),s=y(t[2],e,w);if(s.type!==w)throw new Error('"slice" index must return a number');if(t.length===4){const a=y(t[3],e,w);if(a.type!==w)throw new Error('"slice" index must return a number');return new ft(r.type,r,s,a)}return new ft(r.type,r,s)}evaluate(t,e){const r=this._array.evaluate(t,e);if(!Array.isArray(r)&&typeof r!="string")throw new Error('"slice" input must be an array or a string');const s=this._from.evaluate(t,e);if(s<0||s>=r.length)throw new Error('"slice" index out of bounds');if(s!==Math.floor(s))throw new Error('"slice" index must be an integer');if(this._to){const a=this._to.evaluate(t,e);if(a<0||a>=r.length)throw new Error('"slice" index out of bounds');if(a!==Math.floor(a))throw new Error('"slice" index must be an integer');return r.slice(s,a)}return r.slice(s)}}class zt{constructor(){this.type=N}static parse(t){if(t.length!==1)throw new Error('"has-id" expects no arguments');return new zt}evaluate(t,e){return t&&t.id!==void 0}}class L{constructor(t,e){this._args=t,this._calculate=e,this.type=w}static parse(t,e,r){const s=t.slice(1).map(a=>y(a,e));return new L(s,r)}evaluate(t,e){let r;return this._args&&(r=this._args.map(s=>s.evaluate(t,e))),this._calculate(r)}}class me extends L{static parse(t,e){switch(t.length){case 2:return L.parse(t,e,r=>-r[0]);case 3:return L.parse(t,e,r=>r[0]-r[1]);default:throw new Error('"-" expects 1 or 2 arguments')}}}class we extends L{static parse(t,e){return L.parse(t,e,r=>{let s=1;for(const a of r)s*=a;return s})}}class Ee extends L{static parse(t,e){if(t.length===3)return L.parse(t,e,r=>r[0]/r[1]);throw new Error('"/" expects 2 arguments')}}class be extends L{static parse(t,e){if(t.length===3)return L.parse(t,e,r=>r[0]%r[1]);throw new Error('"%" expects 2 arguments')}}class Ie extends L{static parse(t,e){if(t.length===3)return L.parse(t,e,r=>r[0]**r[1]);throw new Error('"^" expects 1 or 2 arguments')}}class Te extends L{static parse(t,e){return L.parse(t,e,r=>{let s=0;for(const a of r)s+=a;return s})}}class m{constructor(t,e){this._args=t,this._calculate=e,this.type=w}static parse(t,e){const r=t.slice(1).map(s=>y(s,e));return new m(r,m.ops[t[0]])}evaluate(t,e){let r;return this._args&&(r=this._args.map(s=>s.evaluate(t,e))),this._calculate(r)}}m.ops={abs:i=>Math.abs(i[0]),acos:i=>Math.acos(i[0]),asin:i=>Math.asin(i[0]),atan:i=>Math.atan(i[0]),ceil:i=>Math.ceil(i[0]),cos:i=>Math.cos(i[0]),e:()=>Math.E,floor:i=>Math.floor(i[0]),ln:i=>Math.log(i[0]),ln2:()=>Math.LN2,log10:i=>Math.log(i[0])/Math.LN10,log2:i=>Math.log(i[0])/Math.LN2,max:i=>Math.max(...i),min:i=>Math.min(...i),pi:()=>Math.PI,round:i=>Math.round(i[0]),sin:i=>Math.sin(i[0]),sqrt:i=>Math.sqrt(i[0]),tan:i=>Math.tan(i[0])};class Ft{constructor(t){this._args=t,this.type=O}static parse(t,e){return new Ft(t.slice(1).map(r=>y(r,e)))}evaluate(t,e){return this._args.map(r=>r.evaluate(t,e)).join("")}}class at{constructor(t,e){this._arg=t,this._calculate=e,this.type=O}static parse(t,e){if(t.length!==2)throw new Error(`${t[0]} expects 1 argument`);const r=y(t[1],e);return new at(r,at.ops[t[0]])}evaluate(t,e){return this._calculate(this._arg.evaluate(t,e))}}at.ops={downcase:i=>i.toLowerCase(),upcase:i=>i.toUpperCase()};class Vt{constructor(t){this._args=t,this.type=Z}static parse(t,e){if(t.length!==4)throw new Error('"rgb" expects 3 arguments');const r=t.slice(1).map(s=>y(s,e));return new Vt(r)}evaluate(t,e){const r=this._validate(this._args[0].evaluate(t,e)),s=this._validate(this._args[1].evaluate(t,e)),a=this._validate(this._args[2].evaluate(t,e));return new I({r,g:s,b:a})}_validate(t){if(typeof t!="number"||t<0||t>255)throw new Error(`${t}: invalid color component`);return Math.round(t)}}class Mt{constructor(t){this._args=t,this.type=Z}static parse(t,e){if(t.length!==5)throw new Error('"rgba" expects 4 arguments');const r=t.slice(1).map(s=>y(s,e));return new Mt(r)}evaluate(t,e){const r=this._validate(this._args[0].evaluate(t,e)),s=this._validate(this._args[1].evaluate(t,e)),a=this._validate(this._args[2].evaluate(t,e)),o=this._validateAlpha(this._args[3].evaluate(t,e));return new I({r,g:s,b:a,a:o})}_validate(t){if(typeof t!="number"||t<0||t>255)throw new Error(`${t}: invalid color component`);return Math.round(t)}_validateAlpha(t){if(typeof t!="number"||t<0||t>1)throw new Error(`${t}: invalid alpha color component`);return t}}class Ct{constructor(t){this._color=t,this.type=ut(w,4)}static parse(t,e){if(t.length!==2)throw new Error('"to-rgba" expects 1 argument');const r=y(t[1],e);return new Ct(r)}evaluate(t,e){return new I(this._color.evaluate(t,e)).toRgba()}}class tt{constructor(t,e){this.type=t,this._args=e}static parse(t,e){const r=t[0];if(t.length<2)throw new Error(`${r} expects at least one argument`);let s,a=1;if(r==="array"){if(t.length>2){switch(t[1]){case"string":s=O;break;case"number":s=w;break;case"boolean":s=N;break;default:throw new Error('"array" type argument must be string, number or boolean')}a++}else s=W;let n;if(t.length>3){if(n=t[2],n!==null&&(typeof n!="number"||n<0||n!==Math.floor(n)))throw new Error('"array" length argument must be a positive integer literal');a++}s=ut(s,n)}else switch(r){case"string":s=O;break;case"number":s=w;break;case"boolean":s=N;break;case"object":s=_t}const o=[];for(;a":_e,">=":de,all:Rt,any:At,case:xt,coalesce:St,match:Pt,within:null,interpolate:M,"interpolate-hcl":M,"interpolate-lab":M,step:Lt,let:Ut,var:Bt,concat:Ft,downcase:at,"is-supported-script":null,"resolved-locale":null,upcase:at,rgb:Vt,rgba:Mt,"to-rgba":Ct,"-":me,"*":we,"/":Ee,"%":be,"^":Ie,"+":Te,abs:m,acos:m,asin:m,atan:m,ceil:m,cos:m,e:m,floor:m,ln:m,ln2:m,log10:m,log2:m,max:m,min:m,pi:m,round:m,sin:m,sqrt:m,tan:m,zoom:mt,"heatmap-density":null,"has-id":zt,none:Nt};class U{constructor(t){this._expression=t}filter(t,e){if(!this._expression)return!0;try{return this._expression.evaluate(t,e)}catch(r){return console.log(r.message),!0}}static createFilter(t){if(!t)return null;this.isLegacyFilter(t)&&(t=this.convertLegacyFilter(t));try{const e=y(t,null,N);return new U(e)}catch(e){return console.log(e.message),null}}static isLegacyFilter(t){if(!Array.isArray(t)||t.length===0)return!0;switch(t[0]){case"==":case"!=":case">":case"<":case">=":case"<=":return t.length===3&&typeof t[1]=="string"&&!Array.isArray(t[2]);case"in":return t.length>=3&&typeof t[1]=="string"&&!Array.isArray(t[2]);case"!in":case"none":case"!has":return!0;case"any":case"all":for(let e=1;e":case"<":case">=":case"<=":return U.convertComparison(e,t[1],t[2]);case"in":return U.convertIn(t[1],t.slice(2));case"!in":return U.negate(U.convertIn(t[1],t.slice(2)));case"any":case"all":case"none":return U.convertCombining(e,t.slice(1));case"has":return U.convertHas(t[1]);case"!has":return U.negate(U.convertHas(t[1]));default:throw new Error("Unexpected legacy filter.")}}static convertComparison(t,e,r){switch(e){case"$type":return[t,["geometry-type"],r];case"$id":return[t,["id"],r];default:return[t,["get",e],r]}}static convertIn(t,e){switch(t){case"$type":return["in",["geometry-type"],["literal",e]];case"$id":return["in",["id"],["literal",e]];default:return["in",["get",t],["literal",e]]}}static convertHas(t){switch(t){case"$type":return!0;case"$id":return["has-id"];default:return["has",t]}}static convertCombining(t,e){return[t].concat(e.map(this.convertLegacyFilter))}static negate(t){return["!",t]}}class gt{constructor(t,e){let r;switch(this.isDataDriven=!1,this.interpolator=null,t.type){case"number":case"color":r=!0;break;case"array":r=t.value==="number";break;default:r=!1}if(e==null&&(e=t.default),Array.isArray(e)&&e.length>0&&ie[e[0]]){const a={number:w,color:Z,string:O,boolean:N,enum:O};try{const o=t.type==="array"?ut(a[t.value]||W,t.length):a[t.type],n=y(e,null,o);this.getValue=this._buildExpression(n,t),this.isDataDriven=!0,n instanceof M&&n.input instanceof mt&&(this.interpolator=n)}catch(o){console.log(o.message),this.getValue=this._buildSimple(t.default)}return}r&&e.type==="interval"&&(r=!1);const s=e&&e.stops&&e.stops.length>0;if(s)for(const a of e.stops)a[1]=this._validate(a[1],t);if(this.isDataDriven=!!e&&!!e.property,this.isDataDriven)if(e.default!==void 0&&(e.default=this._validate(e.default,t)),s)switch(e.type){case"identity":this.getValue=this._buildIdentity(e,t);break;case"categorical":this.getValue=this._buildCategorical(e,t);break;default:this.getValue=r?this._buildInterpolate(e,t):this._buildInterval(e,t)}else this.getValue=this._buildIdentity(e,t);else s?this.getValue=r?this._buildZoomInterpolate(e):this._buildZoomInterval(e):(e=this._validate(e,t),this.getValue=this._buildSimple(e))}_validate(t,e){if(e.type==="number"){if(te.maximum)return e.maximum}else e.type==="color"?t=gt._parseColor(t):e.type==="enum"?typeof t=="string"&&(t=e.values.indexOf(t)):e.type==="array"&&e.value==="enum"?t=t.map(r=>typeof r=="string"?e.values.indexOf(r):r):e.type==="string"&&(t=bt(t));return t}_buildSimple(t){return()=>t}_buildExpression(t,e){return(r,s)=>{try{const a=t.evaluate(s,r);return a===void 0?e.default:this._validate(a,e)}catch(a){return console.log(a.message),e.default}}}_buildIdentity(t,e){return(r,s)=>{let a;return s&&(a=s.values[t.property]),a!==void 0&&(a=this._validate(a,e)),a!=null?a:t.default!==void 0?t.default:e.default}}_buildCategorical(t,e){return(r,s)=>{let a;return s&&(a=s.values[t.property]),a=this._categorical(a,t.stops),a!==void 0?a:t.default!==void 0?t.default:e.default}}_buildInterval(t,e){return(r,s)=>{let a;return s&&(a=s.values[t.property]),typeof a=="number"?this._interval(a,t.stops):t.default!==void 0?t.default:e.default}}_buildInterpolate(t,e){return(r,s)=>{let a;return s&&(a=s.values[t.property]),typeof a=="number"?this._interpolate(a,t.stops,t.base||1):t.default!==void 0?t.default:e.default}}_buildZoomInterpolate(t){return e=>this._interpolate(e,t.stops,t.base||1)}_buildZoomInterval(t){return e=>this._interval(e,t.stops)}_categorical(t,e){const r=e.length;for(let s=0;sthis._create(e,r,s)).filter(e=>!!e),this.layers){let e;for(let r=0;r=this.layers.length?null:this.layers[t].id}getStyleLayerByUID(t){var e;return(e=this._uidToLayer.get(t))!=null?e:null}getStyleLayerIndex(t){const e=this._layerByName[t];return e?this.layers.indexOf(e):-1}setStyleLayer(t,e){if(!t||!t.id)return;const r=this._style;e!=null&&e>=this.layers.length&&(e=this.layers.length-1);let s,a=!0;const o=this._layerByName[t.id];if(o){const n=this.layers.indexOf(o);e||(e=n),e===n?(a=!1,s=ot._recreateLayer(t,o),this.layers[e]=s,r.layers[e]=t):(this.layers.splice(n,1),r.layers.splice(n,1),s=this._create(t,e,this.layers),this.layers.splice(e,0,s),r.layers.splice(e,0,t))}else s=this._create(t,e,this.layers),!e||e>=this.layers.length?(this.layers.push(s),r.layers.push(t)):(this.layers.splice(e,0,s),r.layers.splice(e,0,t));this._layerByName[t.id]=s,this._uidToLayer.set(s.uid,s),a&&this._recomputeZValues(),this._identifyRefLayers()}getStyleLayer(t){const e=this._layerByName[t];return e?{type:e.typeName,id:e.id,source:e.source,"source-layer":e.sourceLayer,minzoom:e.minzoom,maxzoom:e.maxzoom,filter:e.filter,layout:e.layout,paint:e.paint}:null}deleteStyleLayer(t){const e=this._layerByName[t];if(e){delete this._layerByName[t],this._uidToLayer.delete(e.uid);const r=this.layers.indexOf(e);this.layers.splice(r,1),this._style.layers.splice(r,1),this._recomputeZValues(),this._identifyRefLayers()}}getLayerById(t){return this._layerByName[t]}getLayoutProperties(t){const e=this._layerByName[t];return e?e.layout:null}getPaintProperties(t){const e=this._layerByName[t];return e?e.paint:null}setPaintProperties(t,e){const r=this._layerByName[t];if(!r)return;const s={type:r.typeName,id:r.id,source:r.source,"source-layer":r.sourceLayer,minzoom:r.minzoom,maxzoom:r.maxzoom,filter:r.filter,layout:r.layout,paint:e},a=ot._recreateLayer(s,r),o=this.layers.indexOf(r);this.layers[o]=a,this._style.layers[o].paint=e,this._layerByName[r.id]=a,this._uidToLayer.set(r.uid,a)}setLayoutProperties(t,e){const r=this._layerByName[t];if(!r)return;const s={type:r.typeName,id:r.id,source:r.source,"source-layer":r.sourceLayer,minzoom:r.minzoom,maxzoom:r.maxzoom,filter:r.filter,layout:e,paint:r.paint},a=ot._recreateLayer(s,r),o=this.layers.indexOf(r);this.layers[o]=a,this._style.layers[o].layout=e,this._layerByName[r.id]=a,this._uidToLayer.set(r.uid,a)}setStyleLayerVisibility(t,e){const r=this._layerByName[t];if(!r)return;const s=r.layout||{};s.visibility=e;const a={type:r.typeName,id:r.id,source:r.source,"source-layer":r.sourceLayer,minzoom:r.minzoom,maxzoom:r.maxzoom,filter:r.filter,layout:s,paint:r.paint},o=ot._recreateLayer(a,r),n=this.layers.indexOf(r);this.layers[n]=o,this._style.layers[n].layout=s,this._layerByName[r.id]=o,this._uidToLayer.set(r.uid,o)}getStyleLayerVisibility(t){var r,s;const e=this._layerByName[t];return e?(s=(r=e.layout)==null?void 0:r.visibility)!=null?s:"visible":"none"}_recomputeZValues(){const t=this.layers,e=1/(t.length+1);for(let r=0;ra.keyo.key?1:0);const s=t.length;for(let a=0;a