2*R){const zt=H.add(K.sub(H)._mult(R/dt)._round());this.updateDistance(H,zt),this.addCurrentVertex(zt,oe,0,0,F),H=zt}}}}addCurrentVertex(n,c,m,b,v,w=!1){const S=c.y*b-c.x,M=-c.y-c.x*b;this.addHalfVertex(n,c.x+c.y*m,c.y-c.x*m,w,!1,m,v),this.addHalfVertex(n,S,M,w,!0,-b,v),this.distance>kb/2&&this.totalDistance===0&&(this.distance=0,this.addCurrentVertex(n,c,m,b,v,w))}addHalfVertex({x:n,y:c},m,b,v,w,S,M){const P=.5*(this.lineClips?this.scaledDistance*(kb-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((n<<1)+(v?1:0),(c<<1)+(w?1:0),Math.round(63*m)+128,Math.round(63*b)+128,1+(S===0?0:S<0?-1:1)|(63&P)<<2,P>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const R=M.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,R),M.primitiveLength++),w?this.e2=R:this.e1=R}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(n,c){this.distance+=n.dist(c),this.updateScaledDistance()}}Ct("LineBucket",Cp,{omit:["layers","patternFeatures"]});const hx=new nn({"line-cap":new Rt(Oe.layout_line["line-cap"]),"line-join":new Kt(Oe.layout_line["line-join"]),"line-miter-limit":new Rt(Oe.layout_line["line-miter-limit"]),"line-round-limit":new Rt(Oe.layout_line["line-round-limit"]),"line-sort-key":new Kt(Oe.layout_line["line-sort-key"])});var wb={paint:new nn({"line-opacity":new Kt(Oe.paint_line["line-opacity"]),"line-color":new Kt(Oe.paint_line["line-color"]),"line-translate":new Rt(Oe.paint_line["line-translate"]),"line-translate-anchor":new Rt(Oe.paint_line["line-translate-anchor"]),"line-width":new Kt(Oe.paint_line["line-width"]),"line-gap-width":new Kt(Oe.paint_line["line-gap-width"]),"line-offset":new Kt(Oe.paint_line["line-offset"]),"line-blur":new Kt(Oe.paint_line["line-blur"]),"line-dasharray":new Dc(Oe.paint_line["line-dasharray"]),"line-pattern":new Ac(Oe.paint_line["line-pattern"]),"line-gradient":new ju(Oe.paint_line["line-gradient"])}),layout:hx};const xb=new class extends Kt{possiblyEvaluate(o,n){return n=new xi(Math.floor(n.zoom),{now:n.now,fadeDuration:n.fadeDuration,zoomHistory:n.zoomHistory,transition:n.transition}),super.possiblyEvaluate(o,n)}evaluate(o,n,c,m){return n=$({},n,{zoom:Math.floor(n.zoom)}),super.evaluate(o,n,c,m)}}(wb.paint.properties["line-width"].specification);function _b(o,n){return n>0?n+2*o:o}xb.useIntegerZoom=!0;const mx=Ki([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),px=Ki([{name:"a_projected_pos",components:3,type:"Float32"}],4);Ki([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const gx=Ki([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]);Ki([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const zb=Ki([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),fx=Ki([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function bx(o,n,c){return o.sections.forEach(m=>{m.text=function(b,v,w){const S=v.layout.get("text-transform").evaluate(w,{});return S==="uppercase"?b=b.toLocaleUpperCase():S==="lowercase"&&(b=b.toLocaleLowerCase()),Hr.applyArabicShaping&&(b=Hr.applyArabicShaping(b)),b}(m.text,n,c)}),o}Ki([{name:"triangle",components:3,type:"Uint16"}]),Ki([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),Ki([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),Ki([{type:"Float32",name:"offsetX"}]),Ki([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);const Ru={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var bn=24,jp=Qa,Cb=function(o,n,c,m,b){var v,w,S=8*b-m-1,M=(1<>1,R=-7,F=b-1,H=-1,Y=o[n+F];for(F+=H,v=Y&(1<<-R)-1,Y>>=-R,R+=S;R>0;v=256*v+o[n+F],F+=H,R-=8);for(w=v&(1<<-R)-1,v>>=-R,R+=m;R>0;w=256*w+o[n+F],F+=H,R-=8);if(v===0)v=1-P;else{if(v===M)return w?NaN:1/0*(Y?-1:1);w+=Math.pow(2,m),v-=P}return(Y?-1:1)*w*Math.pow(2,v-m)},jb=function(o,n,c,m,b,v){var w,S,M,P=8*v-b-1,R=(1<>1,H=b===23?Math.pow(2,-24)-Math.pow(2,-77):0,Y=0,K=1,le=n<0||n===0&&1/n<0?1:0;for(n=Math.abs(n),isNaN(n)||n===1/0?(S=isNaN(n)?1:0,w=R):(w=Math.floor(Math.log(n)/Math.LN2),n*(M=Math.pow(2,-w))<1&&(w--,M*=2),(n+=w+F>=1?H/M:H*Math.pow(2,1-F))*M>=2&&(w++,M/=2),w+F>=R?(S=0,w=R):w+F>=1?(S=(n*M-1)*Math.pow(2,b),w+=F):(S=n*Math.pow(2,F-1)*Math.pow(2,b),w=0));b>=8;o[c+Y]=255&S,Y+=K,S/=256,b-=8);for(w=w<0;o[c+Y]=255&w,Y+=K,w/=256,P-=8);o[c+Y-K]|=128*le};function Qa(o){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(o)?o:new Uint8Array(o||0),this.pos=0,this.type=0,this.length=this.buf.length}Qa.Varint=0,Qa.Fixed64=1,Qa.Bytes=2,Qa.Fixed32=5;var Hl,Sp=4294967296,Sb=1/Sp,Tb=typeof TextDecoder>"u"?null:new TextDecoder("utf8");function ll(o){return o.type===Qa.Bytes?o.readVarint()+o.pos:o.pos+1}function Td(o,n,c){return c?4294967296*n+(o>>>0):4294967296*(n>>>0)+(o>>>0)}function Mb(o,n,c){var m=n<=16383?1:n<=2097151?2:n<=268435455?3:Math.floor(Math.log(n)/(7*Math.LN2));c.realloc(m);for(var b=c.pos-1;b>=o;b--)c.buf[b+m]=c.buf[b]}function yx(o,n){for(var c=0;c>>8,o[c+2]=n>>>16,o[c+3]=n>>>24}function Eb(o,n){return(o[n]|o[n+1]<<8|o[n+2]<<16)+(o[n+3]<<24)}function Sx(o,n,c){o===1&&c.readMessage(Tx,n)}function Tx(o,n,c){if(o===3){const{id:m,bitmap:b,width:v,height:w,left:S,top:M,advance:P}=c.readMessage(Mx,{});n.push({id:m,bitmap:new Iu({width:v+6,height:w+6},b),metrics:{width:v,height:w,left:S,top:M,advance:P}})}}function Mx(o,n,c){o===1?n.id=c.readVarint():o===2?n.bitmap=c.readBytes():o===3?n.width=c.readVarint():o===4?n.height=c.readVarint():o===5?n.left=c.readSVarint():o===6?n.top=c.readSVarint():o===7&&(n.advance=c.readVarint())}function Ib(o){let n=0,c=0;for(const w of o)n+=w.w*w.h,c=Math.max(c,w.w);o.sort((w,S)=>S.h-w.h);const m=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(n/.95)),c),h:1/0}];let b=0,v=0;for(const w of o)for(let S=m.length-1;S>=0;S--){const M=m[S];if(!(w.w>M.w||w.h>M.h)){if(w.x=M.x,w.y=M.y,v=Math.max(v,w.y+w.h),b=Math.max(b,w.x+w.w),w.w===M.w&&w.h===M.h){const P=m.pop();S>3,v=this.pos;this.type=7&m,o(b,n,this),this.pos===v&&this.skip(m)}return n},readMessage:function(o,n){return this.readFields(o,n,this.readVarint()+this.pos)},readFixed32:function(){var o=Lh(this.buf,this.pos);return this.pos+=4,o},readSFixed32:function(){var o=Eb(this.buf,this.pos);return this.pos+=4,o},readFixed64:function(){var o=Lh(this.buf,this.pos)+Lh(this.buf,this.pos+4)*Sp;return this.pos+=8,o},readSFixed64:function(){var o=Lh(this.buf,this.pos)+Eb(this.buf,this.pos+4)*Sp;return this.pos+=8,o},readFloat:function(){var o=Cb(this.buf,this.pos,!0,23,4);return this.pos+=4,o},readDouble:function(){var o=Cb(this.buf,this.pos,!0,52,8);return this.pos+=8,o},readVarint:function(o){var n,c,m=this.buf;return n=127&(c=m[this.pos++]),c<128?n:(n|=(127&(c=m[this.pos++]))<<7,c<128?n:(n|=(127&(c=m[this.pos++]))<<14,c<128?n:(n|=(127&(c=m[this.pos++]))<<21,c<128?n:function(b,v,w){var S,M,P=w.buf;if(S=(112&(M=P[w.pos++]))>>4,M<128||(S|=(127&(M=P[w.pos++]))<<3,M<128)||(S|=(127&(M=P[w.pos++]))<<10,M<128)||(S|=(127&(M=P[w.pos++]))<<17,M<128)||(S|=(127&(M=P[w.pos++]))<<24,M<128)||(S|=(1&(M=P[w.pos++]))<<31,M<128))return Td(b,S,v);throw new Error("Expected varint not more than 10 bytes")}(n|=(15&(c=m[this.pos]))<<28,o,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var o=this.readVarint();return o%2==1?(o+1)/-2:o/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var o=this.readVarint()+this.pos,n=this.pos;return this.pos=o,o-n>=12&&Tb?function(c,m,b){return Tb.decode(c.subarray(m,b))}(this.buf,n,o):function(c,m,b){for(var v="",w=m;w239?4:R>223?3:R>191?2:1;if(w+H>b)break;H===1?R<128&&(F=R):H===2?(192&(S=c[w+1]))==128&&(F=(31&R)<<6|63&S)<=127&&(F=null):H===3?(M=c[w+2],(192&(S=c[w+1]))==128&&(192&M)==128&&((F=(15&R)<<12|(63&S)<<6|63&M)<=2047||F>=55296&&F<=57343)&&(F=null)):H===4&&(M=c[w+2],P=c[w+3],(192&(S=c[w+1]))==128&&(192&M)==128&&(192&P)==128&&((F=(15&R)<<18|(63&S)<<12|(63&M)<<6|63&P)<=65535||F>=1114112)&&(F=null)),F===null?(F=65533,H=1):F>65535&&(F-=65536,v+=String.fromCharCode(F>>>10&1023|55296),F=56320|1023&F),v+=String.fromCharCode(F),w+=H}return v}(this.buf,n,o)},readBytes:function(){var o=this.readVarint()+this.pos,n=this.buf.subarray(this.pos,o);return this.pos=o,n},readPackedVarint:function(o,n){if(this.type!==Qa.Bytes)return o.push(this.readVarint(n));var c=ll(this);for(o=o||[];this.pos127;);else if(n===Qa.Bytes)this.pos=this.readVarint()+this.pos;else if(n===Qa.Fixed32)this.pos+=4;else{if(n!==Qa.Fixed64)throw new Error("Unimplemented type: "+n);this.pos+=8}},writeTag:function(o,n){this.writeVarint(o<<3|n)},realloc:function(o){for(var n=this.length||16;n268435455||o<0?function(n,c){var m,b;if(n>=0?(m=n%4294967296|0,b=n/4294967296|0):(b=~(-n/4294967296),4294967295^(m=~(-n%4294967296))?m=m+1|0:(m=0,b=b+1|0)),n>=18446744073709552e3||n<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");c.realloc(10),function(v,w,S){S.buf[S.pos++]=127&v|128,v>>>=7,S.buf[S.pos++]=127&v|128,v>>>=7,S.buf[S.pos++]=127&v|128,v>>>=7,S.buf[S.pos++]=127&v|128,S.buf[S.pos]=127&(v>>>=7)}(m,0,c),function(v,w){var S=(7&v)<<4;w.buf[w.pos++]|=S|((v>>>=3)?128:0),v&&(w.buf[w.pos++]=127&v|((v>>>=7)?128:0),v&&(w.buf[w.pos++]=127&v|((v>>>=7)?128:0),v&&(w.buf[w.pos++]=127&v|((v>>>=7)?128:0),v&&(w.buf[w.pos++]=127&v|((v>>>=7)?128:0),v&&(w.buf[w.pos++]=127&v)))))}(b,c)}(o,this):(this.realloc(4),this.buf[this.pos++]=127&o|(o>127?128:0),o<=127||(this.buf[this.pos++]=127&(o>>>=7)|(o>127?128:0),o<=127||(this.buf[this.pos++]=127&(o>>>=7)|(o>127?128:0),o<=127||(this.buf[this.pos++]=o>>>7&127))))},writeSVarint:function(o){this.writeVarint(o<0?2*-o-1:2*o)},writeBoolean:function(o){this.writeVarint(!!o)},writeString:function(o){o=String(o),this.realloc(4*o.length),this.pos++;var n=this.pos;this.pos=function(m,b,v){for(var w,S,M=0;M55295&&w<57344){if(!S){w>56319||M+1===b.length?(m[v++]=239,m[v++]=191,m[v++]=189):S=w;continue}if(w<56320){m[v++]=239,m[v++]=191,m[v++]=189,S=w;continue}w=S-55296<<10|w-56320|65536,S=null}else S&&(m[v++]=239,m[v++]=191,m[v++]=189,S=null);w<128?m[v++]=w:(w<2048?m[v++]=w>>6|192:(w<65536?m[v++]=w>>12|224:(m[v++]=w>>18|240,m[v++]=w>>12&63|128),m[v++]=w>>6&63|128),m[v++]=63&w|128)}return v}(this.buf,o,this.pos);var c=this.pos-n;c>=128&&Mb(n,c,this),this.pos=n-1,this.writeVarint(c),this.pos+=c},writeFloat:function(o){this.realloc(4),jb(this.buf,o,this.pos,!0,23,4),this.pos+=4},writeDouble:function(o){this.realloc(8),jb(this.buf,o,this.pos,!0,52,8),this.pos+=8},writeBytes:function(o){var n=o.length;this.writeVarint(n),this.realloc(n);for(var c=0;c=128&&Mb(c,m,this),this.pos=c-1,this.writeVarint(m),this.pos+=m},writeMessage:function(o,n,c){this.writeTag(o,Qa.Bytes),this.writeRawMessage(n,c)},writePackedVarint:function(o,n){n.length&&this.writeMessage(o,yx,n)},writePackedSVarint:function(o,n){n.length&&this.writeMessage(o,vx,n)},writePackedBoolean:function(o,n){n.length&&this.writeMessage(o,xx,n)},writePackedFloat:function(o,n){n.length&&this.writeMessage(o,kx,n)},writePackedDouble:function(o,n){n.length&&this.writeMessage(o,wx,n)},writePackedFixed32:function(o,n){n.length&&this.writeMessage(o,_x,n)},writePackedSFixed32:function(o,n){n.length&&this.writeMessage(o,zx,n)},writePackedFixed64:function(o,n){n.length&&this.writeMessage(o,Cx,n)},writePackedSFixed64:function(o,n){n.length&&this.writeMessage(o,jx,n)},writeBytesField:function(o,n){this.writeTag(o,Qa.Bytes),this.writeBytes(n)},writeFixed32Field:function(o,n){this.writeTag(o,Qa.Fixed32),this.writeFixed32(n)},writeSFixed32Field:function(o,n){this.writeTag(o,Qa.Fixed32),this.writeSFixed32(n)},writeFixed64Field:function(o,n){this.writeTag(o,Qa.Fixed64),this.writeFixed64(n)},writeSFixed64Field:function(o,n){this.writeTag(o,Qa.Fixed64),this.writeSFixed64(n)},writeVarintField:function(o,n){this.writeTag(o,Qa.Varint),this.writeVarint(n)},writeSVarintField:function(o,n){this.writeTag(o,Qa.Varint),this.writeSVarint(n)},writeStringField:function(o,n){this.writeTag(o,Qa.Bytes),this.writeString(n)},writeFloatField:function(o,n){this.writeTag(o,Qa.Fixed32),this.writeFloat(n)},writeDoubleField:function(o,n){this.writeTag(o,Qa.Fixed64),this.writeDouble(n)},writeBooleanField:function(o,n){this.writeVarintField(o,!!n)}};class Tp{constructor(n,{pixelRatio:c,version:m,stretchX:b,stretchY:v,content:w}){this.paddedRect=n,this.pixelRatio=c,this.stretchX=b,this.stretchY=v,this.content=w,this.version=m}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class Ab{constructor(n,c){const m={},b={};this.haveRenderCallbacks=[];const v=[];this.addImages(n,m,v),this.addImages(c,b,v);const{w,h:S}=Ib(v),M=new hs({width:w||1,height:S||1});for(const P in n){const R=n[P],F=m[P].paddedRect;hs.copy(R.data,M,{x:0,y:0},{x:F.x+1,y:F.y+1},R.data)}for(const P in c){const R=c[P],F=b[P].paddedRect,H=F.x+1,Y=F.y+1,K=R.data.width,le=R.data.height;hs.copy(R.data,M,{x:0,y:0},{x:H,y:Y},R.data),hs.copy(R.data,M,{x:0,y:le-1},{x:H,y:Y-1},{width:K,height:1}),hs.copy(R.data,M,{x:0,y:0},{x:H,y:Y+le},{width:K,height:1}),hs.copy(R.data,M,{x:K-1,y:0},{x:H-1,y:Y},{width:1,height:le}),hs.copy(R.data,M,{x:0,y:0},{x:H+K,y:Y},{width:1,height:le})}this.image=M,this.iconPositions=m,this.patternPositions=b}addImages(n,c,m){for(const b in n){const v=n[b],w={x:0,y:0,w:v.data.width+2,h:v.data.height+2};m.push(w),c[b]=new Tp(w,v),v.hasRenderCallback&&this.haveRenderCallbacks.push(b)}}patchUpdatedImages(n,c){n.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const m in n.updatedImages)this.patchUpdatedImage(this.iconPositions[m],n.getImage(m),c),this.patchUpdatedImage(this.patternPositions[m],n.getImage(m),c)}patchUpdatedImage(n,c,m){if(!n||!c||n.version===c.version)return;n.version=c.version;const[b,v]=n.tl;m.update(c.data,void 0,{x:b,y:v})}}Ct("ImagePosition",Tp),Ct("ImageAtlas",Ab),l.WritingMode=void 0,(Hl=l.WritingMode||(l.WritingMode={}))[Hl.none=0]="none",Hl[Hl.horizontal=1]="horizontal",Hl[Hl.vertical=2]="vertical",Hl[Hl.horizontalOnly=3]="horizontalOnly";const Rh=-17;class Bu{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(n,c){const m=new Bu;return m.scale=n||1,m.fontStack=c,m}static forImage(n){const c=new Bu;return c.imageName=n,c}}class Ed{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(n,c){const m=new Ed;for(let b=0;b=0&&m>=n&&Nh[this.text.charCodeAt(m)];m--)c--;this.text=this.text.substring(n,c),this.sectionIndex=this.sectionIndex.slice(n,c)}substring(n,c){const m=new Ed;return m.text=this.text.substring(n,c),m.sectionIndex=this.sectionIndex.slice(n,c),m.sections=this.sections,m}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((n,c)=>Math.max(n,this.sections[c].scale),0)}addTextSection(n,c){this.text+=n.text,this.sections.push(Bu.forText(n.scale,n.fontStack||c));const m=this.sections.length-1;for(let b=0;b=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Bh(o,n,c,m,b,v,w,S,M,P,R,F,H,Y,K,le){const oe=Ed.fromFeature(o,b);let Ce;F===l.WritingMode.vertical&&oe.verticalizePunctuation();const{processBidirectionalText:Ae,processStyledBidirectionalText:xe}=Hr;if(Ae&&oe.sections.length===1){Ce=[];const Ge=Ae(oe.toString(),Mp(oe,P,v,n,m,Y,K));for(const Et of Ge){const Ot=new Ed;Ot.text=Et,Ot.sections=oe.sections;for(let _t=0;_t0&&ul>zr&&(zr=ul)}else{const gs=Ot[Ta.fontStack],Cr=gs&&gs[jn];if(Cr&&Cr.rect)Ys=Cr.rect,Ms=Cr.metrics;else{const ul=Et[Ta.fontStack],Vu=ul&&ul[jn];if(!Vu)continue;Ms=Vu.metrics}Bn=(Cn-Ta.scale)*bn}Es?(Ge.verticalizable=!0,_r.push({glyph:jn,imageName:Ks,x:pi,y:zi+Bn,vertical:Es,scale:Ta.scale,fontStack:Ta.fontStack,sectionIndex:Wr,metrics:Ms,rect:Ys}),pi+=dl*Ta.scale+$t):(_r.push({glyph:jn,imageName:Ks,x:pi,y:zi+Bn,vertical:Es,scale:Ta.scale,fontStack:Ta.fontStack,sectionIndex:Wr,metrics:Ms,rect:Ys}),pi+=Ms.advance*Ta.scale+$t)}_r.length!==0&&(sn=Math.max(pi-$t,sn),Ax(_r,0,_r.length-1,_n,zr)),pi=0;const Di=dt*Cn+zr;rr.lineOffset=Math.max(zr,Rn),zi+=Di,ps=Math.max(Di,ps),++Qi}var un;const zn=zi-Rh,{horizontalAlign:Ln,verticalAlign:xr}=Ep(zt);(function(en,Cn,Rn,rr,_r,zr,Di,hn,Ta){const Wr=(Cn-Rn)*_r;let jn=0;jn=zr!==Di?-hn*rr-Rh:(-rr*Ta+.5)*Di;for(const Bn of en)for(const Ms of Bn.positionedGlyphs)Ms.x+=Wr,Ms.y+=jn})(Ge.positionedLines,_n,Ln,xr,sn,ps,dt,zn,gt.length),Ge.top+=-xr*zn,Ge.bottom=Ge.top+zn,Ge.left+=-Ln*sn,Ge.right=Ge.left+sn}(We,n,c,m,Ce,w,S,M,F,P,H,le),!function(Ge){for(const Et of Ge)if(Et.positionedGlyphs.length!==0)return!1;return!0}(Ie)&&We}const Nh={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Ex={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function Db(o,n,c,m,b,v){if(n.imageName){const w=m[n.imageName];return w?w.displaySize[0]*n.scale*bn/v+b:0}{const w=c[n.fontStack],S=w&&w[o];return S?S.metrics.advance*n.scale+b:0}}function qb(o,n,c,m){const b=Math.pow(o-n,2);return m?o=0;let R=0;for(let H=0;H-c/2;){if(w--,w<0)return!1;S-=o[w].dist(v),v=o[w]}S+=o[w].dist(o[w+1]),w++;const M=[];let P=0;for(;Sm;)P-=M.shift().angleDelta;if(P>b)return!1;w++,S+=R.dist(F)}return!0}function Nb(o){let n=0;for(let c=0;cP){const K=(P-M)/Y,le=ya(F.x,H.x,K),oe=ya(F.y,H.y,K),Ce=new Gl(le,oe,H.angleTo(F),R);return Ce._round(),!w||Bb(o,Ce,S,w,n)?Ce:void 0}M+=Y}}function Px(o,n,c,m,b,v,w,S,M){const P=Fb(m,v,w),R=Vb(m,b),F=R*w,H=o[0].x===0||o[0].x===M||o[0].y===0||o[0].y===M;return n-F=0&&Ie=0&&We=0&&H+P<=R){const Ge=new Gl(Ie,We,Ae,K);Ge._round(),m&&!Bb(o,Ge,v,m,b)||Y.push(Ge)}}F+=Ce}return S||Y.length||w||(Y=Ub(o,F/2,c,m,b,v,w,!0,M)),Y}function $b(o,n,c,m,b){const v=[];for(let w=0;w=m&&F.x>=m||(R.x>=m?R=new at(m,R.y+(m-R.x)/(F.x-R.x)*(F.y-R.y))._round():F.x>=m&&(F=new at(m,R.y+(m-R.x)/(F.x-R.x)*(F.y-R.y))._round()),R.y>=b&&F.y>=b||(R.y>=b?R=new at(R.x+(b-R.y)/(F.y-R.y)*(F.x-R.x),b)._round():F.y>=b&&(F=new at(R.x+(b-R.y)/(F.y-R.y)*(F.x-R.x),b)._round()),M&&R.equals(M[M.length-1])||(M=[R],v.push(M)),M.push(F)))))}}return v}function Hb(o,n,c,m){const b=[],v=o.image,w=v.pixelRatio,S=v.paddedRect.w-2,M=v.paddedRect.h-2,P=o.right-o.left,R=o.bottom-o.top,F=v.stretchX||[[0,S]],H=v.stretchY||[[0,M]],Y=(dt,zt)=>dt+zt[1]-zt[0],K=F.reduce(Y,0),le=H.reduce(Y,0),oe=S-K,Ce=M-le;let Ae=0,xe=K,Ie=0,We=le,Ge=0,Et=oe,Ot=0,_t=Ce;if(v.content&&m){const dt=v.content;Ae=Fh(F,0,dt[0]),Ie=Fh(H,0,dt[1]),xe=Fh(F,dt[0],dt[2]),We=Fh(H,dt[1],dt[3]),Ge=dt[0]-Ae,Ot=dt[1]-Ie,Et=dt[2]-dt[0]-xe,_t=dt[3]-dt[1]-We}const gt=(dt,zt,kt,Ke)=>{const $t=Vh(dt.stretch-Ae,xe,P,o.left),Bt=Uh(dt.fixed-Ge,Et,dt.stretch,K),wa=Vh(zt.stretch-Ie,We,R,o.top),pi=Uh(zt.fixed-Ot,_t,zt.stretch,le),zi=Vh(kt.stretch-Ae,xe,P,o.left),sn=Uh(kt.fixed-Ge,Et,kt.stretch,K),ps=Vh(Ke.stretch-Ie,We,R,o.top),_n=Uh(Ke.fixed-Ot,_t,Ke.stretch,le),Qi=new at($t,wa),un=new at(zi,wa),zn=new at(zi,ps),Ln=new at($t,ps),xr=new at(Bt/w,pi/w),en=new at(sn/w,_n/w),Cn=n*Math.PI/180;if(Cn){const _r=Math.sin(Cn),zr=Math.cos(Cn),Di=[zr,-_r,_r,zr];Qi._matMult(Di),un._matMult(Di),Ln._matMult(Di),zn._matMult(Di)}const Rn=dt.stretch+dt.fixed,rr=zt.stretch+zt.fixed;return{tl:Qi,tr:un,bl:Ln,br:zn,tex:{x:v.paddedRect.x+1+Rn,y:v.paddedRect.y+1+rr,w:kt.stretch+kt.fixed-Rn,h:Ke.stretch+Ke.fixed-rr},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:xr,pixelOffsetBR:en,minFontScaleX:Et/w/P,minFontScaleY:_t/w/R,isSDF:c}};if(m&&(v.stretchX||v.stretchY)){const dt=Gb(F,oe,K),zt=Gb(H,Ce,le);for(let kt=0;kt0&&(K=Math.max(10,K),this.circleDiameter=K)}else{let F=w.top*S-M[0],H=w.bottom*S+M[2],Y=w.left*S-M[3],K=w.right*S+M[1];const le=w.collisionPadding;if(le&&(Y-=le[0]*S,F-=le[1]*S,K+=le[2]*S,H+=le[3]*S),R){const oe=new at(Y,F),Ce=new at(K,F),Ae=new at(Y,H),xe=new at(K,H),Ie=R*Math.PI/180;oe._rotate(Ie),Ce._rotate(Ie),Ae._rotate(Ie),xe._rotate(Ie),Y=Math.min(oe.x,Ce.x,Ae.x,xe.x),K=Math.max(oe.x,Ce.x,Ae.x,xe.x),F=Math.min(oe.y,Ce.y,Ae.y,xe.y),H=Math.max(oe.y,Ce.y,Ae.y,xe.y)}n.emplaceBack(c.x,c.y,Y,F,K,H,m,b,v)}this.boxEndIndex=n.length}}class Ox{constructor(n=[],c=Lx){if(this.data=n,this.length=this.data.length,this.compare=c,this.length>0)for(let m=(this.length>>1)-1;m>=0;m--)this._down(m)}push(n){this.data.push(n),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const n=this.data[0],c=this.data.pop();return this.length--,this.length>0&&(this.data[0]=c,this._down(0)),n}peek(){return this.data[0]}_up(n){const{data:c,compare:m}=this,b=c[n];for(;n>0;){const v=n-1>>1,w=c[v];if(m(b,w)>=0)break;c[n]=w,n=v}c[n]=b}_down(n){const{data:c,compare:m}=this,b=this.length>>1,v=c[n];for(;n=0)break;c[n]=S,n=w}c[n]=v}}function Lx(o,n){return on?1:0}function Rx(o,n=1,c=!1){let m=1/0,b=1/0,v=-1/0,w=-1/0;const S=o[0];for(let Y=0;Yv)&&(v=K.x),(!Y||K.y>w)&&(w=K.y)}const M=Math.min(v-m,w-b);let P=M/2;const R=new Ox([],Bx);if(M===0)return new at(m,b);for(let Y=m;YF.d||!F.d)&&(F=Y,c&&console.log("found best %d after %d probes",Math.round(1e4*Y.d)/1e4,H)),Y.max-F.d<=n||(P=Y.h/2,R.push(new Id(Y.p.x-P,Y.p.y-P,P,o)),R.push(new Id(Y.p.x+P,Y.p.y-P,P,o)),R.push(new Id(Y.p.x-P,Y.p.y+P,P,o)),R.push(new Id(Y.p.x+P,Y.p.y+P,P,o)),H+=4)}return c&&(console.log(`num probes: ${H}`),console.log(`best distance: ${F.d}`)),F.p}function Bx(o,n){return n.max-o.max}function Id(o,n,c,m){this.p=new at(o,n),this.h=c,this.d=function(b,v){let w=!1,S=1/0;for(let M=0;Mb.y!=K.y>b.y&&b.x<(K.x-Y.x)*(b.y-Y.y)/(K.y-Y.y)+Y.x&&(w=!w),S=Math.min(S,eb(b,Y,K))}}return(w?1:-1)*Math.sqrt(S)}(this.p,m),this.max=this.d+this.h*Math.SQRT2}const Ip=Number.POSITIVE_INFINITY;function Wb(o,n){return n[1]!==Ip?function(c,m,b){let v=0,w=0;switch(m=Math.abs(m),b=Math.abs(b),c){case"top-right":case"top-left":case"top":w=b-7;break;case"bottom-right":case"bottom-left":case"bottom":w=7-b}switch(c){case"top-right":case"bottom-right":case"right":v=-m;break;case"top-left":case"bottom-left":case"left":v=m}return[v,w]}(o,n[0],n[1]):function(c,m){let b=0,v=0;m<0&&(m=0);const w=m/Math.sqrt(2);switch(c){case"top-right":case"top-left":v=w-7;break;case"bottom-right":case"bottom-left":v=7-w;break;case"bottom":v=7-m;break;case"top":v=m-7}switch(c){case"top-right":case"bottom-right":b=-w;break;case"top-left":case"bottom-left":b=w;break;case"left":b=m;break;case"right":b=-m}return[b,v]}(o,n[0])}function Ap(o){switch(o){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Nx(o,n,c,m,b,v,w,S,M,P,R){let F=v.textMaxSize.evaluate(n,{});F===void 0&&(F=w);const H=o.layers[0].layout,Y=H.get("icon-offset").evaluate(n,{},R),K=Zb(c.horizontal),le=w/24,oe=o.tilePixelRatio*le,Ce=o.tilePixelRatio*F/24,Ae=o.tilePixelRatio*S,xe=o.tilePixelRatio*H.get("symbol-spacing"),Ie=H.get("text-padding")*o.tilePixelRatio,We=function(Ke,$t,Bt,wa=1){const pi=Ke.get("icon-padding").evaluate($t,{},Bt),zi=pi&&pi.values;return[zi[0]*wa,zi[1]*wa,zi[2]*wa,zi[3]*wa]}(H,n,R,o.tilePixelRatio),Ge=H.get("text-max-angle")/180*Math.PI,Et=H.get("text-rotation-alignment")!=="viewport"&&H.get("symbol-placement")!=="point",Ot=H.get("icon-rotation-alignment")==="map"&&H.get("symbol-placement")!=="point",_t=H.get("symbol-placement"),gt=xe/2,dt=H.get("icon-text-fit");let zt;m&&dt!=="none"&&(o.allowVerticalPlacement&&c.vertical&&(zt=Lb(m,c.vertical,dt,H.get("icon-text-fit-padding"),Y,le)),K&&(m=Lb(m,K,dt,H.get("icon-text-fit-padding"),Y,le)));const kt=(Ke,$t)=>{$t.x<0||$t.x>=rn||$t.y<0||$t.y>=rn||function(Bt,wa,pi,zi,sn,ps,_n,Qi,un,zn,Ln,xr,en,Cn,Rn,rr,_r,zr,Di,hn,Ta,Wr,jn,Bn,Ms){const Ys=Bt.addToLineVertexArray(wa,pi);let Ks,dl,Es,gs,Cr=0,ul=0,Vu=0,uy=0,Vp=-1,Up=-1;const hl={};let hy=Xi.exports(""),$p=0,Hp=0;if(Qi._unevaluatedLayout.getValue("text-radial-offset")===void 0?[$p,Hp]=Qi.layout.get("text-offset").evaluate(Ta,{},Bn).map(jr=>jr*bn):($p=Qi.layout.get("text-radial-offset").evaluate(Ta,{},Bn)*bn,Hp=Ip),Bt.allowVerticalPlacement&&zi.vertical){const jr=Qi.layout.get("text-rotate").evaluate(Ta,{},Bn)+90;Es=new $h(un,wa,zn,Ln,xr,zi.vertical,en,Cn,Rn,jr),_n&&(gs=new $h(un,wa,zn,Ln,xr,_n,_r,zr,Rn,jr))}if(sn){const jr=Qi.layout.get("icon-rotate").evaluate(Ta,{}),jo=Qi.layout.get("icon-text-fit")!=="none",Uu=Hb(sn,jr,jn,jo),$u=_n?Hb(_n,jr,jn,jo):void 0;dl=new $h(un,wa,zn,Ln,xr,sn,_r,zr,!1,jr),Cr=4*Uu.length;const gy=Bt.iconSizeData;let Vc=null;gy.kind==="source"?(Vc=[cl*Qi.layout.get("icon-size").evaluate(Ta,{})],Vc[0]>Wl&<(`${Bt.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):gy.kind==="composite"&&(Vc=[cl*Wr.compositeIconSizes[0].evaluate(Ta,{},Bn),cl*Wr.compositeIconSizes[1].evaluate(Ta,{},Bn)],(Vc[0]>Wl||Vc[1]>Wl)&<(`${Bt.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),Bt.addSymbols(Bt.icon,Uu,Vc,hn,Di,Ta,l.WritingMode.none,wa,Ys.lineStartIndex,Ys.lineLength,-1,Bn),Vp=Bt.icon.placedSymbolArray.length-1,$u&&(ul=4*$u.length,Bt.addSymbols(Bt.icon,$u,Vc,hn,Di,Ta,l.WritingMode.vertical,wa,Ys.lineStartIndex,Ys.lineLength,-1,Bn),Up=Bt.icon.placedSymbolArray.length-1)}const my=Object.keys(zi.horizontal);for(const jr of my){const jo=zi.horizontal[jr];if(!Ks){hy=Xi.exports(jo.text);const $u=Qi.layout.get("text-rotate").evaluate(Ta,{},Bn);Ks=new $h(un,wa,zn,Ln,xr,jo,en,Cn,Rn,$u)}const Uu=jo.positionedLines.length===1;if(Vu+=Jb(Bt,wa,jo,ps,Qi,Rn,Ta,rr,Ys,zi.vertical?l.WritingMode.horizontal:l.WritingMode.horizontalOnly,Uu?my:[jr],hl,Vp,Wr,Bn),Uu)break}zi.vertical&&(uy+=Jb(Bt,wa,zi.vertical,ps,Qi,Rn,Ta,rr,Ys,l.WritingMode.vertical,["vertical"],hl,Up,Wr,Bn));const Qx=Ks?Ks.boxStartIndex:Bt.collisionBoxArray.length,e0=Ks?Ks.boxEndIndex:Bt.collisionBoxArray.length,t0=Es?Es.boxStartIndex:Bt.collisionBoxArray.length,a0=Es?Es.boxEndIndex:Bt.collisionBoxArray.length,i0=dl?dl.boxStartIndex:Bt.collisionBoxArray.length,n0=dl?dl.boxEndIndex:Bt.collisionBoxArray.length,r0=gs?gs.boxStartIndex:Bt.collisionBoxArray.length,s0=gs?gs.boxEndIndex:Bt.collisionBoxArray.length;let Xs=-1;const Zh=(jr,jo)=>jr&&jr.circleDiameter?Math.max(jr.circleDiameter,jo):jo;Xs=Zh(Ks,Xs),Xs=Zh(Es,Xs),Xs=Zh(dl,Xs),Xs=Zh(gs,Xs);const py=Xs>-1?1:0;py&&(Xs*=Ms/bn),Bt.glyphOffsetArray.length>=Ad.MAX_GLYPHS&<("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),Ta.sortKey!==void 0&&Bt.addToSortKeyRanges(Bt.symbolInstances.length,Ta.sortKey),Bt.symbolInstances.emplaceBack(wa.x,wa.y,hl.right>=0?hl.right:-1,hl.center>=0?hl.center:-1,hl.left>=0?hl.left:-1,hl.vertical||-1,Vp,Up,hy,Qx,e0,t0,a0,i0,n0,r0,s0,zn,Vu,uy,Cr,ul,py,0,en,$p,Hp,Xs)}(o,$t,Ke,c,m,b,zt,o.layers[0],o.collisionBoxArray,n.index,n.sourceLayerIndex,o.index,oe,[Ie,Ie,Ie,Ie],Et,M,Ae,We,Ot,Y,n,v,P,R,w)};if(_t==="line")for(const Ke of $b(n.geometry,0,0,rn,rn)){const $t=Px(Ke,xe,Ge,c.vertical||K,m,24,Ce,o.overscaling,rn);for(const Bt of $t){const wa=K;wa&&Fx(o,wa.text,gt,Bt)||kt(Ke,Bt)}}else if(_t==="line-center"){for(const Ke of n.geometry)if(Ke.length>1){const $t=qx(Ke,Ge,c.vertical||K,m,24,Ce);$t&&kt(Ke,$t)}}else if(n.type==="Polygon")for(const Ke of vp(n.geometry,0)){const $t=Rx(Ke,16);kt(Ke[0],new Gl($t.x,$t.y,0))}else if(n.type==="LineString")for(const Ke of n.geometry)kt(Ke,new Gl(Ke[0].x,Ke[0].y,0));else if(n.type==="Point")for(const Ke of n.geometry)for(const $t of Ke)kt([$t],new Gl($t.x,$t.y,0))}const Wl=32640;function Jb(o,n,c,m,b,v,w,S,M,P,R,F,H,Y,K){const le=function(Ae,xe,Ie,We,Ge,Et,Ot,_t){const gt=We.layout.get("text-rotate").evaluate(Et,{})*Math.PI/180,dt=[];for(const zt of xe.positionedLines)for(const kt of zt.positionedGlyphs){if(!kt.rect)continue;const Ke=kt.rect||{};let $t=4,Bt=!0,wa=1,pi=0;const zi=(Ge||_t)&&kt.vertical,sn=kt.metrics.advance*kt.scale/2;if(_t&&xe.verticalizable){const Di=(kt.scale-1)*bn,hn=(bn-kt.metrics.width*kt.scale)/2;pi=zt.lineOffset/2-(kt.imageName?-hn:Di)}if(kt.imageName){const Di=Ot[kt.imageName];Bt=Di.sdf,wa=Di.pixelRatio,$t=1/wa}const ps=Ge?[kt.x+sn,kt.y]:[0,0];let _n=Ge?[0,0]:[kt.x+sn+Ie[0],kt.y+Ie[1]-pi],Qi=[0,0];zi&&(Qi=_n,_n=[0,0]);const un=(kt.metrics.left-$t)*kt.scale-sn+_n[0],zn=(-kt.metrics.top-$t)*kt.scale+_n[1],Ln=un+Ke.w*kt.scale/wa,xr=zn+Ke.h*kt.scale/wa,en=new at(un,zn),Cn=new at(Ln,zn),Rn=new at(un,xr),rr=new at(Ln,xr);if(zi){const Di=new at(-sn,sn-Rh),hn=-Math.PI/2,Ta=12-sn,Wr=new at(22-Ta,-(kt.imageName?Ta:0)),jn=new at(...Qi);en._rotateAround(hn,Di)._add(Wr)._add(jn),Cn._rotateAround(hn,Di)._add(Wr)._add(jn),Rn._rotateAround(hn,Di)._add(Wr)._add(jn),rr._rotateAround(hn,Di)._add(Wr)._add(jn)}if(gt){const Di=Math.sin(gt),hn=Math.cos(gt),Ta=[hn,-Di,Di,hn];en._matMult(Ta),Cn._matMult(Ta),Rn._matMult(Ta),rr._matMult(Ta)}const _r=new at(0,0),zr=new at(0,0);dt.push({tl:en,tr:Cn,bl:Rn,br:rr,tex:Ke,writingMode:xe.writingMode,glyphOffset:ps,sectionIndex:kt.sectionIndex,isSDF:Bt,pixelOffsetTL:_r,pixelOffsetBR:zr,minFontScaleX:0,minFontScaleY:0})}return dt}(0,c,S,b,v,w,m,o.allowVerticalPlacement),oe=o.textSizeData;let Ce=null;oe.kind==="source"?(Ce=[cl*b.layout.get("text-size").evaluate(w,{})],Ce[0]>Wl&<(`${o.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):oe.kind==="composite"&&(Ce=[cl*Y.compositeTextSizes[0].evaluate(w,{},K),cl*Y.compositeTextSizes[1].evaluate(w,{},K)],(Ce[0]>Wl||Ce[1]>Wl)&<(`${o.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),o.addSymbols(o.text,le,Ce,S,v,w,P,n,M.lineStartIndex,M.lineLength,H,K);for(const Ae of R)F[Ae]=o.text.placedSymbolArray.length-1;return 4*le.length}function Zb(o){for(const n in o)return o[n];return null}function Fx(o,n,c,m){const b=o.compareText;if(n in b){const v=b[n];for(let w=v.length-1;w>=0;w--)if(m.dist(v[w])w.id),this.index=n.index,this.pixelRatio=n.pixelRatio,this.sourceLayerIndex=n.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=mp([]),this.placementViewportMatrix=mp([]);const c=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Rb(this.zoom,c["text-size"]),this.iconSizeData=Rb(this.zoom,c["icon-size"]);const m=this.layers[0].layout,b=m.get("symbol-sort-key"),v=m.get("symbol-z-order");this.canOverlap=Lp(m,"text-overlap","text-allow-overlap")!=="never"||Lp(m,"icon-overlap","icon-allow-overlap")!=="never"||m.get("text-ignore-placement")||m.get("icon-ignore-placement"),this.sortFeaturesByKey=v!=="viewport-y"&&!b.isConstant(),this.sortFeaturesByY=(v==="viewport-y"||v==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,m.get("symbol-placement")==="point"&&(this.writingModes=m.get("text-writing-mode").map(w=>l.WritingMode[w])),this.stateDependentLayerIds=this.layers.filter(w=>w.isStateDependent()).map(w=>w.id),this.sourceID=n.sourceID}createArrays(){this.text=new qp(new Lc(this.layers,this.zoom,n=>/^text/.test(n))),this.icon=new qp(new Lc(this.layers,this.zoom,n=>/^icon/.test(n))),this.glyphOffsetArray=new jt,this.lineVertexArray=new pt,this.symbolInstances=new qe}calculateGlyphDependencies(n,c,m,b,v){for(let w=0;w0)&&(w.value.kind!=="constant"||w.value.value.length>0),R=M.value.kind!=="constant"||!!M.value.value||Object.keys(M.parameters).length>0,F=v.get("symbol-sort-key");if(this.features=[],!P&&!R)return;const H=c.iconDependencies,Y=c.glyphDependencies,K=c.availableImages,le=new xi(this.zoom);for(const{feature:oe,id:Ce,index:Ae,sourceLayerIndex:xe}of n){const Ie=b._featureFilter.needGeometry,We=Bc(oe,Ie);if(!b._featureFilter.filter(le,We,m))continue;let Ge,Et;if(Ie||(We.geometry=Rc(oe)),P){const _t=b.getValueAndResolveTokens("text-field",We,m,K),gt=pe.factory(_t);$x(gt)&&(this.hasRTLText=!0),(!this.hasRTLText||zu()==="unavailable"||this.hasRTLText&&Hr.isParsed())&&(Ge=bx(gt,b,We))}if(R){const _t=b.getValueAndResolveTokens("icon-image",We,m,K);Et=_t instanceof de?_t:de.fromString(_t)}if(!Ge&&!Et)continue;const Ot=this.sortFeaturesByKey?F.evaluate(We,{},m):void 0;if(this.features.push({id:Ce,text:Ge,icon:Et,index:Ae,sourceLayerIndex:xe,geometry:We.geometry,properties:oe.properties,type:Vx[oe.type],sortKey:Ot}),Et&&(H[Et.name]=!0),Ge){const _t=w.evaluate(We,{},m).join(","),gt=v.get("text-rotation-alignment")!=="viewport"&&v.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(l.WritingMode.vertical)>=0;for(const dt of Ge.sections)if(dt.image)H[dt.image.name]=!0;else{const zt=Ws(Ge.toString()),kt=dt.fontStack||_t,Ke=Y[kt]=Y[kt]||{};this.calculateGlyphDependencies(dt.text,Ke,gt,this.allowVerticalPlacement,zt)}}}v.get("symbol-placement")==="line"&&(this.features=function(oe){const Ce={},Ae={},xe=[];let Ie=0;function We(_t){xe.push(oe[_t]),Ie++}function Ge(_t,gt,dt){const zt=Ae[_t];return delete Ae[_t],Ae[gt]=zt,xe[zt].geometry[0].pop(),xe[zt].geometry[0]=xe[zt].geometry[0].concat(dt[0]),zt}function Et(_t,gt,dt){const zt=Ce[gt];return delete Ce[gt],Ce[_t]=zt,xe[zt].geometry[0].shift(),xe[zt].geometry[0]=dt[0].concat(xe[zt].geometry[0]),zt}function Ot(_t,gt,dt){const zt=dt?gt[0][gt[0].length-1]:gt[0][0];return`${_t}:${zt.x}:${zt.y}`}for(let _t=0;_t_t.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((oe,Ce)=>oe.sortKey-Ce.sortKey)}update(n,c,m){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(n,c,this.layers,m),this.icon.programConfigurations.updatePaintArrays(n,c,this.layers,m))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(n){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(n),this.iconCollisionBox.upload(n)),this.text.upload(n,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(n,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(n,c){const m=this.lineVertexArray.length;if(n.segment!==void 0){let b=n.dist(c[n.segment+1]),v=n.dist(c[n.segment]);const w={};for(let S=n.segment+1;S=0;S--)w[S]={x:c[S].x,y:c[S].y,tileUnitDistanceFromAnchor:v},S>0&&(v+=c[S-1].dist(c[S]));for(let S=0;S0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(n,c){const m=n.placedSymbolArray.get(c),b=m.vertexStartIndex+4*m.numGlyphs;for(let v=m.vertexStartIndex;vb[S]-b[M]||v[M]-v[S]),w}addToSortKeyRanges(n,c){const m=this.sortKeyRanges[this.sortKeyRanges.length-1];m&&m.sortKey===c?m.symbolInstanceEnd=n+1:this.sortKeyRanges.push({sortKey:c,symbolInstanceStart:n,symbolInstanceEnd:n+1})}sortFeatures(n){if(this.sortFeaturesByY&&this.sortedAngle!==n&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(n),this.sortedAngle=n,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const c of this.symbolInstanceIndexes){const m=this.symbolInstances.get(c);this.featureSortOrder.push(m.featureIndex),[m.rightJustifiedTextSymbolIndex,m.centerJustifiedTextSymbolIndex,m.leftJustifiedTextSymbolIndex].forEach((b,v,w)=>{b>=0&&w.indexOf(b)===v&&this.addIndicesForPlacedSymbol(this.text,b)}),m.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,m.verticalPlacedTextSymbolIndex),m.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,m.placedIconSymbolIndex),m.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,m.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}Ct("SymbolBucket",Ad,{omit:["layers","collisionBoxArray","features","compareText"]}),Ad.MAX_GLYPHS=65535,Ad.addDynamicAttributes=Dp;const Hx=new nn({"symbol-placement":new Rt(Oe.layout_symbol["symbol-placement"]),"symbol-spacing":new Rt(Oe.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Rt(Oe.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Kt(Oe.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Rt(Oe.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Rt(Oe.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Rt(Oe.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Rt(Oe.layout_symbol["icon-ignore-placement"]),"icon-optional":new Rt(Oe.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Rt(Oe.layout_symbol["icon-rotation-alignment"]),"icon-size":new Kt(Oe.layout_symbol["icon-size"]),"icon-text-fit":new Rt(Oe.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Rt(Oe.layout_symbol["icon-text-fit-padding"]),"icon-image":new Kt(Oe.layout_symbol["icon-image"]),"icon-rotate":new Kt(Oe.layout_symbol["icon-rotate"]),"icon-padding":new Kt(Oe.layout_symbol["icon-padding"]),"icon-keep-upright":new Rt(Oe.layout_symbol["icon-keep-upright"]),"icon-offset":new Kt(Oe.layout_symbol["icon-offset"]),"icon-anchor":new Kt(Oe.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Rt(Oe.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Rt(Oe.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Rt(Oe.layout_symbol["text-rotation-alignment"]),"text-field":new Kt(Oe.layout_symbol["text-field"]),"text-font":new Kt(Oe.layout_symbol["text-font"]),"text-size":new Kt(Oe.layout_symbol["text-size"]),"text-max-width":new Kt(Oe.layout_symbol["text-max-width"]),"text-line-height":new Rt(Oe.layout_symbol["text-line-height"]),"text-letter-spacing":new Kt(Oe.layout_symbol["text-letter-spacing"]),"text-justify":new Kt(Oe.layout_symbol["text-justify"]),"text-radial-offset":new Kt(Oe.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Rt(Oe.layout_symbol["text-variable-anchor"]),"text-anchor":new Kt(Oe.layout_symbol["text-anchor"]),"text-max-angle":new Rt(Oe.layout_symbol["text-max-angle"]),"text-writing-mode":new Rt(Oe.layout_symbol["text-writing-mode"]),"text-rotate":new Kt(Oe.layout_symbol["text-rotate"]),"text-padding":new Rt(Oe.layout_symbol["text-padding"]),"text-keep-upright":new Rt(Oe.layout_symbol["text-keep-upright"]),"text-transform":new Kt(Oe.layout_symbol["text-transform"]),"text-offset":new Kt(Oe.layout_symbol["text-offset"]),"text-allow-overlap":new Rt(Oe.layout_symbol["text-allow-overlap"]),"text-overlap":new Rt(Oe.layout_symbol["text-overlap"]),"text-ignore-placement":new Rt(Oe.layout_symbol["text-ignore-placement"]),"text-optional":new Rt(Oe.layout_symbol["text-optional"])});var Op={paint:new nn({"icon-opacity":new Kt(Oe.paint_symbol["icon-opacity"]),"icon-color":new Kt(Oe.paint_symbol["icon-color"]),"icon-halo-color":new Kt(Oe.paint_symbol["icon-halo-color"]),"icon-halo-width":new Kt(Oe.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Kt(Oe.paint_symbol["icon-halo-blur"]),"icon-translate":new Rt(Oe.paint_symbol["icon-translate"]),"icon-translate-anchor":new Rt(Oe.paint_symbol["icon-translate-anchor"]),"text-opacity":new Kt(Oe.paint_symbol["text-opacity"]),"text-color":new Kt(Oe.paint_symbol["text-color"],{runtimeType:Ui,getOverride:o=>o.textColor,hasOverride:o=>!!o.textColor}),"text-halo-color":new Kt(Oe.paint_symbol["text-halo-color"]),"text-halo-width":new Kt(Oe.paint_symbol["text-halo-width"]),"text-halo-blur":new Kt(Oe.paint_symbol["text-halo-blur"]),"text-translate":new Rt(Oe.paint_symbol["text-translate"]),"text-translate-anchor":new Rt(Oe.paint_symbol["text-translate-anchor"])}),layout:Hx};class Yb{constructor(n){if(n.property.overrides===void 0)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=n.property.overrides?n.property.overrides.runtimeType:Bi,this.defaultValue=n}evaluate(n){if(n.formattedSection){const c=this.defaultValue.property.overrides;if(c&&c.hasOverride(n.formattedSection))return c.getOverride(n.formattedSection)}return n.feature&&n.featureState?this.defaultValue.evaluate(n.feature,n.featureState):this.defaultValue.property.specification.default}eachChild(n){this.defaultValue.isConstant()||n(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Ct("FormatSectionOverride",Yb,{omit:["defaultValue"]});class Gh extends tr{constructor(n){super(n,Op)}recalculate(n,c){if(super.recalculate(n,c),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")==="map"?"map":"viewport"),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),this.layout.get("symbol-placement")==="point"){const m=this.layout.get("text-writing-mode");if(m){const b=[];for(const v of m)b.indexOf(v)<0&&b.push(v);this.layout._values["text-writing-mode"]=b}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(n,c,m,b){const v=this.layout.get(n).evaluate(c,{},m,b),w=this._unevaluatedLayout._values[n];return w.isDataDriven()||rs(w.value)||!v?v:function(S,M){return M.replace(/{([^{}]+)}/g,(P,R)=>R in S?String(S[R]):"")}(c.properties,v)}createBucket(n){return new Ad(n)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const n of Op.paint.overridableProperties){if(!Gh.hasPaintOverride(this.layout,n))continue;const c=this.paint.get(n),m=new Yb(c),b=new bo(m,c.property.specification);let v=null;v=c.value.kind==="constant"||c.value.kind==="source"?new Wo("source",b):new Jo("composite",b,c.value.zoomStops),this.paint._values[n]=new Ss(c.property,v,c.parameters)}}_handleOverridablePaintPropertyUpdate(n,c,m){return!(!this.layout||c.isDataDriven()||m.isDataDriven())&&Gh.hasPaintOverride(this.layout,n)}static hasPaintOverride(n,c){const m=n.get("text-field"),b=Op.paint.properties[c];let v=!1;const w=S=>{for(const M of S)if(b.overrides&&b.overrides.hasOverride(M))return void(v=!0)};if(m.value.kind==="constant"&&m.value.value instanceof pe)w(m.value.value.sections);else if(m.value.kind==="source"){const S=P=>{v||(P instanceof rt&&Fe(P.value)===Rr?w(P.value.sections):P instanceof Ho?w(P.sections):P.eachChild(S))},M=m.value;M._styleExpression&&S(M._styleExpression.expression)}return v}}function Lp(o,n,c){let m="never";const b=o.get(n);return b?m=b:o.get(c)&&(m="always"),m}var Gx={paint:new nn({"background-color":new Rt(Oe.paint_background["background-color"]),"background-pattern":new Dc(Oe.paint_background["background-pattern"]),"background-opacity":new Rt(Oe.paint_background["background-opacity"])})},Wx={paint:new nn({"raster-opacity":new Rt(Oe.paint_raster["raster-opacity"]),"raster-hue-rotate":new Rt(Oe.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Rt(Oe.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Rt(Oe.paint_raster["raster-brightness-max"]),"raster-saturation":new Rt(Oe.paint_raster["raster-saturation"]),"raster-contrast":new Rt(Oe.paint_raster["raster-contrast"]),"raster-resampling":new Rt(Oe.paint_raster["raster-resampling"]),"raster-fade-duration":new Rt(Oe.paint_raster["raster-fade-duration"])})};class Jx extends tr{constructor(n){super(n,{}),this.onAdd=c=>{this.implementation.onAdd&&this.implementation.onAdd(c,c.painter.context.gl)},this.onRemove=c=>{this.implementation.onRemove&&this.implementation.onRemove(c,c.painter.context.gl)},this.implementation=n}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}const Zx={circle:class extends tr{constructor(o){super(o,jw)}createBucket(o){return new dp(o)}queryRadius(o){const n=o;return Mu("circle-radius",this,n)+Mu("circle-stroke-width",this,n)+Mh(this.paint.get("circle-translate"))}queryIntersectsFeature(o,n,c,m,b,v,w,S){const M=Eh(o,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),v.angle,w),P=this.paint.get("circle-radius").evaluate(n,c)+this.paint.get("circle-stroke-width").evaluate(n,c),R=this.paint.get("circle-pitch-alignment")==="map",F=R?M:function(Y,K){return Y.map(le=>ob(le,K))}(M,S),H=R?P*w:P;for(const Y of m)for(const K of Y){const le=R?K:ob(K,S);let oe=H;const Ce=Ih([],[K.x,K.y,0,1],S);if(this.paint.get("circle-pitch-scale")==="viewport"&&this.paint.get("circle-pitch-alignment")==="map"?oe*=Ce[3]/v.cameraToCenterDistance:this.paint.get("circle-pitch-scale")==="map"&&this.paint.get("circle-pitch-alignment")==="viewport"&&(oe*=v.cameraToCenterDistance/Ce[3]),ww(F,le,oe))return!0}return!1}},heatmap:class extends tr{constructor(o){super(o,Tw),this._updateColorRamp()}createBucket(o){return new lb(o)}_handleSpecialPaintPropertyUpdate(o){o==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=db({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(){return 0}queryIntersectsFeature(){return!1}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}},hillshade:class extends tr{constructor(o){super(o,Mw)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}},fill:class extends tr{constructor(o){super(o,Hw)}recalculate(o,n){super.recalculate(o,n);const c=this.paint._values["fill-outline-color"];c.value.kind==="constant"&&c.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(o){return new xp(o)}queryRadius(){return Mh(this.paint.get("fill-translate"))}queryIntersectsFeature(o,n,c,m,b,v,w){return Qf(Eh(o,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),v.angle,w),m)}isTileClipped(){return!0}},"fill-extrusion":class extends tr{constructor(o){super(o,rx)}createBucket(o){return new zp(o)}queryRadius(){return Mh(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(o,n,c,m,b,v,w,S){const M=Eh(o,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),v.angle,w),P=this.paint.get("fill-extrusion-height").evaluate(n,c),R=this.paint.get("fill-extrusion-base").evaluate(n,c),F=function(Y,K,le,oe){const Ce=[];for(const Ae of Y){const xe=[Ae.x,Ae.y,0,1];Ih(xe,xe,K),Ce.push(new at(xe[0]/xe[3],xe[1]/xe[3]))}return Ce}(M,S),H=function(Y,K,le,oe){const Ce=[],Ae=[],xe=oe[8]*K,Ie=oe[9]*K,We=oe[10]*K,Ge=oe[11]*K,Et=oe[8]*le,Ot=oe[9]*le,_t=oe[10]*le,gt=oe[11]*le;for(const dt of Y){const zt=[],kt=[];for(const Ke of dt){const $t=Ke.x,Bt=Ke.y,wa=oe[0]*$t+oe[4]*Bt+oe[12],pi=oe[1]*$t+oe[5]*Bt+oe[13],zi=oe[2]*$t+oe[6]*Bt+oe[14],sn=oe[3]*$t+oe[7]*Bt+oe[15],ps=zi+We,_n=sn+Ge,Qi=wa+Et,un=pi+Ot,zn=zi+_t,Ln=sn+gt,xr=new at((wa+xe)/_n,(pi+Ie)/_n);xr.z=ps/_n,zt.push(xr);const en=new at(Qi/Ln,un/Ln);en.z=zn/Ln,kt.push(en)}Ce.push(zt),Ae.push(kt)}return[Ce,Ae]}(m,R,P,S);return function(Y,K,le){let oe=1/0;Qf(le,K)&&(oe=vb(le,K[0]));for(let Ce=0;Ce=3){for(let le=0;le{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){delete this._channel,this._callback=()=>{}}}const Kb=63710088e-1;class Fi{constructor(n,c){if(isNaN(n)||isNaN(c))throw new Error(`Invalid LngLat object: (${n}, ${c})`);if(this.lng=+n,this.lat=+c,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Fi(N(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(n){const c=Math.PI/180,m=this.lat*c,b=n.lat*c,v=Math.sin(m)*Math.sin(b)+Math.cos(m)*Math.cos(b)*Math.cos((n.lng-this.lng)*c);return Kb*Math.acos(Math.min(v,1))}toBounds(n=0){const c=360*n/40075017,m=c/Math.cos(Math.PI/180*this.lat);return new Fc(new Fi(this.lng-m,this.lat-c),new Fi(this.lng+m,this.lat+c))}static convert(n){if(n instanceof Fi)return n;if(Array.isArray(n)&&(n.length===2||n.length===3))return new Fi(Number(n[0]),Number(n[1]));if(!Array.isArray(n)&&typeof n=="object"&&n!==null)return new Fi(Number("lng"in n?n.lng:n.lon),Number(n.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}class Fc{constructor(n,c){n&&(c?this.setSouthWest(n).setNorthEast(c):n.length===4?this.setSouthWest([n[0],n[1]]).setNorthEast([n[2],n[3]]):this.setSouthWest(n[0]).setNorthEast(n[1]))}setNorthEast(n){return this._ne=n instanceof Fi?new Fi(n.lng,n.lat):Fi.convert(n),this}setSouthWest(n){return this._sw=n instanceof Fi?new Fi(n.lng,n.lat):Fi.convert(n),this}extend(n){const c=this._sw,m=this._ne;let b,v;if(n instanceof Fi)b=n,v=n;else{if(!(n instanceof Fc))return Array.isArray(n)?n.length===4||n.every(Array.isArray)?this.extend(Fc.convert(n)):this.extend(Fi.convert(n)):this;if(b=n._sw,v=n._ne,!b||!v)return this}return c||m?(c.lng=Math.min(b.lng,c.lng),c.lat=Math.min(b.lat,c.lat),m.lng=Math.max(v.lng,m.lng),m.lat=Math.max(v.lat,m.lat)):(this._sw=new Fi(b.lng,b.lat),this._ne=new Fi(v.lng,v.lat)),this}getCenter(){return new Fi((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new Fi(this.getWest(),this.getNorth())}getSouthEast(){return new Fi(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(n){const{lng:c,lat:m}=Fi.convert(n);let b=this._sw.lng<=c&&c<=this._ne.lng;return this._sw.lng>this._ne.lng&&(b=this._sw.lng>=c&&c>=this._ne.lng),this._sw.lat<=m&&m<=this._ne.lat&&b}static convert(n){return n instanceof Fc?n:n&&new Fc(n)}}const Xb=2*Math.PI*Kb;function Qb(o){return Xb*Math.cos(o*Math.PI/180)}function ey(o){return(180+o)/360}function ty(o){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+o*Math.PI/360)))/360}function ay(o,n){return o/Qb(n)}function Rp(o){return 360/Math.PI*Math.atan(Math.exp((180-360*o)*Math.PI/180))-90}class Wh{constructor(n,c,m=0){this.x=+n,this.y=+c,this.z=+m}static fromLngLat(n,c=0){const m=Fi.convert(n);return new Wh(ey(m.lng),ty(m.lat),ay(c,m.lat))}toLngLat(){return new Fi(360*this.x-180,Rp(this.y))}toAltitude(){return this.z*Qb(Rp(this.y))}meterInMercatorCoordinateUnits(){return 1/Xb*(n=Rp(this.y),1/Math.cos(n*Math.PI/180));var n}}function iy(o,n,c){var m=2*Math.PI*6378137/256/Math.pow(2,c);return[o*m-2*Math.PI*6378137/2,n*m-2*Math.PI*6378137/2]}class Bp{constructor(n,c,m){if(n<0||n>25||m<0||m>=Math.pow(2,n)||c<0||c>=Math.pow(2,n))throw new Error(`x=${c}, y=${m}, z=${n} outside of bounds. 0<=x<${Math.pow(2,n)}, 0<=y<${Math.pow(2,n)} 0<=z<=25 `);this.z=n,this.x=c,this.y=m,this.key=Nu(0,n,n,c,m)}equals(n){return this.z===n.z&&this.x===n.x&&this.y===n.y}url(n,c,m){const b=(w=this.y,S=this.z,M=iy(256*(v=this.x),256*(w=Math.pow(2,S)-w-1),S),P=iy(256*(v+1),256*(w+1),S),M[0]+","+M[1]+","+P[0]+","+P[1]);var v,w,S,M,P;const R=function(F,H,Y){let K,le="";for(let oe=F;oe>0;oe--)K=1<1?"@2x":"").replace(/{quadkey}/g,R).replace(/{bbox-epsg-3857}/g,b)}isChildOf(n){const c=this.z-n.z;return c>0&&n.x===this.x>>c&&n.y===this.y>>c}getTilePoint(n){const c=Math.pow(2,this.z);return new at((n.x*c-this.x)*rn,(n.y*c-this.y)*rn)}toString(){return`${this.z}/${this.x}/${this.y}`}}class ny{constructor(n,c){this.wrap=n,this.canonical=c,this.key=Nu(n,c.z,c.z,c.x,c.y)}}class ms{constructor(n,c,m,b,v){if(n= z; overscaledZ = ${n}; z = ${m}`);this.overscaledZ=n,this.wrap=c,this.canonical=new Bp(m,+b,+v),this.key=Nu(c,n,m,b,v)}clone(){return new ms(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(n){return this.overscaledZ===n.overscaledZ&&this.wrap===n.wrap&&this.canonical.equals(n.canonical)}scaledTo(n){if(n>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${n}; overscaledZ = ${this.overscaledZ}`);const c=this.canonical.z-n;return n>this.canonical.z?new ms(n,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new ms(n,this.wrap,n,this.canonical.x>>c,this.canonical.y>>c)}calculateScaledKey(n,c){if(n>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${n}; overscaledZ = ${this.overscaledZ}`);const m=this.canonical.z-n;return n>this.canonical.z?Nu(this.wrap*+c,n,this.canonical.z,this.canonical.x,this.canonical.y):Nu(this.wrap*+c,n,n,this.canonical.x>>m,this.canonical.y>>m)}isChildOf(n){if(n.wrap!==this.wrap)return!1;const c=this.canonical.z-n.canonical.z;return n.overscaledZ===0||n.overscaledZ>c&&n.canonical.y===this.canonical.y>>c}children(n){if(this.overscaledZ>=n)return[new ms(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const c=this.canonical.z+1,m=2*this.canonical.x,b=2*this.canonical.y;return[new ms(c,this.wrap,c,m,b),new ms(c,this.wrap,c,m+1,b),new ms(c,this.wrap,c,m,b+1),new ms(c,this.wrap,c,m+1,b+1)]}isLessThan(n){return this.wrapn.wrap)&&(this.overscaledZn.overscaledZ)&&(this.canonical.xn.canonical.x)&&this.canonical.ythis.max&&(this.max=S),S=this.dim+1||c<-1||c>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(c+1)*this.stride+(n+1)}_unpackMapbox(n,c,m){return(256*n*256+256*c+m)/10-1e4}_unpackTerrarium(n,c,m){return 256*n+c+m/256-32768}getPixels(){return new hs({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(n,c,m){if(this.dim!==n.dim)throw new Error("dem dimension mismatch");let b=c*this.dim,v=c*this.dim+this.dim,w=m*this.dim,S=m*this.dim+this.dim;switch(c){case-1:b=v-1;break;case 1:v=b+1}switch(m){case-1:w=S-1;break;case 1:S=w+1}const M=-c*this.dim,P=-m*this.dim;for(let R=w;R=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${n} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[n]}}class oy{constructor(n,c,m,b,v){this.type="Feature",this._vectorTileFeature=n,n._z=c,n._x=m,n._y=b,this.properties=n.properties,this.id=v}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(n){this._geometry=n}toJSON(){const n={geometry:this.geometry};for(const c in this)c!=="_geometry"&&c!=="_vectorTileFeature"&&(n[c]=this[c]);return n}}class ly{constructor(n,c){this.tileID=n,this.x=n.canonical.x,this.y=n.canonical.y,this.z=n.canonical.z,this.grid=new La(rn,16,0),this.grid3D=new La(rn,16,0),this.featureIndexArray=new fa,this.promoteId=c}insert(n,c,m,b,v,w){const S=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(m,b,v);const M=w?this.grid3D:this.grid;for(let P=0;P=0&&F[3]>=0&&M.insert(S,F[0],F[1],F[2],F[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new $l.VectorTile(new jp(this.rawTileData)).layers,this.sourceLayerCoder=new sy(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(n,c,m,b){this.loadVTLayers();const v=n.params||{},w=rn/n.tileSize/n.scale,S=ko(v.filter),M=n.queryGeometry,P=n.queryPadding*w,R=dy(M),F=this.grid.query(R.minX-P,R.minY-P,R.maxX+P,R.maxY+P),H=dy(n.cameraQueryGeometry),Y=this.grid3D.query(H.minX-P,H.minY-P,H.maxX+P,H.maxY+P,(oe,Ce,Ae,xe)=>function(Ie,We,Ge,Et,Ot){for(const gt of Ie)if(We<=gt.x&&Ge<=gt.y&&Et>=gt.x&&Ot>=gt.y)return!0;const _t=[new at(We,Ge),new at(We,Ot),new at(Et,Ot),new at(Et,Ge)];if(Ie.length>2){for(const gt of _t)if(Cd(Ie,gt))return!0}for(let gt=0;gt(xe||(xe=Rc(Ie)),We.queryIntersectsFeature(M,Ie,Ge,xe,this.z,n.transform,w,n.pixelPosMatrix)))}return K}loadMatchingFeature(n,c,m,b,v,w,S,M,P,R,F){const H=this.bucketLayerIDs[c];if(w&&!function(oe,Ce){for(let Ae=0;Ae=0)return!0;return!1}(w,H))return;const Y=this.sourceLayerCoder.decode(m),K=this.vtLayers[Y].feature(b);if(v.needGeometry){const oe=Bc(K,!0);if(!v.filter(new xi(this.tileID.overscaledZ),oe,this.tileID.canonical))return}else if(!v.filter(new xi(this.tileID.overscaledZ),K))return;const le=this.getId(K,Y);for(let oe=0;oe{const S=n instanceof yd?n.get(w):null;return S&&S.evaluate?S.evaluate(c,m,b):S})}function dy(o){let n=1/0,c=1/0,m=-1/0,b=-1/0;for(const v of o)n=Math.min(n,v.x),c=Math.min(c,v.y),m=Math.max(m,v.x),b=Math.max(b,v.y);return{minX:n,minY:c,maxX:m,maxY:b}}function Kx(o,n){return n-o}var Np;Ct("FeatureIndex",ly,{omit:["rawTileData","sourceLayerCoder"]}),l.PerformanceMarkers=void 0,(Np=l.PerformanceMarkers||(l.PerformanceMarkers={})).create="create",Np.load="load",Np.fullLoad="fullLoad";let Jh=null,Fu=[];const Fp=1e3/30,Xx={mark(o){performance.mark(o)},frame(o){const n=o;Jh!=null&&Fu.push(n-Jh),Jh=n},clearMetrics(){Jh=null,Fu=[],performance.clearMeasures("loadTime"),performance.clearMeasures("fullLoadTime");for(const o in l.PerformanceMarkers)performance.clearMarks(l.PerformanceMarkers[o])},getPerformanceMetrics(){performance.measure("loadTime",l.PerformanceMarkers.create,l.PerformanceMarkers.load),performance.measure("fullLoadTime",l.PerformanceMarkers.create,l.PerformanceMarkers.fullLoad);const o=performance.getEntriesByName("loadTime")[0].duration,n=performance.getEntriesByName("fullLoadTime")[0].duration,c=Fu.length,m=1/(Fu.reduce((v,w)=>v+w,0)/c/1e3),b=Fu.filter(v=>v>Fp).reduce((v,w)=>v+(w-Fp)/Fp,0);return{loadTime:o,fullLoadTime:n,fps:m,percentDroppedFrames:b/(c+b)*100}}};l.AJAXError=Ti,l.ARRAY_TYPE=nr,l.Actor=class{constructor(o,n,c){this.target=o,this.parent=n,this.mapId=c,this.callbacks={},this.tasks={},this.taskQueue=[],this.cancelCallbacks={},se(["receive","process"],this),this.invoker=new Yx(this.process),this.target.addEventListener("message",this.receive,!1),this.globalScope=nt()?o:window}send(o,n,c,m,b=!1){const v=Math.round(1e18*Math.random()).toString(36).substring(0,10);c&&(this.callbacks[v]=c);const w=Ca(this.globalScope)?void 0:[];return this.target.postMessage({id:v,type:o,hasCallback:!!c,targetMapId:m,mustQueue:b,sourceMapId:this.mapId,data:Gs(n,w)},w),{cancel:()=>{c&&delete this.callbacks[v],this.target.postMessage({id:v,type:"",targetMapId:m,sourceMapId:this.mapId})}}}receive(o){const n=o.data,c=n.id;if(c&&(!n.targetMapId||this.mapId===n.targetMapId))if(n.type===""){delete this.tasks[c];const m=this.cancelCallbacks[c];delete this.cancelCallbacks[c],m&&m()}else nt()||n.mustQueue?(this.tasks[c]=n,this.taskQueue.push(c),this.invoker.trigger()):this.processTask(c,n)}process(){if(!this.taskQueue.length)return;const o=this.taskQueue.shift(),n=this.tasks[o];delete this.tasks[o],this.taskQueue.length&&this.invoker.trigger(),n&&this.processTask(o,n)}processTask(o,n){if(n.type===""){const c=this.callbacks[o];delete this.callbacks[o],c&&(n.error?c(Yi(n.error)):c(null,Yi(n.data)))}else{let c=!1;const m=Ca(this.globalScope)?void 0:[],b=n.hasCallback?(S,M)=>{c=!0,delete this.cancelCallbacks[o],this.target.postMessage({id:o,type:"",sourceMapId:this.mapId,error:S?Gs(S):null,data:Gs(M,m)},m)}:S=>{c=!0};let v=null;const w=Yi(n.data);if(this.parent[n.type])v=this.parent[n.type](n.sourceMapId,w,b);else if(this.parent.getWorkerSource){const S=n.type.split(".");v=this.parent.getWorkerSource(n.sourceMapId,S[0],w.source)[S[1]](w,b)}else b(new Error(`Could not find function ${n.type}`));!c&&v&&v.cancel&&(this.cancelCallbacks[o]=v.cancel)}}remove(){this.invoker.remove(),this.target.removeEventListener("message",this.receive,!1)}},l.AlphaImage=Iu,l.CanonicalTileID=Bp,l.CollisionBoxArray=Te,l.CollisionCircleLayoutArray=class extends O{},l.Color=W,l.DEMData=ry,l.DataConstantProperty=Rt,l.DictionaryCoder=sy,l.EXTENT=rn,l.ErrorEvent=pr,l.EvaluationParameters=xi,l.Event=Kn,l.Evented=Bs,l.FeatureIndex=ly,l.FillBucket=xp,l.FillExtrusionBucket=zp,l.GeoJSONFeature=oy,l.ImageAtlas=Ab,l.ImagePosition=Tp,l.LineBucket=Cp,l.LineStripIndexArray=class extends je{},l.LngLat=Fi,l.LngLatBounds=Fc,l.MercatorCoordinate=Wh,l.ONE_EM=bn,l.OverscaledTileID=ms,l.PerformanceUtils=Xx,l.PosArray=ka,l.Properties=nn,l.QuadTriangleArray=class extends U{},l.RGBAImage=hs,l.RasterBoundsArray=class extends Pc{},l.RequestPerformance=class{constructor(o){this._marks={start:[o.url,"start"].join("#"),end:[o.url,"end"].join("#"),measure:o.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let o=performance.getEntriesByName(this._marks.measure);return o.length===0&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),o=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),o}},l.ResourceType=ws,l.SegmentVector=Ba,l.SymbolBucket=Ad,l.Transitionable=Cu,l.TriangleIndexArray=fn,l.Uniform1f=xd,l.Uniform1i=class extends us{constructor(o,n){super(o,n),this.current=0}set(o){this.current!==o&&(this.current=o,this.gl.uniform1i(this.location,o))}},l.Uniform2f=class extends us{constructor(o,n){super(o,n),this.current=[0,0]}set(o){o[0]===this.current[0]&&o[1]===this.current[1]||(this.current=o,this.gl.uniform2f(this.location,o[0],o[1]))}},l.Uniform3f=class extends us{constructor(o,n){super(o,n),this.current=[0,0,0]}set(o){o[0]===this.current[0]&&o[1]===this.current[1]&&o[2]===this.current[2]||(this.current=o,this.gl.uniform3f(this.location,o[0],o[1],o[2]))}},l.Uniform4f=Oc,l.UniformColor=_d,l.UniformMatrix4f=class extends us{constructor(o,n){super(o,n),this.current=vw}set(o){if(o[12]!==this.current[12]||o[0]!==this.current[0])return this.current=o,void this.gl.uniformMatrix4fv(this.location,!1,o);for(let n=1;n<16;n++)if(o[n]!==this.current[n]){this.current=o,this.gl.uniformMatrix4fv(this.location,!1,o);break}}},l.UnwrappedTileID=ny,l.ValidationError=st,l.ZoomHistory=On,l.add=function(o,n,c){return o[0]=n[0]+c[0],o[1]=n[1]+c[1],o[2]=n[2]+c[2],o},l.addDynamicAttributes=Dp,l.asyncAll=function(o,n,c){if(!o.length)return c(null,[]);let m=o.length;const b=new Array(o.length);let v=null;o.forEach((w,S)=>{n(w,(M,P)=>{M&&(v=M),b[S]=P,--m==0&&c(v,b)})})},l.bezier=T,l.bindAll=se,l.cacheEntryPossiblyAdded=function(o){ut++,ut>di&&(o.getActor().send("enforceCacheSizeLimit",$a),ut=0)},l.clamp=A,l.clearTileCache=function(o){const n=caches.delete(ja);o&&n.catch(o).then(()=>o())},l.clipLine=$b,l.clone=function(o){var n=new nr(16);return n[0]=o[0],n[1]=o[1],n[2]=o[2],n[3]=o[3],n[4]=o[4],n[5]=o[5],n[6]=o[6],n[7]=o[7],n[8]=o[8],n[9]=o[9],n[10]=o[10],n[11]=o[11],n[12]=o[12],n[13]=o[13],n[14]=o[14],n[15]=o[15],n},l.clone$1=$e,l.clone$2=function(o){var n=new nr(3);return n[0]=o[0],n[1]=o[1],n[2]=o[2],n},l.collisionCircleLayout=fx,l.config=ta,l.copy=function(o,n){return o[0]=n[0],o[1]=n[1],o[2]=n[2],o[3]=n[3],o[4]=n[4],o[5]=n[5],o[6]=n[6],o[7]=n[7],o[8]=n[8],o[9]=n[9],o[10]=n[10],o[11]=n[11],o[12]=n[12],o[13]=n[13],o[14]=n[14],o[15]=n[15],o},l.create=function(){var o=new nr(16);return nr!=Float32Array&&(o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[11]=0,o[12]=0,o[13]=0,o[14]=0),o[0]=1,o[5]=1,o[10]=1,o[15]=1,o},l.create$1=ab,l.createExpression=yo,l.createFilter=ko,l.createLayout=Ki,l.createStyleLayer=function(o){return o.type==="custom"?new Jx(o):new Zx[o.type](o)},l.cross=function(o,n,c){var m=n[0],b=n[1],v=n[2],w=c[0],S=c[1],M=c[2];return o[0]=b*M-v*S,o[1]=v*w-m*M,o[2]=m*S-b*w,o},l.dot=function(o,n){return o[0]*n[0]+o[1]*n[1]+o[2]*n[2]},l.dot$1=function(o,n){return o[0]*n[0]+o[1]*n[1]+o[2]*n[2]+o[3]*n[3]},l.ease=q,l.emitValidationErrors=pd,l.enforceCacheSizeLimit=function(o){ri(),yi&&yi.then(n=>{n.keys().then(c=>{for(let m=0;m{}}},l.identity=mp,l.invert=function(o,n){var c=n[0],m=n[1],b=n[2],v=n[3],w=n[4],S=n[5],M=n[6],P=n[7],R=n[8],F=n[9],H=n[10],Y=n[11],K=n[12],le=n[13],oe=n[14],Ce=n[15],Ae=c*S-m*w,xe=c*M-b*w,Ie=c*P-v*w,We=m*M-b*S,Ge=m*P-v*S,Et=b*P-v*M,Ot=R*le-F*K,_t=R*oe-H*K,gt=R*Ce-Y*K,dt=F*oe-H*le,zt=F*Ce-Y*le,kt=H*Ce-Y*oe,Ke=Ae*kt-xe*zt+Ie*dt+We*gt-Ge*_t+Et*Ot;return Ke?(o[0]=(S*kt-M*zt+P*dt)*(Ke=1/Ke),o[1]=(b*zt-m*kt-v*dt)*Ke,o[2]=(le*Et-oe*Ge+Ce*We)*Ke,o[3]=(H*Ge-F*Et-Y*We)*Ke,o[4]=(M*gt-w*kt-P*_t)*Ke,o[5]=(c*kt-b*gt+v*_t)*Ke,o[6]=(oe*Ie-K*Et-Ce*xe)*Ke,o[7]=(R*Et-H*Ie+Y*xe)*Ke,o[8]=(w*zt-S*gt+P*Ot)*Ke,o[9]=(m*gt-c*zt-v*Ot)*Ke,o[10]=(K*Ge-le*Ie+Ce*Ae)*Ke,o[11]=(F*Ie-R*Ge-Y*Ae)*Ke,o[12]=(S*_t-w*dt-M*Ot)*Ke,o[13]=(c*dt-m*_t+b*Ot)*Ke,o[14]=(le*xe-K*We-oe*Ae)*Ke,o[15]=(R*We-F*xe+H*Ae)*Ke,o):null},l.isImageBitmap=za,l.isSafari=Ca,l.isWorker=nt,l.keysDifference=function(o,n){const c=[];for(const m in o)m in n||c.push(m);return c},l.lazyLoadRTLTextPlugin=function(){Hr.isLoading()||Hr.isLoaded()||zu()!=="deferred"||gd()},l.makeRequest=Or,l.mapObject=ze,l.mercatorXfromLng=ey,l.mercatorYfromLat=ty,l.mercatorZfromAltitude=ay,l.mul=Sw,l.mul$1=function(o,n,c){return o[0]=n[0]*c[0],o[1]=n[1]*c[1],o[2]=n[2]*c[2],o[3]=n[3]*c[3],o},l.multiply=ib,l.nextPowerOfTwo=function(o){return o<=1?1:Math.pow(2,Math.ceil(Math.log(o)/Math.LN2))},l.normalize=function(o,n){var c=n[0],m=n[1],b=n[2],v=c*c+m*m+b*b;return v>0&&(v=1/Math.sqrt(v)),o[0]=n[0]*v,o[1]=n[1]*v,o[2]=n[2]*v,o},l.number=ya,l.ortho=function(o,n,c,m,b,v,w){var S=1/(n-c),M=1/(m-b),P=1/(v-w);return o[0]=-2*S,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=-2*M,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=2*P,o[11]=0,o[12]=(n+c)*S,o[13]=(b+m)*M,o[14]=(w+v)*P,o[15]=1,o},l.parseCacheControl=_a,l.parseGlyphPbf=function(o){return new jp(o).readFields(Sx,[])},l.pbf=jp,l.performSymbolLayout=function(o){o.bucket.createArrays(),o.bucket.tilePixelRatio=rn/(512*o.bucket.overscaling),o.bucket.compareText={},o.bucket.iconsNeedLinear=!1;const n=o.bucket.layers[0].layout,c=o.bucket.layers[0]._unevaluatedLayout._values,m={layoutIconSize:c["icon-size"].possiblyEvaluate(new xi(o.bucket.zoom+1),o.canonical),layoutTextSize:c["text-size"].possiblyEvaluate(new xi(o.bucket.zoom+1),o.canonical),textMaxSize:c["text-size"].possiblyEvaluate(new xi(18))};if(o.bucket.textSizeData.kind==="composite"){const{minZoom:M,maxZoom:P}=o.bucket.textSizeData;m.compositeTextSizes=[c["text-size"].possiblyEvaluate(new xi(M),o.canonical),c["text-size"].possiblyEvaluate(new xi(P),o.canonical)]}if(o.bucket.iconSizeData.kind==="composite"){const{minZoom:M,maxZoom:P}=o.bucket.iconSizeData;m.compositeIconSizes=[c["icon-size"].possiblyEvaluate(new xi(M),o.canonical),c["icon-size"].possiblyEvaluate(new xi(P),o.canonical)]}const b=n.get("text-line-height")*bn,v=n.get("text-rotation-alignment")!=="viewport"&&n.get("symbol-placement")!=="point",w=n.get("text-keep-upright"),S=n.get("text-size");for(const M of o.bucket.features){const P=n.get("text-font").evaluate(M,{},o.canonical).join(","),R=S.evaluate(M,{},o.canonical),F=m.layoutTextSize.evaluate(M,{},o.canonical),H=m.layoutIconSize.evaluate(M,{},o.canonical),Y={horizontal:{},vertical:void 0},K=M.text;let le,oe=[0,0];if(K){const xe=K.toString(),Ie=n.get("text-letter-spacing").evaluate(M,{},o.canonical)*bn,We=al(xe)?Ie:0,Ge=n.get("text-anchor").evaluate(M,{},o.canonical),Et=n.get("text-variable-anchor");if(!Et){const zt=n.get("text-radial-offset").evaluate(M,{},o.canonical);oe=zt?Wb(Ge,[zt*bn,Ip]):n.get("text-offset").evaluate(M,{},o.canonical).map(kt=>kt*bn)}let Ot=v?"center":n.get("text-justify").evaluate(M,{},o.canonical);const _t=n.get("symbol-placement"),gt=_t==="point"?n.get("text-max-width").evaluate(M,{},o.canonical)*bn:0,dt=()=>{o.bucket.allowVerticalPlacement&&Ws(xe)&&(Y.vertical=Bh(K,o.glyphMap,o.glyphPositions,o.imagePositions,P,gt,b,Ge,"left",We,oe,l.WritingMode.vertical,!0,_t,F,R))};if(!v&&Et){const zt=Ot==="auto"?Et.map(Ke=>Ap(Ke)):[Ot];let kt=!1;for(let Ke=0;Kethis._layers[Fe.id]),pe=ce[0];if(pe.visibility==="none")continue;const ue=pe.source||"";let de=this.familiesBySource[ue];de||(de=this.familiesBySource[ue]={});const ye=pe.sourceLayer||"_geojsonTileLayer";let De=de[ye];De||(De=de[ye]=[]),De.push(ce)}}}class q{constructor(L){const V={},W=[];for(const ue in L){const de=L[ue],ye=V[ue]={};for(const De in de){const Fe=de[+De];if(!Fe||Fe.bitmap.width===0||Fe.bitmap.height===0)continue;const Be={x:0,y:0,w:Fe.bitmap.width+2,h:Fe.bitmap.height+2};W.push(Be),ye[De]={rect:Be,metrics:Fe.metrics}}}const{w:ee,h:ce}=l.potpack(W),pe=new l.AlphaImage({width:ee||1,height:ce||1});for(const ue in L){const de=L[ue];for(const ye in de){const De=de[+ye];if(!De||De.bitmap.width===0||De.bitmap.height===0)continue;const Fe=V[ue][ye].rect;l.AlphaImage.copy(De.bitmap,pe,{x:0,y:0},{x:Fe.x+1,y:Fe.y+1},De.bitmap)}}this.image=pe,this.positions=V}}l.register("GlyphAtlas",q);class A{constructor(L){this.tileID=new l.OverscaledTileID(L.tileID.overscaledZ,L.tileID.wrap,L.tileID.canonical.z,L.tileID.canonical.x,L.tileID.canonical.y),this.uid=L.uid,this.zoom=L.zoom,this.pixelRatio=L.pixelRatio,this.tileSize=L.tileSize,this.source=L.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=L.showCollisionBoxes,this.collectResourceTiming=!!L.collectResourceTiming,this.returnDependencies=!!L.returnDependencies,this.promoteId=L.promoteId}parse(L,V,W,ee,ce){this.status="parsing",this.data=L,this.collisionBoxArray=new l.CollisionBoxArray;const pe=new l.DictionaryCoder(Object.keys(L.layers).sort()),ue=new l.FeatureIndex(this.tileID,this.promoteId);ue.bucketLayerIDs=[];const de={},ye={featureIndex:ue,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:W},De=V.familiesBySource[this.source];for(const oa in De){const ra=L.layers[oa];if(!ra)continue;ra.version===1&&l.warnOnce(`Vector tile source "${this.source}" layer "${oa}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const ua=pe.encode(oa),Pi=[];for(let Ei=0;Ei=Ni.maxzoom||Ni.visibility!=="none"&&(N(Ei,this.zoom,W),(de[Ni.id]=Ni.createBucket({index:ue.bucketLayerIDs.length,layers:Ei,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:ua,sourceID:this.source})).populate(Pi,ye,this.tileID.canonical),ue.bucketLayerIDs.push(Ei.map(Zi=>Zi.id)))}}let Fe,Be,rt,xt;const qt=l.mapObject(ye.glyphDependencies,oa=>Object.keys(oa).map(Number));Object.keys(qt).length?ee.send("getGlyphs",{uid:this.uid,stacks:qt},(oa,ra)=>{Fe||(Fe=oa,Be=ra,ga.call(this))}):Be={};const Mt=Object.keys(ye.iconDependencies);Mt.length?ee.send("getImages",{icons:Mt,source:this.source,tileID:this.tileID,type:"icons"},(oa,ra)=>{Fe||(Fe=oa,rt=ra,ga.call(this))}):rt={};const ea=Object.keys(ye.patternDependencies);function ga(){if(Fe)return ce(Fe);if(Be&&rt&&xt){const oa=new q(Be),ra=new l.ImageAtlas(rt,xt);for(const ua in de){const Pi=de[ua];Pi instanceof l.SymbolBucket?(N(Pi.layers,this.zoom,W),l.performSymbolLayout({bucket:Pi,glyphMap:Be,glyphPositions:oa.positions,imageMap:rt,imagePositions:ra.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):Pi.hasPattern&&(Pi instanceof l.LineBucket||Pi instanceof l.FillBucket||Pi instanceof l.FillExtrusionBucket)&&(N(Pi.layers,this.zoom,W),Pi.addFeatures(ye,this.tileID.canonical,ra.patternPositions))}this.status="done",ce(null,{buckets:Object.values(de).filter(ua=>!ua.isEmpty()),featureIndex:ue,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:oa.image,imageAtlas:ra,glyphMap:this.returnDependencies?Be:null,iconMap:this.returnDependencies?rt:null,glyphPositions:this.returnDependencies?oa.positions:null})}}ea.length?ee.send("getImages",{icons:ea,source:this.source,tileID:this.tileID,type:"patterns"},(oa,ra)=>{Fe||(Fe=oa,xt=ra,ga.call(this))}):xt={},ga.call(this)}}function N(Q,L,V){const W=new l.EvaluationParameters(L);for(const ee of Q)ee.recalculate(W,V)}function $(Q,L){const V=l.getArrayBuffer(Q.request,(W,ee,ce,pe)=>{W?L(W):ee&&L(null,{vectorTile:new l.vectorTile.VectorTile(new l.pbf(ee)),rawData:ee,cacheControl:ce,expires:pe})});return()=>{V.cancel(),L()}}class X{constructor(L,V,W,ee){this.actor=L,this.layerIndex=V,this.availableImages=W,this.loadVectorData=ee||$,this.loading={},this.loaded={}}loadTile(L,V){const W=L.uid;this.loading||(this.loading={});const ee=!!(L&&L.request&&L.request.collectResourceTiming)&&new l.RequestPerformance(L.request),ce=this.loading[W]=new A(L);ce.abort=this.loadVectorData(L,(pe,ue)=>{if(delete this.loading[W],pe||!ue)return ce.status="done",this.loaded[W]=ce,V(pe);const de=ue.rawData,ye={};ue.expires&&(ye.expires=ue.expires),ue.cacheControl&&(ye.cacheControl=ue.cacheControl);const De={};if(ee){const Fe=ee.finish();Fe&&(De.resourceTiming=JSON.parse(JSON.stringify(Fe)))}ce.vectorTile=ue.vectorTile,ce.parse(ue.vectorTile,this.layerIndex,this.availableImages,this.actor,(Fe,Be)=>{if(Fe||!Be)return V(Fe);V(null,l.extend({rawTileData:de.slice(0)},Be,ye,De))}),this.loaded=this.loaded||{},this.loaded[W]=ce})}reloadTile(L,V){const W=this.loaded,ee=L.uid,ce=this;if(W&&W[ee]){const pe=W[ee];pe.showCollisionBoxes=L.showCollisionBoxes;const ue=(de,ye)=>{const De=pe.reloadCallback;De&&(delete pe.reloadCallback,pe.parse(pe.vectorTile,ce.layerIndex,this.availableImages,ce.actor,De)),V(de,ye)};pe.status==="parsing"?pe.reloadCallback=ue:pe.status==="done"&&(pe.vectorTile?pe.parse(pe.vectorTile,this.layerIndex,this.availableImages,this.actor,ue):ue())}}abortTile(L,V){const W=this.loading,ee=L.uid;W&&W[ee]&&W[ee].abort&&(W[ee].abort(),delete W[ee]),V()}removeTile(L,V){const W=this.loaded,ee=L.uid;W&&W[ee]&&delete W[ee],V()}}class se{constructor(){this.loaded={}}loadTile(L,V){const{uid:W,encoding:ee,rawImageData:ce}=L,pe=l.isImageBitmap(ce)?this.getImageData(ce):ce,ue=new l.DEMData(W,pe,ee);this.loaded=this.loaded||{},this.loaded[W]=ue,V(null,ue)}getImageData(L){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(L.width,L.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=L.width,this.offscreenCanvas.height=L.height,this.offscreenCanvasContext.drawImage(L,0,0,L.width,L.height);const V=this.offscreenCanvasContext.getImageData(-1,-1,L.width+2,L.height+2);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new l.RGBAImage({width:V.width,height:V.height},V.data)}removeTile(L){const V=this.loaded,W=L.uid;V&&V[W]&&delete V[W]}}var ze=function Q(L,V){var W,ee=L&&L.type;if(ee==="FeatureCollection")for(W=0;W=Math.abs(ue)?V-de+ue:ue-de+V,V=de}V+W>=0!=!!L&&Q.reverse()}const yt=l.vectorTile.VectorTileFeature.prototype.toGeoJSON;class lt{constructor(L){this._feature=L,this.extent=l.EXTENT,this.type=L.type,this.properties=L.tags,"id"in L&&!isNaN(L.id)&&(this.id=parseInt(L.id,10))}loadGeometry(){if(this._feature.type===1){const L=[];for(const V of this._feature.geometry)L.push([new l.pointGeometry(V[0],V[1])]);return L}{const L=[];for(const V of this._feature.geometry){const W=[];for(const ee of V)W.push(new l.pointGeometry(ee[0],ee[1]));L.push(W)}return L}}toGeoJSON(L,V,W){return yt.call(this,L,V,W)}}class tt{constructor(L){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=l.EXTENT,this.length=L.length,this._features=L}feature(L){return new lt(this._features[L])}}var Vt={exports:{}},nt=l.pointGeometry,_a=l.vectorTile.VectorTileFeature,It=wt;function wt(Q,L){this.options=L||{},this.features=Q,this.length=Q.length}function Tt(Q,L){this.id=typeof Q.id=="number"?Q.id:void 0,this.type=Q.type,this.rawGeometry=Q.type===1?[Q.geometry]:Q.geometry,this.properties=Q.tags,this.extent=L||4096}wt.prototype.feature=function(Q){return new Tt(this.features[Q],this.options.extent)},Tt.prototype.loadGeometry=function(){var Q=this.rawGeometry;this.geometry=[];for(var L=0;L>31}function $a(Q,L){for(var V=Q.loadGeometry(),W=Q.type,ee=0,ce=0,pe=V.length,ue=0;ue>1;ut(Q,L,pe,W,ee,ce%2),ri(Q,L,V,W,pe-1,ce+1),ri(Q,L,V,pe+1,ee,ce+1)}function ut(Q,L,V,W,ee,ce){for(;ee>W;){if(ee-W>600){const ye=ee-W+1,De=V-W+1,Fe=Math.log(ye),Be=.5*Math.exp(2*Fe/3),rt=.5*Math.sqrt(Fe*Be*(ye-Be)/ye)*(De-ye/2<0?-1:1);ut(Q,L,V,Math.max(W,Math.floor(V-De*Be/ye+rt)),Math.min(ee,Math.floor(V+(ye-De)*Be/ye+rt)),ce)}const pe=L[2*V+ce];let ue=W,de=ee;for(sa(Q,L,W,V),L[2*ee+ce]>pe&&sa(Q,L,W,ee);uepe;)de--}L[2*W+ce]===pe?sa(Q,L,W,de):(de++,sa(Q,L,de,ee)),de<=V&&(W=de+1),V<=de&&(ee=de-1)}}function sa(Q,L,V,W){Nt(Q,V,W),Nt(L,2*V,2*W),Nt(L,2*V+1,2*W+1)}function Nt(Q,L,V){const W=Q[L];Q[L]=Q[V],Q[V]=W}function Zt(Q,L,V,W){const ee=Q-V,ce=L-W;return ee*ee+ce*ce}Vt.exports=na,Vt.exports.fromVectorTileJs=na,Vt.exports.fromGeojsonVt=function(Q,L){L=L||{};var V={};for(var W in Q)V[W]=new za(Q[W].features,L),V[W].name=W,V[W].version=L.version,V[W].extent=L.extent;return na({layers:V})},Vt.exports.GeoJSONWrapper=za;const Xt=Q=>Q[0],Vi=Q=>Q[1];class es{constructor(L,V=Xt,W=Vi,ee=64,ce=Float64Array){this.nodeSize=ee,this.points=L;const pe=L.length<65536?Uint16Array:Uint32Array,ue=this.ids=new pe(L.length),de=this.coords=new ce(2*L.length);for(let ye=0;ye=ue&&xt<=ye&&qt>=de&&qt<=De&&rt.push(ce[ua]);continue}const oa=Math.floor((ga+ea)/2);xt=pe[2*oa],qt=pe[2*oa+1],xt>=ue&&xt<=ye&&qt>=de&&qt<=De&&rt.push(ce[oa]);const ra=(Mt+1)%2;(Mt===0?ue<=xt:de<=qt)&&(Be.push(ga),Be.push(oa-1),Be.push(ra)),(Mt===0?ye>=xt:De>=qt)&&(Be.push(oa+1),Be.push(ea),Be.push(ra))}return rt}(this.ids,this.coords,L,V,W,ee,this.nodeSize)}within(L,V,W){return function(ee,ce,pe,ue,de,ye){const De=[0,ee.length-1,0],Fe=[],Be=de*de;for(;De.length;){const rt=De.pop(),xt=De.pop(),qt=De.pop();if(xt-qt<=ye){for(let ra=qt;ra<=xt;ra++)Zt(ce[2*ra],ce[2*ra+1],pe,ue)<=Be&&Fe.push(ee[ra]);continue}const Mt=Math.floor((qt+xt)/2),ea=ce[2*Mt],ga=ce[2*Mt+1];Zt(ea,ga,pe,ue)<=Be&&Fe.push(ee[Mt]);const oa=(rt+1)%2;(rt===0?pe-de<=ea:ue-de<=ga)&&(De.push(qt),De.push(Mt-1),De.push(oa)),(rt===0?pe+de>=ea:ue+de>=ga)&&(De.push(Mt+1),De.push(xt),De.push(oa))}return Fe}(this.ids,this.coords,L,V,W,this.nodeSize)}}const ws={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:Q=>Q},Ti=Math.fround||(Jn=new Float32Array(1),Q=>(Jn[0]=+Q,Jn[0]));var Jn;class Ya{constructor(L){this.options=ts(Object.create(ws),L),this.trees=new Array(this.options.maxZoom+1)}load(L){const{log:V,minZoom:W,maxZoom:ee,nodeSize:ce}=this.options;V&&console.time("total time");const pe=`prepare ${L.length} points`;V&&console.time(pe),this.points=L;let ue=[];for(let de=0;de=W;de--){const ye=+Date.now();ue=this._cluster(ue,de),this.trees[de]=new es(ue,Yn,Kn,ce,Float32Array),V&&console.log("z%d: %d clusters in %dms",de,ue.length,+Date.now()-ye)}return V&&console.timeEnd("total time"),this}getClusters(L,V){let W=((L[0]+180)%360+360)%360-180;const ee=Math.max(-90,Math.min(90,L[1]));let ce=L[2]===180?180:((L[2]+180)%360+360)%360-180;const pe=Math.max(-90,Math.min(90,L[3]));if(L[2]-L[0]>=360)W=-180,ce=180;else if(W>ce){const De=this.getClusters([W,ee,180,pe],V),Fe=this.getClusters([-180,ee,ce,pe],V);return De.concat(Fe)}const ue=this.trees[this._limitZoom(V)],de=ue.range(Sa(W),Zn(pe),Sa(ce),Zn(ee)),ye=[];for(const De of de){const Fe=ue.points[De];ye.push(Fe.numPoints?zl(Fe):this.points[Fe.index])}return ye}getChildren(L){const V=this._getOriginId(L),W=this._getOriginZoom(L),ee="No cluster with the specified id.",ce=this.trees[W];if(!ce)throw new Error(ee);const pe=ce.points[V];if(!pe)throw new Error(ee);const ue=this.options.radius/(this.options.extent*Math.pow(2,W-1)),de=ce.within(pe.x,pe.y,ue),ye=[];for(const De of de){const Fe=ce.points[De];Fe.parentId===L&&ye.push(Fe.numPoints?zl(Fe):this.points[Fe.index])}if(ye.length===0)throw new Error(ee);return ye}getLeaves(L,V,W){const ee=[];return this._appendLeaves(ee,L,V=V||10,W=W||0,0),ee}getTile(L,V,W){const ee=this.trees[this._limitZoom(L)],ce=Math.pow(2,L),{extent:pe,radius:ue}=this.options,de=ue/pe,ye=(W-de)/ce,De=(W+1+de)/ce,Fe={features:[]};return this._addTileFeatures(ee.range((V-de)/ce,ye,(V+1+de)/ce,De),ee.points,V,W,ce,Fe),V===0&&this._addTileFeatures(ee.range(1-de/ce,ye,1,De),ee.points,ce,W,ce,Fe),V===ce-1&&this._addTileFeatures(ee.range(0,ye,de/ce,De),ee.points,-1,W,ce,Fe),Fe.features.length?Fe:null}getClusterExpansionZoom(L){let V=this._getOriginZoom(L)-1;for(;V<=this.options.maxZoom;){const W=this.getChildren(L);if(V++,W.length!==1)break;L=W[0].properties.cluster_id}return V}_appendLeaves(L,V,W,ee,ce){const pe=this.getChildren(V);for(const ue of pe){const de=ue.properties;if(de&&de.cluster?ce+de.point_count<=ee?ce+=de.point_count:ce=this._appendLeaves(L,de.cluster_id,W,ee,ce):ceV&&(xt+=Mt.numPoints||1)}if(xt>rt&&xt>=ue){let qt=De.x*rt,Mt=De.y*rt,ea=pe&&rt>1?this._map(De,!0):null;const ga=(ye<<5)+(V+1)+this.points.length;for(const oa of Be){const ra=Fe.points[oa];if(ra.zoom<=V)continue;ra.zoom=V;const ua=ra.numPoints||1;qt+=ra.x*ua,Mt+=ra.y*ua,ra.parentId=ga,pe&&(ea||(ea=this._map(De,!0)),pe(ea,this._map(ra)))}De.parentId=ga,W.push(Or(qt/xt,Mt/xt,ga,xt,ea))}else if(W.push(De),xt>1)for(const qt of Be){const Mt=Fe.points[qt];Mt.zoom<=V||(Mt.zoom=V,W.push(Mt))}}return W}_getOriginId(L){return L-this.points.length>>5}_getOriginZoom(L){return(L-this.points.length)%32}_map(L,V){if(L.numPoints)return V?ts({},L.properties):L.properties;const W=this.points[L.index].properties,ee=this.options.map(W);return V&&ee===W?ts({},ee):ee}}function Or(Q,L,V,W,ee){return{x:Ti(Q),y:Ti(L),zoom:1/0,id:V,parentId:-1,numPoints:W,properties:ee}}function Dn(Q,L){const[V,W]=Q.geometry.coordinates;return{x:Ti(Sa(V)),y:Ti(Zn(W)),zoom:1/0,index:L,parentId:-1}}function zl(Q){return{type:"Feature",id:Q.id,properties:so(Q),geometry:{type:"Point",coordinates:[(L=Q.x,360*(L-.5)),xs(Q.y)]}};var L}function so(Q){const L=Q.numPoints,V=L>=1e4?`${Math.round(L/1e3)}k`:L>=1e3?Math.round(L/100)/10+"k":L;return ts(ts({},Q.properties),{cluster:!0,cluster_id:Q.id,point_count:L,point_count_abbreviated:V})}function Sa(Q){return Q/360+.5}function Zn(Q){const L=Math.sin(Q*Math.PI/180),V=.5-.25*Math.log((1+L)/(1-L))/Math.PI;return V<0?0:V>1?1:V}function xs(Q){const L=(180-360*Q)*Math.PI/180;return 360*Math.atan(Math.exp(L))/Math.PI-90}function ts(Q,L){for(const V in L)Q[V]=L[V];return Q}function Yn(Q){return Q.x}function Kn(Q){return Q.y}function pr(Q,L,V,W){for(var ee,ce=W,pe=V-L>>1,ue=V-L,de=Q[L],ye=Q[L+1],De=Q[V],Fe=Q[V+1],Be=L+3;Bece)ee=Be,ce=rt;else if(rt===ce){var xt=Math.abs(Be-pe);xtW&&(ee-L>3&&pr(Q,L,ee,W),Q[ee+2]=ce,V-ee>3&&pr(Q,ee,V,W))}function Bs(Q,L,V,W,ee,ce){var pe=ee-V,ue=ce-W;if(pe!==0||ue!==0){var de=((Q-V)*pe+(L-W)*ue)/(pe*pe+ue*ue);de>1?(V=ee,W=ce):de>0&&(V+=pe*de,W+=ue*de)}return(pe=Q-V)*pe+(ue=L-W)*ue}function Oe(Q,L,V,W){var ee={id:Q===void 0?null:Q,type:L,geometry:V,tags:W,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(ce){var pe=ce.geometry,ue=ce.type;if(ue==="Point"||ue==="MultiPoint"||ue==="LineString")st(ce,pe);else if(ue==="Polygon"||ue==="MultiLineString")for(var de=0;de0&&(pe+=W?(ee*ye-de*ce)/2:Math.sqrt(Math.pow(de-ee,2)+Math.pow(ye-ce,2))),ee=de,ce=ye}var De=L.length-3;L[2]=1,pr(L,0,De,V),L[De+2]=1,L.size=Math.abs(pe),L.start=0,L.end=L.size}function Mi(Q,L,V,W){for(var ee=0;ee1?1:V}function Bi(Q,L,V,W,ee,ce,pe,ue){if(W/=L,ce>=(V/=L)&&pe=W)return null;for(var de=[],ye=0;ye=V&&xt=W)){var qt=[];if(Be==="Point"||Be==="MultiPoint")ht(Fe,qt,V,W,ee);else if(Be==="LineString")ha(Fe,qt,V,W,ee,!1,ue.lineMetrics);else if(Be==="MultiLineString")Ui(Fe,qt,V,W,ee,!1);else if(Be==="Polygon")Ui(Fe,qt,V,W,ee,!0);else if(Be==="MultiPolygon")for(var Mt=0;Mt=V&&pe<=W&&(L.push(Q[ce]),L.push(Q[ce+1]),L.push(Q[ce+2]))}}function ha(Q,L,V,W,ee,ce,pe){for(var ue,de,ye=Yt(Q),De=ee===0?pa:gr,Fe=Q.start,Be=0;BeV&&(de=De(ye,rt,xt,Mt,ea,V),pe&&(ye.start=Fe+ue*de)):ga>W?oa=V&&(de=De(ye,rt,xt,Mt,ea,V),ra=!0),oa>W&&ga<=W&&(de=De(ye,rt,xt,Mt,ea,W),ra=!0),!ce&&ra&&(pe&&(ye.end=Fe+ue*de),L.push(ye),ye=Yt(Q)),pe&&(Fe+=ue)}var ua=Q.length-3;rt=Q[ua],xt=Q[ua+1],qt=Q[ua+2],(ga=ee===0?rt:xt)>=V&&ga<=W&&qn(ye,rt,xt,qt),ua=ye.length-3,ce&&ua>=3&&(ye[ua]!==ye[0]||ye[ua+1]!==ye[1])&&qn(ye,ye[0],ye[1],ye[2]),ye.length&&L.push(ye)}function Yt(Q){var L=[];return L.size=Q.size,L.start=Q.start,L.end=Q.end,L}function Ui(Q,L,V,W,ee,ce){for(var pe=0;pepe.maxX&&(pe.maxX=De),Fe>pe.maxY&&(pe.maxY=Fe)}return pe}function Ns(Q,L,V,W){var ee=L.geometry,ce=L.type,pe=[];if(ce==="Point"||ce==="MultiPoint")for(var ue=0;ue0&&L.size<(ee?pe:W))V.numPoints+=L.length/3;else{for(var ue=[],de=0;depe)&&(V.numSimplified++,ue.push(L[de]),ue.push(L[de+1])),V.numPoints++;ee&&function(ye,De){for(var Fe=0,Be=0,rt=ye.length,xt=rt-2;Be