@tangram.gl/tangram-renderer 0.0.0 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/core.js +2 -2
- package/dist/tangram.debug.mjs +3 -3
- package/dist/tangram.min.mjs +3 -3
- package/package.json +1 -1
package/dist/tangram.min.mjs
CHANGED
|
@@ -17,7 +17,7 @@ var yg=Object.create;var Fu=Object.defineProperty;var xg=Object.getOwnPropertyDe
|
|
|
17
17
|
`,a):o?t.result+=kt.repeat(`
|
|
18
18
|
`,a+1):t.result+=kt.repeat(`
|
|
19
19
|
`,a),o=!0,a=0,r=t.position;!Ct(c)&&c!==0;)c=t.input.charCodeAt(++t.position);cr(t,r,t.position,!1)}return!0}function qp(t,e){var r,i=t.tag,n=t.anchor,o=[],s,a=!1,l;for(t.anchor!==null&&(t.anchorMap[t.anchor]=o),l=t.input.charCodeAt(t.position);l!==0&&!(l!==45||(s=t.input.charCodeAt(t.position+1),!ut(s)));){if(a=!0,t.position++,We(t,!0,-1)&&t.lineIndent<=e){o.push(null),l=t.input.charCodeAt(t.position);continue}if(r=t.line,Ci(t,e,Xp,!1,!0),o.push(t.result),We(t,!0,-1),l=t.input.charCodeAt(t.position),(t.line===r||t.lineIndent>e)&&l!==0)me(t,"bad indentation of a sequence entry");else if(t.lineIndent<e)break}return a?(t.tag=i,t.anchor=n,t.kind="sequence",t.result=o,!0):!1}function E1(t,e,r){var i,n,o,s=t.tag,a=t.anchor,l={},u={},c=null,h=null,d=null,f=!1,p=!1,m;for(t.anchor!==null&&(t.anchorMap[t.anchor]=l),m=t.input.charCodeAt(t.position);m!==0;){if(i=t.input.charCodeAt(t.position+1),o=t.line,(m===63||m===58)&&ut(i))m===63?(f&&(ki(t,l,u,c,h,null),c=h=d=null),p=!0,f=!0,n=!0):f?(f=!1,n=!0):me(t,"incomplete explicit mapping pair; a key node is missed"),t.position+=1,m=i;else if(Ci(t,r,Zp,!1,!0))if(t.line===o){for(m=t.input.charCodeAt(t.position);jr(m);)m=t.input.charCodeAt(++t.position);if(m===58)m=t.input.charCodeAt(++t.position),ut(m)||me(t,"a whitespace character is expected after the key-value separator within a block mapping"),f&&(ki(t,l,u,c,h,null),c=h=d=null),p=!0,f=!1,n=!1,c=t.tag,h=t.result;else if(p)me(t,"can not read an implicit mapping pair; a colon is missed");else return t.tag=s,t.anchor=a,!0}else if(p)me(t,"can not read a block mapping entry; a multiline key may not be an implicit key");else return t.tag=s,t.anchor=a,!0;else break;if((t.line===o||t.lineIndent>e)&&(Ci(t,e,Es,!0,n)&&(f?h=t.result:d=t.result),f||(ki(t,l,u,c,h,d),c=h=d=null),We(t,!0,-1),m=t.input.charCodeAt(t.position)),t.lineIndent>e&&m!==0)me(t,"bad indentation of a mapping entry");else if(t.lineIndent<e)break}return f&&ki(t,l,u,c,h,null),p&&(t.tag=s,t.anchor=a,t.kind="mapping",t.result=l),p}function M1(t){var e,r=!1,i=!1,n,o,s;if(s=t.input.charCodeAt(t.position),s!==33)return!1;if(t.tag!==null&&me(t,"duplication of a tag property"),s=t.input.charCodeAt(++t.position),s===60?(r=!0,s=t.input.charCodeAt(++t.position)):s===33?(i=!0,n="!!",s=t.input.charCodeAt(++t.position)):n="!",e=t.position,r){do s=t.input.charCodeAt(++t.position);while(s!==0&&s!==62);t.position<t.length?(o=t.input.slice(e,t.position),s=t.input.charCodeAt(++t.position)):me(t,"unexpected end of the stream within a verbatim tag")}else{for(;s!==0&&!ut(s);)s===33&&(i?me(t,"tag suffix cannot contain exclamation marks"):(n=t.input.slice(e-1,t.position+1),Yp.test(n)||me(t,"named tag handle cannot contain such characters"),i=!0,e=t.position+1)),s=t.input.charCodeAt(++t.position);o=t.input.slice(e,t.position),p1.test(o)&&me(t,"tag suffix cannot contain flow indicator characters")}return o&&!Jp.test(o)&&me(t,"tag name cannot contain such characters: "+o),r?t.tag=o:Gr.call(t.tagMap,n)?t.tag=t.tagMap[n]+o:n==="!"?t.tag="!"+o:n==="!!"?t.tag="tag:yaml.org,2002:"+o:me(t,'undeclared tag handle "'+n+'"'),!0}function S1(t){var e,r;if(r=t.input.charCodeAt(t.position),r!==38)return!1;for(t.anchor!==null&&me(t,"duplication of an anchor property"),r=t.input.charCodeAt(++t.position),e=t.position;r!==0&&!ut(r)&&!Li(r);)r=t.input.charCodeAt(++t.position);return t.position===e&&me(t,"name of an anchor node must contain at least one character"),t.anchor=t.input.slice(e,t.position),!0}function R1(t){var e,r,i;if(i=t.input.charCodeAt(t.position),i!==42)return!1;for(i=t.input.charCodeAt(++t.position),e=t.position;i!==0&&!ut(i)&&!Li(i);)i=t.input.charCodeAt(++t.position);return t.position===e&&me(t,"name of an alias node must contain at least one character"),r=t.input.slice(e,t.position),t.anchorMap.hasOwnProperty(r)||me(t,'unidentified alias "'+r+'"'),t.result=t.anchorMap[r],We(t,!0,-1),!0}function Ci(t,e,r,i,n){var o,s,a,l=1,u=!1,c=!1,h,d,f,p,m;if(t.listener!==null&&t.listener("open",t),t.tag=null,t.anchor=null,t.kind=null,t.result=null,o=s=a=Es===r||Xp===r,i&&We(t,!0,-1)&&(u=!0,t.lineIndent>e?l=1:t.lineIndent===e?l=0:t.lineIndent<e&&(l=-1)),l===1)for(;M1(t)||S1(t);)We(t,!0,-1)?(u=!0,a=o,t.lineIndent>e?l=1:t.lineIndent===e?l=0:t.lineIndent<e&&(l=-1)):a=!1;if(a&&(a=u||n),(l===1||Es===r)&&(As===r||Zp===r?p=e:p=e+1,m=t.position-t.lineStart,l===1?a&&(qp(t,m)||E1(t,m,p))||T1(t,p)?c=!0:(s&&A1(t,p)||v1(t,p)||w1(t,p)?c=!0:R1(t)?(c=!0,(t.tag!==null||t.anchor!==null)&&me(t,"alias node should not have any properties")):x1(t,p,As===r)&&(c=!0,t.tag===null&&(t.tag="?")),t.anchor!==null&&(t.anchorMap[t.anchor]=t.result)):l===0&&(c=a&&qp(t,m))),t.tag!==null&&t.tag!=="!")if(t.tag==="?"){for(h=0,d=t.implicitTypes.length;h<d;h+=1)if(f=t.implicitTypes[h],f.resolve(t.result)){t.result=f.construct(t.result),t.tag=f.tag,t.anchor!==null&&(t.anchorMap[t.anchor]=t.result);break}}else Gr.call(t.typeMap,t.tag)?(f=t.typeMap[t.tag],t.result!==null&&f.kind!==t.kind&&me(t,"unacceptable node kind for !<"+t.tag+'> tag; it should be "'+f.kind+'", not "'+t.kind+'"'),f.resolve(t.result)?(t.result=f.construct(t.result),t.anchor!==null&&(t.anchorMap[t.anchor]=t.result)):me(t,"cannot resolve a node with !<"+t.tag+"> explicit tag")):me(t,"unknown tag !<"+t.tag+">");return t.listener!==null&&t.listener("close",t),t.tag!==null||t.anchor!==null||c}function P1(t){var e=t.position,r,i,n,o=!1,s;for(t.version=null,t.checkLineBreaks=t.legacy,t.tagMap={},t.anchorMap={};(s=t.input.charCodeAt(t.position))!==0&&(We(t,!0,-1),s=t.input.charCodeAt(t.position),!(t.lineIndent>0||s!==37));){for(o=!0,s=t.input.charCodeAt(++t.position),r=t.position;s!==0&&!ut(s);)s=t.input.charCodeAt(++t.position);for(i=t.input.slice(r,t.position),n=[],i.length<1&&me(t,"directive name must not be less than one character in length");s!==0;){for(;jr(s);)s=t.input.charCodeAt(++t.position);if(s===35){do s=t.input.charCodeAt(++t.position);while(s!==0&&!Ct(s));break}if(Ct(s))break;for(r=t.position;s!==0&&!ut(s);)s=t.input.charCodeAt(++t.position);n.push(t.input.slice(r,t.position))}s!==0&&ql(t),Gr.call(Vp,i)?Vp[i](t,i,n):Ms(t,'unknown document directive "'+i+'"')}if(We(t,!0,-1),t.lineIndent===0&&t.input.charCodeAt(t.position)===45&&t.input.charCodeAt(t.position+1)===45&&t.input.charCodeAt(t.position+2)===45?(t.position+=3,We(t,!0,-1)):o&&me(t,"directives end mark is expected"),Ci(t,t.lineIndent-1,Es,!1,!0),We(t,!0,-1),t.checkLineBreaks&&f1.test(t.input.slice(e,t.position))&&Ms(t,"non-ASCII line breaks are interpreted as content"),t.documents.push(t.result),t.position===t.lineStart&&Ss(t)){t.input.charCodeAt(t.position)===46&&(t.position+=3,We(t,!0,-1));return}if(t.position<t.length-1)me(t,"end of the stream or a document separator is expected");else return}function tm(t,e){t=String(t),e=e||{},t.length!==0&&(t.charCodeAt(t.length-1)!==10&&t.charCodeAt(t.length-1)!==13&&(t+=`
|
|
20
|
-
`),t.charCodeAt(0)===65279&&(t=t.slice(1)));var r=new y1(t,e);for(r.input+="\0";r.input.charCodeAt(r.position)===32;)r.lineIndent+=1,r.position+=1;for(;r.position<r.length-1;)P1(r);return r.documents}function rm(t,e,r){var i=tm(t,r),n,o;for(n=0,o=i.length;n<o;n+=1)e(i[n])}function im(t,e){var r=tm(t,e);if(r.length!==0){if(r.length===1)return r[0];throw new Wp("expected a single document in the stream, but found more")}}function L1(t,e,r){rm(t,e,kt.extend({schema:Hp},r))}function k1(t,e){return im(t,kt.extend({schema:Hp},e))}Mn.exports.loadAll=rm;Mn.exports.load=im;Mn.exports.safeLoadAll=L1;Mn.exports.safeLoad=k1});var om=_e((E3,He)=>{"use strict";var Rs=nm();function Ps(t){return function(){throw new Error("Function "+t+" is deprecated and cannot be used.")}}He.exports.Type=Ye();He.exports.Schema=Ir();He.exports.FAILSAFE_SCHEMA=xs();He.exports.JSON_SCHEMA=Gl();He.exports.CORE_SCHEMA=Ul();He.exports.DEFAULT_SAFE_SCHEMA=En();He.exports.DEFAULT_FULL_SCHEMA=Ts();He.exports.load=Rs.load;He.exports.loadAll=Rs.loadAll;He.exports.safeLoad=Rs.safeLoad;He.exports.safeLoadAll=Rs.safeLoadAll;He.exports.YAMLException=An();He.exports.MINIMAL_SCHEMA=xs();He.exports.SAFE_SCHEMA=En();He.exports.DEFAULT_SCHEMA=Ts();He.exports.scan=Ps("scan");He.exports.parse=Ps("parse");He.exports.compose=Ps("compose");He.exports.addConstructor=Ps("addConstructor")});var Hl=_e((M3,sm)=>{"use strict";var C1=om();sm.exports=C1});var Em=_e(au=>{au.read=function(t,e,r,i,n){var o,s,a=n*8-i-1,l=(1<<a)-1,u=l>>1,c=-7,h=r?n-1:0,d=r?-1:1,f=t[e+h];for(h+=d,o=f&(1<<-c)-1,f>>=-c,c+=a;c>0;o=o*256+t[e+h],h+=d,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=i;c>0;s=s*256+t[e+h],h+=d,c-=8);if(o===0)o=1-u;else{if(o===l)return s?NaN:(f?-1:1)*(1/0);s=s+Math.pow(2,i),o=o-u}return(f?-1:1)*s*Math.pow(2,o-i)};au.write=function(t,e,r,i,n,o){var s,a,l,u=o*8-n-1,c=(1<<u)-1,h=c>>1,d=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,f=i?0:o-1,p=i?1:-1,m=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-s))<1&&(s--,l*=2),s+h>=1?e+=d/l:e+=d*Math.pow(2,1-h),e*l>=2&&(s++,l/=2),s+h>=c?(a=0,s=c):s+h>=1?(a=(e*l-1)*Math.pow(2,n),s=s+h):(a=e*Math.pow(2,h-1)*Math.pow(2,n),s=0));n>=8;t[r+f]=a&255,f+=p,a/=256,n-=8);for(s=s<<n|a,u+=n;u>0;t[r+f]=s&255,f+=p,s/=256,u-=8);t[r+f-p]|=m*128}});var Lm=_e((QC,Pm)=>{"use strict";Pm.exports=Ge;var Fs=Em();function Ge(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}Ge.Varint=0;Ge.Fixed64=1;Ge.Bytes=2;Ge.Fixed32=5;var lu=65536*65536,Mm=1/lu;Ge.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos<r;){var i=this.readVarint(),n=i>>3,o=this.pos;this.type=i&7,t(n,e,this),this.pos===o&&this.skip(i)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Bs(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Rm(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Bs(this.buf,this.pos)+Bs(this.buf,this.pos+4)*lu;return this.pos+=8,t},readSFixed64:function(){var t=Bs(this.buf,this.pos)+Rm(this.buf,this.pos+4)*lu;return this.pos+=8,t},readFloat:function(){var t=Fs.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=Fs.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e=this.buf,r,i;return i=e[this.pos++],r=i&127,i<128||(i=e[this.pos++],r|=(i&127)<<7,i<128)||(i=e[this.pos++],r|=(i&127)<<14,i<128)||(i=e[this.pos++],r|=(i&127)<<21,i<128)?r:(i=e[this.pos],r|=(i&15)<<28,fv(r,t,this))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2===1?(t+1)/-2:t/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var t=this.readVarint()+this.pos,e=Mv(this.buf,this.pos,t);return this.pos=t,e},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){var r=$t(this);for(t=t||[];this.pos<r;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){var e=$t(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){var e=$t(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){var e=$t(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){var e=$t(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){var e=$t(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){var e=$t(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){var e=$t(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){var e=$t(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=t&7;if(e===Ge.Varint)for(;this.buf[this.pos++]>127;);else if(e===Ge.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Ge.Fixed32)this.pos+=4;else if(e===Ge.Fixed64)this.pos+=8;else throw new Error("Unimplemented type: "+e)},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var r=new Uint8Array(e);r.set(this.buf),this.buf=r,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),Oi(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),Oi(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),Oi(this.buf,t&-1,this.pos),Oi(this.buf,Math.floor(t*Mm),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),Oi(this.buf,t&-1,this.pos),Oi(this.buf,Math.floor(t*Mm),this.pos+4),this.pos+=8},writeVarint:function(t){if(t=+t||0,t>268435455||t<0){pv(t,this);return}this.realloc(4),this.buf[this.pos++]=t&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=t>>>7&127)))},writeSVarint:function(t){this.writeVarint(t<0?-t*2-1:t*2)},writeBoolean:function(t){this.writeVarint(!!t)},writeString:function(t){t=String(t),this.realloc(t.length*4),this.pos++;var e=this.pos;this.pos=Sv(this.buf,t,this.pos);var r=this.pos-e;r>=128&&Sm(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),Fs.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),Fs.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r<e;r++)this.buf[this.pos++]=t[r]},writeRawMessage:function(t,e){this.pos++;var r=this.pos;t(e,this);var i=this.pos-r;i>=128&&Sm(r,i,this),this.pos=r-1,this.writeVarint(i),this.pos+=i},writeMessage:function(t,e,r){this.writeTag(t,Ge.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){this.writeMessage(t,_v,e)},writePackedSVarint:function(t,e){this.writeMessage(t,bv,e)},writePackedBoolean:function(t,e){this.writeMessage(t,vv,e)},writePackedFloat:function(t,e){this.writeMessage(t,yv,e)},writePackedDouble:function(t,e){this.writeMessage(t,xv,e)},writePackedFixed32:function(t,e){this.writeMessage(t,wv,e)},writePackedSFixed32:function(t,e){this.writeMessage(t,Tv,e)},writePackedFixed64:function(t,e){this.writeMessage(t,Av,e)},writePackedSFixed64:function(t,e){this.writeMessage(t,Ev,e)},writeBytesField:function(t,e){this.writeTag(t,Ge.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,Ge.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,Ge.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,Ge.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,Ge.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,Ge.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,Ge.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,Ge.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,Ge.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,Ge.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,!!e)}};function fv(t,e,r){var i=r.buf,n,o;if(o=i[r.pos++],n=(o&112)>>4,o<128||(o=i[r.pos++],n|=(o&127)<<3,o<128)||(o=i[r.pos++],n|=(o&127)<<10,o<128)||(o=i[r.pos++],n|=(o&127)<<17,o<128)||(o=i[r.pos++],n|=(o&127)<<24,o<128)||(o=i[r.pos++],n|=(o&1)<<31,o<128))return zi(t,n,e);throw new Error("Expected varint not more than 10 bytes")}function $t(t){return t.type===Ge.Bytes?t.readVarint()+t.pos:t.pos+1}function zi(t,e,r){return r?e*4294967296+(t>>>0):(e>>>0)*4294967296+(t>>>0)}function pv(t,e){var r,i;if(t>=0?(r=t%4294967296|0,i=t/4294967296|0):(r=~(-t%4294967296),i=~(-t/4294967296),r^4294967295?r=r+1|0:(r=0,i=i+1|0)),t>=18446744073709552e3||t<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),mv(r,i,e),gv(i,e)}function mv(t,e,r){r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos]=t&127}function gv(t,e){var r=(t&7)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127)))))}function Sm(t,e,r){var i=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.ceil(Math.log(e)/(Math.LN2*7));r.realloc(i);for(var n=r.pos-1;n>=t;n--)r.buf[n+i]=r.buf[n]}function _v(t,e){for(var r=0;r<t.length;r++)e.writeVarint(t[r])}function bv(t,e){for(var r=0;r<t.length;r++)e.writeSVarint(t[r])}function yv(t,e){for(var r=0;r<t.length;r++)e.writeFloat(t[r])}function xv(t,e){for(var r=0;r<t.length;r++)e.writeDouble(t[r])}function vv(t,e){for(var r=0;r<t.length;r++)e.writeBoolean(t[r])}function wv(t,e){for(var r=0;r<t.length;r++)e.writeFixed32(t[r])}function Tv(t,e){for(var r=0;r<t.length;r++)e.writeSFixed32(t[r])}function Av(t,e){for(var r=0;r<t.length;r++)e.writeFixed64(t[r])}function Ev(t,e){for(var r=0;r<t.length;r++)e.writeSFixed64(t[r])}function Bs(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+t[e+3]*16777216}function Oi(t,e,r){t[r]=e,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function Rm(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function Mv(t,e,r){for(var i="",n=e;n<r;){var o=t[n],s=null,a=o>239?4:o>223?3:o>191?2:1;if(n+a>r)break;var l,u,c;a===1?o<128&&(s=o):a===2?(l=t[n+1],(l&192)===128&&(s=(o&31)<<6|l&63,s<=127&&(s=null))):a===3?(l=t[n+1],u=t[n+2],(l&192)===128&&(u&192)===128&&(s=(o&15)<<12|(l&63)<<6|u&63,(s<=2047||s>=55296&&s<=57343)&&(s=null))):a===4&&(l=t[n+1],u=t[n+2],c=t[n+3],(l&192)===128&&(u&192)===128&&(c&192)===128&&(s=(o&15)<<18|(l&63)<<12|(u&63)<<6|c&63,(s<=65535||s>=1114112)&&(s=null))),s===null?(s=65533,a=1):s>65535&&(s-=65536,i+=String.fromCharCode(s>>>10&1023|55296),s=56320|s&1023),i+=String.fromCharCode(s),n+=a}return i}function Sv(t,e,r){for(var i=0,n,o;i<e.length;i++){if(n=e.charCodeAt(i),n>55295&&n<57344)if(o)if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,o=n;continue}else n=o-55296<<10|n-56320|65536,o=null;else{n>56319||i+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):o=n;continue}else o&&(t[r++]=239,t[r++]=191,t[r++]=189,o=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=n&63|128)}return r}});var Cm=_e((ez,km)=>{"use strict";km.exports=Ni;function Ni(t,e){this.x=t,this.y=e}Ni.prototype={clone:function(){return new Ni(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[0]*this.x+t[1]*this.y,r=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=r,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),i=e*this.x-r*this.y,n=r*this.x+e*this.y;return this.x=i,this.y=n,this},_rotateAround:function(t,e){var r=Math.cos(t),i=Math.sin(t),n=e.x+r*(this.x-e.x)-i*(this.y-e.y),o=e.y+i*(this.x-e.x)+r*(this.y-e.y);return this.x=n,this.y=o,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}};Ni.convert=function(t){return t instanceof Ni?t:Array.isArray(t)?new Ni(t[0],t[1]):t}});var uu=_e((tz,zm)=>{"use strict";var Rv=Cm();zm.exports=Fi;function Fi(t,e,r,i,n){this.properties={},this.extent=r,this.type=0,this._pbf=t,this._geometry=-1,this._keys=i,this._values=n,t.readFields(Pv,this,e)}function Pv(t,e,r){t==1?e.id=r.readVarint():t==2?Lv(r,e):t==3?e.type=r.readVarint():t==4&&(e._geometry=r.pos)}function Lv(t,e){for(var r=t.readVarint()+t.pos;t.pos<r;){var i=e._keys[t.readVarint()],n=e._values[t.readVarint()];e.properties[i]=n}}Fi.types=["Unknown","Point","LineString","Polygon"];Fi.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,i=0,n=0,o=0,s=[],a;t.pos<e;){if(!i){var l=t.readVarint();r=l&7,i=l>>3}if(i--,r===1||r===2)n+=t.readSVarint(),o+=t.readSVarint(),r===1&&(a&&s.push(a),a=[]),a.push(new Rv(n,o));else if(r===7)a&&a.push(a[0].clone());else throw new Error("unknown command "+r)}return a&&s.push(a),s};Fi.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,i=0,n=0,o=0,s=1/0,a=-1/0,l=1/0,u=-1/0;t.pos<e;){if(!i){var c=t.readVarint();r=c&7,i=c>>3}if(i--,r===1||r===2)n+=t.readSVarint(),o+=t.readSVarint(),n<s&&(s=n),n>a&&(a=n),o<l&&(l=o),o>u&&(u=o);else if(r!==7)throw new Error("unknown command "+r)}return[s,l,a,u]};Fi.prototype.toGeoJSON=function(t,e,r){var i=this.extent*Math.pow(2,r),n=this.extent*t,o=this.extent*e,s=this.loadGeometry(),a=Fi.types[this.type],l,u;function c(f){for(var p=0;p<f.length;p++){var m=f[p],g=180-(m.y+o)*360/i;f[p]=[(m.x+n)*360/i-180,360/Math.PI*Math.atan(Math.exp(g*Math.PI/180))-90]}}switch(this.type){case 1:var h=[];for(l=0;l<s.length;l++)h[l]=s[l][0];s=h,c(s);break;case 2:for(l=0;l<s.length;l++)c(s[l]);break;case 3:for(s=kv(s),l=0;l<s.length;l++)for(u=0;u<s[l].length;u++)c(s[l][u]);break}s.length===1?s=s[0]:a="Multi"+a;var d={type:"Feature",geometry:{type:a,coordinates:s},properties:this.properties};return"id"in this&&(d.id=this.id),d};function kv(t){var e=t.length;if(e<=1)return[t];for(var r=[],i,n,o=0;o<e;o++){var s=Cv(t[o]);s!==0&&(n===void 0&&(n=s<0),n===s<0?(i&&r.push(i),i=[t[o]]):i.push(t[o]))}return i&&r.push(i),r}function Cv(t){for(var e=0,r=0,i=t.length,n=i-1,o,s;r<i;n=r++)o=t[r],s=t[n],e+=(s.x-o.x)*(o.y+s.y);return e}});var cu=_e((rz,Nm)=>{"use strict";var zv=uu();Nm.exports=Om;function Om(t,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(Ov,this,e),this.length=this._features.length}function Ov(t,e,r){t===15?e.version=r.readVarint():t===1?e.name=r.readString():t===5?e.extent=r.readVarint():t===2?e._features.push(r.pos):t===3?e._keys.push(r.readString()):t===4&&e._values.push(Nv(r))}function Nv(t){for(var e=null,r=t.readVarint()+t.pos;t.pos<r;){var i=t.readVarint()>>3;e=i===1?t.readString():i===2?t.readFloat():i===3?t.readDouble():i===4?t.readVarint64():i===5?t.readVarint():i===6?t.readSVarint():i===7?t.readBoolean():null}return e}Om.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new zv(this._pbf,e,this.extent,this._keys,this._values)}});var Bm=_e((iz,Fm)=>{"use strict";var Fv=cu();Fm.exports=Bv;function Bv(t,e){this.layers=t.readFields(Iv,{},e)}function Iv(t,e,r){if(t===3){var i=new Fv(r,r.readVarint()+r.pos);i.length&&(e[i.name]=i)}}});var Im=_e((nz,Is)=>{Is.exports.VectorTile=Bm();Is.exports.VectorTileFeature=uu();Is.exports.VectorTileLayer=cu()});var Bu="0.0.0";var Zi="v"+Bu;var Mg=typeof window<"u"&&typeof Window<"u"&&typeof HTMLDocument<"u"&&window instanceof Window&&window.document instanceof HTMLDocument,Iu=typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope,Sg={is_worker:Iu,is_main:Mg};if(Iu){let t={document:{}};Reflect.set(globalThis,"window",t),Reflect.set(globalThis,"document",t.document)}var Qe=Sg;var De={},ce=De,pr=0,wt={};De.targets={};De.addTarget=function(t,e){De.targets[t]=e};De.removeTarget=function(t){t&&delete De.targets[t]};function Du(t){var e=[];typeof t=="string"&&(e=t.split("."),t=e.pop());var r=De.targets;for(let i=0;i<e.length;i++)if(r[e[i]])r=r[e[i]];else return[];return[t,r]}function Rg(){De.postMessage=function(t,e,...r){if(Array.isArray(t))return Promise.all(t.map(a=>De.postMessage(a,e,...r)));let i={};typeof e=="object"&&(i=e,e=e.method);var n=new Promise((a,l)=>{wt[pr]={method:e,message:r,resolve:a,reject:l}});let o,s=[];return r&&r.length===1&&r[0]instanceof De.withTransferables&&(s=r[0].transferables,r=r[0].value),o={type:"main_send",message_id:pr,method:e,message:r},i.stringify&&(o=JSON.stringify(o)),t.postMessage(o,s.map(a=>a.object)),Wr(s),s.length>0&&D("trace",`'${e}' transferred ${s.length} objects to worker thread`),pr++,n},De.addWorker=function(t){if(!(t instanceof Worker))throw Error("Worker broker could not add non-Worker object",t);t.addEventListener("message",function(r){let i=typeof r.data=="string"?JSON.parse(r.data):r.data,n=i.message_id;if(i.type==="worker_reply")wt[n]&&(i.error?wt[n].reject(i.error):wt[n].resolve(i.message),delete wt[n]);else if(i.type==="worker_send"&&n!=null){let o,s,a,l,u;try{if([l,a]=Du(i.method),!a)throw Error(`Worker broker could not dispatch message type ${i.method} on target ${i.target} because no object with that name is registered on main thread`);if(u=typeof a[l]=="function"&&a[l],!u)throw Error(`Worker broker could not dispatch message type ${i.method} on target ${i.target} because object has no method with that name`);o=u.apply(a,i.message)}catch(d){s=d}let c,h=[];o instanceof Promise?o.then(d=>{d instanceof De.withTransferables&&(h=d.transferables,d=d.value[0]),c={type:"main_reply",message_id:n,message:d},t.postMessage(c,h.map(f=>f.object)),Wr(h),h.length>0&&D("trace",`'${l}' transferred ${h.length} objects to worker thread`)},d=>{t.postMessage({type:"main_reply",message_id:n,error:d instanceof Error?`${d.message}: ${d.stack}`:d})}):(o instanceof De.withTransferables&&(h=o.transferables,o=o.value[0]),c={type:"main_reply",message_id:n,message:o,error:s instanceof Error?`${s.message}: ${s.stack}`:s},t.postMessage(c,h.map(d=>d.object)),Wr(h),h.length>0&&D("trace",`'${l}' transferred ${h.length} objects to worker thread`))}})},De.getMessages=function(){return wt},De.getMessageId=function(){return pr}}function Pg(){De.postMessage=function(t,...e){let r={};typeof t=="object"&&(r=t,t=t.method);var i=new Promise((s,a)=>{wt[pr]={method:t,message:e,resolve:s,reject:a}});let n,o=[];return e&&e.length===1&&e[0]instanceof De.withTransferables&&(o=e[0].transferables,e=e[0].value),n={type:"worker_send",message_id:pr,method:t,message:e},r.stringify&&(n=JSON.stringify(n)),self.postMessage(n,o.map(s=>s.object)),Wr(o),o.length>0&&D("trace",`'${t}' transferred ${o.length} objects to main thread`),pr++,i},self.addEventListener("message",function(e){let r=typeof e.data=="string"?JSON.parse(e.data):e.data,i=r.message_id;if(r.type==="main_reply")wt[i]&&(r.error?wt[i].reject(r.error):wt[i].resolve(r.message),delete wt[i]);else if(r.type==="main_send"&&i!=null){let n,o,s,a,l;try{if([a,s]=Du(r.method),!s)throw Error(`Worker broker could not dispatch message type ${r.method} on target ${r.target} because no object with that name is registered on main thread`);if(l=typeof s[a]=="function"&&s[a],!l)throw Error(`Worker broker could not dispatch message type ${r.method} because worker has no method with that name`);n=l.apply(s,r.message)}catch(h){o=h}let u,c=[];n instanceof Promise?n.then(h=>{h instanceof De.withTransferables&&(c=h.transferables,h=h.value[0]),u={type:"worker_reply",message_id:i,message:h},self.postMessage(u,c.map(d=>d.object)),Wr(c),c.length>0&&D("trace",`'${a}' transferred ${c.length} objects to main thread`)},h=>{self.postMessage({type:"worker_reply",message_id:i,error:h instanceof Error?`${h.message}: ${h.stack}`:h})}):(n instanceof De.withTransferables&&(c=n.transferables,n=n.value[0]),u={type:"worker_reply",message_id:i,message:n,error:o instanceof Error?`${o.message}: ${o.stack}`:o},self.postMessage(u,c.map(h=>h.object)),Wr(c),c.length>0&&D("trace",`'${a}' transferred ${c.length} objects to main thread`))}})}De.withTransferables=function(...t){if(!(this instanceof De.withTransferables))return new De.withTransferables(...t);this.value=t,this.transferables=na(this.value)};function na(t,e=null,r=null,i=[]){if(!t)return i;if(Array.isArray(t))t.forEach((n,o)=>na(n,t,o,i));else if(typeof t=="object")if(t instanceof ArrayBuffer)i.push({object:t,parent:e,property:r});else if(t.buffer instanceof ArrayBuffer)i.push({object:t.buffer,parent:e,property:r});else for(let n in t)na(t[n],t,n,i);return i}function Wr(t){Array.isArray(t)&&t.filter(e=>e.parent&&e.property).forEach(e=>delete e.parent[e.property])}Qe.is_main&&Rg();Qe.is_worker&&Pg();var Gu=ce,ju={silent:-1,error:0,warn:1,info:2,debug:3,trace:4},oa={},sa={};function Lg(t){if(!oa[t]){let e=console;oa[t]=(e[t]||console.log).bind(console)}return oa[t]}var ft=(async(t,...e)=>{let r=typeof t=="object"?t.level:t;if(ju[r]>ju[ft.level])return!1;if(Qe.is_worker)return Gu.postMessage({method:"_logProxy",stringify:!0},t,...e);if(typeof t=="object"&&t.once===!0){let n=JSON.stringify(e);if(sa[n])return!1;sa[n]=!0}let i=Lg(r);return e.length>1?i(`Tangram ${Zi} [${r}]: ${e[0]}`,...e.slice(1)):i(`Tangram ${Zi} [${r}]: ${e[0]}`),!0});ft.level="info";ft.workers=null;ft.setLevel=t=>{ft.level=t,Qe.is_main&&Array.isArray(ft.workers)&&Gu.postMessage(ft.workers,"_logSetLevelProxy",t)};Qe.is_worker||(ft.setWorkers=t=>{ft.workers=t},ft.reset=()=>{sa={}});ce.addTarget("_logProxy",ft);ce.addTarget("_logSetLevelProxy",ft.setLevel);var D=ft;var Se={},de=Se;ce.addTarget("Utils",Se);Se.isSafari=function(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)};Se.isMicrosoft=function(){return/(Trident\/7.0|Edge[ /](\d+[.\d]+))/i.test(navigator.userAgent)};Se._requests={};Se._proxy_requests={};Se.io=function(t,e=6e4,r="text",i="GET",n={},o=null,s=!1){if(Qe.is_worker&&Se.isMicrosoft())return D("debug","Proxying request for URL to worker",t),o&&(Se._proxy_requests[o]=!0),ce.postMessage("Utils.io",t,e,r,i,n,o,!0);{let a=new XMLHttpRequest,l=new Promise((u,c)=>{if(a.open(i,t,!0),a.timeout=e,a.responseType=r,n&&typeof n=="object")for(let h in n)a.setRequestHeader(h,n[h]);a.onload=()=>{a.status===200?["text","json"].indexOf(a.responseType)>-1?u({body:a.responseText,status:a.status}):u({body:a.response,status:a.status}):a.status===204?u({body:null,status:a.status}):c(Error("Request error with a status of "+a.statusText))},a.onerror=h=>{c(Error("There was a network error"+h.toString()))},a.ontimeout=h=>{c(Error("timeout "+h.toString()))},a.send()});return l=l.then(u=>(o&&delete Se._requests[o],s?ce.withTransferables(u):u)),o&&(Se._requests[o]=a),l}};Se.cancelRequest=function(t){if(Qe.is_worker&&Se._proxy_requests[t])return ce.postMessage("Utils.cancelRequest",t);Se._requests[t]?(D("trace",`Cancelling network request key '${t}'`),Se._requests[t].abort(),delete Se._requests[t]):D("trace",`Could not find network request key '${t}'`)};Se.serializeWithFunctions=function(t){return typeof t=="function"?t.toString():JSON.stringify(t,function(r,i){return typeof i=="function"?i.toString():i})};Se.use_high_density_display=!0;Se.updateDevicePixelRatio=function(){let t=Se.device_pixel_ratio;return Se.device_pixel_ratio=Se.use_high_density_display&&window.devicePixelRatio||1,Se.device_pixel_ratio!==t};Qe.is_main&&Se.updateDevicePixelRatio();Se.isPowerOf2=function(t){return(t&t-1)===0};Se.interpolate=function(t,e,r){if(!Array.isArray(e)||!Array.isArray(e[0]))return e;if(e.length<1)return e;let i,n,o,s,a,l,u=e;if(t<=u[0][0])s=u[0][1],typeof r=="function"&&(s=r(s));else if(t>=u[u.length-1][0])s=u[u.length-1][1],typeof r=="function"&&(s=r(s));else for(let c=0;c<u.length-1;c++)if(t>=u[c][0]&&t<u[c+1][0]){i=u[c][0],n=u[c+1][0];let h=u[c][1],d=u[c+1][1];if(Array.isArray(h)&&Array.isArray(d)){s=[];for(let f=0;f<h.length;f++)typeof r=="function"?(a=r(h[f]),l=r(d[f]),o=l-a,s[f]=o*(t-i)/(n-i)+a):(o=d[f]-h[f],s[f]=o*(t-i)/(n-i)+h[f])}else typeof r=="function"?(a=r(h),l=r(d),o=l-a,s=o*(t-i)/(n-i)+a):(o=d-h,s=o*(t-i)/(n-i)+h);break}return s};Se.toCSSColor=function(t){if(t!=null)return t[3]===1?`rgb(${t.slice(0,3).map(e=>Math.round(e*255)).join(", ")})`:`rgba(${t.map((e,r)=>r<3&&Math.round(e*255)||e).join(", ")})`};var kg={draw_label_collision_boxes:!1,draw_label_texture_boxes:!1,suppress_label_fade_in:!1,suppress_label_snap_animation:!1,show_hidden_labels:!1,layer_stats:!1,wireframe:!1},Ze=kg;function Wn(t,e){if(!t||!Ht(t))return t;var r=t[0]!=="/",i;if(e?(i=document.createElement("a"),i.href=e):i=window.location,r)t=mr(i.href)+t;else{let n=i.origin;n||(n=i.protocol+"//"+i.host),t=n+t}return t}function mr(t){if(typeof t=="string"&&t.search(/^(data|blob):/)===-1){let e=t.indexOf("?");e>-1&&(t=t.substr(0,e));let r=t.indexOf("#");return r>-1&&(t=t.substr(0,r)),t.substr(0,t.lastIndexOf("/")+1)||""}return""}function Xi(t){let e=t.split("/").pop()||"",r=e.lastIndexOf(".");if(r>-1)return e.substring(r+1)}function Uu(t){return typeof t!="string"?!1:t.search(/^(data|blob):/)>-1}function Ht(t){return typeof t!="string"?!1:!(t.search(/^(http|https|data|blob):/)>-1||t.substr(0,2)==="//")}function Vu(t){let e=(t||"").split("/");for(let r=1;r<e.length;r++)e[r]==="."?(e.splice(r,1),r--):e[r]===".."&&(r=r+0,e.splice(r-1,2),r--);return e.join("/")}function $u(t,e){if(!e||Object.keys(e).length===0)return[t,[]];var r=t.indexOf("?"),i=t.indexOf("#"),n="";i>-1&&(n=t.slice(i),t=t.slice(0,i)),r===-1&&(r=t.length,t+="?"),r++;var o="";let s=[];for(var a in e){if(Cg(a,t)!==""){s.push([a,e[a]]);continue}o+=`${a}=${e[a]}&`}return t=t.slice(0,r)+o+t.slice(r)+n,[t,s]}var Hr;function Zr(t){return Hr===void 0&&(Hr=window.URL&&window.URL.createObjectURL||window.webkitURL&&window.webkitURL.createObjectURL,typeof Hr!="function"&&(Hr=null,D("warn","window.URL.createObjectURL (or vendor prefix) not found, unable to create local blob URLs"))),Hr?Hr(t):t}function Cg(t,e){t=t.replace(/[[]/,"\\[").replace(/[\]]/,"\\]");var r=new RegExp("[\\?&]"+t+"=([^&#]*)"),i=r.exec(e);return i===null?"":decodeURIComponent(i[1].replace(/\+/g," "))}var Xr={id:0,queue:[],max_time:20,start_time:null,state:{},add(t){return t.id=Xr.id++,t.max_time=t.max_time||Xr.max_time,t.pause_factor=t.pause_factor||1,t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t.elapsed=0,t.total_elapsed=0,t.stats={calls:0},this.queue.push(t),this.start_time=this.start_time||performance.now(),this.elapsed=performance.now()-this.start_time,(this.elapsed<Xr.max_time||t.immediate)&&this.process(t),t.promise},remove(t){let e=this.queue.indexOf(t);e>-1&&this.queue.splice(e,1)},process(t){if(!(this.state.user_moving_view&&t.user_moving_view===!1))return t.pause?(t.pause--,!0):(t.stats.calls++,t.start_time=performance.now(),t.run(t))},processAll(){this.start_time=this.start_time||performance.now();for(let t of this.queue)if(this.process(t)!==!0&&(t.pause||(t.pause=t.elapsed>t.max_time?t.pause_factor:0),t.total_elapsed+=t.elapsed),this.elapsed=performance.now()-this.start_time,this.elapsed>=Xr.max_time){this.start_time=null;break}},finish(t,e){return t.elapsed=performance.now()-t.start_time,t.total_elapsed+=t.elapsed,this.remove(t),t.resolve(e),t.promise},cancel(t){let e=t.cancel?.(t);t.resolve(e)},shouldContinue(t){return t.elapsed=performance.now()-t.start_time,this.elapsed=performance.now()-this.start_time,t.elapsed<t.max_time&&this.elapsed<Xr.max_time},removeForTile(t){for(let e=this.queue.length-1;e>=0;e--){let r=this.queue[e];r.tile_id===t&&(this.cancel(r),this.queue.splice(e,1))}},setState(t){this.state=t}},Xe=Xr;function Nt(t){let e=[];return Object.assign(t,{subscribe(r){e.includes(r)||e.push(r)},unsubscribe(r){let i=e.indexOf(r);i>=0&&e.splice(i,1)},unsubscribeAll(){e=[]},trigger(r,...i){for(let n of[...e]){let o=n[r];if(typeof o=="function")try{o.call(n,...i)}catch(s){D("warn",`Caught exception in listener for event '${r}':`,s)}}},hasSubscribersFor(r){return e.some(i=>typeof i[r]=="function")}})}function gr(t,e){let r={};for(let i of e)r[i]=t[i];return r}var Yi={configure:Og,withContext:Fg,hasContextScope:Bg,getContext:Ig,resize:Dg},St=Yi,zg=0,la=new WeakMap;function Og(t,e){let r=Ng(t)?t:Object.assign(t,{_tangram_id:zg++});return e&&la.set(t,e),r}function Ng(t){return"_tangram_id"in t&&typeof t._tangram_id=="number"}function Fg(t,e){let r=t&&la.get(t);return r?r(e):e()}function Bg(t){return!!(t&&la.has(t))}function Ig(t,e={}){var r=!1;t==null&&(t=document.createElement("canvas"),t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.zIndex="-1",document.body.appendChild(t),r=!0),t.addEventListener("webglcontextlost",()=>{}),t.addEventListener("webglcontextrestored",()=>{});let i=t.getContext("webgl",e)||t.getContext("experimental-webgl",e);if(!i||!("getParameter"in i))throw new Error("Couldn't create WebGL context.");return Yi.configure(i),r?(Yi.resize(i,window.innerWidth,window.innerHeight,e.device_pixel_ratio),window.addEventListener("resize",function(){Yi.resize(i,window.innerWidth,window.innerHeight,e.device_pixel_ratio)})):Yi.resize(i,parseFloat(t.style.width),parseFloat(t.style.height),e.device_pixel_ratio),i}function Dg(t,e,r,i){i=i||window.devicePixelRatio||1,"style"in t.canvas&&(t.canvas.style.width=e+"px",t.canvas.style.height=r+"px"),t.canvas.width=Math.round(e*i),t.canvas.height=Math.round(r*i),t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,t.canvas.width,t.canvas.height)}function jg(t){return typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement||typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement&&t.complete}var K=class t{constructor(e,r,i={}){i=t.sliceOptions(i),this.gl=e,this.texture_factory=i.textureFactory||e&&t.getResourceFactory(e)||void 0,this.texture_resource=null,this.texture=this.texture_factory?null:Yr(e).createTexture(),this.valid=!!(this.texture_factory||this.texture),this.bind(),this.name=r,this.retain_count=0,this.config_type=null,this.loading=null,this.loaded=!1,this.filtering=i.filtering,this.density=i.density||1,this.sprites=i.sprites,this.texcoords={},this.sizes={},this.css_sizes={},this.aspects={},this.setData(1,1,new Uint8Array([0,0,0,0]),{filtering:"nearest"}),this.filtering=i.filtering,this.loaded=!1;let n=t.textures[this.name];n instanceof t&&(this.retain_count=n.retain_count,n.retain_count=0,n.destroy()),t.textures[this.name]=this,t.texture_configs[this.name]=JSON.stringify(Object.assign({name:r},i)),this.load(i),D("trace",`creating Texture ${this.name}`)}destroy(e={}){return this.texture_factory?this.destroyTexture(e):St.withContext(this.gl,()=>this.destroyTexture(e))}destroyTexture({force:e}={}){if(this.retain_count>0&&!e){D("error",`Texture '${this.name}': destroying texture with retain count of '${this.retain_count}'`);return}this.valid&&(this.texture_resource?(this.texture_resource.destroy(),this.texture_resource=null):Yr(this.gl).deleteTexture(this.texture),this.texture=null,t.textures[this.name]===this&&(delete t.textures[this.name],delete t.texture_configs[this.name]),this.valid=!1,D("trace",`destroying Texture ${this.name}`))}retain(){this.retain_count++}release(){this.retain_count<=0&&D("error",`Texture '${this.name}': releasing texture with retain count of '${this.retain_count}'`),this.retain_count--,this.retain_count<=0&&this.destroy()}bind(e=0){if(!this.valid||this.texture_factory)return;let r=Yr(this.gl);t.activeUnit!==e&&(r.activeTexture(r.TEXTURE0+e),t.activeUnit=e,t.boundTexture=null),t.boundTexture!==this.texture&&(r.bindTexture(r.TEXTURE_2D,this.texture),t.boundTexture=this.texture)}load(e){return e?(this.loading=null,typeof e.url=="string"?(this.config_type="url",this.setUrl(e.url,e)):e.element?(this.config_type="element",this.setElement(e.element,e)):e.data&&e.width&&e.height&&(this.config_type="data",this.setData(e.width,e.height,e.data,e)),this.loading=this.getLoadingPromise()?.then(()=>(this.calculateSprites(),this))||Promise.resolve(this),this.loading):this.loading||Promise.resolve(this)}setUrl(e,r={}){if(this.valid)return this.url=e,this.loading=new Promise(i=>{let n=new Image;n.onload=()=>{try{if(this.url.slice(0,5)==="data:"){let o=document.createElement("canvas"),s=o.getContext("2d");if(o.width=n.width,o.height=n.height,!s)throw new Error("Texture canvas requires a 2D context");s.drawImage(n,0,0),this.setElement(o,r)}else this.setElement(n,r)}catch(o){this.loaded=!1,D("warn",`Texture '${this.name}': failed to load url: '${this.url}'`,o,r),t.trigger("warning",{message:`Failed to load texture from ${this.url}`,error:o,texture:r})}this.loaded=!0,i(this)},n.onerror=o=>{this.loaded=!1,D("warn",`Texture '${this.name}': failed to load url: '${this.url}'`,o,r),t.trigger("warning",{message:`Failed to load texture from ${this.url}`,error:o,texture:r}),i(this)},de.isSafari()&&this.url.slice(0,5)==="data:"||(n.crossOrigin="anonymous"),n.src=this.url}),this.loading}setData(e,r,i,n={}){return this.width=e,this.height=r,Array.isArray(i)&&(i=new Uint8Array(i)),this.update(i??null,n),this.setFiltering(n),this.loaded=!0,this.loading=Promise.resolve(this),this.loading}setElement(e,r={}){let i=e,n=typeof e=="string"?document.querySelector(e):e;if(n instanceof HTMLCanvasElement||n instanceof HTMLImageElement||n instanceof HTMLVideoElement)this.update(n,r),this.setFiltering(r);else{this.loaded=!1;let o=`the 'element' parameter (\`element: ${JSON.stringify(i)}\`) must be a CSS `;o+="selector string, or a <canvas>, <image> or <video> object",D("warn",`Texture '${this.name}': ${o}`,r),t.trigger("warning",{message:`Failed to load texture because ${o}`,texture:r})}return this.loaded=!0,this.loading=Promise.resolve(this),this.loading}update(e,r={}){return this.texture_factory?this.updateTexture(e,r):St.withContext(this.gl,()=>(St.hasContextScope(this.gl)&&t.resetBindings(),this.updateTexture(e,r)))}updateTexture(e,r={}){if(!this.valid)return;if(this.texture_factory)return this.updateTextureResource(e,r);this.bind();let i=Yr(this.gl);if(e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof HTMLImageElement&&e.complete)this.width=e.width,this.height=e.height,i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,r.UNPACK_FLIP_Y_WEBGL!==!1),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.UNPACK_PREMULTIPLY_ALPHA_WEBGL||!1),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,e);else{if(i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,0),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),e instanceof HTMLImageElement)throw new Error("Texture image must finish loading before upload");i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this.width,this.height,0,i.RGBA,i.UNSIGNED_BYTE,e)}t.trigger("update",this)}updateTextureResource(e,r={}){jg(e)&&(this.width=e.width,this.height=e.height);let i=de.isPowerOf2(this.width)&&de.isPowerOf2(this.height),n=r.filtering==="mipmap"&&!i?"linear":r.filtering||this.filtering||"linear",o=this.texture_factory;if(!o)throw new Error("Texture resource update requires a texture factory");let s=o({id:this.name,width:this.width,height:this.height,data:e??void 0,filtering:n,repeat:r.repeat===!0&&i,flipY:r.UNPACK_FLIP_Y_WEBGL!==!1,premultipliedAlpha:r.UNPACK_PREMULTIPLY_ALPHA_WEBGL===!0});if(!s||typeof s.destroy!="function")throw new Error(`Texture '${this.name}': texture factory must return a GPU resource`);let a=this.texture_resource;this.texture_resource=s,this.texture=s,a&&a.destroy(),t.trigger("update",this)}getResource(){return this.texture_resource}setFiltering(e={}){return this.texture_factory?this.updateFiltering(e):St.withContext(this.gl,()=>(St.hasContextScope(this.gl)&&t.resetBindings(),this.updateFiltering(e)))}updateFiltering(e={}){if(!this.valid)return;if(e.filtering=e.filtering||"linear",this.texture_resource){this.power_of_2=de.isPowerOf2(this.width)&&de.isPowerOf2(this.height),this.filtering=e.filtering==="mipmap"&&!this.power_of_2?"linear":e.filtering,t.trigger("update",this);return}let r=Yr(this.gl);this.bind(),de.isPowerOf2(this.width)&&de.isPowerOf2(this.height)?(this.power_of_2=!0,r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e.TEXTURE_WRAP_S||e.repeat&&r.REPEAT||r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e.TEXTURE_WRAP_T||e.repeat&&r.REPEAT||r.CLAMP_TO_EDGE),e.filtering==="mipmap"?(this.filtering="mipmap",r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR_MIPMAP_LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.generateMipmap(r.TEXTURE_2D)):e.filtering==="linear"?(this.filtering="linear",r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR)):e.filtering==="nearest"&&(this.filtering="nearest",r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST))):(this.power_of_2=!1,r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),e.filtering==="nearest"?(this.filtering="nearest",r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST)):(this.filtering="linear",r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR))),t.trigger("update",this)}calculateSprites(){if(this.sprites)for(let e in this.sprites){let r=this.sprites[e];this.texcoords[e]=t.getTexcoordsForSprite([r[0],r[1]],[r[2],r[3]],[this.width,this.height]),this.sizes[e]=[r[2],r[3]],this.css_sizes[e]=[r[2]/this.density,r[3]/this.density],this.aspects[e]=r[2]/r[3]}}byteSize(){return Math.round(this.width*this.height*4*(this.filtering=="mipmap"?1.33:1))}getLoadingPromise(){return this.loading}};K.create=function(t,e,r){return new K(t,e,r)};K.retain=function(t){let e=K.textures[t];e&&"retain"in e&&e.retain()};K.release=function(t){let e=K.textures[t];e&&"release"in e&&e.release()};K.destroy=function(t){var e=Object.keys(K.textures);e.forEach(r=>{var i=K.textures[r];"gl"in i&&i.gl===t&&i.destroy({force:!0})})};K.getSpriteInfo=function(t,e){let r=K.textures[t];return r&&{size:r.sizes[e],css_size:r.css_sizes[e],aspect:r.aspects[e],texcoords:r.texcoords[e]}};K.getTexcoordsForSprite=function(t,e,r){var i=r[1]-t[1]-e[1];return[t[0]/r[0],i/r[1],(e[0]+t[0])/r[0],(e[1]+i)/r[1]]};K.createFromObject=function(t,e){let r=[];if(e)for(let i in e){let n=e[i];if(n.skip_create||!K.changed(i,n))continue;let o=K.create(t,i,n);r.push(o.loading)}return Promise.all(r)};K.default="__default";K.createDefault=function(t){return K.create(t,K.default)};K.sliceOptions=function(t){return{filtering:t.filtering,sprites:t.sprites,url:t.url,element:t.element,data:t.data,width:t.width,height:t.height,density:t.density,repeat:t.repeat,TEXTURE_WRAP_S:t.TEXTURE_WRAP_S,TEXTURE_WRAP_T:t.TEXTURE_WRAP_T,UNPACK_FLIP_Y_WEBGL:t.UNPACK_FLIP_Y_WEBGL,UNPACK_PREMULTIPLY_ALPHA_WEBGL:t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,textureFactory:t.textureFactory}};K.changed=function(t,e){let r=K.textures[t];if(r){if("config_type"in r&&r.config_type==="element"||e.element!=null)return!0;if(e=K.sliceOptions(e),K.texture_configs[t]===JSON.stringify(Object.assign({name:t},e)))return!1}return!0};function Gg(t){if(t||(t=Object.keys(K.textures)),Array.isArray(t))return Promise.all(t.map(i=>K.getInfo(i)));var e=K.textures[t];if(e){var r="loading"in e&&e.loading||Promise.resolve(e);return r.then(()=>({name:e.name,width:e.width,height:e.height,density:e.density,css_size:[e.width/e.density,e.height/e.density],aspect:e.width/e.height,sprites:e.sprites,texcoords:e.texcoords,sizes:e.sizes,css_sizes:e.css_sizes,aspects:e.aspects,filtering:e.filtering,power_of_2:e.power_of_2,valid:e.valid}))}else return Promise.resolve(null)}K.getInfo=Gg;K.syncTexturesToWorker=function(t){return ce.postMessage("Texture.getInfo",t).then(e=>(Array.isArray(e)&&e.filter(Ug).forEach(r=>K.textures[r.name]=r),K.textures))};K.getMaxTextureSize=function(t){let e=Yr(t);return e.getParameter(e.MAX_TEXTURE_SIZE)};K.setResourceFactory=function(t,e){e&&K.resource_factories.set(t,e)};K.getResourceFactory=function(t){return K.resource_factories.get(t)};K.clearResourceFactory=function(t){K.resource_factories.delete(t)};K.textures={};K.texture_configs={};K.resource_factories=new WeakMap;K.boundTexture=null;K.activeUnit=null;K.resetBindings=function(){K.boundTexture=null,K.activeUnit=null};ce.addTarget("Texture",K);Nt(K);function Ug(t){return typeof t=="object"&&t!==null&&"name"in t&&typeof t.name=="string"&&"width"in t&&typeof t.width=="number"&&"height"in t&&typeof t.height=="number"&&"density"in t&&typeof t.density=="number"&&"valid"in t&&typeof t.valid=="boolean"&&["texcoords","sizes","css_sizes","aspects"].every(e=>typeof Reflect.get(t,e)=="object"&&Reflect.get(t,e)!==null)}function Yr(t){if(Vg(t))return t;throw new Error("Classic textures require a WebGL context")}function Vg(t){return t!==null&&"createTexture"in t&&typeof t.createTexture=="function"&&"texImage2D"in t&&typeof t.texImage2D=="function"}var _r={},Ke=_r;_r.parseUniforms=function(t={}){let e=[];for(let[r,i]of Object.entries(t))if(typeof i=="number")e.push({type:"float",method:"1f",name:r,value:i,path:[r]});else if(Array.isArray(i)){if(typeof i[0]=="number")i.length>=2&&i.length<=4?e.push({type:"vec"+i.length,method:i.length+"fv",name:r,value:i,path:[r]}):i.length>4&&e.push({type:"float[]",method:"1fv",name:r+"[0]",value:i,path:[r]});else if(typeof i[0]=="string")for(let n=0;n<i.length;n++)e.push({type:"sampler2D",method:"1i",name:r+"["+n+"]",value:i[n],path:[r,n]});else if(Array.isArray(i[0])&&typeof i[0][0]=="number"&&i[0].length>=2&&i[0].length<=4)for(let n=0;n<i.length;n++)e.push({type:"vec"+i[0].length,method:i[0].length+"fv",name:r+"["+n+"]",value:i[n],path:[r,n]})}else typeof i=="boolean"?e.push({type:"bool",method:"1i",name:r,value:i,path:[r]}):typeof i=="string"&&e.push({type:"sampler2D",method:"1i",name:r,value:i,path:[r]});return e};_r.defineVariable=function(t,e){let r,i;if(typeof e=="number")r="float";else if(Array.isArray(e))typeof e[0]=="number"?e.length>=2&&e.length<=4?r="vec"+e.length:(r="float",i=e.length):typeof e[0]=="string"?(r="sampler2D",i=e.length):Array.isArray(e[0])&&typeof e[0][0]=="number"&&e[0].length>=2&&e[0].length<=4&&(r="vec"+e[0].length,i=e.length);else if(typeof e=="boolean")r="bool";else if(typeof e=="string")r="sampler2D";else return;var n="";return n+=`${r} ${t}`,i&&(n+=`[${i}]`),n+=`;
|
|
20
|
+
`),t.charCodeAt(0)===65279&&(t=t.slice(1)));var r=new y1(t,e);for(r.input+="\0";r.input.charCodeAt(r.position)===32;)r.lineIndent+=1,r.position+=1;for(;r.position<r.length-1;)P1(r);return r.documents}function rm(t,e,r){var i=tm(t,r),n,o;for(n=0,o=i.length;n<o;n+=1)e(i[n])}function im(t,e){var r=tm(t,e);if(r.length!==0){if(r.length===1)return r[0];throw new Wp("expected a single document in the stream, but found more")}}function L1(t,e,r){rm(t,e,kt.extend({schema:Hp},r))}function k1(t,e){return im(t,kt.extend({schema:Hp},e))}Mn.exports.loadAll=rm;Mn.exports.load=im;Mn.exports.safeLoadAll=L1;Mn.exports.safeLoad=k1});var om=_e((E3,He)=>{"use strict";var Rs=nm();function Ps(t){return function(){throw new Error("Function "+t+" is deprecated and cannot be used.")}}He.exports.Type=Ye();He.exports.Schema=Ir();He.exports.FAILSAFE_SCHEMA=xs();He.exports.JSON_SCHEMA=Gl();He.exports.CORE_SCHEMA=Ul();He.exports.DEFAULT_SAFE_SCHEMA=En();He.exports.DEFAULT_FULL_SCHEMA=Ts();He.exports.load=Rs.load;He.exports.loadAll=Rs.loadAll;He.exports.safeLoad=Rs.safeLoad;He.exports.safeLoadAll=Rs.safeLoadAll;He.exports.YAMLException=An();He.exports.MINIMAL_SCHEMA=xs();He.exports.SAFE_SCHEMA=En();He.exports.DEFAULT_SCHEMA=Ts();He.exports.scan=Ps("scan");He.exports.parse=Ps("parse");He.exports.compose=Ps("compose");He.exports.addConstructor=Ps("addConstructor")});var Hl=_e((M3,sm)=>{"use strict";var C1=om();sm.exports=C1});var Em=_e(au=>{au.read=function(t,e,r,i,n){var o,s,a=n*8-i-1,l=(1<<a)-1,u=l>>1,c=-7,h=r?n-1:0,d=r?-1:1,f=t[e+h];for(h+=d,o=f&(1<<-c)-1,f>>=-c,c+=a;c>0;o=o*256+t[e+h],h+=d,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=i;c>0;s=s*256+t[e+h],h+=d,c-=8);if(o===0)o=1-u;else{if(o===l)return s?NaN:(f?-1:1)*(1/0);s=s+Math.pow(2,i),o=o-u}return(f?-1:1)*s*Math.pow(2,o-i)};au.write=function(t,e,r,i,n,o){var s,a,l,u=o*8-n-1,c=(1<<u)-1,h=c>>1,d=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,f=i?0:o-1,p=i?1:-1,m=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-s))<1&&(s--,l*=2),s+h>=1?e+=d/l:e+=d*Math.pow(2,1-h),e*l>=2&&(s++,l/=2),s+h>=c?(a=0,s=c):s+h>=1?(a=(e*l-1)*Math.pow(2,n),s=s+h):(a=e*Math.pow(2,h-1)*Math.pow(2,n),s=0));n>=8;t[r+f]=a&255,f+=p,a/=256,n-=8);for(s=s<<n|a,u+=n;u>0;t[r+f]=s&255,f+=p,s/=256,u-=8);t[r+f-p]|=m*128}});var Lm=_e((QC,Pm)=>{"use strict";Pm.exports=Ge;var Fs=Em();function Ge(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}Ge.Varint=0;Ge.Fixed64=1;Ge.Bytes=2;Ge.Fixed32=5;var lu=65536*65536,Mm=1/lu;Ge.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos<r;){var i=this.readVarint(),n=i>>3,o=this.pos;this.type=i&7,t(n,e,this),this.pos===o&&this.skip(i)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Bs(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Rm(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Bs(this.buf,this.pos)+Bs(this.buf,this.pos+4)*lu;return this.pos+=8,t},readSFixed64:function(){var t=Bs(this.buf,this.pos)+Rm(this.buf,this.pos+4)*lu;return this.pos+=8,t},readFloat:function(){var t=Fs.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=Fs.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e=this.buf,r,i;return i=e[this.pos++],r=i&127,i<128||(i=e[this.pos++],r|=(i&127)<<7,i<128)||(i=e[this.pos++],r|=(i&127)<<14,i<128)||(i=e[this.pos++],r|=(i&127)<<21,i<128)?r:(i=e[this.pos],r|=(i&15)<<28,fv(r,t,this))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2===1?(t+1)/-2:t/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var t=this.readVarint()+this.pos,e=Mv(this.buf,this.pos,t);return this.pos=t,e},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){var r=$t(this);for(t=t||[];this.pos<r;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){var e=$t(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){var e=$t(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){var e=$t(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){var e=$t(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){var e=$t(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){var e=$t(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){var e=$t(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){var e=$t(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=t&7;if(e===Ge.Varint)for(;this.buf[this.pos++]>127;);else if(e===Ge.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Ge.Fixed32)this.pos+=4;else if(e===Ge.Fixed64)this.pos+=8;else throw new Error("Unimplemented type: "+e)},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var r=new Uint8Array(e);r.set(this.buf),this.buf=r,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),Oi(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),Oi(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),Oi(this.buf,t&-1,this.pos),Oi(this.buf,Math.floor(t*Mm),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),Oi(this.buf,t&-1,this.pos),Oi(this.buf,Math.floor(t*Mm),this.pos+4),this.pos+=8},writeVarint:function(t){if(t=+t||0,t>268435455||t<0){pv(t,this);return}this.realloc(4),this.buf[this.pos++]=t&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=t>>>7&127)))},writeSVarint:function(t){this.writeVarint(t<0?-t*2-1:t*2)},writeBoolean:function(t){this.writeVarint(!!t)},writeString:function(t){t=String(t),this.realloc(t.length*4),this.pos++;var e=this.pos;this.pos=Sv(this.buf,t,this.pos);var r=this.pos-e;r>=128&&Sm(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),Fs.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),Fs.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r<e;r++)this.buf[this.pos++]=t[r]},writeRawMessage:function(t,e){this.pos++;var r=this.pos;t(e,this);var i=this.pos-r;i>=128&&Sm(r,i,this),this.pos=r-1,this.writeVarint(i),this.pos+=i},writeMessage:function(t,e,r){this.writeTag(t,Ge.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){this.writeMessage(t,_v,e)},writePackedSVarint:function(t,e){this.writeMessage(t,bv,e)},writePackedBoolean:function(t,e){this.writeMessage(t,vv,e)},writePackedFloat:function(t,e){this.writeMessage(t,yv,e)},writePackedDouble:function(t,e){this.writeMessage(t,xv,e)},writePackedFixed32:function(t,e){this.writeMessage(t,wv,e)},writePackedSFixed32:function(t,e){this.writeMessage(t,Tv,e)},writePackedFixed64:function(t,e){this.writeMessage(t,Av,e)},writePackedSFixed64:function(t,e){this.writeMessage(t,Ev,e)},writeBytesField:function(t,e){this.writeTag(t,Ge.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,Ge.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,Ge.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,Ge.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,Ge.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,Ge.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,Ge.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,Ge.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,Ge.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,Ge.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,!!e)}};function fv(t,e,r){var i=r.buf,n,o;if(o=i[r.pos++],n=(o&112)>>4,o<128||(o=i[r.pos++],n|=(o&127)<<3,o<128)||(o=i[r.pos++],n|=(o&127)<<10,o<128)||(o=i[r.pos++],n|=(o&127)<<17,o<128)||(o=i[r.pos++],n|=(o&127)<<24,o<128)||(o=i[r.pos++],n|=(o&1)<<31,o<128))return zi(t,n,e);throw new Error("Expected varint not more than 10 bytes")}function $t(t){return t.type===Ge.Bytes?t.readVarint()+t.pos:t.pos+1}function zi(t,e,r){return r?e*4294967296+(t>>>0):(e>>>0)*4294967296+(t>>>0)}function pv(t,e){var r,i;if(t>=0?(r=t%4294967296|0,i=t/4294967296|0):(r=~(-t%4294967296),i=~(-t/4294967296),r^4294967295?r=r+1|0:(r=0,i=i+1|0)),t>=18446744073709552e3||t<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),mv(r,i,e),gv(i,e)}function mv(t,e,r){r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos]=t&127}function gv(t,e){var r=(t&7)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127)))))}function Sm(t,e,r){var i=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.ceil(Math.log(e)/(Math.LN2*7));r.realloc(i);for(var n=r.pos-1;n>=t;n--)r.buf[n+i]=r.buf[n]}function _v(t,e){for(var r=0;r<t.length;r++)e.writeVarint(t[r])}function bv(t,e){for(var r=0;r<t.length;r++)e.writeSVarint(t[r])}function yv(t,e){for(var r=0;r<t.length;r++)e.writeFloat(t[r])}function xv(t,e){for(var r=0;r<t.length;r++)e.writeDouble(t[r])}function vv(t,e){for(var r=0;r<t.length;r++)e.writeBoolean(t[r])}function wv(t,e){for(var r=0;r<t.length;r++)e.writeFixed32(t[r])}function Tv(t,e){for(var r=0;r<t.length;r++)e.writeSFixed32(t[r])}function Av(t,e){for(var r=0;r<t.length;r++)e.writeFixed64(t[r])}function Ev(t,e){for(var r=0;r<t.length;r++)e.writeSFixed64(t[r])}function Bs(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+t[e+3]*16777216}function Oi(t,e,r){t[r]=e,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function Rm(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function Mv(t,e,r){for(var i="",n=e;n<r;){var o=t[n],s=null,a=o>239?4:o>223?3:o>191?2:1;if(n+a>r)break;var l,u,c;a===1?o<128&&(s=o):a===2?(l=t[n+1],(l&192)===128&&(s=(o&31)<<6|l&63,s<=127&&(s=null))):a===3?(l=t[n+1],u=t[n+2],(l&192)===128&&(u&192)===128&&(s=(o&15)<<12|(l&63)<<6|u&63,(s<=2047||s>=55296&&s<=57343)&&(s=null))):a===4&&(l=t[n+1],u=t[n+2],c=t[n+3],(l&192)===128&&(u&192)===128&&(c&192)===128&&(s=(o&15)<<18|(l&63)<<12|(u&63)<<6|c&63,(s<=65535||s>=1114112)&&(s=null))),s===null?(s=65533,a=1):s>65535&&(s-=65536,i+=String.fromCharCode(s>>>10&1023|55296),s=56320|s&1023),i+=String.fromCharCode(s),n+=a}return i}function Sv(t,e,r){for(var i=0,n,o;i<e.length;i++){if(n=e.charCodeAt(i),n>55295&&n<57344)if(o)if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,o=n;continue}else n=o-55296<<10|n-56320|65536,o=null;else{n>56319||i+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):o=n;continue}else o&&(t[r++]=239,t[r++]=191,t[r++]=189,o=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=n&63|128)}return r}});var Cm=_e((ez,km)=>{"use strict";km.exports=Ni;function Ni(t,e){this.x=t,this.y=e}Ni.prototype={clone:function(){return new Ni(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[0]*this.x+t[1]*this.y,r=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=r,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),i=e*this.x-r*this.y,n=r*this.x+e*this.y;return this.x=i,this.y=n,this},_rotateAround:function(t,e){var r=Math.cos(t),i=Math.sin(t),n=e.x+r*(this.x-e.x)-i*(this.y-e.y),o=e.y+i*(this.x-e.x)+r*(this.y-e.y);return this.x=n,this.y=o,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}};Ni.convert=function(t){return t instanceof Ni?t:Array.isArray(t)?new Ni(t[0],t[1]):t}});var uu=_e((tz,zm)=>{"use strict";var Rv=Cm();zm.exports=Fi;function Fi(t,e,r,i,n){this.properties={},this.extent=r,this.type=0,this._pbf=t,this._geometry=-1,this._keys=i,this._values=n,t.readFields(Pv,this,e)}function Pv(t,e,r){t==1?e.id=r.readVarint():t==2?Lv(r,e):t==3?e.type=r.readVarint():t==4&&(e._geometry=r.pos)}function Lv(t,e){for(var r=t.readVarint()+t.pos;t.pos<r;){var i=e._keys[t.readVarint()],n=e._values[t.readVarint()];e.properties[i]=n}}Fi.types=["Unknown","Point","LineString","Polygon"];Fi.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,i=0,n=0,o=0,s=[],a;t.pos<e;){if(!i){var l=t.readVarint();r=l&7,i=l>>3}if(i--,r===1||r===2)n+=t.readSVarint(),o+=t.readSVarint(),r===1&&(a&&s.push(a),a=[]),a.push(new Rv(n,o));else if(r===7)a&&a.push(a[0].clone());else throw new Error("unknown command "+r)}return a&&s.push(a),s};Fi.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,i=0,n=0,o=0,s=1/0,a=-1/0,l=1/0,u=-1/0;t.pos<e;){if(!i){var c=t.readVarint();r=c&7,i=c>>3}if(i--,r===1||r===2)n+=t.readSVarint(),o+=t.readSVarint(),n<s&&(s=n),n>a&&(a=n),o<l&&(l=o),o>u&&(u=o);else if(r!==7)throw new Error("unknown command "+r)}return[s,l,a,u]};Fi.prototype.toGeoJSON=function(t,e,r){var i=this.extent*Math.pow(2,r),n=this.extent*t,o=this.extent*e,s=this.loadGeometry(),a=Fi.types[this.type],l,u;function c(f){for(var p=0;p<f.length;p++){var m=f[p],g=180-(m.y+o)*360/i;f[p]=[(m.x+n)*360/i-180,360/Math.PI*Math.atan(Math.exp(g*Math.PI/180))-90]}}switch(this.type){case 1:var h=[];for(l=0;l<s.length;l++)h[l]=s[l][0];s=h,c(s);break;case 2:for(l=0;l<s.length;l++)c(s[l]);break;case 3:for(s=kv(s),l=0;l<s.length;l++)for(u=0;u<s[l].length;u++)c(s[l][u]);break}s.length===1?s=s[0]:a="Multi"+a;var d={type:"Feature",geometry:{type:a,coordinates:s},properties:this.properties};return"id"in this&&(d.id=this.id),d};function kv(t){var e=t.length;if(e<=1)return[t];for(var r=[],i,n,o=0;o<e;o++){var s=Cv(t[o]);s!==0&&(n===void 0&&(n=s<0),n===s<0?(i&&r.push(i),i=[t[o]]):i.push(t[o]))}return i&&r.push(i),r}function Cv(t){for(var e=0,r=0,i=t.length,n=i-1,o,s;r<i;n=r++)o=t[r],s=t[n],e+=(s.x-o.x)*(o.y+s.y);return e}});var cu=_e((rz,Nm)=>{"use strict";var zv=uu();Nm.exports=Om;function Om(t,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(Ov,this,e),this.length=this._features.length}function Ov(t,e,r){t===15?e.version=r.readVarint():t===1?e.name=r.readString():t===5?e.extent=r.readVarint():t===2?e._features.push(r.pos):t===3?e._keys.push(r.readString()):t===4&&e._values.push(Nv(r))}function Nv(t){for(var e=null,r=t.readVarint()+t.pos;t.pos<r;){var i=t.readVarint()>>3;e=i===1?t.readString():i===2?t.readFloat():i===3?t.readDouble():i===4?t.readVarint64():i===5?t.readVarint():i===6?t.readSVarint():i===7?t.readBoolean():null}return e}Om.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new zv(this._pbf,e,this.extent,this._keys,this._values)}});var Bm=_e((iz,Fm)=>{"use strict";var Fv=cu();Fm.exports=Bv;function Bv(t,e){this.layers=t.readFields(Iv,{},e)}function Iv(t,e,r){if(t===3){var i=new Fv(r,r.readVarint()+r.pos);i.length&&(e[i.name]=i)}}});var Im=_e((nz,Is)=>{Is.exports.VectorTile=Bm();Is.exports.VectorTileFeature=uu();Is.exports.VectorTileLayer=cu()});var Bu="0.0.1";var Zi="v"+Bu;var Mg=typeof window<"u"&&typeof Window<"u"&&typeof HTMLDocument<"u"&&window instanceof Window&&window.document instanceof HTMLDocument,Iu=typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope,Sg={is_worker:Iu,is_main:Mg};if(Iu){let t={document:{}};Reflect.set(globalThis,"window",t),Reflect.set(globalThis,"document",t.document)}var Qe=Sg;var De={},ce=De,pr=0,wt={};De.targets={};De.addTarget=function(t,e){De.targets[t]=e};De.removeTarget=function(t){t&&delete De.targets[t]};function Du(t){var e=[];typeof t=="string"&&(e=t.split("."),t=e.pop());var r=De.targets;for(let i=0;i<e.length;i++)if(r[e[i]])r=r[e[i]];else return[];return[t,r]}function Rg(){De.postMessage=function(t,e,...r){if(Array.isArray(t))return Promise.all(t.map(a=>De.postMessage(a,e,...r)));let i={};typeof e=="object"&&(i=e,e=e.method);var n=new Promise((a,l)=>{wt[pr]={method:e,message:r,resolve:a,reject:l}});let o,s=[];return r&&r.length===1&&r[0]instanceof De.withTransferables&&(s=r[0].transferables,r=r[0].value),o={type:"main_send",message_id:pr,method:e,message:r},i.stringify&&(o=JSON.stringify(o)),t.postMessage(o,s.map(a=>a.object)),Wr(s),s.length>0&&D("trace",`'${e}' transferred ${s.length} objects to worker thread`),pr++,n},De.addWorker=function(t){if(!(t instanceof Worker))throw Error("Worker broker could not add non-Worker object",t);t.addEventListener("message",function(r){let i=typeof r.data=="string"?JSON.parse(r.data):r.data,n=i.message_id;if(i.type==="worker_reply")wt[n]&&(i.error?wt[n].reject(i.error):wt[n].resolve(i.message),delete wt[n]);else if(i.type==="worker_send"&&n!=null){let o,s,a,l,u;try{if([l,a]=Du(i.method),!a)throw Error(`Worker broker could not dispatch message type ${i.method} on target ${i.target} because no object with that name is registered on main thread`);if(u=typeof a[l]=="function"&&a[l],!u)throw Error(`Worker broker could not dispatch message type ${i.method} on target ${i.target} because object has no method with that name`);o=u.apply(a,i.message)}catch(d){s=d}let c,h=[];o instanceof Promise?o.then(d=>{d instanceof De.withTransferables&&(h=d.transferables,d=d.value[0]),c={type:"main_reply",message_id:n,message:d},t.postMessage(c,h.map(f=>f.object)),Wr(h),h.length>0&&D("trace",`'${l}' transferred ${h.length} objects to worker thread`)},d=>{t.postMessage({type:"main_reply",message_id:n,error:d instanceof Error?`${d.message}: ${d.stack}`:d})}):(o instanceof De.withTransferables&&(h=o.transferables,o=o.value[0]),c={type:"main_reply",message_id:n,message:o,error:s instanceof Error?`${s.message}: ${s.stack}`:s},t.postMessage(c,h.map(d=>d.object)),Wr(h),h.length>0&&D("trace",`'${l}' transferred ${h.length} objects to worker thread`))}})},De.getMessages=function(){return wt},De.getMessageId=function(){return pr}}function Pg(){De.postMessage=function(t,...e){let r={};typeof t=="object"&&(r=t,t=t.method);var i=new Promise((s,a)=>{wt[pr]={method:t,message:e,resolve:s,reject:a}});let n,o=[];return e&&e.length===1&&e[0]instanceof De.withTransferables&&(o=e[0].transferables,e=e[0].value),n={type:"worker_send",message_id:pr,method:t,message:e},r.stringify&&(n=JSON.stringify(n)),self.postMessage(n,o.map(s=>s.object)),Wr(o),o.length>0&&D("trace",`'${t}' transferred ${o.length} objects to main thread`),pr++,i},self.addEventListener("message",function(e){let r=typeof e.data=="string"?JSON.parse(e.data):e.data,i=r.message_id;if(r.type==="main_reply")wt[i]&&(r.error?wt[i].reject(r.error):wt[i].resolve(r.message),delete wt[i]);else if(r.type==="main_send"&&i!=null){let n,o,s,a,l;try{if([a,s]=Du(r.method),!s)throw Error(`Worker broker could not dispatch message type ${r.method} on target ${r.target} because no object with that name is registered on main thread`);if(l=typeof s[a]=="function"&&s[a],!l)throw Error(`Worker broker could not dispatch message type ${r.method} because worker has no method with that name`);n=l.apply(s,r.message)}catch(h){o=h}let u,c=[];n instanceof Promise?n.then(h=>{h instanceof De.withTransferables&&(c=h.transferables,h=h.value[0]),u={type:"worker_reply",message_id:i,message:h},self.postMessage(u,c.map(d=>d.object)),Wr(c),c.length>0&&D("trace",`'${a}' transferred ${c.length} objects to main thread`)},h=>{self.postMessage({type:"worker_reply",message_id:i,error:h instanceof Error?`${h.message}: ${h.stack}`:h})}):(n instanceof De.withTransferables&&(c=n.transferables,n=n.value[0]),u={type:"worker_reply",message_id:i,message:n,error:o instanceof Error?`${o.message}: ${o.stack}`:o},self.postMessage(u,c.map(h=>h.object)),Wr(c),c.length>0&&D("trace",`'${a}' transferred ${c.length} objects to main thread`))}})}De.withTransferables=function(...t){if(!(this instanceof De.withTransferables))return new De.withTransferables(...t);this.value=t,this.transferables=na(this.value)};function na(t,e=null,r=null,i=[]){if(!t)return i;if(Array.isArray(t))t.forEach((n,o)=>na(n,t,o,i));else if(typeof t=="object")if(t instanceof ArrayBuffer)i.push({object:t,parent:e,property:r});else if(t.buffer instanceof ArrayBuffer)i.push({object:t.buffer,parent:e,property:r});else for(let n in t)na(t[n],t,n,i);return i}function Wr(t){Array.isArray(t)&&t.filter(e=>e.parent&&e.property).forEach(e=>delete e.parent[e.property])}Qe.is_main&&Rg();Qe.is_worker&&Pg();var Gu=ce,ju={silent:-1,error:0,warn:1,info:2,debug:3,trace:4},oa={},sa={};function Lg(t){if(!oa[t]){let e=console;oa[t]=(e[t]||console.log).bind(console)}return oa[t]}var ft=(async(t,...e)=>{let r=typeof t=="object"?t.level:t;if(ju[r]>ju[ft.level])return!1;if(Qe.is_worker)return Gu.postMessage({method:"_logProxy",stringify:!0},t,...e);if(typeof t=="object"&&t.once===!0){let n=JSON.stringify(e);if(sa[n])return!1;sa[n]=!0}let i=Lg(r);return e.length>1?i(`Tangram ${Zi} [${r}]: ${e[0]}`,...e.slice(1)):i(`Tangram ${Zi} [${r}]: ${e[0]}`),!0});ft.level="info";ft.workers=null;ft.setLevel=t=>{ft.level=t,Qe.is_main&&Array.isArray(ft.workers)&&Gu.postMessage(ft.workers,"_logSetLevelProxy",t)};Qe.is_worker||(ft.setWorkers=t=>{ft.workers=t},ft.reset=()=>{sa={}});ce.addTarget("_logProxy",ft);ce.addTarget("_logSetLevelProxy",ft.setLevel);var D=ft;var Se={},de=Se;ce.addTarget("Utils",Se);Se.isSafari=function(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)};Se.isMicrosoft=function(){return/(Trident\/7.0|Edge[ /](\d+[.\d]+))/i.test(navigator.userAgent)};Se._requests={};Se._proxy_requests={};Se.io=function(t,e=6e4,r="text",i="GET",n={},o=null,s=!1){if(Qe.is_worker&&Se.isMicrosoft())return D("debug","Proxying request for URL to worker",t),o&&(Se._proxy_requests[o]=!0),ce.postMessage("Utils.io",t,e,r,i,n,o,!0);{let a=new XMLHttpRequest,l=new Promise((u,c)=>{if(a.open(i,t,!0),a.timeout=e,a.responseType=r,n&&typeof n=="object")for(let h in n)a.setRequestHeader(h,n[h]);a.onload=()=>{a.status===200?["text","json"].indexOf(a.responseType)>-1?u({body:a.responseText,status:a.status}):u({body:a.response,status:a.status}):a.status===204?u({body:null,status:a.status}):c(Error("Request error with a status of "+a.statusText))},a.onerror=h=>{c(Error("There was a network error"+h.toString()))},a.ontimeout=h=>{c(Error("timeout "+h.toString()))},a.send()});return l=l.then(u=>(o&&delete Se._requests[o],s?ce.withTransferables(u):u)),o&&(Se._requests[o]=a),l}};Se.cancelRequest=function(t){if(Qe.is_worker&&Se._proxy_requests[t])return ce.postMessage("Utils.cancelRequest",t);Se._requests[t]?(D("trace",`Cancelling network request key '${t}'`),Se._requests[t].abort(),delete Se._requests[t]):D("trace",`Could not find network request key '${t}'`)};Se.serializeWithFunctions=function(t){return typeof t=="function"?t.toString():JSON.stringify(t,function(r,i){return typeof i=="function"?i.toString():i})};Se.use_high_density_display=!0;Se.updateDevicePixelRatio=function(){let t=Se.device_pixel_ratio;return Se.device_pixel_ratio=Se.use_high_density_display&&window.devicePixelRatio||1,Se.device_pixel_ratio!==t};Qe.is_main&&Se.updateDevicePixelRatio();Se.isPowerOf2=function(t){return(t&t-1)===0};Se.interpolate=function(t,e,r){if(!Array.isArray(e)||!Array.isArray(e[0]))return e;if(e.length<1)return e;let i,n,o,s,a,l,u=e;if(t<=u[0][0])s=u[0][1],typeof r=="function"&&(s=r(s));else if(t>=u[u.length-1][0])s=u[u.length-1][1],typeof r=="function"&&(s=r(s));else for(let c=0;c<u.length-1;c++)if(t>=u[c][0]&&t<u[c+1][0]){i=u[c][0],n=u[c+1][0];let h=u[c][1],d=u[c+1][1];if(Array.isArray(h)&&Array.isArray(d)){s=[];for(let f=0;f<h.length;f++)typeof r=="function"?(a=r(h[f]),l=r(d[f]),o=l-a,s[f]=o*(t-i)/(n-i)+a):(o=d[f]-h[f],s[f]=o*(t-i)/(n-i)+h[f])}else typeof r=="function"?(a=r(h),l=r(d),o=l-a,s=o*(t-i)/(n-i)+a):(o=d-h,s=o*(t-i)/(n-i)+h);break}return s};Se.toCSSColor=function(t){if(t!=null)return t[3]===1?`rgb(${t.slice(0,3).map(e=>Math.round(e*255)).join(", ")})`:`rgba(${t.map((e,r)=>r<3&&Math.round(e*255)||e).join(", ")})`};var kg={draw_label_collision_boxes:!1,draw_label_texture_boxes:!1,suppress_label_fade_in:!1,suppress_label_snap_animation:!1,show_hidden_labels:!1,layer_stats:!1,wireframe:!1},Ze=kg;function Wn(t,e){if(!t||!Ht(t))return t;var r=t[0]!=="/",i;if(e?(i=document.createElement("a"),i.href=e):i=window.location,r)t=mr(i.href)+t;else{let n=i.origin;n||(n=i.protocol+"//"+i.host),t=n+t}return t}function mr(t){if(typeof t=="string"&&t.search(/^(data|blob):/)===-1){let e=t.indexOf("?");e>-1&&(t=t.substr(0,e));let r=t.indexOf("#");return r>-1&&(t=t.substr(0,r)),t.substr(0,t.lastIndexOf("/")+1)||""}return""}function Xi(t){let e=t.split("/").pop()||"",r=e.lastIndexOf(".");if(r>-1)return e.substring(r+1)}function Uu(t){return typeof t!="string"?!1:t.search(/^(data|blob):/)>-1}function Ht(t){return typeof t!="string"?!1:!(t.search(/^(http|https|data|blob):/)>-1||t.substr(0,2)==="//")}function Vu(t){let e=(t||"").split("/");for(let r=1;r<e.length;r++)e[r]==="."?(e.splice(r,1),r--):e[r]===".."&&(r=r+0,e.splice(r-1,2),r--);return e.join("/")}function $u(t,e){if(!e||Object.keys(e).length===0)return[t,[]];var r=t.indexOf("?"),i=t.indexOf("#"),n="";i>-1&&(n=t.slice(i),t=t.slice(0,i)),r===-1&&(r=t.length,t+="?"),r++;var o="";let s=[];for(var a in e){if(Cg(a,t)!==""){s.push([a,e[a]]);continue}o+=`${a}=${e[a]}&`}return t=t.slice(0,r)+o+t.slice(r)+n,[t,s]}var Hr;function Zr(t){return Hr===void 0&&(Hr=window.URL&&window.URL.createObjectURL||window.webkitURL&&window.webkitURL.createObjectURL,typeof Hr!="function"&&(Hr=null,D("warn","window.URL.createObjectURL (or vendor prefix) not found, unable to create local blob URLs"))),Hr?Hr(t):t}function Cg(t,e){t=t.replace(/[[]/,"\\[").replace(/[\]]/,"\\]");var r=new RegExp("[\\?&]"+t+"=([^&#]*)"),i=r.exec(e);return i===null?"":decodeURIComponent(i[1].replace(/\+/g," "))}var Xr={id:0,queue:[],max_time:20,start_time:null,state:{},add(t){return t.id=Xr.id++,t.max_time=t.max_time||Xr.max_time,t.pause_factor=t.pause_factor||1,t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t.elapsed=0,t.total_elapsed=0,t.stats={calls:0},this.queue.push(t),this.start_time=this.start_time||performance.now(),this.elapsed=performance.now()-this.start_time,(this.elapsed<Xr.max_time||t.immediate)&&this.process(t),t.promise},remove(t){let e=this.queue.indexOf(t);e>-1&&this.queue.splice(e,1)},process(t){if(!(this.state.user_moving_view&&t.user_moving_view===!1))return t.pause?(t.pause--,!0):(t.stats.calls++,t.start_time=performance.now(),t.run(t))},processAll(){this.start_time=this.start_time||performance.now();for(let t of this.queue)if(this.process(t)!==!0&&(t.pause||(t.pause=t.elapsed>t.max_time?t.pause_factor:0),t.total_elapsed+=t.elapsed),this.elapsed=performance.now()-this.start_time,this.elapsed>=Xr.max_time){this.start_time=null;break}},finish(t,e){return t.elapsed=performance.now()-t.start_time,t.total_elapsed+=t.elapsed,this.remove(t),t.resolve(e),t.promise},cancel(t){let e=t.cancel?.(t);t.resolve(e)},shouldContinue(t){return t.elapsed=performance.now()-t.start_time,this.elapsed=performance.now()-this.start_time,t.elapsed<t.max_time&&this.elapsed<Xr.max_time},removeForTile(t){for(let e=this.queue.length-1;e>=0;e--){let r=this.queue[e];r.tile_id===t&&(this.cancel(r),this.queue.splice(e,1))}},setState(t){this.state=t}},Xe=Xr;function Nt(t){let e=[];return Object.assign(t,{subscribe(r){e.includes(r)||e.push(r)},unsubscribe(r){let i=e.indexOf(r);i>=0&&e.splice(i,1)},unsubscribeAll(){e=[]},trigger(r,...i){for(let n of[...e]){let o=n[r];if(typeof o=="function")try{o.call(n,...i)}catch(s){D("warn",`Caught exception in listener for event '${r}':`,s)}}},hasSubscribersFor(r){return e.some(i=>typeof i[r]=="function")}})}function gr(t,e){let r={};for(let i of e)r[i]=t[i];return r}var Yi={configure:Og,withContext:Fg,hasContextScope:Bg,getContext:Ig,resize:Dg},St=Yi,zg=0,la=new WeakMap;function Og(t,e){let r=Ng(t)?t:Object.assign(t,{_tangram_id:zg++});return e&&la.set(t,e),r}function Ng(t){return"_tangram_id"in t&&typeof t._tangram_id=="number"}function Fg(t,e){let r=t&&la.get(t);return r?r(e):e()}function Bg(t){return!!(t&&la.has(t))}function Ig(t,e={}){var r=!1;t==null&&(t=document.createElement("canvas"),t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.zIndex="-1",document.body.appendChild(t),r=!0),t.addEventListener("webglcontextlost",()=>{}),t.addEventListener("webglcontextrestored",()=>{});let i=t.getContext("webgl",e)||t.getContext("experimental-webgl",e);if(!i||!("getParameter"in i))throw new Error("Couldn't create WebGL context.");return Yi.configure(i),r?(Yi.resize(i,window.innerWidth,window.innerHeight,e.device_pixel_ratio),window.addEventListener("resize",function(){Yi.resize(i,window.innerWidth,window.innerHeight,e.device_pixel_ratio)})):Yi.resize(i,parseFloat(t.style.width),parseFloat(t.style.height),e.device_pixel_ratio),i}function Dg(t,e,r,i){i=i||window.devicePixelRatio||1,"style"in t.canvas&&(t.canvas.style.width=e+"px",t.canvas.style.height=r+"px"),t.canvas.width=Math.round(e*i),t.canvas.height=Math.round(r*i),t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,t.canvas.width,t.canvas.height)}function jg(t){return typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement||typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement&&t.complete}var K=class t{constructor(e,r,i={}){i=t.sliceOptions(i),this.gl=e,this.texture_factory=i.textureFactory||e&&t.getResourceFactory(e)||void 0,this.texture_resource=null,this.texture=this.texture_factory?null:Yr(e).createTexture(),this.valid=!!(this.texture_factory||this.texture),this.bind(),this.name=r,this.retain_count=0,this.config_type=null,this.loading=null,this.loaded=!1,this.filtering=i.filtering,this.density=i.density||1,this.sprites=i.sprites,this.texcoords={},this.sizes={},this.css_sizes={},this.aspects={},this.setData(1,1,new Uint8Array([0,0,0,0]),{filtering:"nearest"}),this.filtering=i.filtering,this.loaded=!1;let n=t.textures[this.name];n instanceof t&&(this.retain_count=n.retain_count,n.retain_count=0,n.destroy()),t.textures[this.name]=this,t.texture_configs[this.name]=JSON.stringify(Object.assign({name:r},i)),this.load(i),D("trace",`creating Texture ${this.name}`)}destroy(e={}){return this.texture_factory?this.destroyTexture(e):St.withContext(this.gl,()=>this.destroyTexture(e))}destroyTexture({force:e}={}){if(this.retain_count>0&&!e){D("error",`Texture '${this.name}': destroying texture with retain count of '${this.retain_count}'`);return}this.valid&&(this.texture_resource?(this.texture_resource.destroy(),this.texture_resource=null):Yr(this.gl).deleteTexture(this.texture),this.texture=null,t.textures[this.name]===this&&(delete t.textures[this.name],delete t.texture_configs[this.name]),this.valid=!1,D("trace",`destroying Texture ${this.name}`))}retain(){this.retain_count++}release(){this.retain_count<=0&&D("error",`Texture '${this.name}': releasing texture with retain count of '${this.retain_count}'`),this.retain_count--,this.retain_count<=0&&this.destroy()}bind(e=0){if(!this.valid||this.texture_factory)return;let r=Yr(this.gl);t.activeUnit!==e&&(r.activeTexture(r.TEXTURE0+e),t.activeUnit=e,t.boundTexture=null),t.boundTexture!==this.texture&&(r.bindTexture(r.TEXTURE_2D,this.texture),t.boundTexture=this.texture)}load(e){return e?(this.loading=null,typeof e.url=="string"?(this.config_type="url",this.setUrl(e.url,e)):e.element?(this.config_type="element",this.setElement(e.element,e)):e.data&&e.width&&e.height&&(this.config_type="data",this.setData(e.width,e.height,e.data,e)),this.loading=this.getLoadingPromise()?.then(()=>(this.calculateSprites(),this))||Promise.resolve(this),this.loading):this.loading||Promise.resolve(this)}setUrl(e,r={}){if(this.valid)return this.url=e,this.loading=new Promise(i=>{let n=new Image;n.onload=()=>{try{if(this.url.slice(0,5)==="data:"){let o=document.createElement("canvas"),s=o.getContext("2d");if(o.width=n.width,o.height=n.height,!s)throw new Error("Texture canvas requires a 2D context");s.drawImage(n,0,0),this.setElement(o,r)}else this.setElement(n,r)}catch(o){this.loaded=!1,D("warn",`Texture '${this.name}': failed to load url: '${this.url}'`,o,r),t.trigger("warning",{message:`Failed to load texture from ${this.url}`,error:o,texture:r})}this.loaded=!0,i(this)},n.onerror=o=>{this.loaded=!1,D("warn",`Texture '${this.name}': failed to load url: '${this.url}'`,o,r),t.trigger("warning",{message:`Failed to load texture from ${this.url}`,error:o,texture:r}),i(this)},de.isSafari()&&this.url.slice(0,5)==="data:"||(n.crossOrigin="anonymous"),n.src=this.url}),this.loading}setData(e,r,i,n={}){return this.width=e,this.height=r,Array.isArray(i)&&(i=new Uint8Array(i)),this.update(i??null,n),this.setFiltering(n),this.loaded=!0,this.loading=Promise.resolve(this),this.loading}setElement(e,r={}){let i=e,n=typeof e=="string"?document.querySelector(e):e;if(n instanceof HTMLCanvasElement||n instanceof HTMLImageElement||n instanceof HTMLVideoElement)this.update(n,r),this.setFiltering(r);else{this.loaded=!1;let o=`the 'element' parameter (\`element: ${JSON.stringify(i)}\`) must be a CSS `;o+="selector string, or a <canvas>, <image> or <video> object",D("warn",`Texture '${this.name}': ${o}`,r),t.trigger("warning",{message:`Failed to load texture because ${o}`,texture:r})}return this.loaded=!0,this.loading=Promise.resolve(this),this.loading}update(e,r={}){return this.texture_factory?this.updateTexture(e,r):St.withContext(this.gl,()=>(St.hasContextScope(this.gl)&&t.resetBindings(),this.updateTexture(e,r)))}updateTexture(e,r={}){if(!this.valid)return;if(this.texture_factory)return this.updateTextureResource(e,r);this.bind();let i=Yr(this.gl);if(e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof HTMLImageElement&&e.complete)this.width=e.width,this.height=e.height,i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,r.UNPACK_FLIP_Y_WEBGL!==!1),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.UNPACK_PREMULTIPLY_ALPHA_WEBGL||!1),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,e);else{if(i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,0),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),e instanceof HTMLImageElement)throw new Error("Texture image must finish loading before upload");i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this.width,this.height,0,i.RGBA,i.UNSIGNED_BYTE,e)}t.trigger("update",this)}updateTextureResource(e,r={}){jg(e)&&(this.width=e.width,this.height=e.height);let i=de.isPowerOf2(this.width)&&de.isPowerOf2(this.height),n=r.filtering==="mipmap"&&!i?"linear":r.filtering||this.filtering||"linear",o=this.texture_factory;if(!o)throw new Error("Texture resource update requires a texture factory");let s=o({id:this.name,width:this.width,height:this.height,data:e??void 0,filtering:n,repeat:r.repeat===!0&&i,flipY:r.UNPACK_FLIP_Y_WEBGL!==!1,premultipliedAlpha:r.UNPACK_PREMULTIPLY_ALPHA_WEBGL===!0});if(!s||typeof s.destroy!="function")throw new Error(`Texture '${this.name}': texture factory must return a GPU resource`);let a=this.texture_resource;this.texture_resource=s,this.texture=s,a&&a.destroy(),t.trigger("update",this)}getResource(){return this.texture_resource}setFiltering(e={}){return this.texture_factory?this.updateFiltering(e):St.withContext(this.gl,()=>(St.hasContextScope(this.gl)&&t.resetBindings(),this.updateFiltering(e)))}updateFiltering(e={}){if(!this.valid)return;if(e.filtering=e.filtering||"linear",this.texture_resource){this.power_of_2=de.isPowerOf2(this.width)&&de.isPowerOf2(this.height),this.filtering=e.filtering==="mipmap"&&!this.power_of_2?"linear":e.filtering,t.trigger("update",this);return}let r=Yr(this.gl);this.bind(),de.isPowerOf2(this.width)&&de.isPowerOf2(this.height)?(this.power_of_2=!0,r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,e.TEXTURE_WRAP_S||e.repeat&&r.REPEAT||r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,e.TEXTURE_WRAP_T||e.repeat&&r.REPEAT||r.CLAMP_TO_EDGE),e.filtering==="mipmap"?(this.filtering="mipmap",r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR_MIPMAP_LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.generateMipmap(r.TEXTURE_2D)):e.filtering==="linear"?(this.filtering="linear",r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR)):e.filtering==="nearest"&&(this.filtering="nearest",r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST))):(this.power_of_2=!1,r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),e.filtering==="nearest"?(this.filtering="nearest",r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST)):(this.filtering="linear",r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR))),t.trigger("update",this)}calculateSprites(){if(this.sprites)for(let e in this.sprites){let r=this.sprites[e];this.texcoords[e]=t.getTexcoordsForSprite([r[0],r[1]],[r[2],r[3]],[this.width,this.height]),this.sizes[e]=[r[2],r[3]],this.css_sizes[e]=[r[2]/this.density,r[3]/this.density],this.aspects[e]=r[2]/r[3]}}byteSize(){return Math.round(this.width*this.height*4*(this.filtering=="mipmap"?1.33:1))}getLoadingPromise(){return this.loading}};K.create=function(t,e,r){return new K(t,e,r)};K.retain=function(t){let e=K.textures[t];e&&"retain"in e&&e.retain()};K.release=function(t){let e=K.textures[t];e&&"release"in e&&e.release()};K.destroy=function(t){var e=Object.keys(K.textures);e.forEach(r=>{var i=K.textures[r];"gl"in i&&i.gl===t&&i.destroy({force:!0})})};K.getSpriteInfo=function(t,e){let r=K.textures[t];return r&&{size:r.sizes[e],css_size:r.css_sizes[e],aspect:r.aspects[e],texcoords:r.texcoords[e]}};K.getTexcoordsForSprite=function(t,e,r){var i=r[1]-t[1]-e[1];return[t[0]/r[0],i/r[1],(e[0]+t[0])/r[0],(e[1]+i)/r[1]]};K.createFromObject=function(t,e){let r=[];if(e)for(let i in e){let n=e[i];if(n.skip_create||!K.changed(i,n))continue;let o=K.create(t,i,n);r.push(o.loading)}return Promise.all(r)};K.default="__default";K.createDefault=function(t){return K.create(t,K.default)};K.sliceOptions=function(t){return{filtering:t.filtering,sprites:t.sprites,url:t.url,element:t.element,data:t.data,width:t.width,height:t.height,density:t.density,repeat:t.repeat,TEXTURE_WRAP_S:t.TEXTURE_WRAP_S,TEXTURE_WRAP_T:t.TEXTURE_WRAP_T,UNPACK_FLIP_Y_WEBGL:t.UNPACK_FLIP_Y_WEBGL,UNPACK_PREMULTIPLY_ALPHA_WEBGL:t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,textureFactory:t.textureFactory}};K.changed=function(t,e){let r=K.textures[t];if(r){if("config_type"in r&&r.config_type==="element"||e.element!=null)return!0;if(e=K.sliceOptions(e),K.texture_configs[t]===JSON.stringify(Object.assign({name:t},e)))return!1}return!0};function Gg(t){if(t||(t=Object.keys(K.textures)),Array.isArray(t))return Promise.all(t.map(i=>K.getInfo(i)));var e=K.textures[t];if(e){var r="loading"in e&&e.loading||Promise.resolve(e);return r.then(()=>({name:e.name,width:e.width,height:e.height,density:e.density,css_size:[e.width/e.density,e.height/e.density],aspect:e.width/e.height,sprites:e.sprites,texcoords:e.texcoords,sizes:e.sizes,css_sizes:e.css_sizes,aspects:e.aspects,filtering:e.filtering,power_of_2:e.power_of_2,valid:e.valid}))}else return Promise.resolve(null)}K.getInfo=Gg;K.syncTexturesToWorker=function(t){return ce.postMessage("Texture.getInfo",t).then(e=>(Array.isArray(e)&&e.filter(Ug).forEach(r=>K.textures[r.name]=r),K.textures))};K.getMaxTextureSize=function(t){let e=Yr(t);return e.getParameter(e.MAX_TEXTURE_SIZE)};K.setResourceFactory=function(t,e){e&&K.resource_factories.set(t,e)};K.getResourceFactory=function(t){return K.resource_factories.get(t)};K.clearResourceFactory=function(t){K.resource_factories.delete(t)};K.textures={};K.texture_configs={};K.resource_factories=new WeakMap;K.boundTexture=null;K.activeUnit=null;K.resetBindings=function(){K.boundTexture=null,K.activeUnit=null};ce.addTarget("Texture",K);Nt(K);function Ug(t){return typeof t=="object"&&t!==null&&"name"in t&&typeof t.name=="string"&&"width"in t&&typeof t.width=="number"&&"height"in t&&typeof t.height=="number"&&"density"in t&&typeof t.density=="number"&&"valid"in t&&typeof t.valid=="boolean"&&["texcoords","sizes","css_sizes","aspects"].every(e=>typeof Reflect.get(t,e)=="object"&&Reflect.get(t,e)!==null)}function Yr(t){if(Vg(t))return t;throw new Error("Classic textures require a WebGL context")}function Vg(t){return t!==null&&"createTexture"in t&&typeof t.createTexture=="function"&&"texImage2D"in t&&typeof t.texImage2D=="function"}var _r={},Ke=_r;_r.parseUniforms=function(t={}){let e=[];for(let[r,i]of Object.entries(t))if(typeof i=="number")e.push({type:"float",method:"1f",name:r,value:i,path:[r]});else if(Array.isArray(i)){if(typeof i[0]=="number")i.length>=2&&i.length<=4?e.push({type:"vec"+i.length,method:i.length+"fv",name:r,value:i,path:[r]}):i.length>4&&e.push({type:"float[]",method:"1fv",name:r+"[0]",value:i,path:[r]});else if(typeof i[0]=="string")for(let n=0;n<i.length;n++)e.push({type:"sampler2D",method:"1i",name:r+"["+n+"]",value:i[n],path:[r,n]});else if(Array.isArray(i[0])&&typeof i[0][0]=="number"&&i[0].length>=2&&i[0].length<=4)for(let n=0;n<i.length;n++)e.push({type:"vec"+i[0].length,method:i[0].length+"fv",name:r+"["+n+"]",value:i[n],path:[r,n]})}else typeof i=="boolean"?e.push({type:"bool",method:"1i",name:r,value:i,path:[r]}):typeof i=="string"&&e.push({type:"sampler2D",method:"1i",name:r,value:i,path:[r]});return e};_r.defineVariable=function(t,e){let r,i;if(typeof e=="number")r="float";else if(Array.isArray(e))typeof e[0]=="number"?e.length>=2&&e.length<=4?r="vec"+e.length:(r="float",i=e.length):typeof e[0]=="string"?(r="sampler2D",i=e.length):Array.isArray(e[0])&&typeof e[0][0]=="number"&&e[0].length>=2&&e[0].length<=4&&(r="vec"+e[0].length,i=e.length);else if(typeof e=="boolean")r="bool";else if(typeof e=="string")r="sampler2D";else return;var n="";return n+=`${r} ${t}`,i&&(n+=`[${i}]`),n+=`;
|
|
21
21
|
`,n};_r.defineUniform=function(t,e){var r=_r.defineVariable(t,e);if(r)return"uniform "+r};_r.expandVec3=function(t,e=1){let r;if(Array.isArray(t))if(t.length===2)r=[...t,e].map(parseFloat);else return t;else r=[t,t,t].map(parseFloat);if(r&&r.every(i=>typeof i=="number"&&!isNaN(i)))return r};_r.expandVec4=function(t,e=1){let r;if(Array.isArray(t))if(t.length===3)r=[...t,e].map(parseFloat);else return t;else r=[t,t,t,e].map(parseFloat);if(r&&r.every(i=>typeof i=="number"&&!isNaN(i)))return r};var qu=[];function Jr(t,e){let r=qu.find(i=>i[0]===t)?.[1];return r||(r={},qu.push([t,r])),r[e]||(r[e]=t.getExtension(e)),r[e]}function _t(t){let e=0;for(let r=0;r<t.length;r++)e=(e<<5)-e+t.charCodeAt(r),e|=0;return e}var Hn=new WeakMap;function ua(t,e){let r=Hn.get(t);r||(r=new Set,Hn.set(t,r)),r.add(e);let i=r;return()=>{i.delete(e)}}function Zn(t){let e=Hn.get(t);if(!e)return;Hn.delete(t);let r=[...e];e.clear();let i=[];for(let n of r)try{n()}catch(o){i.push(o)}if(i.length)throw new AggregateError(i,"GPU cache disposal failed")}var Ju=Ot(Hu(),1),Zu=/^\s*#pragma.*$/gm,Xu=/\\\s*\n/mg,qg=/\bgl_FragColor\b/g,Wg=/\btexture2D\b/g,Hg=/\btextureCube\b/g,Qr=new WeakMap,re=class t{constructor(e,r,i,n={}){n=n||{},this.gl=e,this.program=null,this.compiled=!1,this.compiling=!1,this.error=null,this.defines=Object.assign({},n.defines||{}),this.blocks=Object.assign({},n.blocks||{}),this.block_scopes=Object.assign({},n.block_scopes||{}),this.extensions=n.extensions||[],this.dependent_uniforms=n.uniforms,this.uniforms={},this.uniform_blocks=Object.assign({},n.uniform_blocks||{}),this.defer_uniform_blocks=n.deferUniformBlocks===!0,this.defer_texture_bindings=n.deferTextureBindings===!0,this.defer_uniform_updates=n.deferUniformUpdates===!0,this.texture_uniforms={},this.shader_language=n.shaderLanguage||"glsl",this.shader_factory=n.shaderFactory,this.shader_program_validator=n.shaderProgramValidator,this.device_shader_compilation=n.deviceShaderCompilation===!0,this.vertex_shader_resource=null,this.fragment_shader_resource=null,this.glsl_version=n.glsl_version||(Object.keys(this.uniform_blocks).length>0?300:100),this.attribs={},this.vertex_source=r,this.fragment_source=i,this.id=t.id++,this.name=n.name}get classicContext(){if(Xg(this.gl))return this.gl;throw new Error("Classic shaders require a WebGL context")}destroy(){this.shader_language==="glsl"&&!this.device_shader_compilation&&(this.classicContext.useProgram(null),t.current=null,t.releaseProgram(this.classicContext,this.program)),this.destroyShaderResources(),this.program=null,this.uniforms={},this.texture_uniforms={},this.attribs={},this.compiled=!1}use({bindUniformBlocks:e=!this.defer_uniform_blocks}={}){if(!this.compiled)return;t.current!==this&&this.shader_language==="glsl"&&!this.defer_uniform_updates&&this.classicContext.useProgram(this.program),t.current=this,e&&this.bindUniformBlocks({force:!0})}compile(){if(this.shader_language!=="glsl")return this.compilePortable();if(this.device_shader_compilation&&(!this.shader_factory||!this.shader_program_validator))throw new Error("ShaderProgram: device compilation requires shaderFactory and shaderProgramValidator");if(this.compiling)throw new Error(`ShaderProgram.compile(): skipping for ${this.id} (${this.name}) because already compiling`);this.compiling=!0,this.compiled=!1,this.error=null,this.computed_vertex_source=this.vertex_source,this.computed_fragment_source=this.fragment_source;let e=this.checkExtensions();var r=this.buildDefineList(),i=this.buildShaderBlockList(),n;for(var o in i){var s=i[o];if(!(!s||Array.isArray(s)&&s.length===0)){n=new RegExp("^\\s*#pragma\\s+tangram:\\s+"+o+"\\s*$","m");var a=this.computed_vertex_source.match(n),l=this.computed_fragment_source.match(n);if(!(a==null&&l==null)){var u="";s.forEach(d=>{let f=`${d.scope}, ${d.key}, ${d.num}`;u+=`
|
|
22
22
|
// tangram-block-start: ${f}
|
|
23
23
|
`,u+=d.source,u+=`
|
|
@@ -2486,7 +2486,7 @@ vec3 worldNormal() {
|
|
|
2486
2486
|
// and scale down values so objects higher than one screen height will not get clipped
|
|
2487
2487
|
// pull forward slightly to avoid going past far clipping plane
|
|
2488
2488
|
position.z = -position.z / 100. + 1. - 0.001;
|
|
2489
|
-
}`)}update(){super.update(),this.viewport_height=this.view.size.css.height*this.view.meters_per_pixel;var e=[this.view.center.meters.x,this.view.center.meters.y,this.viewport_height];this.position_meters=e,this.matrix4.identity().translate([-e[0],-e[1],0]).toArray(this.view_matrix),this.matrix4.identity().toArray(this.projection_matrix),this.projection_matrix[8]=this.axis.x/this.view.aspect,this.projection_matrix[9]=this.axis.y,this.matrix4.copy(this.projection_matrix).scale([2/this.view.size.meters.x,2/this.view.size.meters.y,2/this.view.size.meters.y]).toArray(this.projection_matrix)}setupProgram(e,r){r?r.setUniforms({u_projection:this.projection_matrix,u_eye:[0,0,this.viewport_height??0],u_vanishing_point:[0,0]}):(e.uniform("Matrix4fv","u_projection",this.projection_matrix),e.uniform("3fv","u_eye",[0,0,this.viewport_height??0]),e.uniform("2fv","u_vanishing_point",[0,0]))}},Pu=class extends Xs{constructor(e,r,i={}){super(e,r,i),this.type="flat"}update(){this.axis.x=0,this.axis.y=0,super.update()}};var Gi=class t extends Wt{constructor(e,r={}){super(e,{...r,cameraFactory:Vr.create})}static create(e,r={}){return new t(e,r)}};var hr=class t{resolveSelectionPoint(e,r={},i=this.activeRenderViewId){if(![e.x,e.y].every(Number.isFinite))throw new Error("Selection coordinates must be finite");if(r.coordinateSpace!==void 0&&!["view","canvas"].includes(r.coordinateSpace))throw new Error("Selection coordinateSpace must be view or canvas");let n=a=>e.x>=a.viewport.x&&e.y>=a.viewport.y&&e.x<a.viewport.x+a.viewport.width&&e.y<a.viewport.y+a.viewport.height,o=r.renderViewId!==void 0?this.getRenderView(r.renderViewId):r.coordinateSpace==="canvas"?[...this.renderViews].reverse().find(n):this.getRenderView(i);if(!o)return null;let s=r.coordinateSpace==="canvas"?{x:e.x-o.viewport.x,y:e.y-o.viewport.y}:{...e};return s.x<0||s.y<0||s.x>=o.viewport.width||s.y>=o.viewport.height?null:{view:o,pixel:s}}viewport;geographicAnchor;projection;renderViews;activeRenderViewId;tileBuffer;tileZoom;tileLOD;tileResources;globePreloadZoom;animationTime;constructor(e){let r=Mt(e,"HostFrame");if(this.viewport=Ys(r.viewport,"HostFrame viewport"),this.geographicAnchor=jn(r.geographicAnchor),this.projection=Js(r.projection),this.tileBuffer=Gn(r.tileBuffer??0,"tileBuffer"),this.tileZoom=sg(r.tileZoom,this.geographicAnchor.zoom),this.tileLOD=og(r.tileLOD),this.projection.type==="projected"&&(this.tileLOD||this.tileZoom===void 0||this.tileZoom>6))throw new Error("HostFrame CPU projection requires explicit tileZoom <= 6 and does not support automatic LOD");if(this.tileResources=ig(r.tileResources),this.globePreloadZoom=ng(r.globePreloadZoom),this.globePreloadZoom!==void 0&&this.projection.type!=="globe")throw new Error("HostFrame globePreloadZoom requires a globe projection");if(this.tileZoom!==void 0&&this.tileLOD!==void 0)throw new Error("HostFrame tileZoom and tileLOD are mutually exclusive");if(this.animationTime=r.animationTime===void 0?void 0:Gn(r.animationTime,"animationTime"),!Array.isArray(r.renderViews)||r.renderViews.length===0)throw new Error("HostFrame requires at least one render view");let i=new Set;this.renderViews=r.renderViews.map((n,o)=>{let s=Mt(n,`HostFrame render view ${o}`),a=typeof s.id=="string"&&s.id?s.id:o===0?"default":`view-${o}`;if(i.has(a))throw new Error(`HostFrame render view id '${a}' is duplicated`);i.add(a);let l=s.projection===void 0?void 0:Js(s.projection);if(l&&l.type!==this.projection.type)throw new Error("HostFrame render views must share a projection type");if(l?.type==="globe"&&this.projection.type==="globe"&&this.projection.maxElevation!==void 0){if(l.maxElevation===void 0)l.maxElevation=this.projection.maxElevation;else if(l.maxElevation<this.projection.maxElevation)throw new Error("HostFrame render-view maxElevation cannot lower the shared scene bound")}return{id:a,viewport:Ys(s.viewport??this.viewport,`HostFrame render view '${a}' viewport`),camera:ag(s.camera,a),geographicAnchor:s.geographicAnchor===void 0?void 0:jn(s.geographicAnchor),projection:l}}),this.activeRenderViewId=typeof r.activeRenderViewId=="string"&&r.activeRenderViewId||this.renderViews[0].id,this.getRenderView()}static from(e){if(e instanceof t)return e;let r=Mt(e,"HostFrame");return r.renderViews!==void 0||r.geographicAnchor!==void 0?t.createValidated(r):t.fromLegacy(r)}static fromLegacy(e){let r=Mt(e,"HostFrame");return t.createValidated({...r,geographicAnchor:r.view,renderViews:[{id:"default",viewport:r.viewport,camera:r.camera}]})}getRenderView(e=this.activeRenderViewId){let r=this.renderViews.find(i=>i.id===e);if(!r)throw new Error(`HostFrame render view '${e}' was not found`);return r}static createValidated(e){let r=Ys(e.viewport,"HostFrame viewport");if(!Array.isArray(e.renderViews)||e.renderViews.length===0)throw new Error("HostFrame requires at least one render view");return new t({viewport:r,geographicAnchor:jn(e.geographicAnchor),projection:Js(e.projection),renderViews:e.renderViews.map((i,n)=>{let o=Mt(i,`HostFrame render view ${n}`);return{id:typeof o.id=="string"?o.id:void 0,viewport:Ys(o.viewport??r,"HostFrame render view viewport"),camera:ag(o.camera,String(n)),geographicAnchor:o.geographicAnchor===void 0?void 0:jn(o.geographicAnchor),projection:o.projection===void 0?void 0:Js(o.projection)}}),activeRenderViewId:typeof e.activeRenderViewId=="string"?e.activeRenderViewId:void 0,tileBuffer:Gn(e.tileBuffer??0,"tileBuffer"),tileZoom:sg(e.tileZoom,jn(e.geographicAnchor).zoom),tileLOD:og(e.tileLOD),tileResources:ig(e.tileResources),globePreloadZoom:ng(e.globePreloadZoom),animationTime:e.animationTime===void 0?void 0:Gn(e.animationTime,"animationTime")})}};function ig(t){if(t===void 0)return;let e=Mt(t,"HostFrame tileResources"),r={};for(let i of["maxConcurrentBuilds","maxCachedTiles","maxCachedMeshBytes"]){let n=e[i];if(n!==void 0){if(typeof n!="number"||!Number.isSafeInteger(n)||n<(i==="maxConcurrentBuilds"?1:0))throw new Error(`HostFrame tileResources ${i} must be a ${i==="maxConcurrentBuilds"?"positive":"non-negative"} safe integer`);r[i]=n}}return Object.freeze(r)}function ng(t){if(t!==void 0){if(typeof t!="number"||!Number.isInteger(t)||t<0||t>3)throw new Error("HostFrame globePreloadZoom must be an integer from 0 to 3");return t}}function og(t){if(t===void 0)return;let e=Mt(t,"HostFrame tileLOD"),r=e.targetTilePixels??512,i=e.pixelRatio??1,n=e.maxTiles??256,o=e.hysteresis??.2;if(!ct(r)||r<=0||!ct(i)||i<=0||!ct(n)||!Number.isSafeInteger(n)||n<1||!ct(o)||o<0||o>=1)throw new Error("HostFrame tileLOD requires positive pixel scales, a positive integer maxTiles, and hysteresis in [0, 1)");return{targetTilePixels:r,pixelRatio:i,maxTiles:n,hysteresis:o}}function sg(t,e){if(t!==void 0){if(typeof t!="number"||!Number.isInteger(t)||t<0||t>22||t>Math.floor(e))throw new Error("HostFrame tileZoom must be an integer from 0 to 22, no higher than the shared style zoom");return t}}function Mt(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} requires an object`);return Object.fromEntries(Object.entries(t))}function Ys(t,e){let r=t&&typeof t=="object"?Mt(t,e):{};if(!ct(r.width)||r.width<=0||!ct(r.height)||r.height<=0)throw new Error(`${e} requires positive width and height`);return{x:ku(r.x,0),y:ku(r.y,0),width:r.width,height:r.height}}function jn(t){let e=t&&typeof t=="object"?Mt(t,"HostFrame geographic anchor"):{};if(!ct(e.longitude)||!ct(e.latitude)||!ct(e.zoom))throw new Error("HostFrame geographic anchor requires finite longitude, latitude, and zoom");return{longitude:e.longitude,latitude:e.latitude,zoom:e.zoom,altitude:ku(e.altitude,0)}}function Js(t){let e=t===void 0?{}:Mt(t,"HostFrame projection"),r=t===void 0?"web-mercator":e.type;if(r==="web-mercator"||r==="projected"){if(r==="projected"&&(e.visibleBounds===void 0||e.visibleBounds===null))throw new Error("HostFrame CPU projection requires an explicit geographic footprint");if(r==="web-mercator"&&e.visibleBounds===void 0)return{type:r};if(r==="web-mercator"&&e.visibleBounds===null)return{type:r,visibleBounds:null};let n=e.visibleBounds;if(!Array.isArray(n)||n.length!==4||!n.every(ct)||n[0]>n[2]||n[1]>n[3]||n[1]<=-90||n[3]>=90)throw new Error("HostFrame planar projection requires finite ordered visibleBounds with latitudes strictly between -90 and 90");if(r==="projected"&&(n[0]<-180||n[2]>180||n[1]<-85.0511287798066||n[3]>85.0511287798066))throw new Error("HostFrame CPU projection footprint must stay inside the finite single-world tile domain");return{type:r,visibleBounds:[n[0],n[1],n[2],n[3]]}}if(r!=="globe")throw new Error(`HostFrame projection type '${String(r)}' is invalid`);let i=e.visibleBounds;if(!Array.isArray(i)||i.length!==4||!i.every(ct))throw new Error("HostFrame globe projection requires finite visibleBounds");return{type:r,visibleBounds:[i[0],i[1],i[2],i[3]],...e.maxElevation===void 0?{}:{maxElevation:Gn(e.maxElevation,"maxElevation")}}}function ag(t,e){let r=t&&typeof t=="object"?Mt(t,"HostFrame camera"):{},i=Lu(r.view,16),n=Lu(r.projection,16),o=Lu(r.position,3);if(!i||!n||!o)throw new Error(`HostFrame render view '${e}' requires finite camera matrices and position`);let s=new Float32Array(n);if(!s.every(Number.isFinite))throw new Error(`HostFrame render view '${e}' requires finite camera matrices and position`);return{view:new Float64Array(i),projection:s,position:[o[0],o[1],o[2]]}}function Lu(t,e){if(!Array.isArray(t)&&!(t instanceof Float32Array)&&!(t instanceof Float64Array))return null;let r=Array.from(t);return r.length===e&&r.every(ct)?r:null}function ct(t){return typeof t=="number"&&Number.isFinite(t)}function ku(t,e){return ct(t)?t:e}function Gn(t,e){if(!ct(t)||t<0)throw new Error(`HostFrame ${e} must be a finite non-negative number`);return t}var Qv=["Buffer","Texture","TextureView","ExternalTexture","Sampler"],ew=["Buffer"];function lg(t){return t.startsWith("depth")||t.startsWith("stencil")}function tw(t,e){return ug(t,e,Qv)?!0:"buffer"in t&&ug(t.buffer,e,ew)&&(!("offset"in t)||t.offset===void 0||typeof t.offset=="number")&&(!("size"in t)||t.size===void 0||typeof t.size=="number")}function ug(t,e,r){if(!t||typeof t!="object"||!("device"in t)||t.device!==e||!("destroy"in t)||typeof t.destroy!="function")return!1;let i=Reflect.get(t,Symbol.toStringTag);return typeof i=="string"&&r.includes(i)}var dr=class{bindingResources=new WeakMap;constructor(e){rw(e),this.device=e,this.pipeline_cache=new WeakMap,this.mesh_resource_cache=new WeakMap,this.program_resources=new Set,this.mesh_resources=new Set,this.destroyed=!1}get shaderLanguage(){return this.device.info.shadingLanguage}get maxTextureSize(){return this.device.limits&&this.device.limits.maxTextureDimension2D}getSceneOptions(){return this.assertAlive(),{enableUniformBuffers:!0,deviceShaderCompilation:!0,shaderLanguage:this.shaderLanguage,uniformBufferFactory:e=>this.createUniformBuffer(e),shaderFactory:e=>this.createShader(e),shaderProgramValidator:e=>this.validateShaderProgram(e),meshBufferFactory:e=>this.createMeshBuffer(e),textureFactory:e=>this.createTexture(e),maxTextureSize:this.maxTextureSize,meshRenderer:this}}createUniformBuffer(e){if(this.assertAlive(),e.usage!=="uniform")throw new Error(`unsupported Tangram buffer usage '${e.usage}'`);let r=this.device.createBuffer({id:`tangram-${e.id}`,byteLength:e.byteLength,usage:at.UNIFORM|at.COPY_DST});return this.bindingResources.set(r,r),r}createShader(e){this.assertAlive();let r={id:`tangram-${e.id}`,language:e.language||this.device.info.shadingLanguage,stage:e.stage,source:e.source};return e.entryPoint&&(r.entryPoint=e.entryPoint),this.device.createShader(r)}validateShaderProgram({id:e,vertexShader:r,fragmentShader:i}){if(this.assertAlive(),this.device.type==="webgl")return;let n=this.device.createRenderPipeline({id:`tangram-${e}-validation`,vs:r,fs:i,topology:"triangle-list",bufferLayout:[],disableWarnings:!0});try{if(n.isErrored)throw new Error(`Tangram shader program '${e}' failed device link validation`)}finally{n.destroy()}}createMeshBuffer(e){this.assertAlive();let r=e.usage==="vertex"?at.VERTEX:e.usage==="index"?at.INDEX:null;if(r==null)throw new Error(`unsupported Tangram mesh buffer usage '${e.usage}'`);let i={id:`tangram-${e.id}`,usage:r|at.COPY_DST,data:e.data};return e.indexType&&(i.indexType=e.indexType),this.device.createBuffer(i)}createTexture(e){this.assertAlive();let r=e.filtering==="mipmap"&&this.device.type==="webgl",i=e.filtering==="nearest"?"nearest":"linear",n=this.device.createTexture({id:`tangram-${e.id}`,width:e.width,height:e.height,format:"rgba8unorm",usage:Pt.COPY_DST|Pt.SAMPLE|Pt.RENDER,mipLevels:r?Math.floor(Math.log2(Math.max(e.width,e.height)))+1:1,sampler:{minFilter:i,magFilter:i,mipmapFilter:r?"linear":"none",addressModeU:e.repeat?"repeat":"clamp-to-edge",addressModeV:e.repeat?"repeat":"clamp-to-edge"}});this.bindingResources.set(n,n);try{return e.data!=null&&(ArrayBuffer.isView(e.data)||e.data instanceof ArrayBuffer?n.writeData(e.data,{width:e.width,height:e.height}):n.copyExternalImage({image:e.data,width:e.width,height:e.height,flipY:e.flipY,premultipliedAlpha:e.premultipliedAlpha}),r&&n.generateMipmapsWebGL()),n}catch(o){throw n.destroy(),o}}getRenderPipelineParameters({depthTest:e,depthWrite:r,cullFace:i,blend:n}){let o={cullMode:i?"back":"none",depthCompare:e?"less":"always",depthWriteEnabled:r,blend:!!(n&&n!=="opaque")};return n==="overlay"||n==="inlay"||n==="translucent"?Object.assign(o,{blendColorOperation:"add",blendColorSrcFactor:"src-alpha",blendColorDstFactor:"one-minus-src-alpha",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha"}):n==="add"?Object.assign(o,{blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}):n==="multiply"&&Object.assign(o,{blendColorOperation:"add",blendColorSrcFactor:"zero",blendColorDstFactor:"src",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha"}),o}drawMesh({mesh:e,program:r,renderPass:i,renderState:n,visibleTime:o}){if(this.assertAlive(),!i||!r||!r.vertex_shader_resource||!r.fragment_shader_resource)throw new Error("Tangram luma renderer requires an active render pass and shader resources");let s=e.getDrawDescriptor(),a=this.getPipeline(r,e.vertex_layout,s,n,i);e.uniforms&&(r.saveUniforms(e.uniforms),r.setUniforms(e.uniforms,!1));try{r.uniform("1f","u_visible_time",o);let l=r.getBindings();this.snapshotMeshUniformBindings(e,r,l);let u={};for(let[f,p]of Object.entries(l)){let m=this.bindingResources.get(p);if(m)u[f]=m;else if(tw(p,this.device))u[f]=p;else throw new Error(`Tangram binding '${f}' requires a native luma resource`)}iw(a,u);let c=this.getVertexArray(e,a,s);i.setPipeline(a),i.setBindings(u),i.setVertexArray(c);let h=r.getUniformValues();return i.draw({vertexCount:s.indexBuffer?void 0:s.vertexCount,indexCount:s.indexBuffer?s.indexCount:void 0,uniforms:this.device.type==="webgl"?h:void 0})===!1&&a.isPending===!0}finally{e.uniforms&&r.restoreUniforms(e.uniforms)}}destroy(){if(!this.destroyed){this.destroyed=!0;for(let e of this.mesh_resources)this.disposeMeshResources(e);for(let e of this.program_resources)this.disposeProgramResources(e);this.pipeline_cache=new WeakMap,this.mesh_resource_cache=new WeakMap}}snapshotMeshUniformBindings(e,r,i){let n=r.uniform_blocks||{},o=Object.entries(n).filter(a=>a[1].snapshot_per_mesh&&!!a[1].data);if(o.length===0)return;let s=this.getMeshResources(e).uniformBuffers;for(let[a,l]of o){let u=s.get(a);if(!u||u.byteLength!==l.byteLength){let c=this.device.createBuffer({id:`tangram-mesh-${e.id}-${a}-uniforms`,byteLength:l.byteLength,usage:at.UNIFORM|at.COPY_DST});this.bindingResources.set(c,c),u?.buffer.destroy(),u={buffer:c,byteLength:l.byteLength},s.set(a,u)}u.buffer.write(new Uint8Array(l.data)),i[a]=u.buffer}}getPipeline(e,r,i,n,o){this.assertAlive();let s=this.getProgramResources(e),a=s.layouts,l=a.get(r);l||(l=new Map,a.set(r,l));let u=l.get(i.topology);u||(u=new Map,l.set(i.topology,u));let c=o?.props?.framebuffer??(this.device.type==="webgpu"&&o?this.device.getDefaultCanvasContext().getCurrentFramebuffer():void 0),h={},d=n;if(this.device.type==="webgpu"&&c){d={...n,sampleCount:c.colorAttachments[0]?.texture.samples??c.depthStencilAttachment?.texture.samples??1,...c.depthStencilAttachment?{}:{depthWriteEnabled:!1,depthCompare:"always"}},h.colorAttachmentFormats=c.colorAttachments.map(g=>{let _=g.texture.format;if(lg(_))throw new Error("Color attachment requires a color texture");return _});let m=c.depthStencilAttachment?.texture.format;if(m!==void 0){if(!lg(m))throw new Error("Depth attachment requires a depth/stencil texture");h.depthStencilAttachmentFormat=m}}let f=JSON.stringify({state:d||{},attachments:h}),p=u.get(f);if(!p){let m={id:`tangram-${e.name||e.id}-${i.topology}-${u.size}`,vs:e.vertex_shader_resource??void 0,fs:e.fragment_shader_resource??void 0,bufferLayout:[i.bufferLayout],topology:i.topology,disableWarnings:!0,...h};d&&(m.parameters=d),p=this.device.createRenderPipeline(m),u.set(f,p),s.pipelines.add(p)}return p}getVertexArray(e,r,i){this.assertAlive();let n=this.getMeshResources(e).vertexArrays,o=n.get(r);if(o)return o;o=this.device.createVertexArray({id:`tangram-mesh-${e.id}-${r.id}`,shaderLayout:r.shaderLayout,bufferLayout:r.bufferLayout});try{let s=new Map(r.shaderLayout.attributes.map(a=>[a.name,a]));for(let a of i.bufferLayout.attributes){let l=s.get(a.attribute);l&&o.setBuffer(l.location,i.vertexBuffer)}for(let a of i.staticAttributes){let l=s.get(a.attribute);if(l){if(this.device.type==="webgpu")throw new Error(`Tangram WebGPU renderer requires '${a.attribute}' in a vertex buffer`);o.setConstantWebGL(l.location,new Float32Array(a.value))}}i.indexBuffer&&o.setIndexBuffer(i.indexBuffer)}catch(s){throw o.destroy(),s}return n.set(r,o),o}getProgramResources(e){let r=this.pipeline_cache.get(e);if(!r||r.disposed){r={layouts:new WeakMap,pipelines:new Set,disposed:!1,unsubscribe:()=>{}};let i=r;r.unsubscribe=ua(e,()=>this.disposeProgramResources(i)),this.pipeline_cache.set(e,r),this.program_resources.add(r)}return r}getMeshResources(e){this.assertAlive();let r=this.mesh_resource_cache.get(e);if(!r||r.disposed){r={vertexArrays:new Map,uniformBuffers:new Map,disposed:!1,unsubscribe:()=>{}};let i=r;r.unsubscribe=ua(e,()=>this.disposeMeshResources(i)),this.mesh_resource_cache.set(e,r),this.mesh_resources.add(r)}return r}disposeMeshResources(e){if(!e.disposed){e.disposed=!0,e.unsubscribe(),this.mesh_resources.delete(e);for(let r of e.vertexArrays.values())r.destroy();for(let r of e.uniformBuffers.values())r.buffer.destroy();e.vertexArrays.clear(),e.uniformBuffers.clear()}}disposeProgramResources(e){if(!e.disposed){e.disposed=!0,e.unsubscribe(),this.program_resources.delete(e);for(let r of this.mesh_resources)for(let[i,n]of r.vertexArrays)e.pipelines.has(i)&&(n.destroy(),r.vertexArrays.delete(i));for(let r of e.pipelines)r.destroy();e.pipelines.clear(),e.layouts=new WeakMap}}assertAlive(){if(this.destroyed)throw new Error("Tangram GPU backend has been destroyed")}};function rw(t){if(!t||!t.info||typeof t.createBuffer!="function"||typeof t.createShader!="function"||typeof t.createTexture!="function"||typeof t.createRenderPipeline!="function"||typeof t.createVertexArray!="function")throw new Error("Tangram requires a luma.gl Device")}function iw(t,e){for(let r of t.shaderLayout.bindings){if(r.type==="sampler"&&r.name.endsWith("Sampler")){let i=r.name.slice(0,-7);if(e[i])continue}if(r.type!=="uniform"&&r.type!=="texture"&&r.type!=="sampler")throw new Error(`Tangram luma renderer does not support '${r.type}' bindings`);if(!e[r.name])throw new Error(`Tangram luma renderer is missing '${r.name}' binding`)}}function Un(t,e){if(t.length!==e)throw new RangeError("Query dimension must match the index");for(let r=0;r<e;r++)if(!Number.isFinite(t[r]))throw new RangeError("Coordinates must be finite")}function hg(t){if(Number.isNaN(t)||t<0)throw new RangeError("Distance must be nonnegative")}function Vn(t,e,r,i,n=1/0){let o=t.length;if(o!==2&&o!==3)throw new RangeError("Bounds must be 2D or 3D");Un(t,o),Un(e,o),Un(r,o),Un(i,o),hg(n);let s=0,a=n,l=!1;for(let u=0;u<o;u++){if(r[u]>i[u])throw new RangeError("Bounds must be ordered");l||(l=e[u]!==0)}if(!l)throw new RangeError("Ray direction must be nonzero");for(let u=0;u<o;u++){if(e[u]===0){if(t[u]<r[u]||t[u]>i[u])return null;continue}let c=(r[u]-t[u])/e[u],h=(i[u]-t[u])/e[u];if(c>h&&([c,h]=[h,c]),s=Math.max(s,c),a=Math.min(a,h),s>a)return null}return Number.isFinite(s)?s:null}function Qs(t,e,r,i,n,o={}){for(let g of[t,e,r,i,n])Un(g,3);if(e[0]===0&&e[1]===0&&e[2]===0)throw new RangeError("Ray direction must be nonzero");let s=o.maxT??1/0;hg(s);let a=[i[0]-r[0],i[1]-r[1],i[2]-r[2]],l=[n[0]-r[0],n[1]-r[1],n[2]-r[2]],u=cg(e,l),c=Ks(a,u);if(c===0||o.backfaceCulling&&c<0)return null;let h=[t[0]-r[0],t[1]-r[1],t[2]-r[2]],d=Ks(h,u)/c;if(d<0||d>1)return null;let f=cg(h,a),p=Ks(e,f)/c;if(p<0||d+p>1)return null;let m=Ks(l,f)/c;return!Number.isFinite(m)||m<0||m>s?null:{t:Math.max(0,m),barycentric:[1-d-p,d,p]}}function Ks(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function cg(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}var Ui=class t{static getRequiredHierarchyBytes(e,r=8){if(!Number.isSafeInteger(e)||e<0||e>4294967295||!Number.isSafeInteger(r)||r<1||r>64)throw new Error("Invalid triangle hierarchy dimensions");let i=new Map,n=o=>{if(!o)return 0;if(o<=r)return 1;let s=i.get(o);if(s!==void 0)return s;let a=Math.floor(o/2),l=1+n(a)+n(o-a);return i.set(o,l),l};return e*4+n(e)*64}triangleCount;geometryBytes;requiredHierarchyBytes;positions;indices;order;bounds;topology;preparing;leafSize;nodeCount;hierarchyAllowed;deferBuild;minimum=[1/0,1/0,1/0];maximum=[-1/0,-1/0,-1/0];constructor(e,r,i=8,n={}){if(!Number.isSafeInteger(e.length)||!Number.isSafeInteger(r.length)||e.length%3||r.length%3||!Number.isSafeInteger(i)||i<1||i>64)throw new Error("Invalid triangle index dimensions or leaf size");if(r.length/3>4294967295)throw new Error("Triangle positions and indices must be finite and in range");if(n.maxHierarchyBytes!==void 0&&(!Number.isSafeInteger(n.maxHierarchyBytes)||n.maxHierarchyBytes<0))throw new Error("Triangle hierarchy byte limit must be a non-negative integer");this.positions=Float64Array.from(e);for(let o=0;o<this.positions.length;o++)if(!Number.isFinite(this.positions[o]))throw new Error("Triangle positions and indices must be finite and in range");this.indices=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let s=r[o];if(!Number.isSafeInteger(s)||s<0||s>=this.positions.length/3||s>4294967295)throw new Error("Triangle positions and indices must be finite and in range");this.indices[o]=s}this.triangleCount=r.length/3,this.leafSize=i,this.requiredHierarchyBytes=t.getRequiredHierarchyBytes(this.triangleCount,i),this.nodeCount=(this.requiredHierarchyBytes-this.triangleCount*4)/64,this.geometryBytes=this.positions.byteLength+this.indices.byteLength,this.hierarchyAllowed=this.requiredHierarchyBytes<=(n.maxHierarchyBytes??1/0),this.deferBuild=n.deferBuild??!1;for(let o=0;o<this.positions.length;o++){let s=o%3;this.minimum[s]=Math.min(this.minimum[s],this.positions[o]),this.maximum[s]=Math.max(this.maximum[s],this.positions[o])}!n.lazy&&this.hierarchyAllowed&&this.buildHierarchy()}get arrayBytes(){return this.geometryBytes+this.hierarchyBytes}get hierarchyBytes(){return this.preparing?this.requiredHierarchyBytes:(this.order?.byteLength??0)+(this.bounds?.byteLength??0)+(this.topology?.byteLength??0)}getBounds(){return this.positions.length?{minimum:[...this.minimum],maximum:[...this.maximum]}:null}*prepareHierarchySteps(){if(this.order||this.preparing||!this.hierarchyAllowed||!this.triangleCount)return;let e={order:new Uint32Array(this.triangleCount),bounds:new Float64Array(this.nodeCount*6),topology:new Uint32Array(this.nodeCount*4)};this.preparing=e;try{for(let r=0;r<e.order.length;r++)e.order[r]=r,r%128===127&&(yield);yield*this.buildNodeSteps(e,0,this.triangleCount,{next:0}),this.bounds=e.bounds,this.topology=e.topology,this.order=e.order}finally{this.preparing=void 0}}getTriangleVertex(e,r){return{index:this.getVertexIndex(e,r),position:this.getVertex(e,r)}}getVertexIndex(e,r){if(!Number.isSafeInteger(e)||e<0||e>=this.triangleCount||!Number.isSafeInteger(r)||r<0||r>2)throw new Error("Triangle vertex is out of range");return this.indices[e*3+r]}queryRay(e,r,i=1/0,n){if(i<0||Number.isNaN(i))throw new Error("Triangle ray limit must be non-negative");let o={hit:null,testedBounds:0,testedTriangles:0},s=Math.hypot(...r);if(e.length!==3||r.length!==3||!e.every(Number.isFinite)||!r.every(Number.isFinite)||!Number.isFinite(s)||s===0||!this.triangleCount||Vn(e,r,this.minimum,this.maximum,i)===null)return o;this.hierarchyAllowed&&!this.deferBuild&&!this.order&&!this.preparing&&this.buildHierarchy();let a=u=>{o.testedTriangles++;let c=Qs(e,r,this.getVertex(u,0),this.getVertex(u,1),this.getVertex(u,2),{maxT:o.hit?.parameter??i});if(c&&(!o.hit||c.t<o.hit.parameter||c.t===o.hit.parameter&&u<o.hit.triangleIndex)){let h={triangleIndex:u,parameter:c.t,barycentric:c.barycentric};(!n||n(h))&&(o.hit=h)}};if(!this.order){for(let u=0;u<this.triangleCount;u++)a(u);return o}let l=[{index:0,near:0}];for(o.testedBounds++;l.length;){let{index:u,near:c}=l.pop();if(c>(o.hit?.parameter??i))continue;let h=this.readNode(u);if(h.children){let d=h.children.flatMap(f=>{let p=this.readNode(f);o.testedBounds++;let m=Vn(e,r,p.minimum,p.maximum,o.hit?.parameter??i);return m===null?[]:[{index:f,near:m}]});d.sort((f,p)=>p.near-f.near||p.index-f.index),l.push(...d);continue}for(let d=h.start;d<h.end;d++)a(this.order[d])}return o}buildHierarchy(){for(let e of this.prepareHierarchySteps());}readNode(e){let r=this.bounds,i=this.topology,n=e*4;return{minimum:[r[e*6],r[e*6+1],r[e*6+2]],maximum:[r[e*6+3],r[e*6+4],r[e*6+5]],start:i[n],end:i[n+1],children:i[n+2]?[i[n+2],i[n+3]]:void 0}}getVertex(e,r){let i=this.indices[e*3+r]*3;return[this.positions[i],this.positions[i+1],this.positions[i+2]]}*buildNodeSteps(e,r,i,n){let{order:o,bounds:s,topology:a}=e,l=[1/0,1/0,1/0],u=[-1/0,-1/0,-1/0];for(let h=r;h<i;h++){for(let d=0;d<3;d++){let f=this.indices[o[h]*3+d]*3;for(let p=0;p<3;p++){let m=this.positions[f+p];l[p]=Math.min(l[p],m),u[p]=Math.max(u[p],m)}}(h-r)%128===127&&(yield)}let c=n.next++;if(s.set([...l,...u],c*6),a.set([r,i],c*4),i-r>this.leafSize){let h=0;for(let g=1;g<3;g++)u[g]-l[g]>u[h]-l[h]&&(h=g);let d=g=>(this.positions[this.indices[g*3]*3+h]+this.positions[this.indices[g*3+1]*3+h]+this.positions[this.indices[g*3+2]*3+h])/3,f=r+Math.floor((i-r)/2);yield*this.partitionSteps(o,f,r,i-1,(g,_)=>d(g)-d(_)||g-_);let p=yield*this.buildNodeSteps(e,r,f,n),m=yield*this.buildNodeSteps(e,f,i,n);a.set([p,m],c*4+2)}return yield,c}*partitionSteps(e,r,i,n,o){let s=0;for(;i<n;){let a=e[i+Math.floor((n-i)/2)],l=i,u=n;for(;l<=u;){for(;o(e[l],a)<0;)l++,++s%128===0&&(yield);for(;o(e[u],a)>0;)u--,++s%128===0&&(yield);if(l<=u){let c=e[l];e[l++]=e[u],e[u--]=c}++s%128===0&&(yield)}if(r<=u)n=u;else if(r>=l)i=l;else return}}};var Vi=class{projection;entries;constructor(e,r){if(!["web-mercator","globe"].includes(e))throw new Error("Terrain collection projection must be web-mercator or globe");if(this.projection=e,this.entries=r.map(({id:i,surface:n})=>{if(typeof i!="string"||!i.length||n.projection!==e)throw new Error("Terrain collection requires nonempty IDs and matching projections");return Object.freeze({id:i,surface:n})}),new Set(this.entries.map(i=>i.id)).size!==this.entries.length)throw new Error("Terrain collection IDs must be unique")}intersectRay(e,r=1/0){if(r<0||Number.isNaN(r))throw new Error("Terrain ray distance must be non-negative");let i=Math.hypot(...e.direction);if(e.origin.length!==3||e.direction.length!==3||!e.origin.every(Number.isFinite)||!e.direction.every(Number.isFinite)||!Number.isFinite(i)||i===0)return null;let n=e.direction.map(l=>l/i),o=this.entries.flatMap((l,u)=>{if(!l.surface.getBounds)return[{entry:l,index:u,distance:0}];let c=l.surface.getBounds();if(!c)return[];let h=Vn(e.origin,n,c.minimum,c.maximum,r);return h===null?[]:[{entry:l,index:u,distance:h}]}).sort((l,u)=>l.distance-u.distance||l.index-u.index),s=null,a=1/0;for(let{entry:l,index:u,distance:c}of o){if(c>(s?.distance??r))break;let h=l.surface.intersectRay(e,s?.distance??r);h&&(!s||h.distance<s.distance||h.distance===s.distance&&u<a)&&(s={...h,surfaceId:l.id},a=u)}return s}intersectSegment(e,r,i={}){let n=i.startInset??0,o=i.endInset??0;if(e.length!==3||r.length!==3||!e.every(Number.isFinite)||!r.every(Number.isFinite)||![n,o].every(c=>Number.isFinite(c)&&c>=0))throw new Error("Terrain segment requires finite endpoints and non-negative finite insets");let s=[r[0]-e[0],r[1]-e[1],r[2]-e[2]],a=Math.hypot(...s);if(!Number.isFinite(a))throw new Error("Terrain segment length must be finite");if(a===0||n+o>=a)return null;let l=[e[0]+s[0]*n/a,e[1]+s[1]*n/a,e[2]+s[2]*n/a],u=this.intersectRay({origin:l,direction:s},a-n-o);return u?{...u,distance:u.distance+n}:null}};function Cu(t,e,r){if(e.length!==2||!e.every(Number.isFinite)||Math.abs(e[1])>90||![r.minimumAltitude,r.maximumAltitude].every(Number.isFinite)||r.minimumAltitude>=r.maximumAltitude||r.anchorLongitude!==void 0&&!Number.isFinite(r.anchorLongitude))throw new Error("Invalid terrain elevation probe");let i=et(t.projection);if(Math.abs(e[1])>i.latitudeLimit)return null;if(t.projection==="globe"&&r.minimumAltitude<=-ae.earthRadius)throw new Error("Globe elevation probes must remain above the center");let n=i.project([e[0],e[1],r.maximumAltitude],r.anchorLongitude),o=i.project([e[0],e[1],r.minimumAltitude],r.anchorLongitude),s=[o[0]-n[0],o[1]-n[1],o[2]-n[2]];if(!n.every(Number.isFinite)||!o.every(Number.isFinite)||!Number.isFinite(Math.hypot(...s)))throw new Error("Terrain elevation probe exceeds finite projection range");return t.intersectRay({origin:n,direction:s},Math.hypot(...s))}function dg(t,e,r,i){if(t.projection!=="web-mercator")throw new Error("Terrain clearance requires a physical-meter Mercator frame");if(e.length!==3||!e.every(Number.isFinite)||!Number.isFinite(r)||r<0)throw new Error("Invalid terrain clearance");let n=Cu(t,[e[0],e[1]],i);if(!n)return null;let o=Math.max(e[2],n.position[2]+r);if(!Number.isFinite(o))throw new Error("Terrain clearance exceeds finite altitude range");return{coordinate:[e[0],e[1],o],physicalElevation:n.coordinate[2],adjusted:o>e[2]}}var $i=class{projection;physicalHeights;cullBackfaces;queryIndex;constructor(e){if(!["web-mercator","globe"].includes(e.projection))throw new Error("Terrain projection must be web-mercator or globe");if(e.positions.length%3||e.indices.length%3)throw new Error("Terrain requires XYZ positions and triangle indices");this.projection=e.projection;try{this.queryIndex=new Ui(e.positions,e.indices,8,{lazy:!0,maxHierarchyBytes:e.maxQueryIndexBytes,deferBuild:e.deferQueryIndexBuild})}catch(i){throw new Error(`Terrain mesh: ${i instanceof Error?i.message:String(i)}`)}this.cullBackfaces=e.cullBackfaces??!1;let r=e.physicalHeights;if(r){if(r.length!==e.positions.length/3)throw new Error("Terrain physical heights must match indexed vertices");this.physicalHeights=Float64Array.from(r);for(let i=0;i<this.queryIndex.triangleCount;i++)for(let n=0;n<3;n++)if(!Number.isFinite(this.physicalHeights[this.queryIndex.getVertexIndex(i,n)]))throw new Error("Terrain physical heights must match indexed vertices")}}getStatistics(){return{geometryBytes:this.queryIndex.geometryBytes+(this.physicalHeights?.byteLength??0),queryIndexBytes:this.queryIndex.hierarchyBytes,requiredQueryIndexBytes:this.queryIndex.requiredHierarchyBytes}}*prepareQueryIndexSteps(){yield*this.queryIndex.prepareHierarchySteps()}getBounds(){return this.queryIndex.getBounds()}intersectRay(e,r=1/0,i){if(r<0||Number.isNaN(r))throw new Error("Terrain ray distance must be non-negative");let n=Math.hypot(...e.direction);if(e.origin.length!==3||e.direction.length!==3||!e.origin.every(Number.isFinite)||!e.direction.every(Number.isFinite)||!Number.isFinite(n)||n===0||!this.queryIndex.triangleCount)return null;let o=[e.direction[0]/n,e.direction[1]/n,e.direction[2]/n],s=this.queryIndex.queryRay(e.origin,o,r,f=>{if(i&&!i([e.origin[0]+o[0]*f.parameter,e.origin[1]+o[1]*f.parameter,e.origin[2]+o[2]*f.parameter],f.triangleIndex,f.barycentric)||this.projection==="globe"&&Math.hypot(e.origin[0]+o[0]*f.parameter,e.origin[1]+o[1]*f.parameter,e.origin[2]+o[2]*f.parameter)===0)return!1;if(!this.cullBackfaces)return!0;let p=[0,1,2].map(_=>this.queryIndex.getTriangleVertex(f.triangleIndex,_).position),m=new it(p[0]);return new it(p[1]).subtract(m).cross(new it(p[2]).subtract(m)).dot(o)<0}).hit;if(!s)return null;let a=s.triangleIndex*3,l=[0,1,2].map(f=>this.queryIndex.getTriangleVertex(s.triangleIndex,f).position),u=[e.origin[0]+o[0]*s.parameter,e.origin[1]+o[1]*s.parameter,e.origin[2]+o[2]*s.parameter],c=new it(l[1]).subtract(l[0]).cross(new it(l[2]).subtract(l[0])).normalize(),h=et(this.projection).unproject(u),d=this.physicalHeights;return d&&(h[2]=s.barycentric.reduce((f,p,m)=>f+p*d[this.queryIndex.getVertexIndex(s.triangleIndex,m)],0)),{position:u,coordinate:h,distance:s.parameter,normal:[c[0],c[1],c[2]],triangleIndex:a/3,barycentric:s.barycentric}}};function ea(t,e,r,i={},n){if(r.projection!==t.projection.type)throw new Error("Terrain surface and HostFrame projection must match");if(![e.x,e.y].every(Number.isFinite))throw new Error("Terrain query pixels must be finite");if(i.radius!==void 0&&i.radius!==0)throw new Error("Terrain queries select one ray, not a pixel radius");let o=t.resolveSelectionPoint(e,i,n);if(!o)return null;let{view:s,pixel:a}=o,l=new Oe(Array.from(s.camera.projection));r.projection!=="globe"&&l.multiplyRight(Array.from(s.camera.view));let u=l.determinant();if(!Number.isFinite(u)||u===0)return null;l.invert();let c=2*a.x/s.viewport.width-1,h=1-2*a.y/s.viewport.height,d=[-1,1].map(g=>l.transform([c,h,g,1]));if(d.some(g=>!g.every(Number.isFinite)||g[3]===0))return null;let f=[d[0][0]/d[0][3],d[0][1]/d[0][3],d[0][2]/d[0][3]],p=[d[1][0]/d[1][3]-f[0],d[1][1]/d[1][3]-f[1],d[1][2]/d[1][3]-f[2]],m=r.intersectRay({origin:f,direction:p},Math.hypot(...p));return m?{...m,renderViewId:s.id}:null}var zu=new WeakSet,fg=new WeakSet,$n=class{projection;mesh;blend;exaggeration;constructor(e,r,i,n){if(this.mesh=e,this.projection=r,this.blend=i,this.exaggeration=n,e.indices.length%3||!e.positions.every(Number.isFinite)||e.indices.some(o=>o>=e.positions.length/3||!Number.isFinite(e.heights[o*2])||!Number.isFinite(e.heights[o*2+1])))throw new Error("Terrain mesh: triangle positions, indices and physical heights must be finite and in range")}getStatistics(){return{geometryBytes:0,queryIndexBytes:0}}intersectRay(e,r=1/0,i){if(r<0||Number.isNaN(r))throw new Error("Terrain ray distance must be non-negative");let n=Math.hypot(...e.direction);if(e.origin.length!==3||e.direction.length!==3||!e.origin.every(Number.isFinite)||!e.direction.every(Number.isFinite)||!Number.isFinite(n)||n===0)return null;let o=[e.direction[0]/n,e.direction[1]/n,e.direction[2]/n],s=et("web-mercator"),a=et(this.projection),l=null;for(let u=0;u<this.mesh.indices.length/3;u++){let c=[],h=[0,1,2].map(g=>{let _=this.mesh.indices[u*3+g],x=_*3,v=this.mesh.heights[_*2],A=this.mesh.heights[_*2+1],w=A+(v-A)*this.blend;c.push(this.mesh.positions[x+2]+w);let E=[this.mesh.positions[x],this.mesh.positions[x+1],this.mesh.positions[x+2]+w*this.exaggeration];return this.projection==="globe"?this.mesh.globeBasis?nl(this.mesh.globeBasis,_,this.blend,this.exaggeration,[E[0],E[1],this.mesh.positions[x+2]]):a.project(s.unproject(E)):E}),d=Qs(e.origin,o,h[0],h[1],h[2],{maxT:l?.distance??r});if(!d||l&&d.t>=l.distance)continue;let f=[e.origin[0]+o[0]*d.t,e.origin[1]+o[1]*d.t,e.origin[2]+o[2]*d.t];if(i&&!i(f,u,d.barycentric))continue;let p=new it(h[1]).subtract(h[0]).cross(new it(h[2]).subtract(h[0]));if(this.projection==="globe"&&(Math.hypot(...f)===0||p.dot(o)>=0))continue;p.normalize();let m=a.unproject(f);m[2]=d.barycentric.reduce((g,_,x)=>g+_*c[x],0),l={position:f,coordinate:m,distance:d.t,normal:[p[0],p[1],p[2]],triangleIndex:u,barycentric:d.barycentric}}return l}};function nw(t,e,r,i){if(!t.indices.length||i?.length===0)return null;let n=Do(t),o=n.offsets[0]+n.heights[0]*r,s=n.offsets[1]+n.heights[1]*r,a,l;if(e==="web-mercator"){if(a=[t.bounds[0],t.bounds[1],o],l=[t.bounds[2],t.bounds[3],s],i&&(a[0]=Math.max(a[0],Math.min(...i.map(u=>u[0]))),a[1]=Math.max(a[1],Math.min(...i.map(u=>u[1]))),l[0]=Math.min(l[0],Math.max(...i.map(u=>u[2]))),l[1]=Math.min(l[1],Math.max(...i.map(u=>u[3]))),a[0]>l[0]||a[1]>l[1]))return null}else if(n.globe){a=[0,0,0],l=[0,0,0];for(let u of[0,1,2]){let c=n.offsets.flatMap(h=>[n.directions.minimum[u]*h,n.directions.maximum[u]*h]).map(h=>h*ae.globeRadius/ae.earthRadius);a[u]=n.globe.base.minimum[u]+n.globe.relief.minimum[u]*r+Math.min(...c),l[u]=n.globe.base.maximum[u]+n.globe.relief.maximum[u]*r+Math.max(...c)}}else{let u=[o,s].map(c=>ae.globeRadius*(1+c/ae.earthRadius));a=[0,0,0],l=[0,0,0];for(let c of[0,1,2]){let h=u.flatMap(d=>[n.directions.minimum[c]*d,n.directions.maximum[c]*d]);a[c]=Math.min(...h),l[c]=Math.max(...h)}}for(let u of[0,1,2]){let c=Math.max(1,Math.abs(a[u]),Math.abs(l[u]))*1e-12;a[u]-=c,l[u]+=c}return{minimum:a,maximum:l}}var ta=new WeakMap,pg=new WeakMap,ow=0;function sw(t){let e=pg.get(t);return e===void 0&&(e=ow++,pg.set(t,e)),e}function aw(t,e,r,i,n){let o=ta.get(t);if(o?.projection===e&&o.blend===r&&o.exaggeration===i&&o.indexLimit===n)return o.surface;let s=new Float64Array(t.positions.length),a=new Float64Array(t.positions.length/3),l=et("web-mercator"),u=et("globe");for(let h=0;h<a.length;h++){let d=h*3,f=t.heights[h*2],p=t.heights[h*2+1],m=p+(f-p)*r;a[h]=t.positions[d+2]+m;let g=[t.positions[d],t.positions[d+1],t.positions[d+2]+m*i];s.set(e==="globe"?t.globeBasis?nl(t.globeBasis,h,r,i,[g[0],g[1],t.positions[d+2]]):u.project(l.unproject(g)):g,d)}let c=new $i({projection:e,positions:s,indices:t.indices,physicalHeights:a,cullBackfaces:e==="globe",maxQueryIndexBytes:n,deferQueryIndexBuild:!0});return ta.set(t,{projection:e,blend:r,exaggeration:i,indexLimit:n,surface:c}),c}function lw(t,e,r){let i=0,n=(e??1/0)/Math.hypot(...t.direction);for(let o of[0,1])if(t.direction[o]===0){if(t.origin[o]<r[o]||t.origin[o]>r[o+2])return!1}else{let s=(r[o]-t.origin[o])/t.direction[o],a=(r[o+2]-t.origin[o])/t.direction[o];if(i=Math.max(i,Math.min(s,a)),n=Math.min(n,Math.max(s,a)),i>n)return!1}return!0}var $r=class extends Vi{queryOwners;generation;frameTime;exaggeration;inputBytes;displayKey;get reservedQueryIndexBytes(){return this.indexBudget.reserved}indexBudget;constructor(e,r,i,n,o,s=16*1024*1024,a=32*1024*1024){if(!Number.isSafeInteger(i)||i<0||!Number.isFinite(n)||!Number.isFinite(o)||o<0||o>1e3)throw new Error("Invalid terrain surface frame");if(!Number.isSafeInteger(s)||s<0)throw new Error("Invalid terrain query index budget");if(!Number.isSafeInteger(a)||a<0)throw new Error("Invalid terrain projected query budget");let l=[],u={reserved:0},c=new Map,h=new Map,d=0,f=r.map(p=>{if(!Number.isFinite(p.blend)||p.blend<0||p.blend>1)throw new Error("Invalid terrain surface blend");let m=p.mesh;if(m.positions.length%3||m.heights.length!==m.positions.length/3*2)throw new Error("Invalid terrain query channels");if(m.globeBasis&&!fg.has(m)){if(m.globeBasis.length!==m.positions.length*4||!m.globeBasis.every(Number.isFinite))throw new Error("Invalid terrain globe basis channels");fg.add(m)}let g=p.blend,_=p.clips?.map(M=>[...M]),x=p.halfOpenClips??!1;if(typeof x!="boolean")throw new Error("Invalid terrain query clip ownership");let v=Ui.getRequiredHierarchyBytes(m.indices.length/3);if(_?.some(M=>M.length!==4||!M.every(Number.isFinite)||M[0]>M[2]||M[1]>M[3]))throw new Error("Invalid terrain query clip");let A=Math.PI*ae.mercatorRadius;if(x)for(let M of _??[])for(let R of[2,3])Math.abs(M[R]-A)<=A*Number.EPSILON*8&&(M[R]=A);let w,E={blend:g,projectionBuilds:0,preparationMs:0,queryMs:0,prepare(){if(!E.surface){let M=h.get(m)?.get(g);if(M)return E.surface=M,M;let R=performance.now(),U=m.positions.length*8+m.heights.length/2*8+m.indices.length*4;if(U>a-d)ta.delete(m),E.surface=new $n(m,e,g,o);else{d+=U;let k=g!==1?0:c.get(m)??(v<=s-u.reserved?v:0);g===1&&!c.has(m)&&(c.set(m,k),u.reserved+=k);let b=ta.get(m);E.projectionBuilds=+(b?.projection!==e||b.blend!==g||b.exaggeration!==o||b.indexLimit!==k),E.surface=aw(m,e,g,o,k)}E.preparationMs+=performance.now()-R;let T=h.get(m)??new Map;T.set(g,E.surface),h.set(m,T)}return E.surface}};return l.push(E),{id:p.id,surface:{projection:e,getBounds(){return w===void 0&&(w=nw(m,e,o,_)),w?{minimum:[...w.minimum],maximum:[...w.maximum]}:null},intersectRay(M,R){if(_?.length===0||!m.indices.length||e==="web-mercator"&&!lw(M,R,m.bounds))return null;let U=E.prepare(),T=performance.now(),k=U.intersectRay(M,R,_?(b,L,B)=>{let F=e==="web-mercator"?b:[0,1].map(ee=>B.reduce((G,Z,O)=>G+Z*m.positions[m.indices[L*3+O]*3+ee],0));return _.some(ee=>F[0]>=ee[0]&&(x&&ee[2]!==A?F[0]<ee[2]:F[0]<=ee[2])&&F[1]>=ee[1]&&(x&&ee[3]!==A?F[1]<ee[3]:F[1]<=ee[3]))}:void 0);return E.queryMs+=performance.now()-T,k}}}});super(e,f),this.generation=i,this.frameTime=n,this.exaggeration=o,this.queryOwners=l,this.indexBudget=u,this.inputBytes=[...new Set(r.map(p=>p.mesh))].reduce((p,m)=>p+m.positions.byteLength+m.heights.byteLength+m.indices.byteLength+(m.globeBasis?.byteLength??0),0),this.displayKey=`${e}/${i}/${o}/${s}/${a}/${r.map(p=>`${p.id}:${sw(p.mesh)}:${p.blend}:${JSON.stringify(p.clips)}:${!!p.halfOpenClips}`).join(",")}`}*prepareQueryIndexSteps(){let e=new Set,r=[];for(let i of this.queryOwners){let n=i.surface;!n||n instanceof $n||i.blend!==1||e.has(n)||zu.has(n)||(e.add(n),r.push({owner:i,steps:n.prepareQueryIndexSteps()}))}try{for(;r.length;)for(let i=0;i<r.length;){let{owner:n,steps:o}=r[i],s=performance.now(),a;try{a=o.next().done}catch(l){n.surface&&zu.add(n.surface),D("warn","Terrain query acceleration failed; retaining exact linear queries",l),a=!0}finally{n.preparationMs+=performance.now()-s}a?(o.return(),r.splice(i,1)):(i++,yield)}}finally{for(let{steps:i}of r)i.return()}}getStatistics(){let e={inputBytes:this.inputBytes,projectedBytes:0,queryIndexBytes:0,reservedQueryIndexBytes:this.reservedQueryIndexBytes,preparedMeshes:0,projectionBuilds:0,preparationMs:0,queryMs:0,preparationFailures:0,streamingMeshes:0},r=new Set;for(let i of this.queryOwners){if(i.surface&&!r.has(i.surface)){let n=i.surface.getStatistics();e.projectedBytes+=n.geometryBytes,e.queryIndexBytes+=n.queryIndexBytes,e.preparationFailures+=Number(zu.has(i.surface)),r.add(i.surface)}e.preparedMeshes+=+(i.surface!==void 0),e.streamingMeshes+=+(i.surface instanceof $n),e.projectionBuilds+=i.projectionBuilds,e.preparationMs+=i.preparationMs,e.queryMs+=i.queryMs}return e}};var qr=class t{gpuBackend;device_renderer;scene;get activeTileManager(){if(!this.scene.tile_manager)throw new Error("Renderer scene tile manager has been destroyed");return this.scene.tile_manager}host_frame;active_render_view_id;animationFrame=null;submittedViews=new Set;terrainQueryPreparation;annotationTerrainSurface;projectionUpdate=Promise.resolve();projectionNeedsRebuild=!1;terrainUpdate=Promise.resolve();pendingTerrain;pendingTerrainUsesPrevious=!1;terrainRevision=0;terrainFailed=!1;terrainUpdating=!1;terrainRibbonScheduled=!1;requestedTerrainRibbonZoom;admittedTerrainRibbonZoom;terrainRibbonFailure;terrainSurfaceSnapshot=null;terrainDisplayMinimumHeight=0;destroyed=!1;constructor(e,r={}){Ws(r.maxConcurrentTileLoadsPerWorker),Dn(r.projectionEngine),In(r.projectionEngineExecution),this.gpuBackend=r.device?new dr(r.device):null,this.device_renderer=this.gpuBackend;let i=this.gpuBackend?this.gpuBackend.getSceneOptions():{};this.scene=Wt.create(e,Object.assign({},r,i,{device:this.gpuBackend?this.gpuBackend.device:r.device,disableRenderLoop:!0,cameraMode:"external"})),this.terrainDisplayMinimumHeight=this.scene.terrain?.minimumHeight??0,this.host_frame=null,this.active_render_view_id=null}static create(e,r={}){return new t(e,r)}subscribe(e){return this.scene.subscribe(e)}load(e=null,r={}){return this.terrainSurfaceSnapshot=null,this.annotationTerrainSurface=void 0,this.terrainQueryPreparation?.steps.return(),this.terrainQueryPreparation=void 0,this.scene.load(e,r)}setTerrain(e){if(this.destroyed||!this.scene.terrain)return Promise.reject(new Error("Terrain requires a live enabled renderer"));this.pendingTerrain=$o(e),this.terrainRibbonFailure=void 0,this.pendingTerrainUsesPrevious=e.previousGrids===void 0;let r=++this.terrainRevision,i=this.terrainUpdate.then(async()=>{if(this.destroyed)throw new Error("Cannot update a destroyed renderer");if(r!==this.terrainRevision)return;if(!this.scene.terrain)throw new Error("Terrain must be enabled at renderer creation");let n=this.pendingTerrain;if(!n)return;this.pendingTerrain=void 0;let o=this.scene.terrain;if(n={...n,transitionGeneration:o.transitionGeneration+1},this.pendingTerrainUsesPrevious&&n.grids.length&&o.grids.length){let s=n.byteLength+o.grids.reduce((l,u)=>l+u.heights.byteLength+u.valid.byteLength,0);if(s>n.maxGridBytes)throw new Error("Terrain draping current/previous grid-byte budget exceeded");if(o.grids[0].verticalDatum!==n.grids[0].verticalDatum)throw new Error("Terrain draping previous datum must match");let a=o.grids.reduce((l,u)=>{for(let c=0;c<u.heights.length;c++)u.valid[c]&&(l=Math.min(l,u.heights[c]));return l},0);n={...n,previousGrids:o.grids,previousGroundMeshResolution:o.groundMeshResolution,byteLength:s,minimumHeight:Math.min(n.minimumHeight,a)}}if(n.minimumHeight*this.scene.terrainExaggeration<=-ae.earthRadius)throw new Error("Terrain exaggeration would invert the globe radius");this.scene.terrain=n,this.terrainUpdating=!0;try{await this.scene.rebuild({preserveTileCache:!0,preserveTime:!0}),this.terrainDisplayMinimumHeight=n.minimumHeight,this.terrainFailed=!1,this.destroyed||this.scene.requestRedraw()}catch(s){if(this.scene.terrain=o,this.terrainFailed=!0,!this.destroyed)try{await this.scene.rebuild({preserveTileCache:!0,preserveTime:!0}),this.terrainFailed=!1,this.destroyed||this.scene.requestRedraw()}catch(a){throw new AggregateError([s,a],"Terrain update and recovery failed")}throw s}finally{this.terrainUpdating=!1}});return this.terrainUpdate=i.catch(()=>{}),i}requestTerrainRibbonRefinement(e){if(this.requestedTerrainRibbonZoom=e,this.terrainRibbonScheduled||this.admittedTerrainRibbonZoom===e||this.terrainRibbonFailure?.zoom===e||!this.scene.terrain?.groundMeshResolution||!this.scene.terrainRibbonStyles&&!this.activeTileManager.getTerrainDrapingStatistics(this.scene.terrain).ribbonMeshes)return;this.terrainRibbonScheduled=!0;let r=this.terrainUpdate.then(async()=>{if(this.destroyed||!this.scene.terrain?.groundMeshResolution)return;let i=this.requestedTerrainRibbonZoom;if(i===void 0||i===this.admittedTerrainRibbonZoom)return;let n=this.scene.terrainRibbonZoom;this.terrainUpdating=!0;try{if(await this.scene.rebuild({preserveTileCache:!0,preserveTime:!0,terrainRibbonZoom:i})===!1)return;this.admittedTerrainRibbonZoom=i,this.terrainRibbonFailure=void 0,this.terrainFailed=!1}catch(o){if(this.terrainRibbonFailure={zoom:i,message:o instanceof Error?o.message:String(o)},this.scene.terrainRibbonZoom=n,!this.destroyed)try{if(await this.scene.rebuild({preserveTileCache:!0,preserveTime:!0,terrainRibbonZoom:n??null})===!1)throw new Error("Terrain ribbon recovery was superseded")}catch(s){throw this.terrainFailed=!0,new AggregateError([o,s],"Terrain ribbon update and recovery failed")}}finally{this.terrainUpdating=!1}}).finally(()=>{this.terrainRibbonScheduled=!1,this.destroyed||this.scene.requestRedraw()});this.terrainUpdate=r.catch(()=>{})}setTerrainExaggeration(e){if(this.destroyed||!this.scene.terrain)throw new Error("Terrain requires a live enabled renderer");if(!Number.isFinite(e)||e<0||e>1e3)throw new Error("Terrain exaggeration must be in [0, 1000]");if(Math.min(this.scene.terrain.minimumHeight,this.terrainDisplayMinimumHeight)*e<=-ae.earthRadius)throw new Error("Terrain exaggeration would invert the globe radius");this.scene.terrainExaggeration!==e&&(this.scene.terrainExaggeration=e,this.scene.requestRedraw())}getTerrainDrapingStatistics(){return{...this.activeTileManager.getTerrainDrapingStatistics(this.scene.terrain),...this.scene.terrain?.groundMeshResolution?{ribbonRefinement:{requestedZoom:this.requestedTerrainRibbonZoom,admittedZoom:this.admittedTerrainRibbonZoom,pending:this.terrainRibbonScheduled,error:this.terrainRibbonFailure?.message}}:{},annotationQueries:this.annotationTerrainSurface?.getStatistics()}}setProjectedBasemapProjection(e){let r=Sr(e),i=this.projectionUpdate.then(async()=>{if(this.destroyed)throw new Error("Cannot update a destroyed renderer");let n=this.scene.config?.scene;if(!n?.cpu_projection)throw new Error("Projection updates require a loaded CPU-projected scene");let o=Sr(n.cpu_projection);if(!(!this.projectionNeedsRebuild&&JSON.stringify(o)===JSON.stringify(r))){n.cpu_projection=r;try{await this.scene.rebuild({preserveTileCache:!0}),this.projectionNeedsRebuild=!1,this.destroyed||this.scene.requestRedraw()}catch(s){throw this.projectionNeedsRebuild=!0,n.cpu_projection=o,s}}});return this.projectionUpdate=i.catch(()=>{}),i}getAttributions(){return this.scene.getAttributions()}getFeatureAt(e,r={}){if(this.destroyed)return Promise.reject(new Error("Cannot query a destroyed renderer"));if(this.terrainUpdating)return this.terrainUpdate.then(()=>this.getFeatureAt(e,r));if(this.terrainFailed)return Promise.reject(new Error("Terrain generation requires a successful correction"));if(![e.x,e.y,r.radius??0].every(Number.isFinite)||(r.radius??0)<0)return Promise.reject(new Error("Selection coordinates and non-negative radius must be finite"));let i;try{if(!this.host_frame&&(r.renderViewId!==void 0||r.coordinateSpace==="canvas"))throw new Error("View-aware selection requires a HostFrame");i=this.host_frame?.resolveSelectionPoint(e,r,this.active_render_view_id??void 0)}catch(o){return Promise.reject(o)}if(i===null)return Promise.resolve({feature:null,changed:!1,pixel:{...e}});let n=this.scene.getFeatureAt(i?.pixel??{...e},{radius:r.radius,...i?{renderViewId:i.view.id,width:i.view.viewport.width,height:i.view.viewport.height}:{}});return this.scene.requestRedraw(),i?n.then(o=>o&&{...o,pixel:{...e},renderViewId:i.view.id}):n}getDrapedTerrainSurface(){return this.destroyed||this.terrainFailed?null:this.terrainSurfaceSnapshot}getTerrainAt(e,r,i={}){if(this.destroyed)throw new Error("Cannot query a destroyed renderer");if(!this.host_frame)throw new Error("Terrain selection requires a HostFrame");let n=r??this.getDrapedTerrainSurface();return n?ea(this.host_frame,e,n,i,this.active_render_view_id??void 0):null}getSourceMetadata(){return this.scene.getSourceMetadata()}getTileSourceStatistics(){return this.scene.getTileSourceStatistics()}getProjectionEngineStatistics(){return this.scene.getProjectionEngineStatistics()}getLumaLightDefinitions(){return this.scene.getLumaLightDefinitions()}getTileResourceStatistics(){return this.activeTileManager.getResourceStatistics()}setFrame(e,{renderViewId:r}={}){let i=hr.from(e);if(this.scene.config&&!!this.scene.config.scene?.cpu_projection!=(i.projection.type==="projected"))throw new Error("CPU-projected scene meshes and HostFrame projection must match");let n=i.getRenderView(r),o=n.viewport,s=this.active_render_view_id!==n.id;return this.scene.view.applyHostFrame(i,()=>{(this.scene.view.size.css.width!==o.width||this.scene.view.size.css.height!==o.height)&&this.scene.resizeMap(o.width,o.height)},()=>{this.scene.setCameraMatrices(i.projection.type==="projected"?{...n.camera,view:new Float64Array(new Oe),projection:new Float64Array(new Oe(Array.from(n.camera.projection)).multiplyRight(Array.from(n.camera.view)))}:n.camera),this.host_frame=i,this.active_render_view_id=n.id}),i!==this.animationFrame&&(this.animationFrame=i,this.submittedViews.clear(),this.scene.host_animation_time=i.animationTime??Math.max(0,(Date.now()-this.scene.start_time)/1e3)),s&&(this.scene.dirty=!0),this.scene.setFeatureSelectionView?.(n.id,i.renderViews.map(a=>a.id)),i}render({frame:e,renderPass:r=null,renderViewId:i,force:n=!1}={}){if(this.destroyed||this.terrainFailed)return!1;if(e)this.setFrame(e,{renderViewId:i});else if(i){if(!this.host_frame)throw new Error("Renderer requires a HostFrame before selecting a render view");this.setFrame(this.host_frame,{renderViewId:i})}if(this.host_frame&&this.active_render_view_id&&this.scene.setFeatureSelectionView?.(this.active_render_view_id,this.host_frame.renderViews.map(s=>s.id)),n&&(this.scene.dirty=!0),this.active_render_view_id&&this.submittedViews.has(this.active_render_view_id)&&(this.submittedViews.clear(),this.host_frame&&(this.scene.host_animation_time=this.host_frame.animationTime??Math.max(0,(Date.now()-this.scene.start_time)/1e3))),this.host_frame){this.submittedViews.size||(this.requestTerrainRibbonRefinement(this.host_frame.geographicAnchor.zoom),this.scene.terrainFrameTime=performance.now(),this.advanceTerrainQueryPreparation());let s;if(this.scene.terrain?.occludeAnnotations&&this.host_frame.projection.type!=="projected"){let a=this.activeTileManager.getDrapedTerrainQueryEntries(this.scene.terrainFrameTime??performance.now()),l=new $r(this.host_frame.projection.type,a,this.scene.terrainDisplayGeneration??0,this.scene.terrainFrameTime??performance.now(),this.scene.terrainExaggeration,this.scene.terrain.maxQueryIndexBytes,this.scene.terrain.maxProjectedQueryBytes);this.annotationTerrainSurface?.displayKey!==l.displayKey&&(this.annotationTerrainSurface=l),s=this.annotationTerrainSurface}else this.annotationTerrainSurface=void 0;this.activeTileManager.updateProjectedLabels(this.host_frame,this.gpuBackend?.device.type!=="webgpu",s)}let o=this.scene.updateScene({renderPass:r});if(o&&this.scene.terrain&&this.host_frame&&this.host_frame.projection.type!=="projected"){let s=this.scene.terrainFrameTime??performance.now(),a=this.activeTileManager.getDrapedTerrainQueryEntries(s);this.terrainSurfaceSnapshot=new $r(this.host_frame.projection.type,a,this.scene.terrainDisplayGeneration??0,s,this.scene.terrainExaggeration,this.scene.terrain.maxQueryIndexBytes,this.scene.terrain.maxProjectedQueryBytes)}return this.submittedViews.size===0&&this.scene.processTasks(),this.active_render_view_id&&this.submittedViews.add(this.active_render_view_id),o&&this.scene.config&&this.scene.animated&&this.scene.requestRedraw(),o}advanceTerrainQueryPreparation(){let e=this.annotationTerrainSurface??this.terrainSurfaceSnapshot,r=this.scene.terrain?.queryPreparationBudgetMs??0;if(!e||!r){this.terrainQueryPreparation?.steps.return(),this.terrainQueryPreparation=void 0;return}this.terrainQueryPreparation?.snapshot.displayKey!==e.displayKey&&(this.terrainQueryPreparation?.steps.return(),this.terrainQueryPreparation={snapshot:e,steps:e.prepareQueryIndexSteps()});let i=this.terrainQueryPreparation,n=performance.now();do if(i.steps.next().done){this.terrainQueryPreparation=void 0;return}while(performance.now()-n<r);this.scene.requestRedraw()}destroy(){this.annotationTerrainSurface=void 0,this.terrainQueryPreparation?.steps.return(),this.terrainQueryPreparation=void 0,this.destroyed=!0,this.pendingTerrain=void 0,this.terrainSurfaceSnapshot=null,this.terrainRevision++;try{return this.scene.destroy()}finally{this.gpuBackend&&this.gpuBackend.destroy()}}};var gg=Ot(Hl(),1);function mg(t,e){return Ou(t,[0,0],e)}function Ou(t,e,r){let[i,n]=e;if(e.length!==2||!Number.isFinite(i)||!Number.isFinite(n)||i>n)throw new Error("Elevation range requires two finite ordered heights");if(t.view.length!==16||t.projection.length!==16||!Array.from(t.view).every(Number.isFinite)||!Array.from(t.projection).every(Number.isFinite))throw new Error("Ground footprint requires finite camera matrices");if(r&&(![r.sw.x,r.sw.y,r.ne.x,r.ne.y].every(Number.isFinite)||r.sw.x>r.ne.x||r.sw.y>r.ne.y))throw new Error("Ground footprint limits must be finite ordered bounds");let o=new Oe().copy(t.projection).multiplyRight(t.view);if(!Number.isFinite(o.determinant())||o.determinant()===0)throw new Error("Ground footprint camera is singular");o.invert();let s=[];for(let d of[-1,1])for(let f of[-1,1])for(let p of[-1,1]){let m=o.transform([p,f,d,1]),g=Array.from(m).slice(0,3).map(_=>_/m[3]);if(!g.every(Number.isFinite)||m[3]<=0)throw new Error("Ground footprint requires a finite near and far frustum");s.push(g)}let a=s.filter(d=>d[2]>=i&&d[2]<=n).map(d=>[d[0],d[1]]);for(let d=0;d<s.length;d++)for(let f of[1,2,4]){let p=d^f;if(p<d)continue;let m=s[d],g=s[p];for(let _ of[i,n])if(m[2]===_&&a.push([m[0],m[1]]),g[2]===_&&a.push([g[0],g[1]]),m[2]<_&&g[2]>_||m[2]>_&&g[2]<_){let x=(_-m[2])/(g[2]-m[2]);a.push([m[0]+x*(g[0]-m[0]),m[1]+x*(g[1]-m[1])])}}let l=uw(a);if(l.length<3||(r&&(l=ra(l,0,r.sw.x,!0),l=ra(l,0,r.ne.x,!1),l=ra(l,1,r.sw.y,!0),l=ra(l,1,r.ne.y,!1)),l.length<3))return null;let u=l[0];if(l.reduce((d,f,p)=>{let m=l[(p+1)%l.length];return d+(f[0]-u[0])*(m[1]-u[1])-(f[1]-u[1])*(m[0]-u[0])},0)===0)return null;let h={sw:{x:Math.min(...l.map(d=>d[0])),y:Math.min(...l.map(d=>d[1]))},ne:{x:Math.max(...l.map(d=>d[0])),y:Math.max(...l.map(d=>d[1]))}};return h.ne.x>h.sw.x&&h.ne.y>h.sw.y?h:null}function uw(t){let e=t.sort((s,a)=>s[0]-a[0]||s[1]-a[1]).filter((s,a,l)=>a===0||s[0]!==l[a-1][0]||s[1]!==l[a-1][1]),r=(s,a,l)=>(a[0]-s[0])*(l[1]-s[1])-(a[1]-s[1])*(l[0]-s[0]),i=s=>{let a=[];for(let l of s){for(;a.length>=2&&r(a[a.length-2],a[a.length-1],l)<=0;)a.pop();a.push(l)}return a},n=i(e),o=i([...e].reverse());return[...n.slice(0,-1),...o.slice(0,-1)]}function ra(t,e,r,i){let n=[],o=s=>i?s[e]>=r:s[e]<=r;for(let s=0;s<t.length;s++){let a=t[s],l=t[(s+1)%t.length];if(o(a)&&n.push(a),o(a)!==o(l)){let u=(r-a[e])/(l[e]-a[e]),c=[a[0]+u*(l[0]-a[0]),a[1]+u*(l[1]-a[1])];c[e]=r,n.push(c)}}return n}var cw={log:D,yaml:gg.default,Utils:de,Geo:q,Vector:le,DataSource:qe,GLSL:Ke,ShaderProgram:re,UniformBuffer:Ft,VertexData:br,Texture:K,Material:pt,Light:ke,Scene:Gi,ClassicWebGLRenderer:qr,HostFrame:hr,LumaDeviceRenderer:dr,WorkerBroker:ce,Task:Xe,StyleManager:Si,StyleParser:W,TileID:Te,Collision:Fe,FeatureSelection:Je,TextCanvas:lt,debugSettings:Ze},hw={Scene:Gi,ClassicWebGLRenderer:qr,Renderer:qr,HostFrame:hr,LumaDeviceRenderer:dr,debug:cw,version:Zi};var qi=hw;var _g=`"use strict";(()=>{var Id=Object.create;var Js=Object.defineProperty;var Gd=Object.getOwnPropertyDescriptor;var Vd=Object.getOwnPropertyNames;var Ud=Object.getPrototypeOf,jd=Object.prototype.hasOwnProperty;var je=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}};var Wd=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Vd(e))!jd.call(t,n)&&n!==r&&Js(t,n,{get:()=>e[n],enumerable:!(i=Gd(e,n))||i.enumerable});return t};var Zt=(t,e,r)=>(r=t!=null?Id(Ud(t)):{},Wd(e||!t||!t.__esModule?Js(r,"default",{value:t,enumerable:!0}):r,t));var Ya=je(Xa=>{var qa={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function Vr(t){return t=Math.round(t),t<0?0:t>255?255:t}function Ha(t){return t<0?0:t>1?1:t}function oo(t){return t[t.length-1]==="%"?Vr(parseFloat(t)/100*255):Vr(parseInt(t))}function Ai(t){return t[t.length-1]==="%"?Ha(parseFloat(t)/100):Ha(parseFloat(t))}function so(t,e,r){return r<0?r+=1:r>1&&(r-=1),r*6<1?t+(e-t)*r*6:r*2<1?e:r*3<2?t+(e-t)*(2/3-r)*6:t}function wf(t){var e=t.replace(/ /g,"").toLowerCase();if(e in qa)return qa[e].slice();if(e[0]==="#"){if(e.length===4){var r=parseInt(e.substr(1),16);return r>=0&&r<=4095?[(r&3840)>>4|(r&3840)>>8,r&240|(r&240)>>4,r&15|(r&15)<<4,1]:null}else if(e.length===7){var r=parseInt(e.substr(1),16);return r>=0&&r<=16777215?[(r&16711680)>>16,(r&65280)>>8,r&255,1]:null}return null}var i=e.indexOf("("),n=e.indexOf(")");if(i!==-1&&n+1===e.length){var o=e.substr(0,i),s=e.substr(i+1,n-(i+1)).split(","),a=1;switch(o){case"rgba":if(s.length!==4)return null;a=Ai(s.pop());case"rgb":return s.length!==3?null:[oo(s[0]),oo(s[1]),oo(s[2]),a];case"hsla":if(s.length!==4)return null;a=Ai(s.pop());case"hsl":if(s.length!==3)return null;var l=(parseFloat(s[0])%360+360)%360/360,u=Ai(s[1]),c=Ai(s[2]),d=c<=.5?c*(u+1):c+u-c*u,f=c*2-d;return[Vr(so(f,d,l+1/3)*255),Vr(so(f,d,l)*255),Vr(so(f,d,l-1/3)*255),a];default:return null}}return null}try{Xa.parseCSSColor=wf}catch{}});var Fl=je((xx,Nl)=>{Nl.exports=bh;function bh(t){t=String(t);for(var e=[],r;r=t.match(/ERROR\\:([^\\n]+)/);){t=t.slice(r.index+1);var s=r[1].trim(),i=s.split(":"),n=i.slice(2).join(":").trim(),o=parseInt(i[0],10),s=parseInt(i[1],10);e.push({message:n,file:o,line:s})}return e}});var Zu=je(qo=>{qo.read=function(t,e,r,i,n){var o,s,a=n*8-i-1,l=(1<<a)-1,u=l>>1,c=-7,d=r?n-1:0,f=r?-1:1,h=t[e+d];for(d+=f,o=h&(1<<-c)-1,h>>=-c,c+=a;c>0;o=o*256+t[e+d],d+=f,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=i;c>0;s=s*256+t[e+d],d+=f,c-=8);if(o===0)o=1-u;else{if(o===l)return s?NaN:(h?-1:1)*(1/0);s=s+Math.pow(2,i),o=o-u}return(h?-1:1)*s*Math.pow(2,o-i)};qo.write=function(t,e,r,i,n,o){var s,a,l,u=o*8-n-1,c=(1<<u)-1,d=c>>1,f=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=i?0:o-1,m=i?1:-1,g=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-s))<1&&(s--,l*=2),s+d>=1?e+=f/l:e+=f*Math.pow(2,1-d),e*l>=2&&(s++,l/=2),s+d>=c?(a=0,s=c):s+d>=1?(a=(e*l-1)*Math.pow(2,n),s=s+d):(a=e*Math.pow(2,d-1)*Math.pow(2,n),s=0));n>=8;t[r+h]=a&255,h+=m,a/=256,n-=8);for(s=s<<n|a,u+=n;u>0;t[r+h]=s&255,h+=m,s/=256,u-=8);t[r+h-m]|=g*128}});var tc=je((ov,ec)=>{"use strict";ec.exports=he;var ln=Zu();function he(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}he.Varint=0;he.Fixed64=1;he.Bytes=2;he.Fixed32=5;var Ho=65536*65536,Ju=1/Ho;he.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos<r;){var i=this.readVarint(),n=i>>3,o=this.pos;this.type=i&7,t(n,e,this),this.pos===o&&this.skip(i)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=un(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Qu(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=un(this.buf,this.pos)+un(this.buf,this.pos+4)*Ho;return this.pos+=8,t},readSFixed64:function(){var t=un(this.buf,this.pos)+Qu(this.buf,this.pos+4)*Ho;return this.pos+=8,t},readFloat:function(){var t=ln.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=ln.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e=this.buf,r,i;return i=e[this.pos++],r=i&127,i<128||(i=e[this.pos++],r|=(i&127)<<7,i<128)||(i=e[this.pos++],r|=(i&127)<<14,i<128)||(i=e[this.pos++],r|=(i&127)<<21,i<128)?r:(i=e[this.pos],r|=(i&15)<<28,xm(r,t,this))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2===1?(t+1)/-2:t/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var t=this.readVarint()+this.pos,e=zm(this.buf,this.pos,t);return this.pos=t,e},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){var r=lt(this);for(t=t||[];this.pos<r;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){var e=lt(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){var e=lt(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){var e=lt(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){var e=lt(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){var e=lt(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){var e=lt(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){var e=lt(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){var e=lt(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=t&7;if(e===he.Varint)for(;this.buf[this.pos++]>127;);else if(e===he.Bytes)this.pos=this.readVarint()+this.pos;else if(e===he.Fixed32)this.pos+=4;else if(e===he.Fixed64)this.pos+=8;else throw new Error("Unimplemented type: "+e)},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var r=new Uint8Array(e);r.set(this.buf),this.buf=r,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),vr(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),vr(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),vr(this.buf,t&-1,this.pos),vr(this.buf,Math.floor(t*Ju),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),vr(this.buf,t&-1,this.pos),vr(this.buf,Math.floor(t*Ju),this.pos+4),this.pos+=8},writeVarint:function(t){if(t=+t||0,t>268435455||t<0){Tm(t,this);return}this.realloc(4),this.buf[this.pos++]=t&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=t>>>7&127)))},writeSVarint:function(t){this.writeVarint(t<0?-t*2-1:t*2)},writeBoolean:function(t){this.writeVarint(!!t)},writeString:function(t){t=String(t),this.realloc(t.length*4),this.pos++;var e=this.pos;this.pos=Nm(this.buf,t,this.pos);var r=this.pos-e;r>=128&&Ku(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),ln.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),ln.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r<e;r++)this.buf[this.pos++]=t[r]},writeRawMessage:function(t,e){this.pos++;var r=this.pos;t(e,this);var i=this.pos-r;i>=128&&Ku(r,i,this),this.pos=r-1,this.writeVarint(i),this.pos+=i},writeMessage:function(t,e,r){this.writeTag(t,he.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){this.writeMessage(t,Em,e)},writePackedSVarint:function(t,e){this.writeMessage(t,Mm,e)},writePackedBoolean:function(t,e){this.writeMessage(t,Sm,e)},writePackedFloat:function(t,e){this.writeMessage(t,Am,e)},writePackedDouble:function(t,e){this.writeMessage(t,Rm,e)},writePackedFixed32:function(t,e){this.writeMessage(t,Pm,e)},writePackedSFixed32:function(t,e){this.writeMessage(t,Lm,e)},writePackedFixed64:function(t,e){this.writeMessage(t,Cm,e)},writePackedSFixed64:function(t,e){this.writeMessage(t,km,e)},writeBytesField:function(t,e){this.writeTag(t,he.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,he.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,he.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,he.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,he.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,he.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,he.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,he.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,he.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,he.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,!!e)}};function xm(t,e,r){var i=r.buf,n,o;if(o=i[r.pos++],n=(o&112)>>4,o<128||(o=i[r.pos++],n|=(o&127)<<3,o<128)||(o=i[r.pos++],n|=(o&127)<<10,o<128)||(o=i[r.pos++],n|=(o&127)<<17,o<128)||(o=i[r.pos++],n|=(o&127)<<24,o<128)||(o=i[r.pos++],n|=(o&1)<<31,o<128))return Tr(t,n,e);throw new Error("Expected varint not more than 10 bytes")}function lt(t){return t.type===he.Bytes?t.readVarint()+t.pos:t.pos+1}function Tr(t,e,r){return r?e*4294967296+(t>>>0):(e>>>0)*4294967296+(t>>>0)}function Tm(t,e){var r,i;if(t>=0?(r=t%4294967296|0,i=t/4294967296|0):(r=~(-t%4294967296),i=~(-t/4294967296),r^4294967295?r=r+1|0:(r=0,i=i+1|0)),t>=18446744073709552e3||t<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),vm(r,i,e),wm(i,e)}function vm(t,e,r){r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos]=t&127}function wm(t,e){var r=(t&7)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127)))))}function Ku(t,e,r){var i=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.ceil(Math.log(e)/(Math.LN2*7));r.realloc(i);for(var n=r.pos-1;n>=t;n--)r.buf[n+i]=r.buf[n]}function Em(t,e){for(var r=0;r<t.length;r++)e.writeVarint(t[r])}function Mm(t,e){for(var r=0;r<t.length;r++)e.writeSVarint(t[r])}function Am(t,e){for(var r=0;r<t.length;r++)e.writeFloat(t[r])}function Rm(t,e){for(var r=0;r<t.length;r++)e.writeDouble(t[r])}function Sm(t,e){for(var r=0;r<t.length;r++)e.writeBoolean(t[r])}function Pm(t,e){for(var r=0;r<t.length;r++)e.writeFixed32(t[r])}function Lm(t,e){for(var r=0;r<t.length;r++)e.writeSFixed32(t[r])}function Cm(t,e){for(var r=0;r<t.length;r++)e.writeFixed64(t[r])}function km(t,e){for(var r=0;r<t.length;r++)e.writeSFixed64(t[r])}function un(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+t[e+3]*16777216}function vr(t,e,r){t[r]=e,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function Qu(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function zm(t,e,r){for(var i="",n=e;n<r;){var o=t[n],s=null,a=o>239?4:o>223?3:o>191?2:1;if(n+a>r)break;var l,u,c;a===1?o<128&&(s=o):a===2?(l=t[n+1],(l&192)===128&&(s=(o&31)<<6|l&63,s<=127&&(s=null))):a===3?(l=t[n+1],u=t[n+2],(l&192)===128&&(u&192)===128&&(s=(o&15)<<12|(l&63)<<6|u&63,(s<=2047||s>=55296&&s<=57343)&&(s=null))):a===4&&(l=t[n+1],u=t[n+2],c=t[n+3],(l&192)===128&&(u&192)===128&&(c&192)===128&&(s=(o&15)<<18|(l&63)<<12|(u&63)<<6|c&63,(s<=65535||s>=1114112)&&(s=null))),s===null?(s=65533,a=1):s>65535&&(s-=65536,i+=String.fromCharCode(s>>>10&1023|55296),s=56320|s&1023),i+=String.fromCharCode(s),n+=a}return i}function Nm(t,e,r){for(var i=0,n,o;i<e.length;i++){if(n=e.charCodeAt(i),n>55295&&n<57344)if(o)if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,o=n;continue}else n=o-55296<<10|n-56320|65536,o=null;else{n>56319||i+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):o=n;continue}else o&&(t[r++]=239,t[r++]=191,t[r++]=189,o=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=n&63|128)}return r}});var ic=je((sv,rc)=>{"use strict";rc.exports=wr;function wr(t,e){this.x=t,this.y=e}wr.prototype={clone:function(){return new wr(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[0]*this.x+t[1]*this.y,r=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=r,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),i=e*this.x-r*this.y,n=r*this.x+e*this.y;return this.x=i,this.y=n,this},_rotateAround:function(t,e){var r=Math.cos(t),i=Math.sin(t),n=e.x+r*(this.x-e.x)-i*(this.y-e.y),o=e.y+i*(this.x-e.x)+r*(this.y-e.y);return this.x=n,this.y=o,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}};wr.convert=function(t){return t instanceof wr?t:Array.isArray(t)?new wr(t[0],t[1]):t}});var Xo=je((av,nc)=>{"use strict";var Fm=ic();nc.exports=Er;function Er(t,e,r,i,n){this.properties={},this.extent=r,this.type=0,this._pbf=t,this._geometry=-1,this._keys=i,this._values=n,t.readFields(Om,this,e)}function Om(t,e,r){t==1?e.id=r.readVarint():t==2?Dm(r,e):t==3?e.type=r.readVarint():t==4&&(e._geometry=r.pos)}function Dm(t,e){for(var r=t.readVarint()+t.pos;t.pos<r;){var i=e._keys[t.readVarint()],n=e._values[t.readVarint()];e.properties[i]=n}}Er.types=["Unknown","Point","LineString","Polygon"];Er.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,i=0,n=0,o=0,s=[],a;t.pos<e;){if(!i){var l=t.readVarint();r=l&7,i=l>>3}if(i--,r===1||r===2)n+=t.readSVarint(),o+=t.readSVarint(),r===1&&(a&&s.push(a),a=[]),a.push(new Fm(n,o));else if(r===7)a&&a.push(a[0].clone());else throw new Error("unknown command "+r)}return a&&s.push(a),s};Er.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,i=0,n=0,o=0,s=1/0,a=-1/0,l=1/0,u=-1/0;t.pos<e;){if(!i){var c=t.readVarint();r=c&7,i=c>>3}if(i--,r===1||r===2)n+=t.readSVarint(),o+=t.readSVarint(),n<s&&(s=n),n>a&&(a=n),o<l&&(l=o),o>u&&(u=o);else if(r!==7)throw new Error("unknown command "+r)}return[s,l,a,u]};Er.prototype.toGeoJSON=function(t,e,r){var i=this.extent*Math.pow(2,r),n=this.extent*t,o=this.extent*e,s=this.loadGeometry(),a=Er.types[this.type],l,u;function c(h){for(var m=0;m<h.length;m++){var g=h[m],p=180-(g.y+o)*360/i;h[m]=[(g.x+n)*360/i-180,360/Math.PI*Math.atan(Math.exp(p*Math.PI/180))-90]}}switch(this.type){case 1:var d=[];for(l=0;l<s.length;l++)d[l]=s[l][0];s=d,c(s);break;case 2:for(l=0;l<s.length;l++)c(s[l]);break;case 3:for(s=Bm(s),l=0;l<s.length;l++)for(u=0;u<s[l].length;u++)c(s[l][u]);break}s.length===1?s=s[0]:a="Multi"+a;var f={type:"Feature",geometry:{type:a,coordinates:s},properties:this.properties};return"id"in this&&(f.id=this.id),f};function Bm(t){var e=t.length;if(e<=1)return[t];for(var r=[],i,n,o=0;o<e;o++){var s=Im(t[o]);s!==0&&(n===void 0&&(n=s<0),n===s<0?(i&&r.push(i),i=[t[o]]):i.push(t[o]))}return i&&r.push(i),r}function Im(t){for(var e=0,r=0,i=t.length,n=i-1,o,s;r<i;n=r++)o=t[r],s=t[n],e+=(s.x-o.x)*(o.y+s.y);return e}});var Yo=je((lv,sc)=>{"use strict";var Gm=Xo();sc.exports=oc;function oc(t,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(Vm,this,e),this.length=this._features.length}function Vm(t,e,r){t===15?e.version=r.readVarint():t===1?e.name=r.readString():t===5?e.extent=r.readVarint():t===2?e._features.push(r.pos):t===3?e._keys.push(r.readString()):t===4&&e._values.push(Um(r))}function Um(t){for(var e=null,r=t.readVarint()+t.pos;t.pos<r;){var i=t.readVarint()>>3;e=i===1?t.readString():i===2?t.readFloat():i===3?t.readDouble():i===4?t.readVarint64():i===5?t.readVarint():i===6?t.readSVarint():i===7?t.readBoolean():null}return e}oc.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new Gm(this._pbf,e,this.extent,this._keys,this._values)}});var lc=je((uv,ac)=>{"use strict";var jm=Yo();ac.exports=Wm;function Wm(t,e){this.layers=t.readFields($m,{},e)}function $m(t,e,r){if(t===3){var i=new jm(r,r.readVarint()+r.pos);i.length&&(e[i.name]=i)}}});var uc=je((cv,cn)=>{cn.exports.VectorTile=lc();cn.exports.VectorTileFeature=Xo();cn.exports.VectorTileLayer=Yo()});var Nc=je((I2,_s)=>{"use strict";_s.exports=wn;_s.exports.default=wn;function wn(t,e,r){r=r||2;var i=e&&e.length,n=i?e[0]*r:t.length,o=Cc(t,0,n,r,!0),s=[];if(!o||o.next===o.prev)return s;var a,l,u,c,d,f,h;if(i&&(o=wp(t,e,o,r)),t.length>80*r){a=u=t[0],l=c=t[1];for(var m=r;m<n;m+=r)d=t[m],f=t[m+1],d<a&&(a=d),f<l&&(l=f),d>u&&(u=d),f>c&&(c=f);h=Math.max(u-a,c-l),h=h!==0?1/h:0}return oi(o,s,r,a,l,h),s}function Cc(t,e,r,i,n){var o,s;if(n===gs(t,e,r,i)>0)for(o=e;o<r;o+=i)s=Lc(o,t[o],t[o+1],s);else for(o=r-i;o>=e;o-=i)s=Lc(o,t[o],t[o+1],s);return s&&En(s,s.next)&&(ai(s),s=s.next),s}function Rt(t,e){if(!t)return t;e||(e=t);var r=t,i;do if(i=!1,!r.steiner&&(En(r,r.next)||ue(r.prev,r,r.next)===0)){if(ai(r),r=e=r.prev,r===r.next)break;i=!0}else r=r.next;while(i||r!==e);return e}function oi(t,e,r,i,n,o,s){if(t){!s&&o&&Sp(t,i,n,o);for(var a=t,l,u;t.prev!==t.next;){if(l=t.prev,u=t.next,o?xp(t,i,n,o):yp(t)){e.push(l.i/r),e.push(t.i/r),e.push(u.i/r),ai(t),t=u.next,a=u.next;continue}if(t=u,t===a){s?s===1?(t=Tp(Rt(t),e,r),oi(t,e,r,i,n,o,2)):s===2&&vp(t,e,r,i,n,o):oi(Rt(t),e,r,i,n,o,1);break}}}}function yp(t){var e=t.prev,r=t,i=t.next;if(ue(e,r,i)>=0)return!1;for(var n=t.next.next;n!==t.prev;){if(Pr(e.x,e.y,r.x,r.y,i.x,i.y,n.x,n.y)&&ue(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function xp(t,e,r,i){var n=t.prev,o=t,s=t.next;if(ue(n,o,s)>=0)return!1;for(var a=n.x<o.x?n.x<s.x?n.x:s.x:o.x<s.x?o.x:s.x,l=n.y<o.y?n.y<s.y?n.y:s.y:o.y<s.y?o.y:s.y,u=n.x>o.x?n.x>s.x?n.x:s.x:o.x>s.x?o.x:s.x,c=n.y>o.y?n.y>s.y?n.y:s.y:o.y>s.y?o.y:s.y,d=ms(a,l,e,r,i),f=ms(u,c,e,r,i),h=t.prevZ,m=t.nextZ;h&&h.z>=d&&m&&m.z<=f;){if(h!==t.prev&&h!==t.next&&Pr(n.x,n.y,o.x,o.y,s.x,s.y,h.x,h.y)&&ue(h.prev,h,h.next)>=0||(h=h.prevZ,m!==t.prev&&m!==t.next&&Pr(n.x,n.y,o.x,o.y,s.x,s.y,m.x,m.y)&&ue(m.prev,m,m.next)>=0))return!1;m=m.nextZ}for(;h&&h.z>=d;){if(h!==t.prev&&h!==t.next&&Pr(n.x,n.y,o.x,o.y,s.x,s.y,h.x,h.y)&&ue(h.prev,h,h.next)>=0)return!1;h=h.prevZ}for(;m&&m.z<=f;){if(m!==t.prev&&m!==t.next&&Pr(n.x,n.y,o.x,o.y,s.x,s.y,m.x,m.y)&&ue(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function Tp(t,e,r){var i=t;do{var n=i.prev,o=i.next.next;!En(n,o)&&kc(n,i,i.next,o)&&si(n,o)&&si(o,n)&&(e.push(n.i/r),e.push(i.i/r),e.push(o.i/r),ai(i),ai(i.next),i=t=o),i=i.next}while(i!==t);return Rt(i)}function vp(t,e,r,i,n,o){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&Cp(s,a)){var l=zc(s,a);s=Rt(s,s.next),l=Rt(l,l.next),oi(s,e,r,i,n,o),oi(l,e,r,i,n,o);return}a=a.next}s=s.next}while(s!==t)}function wp(t,e,r,i){var n=[],o,s,a,l,u;for(o=0,s=e.length;o<s;o++)a=e[o]*i,l=o<s-1?e[o+1]*i:t.length,u=Cc(t,a,l,i,!1),u===u.next&&(u.steiner=!0),n.push(Lp(u));for(n.sort(Ep),o=0;o<n.length;o++)Mp(n[o],r),r=Rt(r,r.next);return r}function Ep(t,e){return t.x-e.x}function Mp(t,e){if(e=Ap(t,e),e){var r=zc(e,t);Rt(e,e.next),Rt(r,r.next)}}function Ap(t,e){var r=e,i=t.x,n=t.y,o=-1/0,s;do{if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){var a=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=i&&a>o){if(o=a,a===i){if(n===r.y)return r;if(n===r.next.y)return r.next}s=r.x<r.next.x?r:r.next}}r=r.next}while(r!==e);if(!s)return null;if(i===o)return s;var l=s,u=s.x,c=s.y,d=1/0,f;r=s;do i>=r.x&&r.x>=u&&i!==r.x&&Pr(n<c?i:o,n,u,c,n<c?o:i,n,r.x,r.y)&&(f=Math.abs(n-r.y)/(i-r.x),si(r,t)&&(f<d||f===d&&(r.x>s.x||r.x===s.x&&Rp(s,r)))&&(s=r,d=f)),r=r.next;while(r!==l);return s}function Rp(t,e){return ue(t.prev,t,e.prev)<0&&ue(e.next,t,t.next)<0}function Sp(t,e,r,i){var n=t;do n.z===null&&(n.z=ms(n.x,n.y,e,r,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,Pp(n)}function Pp(t){var e,r,i,n,o,s,a,l,u=1;do{for(r=t,t=null,o=null,s=0;r;){for(s++,i=r,a=0,e=0;e<u&&(a++,i=i.nextZ,!!i);e++);for(l=u;a>0||l>0&&i;)a!==0&&(l===0||!i||r.z<=i.z)?(n=r,r=r.nextZ,a--):(n=i,i=i.nextZ,l--),o?o.nextZ=n:t=n,n.prevZ=o,o=n;r=i}o.nextZ=null,u*=2}while(s>1);return t}function ms(t,e,r,i,n){return t=32767*(t-r)*n,e=32767*(e-i)*n,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t|e<<1}function Lp(t){var e=t,r=t;do(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;while(e!==t);return r}function Pr(t,e,r,i,n,o,s,a){return(n-s)*(e-a)-(t-s)*(o-a)>=0&&(t-s)*(i-a)-(r-s)*(e-a)>=0&&(r-s)*(o-a)-(n-s)*(i-a)>=0}function Cp(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!kp(t,e)&&(si(t,e)&&si(e,t)&&zp(t,e)&&(ue(t.prev,t,e.prev)||ue(t,e.prev,e))||En(t,e)&&ue(t.prev,t,t.next)>0&&ue(e.prev,e,e.next)>0)}function ue(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function En(t,e){return t.x===e.x&&t.y===e.y}function kc(t,e,r,i){var n=vn(ue(t,e,r)),o=vn(ue(t,e,i)),s=vn(ue(r,i,t)),a=vn(ue(r,i,e));return!!(n!==o&&s!==a||n===0&&Tn(t,r,e)||o===0&&Tn(t,i,e)||s===0&&Tn(r,t,i)||a===0&&Tn(r,e,i))}function Tn(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function vn(t){return t>0?1:t<0?-1:0}function kp(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&kc(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}function si(t,e){return ue(t.prev,t,t.next)<0?ue(t,e,t.next)>=0&&ue(t,t.prev,e)>=0:ue(t,e,t.prev)<0||ue(t,t.next,e)<0}function zp(t,e){var r=t,i=!1,n=(t.x+e.x)/2,o=(t.y+e.y)/2;do r.y>o!=r.next.y>o&&r.next.y!==r.y&&n<(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x&&(i=!i),r=r.next;while(r!==t);return i}function zc(t,e){var r=new ps(t.i,t.x,t.y),i=new ps(e.i,e.x,e.y),n=t.next,o=e.prev;return t.next=e,e.prev=t,r.next=n,n.prev=r,i.next=r,r.prev=i,o.next=i,i.prev=o,i}function Lc(t,e,r,i){var n=new ps(t,e,r);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function ai(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function ps(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}wn.deviation=function(t,e,r,i){var n=e&&e.length,o=n?e[0]*r:t.length,s=Math.abs(gs(t,0,o,r));if(n)for(var a=0,l=e.length;a<l;a++){var u=e[a]*r,c=a<l-1?e[a+1]*r:t.length;s-=Math.abs(gs(t,u,c,r))}var d=0;for(a=0;a<i.length;a+=3){var f=i[a]*r,h=i[a+1]*r,m=i[a+2]*r;d+=Math.abs((t[f]-t[m])*(t[h+1]-t[f+1])-(t[f]-t[h])*(t[m+1]-t[f+1]))}return s===0&&d===0?0:Math.abs((d-s)/s)};function gs(t,e,r,i){for(var n=0,o=e,s=r-i;o<r;o+=i)n+=(t[s]-t[o])*(t[o+1]+t[s+1]),s=o;return n}wn.flatten=function(t){for(var e=t[0][0].length,r={vertices:[],holes:[],dimensions:e},i=0,n=0;n<t.length;n++){for(var o=0;o<t[n].length;o++)for(var s=0;s<e;s++)r.vertices.push(t[n][o][s]);n>0&&(i+=t[n-1].length,r.holes.push(i))}return r}});var td=je((Qw,Ss)=>{(function(){function t(h,m){document.addEventListener?h.addEventListener("scroll",m,!1):h.attachEvent("scroll",m)}function e(h){document.body?h():document.addEventListener?document.addEventListener("DOMContentLoaded",function m(){document.removeEventListener("DOMContentLoaded",m),h()}):document.attachEvent("onreadystatechange",function m(){(document.readyState=="interactive"||document.readyState=="complete")&&(document.detachEvent("onreadystatechange",m),h())})}function r(h){this.a=document.createElement("div"),this.a.setAttribute("aria-hidden","true"),this.a.appendChild(document.createTextNode(h)),this.b=document.createElement("span"),this.c=document.createElement("span"),this.h=document.createElement("span"),this.f=document.createElement("span"),this.g=-1,this.b.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.c.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.f.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.h.style.cssText="display:inline-block;width:200%;height:200%;font-size:16px;max-width:none;",this.b.appendChild(this.h),this.c.appendChild(this.f),this.a.appendChild(this.b),this.a.appendChild(this.c)}function i(h,m){h.a.style.cssText="max-width:none;min-width:20px;min-height:20px;display:inline-block;overflow:hidden;position:absolute;width:auto;margin:0;padding:0;top:-999px;left:-999px;white-space:nowrap;font:"+m+";"}function n(h){var m=h.a.offsetWidth,g=m+100;return h.f.style.width=g+"px",h.c.scrollLeft=g,h.b.scrollLeft=h.b.scrollWidth+100,h.g!==m?(h.g=m,!0):!1}function o(h,m){function g(){var _=p;n(_)&&_.a.parentNode&&m(_.g)}var p=h;t(h.b,g),t(h.c,g),n(h)}function s(h,m){var g=m||{};this.family=h,this.style=g.style||"normal",this.weight=g.weight||"normal",this.stretch=g.stretch||"normal"}var a=null,l=null,u=null,c=null;function d(){if(u===null){var h=document.createElement("div");try{h.style.font="condensed 100px sans-serif"}catch{}u=h.style.font!==""}return u}function f(h,m){return[h.style,h.weight,d()?h.stretch:"","100px",m].join(" ")}s.prototype.load=function(h,m){var g=this,p=h||"BESbswy",_=0,b=m||3e3,x=new Date().getTime();return new Promise(function(T,y){var v;if(c===null&&(c=!!document.fonts),(v=c)&&(l===null&&(l=/OS X.*Version\\/10\\..*Safari/.test(navigator.userAgent)&&/Apple/.test(navigator.vendor)),v=!l),v){v=new Promise(function(M,I){function C(){new Date().getTime()-x>=b?I():document.fonts.load(f(g,'"'+g.family+'"'),p).then(function(z){1<=z.length?M():setTimeout(C,25)},function(){I()})}C()});var P=new Promise(function(M,I){_=setTimeout(I,b)});Promise.race([P,v]).then(function(){clearTimeout(_),T(g)},function(){y(g)})}else e(function(){function M(){var K;(K=k!=-1&&L!=-1||k!=-1&&B!=-1||L!=-1&&B!=-1)&&((K=k!=L&&k!=B&&L!=B)||(a===null&&(K=/AppleWebKit\\/([0-9]+)(?:\\.([0-9]+))/.exec(window.navigator.userAgent),a=!!K&&(536>parseInt(K[1],10)||parseInt(K[1],10)===536&&11>=parseInt(K[2],10))),K=a&&(k==te&&L==te&&B==te||k==q&&L==q&&B==q||k==$&&L==$&&B==$)),K=!K),K&&(Q.parentNode&&Q.parentNode.removeChild(Q),clearTimeout(_),T(g))}function I(){if(new Date().getTime()-x>=b)Q.parentNode&&Q.parentNode.removeChild(Q),y(g);else{var K=document.hidden;(K===!0||K===void 0)&&(k=C.a.offsetWidth,L=z.a.offsetWidth,B=S.a.offsetWidth,M()),_=setTimeout(I,50)}}var C=new r(p),z=new r(p),S=new r(p),k=-1,L=-1,B=-1,te=-1,q=-1,$=-1,Q=document.createElement("div");Q.dir="ltr",i(C,f(g,"sans-serif")),i(z,f(g,"serif")),i(S,f(g,"monospace")),Q.appendChild(C.a),Q.appendChild(z.a),Q.appendChild(S.a),document.body.appendChild(Q),te=C.a.offsetWidth,q=z.a.offsetWidth,$=S.a.offsetWidth,I(),o(C,function(K){k=K,M()}),i(C,f(g,'"'+g.family+'",sans-serif')),o(z,function(K){L=K,M()}),i(z,f(g,'"'+g.family+'",serif')),o(S,function(K){B=K,M()}),i(S,f(g,'"'+g.family+'",monospace'))})})},typeof Ss<"u"?Ss.exports=s:(window.FontFaceObserver=s,window.FontFaceObserver.prototype.load=s.prototype.load)})()});var Ks="0.0.0";var Xn="v"+Ks;var qd=typeof window<"u"&&typeof Window<"u"&&typeof HTMLDocument<"u"&&window instanceof Window&&window.document instanceof HTMLDocument,Qs=typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope,Hd={is_worker:Qs,is_main:qd};if(Qs){let t={document:{}};Reflect.set(globalThis,"window",t),Reflect.set(globalThis,"document",t.document)}var Ae=Hd;var fe={},Z=fe,kt=0,We={};fe.targets={};fe.addTarget=function(t,e){fe.targets[t]=e};fe.removeTarget=function(t){t&&delete fe.targets[t]};function ea(t){var e=[];typeof t=="string"&&(e=t.split("."),t=e.pop());var r=fe.targets;for(let i=0;i<e.length;i++)if(r[e[i]])r=r[e[i]];else return[];return[t,r]}function Xd(){fe.postMessage=function(t,e,...r){if(Array.isArray(t))return Promise.all(t.map(a=>fe.postMessage(a,e,...r)));let i={};typeof e=="object"&&(i=e,e=e.method);var n=new Promise((a,l)=>{We[kt]={method:e,message:r,resolve:a,reject:l}});let o,s=[];return r&&r.length===1&&r[0]instanceof fe.withTransferables&&(s=r[0].transferables,r=r[0].value),o={type:"main_send",message_id:kt,method:e,message:r},i.stringify&&(o=JSON.stringify(o)),t.postMessage(o,s.map(a=>a.object)),Jt(s),s.length>0&&A("trace",\`'\${e}' transferred \${s.length} objects to worker thread\`),kt++,n},fe.addWorker=function(t){if(!(t instanceof Worker))throw Error("Worker broker could not add non-Worker object",t);t.addEventListener("message",function(r){let i=typeof r.data=="string"?JSON.parse(r.data):r.data,n=i.message_id;if(i.type==="worker_reply")We[n]&&(i.error?We[n].reject(i.error):We[n].resolve(i.message),delete We[n]);else if(i.type==="worker_send"&&n!=null){let o,s,a,l,u;try{if([l,a]=ea(i.method),!a)throw Error(\`Worker broker could not dispatch message type \${i.method} on target \${i.target} because no object with that name is registered on main thread\`);if(u=typeof a[l]=="function"&&a[l],!u)throw Error(\`Worker broker could not dispatch message type \${i.method} on target \${i.target} because object has no method with that name\`);o=u.apply(a,i.message)}catch(f){s=f}let c,d=[];o instanceof Promise?o.then(f=>{f instanceof fe.withTransferables&&(d=f.transferables,f=f.value[0]),c={type:"main_reply",message_id:n,message:f},t.postMessage(c,d.map(h=>h.object)),Jt(d),d.length>0&&A("trace",\`'\${l}' transferred \${d.length} objects to worker thread\`)},f=>{t.postMessage({type:"main_reply",message_id:n,error:f instanceof Error?\`\${f.message}: \${f.stack}\`:f})}):(o instanceof fe.withTransferables&&(d=o.transferables,o=o.value[0]),c={type:"main_reply",message_id:n,message:o,error:s instanceof Error?\`\${s.message}: \${s.stack}\`:s},t.postMessage(c,d.map(f=>f.object)),Jt(d),d.length>0&&A("trace",\`'\${l}' transferred \${d.length} objects to worker thread\`))}})},fe.getMessages=function(){return We},fe.getMessageId=function(){return kt}}function Yd(){fe.postMessage=function(t,...e){let r={};typeof t=="object"&&(r=t,t=t.method);var i=new Promise((s,a)=>{We[kt]={method:t,message:e,resolve:s,reject:a}});let n,o=[];return e&&e.length===1&&e[0]instanceof fe.withTransferables&&(o=e[0].transferables,e=e[0].value),n={type:"worker_send",message_id:kt,method:t,message:e},r.stringify&&(n=JSON.stringify(n)),self.postMessage(n,o.map(s=>s.object)),Jt(o),o.length>0&&A("trace",\`'\${t}' transferred \${o.length} objects to main thread\`),kt++,i},self.addEventListener("message",function(e){let r=typeof e.data=="string"?JSON.parse(e.data):e.data,i=r.message_id;if(r.type==="main_reply")We[i]&&(r.error?We[i].reject(r.error):We[i].resolve(r.message),delete We[i]);else if(r.type==="main_send"&&i!=null){let n,o,s,a,l;try{if([a,s]=ea(r.method),!s)throw Error(\`Worker broker could not dispatch message type \${r.method} on target \${r.target} because no object with that name is registered on main thread\`);if(l=typeof s[a]=="function"&&s[a],!l)throw Error(\`Worker broker could not dispatch message type \${r.method} because worker has no method with that name\`);n=l.apply(s,r.message)}catch(d){o=d}let u,c=[];n instanceof Promise?n.then(d=>{d instanceof fe.withTransferables&&(c=d.transferables,d=d.value[0]),u={type:"worker_reply",message_id:i,message:d},self.postMessage(u,c.map(f=>f.object)),Jt(c),c.length>0&&A("trace",\`'\${a}' transferred \${c.length} objects to main thread\`)},d=>{self.postMessage({type:"worker_reply",message_id:i,error:d instanceof Error?\`\${d.message}: \${d.stack}\`:d})}):(n instanceof fe.withTransferables&&(c=n.transferables,n=n.value[0]),u={type:"worker_reply",message_id:i,message:n,error:o instanceof Error?\`\${o.message}: \${o.stack}\`:o},self.postMessage(u,c.map(d=>d.object)),Jt(c),c.length>0&&A("trace",\`'\${a}' transferred \${c.length} objects to main thread\`))}})}fe.withTransferables=function(...t){if(!(this instanceof fe.withTransferables))return new fe.withTransferables(...t);this.value=t,this.transferables=Yn(this.value)};function Yn(t,e=null,r=null,i=[]){if(!t)return i;if(Array.isArray(t))t.forEach((n,o)=>Yn(n,t,o,i));else if(typeof t=="object")if(t instanceof ArrayBuffer)i.push({object:t,parent:e,property:r});else if(t.buffer instanceof ArrayBuffer)i.push({object:t.buffer,parent:e,property:r});else for(let n in t)Yn(t[n],t,n,i);return i}function Jt(t){Array.isArray(t)&&t.filter(e=>e.parent&&e.property).forEach(e=>delete e.parent[e.property])}Ae.is_main&&Xd();Ae.is_worker&&Yd();var ra=Z,ta={silent:-1,error:0,warn:1,info:2,debug:3,trace:4},Zn={},Jn={};function Zd(t){if(!Zn[t]){let e=console;Zn[t]=(e[t]||console.log).bind(console)}return Zn[t]}var ze=(async(t,...e)=>{let r=typeof t=="object"?t.level:t;if(ta[r]>ta[ze.level])return!1;if(Ae.is_worker)return ra.postMessage({method:"_logProxy",stringify:!0},t,...e);if(typeof t=="object"&&t.once===!0){let n=JSON.stringify(e);if(Jn[n])return!1;Jn[n]=!0}let i=Zd(r);return e.length>1?i(\`Tangram \${Xn} [\${r}]: \${e[0]}\`,...e.slice(1)):i(\`Tangram \${Xn} [\${r}]: \${e[0]}\`),!0});ze.level="info";ze.workers=null;ze.setLevel=t=>{ze.level=t,Ae.is_main&&Array.isArray(ze.workers)&&ra.postMessage(ze.workers,"_logSetLevelProxy",t)};Ae.is_worker||(ze.setWorkers=t=>{ze.workers=t},ze.reset=()=>{Jn={}});Z.addTarget("_logProxy",ze);Z.addTarget("_logSetLevelProxy",ze.setLevel);var A=ze;var se={},J=se;Z.addTarget("Utils",se);se.isSafari=function(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)};se.isMicrosoft=function(){return/(Trident\\/7.0|Edge[ /](\\d+[.\\d]+))/i.test(navigator.userAgent)};se._requests={};se._proxy_requests={};se.io=function(t,e=6e4,r="text",i="GET",n={},o=null,s=!1){if(Ae.is_worker&&se.isMicrosoft())return A("debug","Proxying request for URL to worker",t),o&&(se._proxy_requests[o]=!0),Z.postMessage("Utils.io",t,e,r,i,n,o,!0);{let a=new XMLHttpRequest,l=new Promise((u,c)=>{if(a.open(i,t,!0),a.timeout=e,a.responseType=r,n&&typeof n=="object")for(let d in n)a.setRequestHeader(d,n[d]);a.onload=()=>{a.status===200?["text","json"].indexOf(a.responseType)>-1?u({body:a.responseText,status:a.status}):u({body:a.response,status:a.status}):a.status===204?u({body:null,status:a.status}):c(Error("Request error with a status of "+a.statusText))},a.onerror=d=>{c(Error("There was a network error"+d.toString()))},a.ontimeout=d=>{c(Error("timeout "+d.toString()))},a.send()});return l=l.then(u=>(o&&delete se._requests[o],s?Z.withTransferables(u):u)),o&&(se._requests[o]=a),l}};se.cancelRequest=function(t){if(Ae.is_worker&&se._proxy_requests[t])return Z.postMessage("Utils.cancelRequest",t);se._requests[t]?(A("trace",\`Cancelling network request key '\${t}'\`),se._requests[t].abort(),delete se._requests[t]):A("trace",\`Could not find network request key '\${t}'\`)};se.serializeWithFunctions=function(t){return typeof t=="function"?t.toString():JSON.stringify(t,function(r,i){return typeof i=="function"?i.toString():i})};se.use_high_density_display=!0;se.updateDevicePixelRatio=function(){let t=se.device_pixel_ratio;return se.device_pixel_ratio=se.use_high_density_display&&window.devicePixelRatio||1,se.device_pixel_ratio!==t};Ae.is_main&&se.updateDevicePixelRatio();se.isPowerOf2=function(t){return(t&t-1)===0};se.interpolate=function(t,e,r){if(!Array.isArray(e)||!Array.isArray(e[0]))return e;if(e.length<1)return e;let i,n,o,s,a,l,u=e;if(t<=u[0][0])s=u[0][1],typeof r=="function"&&(s=r(s));else if(t>=u[u.length-1][0])s=u[u.length-1][1],typeof r=="function"&&(s=r(s));else for(let c=0;c<u.length-1;c++)if(t>=u[c][0]&&t<u[c+1][0]){i=u[c][0],n=u[c+1][0];let d=u[c][1],f=u[c+1][1];if(Array.isArray(d)&&Array.isArray(f)){s=[];for(let h=0;h<d.length;h++)typeof r=="function"?(a=r(d[h]),l=r(f[h]),o=l-a,s[h]=o*(t-i)/(n-i)+a):(o=f[h]-d[h],s[h]=o*(t-i)/(n-i)+d[h])}else typeof r=="function"?(a=r(d),l=r(f),o=l-a,s=o*(t-i)/(n-i)+a):(o=f-d,s=o*(t-i)/(n-i)+d);break}return s};se.toCSSColor=function(t){if(t!=null)return t[3]===1?\`rgb(\${t.slice(0,3).map(e=>Math.round(e*255)).join(", ")})\`:\`rgba(\${t.map((e,r)=>r<3&&Math.round(e*255)||e).join(", ")})\`};function De(t){let e=0;for(let r=0;r<t.length;r++)e=(e<<5)-e+t.charCodeAt(r),e|=0;return e}var Ze={functions:{},num_functions:0,num_cached:0};function ia(){Ze.functions={},Ze.num_functions=0,Ze.num_cached=0}function tt(t,e){if(typeof t=="string")return gi(t,e);if(t!=null&&typeof t=="object"){let r=t;for(let i in r)r[i]=tt(r[i],e)}return t}function gi(t,e){let r=typeof t=="string"&&t.match(/^\\s*function[^(]*\\(([^)]*)\\)\\s*?\\{([\\s\\S]*)\\}$/m);if(r&&r.length>2)try{let i=r[2],n=e?e(i):i,o=De(n);if(Ze.functions[o]===void 0){let s=r[1].split(",").map(u=>u.trim()).filter(Boolean),a=s.length>0?s:["context"],l=new Function(a.toString(),n);l.source=i,Ze.functions[o]=l,Ze.num_functions++}else Ze.num_cached++;return Ze.functions[o]}catch{return t}return t}var na={draw_label_collision_boxes:!1,draw_label_texture_boxes:!1,suppress_label_fade_in:!1,suppress_label_snap_animation:!1,show_hidden_labels:!1,layer_stats:!1,wireframe:!1},Ne=na;function oa(t){Object.assign(na,t)}function sa(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Ce(t,...e){let r=t;for(let i of e)if(i)for(let n in i){let s=i[n];if(sa(s)){let a=r[n];r[n]=sa(a)?Ce(a,s):Ce({},s)}else s!==void 0&&(r[n]=s)}return t}function aa(t,e,r){let i=e[0],n=e[1],o=e[2],s=e[3];return t[0]=r[0]*i+r[4]*n+r[8]*o+r[12]*s,t[1]=r[1]*i+r[5]*n+r[9]*o+r[13]*s,t[2]=r[2]*i+r[6]*n+r[10]*o+r[14]*s,t[3]=r[3]*i+r[7]*n+r[11]*o+r[15]*s,t}function Jd(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function la(t,e){if(t===e){let r=e[1],i=e[2],n=e[3],o=e[6],s=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=i,t[9]=o,t[11]=e[14],t[12]=n,t[13]=s,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function ua(t,e){let r=e[0],i=e[1],n=e[2],o=e[3],s=e[4],a=e[5],l=e[6],u=e[7],c=e[8],d=e[9],f=e[10],h=e[11],m=e[12],g=e[13],p=e[14],_=e[15],b=r*a-i*s,x=r*l-n*s,T=r*u-o*s,y=i*l-n*a,v=i*u-o*a,P=n*u-o*l,M=c*g-d*m,I=c*p-f*m,C=c*_-h*m,z=d*p-f*g,S=d*_-h*g,k=f*_-h*p,L=b*k-x*S+T*z+y*C-v*I+P*M;return L?(L=1/L,t[0]=(a*k-l*S+u*z)*L,t[1]=(n*S-i*k-o*z)*L,t[2]=(g*P-p*v+_*y)*L,t[3]=(f*v-d*P-h*y)*L,t[4]=(l*C-s*k-u*I)*L,t[5]=(r*k-n*C+o*I)*L,t[6]=(p*T-m*P-_*x)*L,t[7]=(c*P-f*T+h*x)*L,t[8]=(s*S-a*C+u*M)*L,t[9]=(i*C-r*S-o*M)*L,t[10]=(m*v-g*T+_*b)*L,t[11]=(d*T-c*v-h*b)*L,t[12]=(a*I-s*z-l*M)*L,t[13]=(r*z-i*I+n*M)*L,t[14]=(g*x-m*y-p*b)*L,t[15]=(c*y-d*x+f*b)*L,t):null}function ca(t){let e=t[0],r=t[1],i=t[2],n=t[3],o=t[4],s=t[5],a=t[6],l=t[7],u=t[8],c=t[9],d=t[10],f=t[11],h=t[12],m=t[13],g=t[14],p=t[15],_=e*s-r*o,b=e*a-i*o,x=r*a-i*s,T=u*m-c*h,y=u*g-d*h,v=c*g-d*m,P=e*v-r*y+i*T,M=o*v-s*y+a*T,I=u*x-c*b+d*_,C=h*x-m*b+g*_;return l*P-n*M+p*I-f*C}function Qn(t,e,r){let i=e[0],n=e[1],o=e[2],s=e[3],a=e[4],l=e[5],u=e[6],c=e[7],d=e[8],f=e[9],h=e[10],m=e[11],g=e[12],p=e[13],_=e[14],b=e[15],x=r[0],T=r[1],y=r[2],v=r[3];return t[0]=x*i+T*a+y*d+v*g,t[1]=x*n+T*l+y*f+v*p,t[2]=x*o+T*u+y*h+v*_,t[3]=x*s+T*c+y*m+v*b,x=r[4],T=r[5],y=r[6],v=r[7],t[4]=x*i+T*a+y*d+v*g,t[5]=x*n+T*l+y*f+v*p,t[6]=x*o+T*u+y*h+v*_,t[7]=x*s+T*c+y*m+v*b,x=r[8],T=r[9],y=r[10],v=r[11],t[8]=x*i+T*a+y*d+v*g,t[9]=x*n+T*l+y*f+v*p,t[10]=x*o+T*u+y*h+v*_,t[11]=x*s+T*c+y*m+v*b,x=r[12],T=r[13],y=r[14],v=r[15],t[12]=x*i+T*a+y*d+v*g,t[13]=x*n+T*l+y*f+v*p,t[14]=x*o+T*u+y*h+v*_,t[15]=x*s+T*c+y*m+v*b,t}function da(t,e,r){let i=r[0],n=r[1],o=r[2],s,a,l,u,c,d,f,h,m,g,p,_;return e===t?(t[12]=e[0]*i+e[4]*n+e[8]*o+e[12],t[13]=e[1]*i+e[5]*n+e[9]*o+e[13],t[14]=e[2]*i+e[6]*n+e[10]*o+e[14],t[15]=e[3]*i+e[7]*n+e[11]*o+e[15]):(s=e[0],a=e[1],l=e[2],u=e[3],c=e[4],d=e[5],f=e[6],h=e[7],m=e[8],g=e[9],p=e[10],_=e[11],t[0]=s,t[1]=a,t[2]=l,t[3]=u,t[4]=c,t[5]=d,t[6]=f,t[7]=h,t[8]=m,t[9]=g,t[10]=p,t[11]=_,t[12]=s*i+c*n+m*o+e[12],t[13]=a*i+d*n+g*o+e[13],t[14]=l*i+f*n+p*o+e[14],t[15]=u*i+h*n+_*o+e[15]),t}function fa(t,e,r){let i=r[0],n=r[1],o=r[2];return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t[4]=e[4]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function ha(t,e,r,i){let n=i[0],o=i[1],s=i[2],a=Math.sqrt(n*n+o*o+s*s),l,u,c,d,f,h,m,g,p,_,b,x,T,y,v,P,M,I,C,z,S,k,L,B;return a<1e-6?null:(a=1/a,n*=a,o*=a,s*=a,u=Math.sin(r),l=Math.cos(r),c=1-l,d=e[0],f=e[1],h=e[2],m=e[3],g=e[4],p=e[5],_=e[6],b=e[7],x=e[8],T=e[9],y=e[10],v=e[11],P=n*n*c+l,M=o*n*c+s*u,I=s*n*c-o*u,C=n*o*c-s*u,z=o*o*c+l,S=s*o*c+n*u,k=n*s*c+o*u,L=o*s*c-n*u,B=s*s*c+l,t[0]=d*P+g*M+x*I,t[1]=f*P+p*M+T*I,t[2]=h*P+_*M+y*I,t[3]=m*P+b*M+v*I,t[4]=d*C+g*z+x*S,t[5]=f*C+p*z+T*S,t[6]=h*C+_*z+y*S,t[7]=m*C+b*z+v*S,t[8]=d*k+g*L+x*B,t[9]=f*k+p*L+T*B,t[10]=h*k+_*L+y*B,t[11]=m*k+b*L+v*B,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function ma(t,e,r){let i=Math.sin(r),n=Math.cos(r),o=e[4],s=e[5],a=e[6],l=e[7],u=e[8],c=e[9],d=e[10],f=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*n+u*i,t[5]=s*n+c*i,t[6]=a*n+d*i,t[7]=l*n+f*i,t[8]=u*n-o*i,t[9]=c*n-s*i,t[10]=d*n-a*i,t[11]=f*n-l*i,t}function pa(t,e,r){let i=Math.sin(r),n=Math.cos(r),o=e[0],s=e[1],a=e[2],l=e[3],u=e[8],c=e[9],d=e[10],f=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*n-u*i,t[1]=s*n-c*i,t[2]=a*n-d*i,t[3]=l*n-f*i,t[8]=o*i+u*n,t[9]=s*i+c*n,t[10]=a*i+d*n,t[11]=l*i+f*n,t}function ga(t,e,r){let i=Math.sin(r),n=Math.cos(r),o=e[0],s=e[1],a=e[2],l=e[3],u=e[4],c=e[5],d=e[6],f=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*n+u*i,t[1]=s*n+c*i,t[2]=a*n+d*i,t[3]=l*n+f*i,t[4]=u*n-o*i,t[5]=c*n-s*i,t[6]=d*n-a*i,t[7]=f*n-l*i,t}function _a(t,e){let r=e[0],i=e[1],n=e[2],o=e[3],s=r+r,a=i+i,l=n+n,u=r*s,c=i*s,d=i*a,f=n*s,h=n*a,m=n*l,g=o*s,p=o*a,_=o*l;return t[0]=1-d-m,t[1]=c+_,t[2]=f-p,t[3]=0,t[4]=c-_,t[5]=1-u-m,t[6]=h+g,t[7]=0,t[8]=f+p,t[9]=h-g,t[10]=1-u-d,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function ba(t,e,r,i,n,o,s){let a=1/(r-e),l=1/(n-i),u=1/(o-s);return t[0]=o*2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o*2*l,t[6]=0,t[7]=0,t[8]=(r+e)*a,t[9]=(n+i)*l,t[10]=(s+o)*u,t[11]=-1,t[12]=0,t[13]=0,t[14]=s*o*2*u,t[15]=0,t}function Kd(t,e,r,i,n){let o=1/Math.tan(e/2);if(t[0]=o/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,n!=null&&n!==1/0){let s=1/(i-n);t[10]=(n+i)*s,t[14]=2*n*i*s}else t[10]=-1,t[14]=-2*i;return t}var ya=Kd;function Qd(t,e,r,i,n,o,s){let a=1/(e-r),l=1/(i-n),u=1/(o-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*u,t[11]=0,t[12]=(e+r)*a,t[13]=(n+i)*l,t[14]=(s+o)*u,t[15]=1,t}var xa=Qd;function Ta(t,e,r,i){let n,o,s,a,l,u,c,d,f,h,m=e[0],g=e[1],p=e[2],_=i[0],b=i[1],x=i[2],T=r[0],y=r[1],v=r[2];return Math.abs(m-T)<1e-6&&Math.abs(g-y)<1e-6&&Math.abs(p-v)<1e-6?Jd(t):(d=m-T,f=g-y,h=p-v,n=1/Math.sqrt(d*d+f*f+h*h),d*=n,f*=n,h*=n,o=b*h-x*f,s=x*d-_*h,a=_*f-b*d,n=Math.sqrt(o*o+s*s+a*a),n?(n=1/n,o*=n,s*=n,a*=n):(o=0,s=0,a=0),l=f*a-h*s,u=h*o-d*a,c=d*s-f*o,n=Math.sqrt(l*l+u*u+c*c),n?(n=1/n,l*=n,u*=n,c*=n):(l=0,u=0,c=0),t[0]=o,t[1]=l,t[2]=d,t[3]=0,t[4]=s,t[5]=u,t[6]=f,t[7]=0,t[8]=a,t[9]=c,t[10]=h,t[11]=0,t[12]=-(o*m+s*g+a*p),t[13]=-(l*m+u*g+c*p),t[14]=-(d*m+f*g+h*p),t[15]=1,t)}function va(t,e,r){let i=e[0],n=e[1];return t[0]=r[0]*i+r[2]*n,t[1]=r[1]*i+r[3]*n,t}function wa(t,e,r){let i=e[0],n=e[1];return t[0]=r[0]*i+r[2]*n+r[4],t[1]=r[1]*i+r[3]*n+r[5],t}function Ea(t,e,r){let i=e[0],n=e[1];return t[0]=r[0]*i+r[3]*n+r[6],t[1]=r[1]*i+r[4]*n+r[7],t}function _i(t,e,r){let i=e[0],n=e[1];return t[0]=r[0]*i+r[4]*n+r[12],t[1]=r[1]*i+r[5]*n+r[13],t}function ef(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Ma(t,e,r){let i=e[0],n=e[1],o=e[2],s=r[0],a=r[1],l=r[2];return t[0]=n*l-o*a,t[1]=o*s-i*l,t[2]=i*a-n*s,t}function bi(t,e,r){let i=e[0],n=e[1],o=e[2],s=r[3]*i+r[7]*n+r[11]*o+r[15];return s=s||1,t[0]=(r[0]*i+r[4]*n+r[8]*o+r[12])/s,t[1]=(r[1]*i+r[5]*n+r[9]*o+r[13])/s,t[2]=(r[2]*i+r[6]*n+r[10]*o+r[14])/s,t}function Aa(t,e,r){let i=e[0],n=e[1],o=e[2];return t[0]=i*r[0]+n*r[3]+o*r[6],t[1]=i*r[1]+n*r[4]+o*r[7],t[2]=i*r[2]+n*r[5]+o*r[8],t}function Ra(t,e,r){let i=r[0],n=r[1],o=r[2],s=r[3],a=e[0],l=e[1],u=e[2],c=n*u-o*l,d=o*a-i*u,f=i*l-n*a,h=n*f-o*d,m=o*c-i*f,g=i*d-n*c,p=s*2;return c*=p,d*=p,f*=p,h*=2,m*=2,g*=2,t[0]=a+c+h,t[1]=l+d+m,t[2]=u+f+g,t}function Sa(t,e,r,i){let n=[],o=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],o[0]=n[0],o[1]=n[1]*Math.cos(i)-n[2]*Math.sin(i),o[2]=n[1]*Math.sin(i)+n[2]*Math.cos(i),t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function Pa(t,e,r,i){let n=[],o=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],o[0]=n[2]*Math.sin(i)+n[0]*Math.cos(i),o[1]=n[1],o[2]=n[2]*Math.cos(i)-n[0]*Math.sin(i),t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function La(t,e,r,i){let n=[],o=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],o[0]=n[0]*Math.cos(i)-n[1]*Math.sin(i),o[1]=n[0]*Math.sin(i)+n[1]*Math.cos(i),o[2]=n[2],t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function Ca(t,e){let r=t[0],i=t[1],n=t[2],o=e[0],s=e[1],a=e[2],l=Math.sqrt((r*r+i*i+n*n)*(o*o+s*s+a*a)),u=l&&ef(t,e)/l;return Math.acos(Math.min(Math.max(u,-1),1))}function yi(t,e){if(!t)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}var $e=Math.PI,Fa=$e/4,ka=$e/180,za=180/$e,xi=512;function Kt(t){let[e,r]=t;yi(Number.isFinite(e)),yi(Number.isFinite(r)&&r>=-90&&r<=90,"invalid latitude");let i=e*ka,n=r*ka,o=xi*(i+$e)/(2*$e),s=xi*($e+Math.log(Math.tan(Fa+n*.5)))/(2*$e);return[o,s]}function pt(t){let[e,r]=t,i=e/xi*(2*$e)-$e,n=2*(Math.atan(Math.exp(r/xi*(2*$e)-$e))-Fa);return[i*za,n*za]}var D_=Math.PI/180;var Ti=Math.PI,Q_=Ti/180,gf=180/Ti,Da=6378137,Ba=Ti*Da,_f=Math.atan(Math.sinh(Ti))*gf,bf=512/(2*Ba);var vi=20037508342789244e-9;function Ia(t){let e=t[0]*(vi/180),r=Math.log(Math.tan(t[1]*Math.PI/360+Math.PI/4))/Math.PI*vi;return[e,r]}function Ga(t){let e=t[0]/vi*180,r=t[1]/vi,i=(2*Math.atan(Math.exp(r*Math.PI))-Math.PI/2)/Math.PI*180;return[e,i]}var wi=512,Gr=20037508342789244e-9,Ei=Gr*2;function Va(t){let e=t*1073741824,r=Math.round(e),i=Number.EPSILON*Math.max(1,Math.abs(e))*4;return Math.abs(e-r)<=i}function Ua(t){let[e,r]=Kt([t[0],t[1]]),i=e/wi,n=r/wi,o=Va(i)||Va(n)?Ia(t):void 0;return[o?.[0]??i*Ei-Gr,o?.[1]??n*Ei-Gr]}function ja(t){let e=(t[0]+Gr)/Ei*wi,r=(t[1]+Gr)/Ei*wi;return pt([e,r])}var Y=Object.freeze({mercatorRadius:6378137,earthRadius:6370972,globeRadius:256,tileSize:256,maxMercatorLatitude:85.0511287798066});function Wa(t,e,r){let[i,n,o]=t;if(e==="projected")throw new Error("CPU-projected basemaps require the experimental worker procedure");if(!t.every(Number.isFinite)||Math.abs(n)>90)throw new Error("Projection requires finite geographic coordinates and latitude within +/-90 degrees");if(e==="globe"){i*=Math.PI/180,n*=Math.PI/180;let s=Y.globeRadius*(1+o/Y.earthRadius);return[Math.sin(i)*Math.cos(n)*s,-Math.cos(i)*Math.cos(n)*s,Math.sin(n)*s]}return r!=null&&Number.isFinite(r)&&(i+=Math.round((r-i)/360)*360),n=Math.max(-Y.maxMercatorLatitude,Math.min(Y.maxMercatorLatitude,n)),[Y.mercatorRadius*i*Math.PI/180,Y.mercatorRadius*Math.log(Math.tan(Math.PI/4+n*Math.PI/360)),o]}function eo(t,e,r){if(r==="projected")throw new Error("CPU-projected basemaps do not support geographic lighting");let[i,n,o]=e;if(r==="web-mercator")return[i,n,o];let s=t[0]*Math.PI/180,a=t[1]*Math.PI/180;return[i*Math.cos(s)-n*Math.sin(s)*Math.sin(a)+o*Math.sin(s)*Math.cos(a),i*Math.sin(s)+n*Math.cos(s)*Math.sin(a)-o*Math.cos(s)*Math.cos(a),n*Math.cos(a)+o*Math.sin(a)]}function xf(t){let e=Math.hypot(...t);if(!t.every(Number.isFinite)||e===0)throw new Error("Globe position must be finite and non-zero");return[Math.atan2(t[0],-t[1])*180/Math.PI,Math.asin(Math.max(-1,Math.min(1,t[2]/e)))*180/Math.PI,(e/Y.globeRadius-1)*Y.earthRadius]}function $a(t){return 2*Math.PI*Y.mercatorRadius/Y.tileSize/Math.pow(2,t)}function to(t,e,r){if(r==="projected")throw new Error("CPU-projected basemaps require explicit LOD");if(r==="web-mercator")return{position:[t,e,0],derivativeX:[1,0,0],derivativeY:[0,1,0]};let i=t/Y.mercatorRadius,n=Math.atan(Math.sinh(e/Y.mercatorRadius)),o=Math.cos(n),s=Math.sin(n),a=Math.sin(i),l=Math.cos(i),u=Y.globeRadius,c=u/Y.mercatorRadius;return{position:[u*a*o,-u*l*o,u*s],derivativeX:[c*l*o,c*a*o,0],derivativeY:[-c*a*s*o,c*l*s*o,c*o**2]}}function Tf(t){if(!t.every(Number.isFinite))throw new Error("Mercator position must be finite");let[e,r]=Ga([t[0],t[1]]);return[e,r,t[2]]}var vf=Object.freeze({"web-mercator":Object.freeze({type:"web-mercator",positionUnits:"meters",latitudeLimit:Y.maxMercatorLatitude,longitudePolicy:"nearest-anchor-or-unwrapped",project:(t,e)=>Wa(t,"web-mercator",e),unproject:Tf,projectVector:(t,e)=>eo(t,e,"web-mercator")}),globe:Object.freeze({type:"globe",positionUnits:"globe-common-units",latitudeLimit:90,longitudePolicy:"periodic",project:t=>Wa(t,"globe"),unproject:xf,projectVector:(t,e)=>eo(t,e,"globe")})});function Qt(t){if(t!=="web-mercator"&&t!=="globe")throw new Error("Unsupported geographic projection; expected web-mercator or globe");return vf[t]}function Mi(t,e=!1){let r=t??0;if(typeof r!="number"||!Number.isFinite(r))throw new Error("Projected annotation height must be finite meters");if(r!==0&&!e)throw new Error("Projected symbols require ground anchors unless allowElevation is enabled");if(r<-32768/16||r>32767/16)throw new Error("Projected annotation height exceeds signed-short storage");return Math.trunc(r*16)}var V={},R=V;V.default_source_max_zoom=18;V.default_view_max_zoom=20;V.max_style_zoom=25;V.tile_size=Y.tileSize;V.half_circumference_meters=Math.PI*Y.mercatorRadius;V.circumference_meters=V.half_circumference_meters*2;V.min_zoom_meters_per_pixel=V.circumference_meters/V.tile_size;var ro=[];V.metersPerPixel=function(t){return ro[t]=ro[t]||$a(t),ro[t]};var io=[];V.metersPerTile=function(t){return io[t]=io[t]||V.circumference_meters/Math.pow(2,t),io[t]};V.tile_scale=4096;V.units_per_pixel=V.tile_scale/V.tile_size;V.height_scale=16;var no=[];V.unitsPerMeter=function(t){return no[t]=no[t]||V.tile_scale/(V.tile_size*V.metersPerPixel(t)),no[t]};V.metersForTile=function(t){return{x:t.x*V.circumference_meters/Math.pow(2,t.z)-V.half_circumference_meters,y:-(t.y*V.circumference_meters/Math.pow(2,t.z)-V.half_circumference_meters)}};V.tileForMeters=function([t,e],r){return{x:Math.floor((t+V.half_circumference_meters)/(V.circumference_meters/Math.pow(2,r))),y:Math.floor((-e+V.half_circumference_meters)/(V.circumference_meters/Math.pow(2,r))),z:r}};V.wrapTile=function({x:t,y:e,z:r},i={x:!0,y:!1}){var n=(1<<r)-1;return i.x&&(t=t&n),i.y&&(e=e&n),{x:t,y:e,z:r}};V.metersToLatLng=function(t){let e=ja([t[0],t[1]]);return t[0]=e[0],t[1]=e[1],t};V.latLngToMeters=function(t){let e=Ua([t[0],t[1]]);return t[0]=e[0],t[1]=e[1],t};V.tileSpaceToLatlng=function(t,e,r){let i=V.unitsPerMeter(e);return V.transformGeometry(t,n=>{n[0]=n[0]/i+r.x,n[1]=n[1]/i+r.y,V.metersToLatLng(n)}),t};V.copyGeometry=function(t){if(t==null)return;let e=t.coordinates,r={type:t.type,coordinates:void 0};return t.type==="Point"?r.coordinates=[e[0],e[1]]:t.type==="LineString"||t.type==="MultiPoint"?r.coordinates=e.map(i=>[i[0],i[1]]):t.type==="Polygon"||t.type==="MultiLineString"?r.coordinates=e.map(i=>i.map(n=>[n[0],n[1]])):t.type==="MultiPolygon"&&(r.coordinates=e.map(i=>i.map(n=>n.map(o=>[o[0],o[1]])))),r};V.transformGeometry=function(t,e){t!=null&&(t.type==="Point"?e(t.coordinates):t.type==="LineString"||t.type==="MultiPoint"?t.coordinates.forEach(e):t.type==="Polygon"||t.type==="MultiLineString"?t.coordinates.forEach(r=>r.forEach(e)):t.type==="MultiPolygon"&&t.coordinates.forEach(r=>{r.forEach(i=>i.forEach(e))}))};V.boxIntersect=function(t,e){return!(e.sw.x>t.ne.x||e.ne.x<t.sw.x||e.sw.y>t.ne.y||e.ne.y<t.sw.y)};V.findBoundingBox=function(t){for(var e=1/0,r=-1/0,i=1/0,n=-1/0,o=t[0].length,s=0;s<o;s++){var a=t[0][s];a[0]<e&&(e=a[0]),a[1]<i&&(i=a[1]),a[0]>r&&(r=a[0]),a[1]>n&&(n=a[1])}return[e,i,r,n]};V.geometryType=function(t){if(t==="Polygon"||t==="MultiPolygon")return"polygon";if(t==="LineString"||t==="MultiLineString")return"line";if(t==="Point"||t==="MultiPoint")return"point"};V.centroid=function(t,e=!0){if(!t||t.length===0)return;let r=0,i=0,n=0,o=t[0],s=o.length,a;if(e){let u=o[0];a=u,o=o.map(c=>[c[0]-u[0],c[1]-u[1]])}for(let u=0,c=s-1;u<s;c=u,u++){let d=o[u],f=o[c],h=d[1]*f[0]-f[1]*d[0];r+=(d[0]+f[0])*h,i+=(d[1]+f[1])*h,n+=h*3}if(!n)return;let l=[r/n,i/n];return e&&(l[0]+=a[0],l[1]+=a[1]),l};V.multiCentroid=function(t){let e=0,r=null;for(let i=0;i<t.length;i++){let n=V.centroid(t[i]);n&&(r=r||[0,0],r[0]+=n[0],r[1]+=n[1],e++)}return e>0&&(r[0]/=e,r[1]/=e),r};V.signedPolygonRingAreaSum=function(t){let e=0,r=t.length;for(let i=0;i<r-1;i++){let n=t[i],o=t[i+1];e+=n[0]*o[1]-o[0]*n[1]}return e+=t[r-1][0]*t[0][1]-t[0][0]*t[r-1][1],e};V.polygonRingArea=function(t){return Math.abs(V.signedPolygonRingAreaSum(t))/2};V.polygonArea=function(t){if(t)return V.polygonRingArea(t[0])};V.multiPolygonArea=function(t){let e=0;for(let r=0;r<t.length;r++)e+=V.polygonArea(t[r])||0;return e};V.ringWinding=function(t){let e=V.signedPolygonRingAreaSum(t);if(e>0)return"CW";if(e<0)return"CCW"};var it={coord(t){return{x:t.x,y:t.y,z:t.z,key:this.coordKey(t)}},coordKey({x:t,y:e,z:r}){return t+"/"+e+"/"+r},key(t,e,r){if(!(t.y<0||t.y>=1<<t.z||t.z<0))return[e.name,t.x,t.y,t.z,r].join("/")},normalizedKey(t,e,r){return this.key(this.normalizedCoord(t,e),e,r)},normalizedCoord(t,e){return e.zoom_bias&&(t=this.coordAtZoom(t,Math.max(t.z-e.zoom_bias,e.zooms[0]))),this.coordForTileZooms(t,e.zooms)},coordAtZoom({x:t,y:e,z:r},i){if(i=Math.max(0,i),r!==i){let n=Math.pow(2,r-i);t=Math.floor(t/n),e=Math.floor(e/n),r=i}return this.coord({x:t,y:e,z:r})},coordForTileZooms({x:t,y:e,z:r},i){let n=this.findZoomInRange(r,i);return n!==r?this.coordAtZoom({x:t,y:e,z:r},n):this.coord({x:t,y:e,z:r})},findZoomInRange(t,e){return e.filter(r=>t>=r).reverse()[0]||e[0]},isDescendant(t,e){if(e.z>t.z){let{x:r,y:i}=this.coordAtZoom(e,t.z);return t.x===r&&t.y===i}return!1},parent({coords:t,source:e,style_z:r}){if(r>0){r--;let i=Math.max(r-(e.zoom_bias||0),e.zooms[0]),n=this.coordForTileZooms(this.coordAtZoom(t,i),e.zooms);return n.z>r?null:{key:this.key(n,e,r),coords:n,style_z:r,source:e}}},children({coords:t,source:e,style_z:r},i={}){r++;let n=this.coordForTileZooms(this.coordAtZoom(t,r-(e.zoom_bias||0)),e.zooms);if(n.z===t.z)return[{key:this.key(n,e,r),coords:n,style_z:r,source:e}];{let o=this.key(n,e,r);if(!o)return[];if(i[e.id]=i[e.id]||{},i[e.id][o]==null){let s=Math.pow(2,n.z-t.z),a=t.x*s,l=t.y*s,u=[];for(let c=a;c<a+s;c++)for(let d=l;d<l+s;d++){let f=this.coord({x:c,y:d,z:n.z});u.push({key:this.key(f,e,r),coords:f,style_z:r,source:e})}i[e.id][o]=u}return i[e.id][o]}}};var Qa=Zt(Ya(),1),U={},E=U,ao=t=>Math.max(t,0),lo=t=>isNaN(t)?0:t,tr=(t=>Array.isArray(t)?t.map(parseFloat).map(lo):lo(parseFloat(t))),Ur=(t=>Array.isArray(t)?t.map(tr).map(ao):ao(tr(t)));Object.assign(U,{clampPositive:ao,noNaN:lo,parseNumber:tr,parsePositiveNumber:Ur});U.wrapFunction=function(t,e=!1){var r=\`
|
|
2489
|
+
}`)}update(){super.update(),this.viewport_height=this.view.size.css.height*this.view.meters_per_pixel;var e=[this.view.center.meters.x,this.view.center.meters.y,this.viewport_height];this.position_meters=e,this.matrix4.identity().translate([-e[0],-e[1],0]).toArray(this.view_matrix),this.matrix4.identity().toArray(this.projection_matrix),this.projection_matrix[8]=this.axis.x/this.view.aspect,this.projection_matrix[9]=this.axis.y,this.matrix4.copy(this.projection_matrix).scale([2/this.view.size.meters.x,2/this.view.size.meters.y,2/this.view.size.meters.y]).toArray(this.projection_matrix)}setupProgram(e,r){r?r.setUniforms({u_projection:this.projection_matrix,u_eye:[0,0,this.viewport_height??0],u_vanishing_point:[0,0]}):(e.uniform("Matrix4fv","u_projection",this.projection_matrix),e.uniform("3fv","u_eye",[0,0,this.viewport_height??0]),e.uniform("2fv","u_vanishing_point",[0,0]))}},Pu=class extends Xs{constructor(e,r,i={}){super(e,r,i),this.type="flat"}update(){this.axis.x=0,this.axis.y=0,super.update()}};var Gi=class t extends Wt{constructor(e,r={}){super(e,{...r,cameraFactory:Vr.create})}static create(e,r={}){return new t(e,r)}};var hr=class t{resolveSelectionPoint(e,r={},i=this.activeRenderViewId){if(![e.x,e.y].every(Number.isFinite))throw new Error("Selection coordinates must be finite");if(r.coordinateSpace!==void 0&&!["view","canvas"].includes(r.coordinateSpace))throw new Error("Selection coordinateSpace must be view or canvas");let n=a=>e.x>=a.viewport.x&&e.y>=a.viewport.y&&e.x<a.viewport.x+a.viewport.width&&e.y<a.viewport.y+a.viewport.height,o=r.renderViewId!==void 0?this.getRenderView(r.renderViewId):r.coordinateSpace==="canvas"?[...this.renderViews].reverse().find(n):this.getRenderView(i);if(!o)return null;let s=r.coordinateSpace==="canvas"?{x:e.x-o.viewport.x,y:e.y-o.viewport.y}:{...e};return s.x<0||s.y<0||s.x>=o.viewport.width||s.y>=o.viewport.height?null:{view:o,pixel:s}}viewport;geographicAnchor;projection;renderViews;activeRenderViewId;tileBuffer;tileZoom;tileLOD;tileResources;globePreloadZoom;animationTime;constructor(e){let r=Mt(e,"HostFrame");if(this.viewport=Ys(r.viewport,"HostFrame viewport"),this.geographicAnchor=jn(r.geographicAnchor),this.projection=Js(r.projection),this.tileBuffer=Gn(r.tileBuffer??0,"tileBuffer"),this.tileZoom=sg(r.tileZoom,this.geographicAnchor.zoom),this.tileLOD=og(r.tileLOD),this.projection.type==="projected"&&(this.tileLOD||this.tileZoom===void 0||this.tileZoom>6))throw new Error("HostFrame CPU projection requires explicit tileZoom <= 6 and does not support automatic LOD");if(this.tileResources=ig(r.tileResources),this.globePreloadZoom=ng(r.globePreloadZoom),this.globePreloadZoom!==void 0&&this.projection.type!=="globe")throw new Error("HostFrame globePreloadZoom requires a globe projection");if(this.tileZoom!==void 0&&this.tileLOD!==void 0)throw new Error("HostFrame tileZoom and tileLOD are mutually exclusive");if(this.animationTime=r.animationTime===void 0?void 0:Gn(r.animationTime,"animationTime"),!Array.isArray(r.renderViews)||r.renderViews.length===0)throw new Error("HostFrame requires at least one render view");let i=new Set;this.renderViews=r.renderViews.map((n,o)=>{let s=Mt(n,`HostFrame render view ${o}`),a=typeof s.id=="string"&&s.id?s.id:o===0?"default":`view-${o}`;if(i.has(a))throw new Error(`HostFrame render view id '${a}' is duplicated`);i.add(a);let l=s.projection===void 0?void 0:Js(s.projection);if(l&&l.type!==this.projection.type)throw new Error("HostFrame render views must share a projection type");if(l?.type==="globe"&&this.projection.type==="globe"&&this.projection.maxElevation!==void 0){if(l.maxElevation===void 0)l.maxElevation=this.projection.maxElevation;else if(l.maxElevation<this.projection.maxElevation)throw new Error("HostFrame render-view maxElevation cannot lower the shared scene bound")}return{id:a,viewport:Ys(s.viewport??this.viewport,`HostFrame render view '${a}' viewport`),camera:ag(s.camera,a),geographicAnchor:s.geographicAnchor===void 0?void 0:jn(s.geographicAnchor),projection:l}}),this.activeRenderViewId=typeof r.activeRenderViewId=="string"&&r.activeRenderViewId||this.renderViews[0].id,this.getRenderView()}static from(e){if(e instanceof t)return e;let r=Mt(e,"HostFrame");return r.renderViews!==void 0||r.geographicAnchor!==void 0?t.createValidated(r):t.fromLegacy(r)}static fromLegacy(e){let r=Mt(e,"HostFrame");return t.createValidated({...r,geographicAnchor:r.view,renderViews:[{id:"default",viewport:r.viewport,camera:r.camera}]})}getRenderView(e=this.activeRenderViewId){let r=this.renderViews.find(i=>i.id===e);if(!r)throw new Error(`HostFrame render view '${e}' was not found`);return r}static createValidated(e){let r=Ys(e.viewport,"HostFrame viewport");if(!Array.isArray(e.renderViews)||e.renderViews.length===0)throw new Error("HostFrame requires at least one render view");return new t({viewport:r,geographicAnchor:jn(e.geographicAnchor),projection:Js(e.projection),renderViews:e.renderViews.map((i,n)=>{let o=Mt(i,`HostFrame render view ${n}`);return{id:typeof o.id=="string"?o.id:void 0,viewport:Ys(o.viewport??r,"HostFrame render view viewport"),camera:ag(o.camera,String(n)),geographicAnchor:o.geographicAnchor===void 0?void 0:jn(o.geographicAnchor),projection:o.projection===void 0?void 0:Js(o.projection)}}),activeRenderViewId:typeof e.activeRenderViewId=="string"?e.activeRenderViewId:void 0,tileBuffer:Gn(e.tileBuffer??0,"tileBuffer"),tileZoom:sg(e.tileZoom,jn(e.geographicAnchor).zoom),tileLOD:og(e.tileLOD),tileResources:ig(e.tileResources),globePreloadZoom:ng(e.globePreloadZoom),animationTime:e.animationTime===void 0?void 0:Gn(e.animationTime,"animationTime")})}};function ig(t){if(t===void 0)return;let e=Mt(t,"HostFrame tileResources"),r={};for(let i of["maxConcurrentBuilds","maxCachedTiles","maxCachedMeshBytes"]){let n=e[i];if(n!==void 0){if(typeof n!="number"||!Number.isSafeInteger(n)||n<(i==="maxConcurrentBuilds"?1:0))throw new Error(`HostFrame tileResources ${i} must be a ${i==="maxConcurrentBuilds"?"positive":"non-negative"} safe integer`);r[i]=n}}return Object.freeze(r)}function ng(t){if(t!==void 0){if(typeof t!="number"||!Number.isInteger(t)||t<0||t>3)throw new Error("HostFrame globePreloadZoom must be an integer from 0 to 3");return t}}function og(t){if(t===void 0)return;let e=Mt(t,"HostFrame tileLOD"),r=e.targetTilePixels??512,i=e.pixelRatio??1,n=e.maxTiles??256,o=e.hysteresis??.2;if(!ct(r)||r<=0||!ct(i)||i<=0||!ct(n)||!Number.isSafeInteger(n)||n<1||!ct(o)||o<0||o>=1)throw new Error("HostFrame tileLOD requires positive pixel scales, a positive integer maxTiles, and hysteresis in [0, 1)");return{targetTilePixels:r,pixelRatio:i,maxTiles:n,hysteresis:o}}function sg(t,e){if(t!==void 0){if(typeof t!="number"||!Number.isInteger(t)||t<0||t>22||t>Math.floor(e))throw new Error("HostFrame tileZoom must be an integer from 0 to 22, no higher than the shared style zoom");return t}}function Mt(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} requires an object`);return Object.fromEntries(Object.entries(t))}function Ys(t,e){let r=t&&typeof t=="object"?Mt(t,e):{};if(!ct(r.width)||r.width<=0||!ct(r.height)||r.height<=0)throw new Error(`${e} requires positive width and height`);return{x:ku(r.x,0),y:ku(r.y,0),width:r.width,height:r.height}}function jn(t){let e=t&&typeof t=="object"?Mt(t,"HostFrame geographic anchor"):{};if(!ct(e.longitude)||!ct(e.latitude)||!ct(e.zoom))throw new Error("HostFrame geographic anchor requires finite longitude, latitude, and zoom");return{longitude:e.longitude,latitude:e.latitude,zoom:e.zoom,altitude:ku(e.altitude,0)}}function Js(t){let e=t===void 0?{}:Mt(t,"HostFrame projection"),r=t===void 0?"web-mercator":e.type;if(r==="web-mercator"||r==="projected"){if(r==="projected"&&(e.visibleBounds===void 0||e.visibleBounds===null))throw new Error("HostFrame CPU projection requires an explicit geographic footprint");if(r==="web-mercator"&&e.visibleBounds===void 0)return{type:r};if(r==="web-mercator"&&e.visibleBounds===null)return{type:r,visibleBounds:null};let n=e.visibleBounds;if(!Array.isArray(n)||n.length!==4||!n.every(ct)||n[0]>n[2]||n[1]>n[3]||n[1]<=-90||n[3]>=90)throw new Error("HostFrame planar projection requires finite ordered visibleBounds with latitudes strictly between -90 and 90");if(r==="projected"&&(n[0]<-180||n[2]>180||n[1]<-85.0511287798066||n[3]>85.0511287798066))throw new Error("HostFrame CPU projection footprint must stay inside the finite single-world tile domain");return{type:r,visibleBounds:[n[0],n[1],n[2],n[3]]}}if(r!=="globe")throw new Error(`HostFrame projection type '${String(r)}' is invalid`);let i=e.visibleBounds;if(!Array.isArray(i)||i.length!==4||!i.every(ct))throw new Error("HostFrame globe projection requires finite visibleBounds");return{type:r,visibleBounds:[i[0],i[1],i[2],i[3]],...e.maxElevation===void 0?{}:{maxElevation:Gn(e.maxElevation,"maxElevation")}}}function ag(t,e){let r=t&&typeof t=="object"?Mt(t,"HostFrame camera"):{},i=Lu(r.view,16),n=Lu(r.projection,16),o=Lu(r.position,3);if(!i||!n||!o)throw new Error(`HostFrame render view '${e}' requires finite camera matrices and position`);let s=new Float32Array(n);if(!s.every(Number.isFinite))throw new Error(`HostFrame render view '${e}' requires finite camera matrices and position`);return{view:new Float64Array(i),projection:s,position:[o[0],o[1],o[2]]}}function Lu(t,e){if(!Array.isArray(t)&&!(t instanceof Float32Array)&&!(t instanceof Float64Array))return null;let r=Array.from(t);return r.length===e&&r.every(ct)?r:null}function ct(t){return typeof t=="number"&&Number.isFinite(t)}function ku(t,e){return ct(t)?t:e}function Gn(t,e){if(!ct(t)||t<0)throw new Error(`HostFrame ${e} must be a finite non-negative number`);return t}var Qv=["Buffer","Texture","TextureView","ExternalTexture","Sampler"],ew=["Buffer"];function lg(t){return t.startsWith("depth")||t.startsWith("stencil")}function tw(t,e){return ug(t,e,Qv)?!0:"buffer"in t&&ug(t.buffer,e,ew)&&(!("offset"in t)||t.offset===void 0||typeof t.offset=="number")&&(!("size"in t)||t.size===void 0||typeof t.size=="number")}function ug(t,e,r){if(!t||typeof t!="object"||!("device"in t)||t.device!==e||!("destroy"in t)||typeof t.destroy!="function")return!1;let i=Reflect.get(t,Symbol.toStringTag);return typeof i=="string"&&r.includes(i)}var dr=class{bindingResources=new WeakMap;constructor(e){rw(e),this.device=e,this.pipeline_cache=new WeakMap,this.mesh_resource_cache=new WeakMap,this.program_resources=new Set,this.mesh_resources=new Set,this.destroyed=!1}get shaderLanguage(){return this.device.info.shadingLanguage}get maxTextureSize(){return this.device.limits&&this.device.limits.maxTextureDimension2D}getSceneOptions(){return this.assertAlive(),{enableUniformBuffers:!0,deviceShaderCompilation:!0,shaderLanguage:this.shaderLanguage,uniformBufferFactory:e=>this.createUniformBuffer(e),shaderFactory:e=>this.createShader(e),shaderProgramValidator:e=>this.validateShaderProgram(e),meshBufferFactory:e=>this.createMeshBuffer(e),textureFactory:e=>this.createTexture(e),maxTextureSize:this.maxTextureSize,meshRenderer:this}}createUniformBuffer(e){if(this.assertAlive(),e.usage!=="uniform")throw new Error(`unsupported Tangram buffer usage '${e.usage}'`);let r=this.device.createBuffer({id:`tangram-${e.id}`,byteLength:e.byteLength,usage:at.UNIFORM|at.COPY_DST});return this.bindingResources.set(r,r),r}createShader(e){this.assertAlive();let r={id:`tangram-${e.id}`,language:e.language||this.device.info.shadingLanguage,stage:e.stage,source:e.source};return e.entryPoint&&(r.entryPoint=e.entryPoint),this.device.createShader(r)}validateShaderProgram({id:e,vertexShader:r,fragmentShader:i}){if(this.assertAlive(),this.device.type==="webgl")return;let n=this.device.createRenderPipeline({id:`tangram-${e}-validation`,vs:r,fs:i,topology:"triangle-list",bufferLayout:[],disableWarnings:!0});try{if(n.isErrored)throw new Error(`Tangram shader program '${e}' failed device link validation`)}finally{n.destroy()}}createMeshBuffer(e){this.assertAlive();let r=e.usage==="vertex"?at.VERTEX:e.usage==="index"?at.INDEX:null;if(r==null)throw new Error(`unsupported Tangram mesh buffer usage '${e.usage}'`);let i={id:`tangram-${e.id}`,usage:r|at.COPY_DST,data:e.data};return e.indexType&&(i.indexType=e.indexType),this.device.createBuffer(i)}createTexture(e){this.assertAlive();let r=e.filtering==="mipmap"&&this.device.type==="webgl",i=e.filtering==="nearest"?"nearest":"linear",n=this.device.createTexture({id:`tangram-${e.id}`,width:e.width,height:e.height,format:"rgba8unorm",usage:Pt.COPY_DST|Pt.SAMPLE|Pt.RENDER,mipLevels:r?Math.floor(Math.log2(Math.max(e.width,e.height)))+1:1,sampler:{minFilter:i,magFilter:i,mipmapFilter:r?"linear":"none",addressModeU:e.repeat?"repeat":"clamp-to-edge",addressModeV:e.repeat?"repeat":"clamp-to-edge"}});this.bindingResources.set(n,n);try{return e.data!=null&&(ArrayBuffer.isView(e.data)||e.data instanceof ArrayBuffer?n.writeData(e.data,{width:e.width,height:e.height}):n.copyExternalImage({image:e.data,width:e.width,height:e.height,flipY:e.flipY,premultipliedAlpha:e.premultipliedAlpha}),r&&n.generateMipmapsWebGL()),n}catch(o){throw n.destroy(),o}}getRenderPipelineParameters({depthTest:e,depthWrite:r,cullFace:i,blend:n}){let o={cullMode:i?"back":"none",depthCompare:e?"less":"always",depthWriteEnabled:r,blend:!!(n&&n!=="opaque")};return n==="overlay"||n==="inlay"||n==="translucent"?Object.assign(o,{blendColorOperation:"add",blendColorSrcFactor:"src-alpha",blendColorDstFactor:"one-minus-src-alpha",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha"}):n==="add"?Object.assign(o,{blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}):n==="multiply"&&Object.assign(o,{blendColorOperation:"add",blendColorSrcFactor:"zero",blendColorDstFactor:"src",blendAlphaOperation:"add",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha"}),o}drawMesh({mesh:e,program:r,renderPass:i,renderState:n,visibleTime:o}){if(this.assertAlive(),!i||!r||!r.vertex_shader_resource||!r.fragment_shader_resource)throw new Error("Tangram luma renderer requires an active render pass and shader resources");let s=e.getDrawDescriptor(),a=this.getPipeline(r,e.vertex_layout,s,n,i);e.uniforms&&(r.saveUniforms(e.uniforms),r.setUniforms(e.uniforms,!1));try{r.uniform("1f","u_visible_time",o);let l=r.getBindings();this.snapshotMeshUniformBindings(e,r,l);let u={};for(let[f,p]of Object.entries(l)){let m=this.bindingResources.get(p);if(m)u[f]=m;else if(tw(p,this.device))u[f]=p;else throw new Error(`Tangram binding '${f}' requires a native luma resource`)}iw(a,u);let c=this.getVertexArray(e,a,s);i.setPipeline(a),i.setBindings(u),i.setVertexArray(c);let h=r.getUniformValues();return i.draw({vertexCount:s.indexBuffer?void 0:s.vertexCount,indexCount:s.indexBuffer?s.indexCount:void 0,uniforms:this.device.type==="webgl"?h:void 0})===!1&&a.isPending===!0}finally{e.uniforms&&r.restoreUniforms(e.uniforms)}}destroy(){if(!this.destroyed){this.destroyed=!0;for(let e of this.mesh_resources)this.disposeMeshResources(e);for(let e of this.program_resources)this.disposeProgramResources(e);this.pipeline_cache=new WeakMap,this.mesh_resource_cache=new WeakMap}}snapshotMeshUniformBindings(e,r,i){let n=r.uniform_blocks||{},o=Object.entries(n).filter(a=>a[1].snapshot_per_mesh&&!!a[1].data);if(o.length===0)return;let s=this.getMeshResources(e).uniformBuffers;for(let[a,l]of o){let u=s.get(a);if(!u||u.byteLength!==l.byteLength){let c=this.device.createBuffer({id:`tangram-mesh-${e.id}-${a}-uniforms`,byteLength:l.byteLength,usage:at.UNIFORM|at.COPY_DST});this.bindingResources.set(c,c),u?.buffer.destroy(),u={buffer:c,byteLength:l.byteLength},s.set(a,u)}u.buffer.write(new Uint8Array(l.data)),i[a]=u.buffer}}getPipeline(e,r,i,n,o){this.assertAlive();let s=this.getProgramResources(e),a=s.layouts,l=a.get(r);l||(l=new Map,a.set(r,l));let u=l.get(i.topology);u||(u=new Map,l.set(i.topology,u));let c=o?.props?.framebuffer??(this.device.type==="webgpu"&&o?this.device.getDefaultCanvasContext().getCurrentFramebuffer():void 0),h={},d=n;if(this.device.type==="webgpu"&&c){d={...n,sampleCount:c.colorAttachments[0]?.texture.samples??c.depthStencilAttachment?.texture.samples??1,...c.depthStencilAttachment?{}:{depthWriteEnabled:!1,depthCompare:"always"}},h.colorAttachmentFormats=c.colorAttachments.map(g=>{let _=g.texture.format;if(lg(_))throw new Error("Color attachment requires a color texture");return _});let m=c.depthStencilAttachment?.texture.format;if(m!==void 0){if(!lg(m))throw new Error("Depth attachment requires a depth/stencil texture");h.depthStencilAttachmentFormat=m}}let f=JSON.stringify({state:d||{},attachments:h}),p=u.get(f);if(!p){let m={id:`tangram-${e.name||e.id}-${i.topology}-${u.size}`,vs:e.vertex_shader_resource??void 0,fs:e.fragment_shader_resource??void 0,bufferLayout:[i.bufferLayout],topology:i.topology,disableWarnings:!0,...h};d&&(m.parameters=d),p=this.device.createRenderPipeline(m),u.set(f,p),s.pipelines.add(p)}return p}getVertexArray(e,r,i){this.assertAlive();let n=this.getMeshResources(e).vertexArrays,o=n.get(r);if(o)return o;o=this.device.createVertexArray({id:`tangram-mesh-${e.id}-${r.id}`,shaderLayout:r.shaderLayout,bufferLayout:r.bufferLayout});try{let s=new Map(r.shaderLayout.attributes.map(a=>[a.name,a]));for(let a of i.bufferLayout.attributes){let l=s.get(a.attribute);l&&o.setBuffer(l.location,i.vertexBuffer)}for(let a of i.staticAttributes){let l=s.get(a.attribute);if(l){if(this.device.type==="webgpu")throw new Error(`Tangram WebGPU renderer requires '${a.attribute}' in a vertex buffer`);o.setConstantWebGL(l.location,new Float32Array(a.value))}}i.indexBuffer&&o.setIndexBuffer(i.indexBuffer)}catch(s){throw o.destroy(),s}return n.set(r,o),o}getProgramResources(e){let r=this.pipeline_cache.get(e);if(!r||r.disposed){r={layouts:new WeakMap,pipelines:new Set,disposed:!1,unsubscribe:()=>{}};let i=r;r.unsubscribe=ua(e,()=>this.disposeProgramResources(i)),this.pipeline_cache.set(e,r),this.program_resources.add(r)}return r}getMeshResources(e){this.assertAlive();let r=this.mesh_resource_cache.get(e);if(!r||r.disposed){r={vertexArrays:new Map,uniformBuffers:new Map,disposed:!1,unsubscribe:()=>{}};let i=r;r.unsubscribe=ua(e,()=>this.disposeMeshResources(i)),this.mesh_resource_cache.set(e,r),this.mesh_resources.add(r)}return r}disposeMeshResources(e){if(!e.disposed){e.disposed=!0,e.unsubscribe(),this.mesh_resources.delete(e);for(let r of e.vertexArrays.values())r.destroy();for(let r of e.uniformBuffers.values())r.buffer.destroy();e.vertexArrays.clear(),e.uniformBuffers.clear()}}disposeProgramResources(e){if(!e.disposed){e.disposed=!0,e.unsubscribe(),this.program_resources.delete(e);for(let r of this.mesh_resources)for(let[i,n]of r.vertexArrays)e.pipelines.has(i)&&(n.destroy(),r.vertexArrays.delete(i));for(let r of e.pipelines)r.destroy();e.pipelines.clear(),e.layouts=new WeakMap}}assertAlive(){if(this.destroyed)throw new Error("Tangram GPU backend has been destroyed")}};function rw(t){if(!t||!t.info||typeof t.createBuffer!="function"||typeof t.createShader!="function"||typeof t.createTexture!="function"||typeof t.createRenderPipeline!="function"||typeof t.createVertexArray!="function")throw new Error("Tangram requires a luma.gl Device")}function iw(t,e){for(let r of t.shaderLayout.bindings){if(r.type==="sampler"&&r.name.endsWith("Sampler")){let i=r.name.slice(0,-7);if(e[i])continue}if(r.type!=="uniform"&&r.type!=="texture"&&r.type!=="sampler")throw new Error(`Tangram luma renderer does not support '${r.type}' bindings`);if(!e[r.name])throw new Error(`Tangram luma renderer is missing '${r.name}' binding`)}}function Un(t,e){if(t.length!==e)throw new RangeError("Query dimension must match the index");for(let r=0;r<e;r++)if(!Number.isFinite(t[r]))throw new RangeError("Coordinates must be finite")}function hg(t){if(Number.isNaN(t)||t<0)throw new RangeError("Distance must be nonnegative")}function Vn(t,e,r,i,n=1/0){let o=t.length;if(o!==2&&o!==3)throw new RangeError("Bounds must be 2D or 3D");Un(t,o),Un(e,o),Un(r,o),Un(i,o),hg(n);let s=0,a=n,l=!1;for(let u=0;u<o;u++){if(r[u]>i[u])throw new RangeError("Bounds must be ordered");l||(l=e[u]!==0)}if(!l)throw new RangeError("Ray direction must be nonzero");for(let u=0;u<o;u++){if(e[u]===0){if(t[u]<r[u]||t[u]>i[u])return null;continue}let c=(r[u]-t[u])/e[u],h=(i[u]-t[u])/e[u];if(c>h&&([c,h]=[h,c]),s=Math.max(s,c),a=Math.min(a,h),s>a)return null}return Number.isFinite(s)?s:null}function Qs(t,e,r,i,n,o={}){for(let g of[t,e,r,i,n])Un(g,3);if(e[0]===0&&e[1]===0&&e[2]===0)throw new RangeError("Ray direction must be nonzero");let s=o.maxT??1/0;hg(s);let a=[i[0]-r[0],i[1]-r[1],i[2]-r[2]],l=[n[0]-r[0],n[1]-r[1],n[2]-r[2]],u=cg(e,l),c=Ks(a,u);if(c===0||o.backfaceCulling&&c<0)return null;let h=[t[0]-r[0],t[1]-r[1],t[2]-r[2]],d=Ks(h,u)/c;if(d<0||d>1)return null;let f=cg(h,a),p=Ks(e,f)/c;if(p<0||d+p>1)return null;let m=Ks(l,f)/c;return!Number.isFinite(m)||m<0||m>s?null:{t:Math.max(0,m),barycentric:[1-d-p,d,p]}}function Ks(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function cg(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}var Ui=class t{static getRequiredHierarchyBytes(e,r=8){if(!Number.isSafeInteger(e)||e<0||e>4294967295||!Number.isSafeInteger(r)||r<1||r>64)throw new Error("Invalid triangle hierarchy dimensions");let i=new Map,n=o=>{if(!o)return 0;if(o<=r)return 1;let s=i.get(o);if(s!==void 0)return s;let a=Math.floor(o/2),l=1+n(a)+n(o-a);return i.set(o,l),l};return e*4+n(e)*64}triangleCount;geometryBytes;requiredHierarchyBytes;positions;indices;order;bounds;topology;preparing;leafSize;nodeCount;hierarchyAllowed;deferBuild;minimum=[1/0,1/0,1/0];maximum=[-1/0,-1/0,-1/0];constructor(e,r,i=8,n={}){if(!Number.isSafeInteger(e.length)||!Number.isSafeInteger(r.length)||e.length%3||r.length%3||!Number.isSafeInteger(i)||i<1||i>64)throw new Error("Invalid triangle index dimensions or leaf size");if(r.length/3>4294967295)throw new Error("Triangle positions and indices must be finite and in range");if(n.maxHierarchyBytes!==void 0&&(!Number.isSafeInteger(n.maxHierarchyBytes)||n.maxHierarchyBytes<0))throw new Error("Triangle hierarchy byte limit must be a non-negative integer");this.positions=Float64Array.from(e);for(let o=0;o<this.positions.length;o++)if(!Number.isFinite(this.positions[o]))throw new Error("Triangle positions and indices must be finite and in range");this.indices=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let s=r[o];if(!Number.isSafeInteger(s)||s<0||s>=this.positions.length/3||s>4294967295)throw new Error("Triangle positions and indices must be finite and in range");this.indices[o]=s}this.triangleCount=r.length/3,this.leafSize=i,this.requiredHierarchyBytes=t.getRequiredHierarchyBytes(this.triangleCount,i),this.nodeCount=(this.requiredHierarchyBytes-this.triangleCount*4)/64,this.geometryBytes=this.positions.byteLength+this.indices.byteLength,this.hierarchyAllowed=this.requiredHierarchyBytes<=(n.maxHierarchyBytes??1/0),this.deferBuild=n.deferBuild??!1;for(let o=0;o<this.positions.length;o++){let s=o%3;this.minimum[s]=Math.min(this.minimum[s],this.positions[o]),this.maximum[s]=Math.max(this.maximum[s],this.positions[o])}!n.lazy&&this.hierarchyAllowed&&this.buildHierarchy()}get arrayBytes(){return this.geometryBytes+this.hierarchyBytes}get hierarchyBytes(){return this.preparing?this.requiredHierarchyBytes:(this.order?.byteLength??0)+(this.bounds?.byteLength??0)+(this.topology?.byteLength??0)}getBounds(){return this.positions.length?{minimum:[...this.minimum],maximum:[...this.maximum]}:null}*prepareHierarchySteps(){if(this.order||this.preparing||!this.hierarchyAllowed||!this.triangleCount)return;let e={order:new Uint32Array(this.triangleCount),bounds:new Float64Array(this.nodeCount*6),topology:new Uint32Array(this.nodeCount*4)};this.preparing=e;try{for(let r=0;r<e.order.length;r++)e.order[r]=r,r%128===127&&(yield);yield*this.buildNodeSteps(e,0,this.triangleCount,{next:0}),this.bounds=e.bounds,this.topology=e.topology,this.order=e.order}finally{this.preparing=void 0}}getTriangleVertex(e,r){return{index:this.getVertexIndex(e,r),position:this.getVertex(e,r)}}getVertexIndex(e,r){if(!Number.isSafeInteger(e)||e<0||e>=this.triangleCount||!Number.isSafeInteger(r)||r<0||r>2)throw new Error("Triangle vertex is out of range");return this.indices[e*3+r]}queryRay(e,r,i=1/0,n){if(i<0||Number.isNaN(i))throw new Error("Triangle ray limit must be non-negative");let o={hit:null,testedBounds:0,testedTriangles:0},s=Math.hypot(...r);if(e.length!==3||r.length!==3||!e.every(Number.isFinite)||!r.every(Number.isFinite)||!Number.isFinite(s)||s===0||!this.triangleCount||Vn(e,r,this.minimum,this.maximum,i)===null)return o;this.hierarchyAllowed&&!this.deferBuild&&!this.order&&!this.preparing&&this.buildHierarchy();let a=u=>{o.testedTriangles++;let c=Qs(e,r,this.getVertex(u,0),this.getVertex(u,1),this.getVertex(u,2),{maxT:o.hit?.parameter??i});if(c&&(!o.hit||c.t<o.hit.parameter||c.t===o.hit.parameter&&u<o.hit.triangleIndex)){let h={triangleIndex:u,parameter:c.t,barycentric:c.barycentric};(!n||n(h))&&(o.hit=h)}};if(!this.order){for(let u=0;u<this.triangleCount;u++)a(u);return o}let l=[{index:0,near:0}];for(o.testedBounds++;l.length;){let{index:u,near:c}=l.pop();if(c>(o.hit?.parameter??i))continue;let h=this.readNode(u);if(h.children){let d=h.children.flatMap(f=>{let p=this.readNode(f);o.testedBounds++;let m=Vn(e,r,p.minimum,p.maximum,o.hit?.parameter??i);return m===null?[]:[{index:f,near:m}]});d.sort((f,p)=>p.near-f.near||p.index-f.index),l.push(...d);continue}for(let d=h.start;d<h.end;d++)a(this.order[d])}return o}buildHierarchy(){for(let e of this.prepareHierarchySteps());}readNode(e){let r=this.bounds,i=this.topology,n=e*4;return{minimum:[r[e*6],r[e*6+1],r[e*6+2]],maximum:[r[e*6+3],r[e*6+4],r[e*6+5]],start:i[n],end:i[n+1],children:i[n+2]?[i[n+2],i[n+3]]:void 0}}getVertex(e,r){let i=this.indices[e*3+r]*3;return[this.positions[i],this.positions[i+1],this.positions[i+2]]}*buildNodeSteps(e,r,i,n){let{order:o,bounds:s,topology:a}=e,l=[1/0,1/0,1/0],u=[-1/0,-1/0,-1/0];for(let h=r;h<i;h++){for(let d=0;d<3;d++){let f=this.indices[o[h]*3+d]*3;for(let p=0;p<3;p++){let m=this.positions[f+p];l[p]=Math.min(l[p],m),u[p]=Math.max(u[p],m)}}(h-r)%128===127&&(yield)}let c=n.next++;if(s.set([...l,...u],c*6),a.set([r,i],c*4),i-r>this.leafSize){let h=0;for(let g=1;g<3;g++)u[g]-l[g]>u[h]-l[h]&&(h=g);let d=g=>(this.positions[this.indices[g*3]*3+h]+this.positions[this.indices[g*3+1]*3+h]+this.positions[this.indices[g*3+2]*3+h])/3,f=r+Math.floor((i-r)/2);yield*this.partitionSteps(o,f,r,i-1,(g,_)=>d(g)-d(_)||g-_);let p=yield*this.buildNodeSteps(e,r,f,n),m=yield*this.buildNodeSteps(e,f,i,n);a.set([p,m],c*4+2)}return yield,c}*partitionSteps(e,r,i,n,o){let s=0;for(;i<n;){let a=e[i+Math.floor((n-i)/2)],l=i,u=n;for(;l<=u;){for(;o(e[l],a)<0;)l++,++s%128===0&&(yield);for(;o(e[u],a)>0;)u--,++s%128===0&&(yield);if(l<=u){let c=e[l];e[l++]=e[u],e[u--]=c}++s%128===0&&(yield)}if(r<=u)n=u;else if(r>=l)i=l;else return}}};var Vi=class{projection;entries;constructor(e,r){if(!["web-mercator","globe"].includes(e))throw new Error("Terrain collection projection must be web-mercator or globe");if(this.projection=e,this.entries=r.map(({id:i,surface:n})=>{if(typeof i!="string"||!i.length||n.projection!==e)throw new Error("Terrain collection requires nonempty IDs and matching projections");return Object.freeze({id:i,surface:n})}),new Set(this.entries.map(i=>i.id)).size!==this.entries.length)throw new Error("Terrain collection IDs must be unique")}intersectRay(e,r=1/0){if(r<0||Number.isNaN(r))throw new Error("Terrain ray distance must be non-negative");let i=Math.hypot(...e.direction);if(e.origin.length!==3||e.direction.length!==3||!e.origin.every(Number.isFinite)||!e.direction.every(Number.isFinite)||!Number.isFinite(i)||i===0)return null;let n=e.direction.map(l=>l/i),o=this.entries.flatMap((l,u)=>{if(!l.surface.getBounds)return[{entry:l,index:u,distance:0}];let c=l.surface.getBounds();if(!c)return[];let h=Vn(e.origin,n,c.minimum,c.maximum,r);return h===null?[]:[{entry:l,index:u,distance:h}]}).sort((l,u)=>l.distance-u.distance||l.index-u.index),s=null,a=1/0;for(let{entry:l,index:u,distance:c}of o){if(c>(s?.distance??r))break;let h=l.surface.intersectRay(e,s?.distance??r);h&&(!s||h.distance<s.distance||h.distance===s.distance&&u<a)&&(s={...h,surfaceId:l.id},a=u)}return s}intersectSegment(e,r,i={}){let n=i.startInset??0,o=i.endInset??0;if(e.length!==3||r.length!==3||!e.every(Number.isFinite)||!r.every(Number.isFinite)||![n,o].every(c=>Number.isFinite(c)&&c>=0))throw new Error("Terrain segment requires finite endpoints and non-negative finite insets");let s=[r[0]-e[0],r[1]-e[1],r[2]-e[2]],a=Math.hypot(...s);if(!Number.isFinite(a))throw new Error("Terrain segment length must be finite");if(a===0||n+o>=a)return null;let l=[e[0]+s[0]*n/a,e[1]+s[1]*n/a,e[2]+s[2]*n/a],u=this.intersectRay({origin:l,direction:s},a-n-o);return u?{...u,distance:u.distance+n}:null}};function Cu(t,e,r){if(e.length!==2||!e.every(Number.isFinite)||Math.abs(e[1])>90||![r.minimumAltitude,r.maximumAltitude].every(Number.isFinite)||r.minimumAltitude>=r.maximumAltitude||r.anchorLongitude!==void 0&&!Number.isFinite(r.anchorLongitude))throw new Error("Invalid terrain elevation probe");let i=et(t.projection);if(Math.abs(e[1])>i.latitudeLimit)return null;if(t.projection==="globe"&&r.minimumAltitude<=-ae.earthRadius)throw new Error("Globe elevation probes must remain above the center");let n=i.project([e[0],e[1],r.maximumAltitude],r.anchorLongitude),o=i.project([e[0],e[1],r.minimumAltitude],r.anchorLongitude),s=[o[0]-n[0],o[1]-n[1],o[2]-n[2]];if(!n.every(Number.isFinite)||!o.every(Number.isFinite)||!Number.isFinite(Math.hypot(...s)))throw new Error("Terrain elevation probe exceeds finite projection range");return t.intersectRay({origin:n,direction:s},Math.hypot(...s))}function dg(t,e,r,i){if(t.projection!=="web-mercator")throw new Error("Terrain clearance requires a physical-meter Mercator frame");if(e.length!==3||!e.every(Number.isFinite)||!Number.isFinite(r)||r<0)throw new Error("Invalid terrain clearance");let n=Cu(t,[e[0],e[1]],i);if(!n)return null;let o=Math.max(e[2],n.position[2]+r);if(!Number.isFinite(o))throw new Error("Terrain clearance exceeds finite altitude range");return{coordinate:[e[0],e[1],o],physicalElevation:n.coordinate[2],adjusted:o>e[2]}}var $i=class{projection;physicalHeights;cullBackfaces;queryIndex;constructor(e){if(!["web-mercator","globe"].includes(e.projection))throw new Error("Terrain projection must be web-mercator or globe");if(e.positions.length%3||e.indices.length%3)throw new Error("Terrain requires XYZ positions and triangle indices");this.projection=e.projection;try{this.queryIndex=new Ui(e.positions,e.indices,8,{lazy:!0,maxHierarchyBytes:e.maxQueryIndexBytes,deferBuild:e.deferQueryIndexBuild})}catch(i){throw new Error(`Terrain mesh: ${i instanceof Error?i.message:String(i)}`)}this.cullBackfaces=e.cullBackfaces??!1;let r=e.physicalHeights;if(r){if(r.length!==e.positions.length/3)throw new Error("Terrain physical heights must match indexed vertices");this.physicalHeights=Float64Array.from(r);for(let i=0;i<this.queryIndex.triangleCount;i++)for(let n=0;n<3;n++)if(!Number.isFinite(this.physicalHeights[this.queryIndex.getVertexIndex(i,n)]))throw new Error("Terrain physical heights must match indexed vertices")}}getStatistics(){return{geometryBytes:this.queryIndex.geometryBytes+(this.physicalHeights?.byteLength??0),queryIndexBytes:this.queryIndex.hierarchyBytes,requiredQueryIndexBytes:this.queryIndex.requiredHierarchyBytes}}*prepareQueryIndexSteps(){yield*this.queryIndex.prepareHierarchySteps()}getBounds(){return this.queryIndex.getBounds()}intersectRay(e,r=1/0,i){if(r<0||Number.isNaN(r))throw new Error("Terrain ray distance must be non-negative");let n=Math.hypot(...e.direction);if(e.origin.length!==3||e.direction.length!==3||!e.origin.every(Number.isFinite)||!e.direction.every(Number.isFinite)||!Number.isFinite(n)||n===0||!this.queryIndex.triangleCount)return null;let o=[e.direction[0]/n,e.direction[1]/n,e.direction[2]/n],s=this.queryIndex.queryRay(e.origin,o,r,f=>{if(i&&!i([e.origin[0]+o[0]*f.parameter,e.origin[1]+o[1]*f.parameter,e.origin[2]+o[2]*f.parameter],f.triangleIndex,f.barycentric)||this.projection==="globe"&&Math.hypot(e.origin[0]+o[0]*f.parameter,e.origin[1]+o[1]*f.parameter,e.origin[2]+o[2]*f.parameter)===0)return!1;if(!this.cullBackfaces)return!0;let p=[0,1,2].map(_=>this.queryIndex.getTriangleVertex(f.triangleIndex,_).position),m=new it(p[0]);return new it(p[1]).subtract(m).cross(new it(p[2]).subtract(m)).dot(o)<0}).hit;if(!s)return null;let a=s.triangleIndex*3,l=[0,1,2].map(f=>this.queryIndex.getTriangleVertex(s.triangleIndex,f).position),u=[e.origin[0]+o[0]*s.parameter,e.origin[1]+o[1]*s.parameter,e.origin[2]+o[2]*s.parameter],c=new it(l[1]).subtract(l[0]).cross(new it(l[2]).subtract(l[0])).normalize(),h=et(this.projection).unproject(u),d=this.physicalHeights;return d&&(h[2]=s.barycentric.reduce((f,p,m)=>f+p*d[this.queryIndex.getVertexIndex(s.triangleIndex,m)],0)),{position:u,coordinate:h,distance:s.parameter,normal:[c[0],c[1],c[2]],triangleIndex:a/3,barycentric:s.barycentric}}};function ea(t,e,r,i={},n){if(r.projection!==t.projection.type)throw new Error("Terrain surface and HostFrame projection must match");if(![e.x,e.y].every(Number.isFinite))throw new Error("Terrain query pixels must be finite");if(i.radius!==void 0&&i.radius!==0)throw new Error("Terrain queries select one ray, not a pixel radius");let o=t.resolveSelectionPoint(e,i,n);if(!o)return null;let{view:s,pixel:a}=o,l=new Oe(Array.from(s.camera.projection));r.projection!=="globe"&&l.multiplyRight(Array.from(s.camera.view));let u=l.determinant();if(!Number.isFinite(u)||u===0)return null;l.invert();let c=2*a.x/s.viewport.width-1,h=1-2*a.y/s.viewport.height,d=[-1,1].map(g=>l.transform([c,h,g,1]));if(d.some(g=>!g.every(Number.isFinite)||g[3]===0))return null;let f=[d[0][0]/d[0][3],d[0][1]/d[0][3],d[0][2]/d[0][3]],p=[d[1][0]/d[1][3]-f[0],d[1][1]/d[1][3]-f[1],d[1][2]/d[1][3]-f[2]],m=r.intersectRay({origin:f,direction:p},Math.hypot(...p));return m?{...m,renderViewId:s.id}:null}var zu=new WeakSet,fg=new WeakSet,$n=class{projection;mesh;blend;exaggeration;constructor(e,r,i,n){if(this.mesh=e,this.projection=r,this.blend=i,this.exaggeration=n,e.indices.length%3||!e.positions.every(Number.isFinite)||e.indices.some(o=>o>=e.positions.length/3||!Number.isFinite(e.heights[o*2])||!Number.isFinite(e.heights[o*2+1])))throw new Error("Terrain mesh: triangle positions, indices and physical heights must be finite and in range")}getStatistics(){return{geometryBytes:0,queryIndexBytes:0}}intersectRay(e,r=1/0,i){if(r<0||Number.isNaN(r))throw new Error("Terrain ray distance must be non-negative");let n=Math.hypot(...e.direction);if(e.origin.length!==3||e.direction.length!==3||!e.origin.every(Number.isFinite)||!e.direction.every(Number.isFinite)||!Number.isFinite(n)||n===0)return null;let o=[e.direction[0]/n,e.direction[1]/n,e.direction[2]/n],s=et("web-mercator"),a=et(this.projection),l=null;for(let u=0;u<this.mesh.indices.length/3;u++){let c=[],h=[0,1,2].map(g=>{let _=this.mesh.indices[u*3+g],x=_*3,v=this.mesh.heights[_*2],A=this.mesh.heights[_*2+1],w=A+(v-A)*this.blend;c.push(this.mesh.positions[x+2]+w);let E=[this.mesh.positions[x],this.mesh.positions[x+1],this.mesh.positions[x+2]+w*this.exaggeration];return this.projection==="globe"?this.mesh.globeBasis?nl(this.mesh.globeBasis,_,this.blend,this.exaggeration,[E[0],E[1],this.mesh.positions[x+2]]):a.project(s.unproject(E)):E}),d=Qs(e.origin,o,h[0],h[1],h[2],{maxT:l?.distance??r});if(!d||l&&d.t>=l.distance)continue;let f=[e.origin[0]+o[0]*d.t,e.origin[1]+o[1]*d.t,e.origin[2]+o[2]*d.t];if(i&&!i(f,u,d.barycentric))continue;let p=new it(h[1]).subtract(h[0]).cross(new it(h[2]).subtract(h[0]));if(this.projection==="globe"&&(Math.hypot(...f)===0||p.dot(o)>=0))continue;p.normalize();let m=a.unproject(f);m[2]=d.barycentric.reduce((g,_,x)=>g+_*c[x],0),l={position:f,coordinate:m,distance:d.t,normal:[p[0],p[1],p[2]],triangleIndex:u,barycentric:d.barycentric}}return l}};function nw(t,e,r,i){if(!t.indices.length||i?.length===0)return null;let n=Do(t),o=n.offsets[0]+n.heights[0]*r,s=n.offsets[1]+n.heights[1]*r,a,l;if(e==="web-mercator"){if(a=[t.bounds[0],t.bounds[1],o],l=[t.bounds[2],t.bounds[3],s],i&&(a[0]=Math.max(a[0],Math.min(...i.map(u=>u[0]))),a[1]=Math.max(a[1],Math.min(...i.map(u=>u[1]))),l[0]=Math.min(l[0],Math.max(...i.map(u=>u[2]))),l[1]=Math.min(l[1],Math.max(...i.map(u=>u[3]))),a[0]>l[0]||a[1]>l[1]))return null}else if(n.globe){a=[0,0,0],l=[0,0,0];for(let u of[0,1,2]){let c=n.offsets.flatMap(h=>[n.directions.minimum[u]*h,n.directions.maximum[u]*h]).map(h=>h*ae.globeRadius/ae.earthRadius);a[u]=n.globe.base.minimum[u]+n.globe.relief.minimum[u]*r+Math.min(...c),l[u]=n.globe.base.maximum[u]+n.globe.relief.maximum[u]*r+Math.max(...c)}}else{let u=[o,s].map(c=>ae.globeRadius*(1+c/ae.earthRadius));a=[0,0,0],l=[0,0,0];for(let c of[0,1,2]){let h=u.flatMap(d=>[n.directions.minimum[c]*d,n.directions.maximum[c]*d]);a[c]=Math.min(...h),l[c]=Math.max(...h)}}for(let u of[0,1,2]){let c=Math.max(1,Math.abs(a[u]),Math.abs(l[u]))*1e-12;a[u]-=c,l[u]+=c}return{minimum:a,maximum:l}}var ta=new WeakMap,pg=new WeakMap,ow=0;function sw(t){let e=pg.get(t);return e===void 0&&(e=ow++,pg.set(t,e)),e}function aw(t,e,r,i,n){let o=ta.get(t);if(o?.projection===e&&o.blend===r&&o.exaggeration===i&&o.indexLimit===n)return o.surface;let s=new Float64Array(t.positions.length),a=new Float64Array(t.positions.length/3),l=et("web-mercator"),u=et("globe");for(let h=0;h<a.length;h++){let d=h*3,f=t.heights[h*2],p=t.heights[h*2+1],m=p+(f-p)*r;a[h]=t.positions[d+2]+m;let g=[t.positions[d],t.positions[d+1],t.positions[d+2]+m*i];s.set(e==="globe"?t.globeBasis?nl(t.globeBasis,h,r,i,[g[0],g[1],t.positions[d+2]]):u.project(l.unproject(g)):g,d)}let c=new $i({projection:e,positions:s,indices:t.indices,physicalHeights:a,cullBackfaces:e==="globe",maxQueryIndexBytes:n,deferQueryIndexBuild:!0});return ta.set(t,{projection:e,blend:r,exaggeration:i,indexLimit:n,surface:c}),c}function lw(t,e,r){let i=0,n=(e??1/0)/Math.hypot(...t.direction);for(let o of[0,1])if(t.direction[o]===0){if(t.origin[o]<r[o]||t.origin[o]>r[o+2])return!1}else{let s=(r[o]-t.origin[o])/t.direction[o],a=(r[o+2]-t.origin[o])/t.direction[o];if(i=Math.max(i,Math.min(s,a)),n=Math.min(n,Math.max(s,a)),i>n)return!1}return!0}var $r=class extends Vi{queryOwners;generation;frameTime;exaggeration;inputBytes;displayKey;get reservedQueryIndexBytes(){return this.indexBudget.reserved}indexBudget;constructor(e,r,i,n,o,s=16*1024*1024,a=32*1024*1024){if(!Number.isSafeInteger(i)||i<0||!Number.isFinite(n)||!Number.isFinite(o)||o<0||o>1e3)throw new Error("Invalid terrain surface frame");if(!Number.isSafeInteger(s)||s<0)throw new Error("Invalid terrain query index budget");if(!Number.isSafeInteger(a)||a<0)throw new Error("Invalid terrain projected query budget");let l=[],u={reserved:0},c=new Map,h=new Map,d=0,f=r.map(p=>{if(!Number.isFinite(p.blend)||p.blend<0||p.blend>1)throw new Error("Invalid terrain surface blend");let m=p.mesh;if(m.positions.length%3||m.heights.length!==m.positions.length/3*2)throw new Error("Invalid terrain query channels");if(m.globeBasis&&!fg.has(m)){if(m.globeBasis.length!==m.positions.length*4||!m.globeBasis.every(Number.isFinite))throw new Error("Invalid terrain globe basis channels");fg.add(m)}let g=p.blend,_=p.clips?.map(M=>[...M]),x=p.halfOpenClips??!1;if(typeof x!="boolean")throw new Error("Invalid terrain query clip ownership");let v=Ui.getRequiredHierarchyBytes(m.indices.length/3);if(_?.some(M=>M.length!==4||!M.every(Number.isFinite)||M[0]>M[2]||M[1]>M[3]))throw new Error("Invalid terrain query clip");let A=Math.PI*ae.mercatorRadius;if(x)for(let M of _??[])for(let R of[2,3])Math.abs(M[R]-A)<=A*Number.EPSILON*8&&(M[R]=A);let w,E={blend:g,projectionBuilds:0,preparationMs:0,queryMs:0,prepare(){if(!E.surface){let M=h.get(m)?.get(g);if(M)return E.surface=M,M;let R=performance.now(),U=m.positions.length*8+m.heights.length/2*8+m.indices.length*4;if(U>a-d)ta.delete(m),E.surface=new $n(m,e,g,o);else{d+=U;let k=g!==1?0:c.get(m)??(v<=s-u.reserved?v:0);g===1&&!c.has(m)&&(c.set(m,k),u.reserved+=k);let b=ta.get(m);E.projectionBuilds=+(b?.projection!==e||b.blend!==g||b.exaggeration!==o||b.indexLimit!==k),E.surface=aw(m,e,g,o,k)}E.preparationMs+=performance.now()-R;let T=h.get(m)??new Map;T.set(g,E.surface),h.set(m,T)}return E.surface}};return l.push(E),{id:p.id,surface:{projection:e,getBounds(){return w===void 0&&(w=nw(m,e,o,_)),w?{minimum:[...w.minimum],maximum:[...w.maximum]}:null},intersectRay(M,R){if(_?.length===0||!m.indices.length||e==="web-mercator"&&!lw(M,R,m.bounds))return null;let U=E.prepare(),T=performance.now(),k=U.intersectRay(M,R,_?(b,L,B)=>{let F=e==="web-mercator"?b:[0,1].map(ee=>B.reduce((G,Z,O)=>G+Z*m.positions[m.indices[L*3+O]*3+ee],0));return _.some(ee=>F[0]>=ee[0]&&(x&&ee[2]!==A?F[0]<ee[2]:F[0]<=ee[2])&&F[1]>=ee[1]&&(x&&ee[3]!==A?F[1]<ee[3]:F[1]<=ee[3]))}:void 0);return E.queryMs+=performance.now()-T,k}}}});super(e,f),this.generation=i,this.frameTime=n,this.exaggeration=o,this.queryOwners=l,this.indexBudget=u,this.inputBytes=[...new Set(r.map(p=>p.mesh))].reduce((p,m)=>p+m.positions.byteLength+m.heights.byteLength+m.indices.byteLength+(m.globeBasis?.byteLength??0),0),this.displayKey=`${e}/${i}/${o}/${s}/${a}/${r.map(p=>`${p.id}:${sw(p.mesh)}:${p.blend}:${JSON.stringify(p.clips)}:${!!p.halfOpenClips}`).join(",")}`}*prepareQueryIndexSteps(){let e=new Set,r=[];for(let i of this.queryOwners){let n=i.surface;!n||n instanceof $n||i.blend!==1||e.has(n)||zu.has(n)||(e.add(n),r.push({owner:i,steps:n.prepareQueryIndexSteps()}))}try{for(;r.length;)for(let i=0;i<r.length;){let{owner:n,steps:o}=r[i],s=performance.now(),a;try{a=o.next().done}catch(l){n.surface&&zu.add(n.surface),D("warn","Terrain query acceleration failed; retaining exact linear queries",l),a=!0}finally{n.preparationMs+=performance.now()-s}a?(o.return(),r.splice(i,1)):(i++,yield)}}finally{for(let{steps:i}of r)i.return()}}getStatistics(){let e={inputBytes:this.inputBytes,projectedBytes:0,queryIndexBytes:0,reservedQueryIndexBytes:this.reservedQueryIndexBytes,preparedMeshes:0,projectionBuilds:0,preparationMs:0,queryMs:0,preparationFailures:0,streamingMeshes:0},r=new Set;for(let i of this.queryOwners){if(i.surface&&!r.has(i.surface)){let n=i.surface.getStatistics();e.projectedBytes+=n.geometryBytes,e.queryIndexBytes+=n.queryIndexBytes,e.preparationFailures+=Number(zu.has(i.surface)),r.add(i.surface)}e.preparedMeshes+=+(i.surface!==void 0),e.streamingMeshes+=+(i.surface instanceof $n),e.projectionBuilds+=i.projectionBuilds,e.preparationMs+=i.preparationMs,e.queryMs+=i.queryMs}return e}};var qr=class t{gpuBackend;device_renderer;scene;get activeTileManager(){if(!this.scene.tile_manager)throw new Error("Renderer scene tile manager has been destroyed");return this.scene.tile_manager}host_frame;active_render_view_id;animationFrame=null;submittedViews=new Set;terrainQueryPreparation;annotationTerrainSurface;projectionUpdate=Promise.resolve();projectionNeedsRebuild=!1;terrainUpdate=Promise.resolve();pendingTerrain;pendingTerrainUsesPrevious=!1;terrainRevision=0;terrainFailed=!1;terrainUpdating=!1;terrainRibbonScheduled=!1;requestedTerrainRibbonZoom;admittedTerrainRibbonZoom;terrainRibbonFailure;terrainSurfaceSnapshot=null;terrainDisplayMinimumHeight=0;destroyed=!1;constructor(e,r={}){Ws(r.maxConcurrentTileLoadsPerWorker),Dn(r.projectionEngine),In(r.projectionEngineExecution),this.gpuBackend=r.device?new dr(r.device):null,this.device_renderer=this.gpuBackend;let i=this.gpuBackend?this.gpuBackend.getSceneOptions():{};this.scene=Wt.create(e,Object.assign({},r,i,{device:this.gpuBackend?this.gpuBackend.device:r.device,disableRenderLoop:!0,cameraMode:"external"})),this.terrainDisplayMinimumHeight=this.scene.terrain?.minimumHeight??0,this.host_frame=null,this.active_render_view_id=null}static create(e,r={}){return new t(e,r)}subscribe(e){return this.scene.subscribe(e)}load(e=null,r={}){return this.terrainSurfaceSnapshot=null,this.annotationTerrainSurface=void 0,this.terrainQueryPreparation?.steps.return(),this.terrainQueryPreparation=void 0,this.scene.load(e,r)}setTerrain(e){if(this.destroyed||!this.scene.terrain)return Promise.reject(new Error("Terrain requires a live enabled renderer"));this.pendingTerrain=$o(e),this.terrainRibbonFailure=void 0,this.pendingTerrainUsesPrevious=e.previousGrids===void 0;let r=++this.terrainRevision,i=this.terrainUpdate.then(async()=>{if(this.destroyed)throw new Error("Cannot update a destroyed renderer");if(r!==this.terrainRevision)return;if(!this.scene.terrain)throw new Error("Terrain must be enabled at renderer creation");let n=this.pendingTerrain;if(!n)return;this.pendingTerrain=void 0;let o=this.scene.terrain;if(n={...n,transitionGeneration:o.transitionGeneration+1},this.pendingTerrainUsesPrevious&&n.grids.length&&o.grids.length){let s=n.byteLength+o.grids.reduce((l,u)=>l+u.heights.byteLength+u.valid.byteLength,0);if(s>n.maxGridBytes)throw new Error("Terrain draping current/previous grid-byte budget exceeded");if(o.grids[0].verticalDatum!==n.grids[0].verticalDatum)throw new Error("Terrain draping previous datum must match");let a=o.grids.reduce((l,u)=>{for(let c=0;c<u.heights.length;c++)u.valid[c]&&(l=Math.min(l,u.heights[c]));return l},0);n={...n,previousGrids:o.grids,previousGroundMeshResolution:o.groundMeshResolution,byteLength:s,minimumHeight:Math.min(n.minimumHeight,a)}}if(n.minimumHeight*this.scene.terrainExaggeration<=-ae.earthRadius)throw new Error("Terrain exaggeration would invert the globe radius");this.scene.terrain=n,this.terrainUpdating=!0;try{await this.scene.rebuild({preserveTileCache:!0,preserveTime:!0}),this.terrainDisplayMinimumHeight=n.minimumHeight,this.terrainFailed=!1,this.destroyed||this.scene.requestRedraw()}catch(s){if(this.scene.terrain=o,this.terrainFailed=!0,!this.destroyed)try{await this.scene.rebuild({preserveTileCache:!0,preserveTime:!0}),this.terrainFailed=!1,this.destroyed||this.scene.requestRedraw()}catch(a){throw new AggregateError([s,a],"Terrain update and recovery failed")}throw s}finally{this.terrainUpdating=!1}});return this.terrainUpdate=i.catch(()=>{}),i}requestTerrainRibbonRefinement(e){if(this.requestedTerrainRibbonZoom=e,this.terrainRibbonScheduled||this.admittedTerrainRibbonZoom===e||this.terrainRibbonFailure?.zoom===e||!this.scene.terrain?.groundMeshResolution||!this.scene.terrainRibbonStyles&&!this.activeTileManager.getTerrainDrapingStatistics(this.scene.terrain).ribbonMeshes)return;this.terrainRibbonScheduled=!0;let r=this.terrainUpdate.then(async()=>{if(this.destroyed||!this.scene.terrain?.groundMeshResolution)return;let i=this.requestedTerrainRibbonZoom;if(i===void 0||i===this.admittedTerrainRibbonZoom)return;let n=this.scene.terrainRibbonZoom;this.terrainUpdating=!0;try{if(await this.scene.rebuild({preserveTileCache:!0,preserveTime:!0,terrainRibbonZoom:i})===!1)return;this.admittedTerrainRibbonZoom=i,this.terrainRibbonFailure=void 0,this.terrainFailed=!1}catch(o){if(this.terrainRibbonFailure={zoom:i,message:o instanceof Error?o.message:String(o)},this.scene.terrainRibbonZoom=n,!this.destroyed)try{if(await this.scene.rebuild({preserveTileCache:!0,preserveTime:!0,terrainRibbonZoom:n??null})===!1)throw new Error("Terrain ribbon recovery was superseded")}catch(s){throw this.terrainFailed=!0,new AggregateError([o,s],"Terrain ribbon update and recovery failed")}}finally{this.terrainUpdating=!1}}).finally(()=>{this.terrainRibbonScheduled=!1,this.destroyed||this.scene.requestRedraw()});this.terrainUpdate=r.catch(()=>{})}setTerrainExaggeration(e){if(this.destroyed||!this.scene.terrain)throw new Error("Terrain requires a live enabled renderer");if(!Number.isFinite(e)||e<0||e>1e3)throw new Error("Terrain exaggeration must be in [0, 1000]");if(Math.min(this.scene.terrain.minimumHeight,this.terrainDisplayMinimumHeight)*e<=-ae.earthRadius)throw new Error("Terrain exaggeration would invert the globe radius");this.scene.terrainExaggeration!==e&&(this.scene.terrainExaggeration=e,this.scene.requestRedraw())}getTerrainDrapingStatistics(){return{...this.activeTileManager.getTerrainDrapingStatistics(this.scene.terrain),...this.scene.terrain?.groundMeshResolution?{ribbonRefinement:{requestedZoom:this.requestedTerrainRibbonZoom,admittedZoom:this.admittedTerrainRibbonZoom,pending:this.terrainRibbonScheduled,error:this.terrainRibbonFailure?.message}}:{},annotationQueries:this.annotationTerrainSurface?.getStatistics()}}setProjectedBasemapProjection(e){let r=Sr(e),i=this.projectionUpdate.then(async()=>{if(this.destroyed)throw new Error("Cannot update a destroyed renderer");let n=this.scene.config?.scene;if(!n?.cpu_projection)throw new Error("Projection updates require a loaded CPU-projected scene");let o=Sr(n.cpu_projection);if(!(!this.projectionNeedsRebuild&&JSON.stringify(o)===JSON.stringify(r))){n.cpu_projection=r;try{await this.scene.rebuild({preserveTileCache:!0}),this.projectionNeedsRebuild=!1,this.destroyed||this.scene.requestRedraw()}catch(s){throw this.projectionNeedsRebuild=!0,n.cpu_projection=o,s}}});return this.projectionUpdate=i.catch(()=>{}),i}getAttributions(){return this.scene.getAttributions()}getFeatureAt(e,r={}){if(this.destroyed)return Promise.reject(new Error("Cannot query a destroyed renderer"));if(this.terrainUpdating)return this.terrainUpdate.then(()=>this.getFeatureAt(e,r));if(this.terrainFailed)return Promise.reject(new Error("Terrain generation requires a successful correction"));if(![e.x,e.y,r.radius??0].every(Number.isFinite)||(r.radius??0)<0)return Promise.reject(new Error("Selection coordinates and non-negative radius must be finite"));let i;try{if(!this.host_frame&&(r.renderViewId!==void 0||r.coordinateSpace==="canvas"))throw new Error("View-aware selection requires a HostFrame");i=this.host_frame?.resolveSelectionPoint(e,r,this.active_render_view_id??void 0)}catch(o){return Promise.reject(o)}if(i===null)return Promise.resolve({feature:null,changed:!1,pixel:{...e}});let n=this.scene.getFeatureAt(i?.pixel??{...e},{radius:r.radius,...i?{renderViewId:i.view.id,width:i.view.viewport.width,height:i.view.viewport.height}:{}});return this.scene.requestRedraw(),i?n.then(o=>o&&{...o,pixel:{...e},renderViewId:i.view.id}):n}getDrapedTerrainSurface(){return this.destroyed||this.terrainFailed?null:this.terrainSurfaceSnapshot}getTerrainAt(e,r,i={}){if(this.destroyed)throw new Error("Cannot query a destroyed renderer");if(!this.host_frame)throw new Error("Terrain selection requires a HostFrame");let n=r??this.getDrapedTerrainSurface();return n?ea(this.host_frame,e,n,i,this.active_render_view_id??void 0):null}getSourceMetadata(){return this.scene.getSourceMetadata()}getTileSourceStatistics(){return this.scene.getTileSourceStatistics()}getProjectionEngineStatistics(){return this.scene.getProjectionEngineStatistics()}getLumaLightDefinitions(){return this.scene.getLumaLightDefinitions()}getTileResourceStatistics(){return this.activeTileManager.getResourceStatistics()}setFrame(e,{renderViewId:r}={}){let i=hr.from(e);if(this.scene.config&&!!this.scene.config.scene?.cpu_projection!=(i.projection.type==="projected"))throw new Error("CPU-projected scene meshes and HostFrame projection must match");let n=i.getRenderView(r),o=n.viewport,s=this.active_render_view_id!==n.id;return this.scene.view.applyHostFrame(i,()=>{(this.scene.view.size.css.width!==o.width||this.scene.view.size.css.height!==o.height)&&this.scene.resizeMap(o.width,o.height)},()=>{this.scene.setCameraMatrices(i.projection.type==="projected"?{...n.camera,view:new Float64Array(new Oe),projection:new Float64Array(new Oe(Array.from(n.camera.projection)).multiplyRight(Array.from(n.camera.view)))}:n.camera),this.host_frame=i,this.active_render_view_id=n.id}),i!==this.animationFrame&&(this.animationFrame=i,this.submittedViews.clear(),this.scene.host_animation_time=i.animationTime??Math.max(0,(Date.now()-this.scene.start_time)/1e3)),s&&(this.scene.dirty=!0),this.scene.setFeatureSelectionView?.(n.id,i.renderViews.map(a=>a.id)),i}render({frame:e,renderPass:r=null,renderViewId:i,force:n=!1}={}){if(this.destroyed||this.terrainFailed)return!1;if(e)this.setFrame(e,{renderViewId:i});else if(i){if(!this.host_frame)throw new Error("Renderer requires a HostFrame before selecting a render view");this.setFrame(this.host_frame,{renderViewId:i})}if(this.host_frame&&this.active_render_view_id&&this.scene.setFeatureSelectionView?.(this.active_render_view_id,this.host_frame.renderViews.map(s=>s.id)),n&&(this.scene.dirty=!0),this.active_render_view_id&&this.submittedViews.has(this.active_render_view_id)&&(this.submittedViews.clear(),this.host_frame&&(this.scene.host_animation_time=this.host_frame.animationTime??Math.max(0,(Date.now()-this.scene.start_time)/1e3))),this.host_frame){this.submittedViews.size||(this.requestTerrainRibbonRefinement(this.host_frame.geographicAnchor.zoom),this.scene.terrainFrameTime=performance.now(),this.advanceTerrainQueryPreparation());let s;if(this.scene.terrain?.occludeAnnotations&&this.host_frame.projection.type!=="projected"){let a=this.activeTileManager.getDrapedTerrainQueryEntries(this.scene.terrainFrameTime??performance.now()),l=new $r(this.host_frame.projection.type,a,this.scene.terrainDisplayGeneration??0,this.scene.terrainFrameTime??performance.now(),this.scene.terrainExaggeration,this.scene.terrain.maxQueryIndexBytes,this.scene.terrain.maxProjectedQueryBytes);this.annotationTerrainSurface?.displayKey!==l.displayKey&&(this.annotationTerrainSurface=l),s=this.annotationTerrainSurface}else this.annotationTerrainSurface=void 0;this.activeTileManager.updateProjectedLabels(this.host_frame,this.gpuBackend?.device.type!=="webgpu",s)}let o=this.scene.updateScene({renderPass:r});if(o&&this.scene.terrain&&this.host_frame&&this.host_frame.projection.type!=="projected"){let s=this.scene.terrainFrameTime??performance.now(),a=this.activeTileManager.getDrapedTerrainQueryEntries(s);this.terrainSurfaceSnapshot=new $r(this.host_frame.projection.type,a,this.scene.terrainDisplayGeneration??0,s,this.scene.terrainExaggeration,this.scene.terrain.maxQueryIndexBytes,this.scene.terrain.maxProjectedQueryBytes)}return this.submittedViews.size===0&&this.scene.processTasks(),this.active_render_view_id&&this.submittedViews.add(this.active_render_view_id),o&&this.scene.config&&this.scene.animated&&this.scene.requestRedraw(),o}advanceTerrainQueryPreparation(){let e=this.annotationTerrainSurface??this.terrainSurfaceSnapshot,r=this.scene.terrain?.queryPreparationBudgetMs??0;if(!e||!r){this.terrainQueryPreparation?.steps.return(),this.terrainQueryPreparation=void 0;return}this.terrainQueryPreparation?.snapshot.displayKey!==e.displayKey&&(this.terrainQueryPreparation?.steps.return(),this.terrainQueryPreparation={snapshot:e,steps:e.prepareQueryIndexSteps()});let i=this.terrainQueryPreparation,n=performance.now();do if(i.steps.next().done){this.terrainQueryPreparation=void 0;return}while(performance.now()-n<r);this.scene.requestRedraw()}destroy(){this.annotationTerrainSurface=void 0,this.terrainQueryPreparation?.steps.return(),this.terrainQueryPreparation=void 0,this.destroyed=!0,this.pendingTerrain=void 0,this.terrainSurfaceSnapshot=null,this.terrainRevision++;try{return this.scene.destroy()}finally{this.gpuBackend&&this.gpuBackend.destroy()}}};var gg=Ot(Hl(),1);function mg(t,e){return Ou(t,[0,0],e)}function Ou(t,e,r){let[i,n]=e;if(e.length!==2||!Number.isFinite(i)||!Number.isFinite(n)||i>n)throw new Error("Elevation range requires two finite ordered heights");if(t.view.length!==16||t.projection.length!==16||!Array.from(t.view).every(Number.isFinite)||!Array.from(t.projection).every(Number.isFinite))throw new Error("Ground footprint requires finite camera matrices");if(r&&(![r.sw.x,r.sw.y,r.ne.x,r.ne.y].every(Number.isFinite)||r.sw.x>r.ne.x||r.sw.y>r.ne.y))throw new Error("Ground footprint limits must be finite ordered bounds");let o=new Oe().copy(t.projection).multiplyRight(t.view);if(!Number.isFinite(o.determinant())||o.determinant()===0)throw new Error("Ground footprint camera is singular");o.invert();let s=[];for(let d of[-1,1])for(let f of[-1,1])for(let p of[-1,1]){let m=o.transform([p,f,d,1]),g=Array.from(m).slice(0,3).map(_=>_/m[3]);if(!g.every(Number.isFinite)||m[3]<=0)throw new Error("Ground footprint requires a finite near and far frustum");s.push(g)}let a=s.filter(d=>d[2]>=i&&d[2]<=n).map(d=>[d[0],d[1]]);for(let d=0;d<s.length;d++)for(let f of[1,2,4]){let p=d^f;if(p<d)continue;let m=s[d],g=s[p];for(let _ of[i,n])if(m[2]===_&&a.push([m[0],m[1]]),g[2]===_&&a.push([g[0],g[1]]),m[2]<_&&g[2]>_||m[2]>_&&g[2]<_){let x=(_-m[2])/(g[2]-m[2]);a.push([m[0]+x*(g[0]-m[0]),m[1]+x*(g[1]-m[1])])}}let l=uw(a);if(l.length<3||(r&&(l=ra(l,0,r.sw.x,!0),l=ra(l,0,r.ne.x,!1),l=ra(l,1,r.sw.y,!0),l=ra(l,1,r.ne.y,!1)),l.length<3))return null;let u=l[0];if(l.reduce((d,f,p)=>{let m=l[(p+1)%l.length];return d+(f[0]-u[0])*(m[1]-u[1])-(f[1]-u[1])*(m[0]-u[0])},0)===0)return null;let h={sw:{x:Math.min(...l.map(d=>d[0])),y:Math.min(...l.map(d=>d[1]))},ne:{x:Math.max(...l.map(d=>d[0])),y:Math.max(...l.map(d=>d[1]))}};return h.ne.x>h.sw.x&&h.ne.y>h.sw.y?h:null}function uw(t){let e=t.sort((s,a)=>s[0]-a[0]||s[1]-a[1]).filter((s,a,l)=>a===0||s[0]!==l[a-1][0]||s[1]!==l[a-1][1]),r=(s,a,l)=>(a[0]-s[0])*(l[1]-s[1])-(a[1]-s[1])*(l[0]-s[0]),i=s=>{let a=[];for(let l of s){for(;a.length>=2&&r(a[a.length-2],a[a.length-1],l)<=0;)a.pop();a.push(l)}return a},n=i(e),o=i([...e].reverse());return[...n.slice(0,-1),...o.slice(0,-1)]}function ra(t,e,r,i){let n=[],o=s=>i?s[e]>=r:s[e]<=r;for(let s=0;s<t.length;s++){let a=t[s],l=t[(s+1)%t.length];if(o(a)&&n.push(a),o(a)!==o(l)){let u=(r-a[e])/(l[e]-a[e]),c=[a[0]+u*(l[0]-a[0]),a[1]+u*(l[1]-a[1])];c[e]=r,n.push(c)}}return n}var cw={log:D,yaml:gg.default,Utils:de,Geo:q,Vector:le,DataSource:qe,GLSL:Ke,ShaderProgram:re,UniformBuffer:Ft,VertexData:br,Texture:K,Material:pt,Light:ke,Scene:Gi,ClassicWebGLRenderer:qr,HostFrame:hr,LumaDeviceRenderer:dr,WorkerBroker:ce,Task:Xe,StyleManager:Si,StyleParser:W,TileID:Te,Collision:Fe,FeatureSelection:Je,TextCanvas:lt,debugSettings:Ze},hw={Scene:Gi,ClassicWebGLRenderer:qr,Renderer:qr,HostFrame:hr,LumaDeviceRenderer:dr,debug:cw,version:Zi};var qi=hw;var _g=`"use strict";(()=>{var Id=Object.create;var Js=Object.defineProperty;var Gd=Object.getOwnPropertyDescriptor;var Vd=Object.getOwnPropertyNames;var Ud=Object.getPrototypeOf,jd=Object.prototype.hasOwnProperty;var je=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}};var Wd=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Vd(e))!jd.call(t,n)&&n!==r&&Js(t,n,{get:()=>e[n],enumerable:!(i=Gd(e,n))||i.enumerable});return t};var Zt=(t,e,r)=>(r=t!=null?Id(Ud(t)):{},Wd(e||!t||!t.__esModule?Js(r,"default",{value:t,enumerable:!0}):r,t));var Ya=je(Xa=>{var qa={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function Vr(t){return t=Math.round(t),t<0?0:t>255?255:t}function Ha(t){return t<0?0:t>1?1:t}function oo(t){return t[t.length-1]==="%"?Vr(parseFloat(t)/100*255):Vr(parseInt(t))}function Ai(t){return t[t.length-1]==="%"?Ha(parseFloat(t)/100):Ha(parseFloat(t))}function so(t,e,r){return r<0?r+=1:r>1&&(r-=1),r*6<1?t+(e-t)*r*6:r*2<1?e:r*3<2?t+(e-t)*(2/3-r)*6:t}function wf(t){var e=t.replace(/ /g,"").toLowerCase();if(e in qa)return qa[e].slice();if(e[0]==="#"){if(e.length===4){var r=parseInt(e.substr(1),16);return r>=0&&r<=4095?[(r&3840)>>4|(r&3840)>>8,r&240|(r&240)>>4,r&15|(r&15)<<4,1]:null}else if(e.length===7){var r=parseInt(e.substr(1),16);return r>=0&&r<=16777215?[(r&16711680)>>16,(r&65280)>>8,r&255,1]:null}return null}var i=e.indexOf("("),n=e.indexOf(")");if(i!==-1&&n+1===e.length){var o=e.substr(0,i),s=e.substr(i+1,n-(i+1)).split(","),a=1;switch(o){case"rgba":if(s.length!==4)return null;a=Ai(s.pop());case"rgb":return s.length!==3?null:[oo(s[0]),oo(s[1]),oo(s[2]),a];case"hsla":if(s.length!==4)return null;a=Ai(s.pop());case"hsl":if(s.length!==3)return null;var l=(parseFloat(s[0])%360+360)%360/360,u=Ai(s[1]),c=Ai(s[2]),d=c<=.5?c*(u+1):c+u-c*u,f=c*2-d;return[Vr(so(f,d,l+1/3)*255),Vr(so(f,d,l)*255),Vr(so(f,d,l-1/3)*255),a];default:return null}}return null}try{Xa.parseCSSColor=wf}catch{}});var Fl=je((xx,Nl)=>{Nl.exports=bh;function bh(t){t=String(t);for(var e=[],r;r=t.match(/ERROR\\:([^\\n]+)/);){t=t.slice(r.index+1);var s=r[1].trim(),i=s.split(":"),n=i.slice(2).join(":").trim(),o=parseInt(i[0],10),s=parseInt(i[1],10);e.push({message:n,file:o,line:s})}return e}});var Zu=je(qo=>{qo.read=function(t,e,r,i,n){var o,s,a=n*8-i-1,l=(1<<a)-1,u=l>>1,c=-7,d=r?n-1:0,f=r?-1:1,h=t[e+d];for(d+=f,o=h&(1<<-c)-1,h>>=-c,c+=a;c>0;o=o*256+t[e+d],d+=f,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=i;c>0;s=s*256+t[e+d],d+=f,c-=8);if(o===0)o=1-u;else{if(o===l)return s?NaN:(h?-1:1)*(1/0);s=s+Math.pow(2,i),o=o-u}return(h?-1:1)*s*Math.pow(2,o-i)};qo.write=function(t,e,r,i,n,o){var s,a,l,u=o*8-n-1,c=(1<<u)-1,d=c>>1,f=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=i?0:o-1,m=i?1:-1,g=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-s))<1&&(s--,l*=2),s+d>=1?e+=f/l:e+=f*Math.pow(2,1-d),e*l>=2&&(s++,l/=2),s+d>=c?(a=0,s=c):s+d>=1?(a=(e*l-1)*Math.pow(2,n),s=s+d):(a=e*Math.pow(2,d-1)*Math.pow(2,n),s=0));n>=8;t[r+h]=a&255,h+=m,a/=256,n-=8);for(s=s<<n|a,u+=n;u>0;t[r+h]=s&255,h+=m,s/=256,u-=8);t[r+h-m]|=g*128}});var tc=je((ov,ec)=>{"use strict";ec.exports=he;var ln=Zu();function he(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}he.Varint=0;he.Fixed64=1;he.Bytes=2;he.Fixed32=5;var Ho=65536*65536,Ju=1/Ho;he.prototype={destroy:function(){this.buf=null},readFields:function(t,e,r){for(r=r||this.length;this.pos<r;){var i=this.readVarint(),n=i>>3,o=this.pos;this.type=i&7,t(n,e,this),this.pos===o&&this.skip(i)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=un(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Qu(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=un(this.buf,this.pos)+un(this.buf,this.pos+4)*Ho;return this.pos+=8,t},readSFixed64:function(){var t=un(this.buf,this.pos)+Qu(this.buf,this.pos+4)*Ho;return this.pos+=8,t},readFloat:function(){var t=ln.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=ln.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e=this.buf,r,i;return i=e[this.pos++],r=i&127,i<128||(i=e[this.pos++],r|=(i&127)<<7,i<128)||(i=e[this.pos++],r|=(i&127)<<14,i<128)||(i=e[this.pos++],r|=(i&127)<<21,i<128)?r:(i=e[this.pos],r|=(i&15)<<28,xm(r,t,this))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2===1?(t+1)/-2:t/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var t=this.readVarint()+this.pos,e=zm(this.buf,this.pos,t);return this.pos=t,e},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){var r=lt(this);for(t=t||[];this.pos<r;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){var e=lt(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){var e=lt(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){var e=lt(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){var e=lt(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){var e=lt(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){var e=lt(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){var e=lt(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){var e=lt(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=t&7;if(e===he.Varint)for(;this.buf[this.pos++]>127;);else if(e===he.Bytes)this.pos=this.readVarint()+this.pos;else if(e===he.Fixed32)this.pos+=4;else if(e===he.Fixed64)this.pos+=8;else throw new Error("Unimplemented type: "+e)},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var r=new Uint8Array(e);r.set(this.buf),this.buf=r,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),vr(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),vr(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),vr(this.buf,t&-1,this.pos),vr(this.buf,Math.floor(t*Ju),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),vr(this.buf,t&-1,this.pos),vr(this.buf,Math.floor(t*Ju),this.pos+4),this.pos+=8},writeVarint:function(t){if(t=+t||0,t>268435455||t<0){Tm(t,this);return}this.realloc(4),this.buf[this.pos++]=t&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=t>>>7&127)))},writeSVarint:function(t){this.writeVarint(t<0?-t*2-1:t*2)},writeBoolean:function(t){this.writeVarint(!!t)},writeString:function(t){t=String(t),this.realloc(t.length*4),this.pos++;var e=this.pos;this.pos=Nm(this.buf,t,this.pos);var r=this.pos-e;r>=128&&Ku(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),ln.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),ln.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r<e;r++)this.buf[this.pos++]=t[r]},writeRawMessage:function(t,e){this.pos++;var r=this.pos;t(e,this);var i=this.pos-r;i>=128&&Ku(r,i,this),this.pos=r-1,this.writeVarint(i),this.pos+=i},writeMessage:function(t,e,r){this.writeTag(t,he.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(t,e){this.writeMessage(t,Em,e)},writePackedSVarint:function(t,e){this.writeMessage(t,Mm,e)},writePackedBoolean:function(t,e){this.writeMessage(t,Sm,e)},writePackedFloat:function(t,e){this.writeMessage(t,Am,e)},writePackedDouble:function(t,e){this.writeMessage(t,Rm,e)},writePackedFixed32:function(t,e){this.writeMessage(t,Pm,e)},writePackedSFixed32:function(t,e){this.writeMessage(t,Lm,e)},writePackedFixed64:function(t,e){this.writeMessage(t,Cm,e)},writePackedSFixed64:function(t,e){this.writeMessage(t,km,e)},writeBytesField:function(t,e){this.writeTag(t,he.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,he.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,he.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,he.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,he.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,he.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,he.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,he.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,he.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,he.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,!!e)}};function xm(t,e,r){var i=r.buf,n,o;if(o=i[r.pos++],n=(o&112)>>4,o<128||(o=i[r.pos++],n|=(o&127)<<3,o<128)||(o=i[r.pos++],n|=(o&127)<<10,o<128)||(o=i[r.pos++],n|=(o&127)<<17,o<128)||(o=i[r.pos++],n|=(o&127)<<24,o<128)||(o=i[r.pos++],n|=(o&1)<<31,o<128))return Tr(t,n,e);throw new Error("Expected varint not more than 10 bytes")}function lt(t){return t.type===he.Bytes?t.readVarint()+t.pos:t.pos+1}function Tr(t,e,r){return r?e*4294967296+(t>>>0):(e>>>0)*4294967296+(t>>>0)}function Tm(t,e){var r,i;if(t>=0?(r=t%4294967296|0,i=t/4294967296|0):(r=~(-t%4294967296),i=~(-t/4294967296),r^4294967295?r=r+1|0:(r=0,i=i+1|0)),t>=18446744073709552e3||t<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),vm(r,i,e),wm(i,e)}function vm(t,e,r){r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos++]=t&127|128,t>>>=7,r.buf[r.pos]=t&127}function wm(t,e){var r=(t&7)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=t&127)))))}function Ku(t,e,r){var i=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.ceil(Math.log(e)/(Math.LN2*7));r.realloc(i);for(var n=r.pos-1;n>=t;n--)r.buf[n+i]=r.buf[n]}function Em(t,e){for(var r=0;r<t.length;r++)e.writeVarint(t[r])}function Mm(t,e){for(var r=0;r<t.length;r++)e.writeSVarint(t[r])}function Am(t,e){for(var r=0;r<t.length;r++)e.writeFloat(t[r])}function Rm(t,e){for(var r=0;r<t.length;r++)e.writeDouble(t[r])}function Sm(t,e){for(var r=0;r<t.length;r++)e.writeBoolean(t[r])}function Pm(t,e){for(var r=0;r<t.length;r++)e.writeFixed32(t[r])}function Lm(t,e){for(var r=0;r<t.length;r++)e.writeSFixed32(t[r])}function Cm(t,e){for(var r=0;r<t.length;r++)e.writeFixed64(t[r])}function km(t,e){for(var r=0;r<t.length;r++)e.writeSFixed64(t[r])}function un(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+t[e+3]*16777216}function vr(t,e,r){t[r]=e,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24}function Qu(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function zm(t,e,r){for(var i="",n=e;n<r;){var o=t[n],s=null,a=o>239?4:o>223?3:o>191?2:1;if(n+a>r)break;var l,u,c;a===1?o<128&&(s=o):a===2?(l=t[n+1],(l&192)===128&&(s=(o&31)<<6|l&63,s<=127&&(s=null))):a===3?(l=t[n+1],u=t[n+2],(l&192)===128&&(u&192)===128&&(s=(o&15)<<12|(l&63)<<6|u&63,(s<=2047||s>=55296&&s<=57343)&&(s=null))):a===4&&(l=t[n+1],u=t[n+2],c=t[n+3],(l&192)===128&&(u&192)===128&&(c&192)===128&&(s=(o&15)<<18|(l&63)<<12|(u&63)<<6|c&63,(s<=65535||s>=1114112)&&(s=null))),s===null?(s=65533,a=1):s>65535&&(s-=65536,i+=String.fromCharCode(s>>>10&1023|55296),s=56320|s&1023),i+=String.fromCharCode(s),n+=a}return i}function Nm(t,e,r){for(var i=0,n,o;i<e.length;i++){if(n=e.charCodeAt(i),n>55295&&n<57344)if(o)if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,o=n;continue}else n=o-55296<<10|n-56320|65536,o=null;else{n>56319||i+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):o=n;continue}else o&&(t[r++]=239,t[r++]=191,t[r++]=189,o=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=n&63|128)}return r}});var ic=je((sv,rc)=>{"use strict";rc.exports=wr;function wr(t,e){this.x=t,this.y=e}wr.prototype={clone:function(){return new wr(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[0]*this.x+t[1]*this.y,r=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=r,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),i=e*this.x-r*this.y,n=r*this.x+e*this.y;return this.x=i,this.y=n,this},_rotateAround:function(t,e){var r=Math.cos(t),i=Math.sin(t),n=e.x+r*(this.x-e.x)-i*(this.y-e.y),o=e.y+i*(this.x-e.x)+r*(this.y-e.y);return this.x=n,this.y=o,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}};wr.convert=function(t){return t instanceof wr?t:Array.isArray(t)?new wr(t[0],t[1]):t}});var Xo=je((av,nc)=>{"use strict";var Fm=ic();nc.exports=Er;function Er(t,e,r,i,n){this.properties={},this.extent=r,this.type=0,this._pbf=t,this._geometry=-1,this._keys=i,this._values=n,t.readFields(Om,this,e)}function Om(t,e,r){t==1?e.id=r.readVarint():t==2?Dm(r,e):t==3?e.type=r.readVarint():t==4&&(e._geometry=r.pos)}function Dm(t,e){for(var r=t.readVarint()+t.pos;t.pos<r;){var i=e._keys[t.readVarint()],n=e._values[t.readVarint()];e.properties[i]=n}}Er.types=["Unknown","Point","LineString","Polygon"];Er.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,i=0,n=0,o=0,s=[],a;t.pos<e;){if(!i){var l=t.readVarint();r=l&7,i=l>>3}if(i--,r===1||r===2)n+=t.readSVarint(),o+=t.readSVarint(),r===1&&(a&&s.push(a),a=[]),a.push(new Fm(n,o));else if(r===7)a&&a.push(a[0].clone());else throw new Error("unknown command "+r)}return a&&s.push(a),s};Er.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,i=0,n=0,o=0,s=1/0,a=-1/0,l=1/0,u=-1/0;t.pos<e;){if(!i){var c=t.readVarint();r=c&7,i=c>>3}if(i--,r===1||r===2)n+=t.readSVarint(),o+=t.readSVarint(),n<s&&(s=n),n>a&&(a=n),o<l&&(l=o),o>u&&(u=o);else if(r!==7)throw new Error("unknown command "+r)}return[s,l,a,u]};Er.prototype.toGeoJSON=function(t,e,r){var i=this.extent*Math.pow(2,r),n=this.extent*t,o=this.extent*e,s=this.loadGeometry(),a=Er.types[this.type],l,u;function c(h){for(var m=0;m<h.length;m++){var g=h[m],p=180-(g.y+o)*360/i;h[m]=[(g.x+n)*360/i-180,360/Math.PI*Math.atan(Math.exp(p*Math.PI/180))-90]}}switch(this.type){case 1:var d=[];for(l=0;l<s.length;l++)d[l]=s[l][0];s=d,c(s);break;case 2:for(l=0;l<s.length;l++)c(s[l]);break;case 3:for(s=Bm(s),l=0;l<s.length;l++)for(u=0;u<s[l].length;u++)c(s[l][u]);break}s.length===1?s=s[0]:a="Multi"+a;var f={type:"Feature",geometry:{type:a,coordinates:s},properties:this.properties};return"id"in this&&(f.id=this.id),f};function Bm(t){var e=t.length;if(e<=1)return[t];for(var r=[],i,n,o=0;o<e;o++){var s=Im(t[o]);s!==0&&(n===void 0&&(n=s<0),n===s<0?(i&&r.push(i),i=[t[o]]):i.push(t[o]))}return i&&r.push(i),r}function Im(t){for(var e=0,r=0,i=t.length,n=i-1,o,s;r<i;n=r++)o=t[r],s=t[n],e+=(s.x-o.x)*(o.y+s.y);return e}});var Yo=je((lv,sc)=>{"use strict";var Gm=Xo();sc.exports=oc;function oc(t,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(Vm,this,e),this.length=this._features.length}function Vm(t,e,r){t===15?e.version=r.readVarint():t===1?e.name=r.readString():t===5?e.extent=r.readVarint():t===2?e._features.push(r.pos):t===3?e._keys.push(r.readString()):t===4&&e._values.push(Um(r))}function Um(t){for(var e=null,r=t.readVarint()+t.pos;t.pos<r;){var i=t.readVarint()>>3;e=i===1?t.readString():i===2?t.readFloat():i===3?t.readDouble():i===4?t.readVarint64():i===5?t.readVarint():i===6?t.readSVarint():i===7?t.readBoolean():null}return e}oc.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new Gm(this._pbf,e,this.extent,this._keys,this._values)}});var lc=je((uv,ac)=>{"use strict";var jm=Yo();ac.exports=Wm;function Wm(t,e){this.layers=t.readFields($m,{},e)}function $m(t,e,r){if(t===3){var i=new jm(r,r.readVarint()+r.pos);i.length&&(e[i.name]=i)}}});var uc=je((cv,cn)=>{cn.exports.VectorTile=lc();cn.exports.VectorTileFeature=Xo();cn.exports.VectorTileLayer=Yo()});var Nc=je((I2,_s)=>{"use strict";_s.exports=wn;_s.exports.default=wn;function wn(t,e,r){r=r||2;var i=e&&e.length,n=i?e[0]*r:t.length,o=Cc(t,0,n,r,!0),s=[];if(!o||o.next===o.prev)return s;var a,l,u,c,d,f,h;if(i&&(o=wp(t,e,o,r)),t.length>80*r){a=u=t[0],l=c=t[1];for(var m=r;m<n;m+=r)d=t[m],f=t[m+1],d<a&&(a=d),f<l&&(l=f),d>u&&(u=d),f>c&&(c=f);h=Math.max(u-a,c-l),h=h!==0?1/h:0}return oi(o,s,r,a,l,h),s}function Cc(t,e,r,i,n){var o,s;if(n===gs(t,e,r,i)>0)for(o=e;o<r;o+=i)s=Lc(o,t[o],t[o+1],s);else for(o=r-i;o>=e;o-=i)s=Lc(o,t[o],t[o+1],s);return s&&En(s,s.next)&&(ai(s),s=s.next),s}function Rt(t,e){if(!t)return t;e||(e=t);var r=t,i;do if(i=!1,!r.steiner&&(En(r,r.next)||ue(r.prev,r,r.next)===0)){if(ai(r),r=e=r.prev,r===r.next)break;i=!0}else r=r.next;while(i||r!==e);return e}function oi(t,e,r,i,n,o,s){if(t){!s&&o&&Sp(t,i,n,o);for(var a=t,l,u;t.prev!==t.next;){if(l=t.prev,u=t.next,o?xp(t,i,n,o):yp(t)){e.push(l.i/r),e.push(t.i/r),e.push(u.i/r),ai(t),t=u.next,a=u.next;continue}if(t=u,t===a){s?s===1?(t=Tp(Rt(t),e,r),oi(t,e,r,i,n,o,2)):s===2&&vp(t,e,r,i,n,o):oi(Rt(t),e,r,i,n,o,1);break}}}}function yp(t){var e=t.prev,r=t,i=t.next;if(ue(e,r,i)>=0)return!1;for(var n=t.next.next;n!==t.prev;){if(Pr(e.x,e.y,r.x,r.y,i.x,i.y,n.x,n.y)&&ue(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function xp(t,e,r,i){var n=t.prev,o=t,s=t.next;if(ue(n,o,s)>=0)return!1;for(var a=n.x<o.x?n.x<s.x?n.x:s.x:o.x<s.x?o.x:s.x,l=n.y<o.y?n.y<s.y?n.y:s.y:o.y<s.y?o.y:s.y,u=n.x>o.x?n.x>s.x?n.x:s.x:o.x>s.x?o.x:s.x,c=n.y>o.y?n.y>s.y?n.y:s.y:o.y>s.y?o.y:s.y,d=ms(a,l,e,r,i),f=ms(u,c,e,r,i),h=t.prevZ,m=t.nextZ;h&&h.z>=d&&m&&m.z<=f;){if(h!==t.prev&&h!==t.next&&Pr(n.x,n.y,o.x,o.y,s.x,s.y,h.x,h.y)&&ue(h.prev,h,h.next)>=0||(h=h.prevZ,m!==t.prev&&m!==t.next&&Pr(n.x,n.y,o.x,o.y,s.x,s.y,m.x,m.y)&&ue(m.prev,m,m.next)>=0))return!1;m=m.nextZ}for(;h&&h.z>=d;){if(h!==t.prev&&h!==t.next&&Pr(n.x,n.y,o.x,o.y,s.x,s.y,h.x,h.y)&&ue(h.prev,h,h.next)>=0)return!1;h=h.prevZ}for(;m&&m.z<=f;){if(m!==t.prev&&m!==t.next&&Pr(n.x,n.y,o.x,o.y,s.x,s.y,m.x,m.y)&&ue(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function Tp(t,e,r){var i=t;do{var n=i.prev,o=i.next.next;!En(n,o)&&kc(n,i,i.next,o)&&si(n,o)&&si(o,n)&&(e.push(n.i/r),e.push(i.i/r),e.push(o.i/r),ai(i),ai(i.next),i=t=o),i=i.next}while(i!==t);return Rt(i)}function vp(t,e,r,i,n,o){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&Cp(s,a)){var l=zc(s,a);s=Rt(s,s.next),l=Rt(l,l.next),oi(s,e,r,i,n,o),oi(l,e,r,i,n,o);return}a=a.next}s=s.next}while(s!==t)}function wp(t,e,r,i){var n=[],o,s,a,l,u;for(o=0,s=e.length;o<s;o++)a=e[o]*i,l=o<s-1?e[o+1]*i:t.length,u=Cc(t,a,l,i,!1),u===u.next&&(u.steiner=!0),n.push(Lp(u));for(n.sort(Ep),o=0;o<n.length;o++)Mp(n[o],r),r=Rt(r,r.next);return r}function Ep(t,e){return t.x-e.x}function Mp(t,e){if(e=Ap(t,e),e){var r=zc(e,t);Rt(e,e.next),Rt(r,r.next)}}function Ap(t,e){var r=e,i=t.x,n=t.y,o=-1/0,s;do{if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){var a=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=i&&a>o){if(o=a,a===i){if(n===r.y)return r;if(n===r.next.y)return r.next}s=r.x<r.next.x?r:r.next}}r=r.next}while(r!==e);if(!s)return null;if(i===o)return s;var l=s,u=s.x,c=s.y,d=1/0,f;r=s;do i>=r.x&&r.x>=u&&i!==r.x&&Pr(n<c?i:o,n,u,c,n<c?o:i,n,r.x,r.y)&&(f=Math.abs(n-r.y)/(i-r.x),si(r,t)&&(f<d||f===d&&(r.x>s.x||r.x===s.x&&Rp(s,r)))&&(s=r,d=f)),r=r.next;while(r!==l);return s}function Rp(t,e){return ue(t.prev,t,e.prev)<0&&ue(e.next,t,t.next)<0}function Sp(t,e,r,i){var n=t;do n.z===null&&(n.z=ms(n.x,n.y,e,r,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,Pp(n)}function Pp(t){var e,r,i,n,o,s,a,l,u=1;do{for(r=t,t=null,o=null,s=0;r;){for(s++,i=r,a=0,e=0;e<u&&(a++,i=i.nextZ,!!i);e++);for(l=u;a>0||l>0&&i;)a!==0&&(l===0||!i||r.z<=i.z)?(n=r,r=r.nextZ,a--):(n=i,i=i.nextZ,l--),o?o.nextZ=n:t=n,n.prevZ=o,o=n;r=i}o.nextZ=null,u*=2}while(s>1);return t}function ms(t,e,r,i,n){return t=32767*(t-r)*n,e=32767*(e-i)*n,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t|e<<1}function Lp(t){var e=t,r=t;do(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;while(e!==t);return r}function Pr(t,e,r,i,n,o,s,a){return(n-s)*(e-a)-(t-s)*(o-a)>=0&&(t-s)*(i-a)-(r-s)*(e-a)>=0&&(r-s)*(o-a)-(n-s)*(i-a)>=0}function Cp(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!kp(t,e)&&(si(t,e)&&si(e,t)&&zp(t,e)&&(ue(t.prev,t,e.prev)||ue(t,e.prev,e))||En(t,e)&&ue(t.prev,t,t.next)>0&&ue(e.prev,e,e.next)>0)}function ue(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function En(t,e){return t.x===e.x&&t.y===e.y}function kc(t,e,r,i){var n=vn(ue(t,e,r)),o=vn(ue(t,e,i)),s=vn(ue(r,i,t)),a=vn(ue(r,i,e));return!!(n!==o&&s!==a||n===0&&Tn(t,r,e)||o===0&&Tn(t,i,e)||s===0&&Tn(r,t,i)||a===0&&Tn(r,e,i))}function Tn(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function vn(t){return t>0?1:t<0?-1:0}function kp(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&kc(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}function si(t,e){return ue(t.prev,t,t.next)<0?ue(t,e,t.next)>=0&&ue(t,t.prev,e)>=0:ue(t,e,t.prev)<0||ue(t,t.next,e)<0}function zp(t,e){var r=t,i=!1,n=(t.x+e.x)/2,o=(t.y+e.y)/2;do r.y>o!=r.next.y>o&&r.next.y!==r.y&&n<(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x&&(i=!i),r=r.next;while(r!==t);return i}function zc(t,e){var r=new ps(t.i,t.x,t.y),i=new ps(e.i,e.x,e.y),n=t.next,o=e.prev;return t.next=e,e.prev=t,r.next=n,n.prev=r,i.next=r,r.prev=i,o.next=i,i.prev=o,i}function Lc(t,e,r,i){var n=new ps(t,e,r);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function ai(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function ps(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}wn.deviation=function(t,e,r,i){var n=e&&e.length,o=n?e[0]*r:t.length,s=Math.abs(gs(t,0,o,r));if(n)for(var a=0,l=e.length;a<l;a++){var u=e[a]*r,c=a<l-1?e[a+1]*r:t.length;s-=Math.abs(gs(t,u,c,r))}var d=0;for(a=0;a<i.length;a+=3){var f=i[a]*r,h=i[a+1]*r,m=i[a+2]*r;d+=Math.abs((t[f]-t[m])*(t[h+1]-t[f+1])-(t[f]-t[h])*(t[m+1]-t[f+1]))}return s===0&&d===0?0:Math.abs((d-s)/s)};function gs(t,e,r,i){for(var n=0,o=e,s=r-i;o<r;o+=i)n+=(t[s]-t[o])*(t[o+1]+t[s+1]),s=o;return n}wn.flatten=function(t){for(var e=t[0][0].length,r={vertices:[],holes:[],dimensions:e},i=0,n=0;n<t.length;n++){for(var o=0;o<t[n].length;o++)for(var s=0;s<e;s++)r.vertices.push(t[n][o][s]);n>0&&(i+=t[n-1].length,r.holes.push(i))}return r}});var td=je((Qw,Ss)=>{(function(){function t(h,m){document.addEventListener?h.addEventListener("scroll",m,!1):h.attachEvent("scroll",m)}function e(h){document.body?h():document.addEventListener?document.addEventListener("DOMContentLoaded",function m(){document.removeEventListener("DOMContentLoaded",m),h()}):document.attachEvent("onreadystatechange",function m(){(document.readyState=="interactive"||document.readyState=="complete")&&(document.detachEvent("onreadystatechange",m),h())})}function r(h){this.a=document.createElement("div"),this.a.setAttribute("aria-hidden","true"),this.a.appendChild(document.createTextNode(h)),this.b=document.createElement("span"),this.c=document.createElement("span"),this.h=document.createElement("span"),this.f=document.createElement("span"),this.g=-1,this.b.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.c.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.f.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;",this.h.style.cssText="display:inline-block;width:200%;height:200%;font-size:16px;max-width:none;",this.b.appendChild(this.h),this.c.appendChild(this.f),this.a.appendChild(this.b),this.a.appendChild(this.c)}function i(h,m){h.a.style.cssText="max-width:none;min-width:20px;min-height:20px;display:inline-block;overflow:hidden;position:absolute;width:auto;margin:0;padding:0;top:-999px;left:-999px;white-space:nowrap;font:"+m+";"}function n(h){var m=h.a.offsetWidth,g=m+100;return h.f.style.width=g+"px",h.c.scrollLeft=g,h.b.scrollLeft=h.b.scrollWidth+100,h.g!==m?(h.g=m,!0):!1}function o(h,m){function g(){var _=p;n(_)&&_.a.parentNode&&m(_.g)}var p=h;t(h.b,g),t(h.c,g),n(h)}function s(h,m){var g=m||{};this.family=h,this.style=g.style||"normal",this.weight=g.weight||"normal",this.stretch=g.stretch||"normal"}var a=null,l=null,u=null,c=null;function d(){if(u===null){var h=document.createElement("div");try{h.style.font="condensed 100px sans-serif"}catch{}u=h.style.font!==""}return u}function f(h,m){return[h.style,h.weight,d()?h.stretch:"","100px",m].join(" ")}s.prototype.load=function(h,m){var g=this,p=h||"BESbswy",_=0,b=m||3e3,x=new Date().getTime();return new Promise(function(T,y){var v;if(c===null&&(c=!!document.fonts),(v=c)&&(l===null&&(l=/OS X.*Version\\/10\\..*Safari/.test(navigator.userAgent)&&/Apple/.test(navigator.vendor)),v=!l),v){v=new Promise(function(M,I){function C(){new Date().getTime()-x>=b?I():document.fonts.load(f(g,'"'+g.family+'"'),p).then(function(z){1<=z.length?M():setTimeout(C,25)},function(){I()})}C()});var P=new Promise(function(M,I){_=setTimeout(I,b)});Promise.race([P,v]).then(function(){clearTimeout(_),T(g)},function(){y(g)})}else e(function(){function M(){var K;(K=k!=-1&&L!=-1||k!=-1&&B!=-1||L!=-1&&B!=-1)&&((K=k!=L&&k!=B&&L!=B)||(a===null&&(K=/AppleWebKit\\/([0-9]+)(?:\\.([0-9]+))/.exec(window.navigator.userAgent),a=!!K&&(536>parseInt(K[1],10)||parseInt(K[1],10)===536&&11>=parseInt(K[2],10))),K=a&&(k==te&&L==te&&B==te||k==q&&L==q&&B==q||k==$&&L==$&&B==$)),K=!K),K&&(Q.parentNode&&Q.parentNode.removeChild(Q),clearTimeout(_),T(g))}function I(){if(new Date().getTime()-x>=b)Q.parentNode&&Q.parentNode.removeChild(Q),y(g);else{var K=document.hidden;(K===!0||K===void 0)&&(k=C.a.offsetWidth,L=z.a.offsetWidth,B=S.a.offsetWidth,M()),_=setTimeout(I,50)}}var C=new r(p),z=new r(p),S=new r(p),k=-1,L=-1,B=-1,te=-1,q=-1,$=-1,Q=document.createElement("div");Q.dir="ltr",i(C,f(g,"sans-serif")),i(z,f(g,"serif")),i(S,f(g,"monospace")),Q.appendChild(C.a),Q.appendChild(z.a),Q.appendChild(S.a),document.body.appendChild(Q),te=C.a.offsetWidth,q=z.a.offsetWidth,$=S.a.offsetWidth,I(),o(C,function(K){k=K,M()}),i(C,f(g,'"'+g.family+'",sans-serif')),o(z,function(K){L=K,M()}),i(z,f(g,'"'+g.family+'",serif')),o(S,function(K){B=K,M()}),i(S,f(g,'"'+g.family+'",monospace'))})})},typeof Ss<"u"?Ss.exports=s:(window.FontFaceObserver=s,window.FontFaceObserver.prototype.load=s.prototype.load)})()});var Ks="0.0.1";var Xn="v"+Ks;var qd=typeof window<"u"&&typeof Window<"u"&&typeof HTMLDocument<"u"&&window instanceof Window&&window.document instanceof HTMLDocument,Qs=typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope,Hd={is_worker:Qs,is_main:qd};if(Qs){let t={document:{}};Reflect.set(globalThis,"window",t),Reflect.set(globalThis,"document",t.document)}var Ae=Hd;var fe={},Z=fe,kt=0,We={};fe.targets={};fe.addTarget=function(t,e){fe.targets[t]=e};fe.removeTarget=function(t){t&&delete fe.targets[t]};function ea(t){var e=[];typeof t=="string"&&(e=t.split("."),t=e.pop());var r=fe.targets;for(let i=0;i<e.length;i++)if(r[e[i]])r=r[e[i]];else return[];return[t,r]}function Xd(){fe.postMessage=function(t,e,...r){if(Array.isArray(t))return Promise.all(t.map(a=>fe.postMessage(a,e,...r)));let i={};typeof e=="object"&&(i=e,e=e.method);var n=new Promise((a,l)=>{We[kt]={method:e,message:r,resolve:a,reject:l}});let o,s=[];return r&&r.length===1&&r[0]instanceof fe.withTransferables&&(s=r[0].transferables,r=r[0].value),o={type:"main_send",message_id:kt,method:e,message:r},i.stringify&&(o=JSON.stringify(o)),t.postMessage(o,s.map(a=>a.object)),Jt(s),s.length>0&&A("trace",\`'\${e}' transferred \${s.length} objects to worker thread\`),kt++,n},fe.addWorker=function(t){if(!(t instanceof Worker))throw Error("Worker broker could not add non-Worker object",t);t.addEventListener("message",function(r){let i=typeof r.data=="string"?JSON.parse(r.data):r.data,n=i.message_id;if(i.type==="worker_reply")We[n]&&(i.error?We[n].reject(i.error):We[n].resolve(i.message),delete We[n]);else if(i.type==="worker_send"&&n!=null){let o,s,a,l,u;try{if([l,a]=ea(i.method),!a)throw Error(\`Worker broker could not dispatch message type \${i.method} on target \${i.target} because no object with that name is registered on main thread\`);if(u=typeof a[l]=="function"&&a[l],!u)throw Error(\`Worker broker could not dispatch message type \${i.method} on target \${i.target} because object has no method with that name\`);o=u.apply(a,i.message)}catch(f){s=f}let c,d=[];o instanceof Promise?o.then(f=>{f instanceof fe.withTransferables&&(d=f.transferables,f=f.value[0]),c={type:"main_reply",message_id:n,message:f},t.postMessage(c,d.map(h=>h.object)),Jt(d),d.length>0&&A("trace",\`'\${l}' transferred \${d.length} objects to worker thread\`)},f=>{t.postMessage({type:"main_reply",message_id:n,error:f instanceof Error?\`\${f.message}: \${f.stack}\`:f})}):(o instanceof fe.withTransferables&&(d=o.transferables,o=o.value[0]),c={type:"main_reply",message_id:n,message:o,error:s instanceof Error?\`\${s.message}: \${s.stack}\`:s},t.postMessage(c,d.map(f=>f.object)),Jt(d),d.length>0&&A("trace",\`'\${l}' transferred \${d.length} objects to worker thread\`))}})},fe.getMessages=function(){return We},fe.getMessageId=function(){return kt}}function Yd(){fe.postMessage=function(t,...e){let r={};typeof t=="object"&&(r=t,t=t.method);var i=new Promise((s,a)=>{We[kt]={method:t,message:e,resolve:s,reject:a}});let n,o=[];return e&&e.length===1&&e[0]instanceof fe.withTransferables&&(o=e[0].transferables,e=e[0].value),n={type:"worker_send",message_id:kt,method:t,message:e},r.stringify&&(n=JSON.stringify(n)),self.postMessage(n,o.map(s=>s.object)),Jt(o),o.length>0&&A("trace",\`'\${t}' transferred \${o.length} objects to main thread\`),kt++,i},self.addEventListener("message",function(e){let r=typeof e.data=="string"?JSON.parse(e.data):e.data,i=r.message_id;if(r.type==="main_reply")We[i]&&(r.error?We[i].reject(r.error):We[i].resolve(r.message),delete We[i]);else if(r.type==="main_send"&&i!=null){let n,o,s,a,l;try{if([a,s]=ea(r.method),!s)throw Error(\`Worker broker could not dispatch message type \${r.method} on target \${r.target} because no object with that name is registered on main thread\`);if(l=typeof s[a]=="function"&&s[a],!l)throw Error(\`Worker broker could not dispatch message type \${r.method} because worker has no method with that name\`);n=l.apply(s,r.message)}catch(d){o=d}let u,c=[];n instanceof Promise?n.then(d=>{d instanceof fe.withTransferables&&(c=d.transferables,d=d.value[0]),u={type:"worker_reply",message_id:i,message:d},self.postMessage(u,c.map(f=>f.object)),Jt(c),c.length>0&&A("trace",\`'\${a}' transferred \${c.length} objects to main thread\`)},d=>{self.postMessage({type:"worker_reply",message_id:i,error:d instanceof Error?\`\${d.message}: \${d.stack}\`:d})}):(n instanceof fe.withTransferables&&(c=n.transferables,n=n.value[0]),u={type:"worker_reply",message_id:i,message:n,error:o instanceof Error?\`\${o.message}: \${o.stack}\`:o},self.postMessage(u,c.map(d=>d.object)),Jt(c),c.length>0&&A("trace",\`'\${a}' transferred \${c.length} objects to main thread\`))}})}fe.withTransferables=function(...t){if(!(this instanceof fe.withTransferables))return new fe.withTransferables(...t);this.value=t,this.transferables=Yn(this.value)};function Yn(t,e=null,r=null,i=[]){if(!t)return i;if(Array.isArray(t))t.forEach((n,o)=>Yn(n,t,o,i));else if(typeof t=="object")if(t instanceof ArrayBuffer)i.push({object:t,parent:e,property:r});else if(t.buffer instanceof ArrayBuffer)i.push({object:t.buffer,parent:e,property:r});else for(let n in t)Yn(t[n],t,n,i);return i}function Jt(t){Array.isArray(t)&&t.filter(e=>e.parent&&e.property).forEach(e=>delete e.parent[e.property])}Ae.is_main&&Xd();Ae.is_worker&&Yd();var ra=Z,ta={silent:-1,error:0,warn:1,info:2,debug:3,trace:4},Zn={},Jn={};function Zd(t){if(!Zn[t]){let e=console;Zn[t]=(e[t]||console.log).bind(console)}return Zn[t]}var ze=(async(t,...e)=>{let r=typeof t=="object"?t.level:t;if(ta[r]>ta[ze.level])return!1;if(Ae.is_worker)return ra.postMessage({method:"_logProxy",stringify:!0},t,...e);if(typeof t=="object"&&t.once===!0){let n=JSON.stringify(e);if(Jn[n])return!1;Jn[n]=!0}let i=Zd(r);return e.length>1?i(\`Tangram \${Xn} [\${r}]: \${e[0]}\`,...e.slice(1)):i(\`Tangram \${Xn} [\${r}]: \${e[0]}\`),!0});ze.level="info";ze.workers=null;ze.setLevel=t=>{ze.level=t,Ae.is_main&&Array.isArray(ze.workers)&&ra.postMessage(ze.workers,"_logSetLevelProxy",t)};Ae.is_worker||(ze.setWorkers=t=>{ze.workers=t},ze.reset=()=>{Jn={}});Z.addTarget("_logProxy",ze);Z.addTarget("_logSetLevelProxy",ze.setLevel);var A=ze;var se={},J=se;Z.addTarget("Utils",se);se.isSafari=function(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)};se.isMicrosoft=function(){return/(Trident\\/7.0|Edge[ /](\\d+[.\\d]+))/i.test(navigator.userAgent)};se._requests={};se._proxy_requests={};se.io=function(t,e=6e4,r="text",i="GET",n={},o=null,s=!1){if(Ae.is_worker&&se.isMicrosoft())return A("debug","Proxying request for URL to worker",t),o&&(se._proxy_requests[o]=!0),Z.postMessage("Utils.io",t,e,r,i,n,o,!0);{let a=new XMLHttpRequest,l=new Promise((u,c)=>{if(a.open(i,t,!0),a.timeout=e,a.responseType=r,n&&typeof n=="object")for(let d in n)a.setRequestHeader(d,n[d]);a.onload=()=>{a.status===200?["text","json"].indexOf(a.responseType)>-1?u({body:a.responseText,status:a.status}):u({body:a.response,status:a.status}):a.status===204?u({body:null,status:a.status}):c(Error("Request error with a status of "+a.statusText))},a.onerror=d=>{c(Error("There was a network error"+d.toString()))},a.ontimeout=d=>{c(Error("timeout "+d.toString()))},a.send()});return l=l.then(u=>(o&&delete se._requests[o],s?Z.withTransferables(u):u)),o&&(se._requests[o]=a),l}};se.cancelRequest=function(t){if(Ae.is_worker&&se._proxy_requests[t])return Z.postMessage("Utils.cancelRequest",t);se._requests[t]?(A("trace",\`Cancelling network request key '\${t}'\`),se._requests[t].abort(),delete se._requests[t]):A("trace",\`Could not find network request key '\${t}'\`)};se.serializeWithFunctions=function(t){return typeof t=="function"?t.toString():JSON.stringify(t,function(r,i){return typeof i=="function"?i.toString():i})};se.use_high_density_display=!0;se.updateDevicePixelRatio=function(){let t=se.device_pixel_ratio;return se.device_pixel_ratio=se.use_high_density_display&&window.devicePixelRatio||1,se.device_pixel_ratio!==t};Ae.is_main&&se.updateDevicePixelRatio();se.isPowerOf2=function(t){return(t&t-1)===0};se.interpolate=function(t,e,r){if(!Array.isArray(e)||!Array.isArray(e[0]))return e;if(e.length<1)return e;let i,n,o,s,a,l,u=e;if(t<=u[0][0])s=u[0][1],typeof r=="function"&&(s=r(s));else if(t>=u[u.length-1][0])s=u[u.length-1][1],typeof r=="function"&&(s=r(s));else for(let c=0;c<u.length-1;c++)if(t>=u[c][0]&&t<u[c+1][0]){i=u[c][0],n=u[c+1][0];let d=u[c][1],f=u[c+1][1];if(Array.isArray(d)&&Array.isArray(f)){s=[];for(let h=0;h<d.length;h++)typeof r=="function"?(a=r(d[h]),l=r(f[h]),o=l-a,s[h]=o*(t-i)/(n-i)+a):(o=f[h]-d[h],s[h]=o*(t-i)/(n-i)+d[h])}else typeof r=="function"?(a=r(d),l=r(f),o=l-a,s=o*(t-i)/(n-i)+a):(o=f-d,s=o*(t-i)/(n-i)+d);break}return s};se.toCSSColor=function(t){if(t!=null)return t[3]===1?\`rgb(\${t.slice(0,3).map(e=>Math.round(e*255)).join(", ")})\`:\`rgba(\${t.map((e,r)=>r<3&&Math.round(e*255)||e).join(", ")})\`};function De(t){let e=0;for(let r=0;r<t.length;r++)e=(e<<5)-e+t.charCodeAt(r),e|=0;return e}var Ze={functions:{},num_functions:0,num_cached:0};function ia(){Ze.functions={},Ze.num_functions=0,Ze.num_cached=0}function tt(t,e){if(typeof t=="string")return gi(t,e);if(t!=null&&typeof t=="object"){let r=t;for(let i in r)r[i]=tt(r[i],e)}return t}function gi(t,e){let r=typeof t=="string"&&t.match(/^\\s*function[^(]*\\(([^)]*)\\)\\s*?\\{([\\s\\S]*)\\}$/m);if(r&&r.length>2)try{let i=r[2],n=e?e(i):i,o=De(n);if(Ze.functions[o]===void 0){let s=r[1].split(",").map(u=>u.trim()).filter(Boolean),a=s.length>0?s:["context"],l=new Function(a.toString(),n);l.source=i,Ze.functions[o]=l,Ze.num_functions++}else Ze.num_cached++;return Ze.functions[o]}catch{return t}return t}var na={draw_label_collision_boxes:!1,draw_label_texture_boxes:!1,suppress_label_fade_in:!1,suppress_label_snap_animation:!1,show_hidden_labels:!1,layer_stats:!1,wireframe:!1},Ne=na;function oa(t){Object.assign(na,t)}function sa(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Ce(t,...e){let r=t;for(let i of e)if(i)for(let n in i){let s=i[n];if(sa(s)){let a=r[n];r[n]=sa(a)?Ce(a,s):Ce({},s)}else s!==void 0&&(r[n]=s)}return t}function aa(t,e,r){let i=e[0],n=e[1],o=e[2],s=e[3];return t[0]=r[0]*i+r[4]*n+r[8]*o+r[12]*s,t[1]=r[1]*i+r[5]*n+r[9]*o+r[13]*s,t[2]=r[2]*i+r[6]*n+r[10]*o+r[14]*s,t[3]=r[3]*i+r[7]*n+r[11]*o+r[15]*s,t}function Jd(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function la(t,e){if(t===e){let r=e[1],i=e[2],n=e[3],o=e[6],s=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=i,t[9]=o,t[11]=e[14],t[12]=n,t[13]=s,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function ua(t,e){let r=e[0],i=e[1],n=e[2],o=e[3],s=e[4],a=e[5],l=e[6],u=e[7],c=e[8],d=e[9],f=e[10],h=e[11],m=e[12],g=e[13],p=e[14],_=e[15],b=r*a-i*s,x=r*l-n*s,T=r*u-o*s,y=i*l-n*a,v=i*u-o*a,P=n*u-o*l,M=c*g-d*m,I=c*p-f*m,C=c*_-h*m,z=d*p-f*g,S=d*_-h*g,k=f*_-h*p,L=b*k-x*S+T*z+y*C-v*I+P*M;return L?(L=1/L,t[0]=(a*k-l*S+u*z)*L,t[1]=(n*S-i*k-o*z)*L,t[2]=(g*P-p*v+_*y)*L,t[3]=(f*v-d*P-h*y)*L,t[4]=(l*C-s*k-u*I)*L,t[5]=(r*k-n*C+o*I)*L,t[6]=(p*T-m*P-_*x)*L,t[7]=(c*P-f*T+h*x)*L,t[8]=(s*S-a*C+u*M)*L,t[9]=(i*C-r*S-o*M)*L,t[10]=(m*v-g*T+_*b)*L,t[11]=(d*T-c*v-h*b)*L,t[12]=(a*I-s*z-l*M)*L,t[13]=(r*z-i*I+n*M)*L,t[14]=(g*x-m*y-p*b)*L,t[15]=(c*y-d*x+f*b)*L,t):null}function ca(t){let e=t[0],r=t[1],i=t[2],n=t[3],o=t[4],s=t[5],a=t[6],l=t[7],u=t[8],c=t[9],d=t[10],f=t[11],h=t[12],m=t[13],g=t[14],p=t[15],_=e*s-r*o,b=e*a-i*o,x=r*a-i*s,T=u*m-c*h,y=u*g-d*h,v=c*g-d*m,P=e*v-r*y+i*T,M=o*v-s*y+a*T,I=u*x-c*b+d*_,C=h*x-m*b+g*_;return l*P-n*M+p*I-f*C}function Qn(t,e,r){let i=e[0],n=e[1],o=e[2],s=e[3],a=e[4],l=e[5],u=e[6],c=e[7],d=e[8],f=e[9],h=e[10],m=e[11],g=e[12],p=e[13],_=e[14],b=e[15],x=r[0],T=r[1],y=r[2],v=r[3];return t[0]=x*i+T*a+y*d+v*g,t[1]=x*n+T*l+y*f+v*p,t[2]=x*o+T*u+y*h+v*_,t[3]=x*s+T*c+y*m+v*b,x=r[4],T=r[5],y=r[6],v=r[7],t[4]=x*i+T*a+y*d+v*g,t[5]=x*n+T*l+y*f+v*p,t[6]=x*o+T*u+y*h+v*_,t[7]=x*s+T*c+y*m+v*b,x=r[8],T=r[9],y=r[10],v=r[11],t[8]=x*i+T*a+y*d+v*g,t[9]=x*n+T*l+y*f+v*p,t[10]=x*o+T*u+y*h+v*_,t[11]=x*s+T*c+y*m+v*b,x=r[12],T=r[13],y=r[14],v=r[15],t[12]=x*i+T*a+y*d+v*g,t[13]=x*n+T*l+y*f+v*p,t[14]=x*o+T*u+y*h+v*_,t[15]=x*s+T*c+y*m+v*b,t}function da(t,e,r){let i=r[0],n=r[1],o=r[2],s,a,l,u,c,d,f,h,m,g,p,_;return e===t?(t[12]=e[0]*i+e[4]*n+e[8]*o+e[12],t[13]=e[1]*i+e[5]*n+e[9]*o+e[13],t[14]=e[2]*i+e[6]*n+e[10]*o+e[14],t[15]=e[3]*i+e[7]*n+e[11]*o+e[15]):(s=e[0],a=e[1],l=e[2],u=e[3],c=e[4],d=e[5],f=e[6],h=e[7],m=e[8],g=e[9],p=e[10],_=e[11],t[0]=s,t[1]=a,t[2]=l,t[3]=u,t[4]=c,t[5]=d,t[6]=f,t[7]=h,t[8]=m,t[9]=g,t[10]=p,t[11]=_,t[12]=s*i+c*n+m*o+e[12],t[13]=a*i+d*n+g*o+e[13],t[14]=l*i+f*n+p*o+e[14],t[15]=u*i+h*n+_*o+e[15]),t}function fa(t,e,r){let i=r[0],n=r[1],o=r[2];return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t[4]=e[4]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function ha(t,e,r,i){let n=i[0],o=i[1],s=i[2],a=Math.sqrt(n*n+o*o+s*s),l,u,c,d,f,h,m,g,p,_,b,x,T,y,v,P,M,I,C,z,S,k,L,B;return a<1e-6?null:(a=1/a,n*=a,o*=a,s*=a,u=Math.sin(r),l=Math.cos(r),c=1-l,d=e[0],f=e[1],h=e[2],m=e[3],g=e[4],p=e[5],_=e[6],b=e[7],x=e[8],T=e[9],y=e[10],v=e[11],P=n*n*c+l,M=o*n*c+s*u,I=s*n*c-o*u,C=n*o*c-s*u,z=o*o*c+l,S=s*o*c+n*u,k=n*s*c+o*u,L=o*s*c-n*u,B=s*s*c+l,t[0]=d*P+g*M+x*I,t[1]=f*P+p*M+T*I,t[2]=h*P+_*M+y*I,t[3]=m*P+b*M+v*I,t[4]=d*C+g*z+x*S,t[5]=f*C+p*z+T*S,t[6]=h*C+_*z+y*S,t[7]=m*C+b*z+v*S,t[8]=d*k+g*L+x*B,t[9]=f*k+p*L+T*B,t[10]=h*k+_*L+y*B,t[11]=m*k+b*L+v*B,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function ma(t,e,r){let i=Math.sin(r),n=Math.cos(r),o=e[4],s=e[5],a=e[6],l=e[7],u=e[8],c=e[9],d=e[10],f=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*n+u*i,t[5]=s*n+c*i,t[6]=a*n+d*i,t[7]=l*n+f*i,t[8]=u*n-o*i,t[9]=c*n-s*i,t[10]=d*n-a*i,t[11]=f*n-l*i,t}function pa(t,e,r){let i=Math.sin(r),n=Math.cos(r),o=e[0],s=e[1],a=e[2],l=e[3],u=e[8],c=e[9],d=e[10],f=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*n-u*i,t[1]=s*n-c*i,t[2]=a*n-d*i,t[3]=l*n-f*i,t[8]=o*i+u*n,t[9]=s*i+c*n,t[10]=a*i+d*n,t[11]=l*i+f*n,t}function ga(t,e,r){let i=Math.sin(r),n=Math.cos(r),o=e[0],s=e[1],a=e[2],l=e[3],u=e[4],c=e[5],d=e[6],f=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*n+u*i,t[1]=s*n+c*i,t[2]=a*n+d*i,t[3]=l*n+f*i,t[4]=u*n-o*i,t[5]=c*n-s*i,t[6]=d*n-a*i,t[7]=f*n-l*i,t}function _a(t,e){let r=e[0],i=e[1],n=e[2],o=e[3],s=r+r,a=i+i,l=n+n,u=r*s,c=i*s,d=i*a,f=n*s,h=n*a,m=n*l,g=o*s,p=o*a,_=o*l;return t[0]=1-d-m,t[1]=c+_,t[2]=f-p,t[3]=0,t[4]=c-_,t[5]=1-u-m,t[6]=h+g,t[7]=0,t[8]=f+p,t[9]=h-g,t[10]=1-u-d,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function ba(t,e,r,i,n,o,s){let a=1/(r-e),l=1/(n-i),u=1/(o-s);return t[0]=o*2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o*2*l,t[6]=0,t[7]=0,t[8]=(r+e)*a,t[9]=(n+i)*l,t[10]=(s+o)*u,t[11]=-1,t[12]=0,t[13]=0,t[14]=s*o*2*u,t[15]=0,t}function Kd(t,e,r,i,n){let o=1/Math.tan(e/2);if(t[0]=o/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,n!=null&&n!==1/0){let s=1/(i-n);t[10]=(n+i)*s,t[14]=2*n*i*s}else t[10]=-1,t[14]=-2*i;return t}var ya=Kd;function Qd(t,e,r,i,n,o,s){let a=1/(e-r),l=1/(i-n),u=1/(o-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*u,t[11]=0,t[12]=(e+r)*a,t[13]=(n+i)*l,t[14]=(s+o)*u,t[15]=1,t}var xa=Qd;function Ta(t,e,r,i){let n,o,s,a,l,u,c,d,f,h,m=e[0],g=e[1],p=e[2],_=i[0],b=i[1],x=i[2],T=r[0],y=r[1],v=r[2];return Math.abs(m-T)<1e-6&&Math.abs(g-y)<1e-6&&Math.abs(p-v)<1e-6?Jd(t):(d=m-T,f=g-y,h=p-v,n=1/Math.sqrt(d*d+f*f+h*h),d*=n,f*=n,h*=n,o=b*h-x*f,s=x*d-_*h,a=_*f-b*d,n=Math.sqrt(o*o+s*s+a*a),n?(n=1/n,o*=n,s*=n,a*=n):(o=0,s=0,a=0),l=f*a-h*s,u=h*o-d*a,c=d*s-f*o,n=Math.sqrt(l*l+u*u+c*c),n?(n=1/n,l*=n,u*=n,c*=n):(l=0,u=0,c=0),t[0]=o,t[1]=l,t[2]=d,t[3]=0,t[4]=s,t[5]=u,t[6]=f,t[7]=0,t[8]=a,t[9]=c,t[10]=h,t[11]=0,t[12]=-(o*m+s*g+a*p),t[13]=-(l*m+u*g+c*p),t[14]=-(d*m+f*g+h*p),t[15]=1,t)}function va(t,e,r){let i=e[0],n=e[1];return t[0]=r[0]*i+r[2]*n,t[1]=r[1]*i+r[3]*n,t}function wa(t,e,r){let i=e[0],n=e[1];return t[0]=r[0]*i+r[2]*n+r[4],t[1]=r[1]*i+r[3]*n+r[5],t}function Ea(t,e,r){let i=e[0],n=e[1];return t[0]=r[0]*i+r[3]*n+r[6],t[1]=r[1]*i+r[4]*n+r[7],t}function _i(t,e,r){let i=e[0],n=e[1];return t[0]=r[0]*i+r[4]*n+r[12],t[1]=r[1]*i+r[5]*n+r[13],t}function ef(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Ma(t,e,r){let i=e[0],n=e[1],o=e[2],s=r[0],a=r[1],l=r[2];return t[0]=n*l-o*a,t[1]=o*s-i*l,t[2]=i*a-n*s,t}function bi(t,e,r){let i=e[0],n=e[1],o=e[2],s=r[3]*i+r[7]*n+r[11]*o+r[15];return s=s||1,t[0]=(r[0]*i+r[4]*n+r[8]*o+r[12])/s,t[1]=(r[1]*i+r[5]*n+r[9]*o+r[13])/s,t[2]=(r[2]*i+r[6]*n+r[10]*o+r[14])/s,t}function Aa(t,e,r){let i=e[0],n=e[1],o=e[2];return t[0]=i*r[0]+n*r[3]+o*r[6],t[1]=i*r[1]+n*r[4]+o*r[7],t[2]=i*r[2]+n*r[5]+o*r[8],t}function Ra(t,e,r){let i=r[0],n=r[1],o=r[2],s=r[3],a=e[0],l=e[1],u=e[2],c=n*u-o*l,d=o*a-i*u,f=i*l-n*a,h=n*f-o*d,m=o*c-i*f,g=i*d-n*c,p=s*2;return c*=p,d*=p,f*=p,h*=2,m*=2,g*=2,t[0]=a+c+h,t[1]=l+d+m,t[2]=u+f+g,t}function Sa(t,e,r,i){let n=[],o=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],o[0]=n[0],o[1]=n[1]*Math.cos(i)-n[2]*Math.sin(i),o[2]=n[1]*Math.sin(i)+n[2]*Math.cos(i),t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function Pa(t,e,r,i){let n=[],o=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],o[0]=n[2]*Math.sin(i)+n[0]*Math.cos(i),o[1]=n[1],o[2]=n[2]*Math.cos(i)-n[0]*Math.sin(i),t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function La(t,e,r,i){let n=[],o=[];return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],o[0]=n[0]*Math.cos(i)-n[1]*Math.sin(i),o[1]=n[0]*Math.sin(i)+n[1]*Math.cos(i),o[2]=n[2],t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function Ca(t,e){let r=t[0],i=t[1],n=t[2],o=e[0],s=e[1],a=e[2],l=Math.sqrt((r*r+i*i+n*n)*(o*o+s*s+a*a)),u=l&&ef(t,e)/l;return Math.acos(Math.min(Math.max(u,-1),1))}function yi(t,e){if(!t)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}var $e=Math.PI,Fa=$e/4,ka=$e/180,za=180/$e,xi=512;function Kt(t){let[e,r]=t;yi(Number.isFinite(e)),yi(Number.isFinite(r)&&r>=-90&&r<=90,"invalid latitude");let i=e*ka,n=r*ka,o=xi*(i+$e)/(2*$e),s=xi*($e+Math.log(Math.tan(Fa+n*.5)))/(2*$e);return[o,s]}function pt(t){let[e,r]=t,i=e/xi*(2*$e)-$e,n=2*(Math.atan(Math.exp(r/xi*(2*$e)-$e))-Fa);return[i*za,n*za]}var D_=Math.PI/180;var Ti=Math.PI,Q_=Ti/180,gf=180/Ti,Da=6378137,Ba=Ti*Da,_f=Math.atan(Math.sinh(Ti))*gf,bf=512/(2*Ba);var vi=20037508342789244e-9;function Ia(t){let e=t[0]*(vi/180),r=Math.log(Math.tan(t[1]*Math.PI/360+Math.PI/4))/Math.PI*vi;return[e,r]}function Ga(t){let e=t[0]/vi*180,r=t[1]/vi,i=(2*Math.atan(Math.exp(r*Math.PI))-Math.PI/2)/Math.PI*180;return[e,i]}var wi=512,Gr=20037508342789244e-9,Ei=Gr*2;function Va(t){let e=t*1073741824,r=Math.round(e),i=Number.EPSILON*Math.max(1,Math.abs(e))*4;return Math.abs(e-r)<=i}function Ua(t){let[e,r]=Kt([t[0],t[1]]),i=e/wi,n=r/wi,o=Va(i)||Va(n)?Ia(t):void 0;return[o?.[0]??i*Ei-Gr,o?.[1]??n*Ei-Gr]}function ja(t){let e=(t[0]+Gr)/Ei*wi,r=(t[1]+Gr)/Ei*wi;return pt([e,r])}var Y=Object.freeze({mercatorRadius:6378137,earthRadius:6370972,globeRadius:256,tileSize:256,maxMercatorLatitude:85.0511287798066});function Wa(t,e,r){let[i,n,o]=t;if(e==="projected")throw new Error("CPU-projected basemaps require the experimental worker procedure");if(!t.every(Number.isFinite)||Math.abs(n)>90)throw new Error("Projection requires finite geographic coordinates and latitude within +/-90 degrees");if(e==="globe"){i*=Math.PI/180,n*=Math.PI/180;let s=Y.globeRadius*(1+o/Y.earthRadius);return[Math.sin(i)*Math.cos(n)*s,-Math.cos(i)*Math.cos(n)*s,Math.sin(n)*s]}return r!=null&&Number.isFinite(r)&&(i+=Math.round((r-i)/360)*360),n=Math.max(-Y.maxMercatorLatitude,Math.min(Y.maxMercatorLatitude,n)),[Y.mercatorRadius*i*Math.PI/180,Y.mercatorRadius*Math.log(Math.tan(Math.PI/4+n*Math.PI/360)),o]}function eo(t,e,r){if(r==="projected")throw new Error("CPU-projected basemaps do not support geographic lighting");let[i,n,o]=e;if(r==="web-mercator")return[i,n,o];let s=t[0]*Math.PI/180,a=t[1]*Math.PI/180;return[i*Math.cos(s)-n*Math.sin(s)*Math.sin(a)+o*Math.sin(s)*Math.cos(a),i*Math.sin(s)+n*Math.cos(s)*Math.sin(a)-o*Math.cos(s)*Math.cos(a),n*Math.cos(a)+o*Math.sin(a)]}function xf(t){let e=Math.hypot(...t);if(!t.every(Number.isFinite)||e===0)throw new Error("Globe position must be finite and non-zero");return[Math.atan2(t[0],-t[1])*180/Math.PI,Math.asin(Math.max(-1,Math.min(1,t[2]/e)))*180/Math.PI,(e/Y.globeRadius-1)*Y.earthRadius]}function $a(t){return 2*Math.PI*Y.mercatorRadius/Y.tileSize/Math.pow(2,t)}function to(t,e,r){if(r==="projected")throw new Error("CPU-projected basemaps require explicit LOD");if(r==="web-mercator")return{position:[t,e,0],derivativeX:[1,0,0],derivativeY:[0,1,0]};let i=t/Y.mercatorRadius,n=Math.atan(Math.sinh(e/Y.mercatorRadius)),o=Math.cos(n),s=Math.sin(n),a=Math.sin(i),l=Math.cos(i),u=Y.globeRadius,c=u/Y.mercatorRadius;return{position:[u*a*o,-u*l*o,u*s],derivativeX:[c*l*o,c*a*o,0],derivativeY:[-c*a*s*o,c*l*s*o,c*o**2]}}function Tf(t){if(!t.every(Number.isFinite))throw new Error("Mercator position must be finite");let[e,r]=Ga([t[0],t[1]]);return[e,r,t[2]]}var vf=Object.freeze({"web-mercator":Object.freeze({type:"web-mercator",positionUnits:"meters",latitudeLimit:Y.maxMercatorLatitude,longitudePolicy:"nearest-anchor-or-unwrapped",project:(t,e)=>Wa(t,"web-mercator",e),unproject:Tf,projectVector:(t,e)=>eo(t,e,"web-mercator")}),globe:Object.freeze({type:"globe",positionUnits:"globe-common-units",latitudeLimit:90,longitudePolicy:"periodic",project:t=>Wa(t,"globe"),unproject:xf,projectVector:(t,e)=>eo(t,e,"globe")})});function Qt(t){if(t!=="web-mercator"&&t!=="globe")throw new Error("Unsupported geographic projection; expected web-mercator or globe");return vf[t]}function Mi(t,e=!1){let r=t??0;if(typeof r!="number"||!Number.isFinite(r))throw new Error("Projected annotation height must be finite meters");if(r!==0&&!e)throw new Error("Projected symbols require ground anchors unless allowElevation is enabled");if(r<-32768/16||r>32767/16)throw new Error("Projected annotation height exceeds signed-short storage");return Math.trunc(r*16)}var V={},R=V;V.default_source_max_zoom=18;V.default_view_max_zoom=20;V.max_style_zoom=25;V.tile_size=Y.tileSize;V.half_circumference_meters=Math.PI*Y.mercatorRadius;V.circumference_meters=V.half_circumference_meters*2;V.min_zoom_meters_per_pixel=V.circumference_meters/V.tile_size;var ro=[];V.metersPerPixel=function(t){return ro[t]=ro[t]||$a(t),ro[t]};var io=[];V.metersPerTile=function(t){return io[t]=io[t]||V.circumference_meters/Math.pow(2,t),io[t]};V.tile_scale=4096;V.units_per_pixel=V.tile_scale/V.tile_size;V.height_scale=16;var no=[];V.unitsPerMeter=function(t){return no[t]=no[t]||V.tile_scale/(V.tile_size*V.metersPerPixel(t)),no[t]};V.metersForTile=function(t){return{x:t.x*V.circumference_meters/Math.pow(2,t.z)-V.half_circumference_meters,y:-(t.y*V.circumference_meters/Math.pow(2,t.z)-V.half_circumference_meters)}};V.tileForMeters=function([t,e],r){return{x:Math.floor((t+V.half_circumference_meters)/(V.circumference_meters/Math.pow(2,r))),y:Math.floor((-e+V.half_circumference_meters)/(V.circumference_meters/Math.pow(2,r))),z:r}};V.wrapTile=function({x:t,y:e,z:r},i={x:!0,y:!1}){var n=(1<<r)-1;return i.x&&(t=t&n),i.y&&(e=e&n),{x:t,y:e,z:r}};V.metersToLatLng=function(t){let e=ja([t[0],t[1]]);return t[0]=e[0],t[1]=e[1],t};V.latLngToMeters=function(t){let e=Ua([t[0],t[1]]);return t[0]=e[0],t[1]=e[1],t};V.tileSpaceToLatlng=function(t,e,r){let i=V.unitsPerMeter(e);return V.transformGeometry(t,n=>{n[0]=n[0]/i+r.x,n[1]=n[1]/i+r.y,V.metersToLatLng(n)}),t};V.copyGeometry=function(t){if(t==null)return;let e=t.coordinates,r={type:t.type,coordinates:void 0};return t.type==="Point"?r.coordinates=[e[0],e[1]]:t.type==="LineString"||t.type==="MultiPoint"?r.coordinates=e.map(i=>[i[0],i[1]]):t.type==="Polygon"||t.type==="MultiLineString"?r.coordinates=e.map(i=>i.map(n=>[n[0],n[1]])):t.type==="MultiPolygon"&&(r.coordinates=e.map(i=>i.map(n=>n.map(o=>[o[0],o[1]])))),r};V.transformGeometry=function(t,e){t!=null&&(t.type==="Point"?e(t.coordinates):t.type==="LineString"||t.type==="MultiPoint"?t.coordinates.forEach(e):t.type==="Polygon"||t.type==="MultiLineString"?t.coordinates.forEach(r=>r.forEach(e)):t.type==="MultiPolygon"&&t.coordinates.forEach(r=>{r.forEach(i=>i.forEach(e))}))};V.boxIntersect=function(t,e){return!(e.sw.x>t.ne.x||e.ne.x<t.sw.x||e.sw.y>t.ne.y||e.ne.y<t.sw.y)};V.findBoundingBox=function(t){for(var e=1/0,r=-1/0,i=1/0,n=-1/0,o=t[0].length,s=0;s<o;s++){var a=t[0][s];a[0]<e&&(e=a[0]),a[1]<i&&(i=a[1]),a[0]>r&&(r=a[0]),a[1]>n&&(n=a[1])}return[e,i,r,n]};V.geometryType=function(t){if(t==="Polygon"||t==="MultiPolygon")return"polygon";if(t==="LineString"||t==="MultiLineString")return"line";if(t==="Point"||t==="MultiPoint")return"point"};V.centroid=function(t,e=!0){if(!t||t.length===0)return;let r=0,i=0,n=0,o=t[0],s=o.length,a;if(e){let u=o[0];a=u,o=o.map(c=>[c[0]-u[0],c[1]-u[1]])}for(let u=0,c=s-1;u<s;c=u,u++){let d=o[u],f=o[c],h=d[1]*f[0]-f[1]*d[0];r+=(d[0]+f[0])*h,i+=(d[1]+f[1])*h,n+=h*3}if(!n)return;let l=[r/n,i/n];return e&&(l[0]+=a[0],l[1]+=a[1]),l};V.multiCentroid=function(t){let e=0,r=null;for(let i=0;i<t.length;i++){let n=V.centroid(t[i]);n&&(r=r||[0,0],r[0]+=n[0],r[1]+=n[1],e++)}return e>0&&(r[0]/=e,r[1]/=e),r};V.signedPolygonRingAreaSum=function(t){let e=0,r=t.length;for(let i=0;i<r-1;i++){let n=t[i],o=t[i+1];e+=n[0]*o[1]-o[0]*n[1]}return e+=t[r-1][0]*t[0][1]-t[0][0]*t[r-1][1],e};V.polygonRingArea=function(t){return Math.abs(V.signedPolygonRingAreaSum(t))/2};V.polygonArea=function(t){if(t)return V.polygonRingArea(t[0])};V.multiPolygonArea=function(t){let e=0;for(let r=0;r<t.length;r++)e+=V.polygonArea(t[r])||0;return e};V.ringWinding=function(t){let e=V.signedPolygonRingAreaSum(t);if(e>0)return"CW";if(e<0)return"CCW"};var it={coord(t){return{x:t.x,y:t.y,z:t.z,key:this.coordKey(t)}},coordKey({x:t,y:e,z:r}){return t+"/"+e+"/"+r},key(t,e,r){if(!(t.y<0||t.y>=1<<t.z||t.z<0))return[e.name,t.x,t.y,t.z,r].join("/")},normalizedKey(t,e,r){return this.key(this.normalizedCoord(t,e),e,r)},normalizedCoord(t,e){return e.zoom_bias&&(t=this.coordAtZoom(t,Math.max(t.z-e.zoom_bias,e.zooms[0]))),this.coordForTileZooms(t,e.zooms)},coordAtZoom({x:t,y:e,z:r},i){if(i=Math.max(0,i),r!==i){let n=Math.pow(2,r-i);t=Math.floor(t/n),e=Math.floor(e/n),r=i}return this.coord({x:t,y:e,z:r})},coordForTileZooms({x:t,y:e,z:r},i){let n=this.findZoomInRange(r,i);return n!==r?this.coordAtZoom({x:t,y:e,z:r},n):this.coord({x:t,y:e,z:r})},findZoomInRange(t,e){return e.filter(r=>t>=r).reverse()[0]||e[0]},isDescendant(t,e){if(e.z>t.z){let{x:r,y:i}=this.coordAtZoom(e,t.z);return t.x===r&&t.y===i}return!1},parent({coords:t,source:e,style_z:r}){if(r>0){r--;let i=Math.max(r-(e.zoom_bias||0),e.zooms[0]),n=this.coordForTileZooms(this.coordAtZoom(t,i),e.zooms);return n.z>r?null:{key:this.key(n,e,r),coords:n,style_z:r,source:e}}},children({coords:t,source:e,style_z:r},i={}){r++;let n=this.coordForTileZooms(this.coordAtZoom(t,r-(e.zoom_bias||0)),e.zooms);if(n.z===t.z)return[{key:this.key(n,e,r),coords:n,style_z:r,source:e}];{let o=this.key(n,e,r);if(!o)return[];if(i[e.id]=i[e.id]||{},i[e.id][o]==null){let s=Math.pow(2,n.z-t.z),a=t.x*s,l=t.y*s,u=[];for(let c=a;c<a+s;c++)for(let d=l;d<l+s;d++){let f=this.coord({x:c,y:d,z:n.z});u.push({key:this.key(f,e,r),coords:f,style_z:r,source:e})}i[e.id][o]=u}return i[e.id][o]}}};var Qa=Zt(Ya(),1),U={},E=U,ao=t=>Math.max(t,0),lo=t=>isNaN(t)?0:t,tr=(t=>Array.isArray(t)?t.map(parseFloat).map(lo):lo(parseFloat(t))),Ur=(t=>Array.isArray(t)?t.map(tr).map(ao):ao(tr(t)));Object.assign(U,{clampPositive:ao,noNaN:lo,parseNumber:tr,parsePositiveNumber:Ur});U.wrapFunction=function(t,e=!1){var r=\`
|
|
2490
2490
|
var feature = context.feature.properties;
|
|
2491
2491
|
var global = context.global;
|
|
2492
2492
|
var $zoom = context.zoom;
|
|
@@ -4929,7 +4929,7 @@ vec3 worldNormal() {
|
|
|
4929
4929
|
ieee754/index.js:
|
|
4930
4930
|
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
4931
4931
|
*/
|
|
4932
|
-
`;qi.workerURL=URL.createObjectURL(new Blob([_g],{type:"text/javascript"}));qi.debug.ESM=!0;qi.debug.SHA="
|
|
4932
|
+
`;qi.workerURL=URL.createObjectURL(new Blob([_g],{type:"text/javascript"}));qi.debug.ESM=!0;qi.debug.SHA="1a35a1f7cc70141c0308ad762a50d6e06b9279f4";globalThis.Tangram=qi;var LF=qi;export{$r as DrapedTerrainSurfaceSnapshot,$i as TerrainMeshSurface,Vi as TerrainSurfaceCollection,Mi as WebMercatorGlobeVisibilityAdapter,zr as WebMercatorVisibilityAdapter,mg as calculatePlanarGroundBounds,Ou as calculatePlanarVolumeBounds,Oo as convertLumaLight,LF as default,zo as mapTangramLight,ea as pickTerrainAt,dg as resolveTerrainClearance,Cu as sampleTerrainElevation};
|
|
4933
4933
|
/*! Bundled license information:
|
|
4934
4934
|
|
|
4935
4935
|
jszip/dist/jszip.min.js:
|