@loaders.gl/mvt 4.2.2 → 4.2.4

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/dist/dist.min.js CHANGED
@@ -4,7 +4,7 @@
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
5
  else if (typeof exports === 'object') exports['loaders'] = factory();
6
6
  else root['loaders'] = factory();})(globalThis, function () {
7
- "use strict";var __exports__=(()=>{var nn=Object.create;var ie=Object.defineProperty;var rn=Object.getOwnPropertyDescriptor;var on=Object.getOwnPropertyNames;var sn=Object.getPrototypeOf,an=Object.prototype.hasOwnProperty;var Te=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ln=(e,t)=>{for(var n in t)ie(e,n,{get:t[n],enumerable:!0})},ne=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of on(t))!an.call(e,r)&&r!==n&&ie(e,r,{get:()=>t[r],enumerable:!(i=rn(t,r))||i.enumerable});return e},re=(e,t,n)=>(ne(e,t,"default"),n&&ne(n,t,"default")),it=(e,t,n)=>(n=e!=null?nn(sn(e)):{},ne(t||!e||!e.__esModule?ie(n,"default",{value:e,enumerable:!0}):n,e)),fn=e=>ne(ie({},"__esModule",{value:!0}),e);var ot=Te((yr,rt)=>{rt.exports=globalThis.loaders});var ht=Te(be=>{be.read=function(e,t,n,i,r){var o,s,a=r*8-i-1,l=(1<<a)-1,f=l>>1,c=-7,u=n?r-1:0,p=n?-1:1,h=e[t+u];for(u+=p,o=h&(1<<-c)-1,h>>=-c,c+=a;c>0;o=o*256+e[t+u],u+=p,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=i;c>0;s=s*256+e[t+u],u+=p,c-=8);if(o===0)o=1-f;else{if(o===l)return s?NaN:(h?-1:1)*(1/0);s=s+Math.pow(2,i),o=o-f}return(h?-1:1)*s*Math.pow(2,o-i)};be.write=function(e,t,n,i,r,o){var s,a,l,f=o*8-r-1,c=(1<<f)-1,u=c>>1,p=r===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=i?0:o-1,d=i?1:-1,x=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),s+u>=1?t+=p/l:t+=p*Math.pow(2,1-u),t*l>=2&&(s++,l/=2),s+u>=c?(a=0,s=c):s+u>=1?(a=(t*l-1)*Math.pow(2,r),s=s+u):(a=t*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;e[n+h]=a&255,h+=d,a/=256,r-=8);for(s=s<<r|a,f+=r;f>0;e[n+h]=s&255,h+=d,s/=256,f-=8);e[n+h-d]|=x*128}});var yt=Te((po,xt)=>{"use strict";xt.exports=y;var le=ht();function y(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}y.Varint=0;y.Fixed64=1;y.Bytes=2;y.Fixed32=5;var Le=(1<<16)*(1<<16),pt=1/Le,Un=12,mt=typeof TextDecoder>"u"?null:new TextDecoder("utf8");y.prototype={destroy:function(){this.buf=null},readFields:function(e,t,n){for(n=n||this.length;this.pos<n;){var i=this.readVarint(),r=i>>3,o=this.pos;this.type=i&7,e(r,t,this),this.pos===o&&this.skip(i)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=fe(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=gt(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=fe(this.buf,this.pos)+fe(this.buf,this.pos+4)*Le;return this.pos+=8,e},readSFixed64:function(){var e=fe(this.buf,this.pos)+gt(this.buf,this.pos+4)*Le;return this.pos+=8,e},readFloat:function(){var e=le.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=le.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t=this.buf,n,i;return i=t[this.pos++],n=i&127,i<128||(i=t[this.pos++],n|=(i&127)<<7,i<128)||(i=t[this.pos++],n|=(i&127)<<14,i<128)||(i=t[this.pos++],n|=(i&127)<<21,i<128)?n:(i=t[this.pos],n|=(i&15)<<28,Gn(n,e,this))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2===1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=Un&&mt?ei(this.buf,t,e):qn(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==y.Bytes)return e.push(this.readVarint(t));var n=D(this);for(e=e||[];this.pos<n;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==y.Bytes)return e.push(this.readSVarint());var t=D(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){if(this.type!==y.Bytes)return e.push(this.readBoolean());var t=D(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){if(this.type!==y.Bytes)return e.push(this.readFloat());var t=D(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){if(this.type!==y.Bytes)return e.push(this.readDouble());var t=D(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){if(this.type!==y.Bytes)return e.push(this.readFixed32());var t=D(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){if(this.type!==y.Bytes)return e.push(this.readSFixed32());var t=D(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){if(this.type!==y.Bytes)return e.push(this.readFixed64());var t=D(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){if(this.type!==y.Bytes)return e.push(this.readSFixed64());var t=D(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var t=e&7;if(t===y.Varint)for(;this.buf[this.pos++]>127;);else if(t===y.Bytes)this.pos=this.readVarint()+this.pos;else if(t===y.Fixed32)this.pos+=4;else if(t===y.Fixed64)this.pos+=8;else throw new Error("Unimplemented type: "+t)},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t<this.pos+e;)t*=2;if(t!==this.length){var n=new Uint8Array(t);n.set(this.buf),this.buf=n,this.length=t}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(e){this.realloc(4),R(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),R(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),R(this.buf,e&-1,this.pos),R(this.buf,Math.floor(e*pt),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),R(this.buf,e&-1,this.pos),R(this.buf,Math.floor(e*pt),this.pos+4),this.pos+=8},writeVarint:function(e){if(e=+e||0,e>268435455||e<0){Rn(e,this);return}this.realloc(4),this.buf[this.pos++]=e&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=e>>>7&127)))},writeSVarint:function(e){this.writeVarint(e<0?-e*2-1:e*2)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(e.length*4),this.pos++;var t=this.pos;this.pos=ti(this.buf,e,this.pos);var n=this.pos-t;n>=128&&dt(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n},writeFloat:function(e){this.realloc(4),le.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),le.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var n=0;n<t;n++)this.buf[this.pos++]=e[n]},writeRawMessage:function(e,t){this.pos++;var n=this.pos;e(t,this);var i=this.pos-n;i>=128&&dt(n,i,this),this.pos=n-1,this.writeVarint(i),this.pos+=i},writeMessage:function(e,t,n){this.writeTag(e,y.Bytes),this.writeRawMessage(t,n)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,zn,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,Jn,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,Xn,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,Wn,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,Yn,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,$n,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,Hn,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,Kn,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,Qn,t)},writeBytesField:function(e,t){this.writeTag(e,y.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,y.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,y.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,y.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,y.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,y.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,y.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,y.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,y.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,y.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};function Gn(e,t,n){var i=n.buf,r,o;if(o=i[n.pos++],r=(o&112)>>4,o<128||(o=i[n.pos++],r|=(o&127)<<3,o<128)||(o=i[n.pos++],r|=(o&127)<<10,o<128)||(o=i[n.pos++],r|=(o&127)<<17,o<128)||(o=i[n.pos++],r|=(o&127)<<24,o<128)||(o=i[n.pos++],r|=(o&1)<<31,o<128))return G(e,r,t);throw new Error("Expected varint not more than 10 bytes")}function D(e){return e.type===y.Bytes?e.readVarint()+e.pos:e.pos+1}function G(e,t,n){return n?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function Rn(e,t){var n,i;if(e>=0?(n=e%4294967296|0,i=e/4294967296|0):(n=~(-e%4294967296),i=~(-e/4294967296),n^4294967295?n=n+1|0:(n=0,i=i+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),jn(n,i,t),Zn(i,t)}function jn(e,t,n){n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos]=e&127}function Zn(e,t){var n=(e&7)<<4;t.buf[t.pos++]|=n|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127)))))}function dt(e,t,n){var i=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(Math.LN2*7));n.realloc(i);for(var r=n.pos-1;r>=e;r--)n.buf[r+i]=n.buf[r]}function zn(e,t){for(var n=0;n<e.length;n++)t.writeVarint(e[n])}function Jn(e,t){for(var n=0;n<e.length;n++)t.writeSVarint(e[n])}function Wn(e,t){for(var n=0;n<e.length;n++)t.writeFloat(e[n])}function Yn(e,t){for(var n=0;n<e.length;n++)t.writeDouble(e[n])}function Xn(e,t){for(var n=0;n<e.length;n++)t.writeBoolean(e[n])}function $n(e,t){for(var n=0;n<e.length;n++)t.writeFixed32(e[n])}function Hn(e,t){for(var n=0;n<e.length;n++)t.writeSFixed32(e[n])}function Kn(e,t){for(var n=0;n<e.length;n++)t.writeFixed64(e[n])}function Qn(e,t){for(var n=0;n<e.length;n++)t.writeSFixed64(e[n])}function fe(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+e[t+3]*16777216}function R(e,t,n){e[n]=t,e[n+1]=t>>>8,e[n+2]=t>>>16,e[n+3]=t>>>24}function gt(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}function qn(e,t,n){for(var i="",r=t;r<n;){var o=e[r],s=null,a=o>239?4:o>223?3:o>191?2:1;if(r+a>n)break;var l,f,c;a===1?o<128&&(s=o):a===2?(l=e[r+1],(l&192)===128&&(s=(o&31)<<6|l&63,s<=127&&(s=null))):a===3?(l=e[r+1],f=e[r+2],(l&192)===128&&(f&192)===128&&(s=(o&15)<<12|(l&63)<<6|f&63,(s<=2047||s>=55296&&s<=57343)&&(s=null))):a===4&&(l=e[r+1],f=e[r+2],c=e[r+3],(l&192)===128&&(f&192)===128&&(c&192)===128&&(s=(o&15)<<18|(l&63)<<12|(f&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),r+=a}return i}function ei(e,t,n){return mt.decode(e.subarray(t,n))}function ti(e,t,n){for(var i=0,r,o;i<t.length;i++){if(r=t.charCodeAt(i),r>55295&&r<57344)if(o)if(r<56320){e[n++]=239,e[n++]=191,e[n++]=189,o=r;continue}else r=o-55296<<10|r-56320|65536,o=null;else{r>56319||i+1===t.length?(e[n++]=239,e[n++]=191,e[n++]=189):o=r;continue}else o&&(e[n++]=239,e[n++]=191,e[n++]=189,o=null);r<128?e[n++]=r:(r<2048?e[n++]=r>>6|192:(r<65536?e[n++]=r>>12|224:(e[n++]=r>>18|240,e[n++]=r>>12&63|128),e[n++]=r>>6&63|128),e[n++]=r&63|128)}return n}});var te={};ln(te,{GeoJSONTiler:()=>ve,MVTLoader:()=>me,MVTSource:()=>we,MVTWorkerLoader:()=>Re,TileJSONLoader:()=>Z});re(te,it(ot(),1));function b(e){return b=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},b(e)}function Se(e,t){if(b(e)!=="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,t||"default");if(b(i)!=="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function _e(e){var t=Se(e,"string");return b(t)==="symbol"?t:String(t)}function V(e,t,n){return t=_e(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var J={x:0,y:1,z:2};function C(e,t={}){let{start:n=0,end:i=e.length,plane:r="xy"}=t,o=t.size||2,s=0,a=J[r[0]],l=J[r[1]];for(let f=n,c=i-o;f<i;f+=o)s+=(e[f+a]-e[c+a])*(e[f+l]+e[c+l]),c=f;return s/2}function Ve(e,t,n=2,i,r="xy"){let o=t&&t.length,s=o?t[0]*n:e.length,a=at(e,0,s,n,!0,i&&i[0],r),l=[];if(!a||a.next===a.prev)return l;let f,c,u,p,h,d,x;if(o&&(a=mn(e,t,a,n,i,r)),e.length>80*n){p=c=e[0],h=u=e[1];for(let w=n;w<s;w+=n)d=e[w],x=e[w+1],d<p&&(p=d),x<h&&(h=x),d>c&&(c=d),x>u&&(u=x);f=Math.max(c-p,u-h),f=f!==0?32767/f:0}return W(a,l,n,p,h,f,0),l}function at(e,t,n,i,r,o,s){let a,l;o===void 0&&(o=C(e,{start:t,end:n,size:i,plane:s}));let f=J[s[0]],c=J[s[1]];if(r===o<0)for(a=t;a<n;a+=i)l=st(a,e[a+f],e[a+c],l);else for(a=n-i;a>=t;a-=i)l=st(a,e[a+f],e[a+c],l);return l&&ae(l,l.next)&&(X(l),l=l.next),l}function O(e,t){if(!e)return e;t||(t=e);let n=e,i;do if(i=!1,!n.steiner&&(ae(n,n.next)||P(n.prev,n,n.next)===0)){if(X(n),n=t=n.prev,n===n.next)break;i=!0}else n=n.next;while(i||n!==t);return t}function W(e,t,n,i,r,o,s){if(!e)return;!s&&o&&Fn(e,i,r,o);let a=e,l,f;for(;e.prev!==e.next;){if(l=e.prev,f=e.next,o?pn(e,i,r,o):hn(e)){t.push(l.i/n|0),t.push(e.i/n|0),t.push(f.i/n|0),X(e),e=f.next,a=f.next;continue}if(e=f,e===a){s?s===1?(e=dn(O(e),t,n),W(e,t,n,i,r,o,2)):s===2&&gn(e,t,n,i,r,o):W(O(e),t,n,i,r,o,1);break}}}function hn(e){let t=e.prev,n=e,i=e.next;if(P(t,n,i)>=0)return!1;let r=t.x,o=n.x,s=i.x,a=t.y,l=n.y,f=i.y,c=r<o?r<s?r:s:o<s?o:s,u=a<l?a<f?a:f:l<f?l:f,p=r>o?r>s?r:s:o>s?o:s,h=a>l?a>f?a:f:l>f?l:f,d=i.next;for(;d!==t;){if(d.x>=c&&d.x<=p&&d.y>=u&&d.y<=h&&U(r,a,o,l,s,f,d.x,d.y)&&P(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function pn(e,t,n,i){let r=e.prev,o=e,s=e.next;if(P(r,o,s)>=0)return!1;let a=r.x,l=o.x,f=s.x,c=r.y,u=o.y,p=s.y,h=a<l?a<f?a:f:l<f?l:f,d=c<u?c<p?c:p:u<p?u:p,x=a>l?a>f?a:f:l>f?l:f,w=c>u?c>p?c:p:u>p?u:p,I=Me(h,d,t,n,i),_=Me(x,w,t,n,i),g=e.prevZ,m=e.nextZ;for(;g&&g.z>=I&&m&&m.z<=_;){if(g.x>=h&&g.x<=x&&g.y>=d&&g.y<=w&&g!==r&&g!==s&&U(a,c,l,u,f,p,g.x,g.y)&&P(g.prev,g,g.next)>=0||(g=g.prevZ,m.x>=h&&m.x<=x&&m.y>=d&&m.y<=w&&m!==r&&m!==s&&U(a,c,l,u,f,p,m.x,m.y)&&P(m.prev,m,m.next)>=0))return!1;m=m.nextZ}for(;g&&g.z>=I;){if(g.x>=h&&g.x<=x&&g.y>=d&&g.y<=w&&g!==r&&g!==s&&U(a,c,l,u,f,p,g.x,g.y)&&P(g.prev,g,g.next)>=0)return!1;g=g.prevZ}for(;m&&m.z<=_;){if(m.x>=h&&m.x<=x&&m.y>=d&&m.y<=w&&m!==r&&m!==s&&U(a,c,l,u,f,p,m.x,m.y)&&P(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function dn(e,t,n){let i=e;do{let r=i.prev,o=i.next.next;!ae(r,o)&&lt(r,i,i.next,o)&&Y(r,o)&&Y(o,r)&&(t.push(r.i/n|0),t.push(i.i/n|0),t.push(o.i/n|0),X(i),X(i.next),i=e=o),i=i.next}while(i!==e);return O(i)}function gn(e,t,n,i,r,o){let s=e;do{let a=s.next.next;for(;a!==s.prev;){if(s.i!==a.i&&Tn(s,a)){let l=ft(s,a);s=O(s,s.next),l=O(l,l.next),W(s,t,n,i,r,o,0),W(l,t,n,i,r,o,0);return}a=a.next}s=s.next}while(s!==e)}function mn(e,t,n,i,r,o){let s=[],a,l,f,c,u;for(a=0,l=t.length;a<l;a++)f=t[a]*i,c=a<l-1?t[a+1]*i:e.length,u=at(e,f,c,i,!1,r&&r[a+1],o),u===u.next&&(u.steiner=!0),s.push(vn(u));for(s.sort(xn),a=0;a<s.length;a++)n=yn(s[a],n);return n}function xn(e,t){return e.x-t.x}function yn(e,t){let n=wn(e,t);if(!n)return t;let i=ft(n,e);return O(i,i.next),O(n,n.next)}function wn(e,t){let n=t,i=e.x,r=e.y,o=-1/0,s;do{if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){let p=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(p<=i&&p>o&&(o=p,s=n.x<n.next.x?n:n.next,p===i))return s}n=n.next}while(n!==t);if(!s)return null;let a=s,l=s.x,f=s.y,c=1/0,u;n=s;do i>=n.x&&n.x>=l&&i!==n.x&&U(r<f?i:o,r,l,f,r<f?o:i,r,n.x,n.y)&&(u=Math.abs(r-n.y)/(i-n.x),Y(n,e)&&(u<c||u===c&&(n.x>s.x||n.x===s.x&&Pn(s,n)))&&(s=n,c=u)),n=n.next;while(n!==a);return s}function Pn(e,t){return P(e.prev,e,t.prev)<0&&P(t.next,e,e.next)<0}function Fn(e,t,n,i){let r=e;do r.z===0&&(r.z=Me(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,In(r)}function In(e){let t,n,i=1,r,o,s,a,l,f;do{for(o=e,e=null,f=null,r=0;o;){for(r++,a=o,s=0,n=0;n<i&&(s++,a=a.nextZ,!!a);n++);for(l=i;s>0||l>0&&a;)s!==0&&(l===0||!a||o.z<=a.z)?(t=o,o=o.nextZ,s--):(t=a,a=a.nextZ,l--),f?f.nextZ=t:e=t,t.prevZ=f,f=t;o=a}f.nextZ=null,i*=2}while(r>1);return e}function Me(e,t,n,i,r){return e=(e-n)*r|0,t=(t-i)*r|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function vn(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function U(e,t,n,i,r,o,s,a){return(r-s)*(t-a)>=(e-s)*(o-a)&&(e-s)*(i-a)>=(n-s)*(t-a)&&(n-s)*(o-a)>=(r-s)*(i-a)}function Tn(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Sn(e,t)&&(Y(e,t)&&Y(t,e)&&_n(e,t)&&(P(e.prev,e,t.prev)||P(e,t.prev,t))||ae(e,t)&&P(e.prev,e,e.next)>0&&P(t.prev,t,t.next)>0)}function P(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function ae(e,t){return e.x===t.x&&e.y===t.y}function lt(e,t,n,i){let r=se(P(e,t,n)),o=se(P(e,t,i)),s=se(P(n,i,e)),a=se(P(n,i,t));return!!(r!==o&&s!==a||r===0&&oe(e,n,t)||o===0&&oe(e,i,t)||s===0&&oe(n,e,i)||a===0&&oe(n,t,i))}function oe(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function se(e){return e>0?1:e<0?-1:0}function Sn(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&lt(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Y(e,t){return P(e.prev,e,e.next)<0?P(e,t,e.next)>=0&&P(e,e.prev,t)>=0:P(e,t,e.prev)<0||P(e,e.next,t)<0}function _n(e,t){let n=e,i=!1,r=(e.x+t.x)/2,o=(e.y+t.y)/2;do n.y>o!=n.next.y>o&&n.next.y!==n.y&&r<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next;while(n!==e);return i}function ft(e,t){let n=new $(e.i,e.x,e.y),i=new $(t.i,t.x,t.y),r=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,o.next=i,i.prev=o,i}function st(e,t,n,i){let r=new $(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function X(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}var $=class{constructor(t,n,i){V(this,"i",void 0),V(this,"x",void 0),V(this,"y",void 0),V(this,"prev",null),V(this,"next",null),V(this,"z",0),V(this,"prevZ",null),V(this,"nextZ",null),V(this,"steiner",!1),this.i=t,this.x=n,this.y=i}};function Ee(e,t,n){let i=En(e),r=Object.keys(i).filter(o=>i[o]!==Array);return Dn(e,{propArrayTypes:i,...t},{numericPropKeys:n&&n.numericPropKeys||r,PositionDataType:n?n.PositionDataType:Float32Array,triangulate:n?n.triangulate:!0})}function En(e){let t={};for(let n of e)if(n.properties)for(let i in n.properties){let r=n.properties[i];t[i]=kn(r,t[i])}return t}function Dn(e,t,n){let{pointPositionsCount:i,pointFeaturesCount:r,linePositionsCount:o,linePathsCount:s,lineFeaturesCount:a,polygonPositionsCount:l,polygonObjectsCount:f,polygonRingsCount:c,polygonFeaturesCount:u,propArrayTypes:p,coordLength:h}=t,{numericPropKeys:d=[],PositionDataType:x=Float32Array,triangulate:w=!0}=n,I=e[0]&&"id"in e[0],_=e.length>65535?Uint32Array:Uint16Array,g={type:"Point",positions:new x(i*h),globalFeatureIds:new _(i),featureIds:r>65535?new Uint32Array(i):new Uint16Array(i),numericProps:{},properties:[],fields:[]},m={type:"LineString",pathIndices:o>65535?new Uint32Array(s+1):new Uint16Array(s+1),positions:new x(o*h),globalFeatureIds:new _(o),featureIds:a>65535?new Uint32Array(o):new Uint16Array(o),numericProps:{},properties:[],fields:[]},v={type:"Polygon",polygonIndices:l>65535?new Uint32Array(f+1):new Uint16Array(f+1),primitivePolygonIndices:l>65535?new Uint32Array(c+1):new Uint16Array(c+1),positions:new x(l*h),globalFeatureIds:new _(l),featureIds:u>65535?new Uint32Array(l):new Uint16Array(l),numericProps:{},properties:[],fields:[]};w&&(v.triangles=[]);for(let T of[g,m,v])for(let S of d){let M=p[S];T.numericProps[S]=new M(T.positions.length/h)}m.pathIndices[s]=o,v.polygonIndices[f]=l,v.primitivePolygonIndices[c]=l;let F={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(let T of e){let S=T.geometry,M=T.properties||{};switch(S.type){case"Point":bn(S,g,F,h,M),g.properties.push(Ae(M,d)),I&&g.fields.push({id:T.id}),F.pointFeature++;break;case"LineString":Ln(S,m,F,h,M),m.properties.push(Ae(M,d)),I&&m.fields.push({id:T.id}),F.lineFeature++;break;case"Polygon":Cn(S,v,F,h,M),v.properties.push(Ae(M,d)),I&&v.fields.push({id:T.id}),F.polygonFeature++;break;default:throw new Error("Invalid geometry type")}F.feature++}return Nn(g,m,v,h)}function bn(e,t,n,i,r){t.positions.set(e.data,n.pointPosition*i);let o=e.data.length/i;De(t,r,n.pointPosition,o),t.globalFeatureIds.fill(n.feature,n.pointPosition,n.pointPosition+o),t.featureIds.fill(n.pointFeature,n.pointPosition,n.pointPosition+o),n.pointPosition+=o}function Ln(e,t,n,i,r){t.positions.set(e.data,n.linePosition*i);let o=e.data.length/i;De(t,r,n.linePosition,o),t.globalFeatureIds.fill(n.feature,n.linePosition,n.linePosition+o),t.featureIds.fill(n.lineFeature,n.linePosition,n.linePosition+o);for(let s=0,a=e.indices.length;s<a;++s){let l=e.indices[s],f=s===a-1?e.data.length:e.indices[s+1];t.pathIndices[n.linePath++]=n.linePosition,n.linePosition+=(f-l)/i}}function Cn(e,t,n,i,r){t.positions.set(e.data,n.polygonPosition*i);let o=e.data.length/i;De(t,r,n.polygonPosition,o),t.globalFeatureIds.fill(n.feature,n.polygonPosition,n.polygonPosition+o),t.featureIds.fill(n.polygonFeature,n.polygonPosition,n.polygonPosition+o);for(let s=0,a=e.indices.length;s<a;++s){let l=n.polygonPosition;t.polygonIndices[n.polygonObject++]=l;let f=e.areas[s],c=e.indices[s],u=e.indices[s+1];for(let h=0,d=c.length;h<d;++h){let x=c[h],w=h===d-1?u===void 0?e.data.length:u[0]:c[h+1];t.primitivePolygonIndices[n.polygonRing++]=n.polygonPosition,n.polygonPosition+=(w-x)/i}let p=n.polygonPosition;On(t,f,c,{startPosition:l,endPosition:p,coordLength:i})}}function On(e,t,n,{startPosition:i,endPosition:r,coordLength:o}){if(!e.triangles)return;let s=i*o,a=r*o,l=e.positions.subarray(s,a),f=n[0],c=n.slice(1).map(p=>(p-f)/o),u=Ve(l,c,o,t);for(let p=0,h=u.length;p<h;++p)e.triangles.push(i+u[p])}function Be(e,t){let n={};for(let i in e)n[i]={value:e[i],size:t};return n}function Nn(e,t,n,i){let r={shape:"binary-feature-collection",points:{...e,positions:{value:e.positions,size:i},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},numericProps:Be(e.numericProps,1)},lines:{...t,positions:{value:t.positions,size:i},pathIndices:{value:t.pathIndices,size:1},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},numericProps:Be(t.numericProps,1)},polygons:{...n,positions:{value:n.positions,size:i},polygonIndices:{value:n.polygonIndices,size:1},primitivePolygonIndices:{value:n.primitivePolygonIndices,size:1},globalFeatureIds:{value:n.globalFeatureIds,size:1},featureIds:{value:n.featureIds,size:1},numericProps:Be(n.numericProps,1)}};return r.polygons&&n.triangles&&(r.polygons.triangles={value:new Uint32Array(n.triangles),size:1}),r}function De(e,t,n,i){for(let r in e.numericProps)if(r in t){let o=t[r];e.numericProps[r].fill(o,n,n+i)}}function Ae(e,t){let n={};for(let i in e)t.includes(i)||(n[i]=e[i]);return n}function kn(e,t){return t===Array||!Number.isFinite(e)?Array:t===Float64Array||Math.fround(e)!==e?Float64Array:Float32Array}var Ue=it(yt(),1);function wt(e){let t=e.length;if(t<=1)return[e];let n=[],i,r;for(let o=0;o<t;o++){let s=ni(e[o]);s!==0&&(r===void 0&&(r=s<0),r===s<0?(i&&n.push(i),i=[e[o]]):i&&i.push(e[o]))}return i&&n.push(i),n}function ni(e){let t=0;for(let n=0,i=e.length-1,r,o;n<e.length;i=n++)r=e[n],o=e[i],t+=(o[0]-r[0])*(r[1]+o[1]);return t}function Pt(e,t,n){t&&n&&(e===1?t.id=n.readVarint():e===2?ii(n,t):e===3?t.type=n.readVarint():e===4&&(t._geometry=n.pos))}function ii(e,t){let n=e.readVarint()+e.pos;for(;e.pos<n;){let i=t._keys[e.readVarint()],r=t._values[e.readVarint()];t.properties[i]=r}}var j=class{properties;extent;type;id;_pbf;_geometry;_keys;_values;static get types(){return["Unknown","Point","LineString","Polygon"]}constructor(t,n,i,r,o){this.properties={},this.extent=i,this.type=0,this.id=null,this._pbf=t,this._geometry=-1,this._keys=r,this._values=o,t.readFields(Pt,this,n)}loadGeometry(){let t=this._pbf;t.pos=this._geometry;let n=t.readVarint()+t.pos,i=1,r=0,o=0,s=0,a=[],l;for(;t.pos<n;){if(r<=0){let f=t.readVarint();i=f&7,r=f>>3}if(r--,i===1||i===2)o+=t.readSVarint(),s+=t.readSVarint(),i===1&&(l&&a.push(l),l=[]),l&&l.push([o,s]);else if(i===7)l&&l.push(l[0].slice());else throw new Error(`unknown command ${i}`)}return l&&a.push(l),a}bbox(){let t=this._pbf;t.pos=this._geometry;let n=t.readVarint()+t.pos,i=1,r=0,o=0,s=0,a=1/0,l=-1/0,f=1/0,c=-1/0;for(;t.pos<n;){if(r<=0){let u=t.readVarint();i=u&7,r=u>>3}if(r--,i===1||i===2)o+=t.readSVarint(),s+=t.readSVarint(),o<a&&(a=o),o>l&&(l=o),s<f&&(f=s),s>c&&(c=s);else if(i!==7)throw new Error(`unknown command ${i}`)}return[a,f,l,c]}_toGeoJSON(t){let n=this.loadGeometry(),i=j.types[this.type],r,o;switch(this.type){case 1:let a=[];for(r=0;r<n.length;r++)a[r]=n[r][0];n=a,t(n,this);break;case 2:for(r=0;r<n.length;r++)t(n[r],this);break;case 3:for(n=wt(n),r=0;r<n.length;r++)for(o=0;o<n[r].length;o++)t(n[r][o],this);break}n.length===1?n=n[0]:i=`Multi${i}`;let s={type:"Feature",geometry:{type:i,coordinates:n},properties:this.properties};return this.id!==null&&(s.id=this.id),s}toGeoJSON(t){if(typeof t=="function")return this._toGeoJSON(t);let{x:n,y:i,z:r}=t,o=this.extent*Math.pow(2,r),s=this.extent*n,a=this.extent*i;function l(f){for(let c=0;c<f.length;c++){let u=f[c];u[0]=(u[0]+s)*360/o-180;let p=180-(u[1]+a)*360/o;u[1]=360/Math.PI*Math.atan(Math.exp(p*Math.PI/180))-90}}return this._toGeoJSON(l)}};var ce=class{version;name;extent;length;_pbf;_keys;_values;_features;constructor(t,n){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(ri,this,n),this.length=this._features.length}feature(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];let n=this._pbf.readVarint()+this._pbf.pos;return new j(this._pbf,n,this.extent,this._keys,this._values)}};function ri(e,t,n){t&&n&&(e===15?t.version=n.readVarint():e===1?t.name=n.readString():e===5?t.extent=n.readVarint():e===2?t._features.push(n.pos):e===3?t._keys.push(n.readString()):e===4&&t._values.push(oi(n)))}function oi(e){let t=null,n=e.readVarint()+e.pos;for(;e.pos<n;){let i=e.readVarint()>>3;t=i===1?e.readString():i===2?e.readFloat():i===3?e.readDouble():i===4?e.readVarint64():i===5?e.readVarint():i===6?e.readSVarint():i===7?e.readBoolean():null}return t}var ue=class{layers;constructor(t,n){this.layers=t.readFields(si,{},n)}};function si(e,t,n){if(e===3&&n){let i=new ce(n,n.readVarint()+n.pos);i.length&&t&&(t[i.name]=i)}}function Ft(e){let t=e.indices.length,n="Polygon";if(t<=1)return{type:n,data:e.data,areas:[[C(e.data)]],indices:[e.indices]};let i=[],r=[],o=[],s=[],a,l=0;for(let f,c=0,u;c<t;c++){u=e.indices[c]-l,f=e.indices[c+1]-l||e.data.length;let p=e.data.slice(u,f),h=C(p);if(h===0){let d=e.data.slice(0,u),x=e.data.slice(f);e.data=d.concat(x),l+=f-u;continue}a===void 0&&(a=h<0),a===h<0?(s.length&&(i.push(o),r.push(s)),s=[u],o=[h]):(o.push(h),s.push(u))}return o&&i.push(o),s.length&&r.push(s),{type:n,areas:i,indices:r,data:e.data}}function It(e,t,n,i){for(let r=0,o=e.length;r<o;r+=2){e[r]=(e[r]+t)*360/i-180;let s=180-(e[r+1]+n)*360/i;e[r+1]=360/Math.PI*Math.atan(Math.exp(s*Math.PI/180))-90}}function vt(e,t,n){t&&n&&(e===1?t.id=n.readVarint():e===2?ai(n,t):e===3?t.type=n.readVarint():e===4&&(t._geometry=n.pos))}function ai(e,t){let n=e.readVarint()+e.pos;for(;e.pos<n;){let i=t._keys[e.readVarint()],r=t._values[e.readVarint()];t.properties[i]=r}}var Tt,N,Ce,he,Oe,Ne,H;var pe=class{properties;extent;type;id;_pbf;_geometry;_keys;_values;_geometryInfo;constructor(t,n,i,r,o,s){this.properties={},this.extent=i,this.type=0,this.id=null,this._pbf=t,this._geometry=-1,this._keys=r,this._values=o,this._geometryInfo=s,t.readFields(vt,this,n)}loadGeometry(){let t=this._pbf;t.pos=this._geometry,Tt=t.readVarint()+t.pos,N=1,he=0,Oe=0,Ne=0,H=0;let n=[],i=[];for(;t.pos<Tt;)if(he<=0&&(Ce=t.readVarint(),N=Ce&7,he=Ce>>3),he--,N===1||N===2)Oe+=t.readSVarint(),Ne+=t.readSVarint(),N===1&&n.push(H),i.push(Oe,Ne),H+=2;else if(N===7){if(H>0){let r=n[n.length-1];i.push(i[r],i[r+1]),H+=2}}else throw new Error(`unknown command ${N}`);return{data:i,indices:n}}_toBinaryCoordinates(t){let n=this.loadGeometry(),i;t(n.data,this);let r=2;switch(this.type){case 1:this._geometryInfo.pointFeaturesCount++,this._geometryInfo.pointPositionsCount+=n.indices.length,i={type:"Point",...n};break;case 2:this._geometryInfo.lineFeaturesCount++,this._geometryInfo.linePathsCount+=n.indices.length,this._geometryInfo.linePositionsCount+=n.data.length/r,i={type:"LineString",...n};break;case 3:i=Ft(n),this._geometryInfo.polygonFeaturesCount++,this._geometryInfo.polygonObjectsCount+=i.indices.length;for(let s of i.indices)this._geometryInfo.polygonRingsCount+=s.length;this._geometryInfo.polygonPositionsCount+=i.data.length/r;break;default:throw new Error(`Invalid geometry type: ${this.type}`)}let o={type:"Feature",geometry:i,properties:this.properties};return this.id!==null&&(o.id=this.id),o}toBinaryCoordinates(t){if(typeof t=="function")return this._toBinaryCoordinates(t);let{x:n,y:i,z:r}=t,o=this.extent*Math.pow(2,r),s=this.extent*n,a=this.extent*i;return this._toBinaryCoordinates(l=>It(l,s,a,o))}};var de=class{version;name;extent;length;_pbf;_keys;_values;_features;constructor(t,n){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(li,this,n),this.length=this._features.length}feature(t,n){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];let i=this._pbf.readVarint()+this._pbf.pos;return new pe(this._pbf,i,this.extent,this._keys,this._values,n)}};function li(e,t,n){t&&n&&(e===15?t.version=n.readVarint():e===1?t.name=n.readString():e===5?t.extent=n.readVarint():e===2?t._features.push(n.pos):e===3?t._keys.push(n.readString()):e===4&&t._values.push(fi(n)))}function fi(e){let t=null,n=e.readVarint()+e.pos;for(;e.pos<n;){let i=e.readVarint()>>3;t=i===1?e.readString():i===2?e.readFloat():i===3?e.readDouble():i===4?e.readVarint64():i===5?e.readVarint():i===6?e.readSVarint():i===7?e.readBoolean():null}return t}var ge=class{layers;constructor(t,n){this.layers=t.readFields(ci,{},n)}};function ci(e,t,n){if(e===3&&n){let i=new de(n,n.readVarint()+n.pos);i.length&&t&&(t[i.name]=i)}}function Ge(e,t){let n=hi(t),i=t?.gis?.format||t?.mvt?.shape||t?.shape;switch(i){case"columnar-table":return{shape:"columnar-table",data:ke(e,n)};case"geojson-table":return{shape:"geojson-table",type:"FeatureCollection",features:St(e,n)};case"geojson":return St(e,n);case"binary-geometry":return ke(e,n);case"binary":return ke(e,n);default:throw new Error(i||"undefined shape")}}function ke(e,t){let[n,i]=ui(e,t),r=Ee(n,i);return r.byteLength=e.byteLength,r}function ui(e,t){let n=[],i={coordLength:2,pointPositionsCount:0,pointFeaturesCount:0,linePositionsCount:0,linePathsCount:0,lineFeaturesCount:0,polygonPositionsCount:0,polygonObjectsCount:0,polygonRingsCount:0,polygonFeaturesCount:0};if(e.byteLength<=0)return[n,i];let r=new ge(new Ue.default(e));return(t&&Array.isArray(t.layers)?t.layers:Object.keys(r.layers)).forEach(s=>{let a=r.layers[s];if(a)for(let l=0;l<a.length;l++){let f=a.feature(l,i),c=di(f,t,s);n.push(c)}}),[n,i]}function St(e,t){if(e.byteLength<=0)return[];let n=[],i=new ue(new Ue.default(e));return(Array.isArray(t.layers)?t.layers:Object.keys(i.layers)).forEach(o=>{let s=i.layers[o];if(s)for(let a=0;a<s.length;a++){let l=s.feature(a),f=pi(l,t,o);n.push(f)}}),n}function hi(e){if(!e?.mvt)throw new Error("mvt options required");let t=e.mvt?.coordinates==="wgs84",{tileIndex:n}=e.mvt,i=n&&Number.isFinite(n.x)&&Number.isFinite(n.y)&&Number.isFinite(n.z);if(t&&!i)throw new Error("MVT Loader: WGS84 coordinates need tileIndex property");return e.mvt}function pi(e,t,n){let i=e.toGeoJSON(t.coordinates==="wgs84"?t.tileIndex:gi);return t.layerProperty&&(i.properties[t.layerProperty]=n),i}function di(e,t,n){let i=e.toBinaryCoordinates(t.coordinates==="wgs84"?t.tileIndex:mi);return t.layerProperty&&i.properties&&(i.properties[t.layerProperty]=n),i}function gi(e,t){let{extent:n}=t;for(let i=0;i<e.length;i++){let r=e[i];r[0]/=n,r[1]/=n}}function mi(e,t){let{extent:n}=t;for(let i=0,r=e.length;i<r;++i)e[i]/=n}var xi="4.2.1",Re={dataType:null,batchType:null,name:"Mapbox Vector Tile",id:"mvt",module:"mvt",version:xi,extensions:["mvt","pbf"],mimeTypes:["application/vnd.mapbox-vector-tile","application/x-protobuf"],worker:!0,category:"geometry",options:{mvt:{shape:"geojson",coordinates:"local",layerProperty:"layerName",layers:void 0,tileIndex:null}}},me={...Re,parse:async(e,t)=>Ge(e,t),parseSync:Ge,binary:!0};var Bt=e=>e!==null&&typeof e=="object";function je(e,t){if(!e||!Bt(e))return null;let n={name:e.name||"",description:e.description||""};if(typeof e.generator=="string"&&(n.generator=e.generator),typeof e.generator_options=="string"&&(n.generatorOptions=e.generator_options),n.boundingBox=_t(e.bounds)||_t(e.antimeridian_adjusted_bounds),n.center=vi(e.center),n.maxZoom=Mt(e.maxzoom),n.minZoom=Mt(e.minzoom),typeof e?.json=="string")try{n.metaJson=JSON.parse(e.json)}catch(a){console.warn("Failed to parse tilejson.json field",a)}let i=e.tilestats||n.metaJson?.tilestats,r=Pi(i,t),o=yi(e.vector_layers),s=Ii(o,r);return n={...n,layers:s},n.maxZoom===null&&s.length>0&&(n.maxZoom=s[0].maxZoom||null),n.minZoom===null&&s.length>0&&(n.minZoom=s[0].minZoom||null),n}function yi(e){return Array.isArray(e)?e.map(t=>wi(t)):[]}function wi(e){let t=Object.entries(e.fields||[]).map(([i,r])=>({name:i,...bt(String(r))})),n={...e};return delete n.fields,{name:e.id||"",...n,fields:t}}function Pi(e,t){return Bt(e)&&Array.isArray(e.layers)?e.layers.map(n=>Fi(n,t)):[]}function Fi(e,t){let n=[],i={},r=e.attributes||[];for(let o of r){let s=o.attribute;if(typeof s=="string")if(s.split("|").length>1){let a=s.split("|")[0];i[a]=i[a]||[],i[a].push(o),console.warn("ignoring tilestats indexed field",a)}else n[s]||n.push(Si(o,t))}return{name:e.layer||"",dominantGeometry:e.geometry,fields:n}}function Ii(e,t){return e.map(n=>{let i=t.find(s=>s.name===n.name),r=i?.fields||[],o={...n};return delete o.fields,{...o,...i,fields:r}})}function _t(e){let t=Dt(e);if(Array.isArray(t)&&t.length===4&&[t[0],t[2]].every(Et)&&[t[1],t[3]].every(At))return[[t[0],t[1]],[t[2],t[3]]]}function vi(e){let t=Dt(e);return Array.isArray(t)&&t.length===3&&Et(t[0])&&At(t[1])&&Ti(t[2])?t:null}function Mt(e){let t=typeof e=="string"?parseFloat(e):typeof e=="number"?e:null;return t===null||isNaN(t)?null:t}function At(e){return Number.isFinite(e)&&e<=90&&e>=-90}function Et(e){return Number.isFinite(e)&&e<=180&&e>=-180}function Ti(e){return Number.isFinite(e)&&e>=0&&e<=22}function Dt(e){return typeof e=="string"?e.split(",").map(parseFloat):Array.isArray(e)?e:null}var Vt={number:{type:"float32"},numeric:{type:"float32"},string:{type:"utf8"},vachar:{type:"utf8"},float:{type:"float32"},int:{type:"int32"},int4:{type:"int32"},boolean:{type:"boolean"},bool:{type:"boolean"}};function Si(e={},t){let n=bt(e.type),i={name:e.attribute,...n};return typeof e.min=="number"&&(i.min=e.min),typeof e.max=="number"&&(i.max=e.max),typeof e.count=="number"&&(i.uniqueValueCount=e.count),e.values&&(i.values=e.values),i.values&&typeof t.maxValues=="number"&&(i.values=i.values?.slice(0,t.maxValues)),i}function bt(e){let t=e.toLowerCase();return!t||Vt[t],Vt[t]||{type:"string"}}var _i="4.2.1",Z={dataType:null,batchType:null,name:"TileJSON",id:"tilejson",module:"pmtiles",version:_i,worker:!0,extensions:["json"],mimeTypes:["application/json"],text:!0,options:{tilejson:{maxValues:void 0}},parse:async(e,t)=>{let n=new TextDecoder().decode(e),i=JSON.parse(n),r={...Z.options.tilejson,...t?.tilejson};return je(i,r)},parseTextSync:(e,t)=>{let n=JSON.parse(e),i={...Z.options.tilejson,...t?.tilejson};return je(n,i)}};function K(e,t){if(!e)throw new Error(t||"loader assertion failed.")}var A={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},Mi=A.self||A.window||A.global||{},Vi=A.window||A.self||A.global||{},Bi=A.global||A.self||A.window||{},Ai=A.document||{};var Ze=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var Lt=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),Ei=Lt&&parseFloat(Lt[1])||0;var Di="",Ct={};function ze(e){for(let t in Ct)if(e.startsWith(t)){let n=Ct[t];e=e.replace(t,n)}return!e.startsWith("http://")&&!e.startsWith("https://")&&(e=`${Di}${e}`),e}var Q=class{fetch;loadOptions;_needsRefresh=!0;props;constructor(t){this.props={...t},this.loadOptions={...t.loadOptions},this.fetch=bi(this.loadOptions)}setProps(t){this.props=Object.assign(this.props,t),this.setNeedsRefresh()}setNeedsRefresh(){this._needsRefresh=!0}getNeedsRefresh(t=!0){let n=this._needsRefresh;return t&&(this._needsRefresh=!1),n}};function bi(e){let t=e?.fetch;if(t&&typeof t=="function")return(i,r)=>t(i,r);let n=e?.fetch;return n&&typeof n!="function"?i=>fetch(i,n):i=>fetch(i)}var Ot="4.2.1";var Li=globalThis.loaders?.parseImageNode,Je=typeof Image<"u",We=typeof ImageBitmap<"u",Ci=Boolean(Li),Ye=Ze?!0:Ci;function Nt(e){switch(e){case"auto":return We||Je||Ye;case"imagebitmap":return We;case"image":return Je;case"data":return Ye;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}function kt(){if(We)return"imagebitmap";if(Je)return"image";if(Ye)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function Oi(e){let t=Ni(e);if(!t)throw new Error("Not an image");return t}function Ut(e){switch(Oi(e)){case"data":return e;case"image":case"imagebitmap":let t=document.createElement("canvas"),n=t.getContext("2d");if(!n)throw new Error("getImageData");return t.width=e.width,t.height=e.height,n.drawImage(e,0,0),n.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}function Ni(e){return typeof ImageBitmap<"u"&&e instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&e instanceof Image?"image":e&&typeof e=="object"&&e.data&&e.width&&e.height?"data":null}var ki=/^data:image\/svg\+xml/,Ui=/\.svg((\?|#).*)?$/;function xe(e){return e&&(ki.test(e)||Ui.test(e))}function Gt(e,t){if(xe(t)){let i=new TextDecoder().decode(e);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(i=unescape(encodeURIComponent(i)))}catch(o){throw new Error(o.message)}return`data:image/svg+xml;base64,${btoa(i)}`}return Xe(e,t)}function Xe(e,t){if(xe(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function ye(e,t,n){let i=Gt(e,n),r=self.URL||self.webkitURL,o=typeof i!="string"&&r.createObjectURL(i);try{return await Gi(o||i,t)}finally{o&&r.revokeObjectURL(o)}}async function Gi(e,t){let n=new Image;return n.src=e,t.image&&t.image.decode&&n.decode?(await n.decode(),n):await new Promise((i,r)=>{try{n.onload=()=>i(n),n.onerror=o=>{let s=o instanceof Error?o.message:"error";r(new Error(s))}}catch(o){r(o)}})}var Ri={},Rt=!0;async function jt(e,t,n){let i;xe(n)?i=await ye(e,t,n):i=Xe(e,n);let r=t&&t.imagebitmap;return await ji(i,r)}async function ji(e,t=null){if((Zi(t)||!Rt)&&(t=null),t)try{return await createImageBitmap(e,t)}catch(n){console.warn(n),Rt=!1}return await createImageBitmap(e)}function Zi(e){for(let t in e||Ri)return!1;return!0}function Zt(e){return!Yi(e,"ftyp",4)||!(e[8]&96)?null:zi(e)}function zi(e){switch(Ji(e,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function Ji(e,t,n){return String.fromCharCode(...e.slice(t,n))}function Wi(e){return[...e].map(t=>t.charCodeAt(0))}function Yi(e,t,n=0){let i=Wi(t);for(let r=0;r<i.length;++r)if(i[r]!==e[r+n])return!1;return!0}var E=!1,q=!0;function k(e){let t=ee(e);return $i(t)||Qi(t)||Hi(t)||Ki(t)||Xi(t)}function Xi(e){let t=new Uint8Array(e instanceof DataView?e.buffer:e),n=Zt(t);return n?{mimeType:n.mimeType,width:0,height:0}:null}function $i(e){let t=ee(e);return t.byteLength>=24&&t.getUint32(0,E)===2303741511?{mimeType:"image/png",width:t.getUint32(16,E),height:t.getUint32(20,E)}:null}function Hi(e){let t=ee(e);return t.byteLength>=10&&t.getUint32(0,E)===1195984440?{mimeType:"image/gif",width:t.getUint16(6,q),height:t.getUint16(8,q)}:null}function Ki(e){let t=ee(e);return t.byteLength>=14&&t.getUint16(0,E)===16973&&t.getUint32(2,q)===t.byteLength?{mimeType:"image/bmp",width:t.getUint32(18,q),height:t.getUint32(22,q)}:null}function Qi(e){let t=ee(e);if(!(t.byteLength>=3&&t.getUint16(0,E)===65496&&t.getUint8(2)===255))return null;let{tableMarkers:i,sofMarkers:r}=qi(),o=2;for(;o+9<t.byteLength;){let s=t.getUint16(o,E);if(r.has(s))return{mimeType:"image/jpeg",height:t.getUint16(o+5,E),width:t.getUint16(o+7,E)};if(!i.has(s))return null;o+=2,o+=t.getUint16(o,E)}return null}function qi(){let e=new Set([65499,65476,65484,65501,65534]);for(let n=65504;n<65520;++n)e.add(n);return{tableMarkers:e,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function ee(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}async function zt(e,t){let{mimeType:n}=k(e)||{},i=globalThis.loaders?.parseImageNode;return K(i),await i(e,n)}async function Jt(e,t,n){t=t||{};let r=(t.image||{}).type||"auto",{url:o}=n||{},s=er(r),a;switch(s){case"imagebitmap":a=await jt(e,t,o);break;case"image":a=await ye(e,t,o);break;case"data":a=await zt(e,t);break;default:K(!1)}return r==="data"&&(a=Ut(a)),a}function er(e){switch(e){case"auto":case"data":return kt();default:return Nt(e),e}}var tr=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],nr=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],ir={image:{type:"auto",decode:!0}},$e={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:Ot,mimeTypes:nr,extensions:tr,parse:Jt,tests:[e=>Boolean(k(new DataView(e)))],options:ir};var we=class extends Q{props;url;metadataUrl=null;data;schema="tms";metadata;extension;mimeType=null;constructor(t){super(t),this.props=t,this.url=ze(t.url),this.metadataUrl=t.metadataUrl===void 0?`${this.url}/tilejson.json`:t.metadataUrl,this.extension=t.extension||".png",this.data=this.url,this.getTileData=this.getTileData.bind(this),this.metadata=this.getMetadata(),rr(this.url)&&(this.schema="template")}async getMetadata(){if(!this.metadataUrl)return null;let t;try{t=await this.fetch(this.metadataUrl)}catch(r){return console.error(r.message),null}if(!t.ok)return console.error(t.statusText),null;let n=await t.text();return Z.parseTextSync?.(n)||null}getTileMIMEType(){return this.mimeType}async getTile(t){let{x:n,y:i,zoom:r}=t,o=this.getTileURL(n,i,r),s=await this.fetch(o);return s.ok?await s.arrayBuffer():null}async getTileData(t){let{x:n,y:i,z:r}=t.index,o=await this.getTile({x:n,y:i,zoom:r,layers:[]});if(o===null)return null;let s=k(o);switch(this.mimeType=this.mimeType||s?.mimeType||"application/vnd.mapbox-vector-tile",this.mimeType){case"application/vnd.mapbox-vector-tile":return await this._parseVectorTile(o,{x:n,y:i,zoom:r,layers:[]});default:return await this._parseImageTile(o)}}async getImageTile(t){let n=await this.getTile(t);return n?this._parseImageTile(n):null}async _parseImageTile(t){return await $e.parse(t,this.loadOptions)}async getVectorTile(t){let n=await this.getTile(t);return n?this._parseVectorTile(n,t):null}async _parseVectorTile(t,n){let i={shape:"geojson-table",mvt:{coordinates:"wgs84",tileIndex:{x:n.x,y:n.y,z:n.zoom},...this.loadOptions?.mvt},...this.loadOptions};return await me.parse(t,i)}getMetadataUrl(){return this.metadataUrl}getTileURL(t,n,i){switch(this.schema){case"xyz":return`${this.url}/${t}/${n}/${i}${this.extension}`;case"tms":return`${this.url}/${i}/${t}/${n}${this.extension}`;case"template":return lr(this.url,t,n,i,"0");default:throw new Error(this.schema)}}};function rr(e){return/(?=.*{z})(?=.*{x})(?=.*({y}|{-y}))|(?=.*{x})(?=.*({y}|{-y})(?=.*{z}))/.test(e)}var or=new RegExp("{x}","g"),sr=new RegExp("{y}","g"),ar=new RegExp("{z}","g");function lr(e,t,n,i,r="0"){if(Array.isArray(e)){let s=fr(r)%e.length;e=e[s]}let o=e;return o=o.replace(or,String(t)),o=o.replace(sr,String(n)),o=o.replace(ar,String(i)),Number.isInteger(n)&&Number.isInteger(i)&&(o=o.replace(/\{-y\}/g,String(Math.pow(2,i)-n-1))),o}function fr(e){return Math.abs(e.split("").reduce((t,n)=>(t<<5)-t+n.charCodeAt(0)|0,0))}function Pe(e,t,n,i){let r=i,o=n-t>>1,s=n-t,a,l=e[t],f=e[t+1],c=e[n],u=e[n+1];for(let p=t+3;p<n;p+=3){let h=cr(e[p],e[p+1],l,f,c,u);if(h>r)a=p,r=h;else if(h===r){let d=Math.abs(p-o);d<s&&(a=p,s=d)}}r>i&&(a-t>3&&Pe(e,t,a,i),e[a+2]=r,n-a>3&&Pe(e,a,n,i))}function cr(e,t,n,i,r,o){let s=r-n,a=o-i;if(s!==0||a!==0){let l=((e-n)*s+(t-i)*a)/(s*s+a*a);l>1?(n=r,i=o):l>0&&(n+=s*l,i+=a*l)}return s=e-n,a=t-i,s*s+a*a}function L(e,t,n,i){let r={id:e??null,type:t,geometry:n,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(t==="Point"||t==="MultiPoint"||t==="LineString")Fe(r,n);else if(t==="Polygon")Fe(r,n[0]);else if(t==="MultiLineString")for(let o of n)Fe(r,o);else if(t==="MultiPolygon")for(let o of n)Fe(r,o[0]);return r}function Fe(e,t){for(let n=0;n<t.length;n+=3)e.minX=Math.min(e.minX,t[n]),e.minY=Math.min(e.minY,t[n+1]),e.maxX=Math.max(e.maxX,t[n]),e.maxY=Math.max(e.maxY,t[n+1])}function Yt(e,t){let n=[];if(e.type==="FeatureCollection")for(let i=0;i<e.features.length;i++)Ie(n,e.features[i],t,i);else e.type==="Feature"?Ie(n,e,t):Ie(n,{geometry:e},t);return n}function Ie(e,t,n,i){if(!t.geometry)return;let r=t.geometry.coordinates,o=t.geometry.type,s=Math.pow(n.tolerance/((1<<n.maxZoom)*n.extent),2),a=[],l=t.id;if(n.promoteId?l=t.properties[n.promoteId]:n.generateId&&(l=i||0),o==="Point")Wt(r,a);else if(o==="MultiPoint")for(let f of r)Wt(f,a);else if(o==="LineString")Ke(r,a,s,!1);else if(o==="MultiLineString")if(n.lineMetrics){for(let f of r)a=[],Ke(f,a,s,!1),e.push(L(l,"LineString",a,t.properties));return}else He(r,a,s,!1);else if(o==="Polygon")He(r,a,s,!0);else if(o==="MultiPolygon")for(let f of r){let c=[];He(f,c,s,!0),a.push(c)}else if(o==="GeometryCollection"){for(let f of t.geometry.geometries)Ie(e,{id:l,geometry:f,properties:t.properties},n,i);return}else throw new Error("Input data is not a valid GeoJSON object.");e.push(L(l,o,a,t.properties))}function Wt(e,t){t.push(Xt(e[0]),$t(e[1]),0)}function Ke(e,t,n,i){let r,o,s=0;for(let l=0;l<e.length;l++){let f=Xt(e[l][0]),c=$t(e[l][1]);t.push(f,c,0),l>0&&(i?s+=(r*c-f*o)/2:s+=Math.sqrt(Math.pow(f-r,2)+Math.pow(c-o,2))),r=f,o=c}let a=t.length-3;t[2]=1,Pe(t,0,a,n),t[a+2]=1,t.size=Math.abs(s),t.start=0,t.end=t.size}function He(e,t,n,i){for(let r=0;r<e.length;r++){let o=[];Ke(e[r],o,n,i),t.push(o)}}function Xt(e){return e/360+.5}function $t(e){let t=Math.sin(e*Math.PI/180),n=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return n<0?0:n>1?1:n}function B(e,t,n,i,r,o,s,a){if(n/=t,i/=t,o>=n&&s<i)return e;if(s<n||o>=i)return null;let l=[];for(let f of e){let c=f.geometry,u=f.type,p=r===0?f.minX:f.minY,h=r===0?f.maxX:f.maxY;if(p>=n&&h<i){l.push(f);continue}else if(h<n||p>=i)continue;let d=[];if(u==="Point"||u==="MultiPoint")ur(c,d,n,i,r);else if(u==="LineString")Kt(c,d,n,i,r,!1,a.lineMetrics);else if(u==="MultiLineString")Qe(c,d,n,i,r,!1);else if(u==="Polygon")Qe(c,d,n,i,r,!0);else if(u==="MultiPolygon")for(let x of c){let w=[];Qe(x,w,n,i,r,!0),w.length&&d.push(w)}if(d.length){if(a.lineMetrics&&u==="LineString"){for(let x of d)l.push(L(f.id,u,x,f.tags));continue}(u==="LineString"||u==="MultiLineString")&&(d.length===1?(u="LineString",d=d[0]):u="MultiLineString"),(u==="Point"||u==="MultiPoint")&&(u=d.length===3?"Point":"MultiPoint"),l.push(L(f.id,u,d,f.tags))}}return l.length?l:null}function ur(e,t,n,i,r){for(let o=0;o<e.length;o+=3){let s=e[o+r];s>=n&&s<=i&&z(t,e[o],e[o+1],e[o+2])}}function Kt(e,t,n,i,r,o,s){let a=Ht(e),l=r===0?hr:pr,f=e.start,c,u;for(let I=0;I<e.length-3;I+=3){let _=e[I],g=e[I+1],m=e[I+2],v=e[I+3],F=e[I+4],T=r===0?_:g,S=r===0?v:F,M=!1;s&&(c=Math.sqrt(Math.pow(_-v,2)+Math.pow(g-F,2))),T<n?S>n&&(u=l(a,_,g,v,F,n),s&&(a.start=f+c*u)):T>i?S<i&&(u=l(a,_,g,v,F,i),s&&(a.start=f+c*u)):z(a,_,g,m),S<n&&T>=n&&(u=l(a,_,g,v,F,n),M=!0),S>i&&T<=i&&(u=l(a,_,g,v,F,i),M=!0),!o&&M&&(s&&(a.end=f+c*u),t.push(a),a=Ht(e)),s&&(f+=c)}let p=e.length-3,h=e[p],d=e[p+1],x=e[p+2],w=r===0?h:d;w>=n&&w<=i&&z(a,h,d,x),p=a.length-3,o&&p>=3&&(a[p]!==a[0]||a[p+1]!==a[1])&&z(a,a[0],a[1],a[2]),a.length&&t.push(a)}function Ht(e){let t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function Qe(e,t,n,i,r,o){for(let s of e)Kt(s,t,n,i,r,o,!1)}function z(e,t,n,i){e.push(t,n,i)}function hr(e,t,n,i,r,o){let s=(o-t)/(i-t);return z(e,o,n+(r-n)*s,1),s}function pr(e,t,n,i,r,o){let s=(o-n)/(r-n);return z(e,t+(i-t)*s,o,1),s}function qt(e,t){let n=t.buffer/t.extent,i=e,r=B(e,1,-1-n,n,0,-1,2,t),o=B(e,1,1-n,2+n,0,-1,2,t);return(r||o)&&(i=B(e,1,-n,1+n,0,-1,2,t)||[],r&&(i=Qt(r,1).concat(i)),o&&(i=i.concat(Qt(o,-1)))),i}function Qt(e,t){let n=[];for(let i=0;i<e.length;i++){let r=e[i],o=r.type,s;if(o==="Point"||o==="MultiPoint"||o==="LineString")s=qe(r.geometry,t);else if(o==="MultiLineString"||o==="Polygon"){s=[];for(let a of r.geometry)s.push(qe(a,t))}else if(o==="MultiPolygon"){s=[];for(let a of r.geometry){let l=[];for(let f of a)l.push(qe(f,t));s.push(l)}}n.push(L(r.id,o,s,r.tags))}return n}function qe(e,t){let n=[];n.size=e.size,e.start!==void 0&&(n.start=e.start,n.end=e.end);for(let i=0;i<e.length;i+=3)n.push(e[i]+t,e[i+1],e[i+2]);return n}function et(e,t){if(e.transformed)return e;let n=1<<e.z,i=e.x,r=e.y;for(let o of e.features){let s=o.geometry,a=o.type;if(o.geometry=[],a===1)for(let l=0;l<s.length;l+=2)o.geometry.push(en(s[l],s[l+1],t,n,i,r));else for(let l=0;l<s.length;l++){let f=[];for(let c=0;c<s[l].length;c+=2)f.push(en(s[l][c],s[l][c+1],t,n,i,r));o.geometry.push(f)}}return e.transformed=!0,e}function en(e,t,n,i,r,o){return[Math.round(n*(e*i-r)),Math.round(n*(t*i-o))]}function tn(e,t,n,i,r){let o=t===r.maxZoom?0:r.tolerance/((1<<t)*r.extent),s={features:[],numPoints:0,numSimplified:0,numFeatures:e.length,source:null,x:n,y:i,z:t,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(let a of e)dr(s,a,o,r);return s}function dr(e,t,n,i){let r=t.geometry,o=t.type,s=[];if(e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),o==="Point"||o==="MultiPoint")for(let a=0;a<r.length;a+=3)s.push(r[a],r[a+1]),e.numPoints++,e.numSimplified++;else if(o==="LineString")tt(s,r,e,n,!1,!1);else if(o==="MultiLineString"||o==="Polygon")for(let a=0;a<r.length;a++)tt(s,r[a],e,n,o==="Polygon",a===0);else if(o==="MultiPolygon")for(let a=0;a<r.length;a++){let l=r[a];for(let f=0;f<l.length;f++)tt(s,l[f],e,n,!0,f===0)}if(s.length){let a=t.tags||null;if(o==="LineString"&&i.lineMetrics){a={};for(let f in t.tags)a[f]=t.tags[f];a.mapbox_clip_start=r.start/r.size,a.mapbox_clip_end=r.end/r.size}let l={geometry:s,type:o==="Polygon"||o==="MultiPolygon"?3:o==="LineString"||o==="MultiLineString"?2:1,tags:a};t.id!==null&&(l.id=t.id),e.features.push(l)}}function tt(e,t,n,i,r,o){let s=i*i;if(i>0&&t.size<(r?s:i)){n.numPoints+=t.length/3;return}let a=[];for(let l=0;l<t.length;l+=3)(i===0||t[l+2]>s)&&(n.numSimplified++,a.push(t[l],t[l+1])),n.numPoints++;r&&gr(a,o),e.push(a)}function gr(e,t){let n=0;for(let i=0,r=e.length-2;i<e.length;r=i,i+=2)n+=(e[i]-e[r])*(e[i+1]+e[r+1]);if(n>0===t)for(let i=0,r=e.length;i<r/2;i+=2){let o=e[i],s=e[i+1];e[i]=e[r-2-i],e[i+1]=e[r-1-i],e[r-2-i]=o,e[r-1-i]=s}}var mr={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:void 0,generateId:!1,debug:0},ve=class{options;tiles={};tileCoords=[];stats={};total=0;constructor(t,n){this.options={...mr,...n},n=this.options;let i=n.debug;if(i&&console.time("preprocess data"),this.options.maxZoom<0||this.options.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(n.promoteId&&this.options.generateId)throw new Error("promoteId and generateId cannot be used together.");let r=Yt(t,n);i&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",n.indexMaxZoom,n.indexMaxPoints),console.time("generate tiles")),r=qt(r,this.options),r.length&&this.splitTile(r,0,0,0),i&&(r.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}getTile(t,n,i){let{extent:r,debug:o}=this.options;if(t<0||t>24)return null;let s=1<<t;n=n+s&s-1;let a=nt(t,n,i);if(this.tiles[a])return et(this.tiles[a],r);o>1&&console.log("drilling down to z%d-%d-%d",t,n,i);let l=t,f=n,c=i,u;for(;!u&&l>0;)l--,f=f>>1,c=c>>1,u=this.tiles[nt(l,f,c)];return!u||!u.source?null:(o>1&&(console.log("found parent tile z%d-%d-%d",l,f,c),console.time("drilling down")),this.splitTile(u.source,l,f,c,t,n,i),o>1&&console.timeEnd("drilling down"),this.tiles[a]?et(this.tiles[a],r):null)}splitTile(t,n,i,r,o,s,a){let l=[t,n,i,r],f=this.options,c=f.debug;for(;l.length;){r=l.pop(),i=l.pop(),n=l.pop(),t=l.pop();let u=1<<n,p=nt(n,i,r),h=this.tiles[p];if(!h&&(c>1&&console.time("creation"),h=this.tiles[p]=tn(t,n,i,r,f),this.tileCoords.push({z:n,x:i,y:r}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",n,i,r,h.numFeatures,h.numPoints,h.numSimplified),console.timeEnd("creation"));let S=`z${n}`;this.stats[S]=(this.stats[S]||0)+1,this.total++}if(h.source=t,o===void 0){if(n===f.indexMaxZoom||h.numPoints<=f.indexMaxPoints)continue}else{if(n===f.maxZoom||n===o)continue;if(o!==void 0){let S=o-n;if(i!==s>>S||r!==a>>S)continue}}if(h.source=null,t.length===0)continue;c>1&&console.time("clipping");let d=.5*f.buffer/f.extent,x=.5-d,w=.5+d,I=1+d,_=null,g=null,m=null,v=null,F=B(t,u,i-d,i+w,0,h.minX,h.maxX,f),T=B(t,u,i+x,i+I,0,h.minX,h.maxX,f);t=null,F&&(_=B(F,u,r-d,r+w,1,h.minY,h.maxY,f),g=B(F,u,r+x,r+I,1,h.minY,h.maxY,f),F=null),T&&(m=B(T,u,r-d,r+w,1,h.minY,h.maxY,f),v=B(T,u,r+x,r+I,1,h.minY,h.maxY,f),T=null),c>1&&console.timeEnd("clipping"),l.push(_||[],n+1,i*2,r*2),l.push(g||[],n+1,i*2,r*2+1),l.push(m||[],n+1,i*2+1,r*2),l.push(v||[],n+1,i*2+1,r*2+1)}}};function nt(e,t,n){return((1<<e)*n+t)*32+e}return fn(te);})();
7
+ "use strict";var __exports__=(()=>{var nn=Object.create;var ie=Object.defineProperty;var rn=Object.getOwnPropertyDescriptor;var on=Object.getOwnPropertyNames;var sn=Object.getPrototypeOf,an=Object.prototype.hasOwnProperty;var Te=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ln=(e,t)=>{for(var n in t)ie(e,n,{get:t[n],enumerable:!0})},ne=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of on(t))!an.call(e,r)&&r!==n&&ie(e,r,{get:()=>t[r],enumerable:!(i=rn(t,r))||i.enumerable});return e},re=(e,t,n)=>(ne(e,t,"default"),n&&ne(n,t,"default")),it=(e,t,n)=>(n=e!=null?nn(sn(e)):{},ne(t||!e||!e.__esModule?ie(n,"default",{value:e,enumerable:!0}):n,e)),fn=e=>ne(ie({},"__esModule",{value:!0}),e);var ot=Te((yr,rt)=>{rt.exports=globalThis.loaders});var ht=Te(be=>{be.read=function(e,t,n,i,r){var o,s,a=r*8-i-1,l=(1<<a)-1,f=l>>1,c=-7,u=n?r-1:0,p=n?-1:1,h=e[t+u];for(u+=p,o=h&(1<<-c)-1,h>>=-c,c+=a;c>0;o=o*256+e[t+u],u+=p,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=i;c>0;s=s*256+e[t+u],u+=p,c-=8);if(o===0)o=1-f;else{if(o===l)return s?NaN:(h?-1:1)*(1/0);s=s+Math.pow(2,i),o=o-f}return(h?-1:1)*s*Math.pow(2,o-i)};be.write=function(e,t,n,i,r,o){var s,a,l,f=o*8-r-1,c=(1<<f)-1,u=c>>1,p=r===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=i?0:o-1,d=i?1:-1,x=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),s+u>=1?t+=p/l:t+=p*Math.pow(2,1-u),t*l>=2&&(s++,l/=2),s+u>=c?(a=0,s=c):s+u>=1?(a=(t*l-1)*Math.pow(2,r),s=s+u):(a=t*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;e[n+h]=a&255,h+=d,a/=256,r-=8);for(s=s<<r|a,f+=r;f>0;e[n+h]=s&255,h+=d,s/=256,f-=8);e[n+h-d]|=x*128}});var yt=Te((po,xt)=>{"use strict";xt.exports=y;var le=ht();function y(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}y.Varint=0;y.Fixed64=1;y.Bytes=2;y.Fixed32=5;var Le=(1<<16)*(1<<16),pt=1/Le,Un=12,mt=typeof TextDecoder>"u"?null:new TextDecoder("utf8");y.prototype={destroy:function(){this.buf=null},readFields:function(e,t,n){for(n=n||this.length;this.pos<n;){var i=this.readVarint(),r=i>>3,o=this.pos;this.type=i&7,e(r,t,this),this.pos===o&&this.skip(i)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=fe(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=gt(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=fe(this.buf,this.pos)+fe(this.buf,this.pos+4)*Le;return this.pos+=8,e},readSFixed64:function(){var e=fe(this.buf,this.pos)+gt(this.buf,this.pos+4)*Le;return this.pos+=8,e},readFloat:function(){var e=le.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=le.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t=this.buf,n,i;return i=t[this.pos++],n=i&127,i<128||(i=t[this.pos++],n|=(i&127)<<7,i<128)||(i=t[this.pos++],n|=(i&127)<<14,i<128)||(i=t[this.pos++],n|=(i&127)<<21,i<128)?n:(i=t[this.pos],n|=(i&15)<<28,Gn(n,e,this))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2===1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=Un&&mt?ei(this.buf,t,e):qn(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==y.Bytes)return e.push(this.readVarint(t));var n=D(this);for(e=e||[];this.pos<n;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==y.Bytes)return e.push(this.readSVarint());var t=D(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){if(this.type!==y.Bytes)return e.push(this.readBoolean());var t=D(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){if(this.type!==y.Bytes)return e.push(this.readFloat());var t=D(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){if(this.type!==y.Bytes)return e.push(this.readDouble());var t=D(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){if(this.type!==y.Bytes)return e.push(this.readFixed32());var t=D(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){if(this.type!==y.Bytes)return e.push(this.readSFixed32());var t=D(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){if(this.type!==y.Bytes)return e.push(this.readFixed64());var t=D(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){if(this.type!==y.Bytes)return e.push(this.readSFixed64());var t=D(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var t=e&7;if(t===y.Varint)for(;this.buf[this.pos++]>127;);else if(t===y.Bytes)this.pos=this.readVarint()+this.pos;else if(t===y.Fixed32)this.pos+=4;else if(t===y.Fixed64)this.pos+=8;else throw new Error("Unimplemented type: "+t)},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t<this.pos+e;)t*=2;if(t!==this.length){var n=new Uint8Array(t);n.set(this.buf),this.buf=n,this.length=t}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(e){this.realloc(4),R(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),R(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),R(this.buf,e&-1,this.pos),R(this.buf,Math.floor(e*pt),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),R(this.buf,e&-1,this.pos),R(this.buf,Math.floor(e*pt),this.pos+4),this.pos+=8},writeVarint:function(e){if(e=+e||0,e>268435455||e<0){Rn(e,this);return}this.realloc(4),this.buf[this.pos++]=e&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=e>>>7&127)))},writeSVarint:function(e){this.writeVarint(e<0?-e*2-1:e*2)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(e.length*4),this.pos++;var t=this.pos;this.pos=ti(this.buf,e,this.pos);var n=this.pos-t;n>=128&&dt(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n},writeFloat:function(e){this.realloc(4),le.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),le.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var n=0;n<t;n++)this.buf[this.pos++]=e[n]},writeRawMessage:function(e,t){this.pos++;var n=this.pos;e(t,this);var i=this.pos-n;i>=128&&dt(n,i,this),this.pos=n-1,this.writeVarint(i),this.pos+=i},writeMessage:function(e,t,n){this.writeTag(e,y.Bytes),this.writeRawMessage(t,n)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,zn,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,Jn,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,Xn,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,Wn,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,Yn,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,$n,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,Hn,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,Kn,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,Qn,t)},writeBytesField:function(e,t){this.writeTag(e,y.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,y.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,y.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,y.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,y.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,y.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,y.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,y.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,y.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,y.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};function Gn(e,t,n){var i=n.buf,r,o;if(o=i[n.pos++],r=(o&112)>>4,o<128||(o=i[n.pos++],r|=(o&127)<<3,o<128)||(o=i[n.pos++],r|=(o&127)<<10,o<128)||(o=i[n.pos++],r|=(o&127)<<17,o<128)||(o=i[n.pos++],r|=(o&127)<<24,o<128)||(o=i[n.pos++],r|=(o&1)<<31,o<128))return G(e,r,t);throw new Error("Expected varint not more than 10 bytes")}function D(e){return e.type===y.Bytes?e.readVarint()+e.pos:e.pos+1}function G(e,t,n){return n?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function Rn(e,t){var n,i;if(e>=0?(n=e%4294967296|0,i=e/4294967296|0):(n=~(-e%4294967296),i=~(-e/4294967296),n^4294967295?n=n+1|0:(n=0,i=i+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),jn(n,i,t),Zn(i,t)}function jn(e,t,n){n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos]=e&127}function Zn(e,t){var n=(e&7)<<4;t.buf[t.pos++]|=n|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127)))))}function dt(e,t,n){var i=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(Math.LN2*7));n.realloc(i);for(var r=n.pos-1;r>=e;r--)n.buf[r+i]=n.buf[r]}function zn(e,t){for(var n=0;n<e.length;n++)t.writeVarint(e[n])}function Jn(e,t){for(var n=0;n<e.length;n++)t.writeSVarint(e[n])}function Wn(e,t){for(var n=0;n<e.length;n++)t.writeFloat(e[n])}function Yn(e,t){for(var n=0;n<e.length;n++)t.writeDouble(e[n])}function Xn(e,t){for(var n=0;n<e.length;n++)t.writeBoolean(e[n])}function $n(e,t){for(var n=0;n<e.length;n++)t.writeFixed32(e[n])}function Hn(e,t){for(var n=0;n<e.length;n++)t.writeSFixed32(e[n])}function Kn(e,t){for(var n=0;n<e.length;n++)t.writeFixed64(e[n])}function Qn(e,t){for(var n=0;n<e.length;n++)t.writeSFixed64(e[n])}function fe(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+e[t+3]*16777216}function R(e,t,n){e[n]=t,e[n+1]=t>>>8,e[n+2]=t>>>16,e[n+3]=t>>>24}function gt(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}function qn(e,t,n){for(var i="",r=t;r<n;){var o=e[r],s=null,a=o>239?4:o>223?3:o>191?2:1;if(r+a>n)break;var l,f,c;a===1?o<128&&(s=o):a===2?(l=e[r+1],(l&192)===128&&(s=(o&31)<<6|l&63,s<=127&&(s=null))):a===3?(l=e[r+1],f=e[r+2],(l&192)===128&&(f&192)===128&&(s=(o&15)<<12|(l&63)<<6|f&63,(s<=2047||s>=55296&&s<=57343)&&(s=null))):a===4&&(l=e[r+1],f=e[r+2],c=e[r+3],(l&192)===128&&(f&192)===128&&(c&192)===128&&(s=(o&15)<<18|(l&63)<<12|(f&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),r+=a}return i}function ei(e,t,n){return mt.decode(e.subarray(t,n))}function ti(e,t,n){for(var i=0,r,o;i<t.length;i++){if(r=t.charCodeAt(i),r>55295&&r<57344)if(o)if(r<56320){e[n++]=239,e[n++]=191,e[n++]=189,o=r;continue}else r=o-55296<<10|r-56320|65536,o=null;else{r>56319||i+1===t.length?(e[n++]=239,e[n++]=191,e[n++]=189):o=r;continue}else o&&(e[n++]=239,e[n++]=191,e[n++]=189,o=null);r<128?e[n++]=r:(r<2048?e[n++]=r>>6|192:(r<65536?e[n++]=r>>12|224:(e[n++]=r>>18|240,e[n++]=r>>12&63|128),e[n++]=r>>6&63|128),e[n++]=r&63|128)}return n}});var te={};ln(te,{GeoJSONTiler:()=>ve,MVTLoader:()=>me,MVTSource:()=>we,MVTWorkerLoader:()=>Re,TileJSONLoader:()=>Z});re(te,it(ot(),1));function b(e){return b=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},b(e)}function Se(e,t){if(b(e)!=="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,t||"default");if(b(i)!=="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function _e(e){var t=Se(e,"string");return b(t)==="symbol"?t:String(t)}function V(e,t,n){return t=_e(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var J={x:0,y:1,z:2};function C(e,t={}){let{start:n=0,end:i=e.length,plane:r="xy"}=t,o=t.size||2,s=0,a=J[r[0]],l=J[r[1]];for(let f=n,c=i-o;f<i;f+=o)s+=(e[f+a]-e[c+a])*(e[f+l]+e[c+l]),c=f;return s/2}function Ve(e,t,n=2,i,r="xy"){let o=t&&t.length,s=o?t[0]*n:e.length,a=at(e,0,s,n,!0,i&&i[0],r),l=[];if(!a||a.next===a.prev)return l;let f,c,u,p,h,d,x;if(o&&(a=mn(e,t,a,n,i,r)),e.length>80*n){p=c=e[0],h=u=e[1];for(let w=n;w<s;w+=n)d=e[w],x=e[w+1],d<p&&(p=d),x<h&&(h=x),d>c&&(c=d),x>u&&(u=x);f=Math.max(c-p,u-h),f=f!==0?32767/f:0}return W(a,l,n,p,h,f,0),l}function at(e,t,n,i,r,o,s){let a,l;o===void 0&&(o=C(e,{start:t,end:n,size:i,plane:s}));let f=J[s[0]],c=J[s[1]];if(r===o<0)for(a=t;a<n;a+=i)l=st(a,e[a+f],e[a+c],l);else for(a=n-i;a>=t;a-=i)l=st(a,e[a+f],e[a+c],l);return l&&ae(l,l.next)&&(X(l),l=l.next),l}function O(e,t){if(!e)return e;t||(t=e);let n=e,i;do if(i=!1,!n.steiner&&(ae(n,n.next)||P(n.prev,n,n.next)===0)){if(X(n),n=t=n.prev,n===n.next)break;i=!0}else n=n.next;while(i||n!==t);return t}function W(e,t,n,i,r,o,s){if(!e)return;!s&&o&&Fn(e,i,r,o);let a=e,l,f;for(;e.prev!==e.next;){if(l=e.prev,f=e.next,o?pn(e,i,r,o):hn(e)){t.push(l.i/n|0),t.push(e.i/n|0),t.push(f.i/n|0),X(e),e=f.next,a=f.next;continue}if(e=f,e===a){s?s===1?(e=dn(O(e),t,n),W(e,t,n,i,r,o,2)):s===2&&gn(e,t,n,i,r,o):W(O(e),t,n,i,r,o,1);break}}}function hn(e){let t=e.prev,n=e,i=e.next;if(P(t,n,i)>=0)return!1;let r=t.x,o=n.x,s=i.x,a=t.y,l=n.y,f=i.y,c=r<o?r<s?r:s:o<s?o:s,u=a<l?a<f?a:f:l<f?l:f,p=r>o?r>s?r:s:o>s?o:s,h=a>l?a>f?a:f:l>f?l:f,d=i.next;for(;d!==t;){if(d.x>=c&&d.x<=p&&d.y>=u&&d.y<=h&&U(r,a,o,l,s,f,d.x,d.y)&&P(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function pn(e,t,n,i){let r=e.prev,o=e,s=e.next;if(P(r,o,s)>=0)return!1;let a=r.x,l=o.x,f=s.x,c=r.y,u=o.y,p=s.y,h=a<l?a<f?a:f:l<f?l:f,d=c<u?c<p?c:p:u<p?u:p,x=a>l?a>f?a:f:l>f?l:f,w=c>u?c>p?c:p:u>p?u:p,I=Me(h,d,t,n,i),_=Me(x,w,t,n,i),g=e.prevZ,m=e.nextZ;for(;g&&g.z>=I&&m&&m.z<=_;){if(g.x>=h&&g.x<=x&&g.y>=d&&g.y<=w&&g!==r&&g!==s&&U(a,c,l,u,f,p,g.x,g.y)&&P(g.prev,g,g.next)>=0||(g=g.prevZ,m.x>=h&&m.x<=x&&m.y>=d&&m.y<=w&&m!==r&&m!==s&&U(a,c,l,u,f,p,m.x,m.y)&&P(m.prev,m,m.next)>=0))return!1;m=m.nextZ}for(;g&&g.z>=I;){if(g.x>=h&&g.x<=x&&g.y>=d&&g.y<=w&&g!==r&&g!==s&&U(a,c,l,u,f,p,g.x,g.y)&&P(g.prev,g,g.next)>=0)return!1;g=g.prevZ}for(;m&&m.z<=_;){if(m.x>=h&&m.x<=x&&m.y>=d&&m.y<=w&&m!==r&&m!==s&&U(a,c,l,u,f,p,m.x,m.y)&&P(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function dn(e,t,n){let i=e;do{let r=i.prev,o=i.next.next;!ae(r,o)&&lt(r,i,i.next,o)&&Y(r,o)&&Y(o,r)&&(t.push(r.i/n|0),t.push(i.i/n|0),t.push(o.i/n|0),X(i),X(i.next),i=e=o),i=i.next}while(i!==e);return O(i)}function gn(e,t,n,i,r,o){let s=e;do{let a=s.next.next;for(;a!==s.prev;){if(s.i!==a.i&&Tn(s,a)){let l=ft(s,a);s=O(s,s.next),l=O(l,l.next),W(s,t,n,i,r,o,0),W(l,t,n,i,r,o,0);return}a=a.next}s=s.next}while(s!==e)}function mn(e,t,n,i,r,o){let s=[],a,l,f,c,u;for(a=0,l=t.length;a<l;a++)f=t[a]*i,c=a<l-1?t[a+1]*i:e.length,u=at(e,f,c,i,!1,r&&r[a+1],o),u===u.next&&(u.steiner=!0),s.push(vn(u));for(s.sort(xn),a=0;a<s.length;a++)n=yn(s[a],n);return n}function xn(e,t){return e.x-t.x}function yn(e,t){let n=wn(e,t);if(!n)return t;let i=ft(n,e);return O(i,i.next),O(n,n.next)}function wn(e,t){let n=t,i=e.x,r=e.y,o=-1/0,s;do{if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){let p=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(p<=i&&p>o&&(o=p,s=n.x<n.next.x?n:n.next,p===i))return s}n=n.next}while(n!==t);if(!s)return null;let a=s,l=s.x,f=s.y,c=1/0,u;n=s;do i>=n.x&&n.x>=l&&i!==n.x&&U(r<f?i:o,r,l,f,r<f?o:i,r,n.x,n.y)&&(u=Math.abs(r-n.y)/(i-n.x),Y(n,e)&&(u<c||u===c&&(n.x>s.x||n.x===s.x&&Pn(s,n)))&&(s=n,c=u)),n=n.next;while(n!==a);return s}function Pn(e,t){return P(e.prev,e,t.prev)<0&&P(t.next,e,e.next)<0}function Fn(e,t,n,i){let r=e;do r.z===0&&(r.z=Me(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,In(r)}function In(e){let t,n,i=1,r,o,s,a,l,f;do{for(o=e,e=null,f=null,r=0;o;){for(r++,a=o,s=0,n=0;n<i&&(s++,a=a.nextZ,!!a);n++);for(l=i;s>0||l>0&&a;)s!==0&&(l===0||!a||o.z<=a.z)?(t=o,o=o.nextZ,s--):(t=a,a=a.nextZ,l--),f?f.nextZ=t:e=t,t.prevZ=f,f=t;o=a}f.nextZ=null,i*=2}while(r>1);return e}function Me(e,t,n,i,r){return e=(e-n)*r|0,t=(t-i)*r|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function vn(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function U(e,t,n,i,r,o,s,a){return(r-s)*(t-a)>=(e-s)*(o-a)&&(e-s)*(i-a)>=(n-s)*(t-a)&&(n-s)*(o-a)>=(r-s)*(i-a)}function Tn(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Sn(e,t)&&(Y(e,t)&&Y(t,e)&&_n(e,t)&&(P(e.prev,e,t.prev)||P(e,t.prev,t))||ae(e,t)&&P(e.prev,e,e.next)>0&&P(t.prev,t,t.next)>0)}function P(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function ae(e,t){return e.x===t.x&&e.y===t.y}function lt(e,t,n,i){let r=se(P(e,t,n)),o=se(P(e,t,i)),s=se(P(n,i,e)),a=se(P(n,i,t));return!!(r!==o&&s!==a||r===0&&oe(e,n,t)||o===0&&oe(e,i,t)||s===0&&oe(n,e,i)||a===0&&oe(n,t,i))}function oe(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function se(e){return e>0?1:e<0?-1:0}function Sn(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&lt(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Y(e,t){return P(e.prev,e,e.next)<0?P(e,t,e.next)>=0&&P(e,e.prev,t)>=0:P(e,t,e.prev)<0||P(e,e.next,t)<0}function _n(e,t){let n=e,i=!1,r=(e.x+t.x)/2,o=(e.y+t.y)/2;do n.y>o!=n.next.y>o&&n.next.y!==n.y&&r<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next;while(n!==e);return i}function ft(e,t){let n=new $(e.i,e.x,e.y),i=new $(t.i,t.x,t.y),r=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,o.next=i,i.prev=o,i}function st(e,t,n,i){let r=new $(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function X(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}var $=class{constructor(t,n,i){V(this,"i",void 0),V(this,"x",void 0),V(this,"y",void 0),V(this,"prev",null),V(this,"next",null),V(this,"z",0),V(this,"prevZ",null),V(this,"nextZ",null),V(this,"steiner",!1),this.i=t,this.x=n,this.y=i}};function Ee(e,t,n){let i=En(e),r=Object.keys(i).filter(o=>i[o]!==Array);return Dn(e,{propArrayTypes:i,...t},{numericPropKeys:n&&n.numericPropKeys||r,PositionDataType:n?n.PositionDataType:Float32Array,triangulate:n?n.triangulate:!0})}function En(e){let t={};for(let n of e)if(n.properties)for(let i in n.properties){let r=n.properties[i];t[i]=kn(r,t[i])}return t}function Dn(e,t,n){let{pointPositionsCount:i,pointFeaturesCount:r,linePositionsCount:o,linePathsCount:s,lineFeaturesCount:a,polygonPositionsCount:l,polygonObjectsCount:f,polygonRingsCount:c,polygonFeaturesCount:u,propArrayTypes:p,coordLength:h}=t,{numericPropKeys:d=[],PositionDataType:x=Float32Array,triangulate:w=!0}=n,I=e[0]&&"id"in e[0],_=e.length>65535?Uint32Array:Uint16Array,g={type:"Point",positions:new x(i*h),globalFeatureIds:new _(i),featureIds:r>65535?new Uint32Array(i):new Uint16Array(i),numericProps:{},properties:[],fields:[]},m={type:"LineString",pathIndices:o>65535?new Uint32Array(s+1):new Uint16Array(s+1),positions:new x(o*h),globalFeatureIds:new _(o),featureIds:a>65535?new Uint32Array(o):new Uint16Array(o),numericProps:{},properties:[],fields:[]},v={type:"Polygon",polygonIndices:l>65535?new Uint32Array(f+1):new Uint16Array(f+1),primitivePolygonIndices:l>65535?new Uint32Array(c+1):new Uint16Array(c+1),positions:new x(l*h),globalFeatureIds:new _(l),featureIds:u>65535?new Uint32Array(l):new Uint16Array(l),numericProps:{},properties:[],fields:[]};w&&(v.triangles=[]);for(let T of[g,m,v])for(let S of d){let M=p[S];T.numericProps[S]=new M(T.positions.length/h)}m.pathIndices[s]=o,v.polygonIndices[f]=l,v.primitivePolygonIndices[c]=l;let F={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(let T of e){let S=T.geometry,M=T.properties||{};switch(S.type){case"Point":bn(S,g,F,h,M),g.properties.push(Ae(M,d)),I&&g.fields.push({id:T.id}),F.pointFeature++;break;case"LineString":Ln(S,m,F,h,M),m.properties.push(Ae(M,d)),I&&m.fields.push({id:T.id}),F.lineFeature++;break;case"Polygon":Cn(S,v,F,h,M),v.properties.push(Ae(M,d)),I&&v.fields.push({id:T.id}),F.polygonFeature++;break;default:throw new Error("Invalid geometry type")}F.feature++}return Nn(g,m,v,h)}function bn(e,t,n,i,r){t.positions.set(e.data,n.pointPosition*i);let o=e.data.length/i;De(t,r,n.pointPosition,o),t.globalFeatureIds.fill(n.feature,n.pointPosition,n.pointPosition+o),t.featureIds.fill(n.pointFeature,n.pointPosition,n.pointPosition+o),n.pointPosition+=o}function Ln(e,t,n,i,r){t.positions.set(e.data,n.linePosition*i);let o=e.data.length/i;De(t,r,n.linePosition,o),t.globalFeatureIds.fill(n.feature,n.linePosition,n.linePosition+o),t.featureIds.fill(n.lineFeature,n.linePosition,n.linePosition+o);for(let s=0,a=e.indices.length;s<a;++s){let l=e.indices[s],f=s===a-1?e.data.length:e.indices[s+1];t.pathIndices[n.linePath++]=n.linePosition,n.linePosition+=(f-l)/i}}function Cn(e,t,n,i,r){t.positions.set(e.data,n.polygonPosition*i);let o=e.data.length/i;De(t,r,n.polygonPosition,o),t.globalFeatureIds.fill(n.feature,n.polygonPosition,n.polygonPosition+o),t.featureIds.fill(n.polygonFeature,n.polygonPosition,n.polygonPosition+o);for(let s=0,a=e.indices.length;s<a;++s){let l=n.polygonPosition;t.polygonIndices[n.polygonObject++]=l;let f=e.areas[s],c=e.indices[s],u=e.indices[s+1];for(let h=0,d=c.length;h<d;++h){let x=c[h],w=h===d-1?u===void 0?e.data.length:u[0]:c[h+1];t.primitivePolygonIndices[n.polygonRing++]=n.polygonPosition,n.polygonPosition+=(w-x)/i}let p=n.polygonPosition;On(t,f,c,{startPosition:l,endPosition:p,coordLength:i})}}function On(e,t,n,{startPosition:i,endPosition:r,coordLength:o}){if(!e.triangles)return;let s=i*o,a=r*o,l=e.positions.subarray(s,a),f=n[0],c=n.slice(1).map(p=>(p-f)/o),u=Ve(l,c,o,t);for(let p=0,h=u.length;p<h;++p)e.triangles.push(i+u[p])}function Be(e,t){let n={};for(let i in e)n[i]={value:e[i],size:t};return n}function Nn(e,t,n,i){let r={shape:"binary-feature-collection",points:{...e,positions:{value:e.positions,size:i},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},numericProps:Be(e.numericProps,1)},lines:{...t,positions:{value:t.positions,size:i},pathIndices:{value:t.pathIndices,size:1},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},numericProps:Be(t.numericProps,1)},polygons:{...n,positions:{value:n.positions,size:i},polygonIndices:{value:n.polygonIndices,size:1},primitivePolygonIndices:{value:n.primitivePolygonIndices,size:1},globalFeatureIds:{value:n.globalFeatureIds,size:1},featureIds:{value:n.featureIds,size:1},numericProps:Be(n.numericProps,1)}};return r.polygons&&n.triangles&&(r.polygons.triangles={value:new Uint32Array(n.triangles),size:1}),r}function De(e,t,n,i){for(let r in e.numericProps)if(r in t){let o=t[r];e.numericProps[r].fill(o,n,n+i)}}function Ae(e,t){let n={};for(let i in e)t.includes(i)||(n[i]=e[i]);return n}function kn(e,t){return t===Array||!Number.isFinite(e)?Array:t===Float64Array||Math.fround(e)!==e?Float64Array:Float32Array}var Ue=it(yt(),1);function wt(e){let t=e.length;if(t<=1)return[e];let n=[],i,r;for(let o=0;o<t;o++){let s=ni(e[o]);s!==0&&(r===void 0&&(r=s<0),r===s<0?(i&&n.push(i),i=[e[o]]):i&&i.push(e[o]))}return i&&n.push(i),n}function ni(e){let t=0;for(let n=0,i=e.length-1,r,o;n<e.length;i=n++)r=e[n],o=e[i],t+=(o[0]-r[0])*(r[1]+o[1]);return t}function Pt(e,t,n){t&&n&&(e===1?t.id=n.readVarint():e===2?ii(n,t):e===3?t.type=n.readVarint():e===4&&(t._geometry=n.pos))}function ii(e,t){let n=e.readVarint()+e.pos;for(;e.pos<n;){let i=t._keys[e.readVarint()],r=t._values[e.readVarint()];t.properties[i]=r}}var j=class{properties;extent;type;id;_pbf;_geometry;_keys;_values;static get types(){return["Unknown","Point","LineString","Polygon"]}constructor(t,n,i,r,o){this.properties={},this.extent=i,this.type=0,this.id=null,this._pbf=t,this._geometry=-1,this._keys=r,this._values=o,t.readFields(Pt,this,n)}loadGeometry(){let t=this._pbf;t.pos=this._geometry;let n=t.readVarint()+t.pos,i=1,r=0,o=0,s=0,a=[],l;for(;t.pos<n;){if(r<=0){let f=t.readVarint();i=f&7,r=f>>3}if(r--,i===1||i===2)o+=t.readSVarint(),s+=t.readSVarint(),i===1&&(l&&a.push(l),l=[]),l&&l.push([o,s]);else if(i===7)l&&l.push(l[0].slice());else throw new Error(`unknown command ${i}`)}return l&&a.push(l),a}bbox(){let t=this._pbf;t.pos=this._geometry;let n=t.readVarint()+t.pos,i=1,r=0,o=0,s=0,a=1/0,l=-1/0,f=1/0,c=-1/0;for(;t.pos<n;){if(r<=0){let u=t.readVarint();i=u&7,r=u>>3}if(r--,i===1||i===2)o+=t.readSVarint(),s+=t.readSVarint(),o<a&&(a=o),o>l&&(l=o),s<f&&(f=s),s>c&&(c=s);else if(i!==7)throw new Error(`unknown command ${i}`)}return[a,f,l,c]}_toGeoJSON(t){let n=this.loadGeometry(),i=j.types[this.type],r,o;switch(this.type){case 1:let a=[];for(r=0;r<n.length;r++)a[r]=n[r][0];n=a,t(n,this);break;case 2:for(r=0;r<n.length;r++)t(n[r],this);break;case 3:for(n=wt(n),r=0;r<n.length;r++)for(o=0;o<n[r].length;o++)t(n[r][o],this);break}n.length===1?n=n[0]:i=`Multi${i}`;let s={type:"Feature",geometry:{type:i,coordinates:n},properties:this.properties};return this.id!==null&&(s.id=this.id),s}toGeoJSON(t){if(typeof t=="function")return this._toGeoJSON(t);let{x:n,y:i,z:r}=t,o=this.extent*Math.pow(2,r),s=this.extent*n,a=this.extent*i;function l(f){for(let c=0;c<f.length;c++){let u=f[c];u[0]=(u[0]+s)*360/o-180;let p=180-(u[1]+a)*360/o;u[1]=360/Math.PI*Math.atan(Math.exp(p*Math.PI/180))-90}}return this._toGeoJSON(l)}};var ce=class{version;name;extent;length;_pbf;_keys;_values;_features;constructor(t,n){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(ri,this,n),this.length=this._features.length}feature(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];let n=this._pbf.readVarint()+this._pbf.pos;return new j(this._pbf,n,this.extent,this._keys,this._values)}};function ri(e,t,n){t&&n&&(e===15?t.version=n.readVarint():e===1?t.name=n.readString():e===5?t.extent=n.readVarint():e===2?t._features.push(n.pos):e===3?t._keys.push(n.readString()):e===4&&t._values.push(oi(n)))}function oi(e){let t=null,n=e.readVarint()+e.pos;for(;e.pos<n;){let i=e.readVarint()>>3;t=i===1?e.readString():i===2?e.readFloat():i===3?e.readDouble():i===4?e.readVarint64():i===5?e.readVarint():i===6?e.readSVarint():i===7?e.readBoolean():null}return t}var ue=class{layers;constructor(t,n){this.layers=t.readFields(si,{},n)}};function si(e,t,n){if(e===3&&n){let i=new ce(n,n.readVarint()+n.pos);i.length&&t&&(t[i.name]=i)}}function Ft(e){let t=e.indices.length,n="Polygon";if(t<=1)return{type:n,data:e.data,areas:[[C(e.data)]],indices:[e.indices]};let i=[],r=[],o=[],s=[],a,l=0;for(let f,c=0,u;c<t;c++){u=e.indices[c]-l,f=e.indices[c+1]-l||e.data.length;let p=e.data.slice(u,f),h=C(p);if(h===0){let d=e.data.slice(0,u),x=e.data.slice(f);e.data=d.concat(x),l+=f-u;continue}a===void 0&&(a=h<0),a===h<0?(s.length&&(i.push(o),r.push(s)),s=[u],o=[h]):(o.push(h),s.push(u))}return o&&i.push(o),s.length&&r.push(s),{type:n,areas:i,indices:r,data:e.data}}function It(e,t,n,i){for(let r=0,o=e.length;r<o;r+=2){e[r]=(e[r]+t)*360/i-180;let s=180-(e[r+1]+n)*360/i;e[r+1]=360/Math.PI*Math.atan(Math.exp(s*Math.PI/180))-90}}function vt(e,t,n){t&&n&&(e===1?t.id=n.readVarint():e===2?ai(n,t):e===3?t.type=n.readVarint():e===4&&(t._geometry=n.pos))}function ai(e,t){let n=e.readVarint()+e.pos;for(;e.pos<n;){let i=t._keys[e.readVarint()],r=t._values[e.readVarint()];t.properties[i]=r}}var Tt,N,Ce,he,Oe,Ne,H;var pe=class{properties;extent;type;id;_pbf;_geometry;_keys;_values;_geometryInfo;constructor(t,n,i,r,o,s){this.properties={},this.extent=i,this.type=0,this.id=null,this._pbf=t,this._geometry=-1,this._keys=r,this._values=o,this._geometryInfo=s,t.readFields(vt,this,n)}loadGeometry(){let t=this._pbf;t.pos=this._geometry,Tt=t.readVarint()+t.pos,N=1,he=0,Oe=0,Ne=0,H=0;let n=[],i=[];for(;t.pos<Tt;)if(he<=0&&(Ce=t.readVarint(),N=Ce&7,he=Ce>>3),he--,N===1||N===2)Oe+=t.readSVarint(),Ne+=t.readSVarint(),N===1&&n.push(H),i.push(Oe,Ne),H+=2;else if(N===7){if(H>0){let r=n[n.length-1];i.push(i[r],i[r+1]),H+=2}}else throw new Error(`unknown command ${N}`);return{data:i,indices:n}}_toBinaryCoordinates(t){let n=this.loadGeometry(),i;t(n.data,this);let r=2;switch(this.type){case 1:this._geometryInfo.pointFeaturesCount++,this._geometryInfo.pointPositionsCount+=n.indices.length,i={type:"Point",...n};break;case 2:this._geometryInfo.lineFeaturesCount++,this._geometryInfo.linePathsCount+=n.indices.length,this._geometryInfo.linePositionsCount+=n.data.length/r,i={type:"LineString",...n};break;case 3:i=Ft(n),this._geometryInfo.polygonFeaturesCount++,this._geometryInfo.polygonObjectsCount+=i.indices.length;for(let s of i.indices)this._geometryInfo.polygonRingsCount+=s.length;this._geometryInfo.polygonPositionsCount+=i.data.length/r;break;default:throw new Error(`Invalid geometry type: ${this.type}`)}let o={type:"Feature",geometry:i,properties:this.properties};return this.id!==null&&(o.id=this.id),o}toBinaryCoordinates(t){if(typeof t=="function")return this._toBinaryCoordinates(t);let{x:n,y:i,z:r}=t,o=this.extent*Math.pow(2,r),s=this.extent*n,a=this.extent*i;return this._toBinaryCoordinates(l=>It(l,s,a,o))}};var de=class{version;name;extent;length;_pbf;_keys;_values;_features;constructor(t,n){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(li,this,n),this.length=this._features.length}feature(t,n){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];let i=this._pbf.readVarint()+this._pbf.pos;return new pe(this._pbf,i,this.extent,this._keys,this._values,n)}};function li(e,t,n){t&&n&&(e===15?t.version=n.readVarint():e===1?t.name=n.readString():e===5?t.extent=n.readVarint():e===2?t._features.push(n.pos):e===3?t._keys.push(n.readString()):e===4&&t._values.push(fi(n)))}function fi(e){let t=null,n=e.readVarint()+e.pos;for(;e.pos<n;){let i=e.readVarint()>>3;t=i===1?e.readString():i===2?e.readFloat():i===3?e.readDouble():i===4?e.readVarint64():i===5?e.readVarint():i===6?e.readSVarint():i===7?e.readBoolean():null}return t}var ge=class{layers;constructor(t,n){this.layers=t.readFields(ci,{},n)}};function ci(e,t,n){if(e===3&&n){let i=new de(n,n.readVarint()+n.pos);i.length&&t&&(t[i.name]=i)}}function Ge(e,t){let n=hi(t),i=t?.gis?.format||t?.mvt?.shape||t?.shape;switch(i){case"columnar-table":return{shape:"columnar-table",data:ke(e,n)};case"geojson-table":return{shape:"geojson-table",type:"FeatureCollection",features:St(e,n)};case"geojson":return St(e,n);case"binary-geometry":return ke(e,n);case"binary":return ke(e,n);default:throw new Error(i||"undefined shape")}}function ke(e,t){let[n,i]=ui(e,t),r=Ee(n,i);return r.byteLength=e.byteLength,r}function ui(e,t){let n=[],i={coordLength:2,pointPositionsCount:0,pointFeaturesCount:0,linePositionsCount:0,linePathsCount:0,lineFeaturesCount:0,polygonPositionsCount:0,polygonObjectsCount:0,polygonRingsCount:0,polygonFeaturesCount:0};if(e.byteLength<=0)return[n,i];let r=new ge(new Ue.default(e));return(t&&Array.isArray(t.layers)?t.layers:Object.keys(r.layers)).forEach(s=>{let a=r.layers[s];if(a)for(let l=0;l<a.length;l++){let f=a.feature(l,i),c=di(f,t,s);n.push(c)}}),[n,i]}function St(e,t){if(e.byteLength<=0)return[];let n=[],i=new ue(new Ue.default(e));return(Array.isArray(t.layers)?t.layers:Object.keys(i.layers)).forEach(o=>{let s=i.layers[o];if(s)for(let a=0;a<s.length;a++){let l=s.feature(a),f=pi(l,t,o);n.push(f)}}),n}function hi(e){if(!e?.mvt)throw new Error("mvt options required");let t=e.mvt?.coordinates==="wgs84",{tileIndex:n}=e.mvt,i=n&&Number.isFinite(n.x)&&Number.isFinite(n.y)&&Number.isFinite(n.z);if(t&&!i)throw new Error("MVT Loader: WGS84 coordinates need tileIndex property");return e.mvt}function pi(e,t,n){let i=e.toGeoJSON(t.coordinates==="wgs84"?t.tileIndex:gi);return t.layerProperty&&(i.properties[t.layerProperty]=n),i}function di(e,t,n){let i=e.toBinaryCoordinates(t.coordinates==="wgs84"?t.tileIndex:mi);return t.layerProperty&&i.properties&&(i.properties[t.layerProperty]=n),i}function gi(e,t){let{extent:n}=t;for(let i=0;i<e.length;i++){let r=e[i];r[0]/=n,r[1]/=n}}function mi(e,t){let{extent:n}=t;for(let i=0,r=e.length;i<r;++i)e[i]/=n}var xi="4.2.3",Re={dataType:null,batchType:null,name:"Mapbox Vector Tile",id:"mvt",module:"mvt",version:xi,extensions:["mvt","pbf"],mimeTypes:["application/vnd.mapbox-vector-tile","application/x-protobuf"],worker:!0,category:"geometry",options:{mvt:{shape:"geojson",coordinates:"local",layerProperty:"layerName",layers:void 0,tileIndex:null}}},me={...Re,parse:async(e,t)=>Ge(e,t),parseSync:Ge,binary:!0};var Bt=e=>e!==null&&typeof e=="object";function je(e,t){if(!e||!Bt(e))return null;let n={name:e.name||"",description:e.description||""};if(typeof e.generator=="string"&&(n.generator=e.generator),typeof e.generator_options=="string"&&(n.generatorOptions=e.generator_options),n.boundingBox=_t(e.bounds)||_t(e.antimeridian_adjusted_bounds),n.center=vi(e.center),n.maxZoom=Mt(e.maxzoom),n.minZoom=Mt(e.minzoom),typeof e?.json=="string")try{n.metaJson=JSON.parse(e.json)}catch(a){console.warn("Failed to parse tilejson.json field",a)}let i=e.tilestats||n.metaJson?.tilestats,r=Pi(i,t),o=yi(e.vector_layers),s=Ii(o,r);return n={...n,layers:s},n.maxZoom===null&&s.length>0&&(n.maxZoom=s[0].maxZoom||null),n.minZoom===null&&s.length>0&&(n.minZoom=s[0].minZoom||null),n}function yi(e){return Array.isArray(e)?e.map(t=>wi(t)):[]}function wi(e){let t=Object.entries(e.fields||[]).map(([i,r])=>({name:i,...bt(String(r))})),n={...e};return delete n.fields,{name:e.id||"",...n,fields:t}}function Pi(e,t){return Bt(e)&&Array.isArray(e.layers)?e.layers.map(n=>Fi(n,t)):[]}function Fi(e,t){let n=[],i={},r=e.attributes||[];for(let o of r){let s=o.attribute;if(typeof s=="string")if(s.split("|").length>1){let a=s.split("|")[0];i[a]=i[a]||[],i[a].push(o),console.warn("ignoring tilestats indexed field",a)}else n[s]||n.push(Si(o,t))}return{name:e.layer||"",dominantGeometry:e.geometry,fields:n}}function Ii(e,t){return e.map(n=>{let i=t.find(s=>s.name===n.name),r=i?.fields||[],o={...n};return delete o.fields,{...o,...i,fields:r}})}function _t(e){let t=Dt(e);if(Array.isArray(t)&&t.length===4&&[t[0],t[2]].every(Et)&&[t[1],t[3]].every(At))return[[t[0],t[1]],[t[2],t[3]]]}function vi(e){let t=Dt(e);return Array.isArray(t)&&t.length===3&&Et(t[0])&&At(t[1])&&Ti(t[2])?t:null}function Mt(e){let t=typeof e=="string"?parseFloat(e):typeof e=="number"?e:null;return t===null||isNaN(t)?null:t}function At(e){return Number.isFinite(e)&&e<=90&&e>=-90}function Et(e){return Number.isFinite(e)&&e<=180&&e>=-180}function Ti(e){return Number.isFinite(e)&&e>=0&&e<=22}function Dt(e){return typeof e=="string"?e.split(",").map(parseFloat):Array.isArray(e)?e:null}var Vt={number:{type:"float32"},numeric:{type:"float32"},string:{type:"utf8"},vachar:{type:"utf8"},float:{type:"float32"},int:{type:"int32"},int4:{type:"int32"},boolean:{type:"boolean"},bool:{type:"boolean"}};function Si(e={},t){let n=bt(e.type),i={name:e.attribute,...n};return typeof e.min=="number"&&(i.min=e.min),typeof e.max=="number"&&(i.max=e.max),typeof e.count=="number"&&(i.uniqueValueCount=e.count),e.values&&(i.values=e.values),i.values&&typeof t.maxValues=="number"&&(i.values=i.values?.slice(0,t.maxValues)),i}function bt(e){let t=e.toLowerCase();return!t||Vt[t],Vt[t]||{type:"string"}}var _i="4.2.3",Z={dataType:null,batchType:null,name:"TileJSON",id:"tilejson",module:"pmtiles",version:_i,worker:!0,extensions:["json"],mimeTypes:["application/json"],text:!0,options:{tilejson:{maxValues:void 0}},parse:async(e,t)=>{let n=new TextDecoder().decode(e),i=JSON.parse(n),r={...Z.options.tilejson,...t?.tilejson};return je(i,r)},parseTextSync:(e,t)=>{let n=JSON.parse(e),i={...Z.options.tilejson,...t?.tilejson};return je(n,i)}};function K(e,t){if(!e)throw new Error(t||"loader assertion failed.")}var A={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},Mi=A.self||A.window||A.global||{},Vi=A.window||A.self||A.global||{},Bi=A.global||A.self||A.window||{},Ai=A.document||{};var Ze=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var Lt=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),Ei=Lt&&parseFloat(Lt[1])||0;var Di="",Ct={};function ze(e){for(let t in Ct)if(e.startsWith(t)){let n=Ct[t];e=e.replace(t,n)}return!e.startsWith("http://")&&!e.startsWith("https://")&&(e=`${Di}${e}`),e}var Q=class{fetch;loadOptions;_needsRefresh=!0;props;constructor(t){this.props={...t},this.loadOptions={...t.loadOptions},this.fetch=bi(this.loadOptions)}setProps(t){this.props=Object.assign(this.props,t),this.setNeedsRefresh()}setNeedsRefresh(){this._needsRefresh=!0}getNeedsRefresh(t=!0){let n=this._needsRefresh;return t&&(this._needsRefresh=!1),n}};function bi(e){let t=e?.fetch;if(t&&typeof t=="function")return(i,r)=>t(i,r);let n=e?.fetch;return n&&typeof n!="function"?i=>fetch(i,n):i=>fetch(i)}var Ot="4.2.3";var Li=globalThis.loaders?.parseImageNode,Je=typeof Image<"u",We=typeof ImageBitmap<"u",Ci=Boolean(Li),Ye=Ze?!0:Ci;function Nt(e){switch(e){case"auto":return We||Je||Ye;case"imagebitmap":return We;case"image":return Je;case"data":return Ye;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}function kt(){if(We)return"imagebitmap";if(Je)return"image";if(Ye)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function Oi(e){let t=Ni(e);if(!t)throw new Error("Not an image");return t}function Ut(e){switch(Oi(e)){case"data":return e;case"image":case"imagebitmap":let t=document.createElement("canvas"),n=t.getContext("2d");if(!n)throw new Error("getImageData");return t.width=e.width,t.height=e.height,n.drawImage(e,0,0),n.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}function Ni(e){return typeof ImageBitmap<"u"&&e instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&e instanceof Image?"image":e&&typeof e=="object"&&e.data&&e.width&&e.height?"data":null}var ki=/^data:image\/svg\+xml/,Ui=/\.svg((\?|#).*)?$/;function xe(e){return e&&(ki.test(e)||Ui.test(e))}function Gt(e,t){if(xe(t)){let i=new TextDecoder().decode(e);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(i=unescape(encodeURIComponent(i)))}catch(o){throw new Error(o.message)}return`data:image/svg+xml;base64,${btoa(i)}`}return Xe(e,t)}function Xe(e,t){if(xe(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function ye(e,t,n){let i=Gt(e,n),r=self.URL||self.webkitURL,o=typeof i!="string"&&r.createObjectURL(i);try{return await Gi(o||i,t)}finally{o&&r.revokeObjectURL(o)}}async function Gi(e,t){let n=new Image;return n.src=e,t.image&&t.image.decode&&n.decode?(await n.decode(),n):await new Promise((i,r)=>{try{n.onload=()=>i(n),n.onerror=o=>{let s=o instanceof Error?o.message:"error";r(new Error(s))}}catch(o){r(o)}})}var Ri={},Rt=!0;async function jt(e,t,n){let i;xe(n)?i=await ye(e,t,n):i=Xe(e,n);let r=t&&t.imagebitmap;return await ji(i,r)}async function ji(e,t=null){if((Zi(t)||!Rt)&&(t=null),t)try{return await createImageBitmap(e,t)}catch(n){console.warn(n),Rt=!1}return await createImageBitmap(e)}function Zi(e){for(let t in e||Ri)return!1;return!0}function Zt(e){return!Yi(e,"ftyp",4)||!(e[8]&96)?null:zi(e)}function zi(e){switch(Ji(e,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function Ji(e,t,n){return String.fromCharCode(...e.slice(t,n))}function Wi(e){return[...e].map(t=>t.charCodeAt(0))}function Yi(e,t,n=0){let i=Wi(t);for(let r=0;r<i.length;++r)if(i[r]!==e[r+n])return!1;return!0}var E=!1,q=!0;function k(e){let t=ee(e);return $i(t)||Qi(t)||Hi(t)||Ki(t)||Xi(t)}function Xi(e){let t=new Uint8Array(e instanceof DataView?e.buffer:e),n=Zt(t);return n?{mimeType:n.mimeType,width:0,height:0}:null}function $i(e){let t=ee(e);return t.byteLength>=24&&t.getUint32(0,E)===2303741511?{mimeType:"image/png",width:t.getUint32(16,E),height:t.getUint32(20,E)}:null}function Hi(e){let t=ee(e);return t.byteLength>=10&&t.getUint32(0,E)===1195984440?{mimeType:"image/gif",width:t.getUint16(6,q),height:t.getUint16(8,q)}:null}function Ki(e){let t=ee(e);return t.byteLength>=14&&t.getUint16(0,E)===16973&&t.getUint32(2,q)===t.byteLength?{mimeType:"image/bmp",width:t.getUint32(18,q),height:t.getUint32(22,q)}:null}function Qi(e){let t=ee(e);if(!(t.byteLength>=3&&t.getUint16(0,E)===65496&&t.getUint8(2)===255))return null;let{tableMarkers:i,sofMarkers:r}=qi(),o=2;for(;o+9<t.byteLength;){let s=t.getUint16(o,E);if(r.has(s))return{mimeType:"image/jpeg",height:t.getUint16(o+5,E),width:t.getUint16(o+7,E)};if(!i.has(s))return null;o+=2,o+=t.getUint16(o,E)}return null}function qi(){let e=new Set([65499,65476,65484,65501,65534]);for(let n=65504;n<65520;++n)e.add(n);return{tableMarkers:e,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function ee(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}async function zt(e,t){let{mimeType:n}=k(e)||{},i=globalThis.loaders?.parseImageNode;return K(i),await i(e,n)}async function Jt(e,t,n){t=t||{};let r=(t.image||{}).type||"auto",{url:o}=n||{},s=er(r),a;switch(s){case"imagebitmap":a=await jt(e,t,o);break;case"image":a=await ye(e,t,o);break;case"data":a=await zt(e,t);break;default:K(!1)}return r==="data"&&(a=Ut(a)),a}function er(e){switch(e){case"auto":case"data":return kt();default:return Nt(e),e}}var tr=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],nr=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],ir={image:{type:"auto",decode:!0}},$e={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:Ot,mimeTypes:nr,extensions:tr,parse:Jt,tests:[e=>Boolean(k(new DataView(e)))],options:ir};var we=class extends Q{props;url;metadataUrl=null;data;schema="tms";metadata;extension;mimeType=null;constructor(t){super(t),this.props=t,this.url=ze(t.url),this.metadataUrl=t.metadataUrl===void 0?`${this.url}/tilejson.json`:t.metadataUrl,this.extension=t.extension||".png",this.data=this.url,this.getTileData=this.getTileData.bind(this),this.metadata=this.getMetadata(),rr(this.url)&&(this.schema="template")}async getMetadata(){if(!this.metadataUrl)return null;let t;try{t=await this.fetch(this.metadataUrl)}catch(r){return console.error(r.message),null}if(!t.ok)return console.error(t.statusText),null;let n=await t.text();return Z.parseTextSync?.(n)||null}getTileMIMEType(){return this.mimeType}async getTile(t){let{x:n,y:i,zoom:r}=t,o=this.getTileURL(n,i,r),s=await this.fetch(o);return s.ok?await s.arrayBuffer():null}async getTileData(t){let{x:n,y:i,z:r}=t.index,o=await this.getTile({x:n,y:i,zoom:r,layers:[]});if(o===null)return null;let s=k(o);switch(this.mimeType=this.mimeType||s?.mimeType||"application/vnd.mapbox-vector-tile",this.mimeType){case"application/vnd.mapbox-vector-tile":return await this._parseVectorTile(o,{x:n,y:i,zoom:r,layers:[]});default:return await this._parseImageTile(o)}}async getImageTile(t){let n=await this.getTile(t);return n?this._parseImageTile(n):null}async _parseImageTile(t){return await $e.parse(t,this.loadOptions)}async getVectorTile(t){let n=await this.getTile(t);return n?this._parseVectorTile(n,t):null}async _parseVectorTile(t,n){let i={shape:"geojson-table",mvt:{coordinates:"wgs84",tileIndex:{x:n.x,y:n.y,z:n.zoom},...this.loadOptions?.mvt},...this.loadOptions};return await me.parse(t,i)}getMetadataUrl(){return this.metadataUrl}getTileURL(t,n,i){switch(this.schema){case"xyz":return`${this.url}/${t}/${n}/${i}${this.extension}`;case"tms":return`${this.url}/${i}/${t}/${n}${this.extension}`;case"template":return lr(this.url,t,n,i,"0");default:throw new Error(this.schema)}}};function rr(e){return/(?=.*{z})(?=.*{x})(?=.*({y}|{-y}))|(?=.*{x})(?=.*({y}|{-y})(?=.*{z}))/.test(e)}var or=new RegExp("{x}","g"),sr=new RegExp("{y}","g"),ar=new RegExp("{z}","g");function lr(e,t,n,i,r="0"){if(Array.isArray(e)){let s=fr(r)%e.length;e=e[s]}let o=e;return o=o.replace(or,String(t)),o=o.replace(sr,String(n)),o=o.replace(ar,String(i)),Number.isInteger(n)&&Number.isInteger(i)&&(o=o.replace(/\{-y\}/g,String(Math.pow(2,i)-n-1))),o}function fr(e){return Math.abs(e.split("").reduce((t,n)=>(t<<5)-t+n.charCodeAt(0)|0,0))}function Pe(e,t,n,i){let r=i,o=n-t>>1,s=n-t,a,l=e[t],f=e[t+1],c=e[n],u=e[n+1];for(let p=t+3;p<n;p+=3){let h=cr(e[p],e[p+1],l,f,c,u);if(h>r)a=p,r=h;else if(h===r){let d=Math.abs(p-o);d<s&&(a=p,s=d)}}r>i&&(a-t>3&&Pe(e,t,a,i),e[a+2]=r,n-a>3&&Pe(e,a,n,i))}function cr(e,t,n,i,r,o){let s=r-n,a=o-i;if(s!==0||a!==0){let l=((e-n)*s+(t-i)*a)/(s*s+a*a);l>1?(n=r,i=o):l>0&&(n+=s*l,i+=a*l)}return s=e-n,a=t-i,s*s+a*a}function L(e,t,n,i){let r={id:e??null,type:t,geometry:n,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(t==="Point"||t==="MultiPoint"||t==="LineString")Fe(r,n);else if(t==="Polygon")Fe(r,n[0]);else if(t==="MultiLineString")for(let o of n)Fe(r,o);else if(t==="MultiPolygon")for(let o of n)Fe(r,o[0]);return r}function Fe(e,t){for(let n=0;n<t.length;n+=3)e.minX=Math.min(e.minX,t[n]),e.minY=Math.min(e.minY,t[n+1]),e.maxX=Math.max(e.maxX,t[n]),e.maxY=Math.max(e.maxY,t[n+1])}function Yt(e,t){let n=[];if(e.type==="FeatureCollection")for(let i=0;i<e.features.length;i++)Ie(n,e.features[i],t,i);else e.type==="Feature"?Ie(n,e,t):Ie(n,{geometry:e},t);return n}function Ie(e,t,n,i){if(!t.geometry)return;let r=t.geometry.coordinates,o=t.geometry.type,s=Math.pow(n.tolerance/((1<<n.maxZoom)*n.extent),2),a=[],l=t.id;if(n.promoteId?l=t.properties[n.promoteId]:n.generateId&&(l=i||0),o==="Point")Wt(r,a);else if(o==="MultiPoint")for(let f of r)Wt(f,a);else if(o==="LineString")Ke(r,a,s,!1);else if(o==="MultiLineString")if(n.lineMetrics){for(let f of r)a=[],Ke(f,a,s,!1),e.push(L(l,"LineString",a,t.properties));return}else He(r,a,s,!1);else if(o==="Polygon")He(r,a,s,!0);else if(o==="MultiPolygon")for(let f of r){let c=[];He(f,c,s,!0),a.push(c)}else if(o==="GeometryCollection"){for(let f of t.geometry.geometries)Ie(e,{id:l,geometry:f,properties:t.properties},n,i);return}else throw new Error("Input data is not a valid GeoJSON object.");e.push(L(l,o,a,t.properties))}function Wt(e,t){t.push(Xt(e[0]),$t(e[1]),0)}function Ke(e,t,n,i){let r,o,s=0;for(let l=0;l<e.length;l++){let f=Xt(e[l][0]),c=$t(e[l][1]);t.push(f,c,0),l>0&&(i?s+=(r*c-f*o)/2:s+=Math.sqrt(Math.pow(f-r,2)+Math.pow(c-o,2))),r=f,o=c}let a=t.length-3;t[2]=1,Pe(t,0,a,n),t[a+2]=1,t.size=Math.abs(s),t.start=0,t.end=t.size}function He(e,t,n,i){for(let r=0;r<e.length;r++){let o=[];Ke(e[r],o,n,i),t.push(o)}}function Xt(e){return e/360+.5}function $t(e){let t=Math.sin(e*Math.PI/180),n=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return n<0?0:n>1?1:n}function B(e,t,n,i,r,o,s,a){if(n/=t,i/=t,o>=n&&s<i)return e;if(s<n||o>=i)return null;let l=[];for(let f of e){let c=f.geometry,u=f.type,p=r===0?f.minX:f.minY,h=r===0?f.maxX:f.maxY;if(p>=n&&h<i){l.push(f);continue}else if(h<n||p>=i)continue;let d=[];if(u==="Point"||u==="MultiPoint")ur(c,d,n,i,r);else if(u==="LineString")Kt(c,d,n,i,r,!1,a.lineMetrics);else if(u==="MultiLineString")Qe(c,d,n,i,r,!1);else if(u==="Polygon")Qe(c,d,n,i,r,!0);else if(u==="MultiPolygon")for(let x of c){let w=[];Qe(x,w,n,i,r,!0),w.length&&d.push(w)}if(d.length){if(a.lineMetrics&&u==="LineString"){for(let x of d)l.push(L(f.id,u,x,f.tags));continue}(u==="LineString"||u==="MultiLineString")&&(d.length===1?(u="LineString",d=d[0]):u="MultiLineString"),(u==="Point"||u==="MultiPoint")&&(u=d.length===3?"Point":"MultiPoint"),l.push(L(f.id,u,d,f.tags))}}return l.length?l:null}function ur(e,t,n,i,r){for(let o=0;o<e.length;o+=3){let s=e[o+r];s>=n&&s<=i&&z(t,e[o],e[o+1],e[o+2])}}function Kt(e,t,n,i,r,o,s){let a=Ht(e),l=r===0?hr:pr,f=e.start,c,u;for(let I=0;I<e.length-3;I+=3){let _=e[I],g=e[I+1],m=e[I+2],v=e[I+3],F=e[I+4],T=r===0?_:g,S=r===0?v:F,M=!1;s&&(c=Math.sqrt(Math.pow(_-v,2)+Math.pow(g-F,2))),T<n?S>n&&(u=l(a,_,g,v,F,n),s&&(a.start=f+c*u)):T>i?S<i&&(u=l(a,_,g,v,F,i),s&&(a.start=f+c*u)):z(a,_,g,m),S<n&&T>=n&&(u=l(a,_,g,v,F,n),M=!0),S>i&&T<=i&&(u=l(a,_,g,v,F,i),M=!0),!o&&M&&(s&&(a.end=f+c*u),t.push(a),a=Ht(e)),s&&(f+=c)}let p=e.length-3,h=e[p],d=e[p+1],x=e[p+2],w=r===0?h:d;w>=n&&w<=i&&z(a,h,d,x),p=a.length-3,o&&p>=3&&(a[p]!==a[0]||a[p+1]!==a[1])&&z(a,a[0],a[1],a[2]),a.length&&t.push(a)}function Ht(e){let t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function Qe(e,t,n,i,r,o){for(let s of e)Kt(s,t,n,i,r,o,!1)}function z(e,t,n,i){e.push(t,n,i)}function hr(e,t,n,i,r,o){let s=(o-t)/(i-t);return z(e,o,n+(r-n)*s,1),s}function pr(e,t,n,i,r,o){let s=(o-n)/(r-n);return z(e,t+(i-t)*s,o,1),s}function qt(e,t){let n=t.buffer/t.extent,i=e,r=B(e,1,-1-n,n,0,-1,2,t),o=B(e,1,1-n,2+n,0,-1,2,t);return(r||o)&&(i=B(e,1,-n,1+n,0,-1,2,t)||[],r&&(i=Qt(r,1).concat(i)),o&&(i=i.concat(Qt(o,-1)))),i}function Qt(e,t){let n=[];for(let i=0;i<e.length;i++){let r=e[i],o=r.type,s;if(o==="Point"||o==="MultiPoint"||o==="LineString")s=qe(r.geometry,t);else if(o==="MultiLineString"||o==="Polygon"){s=[];for(let a of r.geometry)s.push(qe(a,t))}else if(o==="MultiPolygon"){s=[];for(let a of r.geometry){let l=[];for(let f of a)l.push(qe(f,t));s.push(l)}}n.push(L(r.id,o,s,r.tags))}return n}function qe(e,t){let n=[];n.size=e.size,e.start!==void 0&&(n.start=e.start,n.end=e.end);for(let i=0;i<e.length;i+=3)n.push(e[i]+t,e[i+1],e[i+2]);return n}function et(e,t){if(e.transformed)return e;let n=1<<e.z,i=e.x,r=e.y;for(let o of e.features){let s=o.geometry,a=o.type;if(o.geometry=[],a===1)for(let l=0;l<s.length;l+=2)o.geometry.push(en(s[l],s[l+1],t,n,i,r));else for(let l=0;l<s.length;l++){let f=[];for(let c=0;c<s[l].length;c+=2)f.push(en(s[l][c],s[l][c+1],t,n,i,r));o.geometry.push(f)}}return e.transformed=!0,e}function en(e,t,n,i,r,o){return[Math.round(n*(e*i-r)),Math.round(n*(t*i-o))]}function tn(e,t,n,i,r){let o=t===r.maxZoom?0:r.tolerance/((1<<t)*r.extent),s={features:[],numPoints:0,numSimplified:0,numFeatures:e.length,source:null,x:n,y:i,z:t,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(let a of e)dr(s,a,o,r);return s}function dr(e,t,n,i){let r=t.geometry,o=t.type,s=[];if(e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),o==="Point"||o==="MultiPoint")for(let a=0;a<r.length;a+=3)s.push(r[a],r[a+1]),e.numPoints++,e.numSimplified++;else if(o==="LineString")tt(s,r,e,n,!1,!1);else if(o==="MultiLineString"||o==="Polygon")for(let a=0;a<r.length;a++)tt(s,r[a],e,n,o==="Polygon",a===0);else if(o==="MultiPolygon")for(let a=0;a<r.length;a++){let l=r[a];for(let f=0;f<l.length;f++)tt(s,l[f],e,n,!0,f===0)}if(s.length){let a=t.tags||null;if(o==="LineString"&&i.lineMetrics){a={};for(let f in t.tags)a[f]=t.tags[f];a.mapbox_clip_start=r.start/r.size,a.mapbox_clip_end=r.end/r.size}let l={geometry:s,type:o==="Polygon"||o==="MultiPolygon"?3:o==="LineString"||o==="MultiLineString"?2:1,tags:a};t.id!==null&&(l.id=t.id),e.features.push(l)}}function tt(e,t,n,i,r,o){let s=i*i;if(i>0&&t.size<(r?s:i)){n.numPoints+=t.length/3;return}let a=[];for(let l=0;l<t.length;l+=3)(i===0||t[l+2]>s)&&(n.numSimplified++,a.push(t[l],t[l+1])),n.numPoints++;r&&gr(a,o),e.push(a)}function gr(e,t){let n=0;for(let i=0,r=e.length-2;i<e.length;r=i,i+=2)n+=(e[i]-e[r])*(e[i+1]+e[r+1]);if(n>0===t)for(let i=0,r=e.length;i<r/2;i+=2){let o=e[i],s=e[i+1];e[i]=e[r-2-i],e[i+1]=e[r-1-i],e[r-2-i]=o,e[r-1-i]=s}}var mr={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:void 0,generateId:!1,debug:0},ve=class{options;tiles={};tileCoords=[];stats={};total=0;constructor(t,n){this.options={...mr,...n},n=this.options;let i=n.debug;if(i&&console.time("preprocess data"),this.options.maxZoom<0||this.options.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(n.promoteId&&this.options.generateId)throw new Error("promoteId and generateId cannot be used together.");let r=Yt(t,n);i&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",n.indexMaxZoom,n.indexMaxPoints),console.time("generate tiles")),r=qt(r,this.options),r.length&&this.splitTile(r,0,0,0),i&&(r.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}getTile(t,n,i){let{extent:r,debug:o}=this.options;if(t<0||t>24)return null;let s=1<<t;n=n+s&s-1;let a=nt(t,n,i);if(this.tiles[a])return et(this.tiles[a],r);o>1&&console.log("drilling down to z%d-%d-%d",t,n,i);let l=t,f=n,c=i,u;for(;!u&&l>0;)l--,f=f>>1,c=c>>1,u=this.tiles[nt(l,f,c)];return!u||!u.source?null:(o>1&&(console.log("found parent tile z%d-%d-%d",l,f,c),console.time("drilling down")),this.splitTile(u.source,l,f,c,t,n,i),o>1&&console.timeEnd("drilling down"),this.tiles[a]?et(this.tiles[a],r):null)}splitTile(t,n,i,r,o,s,a){let l=[t,n,i,r],f=this.options,c=f.debug;for(;l.length;){r=l.pop(),i=l.pop(),n=l.pop(),t=l.pop();let u=1<<n,p=nt(n,i,r),h=this.tiles[p];if(!h&&(c>1&&console.time("creation"),h=this.tiles[p]=tn(t,n,i,r,f),this.tileCoords.push({z:n,x:i,y:r}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",n,i,r,h.numFeatures,h.numPoints,h.numSimplified),console.timeEnd("creation"));let S=`z${n}`;this.stats[S]=(this.stats[S]||0)+1,this.total++}if(h.source=t,o===void 0){if(n===f.indexMaxZoom||h.numPoints<=f.indexMaxPoints)continue}else{if(n===f.maxZoom||n===o)continue;if(o!==void 0){let S=o-n;if(i!==s>>S||r!==a>>S)continue}}if(h.source=null,t.length===0)continue;c>1&&console.time("clipping");let d=.5*f.buffer/f.extent,x=.5-d,w=.5+d,I=1+d,_=null,g=null,m=null,v=null,F=B(t,u,i-d,i+w,0,h.minX,h.maxX,f),T=B(t,u,i+x,i+I,0,h.minX,h.maxX,f);t=null,F&&(_=B(F,u,r-d,r+w,1,h.minY,h.maxY,f),g=B(F,u,r+x,r+I,1,h.minY,h.maxY,f),F=null),T&&(m=B(T,u,r-d,r+w,1,h.minY,h.maxY,f),v=B(T,u,r+x,r+I,1,h.minY,h.maxY,f),T=null),c>1&&console.timeEnd("clipping"),l.push(_||[],n+1,i*2,r*2),l.push(g||[],n+1,i*2,r*2+1),l.push(m||[],n+1,i*2+1,r*2),l.push(v||[],n+1,i*2+1,r*2+1)}}};function nt(e,t,n){return((1<<e)*n+t)*32+e}return fn(te);})();
8
8
  /*! Bundled license information:
9
9
 
10
10
  ieee754/index.js:
package/dist/index.cjs CHANGED
@@ -760,7 +760,7 @@ function transformToLocalCoordinatesBinary(data, feature) {
760
760
  }
761
761
 
762
762
  // dist/mvt-loader.js
763
- var VERSION = true ? "4.2.1" : "latest";
763
+ var VERSION = true ? "4.2.3" : "latest";
764
764
  var MVTWorkerLoader = {
765
765
  dataType: null,
766
766
  batchType: null,
@@ -1002,7 +1002,7 @@ function attributeTypeToFieldType(aType) {
1002
1002
  }
1003
1003
 
1004
1004
  // dist/tilejson-loader.js
1005
- var VERSION2 = true ? "4.2.1" : "latest";
1005
+ var VERSION2 = true ? "4.2.3" : "latest";
1006
1006
  var TileJSONLoader = {
1007
1007
  dataType: null,
1008
1008
  batchType: null,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["index.js", "lib/parse-mvt.js", "helpers/mapbox-util-functions.js", "lib/mapbox-vector-tile/vector-tile-feature.js", "lib/mapbox-vector-tile/vector-tile-layer.js", "lib/mapbox-vector-tile/vector-tile.js", "helpers/binary-util-functions.js", "lib/binary-vector-tile/vector-tile-feature.js", "lib/binary-vector-tile/vector-tile-layer.js", "lib/binary-vector-tile/vector-tile.js", "mvt-loader.js", "lib/parse-tilejson.js", "tilejson-loader.js", "mvt-source.js", "lib/geojson-tiler/simplify.js", "lib/geojson-tiler/feature.js", "lib/geojson-tiler/convert.js", "lib/geojson-tiler/clip.js", "lib/geojson-tiler/wrap.js", "lib/geojson-tiler/transform.js", "lib/geojson-tiler/tile.js", "lib/geojson-tiler/geojson-tiler.js"],
4
- "sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport { MVTLoader, MVTWorkerLoader } from \"./mvt-loader.js\";\nexport { TileJSONLoader } from \"./tilejson-loader.js\";\nexport { MVTSource } from \"./mvt-source.js\";\nexport { GeoJSONTiler } from \"./lib/geojson-tiler/geojson-tiler.js\";\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\nimport { flatGeojsonToBinary } from '@loaders.gl/gis';\nimport Protobuf from 'pbf';\nimport { VectorTile } from \"./mapbox-vector-tile/vector-tile.js\";\nimport { BinaryVectorTile } from \"./binary-vector-tile/vector-tile.js\";\n/**\n * Parse MVT arrayBuffer and return GeoJSON.\n *\n * @param arrayBuffer A MVT arrayBuffer\n * @param options\n * @returns A GeoJSON geometry object or a binary representation\n */\nexport function parseMVT(arrayBuffer, options) {\n const mvtOptions = normalizeOptions(options);\n const shape = options?.gis?.format || options?.mvt?.shape || options?.shape;\n switch (shape) {\n case 'columnar-table': // binary + some JS arrays\n return { shape: 'columnar-table', data: parseToBinary(arrayBuffer, mvtOptions) };\n case 'geojson-table': {\n const table = {\n shape: 'geojson-table',\n type: 'FeatureCollection',\n features: parseToGeojsonFeatures(arrayBuffer, mvtOptions)\n };\n return table;\n }\n case 'geojson':\n return parseToGeojsonFeatures(arrayBuffer, mvtOptions);\n case 'binary-geometry':\n return parseToBinary(arrayBuffer, mvtOptions);\n case 'binary':\n return parseToBinary(arrayBuffer, mvtOptions);\n default:\n throw new Error(shape || 'undefined shape');\n }\n}\nfunction parseToBinary(arrayBuffer, options) {\n const [flatGeoJsonFeatures, geometryInfo] = parseToFlatGeoJson(arrayBuffer, options);\n const binaryData = flatGeojsonToBinary(flatGeoJsonFeatures, geometryInfo);\n // Add the original byteLength (as a reasonable approximation of the size of the binary data)\n // TODO decide where to store extra fields like byteLength (header etc) and document\n // @ts-ignore\n binaryData.byteLength = arrayBuffer.byteLength;\n return binaryData;\n}\nfunction parseToFlatGeoJson(arrayBuffer, options) {\n const features = [];\n const geometryInfo = {\n coordLength: 2,\n pointPositionsCount: 0,\n pointFeaturesCount: 0,\n linePositionsCount: 0,\n linePathsCount: 0,\n lineFeaturesCount: 0,\n polygonPositionsCount: 0,\n polygonObjectsCount: 0,\n polygonRingsCount: 0,\n polygonFeaturesCount: 0\n };\n if (arrayBuffer.byteLength <= 0) {\n return [features, geometryInfo];\n }\n const tile = new BinaryVectorTile(new Protobuf(arrayBuffer));\n const selectedLayers = options && Array.isArray(options.layers) ? options.layers : Object.keys(tile.layers);\n selectedLayers.forEach((layerName) => {\n const vectorTileLayer = tile.layers[layerName];\n if (!vectorTileLayer) {\n return;\n }\n for (let i = 0; i < vectorTileLayer.length; i++) {\n const vectorTileFeature = vectorTileLayer.feature(i, geometryInfo);\n const decodedFeature = getDecodedFeatureBinary(vectorTileFeature, options, layerName);\n features.push(decodedFeature);\n }\n });\n return [features, geometryInfo];\n}\nfunction parseToGeojsonFeatures(arrayBuffer, options) {\n if (arrayBuffer.byteLength <= 0) {\n return [];\n }\n const features = [];\n const tile = new VectorTile(new Protobuf(arrayBuffer));\n const selectedLayers = Array.isArray(options.layers) ? options.layers : Object.keys(tile.layers);\n selectedLayers.forEach((layerName) => {\n const vectorTileLayer = tile.layers[layerName];\n if (!vectorTileLayer) {\n return;\n }\n for (let i = 0; i < vectorTileLayer.length; i++) {\n const vectorTileFeature = vectorTileLayer.feature(i);\n const decodedFeature = getDecodedFeature(vectorTileFeature, options, layerName);\n features.push(decodedFeature);\n }\n });\n return features;\n}\nfunction normalizeOptions(options) {\n if (!options?.mvt) {\n throw new Error('mvt options required');\n }\n // Validate\n const wgs84Coordinates = options.mvt?.coordinates === 'wgs84';\n const { tileIndex } = options.mvt;\n const hasTileIndex = tileIndex &&\n Number.isFinite(tileIndex.x) &&\n Number.isFinite(tileIndex.y) &&\n Number.isFinite(tileIndex.z);\n if (wgs84Coordinates && !hasTileIndex) {\n throw new Error('MVT Loader: WGS84 coordinates need tileIndex property');\n }\n return options.mvt;\n}\n/**\n * @param feature\n * @param options\n * @returns decoded feature\n */\nfunction getDecodedFeature(feature, options, layerName) {\n const decodedFeature = feature.toGeoJSON(\n // @ts-expect-error What is going on here?\n options.coordinates === 'wgs84' ? options.tileIndex : transformToLocalCoordinates);\n // Add layer name to GeoJSON properties\n if (options.layerProperty) {\n decodedFeature.properties[options.layerProperty] = layerName;\n }\n return decodedFeature;\n}\n/**\n * @param feature\n * @param options\n * @returns decoded binary feature\n */\nfunction getDecodedFeatureBinary(feature, options, layerName) {\n const decodedFeature = feature.toBinaryCoordinates(\n // @ts-expect-error\n options.coordinates === 'wgs84' ? options.tileIndex : transformToLocalCoordinatesBinary);\n // Add layer name to GeoJSON properties\n if (options.layerProperty && decodedFeature.properties) {\n decodedFeature.properties[options.layerProperty] = layerName;\n }\n return decodedFeature;\n}\n/**\n * @param line\n * @param feature\n */\nfunction transformToLocalCoordinates(line, feature) {\n // This function transforms local coordinates in a\n // [0 - bufferSize, this.extent + bufferSize] range to a\n // [0 - (bufferSize / this.extent), 1 + (bufferSize / this.extent)] range.\n // The resulting extent would be 1.\n const { extent } = feature;\n for (let i = 0; i < line.length; i++) {\n const p = line[i];\n p[0] /= extent;\n p[1] /= extent;\n }\n}\nfunction transformToLocalCoordinatesBinary(data, feature) {\n // For the binary code path, the feature data is just\n // one big flat array, so we just divide each value\n const { extent } = feature;\n for (let i = 0, il = data.length; i < il; ++i) {\n data[i] /= extent;\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\n/**\n * Classifies an array of rings into polygons with outer rings and holes\n * @param rings\n * @returns polygons\n */\nexport function classifyRings(rings) {\n const len = rings.length;\n if (len <= 1)\n return [rings];\n const polygons = [];\n let polygon;\n let ccw;\n for (let i = 0; i < len; i++) {\n const area = signedArea(rings[i]);\n if (area === 0)\n continue; // eslint-disable-line no-continue\n if (ccw === undefined)\n ccw = area < 0;\n if (ccw === area < 0) {\n if (polygon)\n polygons.push(polygon);\n polygon = [rings[i]];\n }\n else if (polygon)\n polygon.push(rings[i]);\n }\n if (polygon)\n polygons.push(polygon);\n return polygons;\n}\n/**\n *\n * @param ring\n * @returns sum\n */\nexport function signedArea(ring) {\n let sum = 0;\n for (let i = 0, j = ring.length - 1, p1, p2; i < ring.length; j = i++) {\n p1 = ring[i];\n p2 = ring[j];\n sum += (p2[0] - p1[0]) * (p1[1] + p2[1]);\n }\n return sum;\n}\n/**\n *\n * @param tag\n * @param feature\n * @param pbf\n */\nexport function readFeature(tag, feature, pbf) {\n if (feature && pbf) {\n if (tag === 1)\n feature.id = pbf.readVarint();\n else if (tag === 2)\n readTag(pbf, feature);\n else if (tag === 3)\n feature.type = pbf.readVarint();\n else if (tag === 4)\n feature._geometry = pbf.pos;\n }\n}\n/**\n *\n * @param pbf\n * @param feature\n */\nexport function readTag(pbf, feature) {\n const end = pbf.readVarint() + pbf.pos;\n while (pbf.pos < end) {\n const key = feature._keys[pbf.readVarint()];\n const value = feature._values[pbf.readVarint()];\n feature.properties[key] = value;\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\nimport { readFeature, classifyRings } from \"../../helpers/mapbox-util-functions.js\";\nexport class VectorTileFeature {\n properties;\n extent;\n type;\n id;\n _pbf;\n _geometry;\n _keys;\n _values;\n static get types() {\n return ['Unknown', 'Point', 'LineString', 'Polygon'];\n }\n constructor(pbf, end, extent, keys, values) {\n // Public\n this.properties = {};\n this.extent = extent;\n this.type = 0;\n this.id = null;\n // Private\n this._pbf = pbf;\n this._geometry = -1;\n this._keys = keys;\n this._values = values;\n pbf.readFields(readFeature, this, end);\n }\n // eslint-disable-next-line complexity, max-statements\n loadGeometry() {\n const pbf = this._pbf;\n pbf.pos = this._geometry;\n const end = pbf.readVarint() + pbf.pos;\n let cmd = 1;\n let length = 0;\n let x = 0;\n let y = 0;\n const lines = [];\n let line;\n while (pbf.pos < end) {\n if (length <= 0) {\n const cmdLen = pbf.readVarint();\n cmd = cmdLen & 0x7;\n length = cmdLen >> 3;\n }\n length--;\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n if (cmd === 1) {\n // moveTo\n if (line)\n lines.push(line);\n line = [];\n }\n if (line)\n line.push([x, y]);\n }\n else if (cmd === 7) {\n // Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90\n if (line) {\n line.push(line[0].slice()); // closePolygon\n }\n }\n else {\n throw new Error(`unknown command ${cmd}`);\n }\n }\n if (line)\n lines.push(line);\n return lines;\n }\n // eslint-disable-next-line max-statements\n bbox() {\n const pbf = this._pbf;\n pbf.pos = this._geometry;\n const end = pbf.readVarint() + pbf.pos;\n let cmd = 1;\n let length = 0;\n let x = 0;\n let y = 0;\n let x1 = Infinity;\n let x2 = -Infinity;\n let y1 = Infinity;\n let y2 = -Infinity;\n while (pbf.pos < end) {\n if (length <= 0) {\n const cmdLen = pbf.readVarint();\n cmd = cmdLen & 0x7;\n length = cmdLen >> 3;\n }\n length--;\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n if (x < x1)\n x1 = x;\n if (x > x2)\n x2 = x;\n if (y < y1)\n y1 = y;\n if (y > y2)\n y2 = y;\n }\n else if (cmd !== 7) {\n throw new Error(`unknown command ${cmd}`);\n }\n }\n return [x1, y1, x2, y2];\n }\n _toGeoJSON(transform) {\n let coords = this.loadGeometry();\n let type = VectorTileFeature.types[this.type];\n let i;\n let j;\n // eslint-disable-next-line default-case\n switch (this.type) {\n case 1:\n const points = [];\n for (i = 0; i < coords.length; i++) {\n points[i] = coords[i][0];\n }\n coords = points;\n transform(coords, this);\n break;\n case 2:\n for (i = 0; i < coords.length; i++) {\n transform(coords[i], this);\n }\n break;\n case 3:\n coords = classifyRings(coords);\n for (i = 0; i < coords.length; i++) {\n for (j = 0; j < coords[i].length; j++) {\n transform(coords[i][j], this);\n }\n }\n break;\n }\n if (coords.length === 1) {\n coords = coords[0];\n }\n else {\n type = `Multi${type}`;\n }\n const result = {\n type: 'Feature',\n geometry: {\n type,\n coordinates: coords\n },\n properties: this.properties\n };\n if (this.id !== null) {\n result.id = this.id;\n }\n return result;\n }\n toGeoJSON(options) {\n if (typeof options === 'function') {\n return this._toGeoJSON(options);\n }\n const { x, y, z } = options;\n const size = this.extent * Math.pow(2, z);\n const x0 = this.extent * x;\n const y0 = this.extent * y;\n function project(line) {\n for (let j = 0; j < line.length; j++) {\n const p = line[j];\n p[0] = ((p[0] + x0) * 360) / size - 180;\n const y2 = 180 - ((p[1] + y0) * 360) / size;\n p[1] = (360 / Math.PI) * Math.atan(Math.exp((y2 * Math.PI) / 180)) - 90;\n }\n }\n return this._toGeoJSON(project);\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\nimport { VectorTileFeature } from \"./vector-tile-feature.js\";\nexport class VectorTileLayer {\n version;\n name;\n extent;\n length;\n _pbf;\n _keys;\n _values;\n _features;\n constructor(pbf, end) {\n // Public\n this.version = 1;\n this.name = '';\n this.extent = 4096;\n this.length = 0;\n // Private\n this._pbf = pbf;\n this._keys = [];\n this._values = [];\n this._features = [];\n pbf.readFields(readLayer, this, end);\n this.length = this._features.length;\n }\n /**\n * return feature `i` from this layer as a `VectorTileFeature`\n * @param index\n * @returns feature\n */\n feature(i) {\n if (i < 0 || i >= this._features.length) {\n throw new Error('feature index out of bounds');\n }\n this._pbf.pos = this._features[i];\n const end = this._pbf.readVarint() + this._pbf.pos;\n return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);\n }\n}\n/**\n *\n * @param tag\n * @param layer\n * @param pbf\n */\nfunction readLayer(tag, layer, pbf) {\n if (layer && pbf) {\n if (tag === 15)\n layer.version = pbf.readVarint();\n else if (tag === 1)\n layer.name = pbf.readString();\n else if (tag === 5)\n layer.extent = pbf.readVarint();\n else if (tag === 2)\n layer._features.push(pbf.pos);\n else if (tag === 3)\n layer._keys.push(pbf.readString());\n else if (tag === 4)\n layer._values.push(readValueMessage(pbf));\n }\n}\n/**\n *\n * @param pbf\n * @returns value\n */\nfunction readValueMessage(pbf) {\n let value = null;\n const end = pbf.readVarint() + pbf.pos;\n while (pbf.pos < end) {\n const tag = pbf.readVarint() >> 3;\n value =\n tag === 1\n ? pbf.readString()\n : tag === 2\n ? pbf.readFloat()\n : tag === 3\n ? pbf.readDouble()\n : tag === 4\n ? pbf.readVarint64()\n : tag === 5\n ? pbf.readVarint()\n : tag === 6\n ? pbf.readSVarint()\n : tag === 7\n ? pbf.readBoolean()\n : null;\n }\n return value;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\n// This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.\nimport { VectorTileLayer } from \"./vector-tile-layer.js\";\nexport class VectorTile {\n layers;\n constructor(pbf, end) {\n this.layers = pbf.readFields(readTile, {}, end);\n }\n}\n/**\n *\n * @param tag\n * @param layers\n * @param pbf\n */\nfunction readTile(tag, layers, pbf) {\n if (tag === 3) {\n if (pbf) {\n const layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);\n if (layer.length && layers) {\n layers[layer.name] = layer;\n }\n }\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\nimport { getPolygonSignedArea } from '@math.gl/polygon';\n/**\n * Classifies an array of rings into polygons with outer rings and holes\n * The function also detects holes which have zero area and\n * removes them. In doing so it modifies the input\n * `geom.data` array to remove the unneeded data\n *\n * @param geometry\n * @returns object\n */\n// eslint-disable-next-line max-statements\nexport function classifyRings(geom) {\n const len = geom.indices.length;\n const type = 'Polygon';\n if (len <= 1) {\n return {\n type,\n data: geom.data,\n areas: [[getPolygonSignedArea(geom.data)]],\n indices: [geom.indices]\n };\n }\n const areas = [];\n const polygons = [];\n let ringAreas = [];\n let polygon = [];\n let ccw;\n let offset = 0;\n for (let endIndex, i = 0, startIndex; i < len; i++) {\n startIndex = geom.indices[i] - offset;\n endIndex = geom.indices[i + 1] - offset || geom.data.length;\n const shape = geom.data.slice(startIndex, endIndex);\n const area = getPolygonSignedArea(shape);\n if (area === 0) {\n // This polygon has no area, so remove it from the shape\n // Remove the section from the data array\n const before = geom.data.slice(0, startIndex);\n const after = geom.data.slice(endIndex);\n geom.data = before.concat(after);\n // Need to offset any remaining indices as we have\n // modified the data buffer\n offset += endIndex - startIndex;\n // Do not add this index to the output and process next shape\n continue; // eslint-disable-line no-continue\n }\n if (ccw === undefined)\n ccw = area < 0;\n if (ccw === area < 0) {\n if (polygon.length) {\n areas.push(ringAreas);\n polygons.push(polygon);\n }\n polygon = [startIndex];\n ringAreas = [area];\n }\n else {\n ringAreas.push(area);\n polygon.push(startIndex);\n }\n }\n if (ringAreas)\n areas.push(ringAreas);\n if (polygon.length)\n polygons.push(polygon);\n return { type, areas, indices: polygons, data: geom.data };\n}\n/**\n *\n * @param data\n * @param x0\n * @param y0\n * @param size\n */\nexport function project(data, x0, y0, size) {\n for (let j = 0, jl = data.length; j < jl; j += 2) {\n data[j] = ((data[j] + x0) * 360) / size - 180;\n const y2 = 180 - ((data[j + 1] + y0) * 360) / size;\n data[j + 1] = (360 / Math.PI) * Math.atan(Math.exp((y2 * Math.PI) / 180)) - 90;\n }\n}\n/**\n * All code below is unchanged from the original Mapbox implemenation\n *\n * @param tag\n * @param feature\n * @param pbf\n */\nexport function readFeature(tag, feature, pbf) {\n if (feature && pbf) {\n if (tag === 1)\n feature.id = pbf.readVarint();\n else if (tag === 2)\n readTag(pbf, feature);\n else if (tag === 3)\n feature.type = pbf.readVarint();\n else if (tag === 4)\n feature._geometry = pbf.pos;\n }\n}\n/**\n * @param pbf\n * @param feature\n */\nexport function readTag(pbf, feature) {\n const end = pbf.readVarint() + pbf.pos;\n while (pbf.pos < end) {\n const key = feature._keys[pbf.readVarint()];\n const value = feature._values[pbf.readVarint()];\n feature.properties[key] = value;\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\nimport { classifyRings, project, readFeature } from \"../../helpers/binary-util-functions.js\";\n// Reduce GC by reusing variables\nlet endPos;\nlet cmd;\nlet cmdLen;\nlet length;\nlet x;\nlet y;\nlet i;\nexport const TEST_EXPORTS = {\n classifyRings\n};\nexport class BinaryVectorTileFeature {\n properties;\n extent;\n type;\n id;\n _pbf;\n _geometry;\n _keys;\n _values;\n _geometryInfo;\n // eslint-disable-next-line max-params\n constructor(pbf, end, extent, keys, values, geometryInfo) {\n // Public\n this.properties = {};\n this.extent = extent;\n this.type = 0;\n this.id = null;\n // Private\n this._pbf = pbf;\n this._geometry = -1;\n this._keys = keys;\n this._values = values;\n this._geometryInfo = geometryInfo;\n pbf.readFields(readFeature, this, end);\n }\n // eslint-disable-next-line complexity, max-statements\n loadGeometry() {\n const pbf = this._pbf;\n pbf.pos = this._geometry;\n endPos = pbf.readVarint() + pbf.pos;\n cmd = 1;\n length = 0;\n x = 0;\n y = 0;\n i = 0;\n // Note: I attempted to replace the `data` array with a\n // Float32Array, but performance was worse, both using\n // `set()` and direct index access. Also, we cannot\n // know how large the buffer should be, so it would\n // increase memory usage\n const indices = []; // Indices where geometries start\n const data = []; // Flat array of coordinate data\n while (pbf.pos < endPos) {\n if (length <= 0) {\n cmdLen = pbf.readVarint();\n cmd = cmdLen & 0x7;\n length = cmdLen >> 3;\n }\n length--;\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n if (cmd === 1) {\n // New line\n indices.push(i);\n }\n data.push(x, y);\n i += 2;\n }\n else if (cmd === 7) {\n // Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90\n if (i > 0) {\n const start = indices[indices.length - 1]; // start index of polygon\n data.push(data[start], data[start + 1]); // closePolygon\n i += 2;\n }\n }\n else {\n throw new Error(`unknown command ${cmd}`);\n }\n }\n return { data, indices };\n }\n /**\n *\n * @param transform\n * @returns result\n */\n _toBinaryCoordinates(transform) {\n // Expands the protobuf data to an intermediate Flat GeoJSON\n // data format, which maps closely to the binary data buffers.\n // It is similar to GeoJSON, but rather than storing the coordinates\n // in multidimensional arrays, we have a 1D `data` with all the\n // coordinates, and then index into this using the `indices`\n // parameter, e.g.\n //\n // geometry: {\n // type: 'Point', data: [1,2], indices: [0]\n // }\n // geometry: {\n // type: 'LineString', data: [1,2,3,4,...], indices: [0]\n // }\n // geometry: {\n // type: 'Polygon', data: [1,2,3,4,...], indices: [[0, 2]]\n // }\n // Thus the indices member lets us look up the relevant range\n // from the data array.\n // The Multi* versions of the above types share the same data\n // structure, just with multiple elements in the indices array\n const geom = this.loadGeometry();\n let geometry;\n // Apply the supplied transformation to data\n transform(geom.data, this);\n const coordLength = 2;\n // eslint-disable-next-line default-case\n switch (this.type) {\n case 1: // Point\n this._geometryInfo.pointFeaturesCount++;\n this._geometryInfo.pointPositionsCount += geom.indices.length;\n geometry = { type: 'Point', ...geom };\n break;\n case 2: // LineString\n this._geometryInfo.lineFeaturesCount++;\n this._geometryInfo.linePathsCount += geom.indices.length;\n this._geometryInfo.linePositionsCount += geom.data.length / coordLength;\n geometry = { type: 'LineString', ...geom };\n break;\n case 3: // Polygon\n geometry = classifyRings(geom);\n // Unlike Point & LineString geom.indices is a 2D array, thanks\n // to the classifyRings method\n this._geometryInfo.polygonFeaturesCount++;\n this._geometryInfo.polygonObjectsCount += geometry.indices.length;\n for (const indices of geometry.indices) {\n this._geometryInfo.polygonRingsCount += indices.length;\n }\n this._geometryInfo.polygonPositionsCount += geometry.data.length / coordLength;\n break;\n default:\n throw new Error(`Invalid geometry type: ${this.type}`);\n }\n const result = { type: 'Feature', geometry, properties: this.properties };\n if (this.id !== null) {\n result.id = this.id;\n }\n return result;\n }\n toBinaryCoordinates(options) {\n if (typeof options === 'function') {\n return this._toBinaryCoordinates(options);\n }\n const { x, y, z } = options;\n const size = this.extent * Math.pow(2, z);\n const x0 = this.extent * x;\n const y0 = this.extent * y;\n return this._toBinaryCoordinates((data) => project(data, x0, y0, size));\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\n/* eslint-disable indent */\n// This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.\nimport { BinaryVectorTileFeature } from \"./vector-tile-feature.js\";\nexport class BinaryVectorTileLayer {\n version;\n name;\n extent;\n length;\n _pbf;\n _keys;\n _values;\n _features;\n constructor(pbf, end) {\n // Public\n this.version = 1;\n this.name = '';\n this.extent = 4096;\n this.length = 0;\n // Private\n this._pbf = pbf;\n this._keys = [];\n this._values = [];\n this._features = [];\n pbf.readFields(readLayer, this, end);\n this.length = this._features.length;\n }\n /**\n * return feature `i` from this layer as a `BinaryVectorTileFeature`\n *\n * @param index\n * @param geometryInfo\n * @returns {BinaryVectorTileFeature}\n */\n feature(i, geometryInfo) {\n if (i < 0 || i >= this._features.length) {\n throw new Error('feature index out of bounds');\n }\n this._pbf.pos = this._features[i];\n const end = this._pbf.readVarint() + this._pbf.pos;\n return new BinaryVectorTileFeature(this._pbf, end, this.extent, this._keys, this._values, geometryInfo);\n }\n}\n/**\n *\n * @param tag\n * @param layer\n * @param pbf\n */\nfunction readLayer(tag, layer, pbf) {\n if (layer && pbf) {\n if (tag === 15)\n layer.version = pbf.readVarint();\n else if (tag === 1)\n layer.name = pbf.readString();\n else if (tag === 5)\n layer.extent = pbf.readVarint();\n else if (tag === 2)\n layer._features.push(pbf.pos);\n else if (tag === 3)\n layer._keys.push(pbf.readString());\n else if (tag === 4)\n layer._values.push(readValueMessage(pbf));\n }\n}\n/**\n *\n * @param pbf\n * @returns value\n */\nfunction readValueMessage(pbf) {\n let value = null;\n const end = pbf.readVarint() + pbf.pos;\n while (pbf.pos < end) {\n const tag = pbf.readVarint() >> 3;\n value =\n tag === 1\n ? pbf.readString()\n : tag === 2\n ? pbf.readFloat()\n : tag === 3\n ? pbf.readDouble()\n : tag === 4\n ? pbf.readVarint64()\n : tag === 5\n ? pbf.readVarint()\n : tag === 6\n ? pbf.readSVarint()\n : tag === 7\n ? pbf.readBoolean()\n : null;\n }\n return value;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\n// This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.\nimport { BinaryVectorTileLayer } from \"./vector-tile-layer.js\";\nexport class BinaryVectorTile {\n layers;\n constructor(pbf, end) {\n this.layers = pbf.readFields(readTile, {}, end);\n }\n}\n/**\n *\n * @param tag\n * @param layers\n * @param pbf\n */\nfunction readTile(tag, layers, pbf) {\n if (tag === 3) {\n if (pbf) {\n const layer = new BinaryVectorTileLayer(pbf, pbf.readVarint() + pbf.pos);\n if (layer.length && layers) {\n layers[layer.name] = layer;\n }\n }\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\nimport { parseMVT } from \"./lib/parse-mvt.js\";\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.2.1\" !== 'undefined' ? \"4.2.1\" : 'latest';\n/**\n * Worker loader for the Mapbox Vector Tile format\n */\nexport const MVTWorkerLoader = {\n dataType: null,\n batchType: null,\n name: 'Mapbox Vector Tile',\n id: 'mvt',\n module: 'mvt',\n version: VERSION,\n // Note: ArcGIS uses '.pbf' extension and 'application/octet-stream'\n extensions: ['mvt', 'pbf'],\n mimeTypes: [\n // https://www.iana.org/assignments/media-types/application/vnd.mapbox-vector-tile\n 'application/vnd.mapbox-vector-tile',\n 'application/x-protobuf'\n // 'application/octet-stream'\n ],\n worker: true,\n category: 'geometry',\n options: {\n mvt: {\n shape: 'geojson',\n coordinates: 'local',\n layerProperty: 'layerName',\n layers: undefined,\n tileIndex: null\n }\n }\n};\n/**\n * Loader for the Mapbox Vector Tile format\n */\nexport const MVTLoader = {\n ...MVTWorkerLoader,\n parse: async (arrayBuffer, options) => parseMVT(arrayBuffer, options),\n parseSync: parseMVT,\n binary: true\n};\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nconst isObject = (x) => x !== null && typeof x === 'object';\n/**\n * Parse TileJSON from metadata\n * @param jsonMetadata - metadata object\n * @param options - options\n * @returns - parsed TileJSON\n */\n// eslint-disable-next-line complexity\nexport function parseTileJSON(jsonMetadata, options) {\n if (!jsonMetadata || !isObject(jsonMetadata)) {\n return null;\n }\n let tileJSON = {\n name: jsonMetadata.name || '',\n description: jsonMetadata.description || ''\n };\n // tippecanoe\n if (typeof jsonMetadata.generator === 'string') {\n tileJSON.generator = jsonMetadata.generator;\n }\n if (typeof jsonMetadata.generator_options === 'string') {\n tileJSON.generatorOptions = jsonMetadata.generator_options;\n }\n // Tippecanoe emits `antimeridian_adjusted_bounds` instead of `bounds`\n tileJSON.boundingBox =\n parseBounds(jsonMetadata.bounds) || parseBounds(jsonMetadata.antimeridian_adjusted_bounds);\n // TODO - can be undefined - we could set to center of bounds...\n tileJSON.center = parseCenter(jsonMetadata.center);\n // TODO - can be undefined, we could extract from layers...\n tileJSON.maxZoom = safeParseFloat(jsonMetadata.maxzoom);\n // TODO - can be undefined, we could extract from layers...\n tileJSON.minZoom = safeParseFloat(jsonMetadata.minzoom);\n // Look for nested metadata embedded in .json field\n // TODO - document what source this applies to, when is this needed?\n if (typeof jsonMetadata?.json === 'string') {\n // try to parse json\n try {\n tileJSON.metaJson = JSON.parse(jsonMetadata.json);\n }\n catch (error) {\n // eslint-disable-next-line no-console\n console.warn('Failed to parse tilejson.json field', error);\n // do nothing\n }\n }\n // Look for fields in tilestats\n const tilestats = jsonMetadata.tilestats || tileJSON.metaJson?.tilestats;\n const tileStatsLayers = parseTilestatsLayers(tilestats, options);\n const tileJSONlayers = parseTileJSONLayers(jsonMetadata.vector_layers); // eslint-disable-line camelcase\n // TODO - merge in description from tilejson\n const layers = mergeLayers(tileJSONlayers, tileStatsLayers);\n tileJSON = {\n ...tileJSON,\n layers\n };\n if (tileJSON.maxZoom === null && layers.length > 0) {\n tileJSON.maxZoom = layers[0].maxZoom || null;\n }\n if (tileJSON.minZoom === null && layers.length > 0) {\n tileJSON.minZoom = layers[0].minZoom || null;\n }\n return tileJSON;\n}\nfunction parseTileJSONLayers(layers) {\n // Look for fields in vector_layers\n if (!Array.isArray(layers)) {\n return [];\n }\n return layers.map((layer) => parseTileJSONLayer(layer));\n}\nfunction parseTileJSONLayer(layer) {\n const fields = Object.entries(layer.fields || []).map(([key, datatype]) => ({\n name: key,\n ...attributeTypeToFieldType(String(datatype))\n }));\n const layer2 = { ...layer };\n delete layer2.fields;\n return {\n name: layer.id || '',\n ...layer2,\n fields\n };\n}\n/** parse Layers array from tilestats */\nfunction parseTilestatsLayers(tilestats, options) {\n if (isObject(tilestats) && Array.isArray(tilestats.layers)) {\n // we are in luck!\n return tilestats.layers.map((layer) => parseTilestatsForLayer(layer, options));\n }\n return [];\n}\nfunction parseTilestatsForLayer(layer, options) {\n const fields = [];\n const indexedAttributes = {};\n const attributes = layer.attributes || [];\n for (const attribute of attributes) {\n const name = attribute.attribute;\n if (typeof name === 'string') {\n // TODO - code copied from kepler.gl, need sample tilestats files to test\n if (name.split('|').length > 1) {\n // indexed field\n const fname = name.split('|')[0];\n indexedAttributes[fname] = indexedAttributes[fname] || [];\n indexedAttributes[fname].push(attribute);\n // eslint-disable-next-line no-console\n console.warn('ignoring tilestats indexed field', fname);\n }\n else if (!fields[name]) {\n fields.push(attributeToField(attribute, options));\n }\n else {\n // return (fields[name], attribute);\n }\n }\n }\n return {\n name: layer.layer || '',\n dominantGeometry: layer.geometry,\n fields\n };\n}\nfunction mergeLayers(layers, tilestatsLayers) {\n return layers.map((layer) => {\n const tilestatsLayer = tilestatsLayers.find((tsLayer) => tsLayer.name === layer.name);\n // For aesthetics in JSON dumps, we preserve field order (make sure layers is last)\n const fields = tilestatsLayer?.fields || [];\n const layer2 = { ...layer };\n delete layer2.fields;\n return {\n ...layer2,\n ...tilestatsLayer,\n fields\n };\n });\n}\n/**\n * bounds should be [minLng, minLat, maxLng, maxLat]\n *`[[w, s], [e, n]]`, indicates the limits of the bounding box using the axis units and order of the specified CRS.\n */\nfunction parseBounds(bounds) {\n // supported formats\n // string: \"-96.657715,40.126127,-90.140061,43.516689\",\n // array: [ -180, -85.05112877980659, 180, 85.0511287798066 ]\n const result = fromArrayOrString(bounds);\n // validate bounds\n if (Array.isArray(result) &&\n result.length === 4 &&\n [result[0], result[2]].every(isLng) &&\n [result[1], result[3]].every(isLat)) {\n return [\n [result[0], result[1]],\n [result[2], result[3]]\n ];\n }\n return undefined;\n}\nfunction parseCenter(center) {\n // supported formats\n // string: \"-96.657715,40.126127,-90.140061,43.516689\",\n // array: [-91.505127,41.615442,14]\n const result = fromArrayOrString(center);\n if (Array.isArray(result) &&\n result.length === 3 &&\n isLng(result[0]) &&\n isLat(result[1]) &&\n isZoom(result[2])) {\n return result;\n }\n return null;\n}\nfunction safeParseFloat(input) {\n const result = typeof input === 'string' ? parseFloat(input) : typeof input === 'number' ? input : null;\n return result === null || isNaN(result) ? null : result;\n}\n// https://github.com/mapbox/tilejson-spec/tree/master/2.2.0\nfunction isLat(num) {\n return Number.isFinite(num) && num <= 90 && num >= -90;\n}\nfunction isLng(num) {\n return Number.isFinite(num) && num <= 180 && num >= -180;\n}\nfunction isZoom(num) {\n return Number.isFinite(num) && num >= 0 && num <= 22;\n}\nfunction fromArrayOrString(data) {\n if (typeof data === 'string') {\n return data.split(',').map(parseFloat);\n }\n else if (Array.isArray(data)) {\n return data;\n }\n return null;\n}\n// possible types https://github.com/mapbox/tippecanoe#modifying-feature-attributes\nconst attrTypeMap = {\n number: {\n type: 'float32'\n },\n numeric: {\n type: 'float32'\n },\n string: {\n type: 'utf8'\n },\n vachar: {\n type: 'utf8'\n },\n float: {\n type: 'float32'\n },\n int: {\n type: 'int32'\n },\n int4: {\n type: 'int32'\n },\n boolean: {\n type: 'boolean'\n },\n bool: {\n type: 'boolean'\n }\n};\nfunction attributeToField(attribute = {}, options) {\n const fieldTypes = attributeTypeToFieldType(attribute.type);\n const field = {\n name: attribute.attribute,\n // what happens if attribute type is string...\n // filterProps: getFilterProps(fieldTypes.type, attribute),\n ...fieldTypes\n };\n // attribute: \"_season_peaks_color\"\n // count: 1000\n // max: 0.95\n // min: 0.24375\n // type: \"number\"\n if (typeof attribute.min === 'number') {\n field.min = attribute.min;\n }\n if (typeof attribute.max === 'number') {\n field.max = attribute.max;\n }\n if (typeof attribute.count === 'number') {\n field.uniqueValueCount = attribute.count;\n }\n if (attribute.values) {\n // Too much data? Add option?\n field.values = attribute.values;\n }\n if (field.values && typeof options.maxValues === 'number') {\n // Too much data? Add option?\n field.values = field.values?.slice(0, options.maxValues);\n }\n return field;\n}\nfunction attributeTypeToFieldType(aType) {\n const type = aType.toLowerCase();\n if (!type || !attrTypeMap[type]) {\n // console.warn(\n // `cannot convert attribute type ${type} to loaders.gl data type, use string by default`\n // );\n }\n return attrTypeMap[type] || { type: 'string' };\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { parseTileJSON } from \"./lib/parse-tilejson.js\";\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.2.1\" !== 'undefined' ? \"4.2.1\" : 'latest';\n/**\n * Loader for TileJSON metadata\n */\nexport const TileJSONLoader = {\n dataType: null,\n batchType: null,\n name: 'TileJSON',\n id: 'tilejson',\n module: 'pmtiles',\n version: VERSION,\n worker: true,\n extensions: ['json'],\n mimeTypes: ['application/json'],\n text: true,\n options: {\n tilejson: {\n maxValues: undefined\n }\n },\n parse: async (arrayBuffer, options) => {\n const jsonString = new TextDecoder().decode(arrayBuffer);\n const json = JSON.parse(jsonString);\n const tilejsonOptions = { ...TileJSONLoader.options.tilejson, ...options?.tilejson };\n return parseTileJSON(json, tilejsonOptions);\n },\n parseTextSync: (text, options) => {\n const json = JSON.parse(text);\n const tilejsonOptions = { ...TileJSONLoader.options.tilejson, ...options?.tilejson };\n return parseTileJSON(json, tilejsonOptions);\n }\n};\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { DataSource, resolvePath } from '@loaders.gl/loader-utils';\nimport { ImageLoader, getBinaryImageMetadata } from '@loaders.gl/images';\nimport { MVTLoader, TileJSONLoader } from '@loaders.gl/mvt';\n/**\n * MVT data source for Mapbox Vector Tiles v1.\n */\n/**\n * A PMTiles data source\n * @note Can be either a raster or vector tile source depending on the contents of the PMTiles file.\n */\nexport class MVTSource extends DataSource {\n props;\n url;\n metadataUrl = null;\n data;\n schema = 'tms';\n metadata;\n extension;\n mimeType = null;\n constructor(props) {\n super(props);\n this.props = props;\n this.url = resolvePath(props.url);\n this.metadataUrl =\n props.metadataUrl === undefined ? `${this.url}/tilejson.json` : props.metadataUrl;\n this.extension = props.extension || '.png';\n this.data = this.url;\n this.getTileData = this.getTileData.bind(this);\n this.metadata = this.getMetadata();\n if (isURLTemplate(this.url)) {\n this.schema = 'template';\n }\n }\n // @ts-ignore - Metadata type misalignment\n async getMetadata() {\n if (!this.metadataUrl) {\n return null;\n }\n let response;\n try {\n // Annoyingly, on CORS errors, fetch doesn't use the response status/ok mechanism but instead throws\n // CORS errors are common when requesting an unavailable sub resource such as a metadata file or an unavailable tile)\n response = await this.fetch(this.metadataUrl);\n }\n catch (error) {\n // eslint-disable-next-line no-console\n console.error(error.message);\n return null;\n }\n if (!response.ok) {\n // eslint-disable-next-line no-console\n console.error(response.statusText);\n return null;\n }\n const tileJSON = await response.text();\n const metadata = TileJSONLoader.parseTextSync?.(tileJSON) || null;\n // TODO add metadata attributions\n // metadata.attributions = [...this.props.attributions, ...(metadata.attributions || [])];\n // if (metadata?.mimeType) {\n // this.mimeType = metadata?.tileMIMEType;\n // }\n return metadata;\n }\n getTileMIMEType() {\n return this.mimeType;\n }\n async getTile(tileParams) {\n const { x, y, zoom: z } = tileParams;\n const tileUrl = this.getTileURL(x, y, z);\n const response = await this.fetch(tileUrl);\n if (!response.ok) {\n return null;\n }\n const arrayBuffer = await response.arrayBuffer();\n return arrayBuffer;\n }\n // Tile Source interface implementation: deck.gl compatible API\n // TODO - currently only handles image tiles, not vector tiles\n async getTileData(tileParams) {\n const { x, y, z } = tileParams.index;\n // const metadata = await this.metadata;\n // mimeType = metadata?.tileMIMEType || 'application/vnd.mapbox-vector-tile';\n const arrayBuffer = await this.getTile({ x, y, zoom: z, layers: [] });\n if (arrayBuffer === null) {\n return null;\n }\n const imageMetadata = getBinaryImageMetadata(arrayBuffer);\n this.mimeType =\n this.mimeType || imageMetadata?.mimeType || 'application/vnd.mapbox-vector-tile';\n switch (this.mimeType) {\n case 'application/vnd.mapbox-vector-tile':\n return await this._parseVectorTile(arrayBuffer, { x, y, zoom: z, layers: [] });\n default:\n return await this._parseImageTile(arrayBuffer);\n }\n }\n // ImageTileSource interface implementation\n async getImageTile(tileParams) {\n const arrayBuffer = await this.getTile(tileParams);\n return arrayBuffer ? this._parseImageTile(arrayBuffer) : null;\n }\n async _parseImageTile(arrayBuffer) {\n return await ImageLoader.parse(arrayBuffer, this.loadOptions);\n }\n // VectorTileSource interface implementation\n async getVectorTile(tileParams) {\n const arrayBuffer = await this.getTile(tileParams);\n return arrayBuffer ? this._parseVectorTile(arrayBuffer, tileParams) : null;\n }\n async _parseVectorTile(arrayBuffer, tileParams) {\n const loadOptions = {\n shape: 'geojson-table',\n mvt: {\n coordinates: 'wgs84',\n tileIndex: { x: tileParams.x, y: tileParams.y, z: tileParams.zoom },\n ...this.loadOptions?.mvt\n },\n ...this.loadOptions\n };\n return await MVTLoader.parse(arrayBuffer, loadOptions);\n }\n getMetadataUrl() {\n return this.metadataUrl;\n }\n getTileURL(x, y, z) {\n switch (this.schema) {\n case 'xyz':\n return `${this.url}/${x}/${y}/${z}${this.extension}`;\n case 'tms':\n return `${this.url}/${z}/${x}/${y}${this.extension}`;\n case 'template':\n return getURLFromTemplate(this.url, x, y, z, '0');\n default:\n throw new Error(this.schema);\n }\n }\n}\nexport function isURLTemplate(s) {\n return /(?=.*{z})(?=.*{x})(?=.*({y}|{-y}))|(?=.*{x})(?=.*({y}|{-y})(?=.*{z}))/.test(s);\n}\nconst xRegex = new RegExp('{x}', 'g');\nconst yRegex = new RegExp('{y}', 'g');\nconst zRegex = new RegExp('{z}', 'g');\n/**\n * Get a URL from a URL template\n * @note copied from deck.gl/modules/geo-layers/src/tileset-2d/utils.ts\n * @param template - URL template\n * @param x - tile x coordinate\n * @param y - tile y coordinate\n * @param z - tile z coordinate\n * @param id - tile id\n * @returns URL\n */\nexport function getURLFromTemplate(template, x, y, z, id = '0') {\n if (Array.isArray(template)) {\n const i = stringHash(id) % template.length;\n template = template[i];\n }\n let url = template;\n url = url.replace(xRegex, String(x));\n url = url.replace(yRegex, String(y));\n url = url.replace(zRegex, String(z));\n // Back-compatible support for {-y}\n if (Number.isInteger(y) && Number.isInteger(z)) {\n url = url.replace(/\\{-y\\}/g, String(Math.pow(2, z) - y - 1));\n }\n return url;\n}\nfunction stringHash(s) {\n return Math.abs(s.split('').reduce((a, b) => ((a << 5) - a + b.charCodeAt(0)) | 0, 0));\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license\n/**\n * Calculate simplification data using optimized Douglas-Peucker algorithm\n *\n * @param coords contiguous list of coordinates\n * @param first first coord to simplify\n * @param last last coord to simplify\n * @param sqTolerance tolerance (square distance)\n */\nexport function simplify(coords, first, last, sqTolerance) {\n let maxSqDist = sqTolerance;\n const mid = (last - first) >> 1;\n let minPosToMid = last - first;\n let index;\n const ax = coords[first];\n const ay = coords[first + 1];\n const bx = coords[last];\n const by = coords[last + 1];\n for (let i = first + 3; i < last; i += 3) {\n const d = getSqSegDist(coords[i], coords[i + 1], ax, ay, bx, by);\n if (d > maxSqDist) {\n index = i;\n maxSqDist = d;\n }\n else if (d === maxSqDist) {\n // a workaround to ensure we choose a pivot close to the middle of the list,\n // reducing recursion depth, for certain degenerate inputs\n // https://github.com/mapbox/geojson-vt/issues/104\n const posToMid = Math.abs(i - mid);\n if (posToMid < minPosToMid) {\n index = i;\n minPosToMid = posToMid;\n }\n }\n }\n if (maxSqDist > sqTolerance) {\n if (index - first > 3)\n simplify(coords, first, index, sqTolerance);\n coords[index + 2] = maxSqDist;\n if (last - index > 3)\n simplify(coords, index, last, sqTolerance);\n }\n}\n/** square distance from a point to a segment */\n// eslint-disable-next-line max-params\nfunction getSqSegDist(px, py, x, y, bx, by) {\n let dx = bx - x;\n let dy = by - y;\n if (dx !== 0 || dy !== 0) {\n const t = ((px - x) * dx + (py - y) * dy) / (dx * dx + dy * dy);\n if (t > 1) {\n x = bx;\n y = by;\n }\n else if (t > 0) {\n x += dx * t;\n y += dy * t;\n }\n }\n dx = px - x;\n dy = py - y;\n return dx * dx + dy * dy;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license\nexport function createFeature(id, type, geom, tags) {\n const feature = {\n // eslint-disable-next-line\n id: id == null ? null : id,\n type,\n geometry: geom,\n tags,\n minX: Infinity,\n minY: Infinity,\n maxX: -Infinity,\n maxY: -Infinity\n };\n if (type === 'Point' || type === 'MultiPoint' || type === 'LineString') {\n calcLineBBox(feature, geom);\n }\n else if (type === 'Polygon') {\n // the outer ring (ie [0]) contains all inner rings\n calcLineBBox(feature, geom[0]);\n }\n else if (type === 'MultiLineString') {\n for (const line of geom) {\n calcLineBBox(feature, line);\n }\n }\n else if (type === 'MultiPolygon') {\n for (const polygon of geom) {\n // the outer ring (ie [0]) contains all inner rings\n calcLineBBox(feature, polygon[0]);\n }\n }\n return feature;\n}\nfunction calcLineBBox(feature, geom) {\n for (let i = 0; i < geom.length; i += 3) {\n feature.minX = Math.min(feature.minX, geom[i]);\n feature.minY = Math.min(feature.minY, geom[i + 1]);\n feature.maxX = Math.max(feature.maxX, geom[i]);\n feature.maxY = Math.max(feature.maxY, geom[i + 1]);\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license\nimport { simplify } from \"./simplify.js\";\nimport { createFeature } from \"./feature.js\";\n// converts GeoJSON feature into an intermediate projected JSON vector format with simplification data\nexport function convert(data, options) {\n const features = [];\n if (data.type === 'FeatureCollection') {\n for (let i = 0; i < data.features.length; i++) {\n convertFeature(features, data.features[i], options, i);\n }\n }\n else if (data.type === 'Feature') {\n convertFeature(features, data, options);\n }\n else {\n // single geometry or a geometry collection\n convertFeature(features, { geometry: data }, options);\n }\n return features;\n}\nfunction convertFeature(features, geojson, options, index) {\n if (!geojson.geometry) {\n return;\n }\n const coords = geojson.geometry.coordinates;\n const type = geojson.geometry.type;\n const tolerance = Math.pow(options.tolerance / ((1 << options.maxZoom) * options.extent), 2);\n let geometry = [];\n let id = geojson.id;\n if (options.promoteId) {\n id = geojson.properties[options.promoteId];\n }\n else if (options.generateId) {\n id = index || 0;\n }\n if (type === 'Point') {\n convertPoint(coords, geometry);\n }\n else if (type === 'MultiPoint') {\n for (const p of coords) {\n convertPoint(p, geometry);\n }\n }\n else if (type === 'LineString') {\n convertLine(coords, geometry, tolerance, false);\n }\n else if (type === 'MultiLineString') {\n if (options.lineMetrics) {\n // explode into linestrings to be able to track metrics\n for (const line of coords) {\n geometry = [];\n convertLine(line, geometry, tolerance, false);\n features.push(createFeature(id, 'LineString', geometry, geojson.properties));\n }\n return;\n }\n else {\n convertLines(coords, geometry, tolerance, false);\n }\n }\n else if (type === 'Polygon') {\n convertLines(coords, geometry, tolerance, true);\n }\n else if (type === 'MultiPolygon') {\n for (const polygon of coords) {\n const newPolygon = [];\n convertLines(polygon, newPolygon, tolerance, true);\n geometry.push(newPolygon);\n }\n }\n else if (type === 'GeometryCollection') {\n for (const singleGeometry of geojson.geometry.geometries) {\n convertFeature(features, {\n id,\n geometry: singleGeometry,\n properties: geojson.properties\n }, options, index);\n }\n return;\n }\n else {\n throw new Error('Input data is not a valid GeoJSON object.');\n }\n features.push(createFeature(id, type, geometry, geojson.properties));\n}\nfunction convertPoint(coords, out) {\n out.push(projectX(coords[0]), projectY(coords[1]), 0);\n}\nfunction convertLine(ring, out, tolerance, isPolygon) {\n let x0, y0;\n let size = 0;\n for (let j = 0; j < ring.length; j++) {\n const x = projectX(ring[j][0]);\n const y = projectY(ring[j][1]);\n out.push(x, y, 0);\n if (j > 0) {\n if (isPolygon) {\n size += (x0 * y - x * y0) / 2; // area\n }\n else {\n size += Math.sqrt(Math.pow(x - x0, 2) + Math.pow(y - y0, 2)); // length\n }\n }\n x0 = x;\n y0 = y;\n }\n const last = out.length - 3;\n out[2] = 1;\n simplify(out, 0, last, tolerance);\n out[last + 2] = 1;\n out.size = Math.abs(size);\n out.start = 0;\n out.end = out.size;\n}\nfunction convertLines(rings, out, tolerance, isPolygon) {\n for (let i = 0; i < rings.length; i++) {\n const geom = [];\n convertLine(rings[i], geom, tolerance, isPolygon);\n out.push(geom);\n }\n}\nfunction projectX(x) {\n return x / 360 + 0.5;\n}\nfunction projectY(y) {\n const sin = Math.sin((y * Math.PI) / 180);\n const y2 = 0.5 - (0.25 * Math.log((1 + sin) / (1 - sin))) / Math.PI;\n return y2 < 0 ? 0 : y2 > 1 ? 1 : y2;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license\nimport { createFeature } from \"./feature.js\";\n/* eslint-disable no-continue */\n/**\n * Clip features between two vertical or horizontal axis-parallel lines:\n * | |\n * ___|___ | /\n * / | \\____|____/\n * | |\n *\n * @param k1 and k2 are the line coordinates\n * @param axis: 0 for x, 1 for y\n * @param minAll and maxAll: minimum and maximum coordinate value for all features\n */\n// eslint-disable-next-line max-params, complexity, max-statements\nexport function clip(features, scale, k1, k2, axis, minAll, maxAll, options) {\n k1 /= scale;\n k2 /= scale;\n if (minAll >= k1 && maxAll < k2) {\n return features;\n }\n // trivial accept\n else if (maxAll < k1 || minAll >= k2) {\n return null; // trivial reject\n }\n const clipped = [];\n for (const feature of features) {\n const geometry = feature.geometry;\n let type = feature.type;\n const min = axis === 0 ? feature.minX : feature.minY;\n const max = axis === 0 ? feature.maxX : feature.maxY;\n if (min >= k1 && max < k2) {\n // trivial accept\n clipped.push(feature);\n continue;\n }\n else if (max < k1 || min >= k2) {\n // trivial reject\n continue;\n }\n let newGeometry = [];\n if (type === 'Point' || type === 'MultiPoint') {\n clipPoints(geometry, newGeometry, k1, k2, axis);\n }\n else if (type === 'LineString') {\n clipLine(geometry, newGeometry, k1, k2, axis, false, options.lineMetrics);\n }\n else if (type === 'MultiLineString') {\n clipLines(geometry, newGeometry, k1, k2, axis, false);\n }\n else if (type === 'Polygon') {\n clipLines(geometry, newGeometry, k1, k2, axis, true);\n }\n else if (type === 'MultiPolygon') {\n for (const polygon of geometry) {\n const newPolygon = [];\n clipLines(polygon, newPolygon, k1, k2, axis, true);\n if (newPolygon.length) {\n newGeometry.push(newPolygon);\n }\n }\n }\n if (newGeometry.length) {\n if (options.lineMetrics && type === 'LineString') {\n for (const line of newGeometry) {\n clipped.push(createFeature(feature.id, type, line, feature.tags));\n }\n continue;\n }\n if (type === 'LineString' || type === 'MultiLineString') {\n if (newGeometry.length === 1) {\n type = 'LineString';\n // @ts-expect-error TODO - use proper GeoJSON geometry types\n newGeometry = newGeometry[0];\n }\n else {\n type = 'MultiLineString';\n }\n }\n if (type === 'Point' || type === 'MultiPoint') {\n type = newGeometry.length === 3 ? 'Point' : 'MultiPoint';\n }\n clipped.push(createFeature(feature.id, type, newGeometry, feature.tags));\n }\n }\n return clipped.length ? clipped : null;\n}\nfunction clipPoints(geom, newGeom, k1, k2, axis) {\n for (let i = 0; i < geom.length; i += 3) {\n const a = geom[i + axis];\n if (a >= k1 && a <= k2) {\n addPoint(newGeom, geom[i], geom[i + 1], geom[i + 2]);\n }\n }\n}\n// eslint-disable-next-line max-params, complexity, max-statements\nfunction clipLine(geom, newGeom, k1, k2, axis, isPolygon, trackMetrics) {\n let slice = newSlice(geom);\n const intersect = axis === 0 ? intersectX : intersectY;\n let len = geom.start;\n let segLen;\n let t;\n for (let i = 0; i < geom.length - 3; i += 3) {\n const ax = geom[i];\n const ay = geom[i + 1];\n const az = geom[i + 2];\n const bx = geom[i + 3];\n const by = geom[i + 4];\n const a = axis === 0 ? ax : ay;\n const b = axis === 0 ? bx : by;\n let exited = false;\n if (trackMetrics) {\n segLen = Math.sqrt(Math.pow(ax - bx, 2) + Math.pow(ay - by, 2));\n }\n if (a < k1) {\n // ---|--> | (line enters the clip region from the left)\n if (b > k1) {\n t = intersect(slice, ax, ay, bx, by, k1);\n if (trackMetrics) {\n slice.start = len + segLen * t;\n }\n }\n }\n else if (a > k2) {\n // | <--|--- (line enters the clip region from the right)\n if (b < k2) {\n t = intersect(slice, ax, ay, bx, by, k2);\n if (trackMetrics) {\n slice.start = len + segLen * t;\n }\n }\n }\n else {\n addPoint(slice, ax, ay, az);\n }\n if (b < k1 && a >= k1) {\n // <--|--- | or <--|-----|--- (line exits the clip region on the left)\n t = intersect(slice, ax, ay, bx, by, k1);\n exited = true;\n }\n if (b > k2 && a <= k2) {\n // | ---|--> or ---|-----|--> (line exits the clip region on the right)\n t = intersect(slice, ax, ay, bx, by, k2);\n exited = true;\n }\n if (!isPolygon && exited) {\n if (trackMetrics) {\n slice.end = len + segLen * t;\n }\n newGeom.push(slice);\n slice = newSlice(geom);\n }\n if (trackMetrics) {\n len += segLen;\n }\n }\n // add the last point\n let last = geom.length - 3;\n const ax = geom[last];\n const ay = geom[last + 1];\n const az = geom[last + 2];\n const a = axis === 0 ? ax : ay;\n if (a >= k1 && a <= k2)\n addPoint(slice, ax, ay, az);\n // close the polygon if its endpoints are not the same after clipping\n last = slice.length - 3;\n if (isPolygon && last >= 3 && (slice[last] !== slice[0] || slice[last + 1] !== slice[1])) {\n addPoint(slice, slice[0], slice[1], slice[2]);\n }\n // add the final slice\n if (slice.length) {\n newGeom.push(slice);\n }\n}\nclass Slice extends Array {\n size;\n start;\n end;\n}\nfunction newSlice(line) {\n const slice = [];\n slice.size = line.size;\n slice.start = line.start;\n slice.end = line.end;\n return slice;\n}\n// eslint-disable-next-line max-params\nfunction clipLines(geom, newGeom, k1, k2, axis, isPolygon) {\n for (const line of geom) {\n clipLine(line, newGeom, k1, k2, axis, isPolygon, false);\n }\n}\nfunction addPoint(out, x, y, z) {\n out.push(x, y, z);\n}\n// eslint-disable-next-line max-params\nfunction intersectX(out, ax, ay, bx, by, x) {\n const t = (x - ax) / (bx - ax);\n addPoint(out, x, ay + (by - ay) * t, 1);\n return t;\n}\n// eslint-disable-next-line max-params\nfunction intersectY(out, ax, ay, bx, by, y) {\n const t = (y - ay) / (by - ay);\n addPoint(out, ax + (bx - ax) * t, y, 1);\n return t;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license\nimport { clip } from \"./clip.js\";\nimport { createFeature } from \"./feature.js\";\n/**\n * Wrap across antemeridian, by clipping into two tiles, shifting the overflowing x coordinates\n * @param features list of features to be wrapped\n * @param options buffer and extent\n * @returns\n */\nexport function wrap(features, options) {\n const buffer = options.buffer / options.extent;\n let merged = features;\n const left = clip(features, 1, -1 - buffer, buffer, 0, -1, 2, options); // left world copy\n const right = clip(features, 1, 1 - buffer, 2 + buffer, 0, -1, 2, options); // right world copy\n if (left || right) {\n merged = clip(features, 1, -buffer, 1 + buffer, 0, -1, 2, options) || []; // center world copy\n if (left) {\n merged = shiftFeatureCoords(left, 1).concat(merged); // merge left into center\n }\n if (right) {\n merged = merged.concat(shiftFeatureCoords(right, -1)); // merge right into center\n }\n }\n return merged;\n}\n/**\n * Shift the x coordinates of a list of features\n * @param features list of features to shift x coordinates for\n * @param offset\n * @returns\n */\nfunction shiftFeatureCoords(features, offset) {\n const newFeatures = [];\n for (let i = 0; i < features.length; i++) {\n const feature = features[i];\n const type = feature.type;\n let newGeometry;\n if (type === 'Point' || type === 'MultiPoint' || type === 'LineString') {\n newGeometry = shiftCoords(feature.geometry, offset);\n }\n else if (type === 'MultiLineString' || type === 'Polygon') {\n newGeometry = [];\n for (const line of feature.geometry) {\n newGeometry.push(shiftCoords(line, offset));\n }\n }\n else if (type === 'MultiPolygon') {\n newGeometry = [];\n for (const polygon of feature.geometry) {\n const newPolygon = [];\n for (const line of polygon) {\n // @ts-expect-error TODO\n newPolygon.push(shiftCoords(line, offset));\n }\n newGeometry.push(newPolygon);\n }\n }\n newFeatures.push(createFeature(feature.id, type, newGeometry, feature.tags));\n }\n return newFeatures;\n}\nclass Points extends Array {\n size;\n start;\n end;\n}\n/**\n * Shift the x coordinate of every point\n * @param points\n * @param offset\n * @returns\n */\nfunction shiftCoords(points, offset) {\n const newPoints = [];\n newPoints.size = points.size;\n if (points.start !== undefined) {\n newPoints.start = points.start;\n newPoints.end = points.end;\n }\n for (let i = 0; i < points.length; i += 3) {\n newPoints.push(points[i] + offset, points[i + 1], points[i + 2]);\n }\n return newPoints;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license\n/**\n * Transforms the coordinates of each feature in the given tile from\n * mercator-projected space into (extent x extent) tile space.\n */\nexport function transformTile(tile, extent) {\n if (tile.transformed) {\n return tile;\n }\n const z2 = 1 << tile.z;\n const tx = tile.x;\n const ty = tile.y;\n for (const feature of tile.features) {\n const geom = feature.geometry;\n const type = feature.type;\n feature.geometry = [];\n if (type === 1) {\n for (let j = 0; j < geom.length; j += 2) {\n feature.geometry.push(transformPoint(geom[j], geom[j + 1], extent, z2, tx, ty));\n }\n }\n else {\n for (let j = 0; j < geom.length; j++) {\n const ring = [];\n for (let k = 0; k < geom[j].length; k += 2) {\n ring.push(transformPoint(geom[j][k], geom[j][k + 1], extent, z2, tx, ty));\n }\n feature.geometry.push(ring);\n }\n }\n }\n tile.transformed = true;\n return tile;\n}\n// eslint-disable-next-line max-params\nfunction transformPoint(x, y, extent, z2, tx, ty) {\n return [Math.round(extent * (x * z2 - tx)), Math.round(extent * (y * z2 - ty))];\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license\n/**\n * Create a tile from features and tile index\n */\nexport function createTile(features, z, tx, ty, options) {\n const tolerance = z === options.maxZoom ? 0 : options.tolerance / ((1 << z) * options.extent);\n const tile = {\n features: [],\n numPoints: 0,\n numSimplified: 0,\n numFeatures: features.length,\n source: null,\n x: tx,\n y: ty,\n z,\n transformed: false,\n minX: 2,\n minY: 1,\n maxX: -1,\n maxY: 0\n };\n for (const feature of features) {\n addFeature(tile, feature, tolerance, options);\n }\n return tile;\n}\n// eslint-disable-next-line complexity, max-statements\nfunction addFeature(tile, feature, tolerance, options) {\n const geom = feature.geometry;\n const type = feature.type;\n const simplified = [];\n tile.minX = Math.min(tile.minX, feature.minX);\n tile.minY = Math.min(tile.minY, feature.minY);\n tile.maxX = Math.max(tile.maxX, feature.maxX);\n tile.maxY = Math.max(tile.maxY, feature.maxY);\n if (type === 'Point' || type === 'MultiPoint') {\n for (let i = 0; i < geom.length; i += 3) {\n simplified.push(geom[i], geom[i + 1]);\n tile.numPoints++;\n tile.numSimplified++;\n }\n }\n else if (type === 'LineString') {\n addLine(simplified, geom, tile, tolerance, false, false);\n }\n else if (type === 'MultiLineString' || type === 'Polygon') {\n for (let i = 0; i < geom.length; i++) {\n addLine(simplified, geom[i], tile, tolerance, type === 'Polygon', i === 0);\n }\n }\n else if (type === 'MultiPolygon') {\n for (let k = 0; k < geom.length; k++) {\n const polygon = geom[k];\n for (let i = 0; i < polygon.length; i++) {\n addLine(simplified, polygon[i], tile, tolerance, true, i === 0);\n }\n }\n }\n if (simplified.length) {\n let tags = feature.tags || null;\n if (type === 'LineString' && options.lineMetrics) {\n tags = {};\n for (const key in feature.tags)\n tags[key] = feature.tags[key];\n // eslint-disable-next-line camelcase\n tags.mapbox_clip_start = geom.start / geom.size;\n // eslint-disable-next-line camelcase\n tags.mapbox_clip_end = geom.end / geom.size;\n }\n // @ts-expect-error TODO - create sub type?\n const tileFeature = {\n geometry: simplified,\n type: type === 'Polygon' || type === 'MultiPolygon'\n ? 3\n : type === 'LineString' || type === 'MultiLineString'\n ? 2\n : 1,\n tags\n };\n if (feature.id !== null) {\n tileFeature.id = feature.id;\n }\n tile.features.push(tileFeature);\n }\n}\n// eslint-disable-next-line max-params, max-statements\nfunction addLine(result, geom, tile, tolerance, isPolygon, isOuter) {\n const sqTolerance = tolerance * tolerance;\n if (tolerance > 0 && geom.size < (isPolygon ? sqTolerance : tolerance)) {\n tile.numPoints += geom.length / 3;\n return;\n }\n const ring = [];\n for (let i = 0; i < geom.length; i += 3) {\n if (tolerance === 0 || geom[i + 2] > sqTolerance) {\n tile.numSimplified++;\n ring.push(geom[i], geom[i + 1]);\n }\n tile.numPoints++;\n }\n if (isPolygon)\n rewind(ring, isOuter);\n result.push(ring);\n}\nfunction rewind(ring, clockwise) {\n let area = 0;\n for (let i = 0, j = ring.length - 2; i < ring.length; j = i, i += 2) {\n area += (ring[i] - ring[j]) * (ring[i + 1] + ring[j + 1]);\n }\n if (area > 0 === clockwise) {\n for (let i = 0, len = ring.length; i < len / 2; i += 2) {\n const x = ring[i];\n const y = ring[i + 1];\n ring[i] = ring[len - 2 - i];\n ring[i + 1] = ring[len - 1 - i];\n ring[len - 2 - i] = x;\n ring[len - 1 - i] = y;\n }\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license\nimport { convert } from \"./convert.js\"; // GeoJSON conversion and preprocessing\nimport { clip } from \"./clip.js\"; // stripe clipping algorithm\nimport { wrap } from \"./wrap.js\"; // date line processing\nimport { transformTile } from \"./transform.js\"; // coordinate transformation\nimport { createTile } from \"./tile.js\"; // final simplified tile generation\nconst DEFAULT_OPTIONS = {\n maxZoom: 14, // max zoom to preserve detail on\n indexMaxZoom: 5, // max zoom in the tile index\n indexMaxPoints: 100000, // max number of points per tile in the tile index\n tolerance: 3, // simplification tolerance (higher means simpler)\n extent: 4096, // tile extent\n buffer: 64, // tile buffer on each side\n lineMetrics: false, // whether to calculate line metrics\n // @ts-expect-error Ensures all these required params have defaults\n promoteId: undefined, // name of a feature property to be promoted to feature.id\n generateId: false, // whether to generate feature ids. Cannot be used with promoteId\n debug: 0 // logging level (0, 1 or 2)\n};\nexport class GeoJSONTiler {\n options;\n // tiles and tileCoords are part of the public API\n tiles = {};\n tileCoords = [];\n stats = {};\n total = 0;\n constructor(data, options) {\n this.options = { ...DEFAULT_OPTIONS, ...options };\n options = this.options;\n const debug = options.debug;\n if (debug)\n console.time('preprocess data');\n if (this.options.maxZoom < 0 || this.options.maxZoom > 24) {\n throw new Error('maxZoom should be in the 0-24 range');\n }\n if (options.promoteId && this.options.generateId) {\n throw new Error('promoteId and generateId cannot be used together.');\n }\n // projects and adds simplification info\n let features = convert(data, options);\n if (debug) {\n console.timeEnd('preprocess data');\n console.log('index: maxZoom: %d, maxPoints: %d', options.indexMaxZoom, options.indexMaxPoints);\n console.time('generate tiles');\n }\n // wraps features (ie extreme west and extreme east)\n features = wrap(features, this.options);\n // start slicing from the top tile down\n if (features.length) {\n this.splitTile(features, 0, 0, 0);\n }\n if (debug) {\n if (features.length) {\n console.log('features: %d, points: %d', this.tiles[0].numFeatures, this.tiles[0].numPoints);\n }\n console.timeEnd('generate tiles');\n console.log('tiles generated:', this.total, JSON.stringify(this.stats));\n }\n }\n /**\n * Get a tile at the specified index\n * @param z\n * @param x\n * @param y\n * @returns\n */\n // eslint-disable-next-line complexity, max-statements\n getTile(z, x, y) {\n // z = +z;\n // x = +x;\n // y = +y;\n const { extent, debug } = this.options;\n if (z < 0 || z > 24) {\n return null;\n }\n const z2 = 1 << z;\n x = (x + z2) & (z2 - 1); // wrap tile x coordinate\n const id = toID(z, x, y);\n if (this.tiles[id]) {\n return transformTile(this.tiles[id], extent);\n }\n if (debug > 1)\n console.log('drilling down to z%d-%d-%d', z, x, y);\n let z0 = z;\n let x0 = x;\n let y0 = y;\n let parent;\n while (!parent && z0 > 0) {\n z0--;\n x0 = x0 >> 1;\n y0 = y0 >> 1;\n parent = this.tiles[toID(z0, x0, y0)];\n }\n if (!parent || !parent.source) {\n return null;\n }\n // if we found a parent tile containing the original geometry, we can drill down from it\n if (debug > 1) {\n console.log('found parent tile z%d-%d-%d', z0, x0, y0);\n console.time('drilling down');\n }\n this.splitTile(parent.source, z0, x0, y0, z, x, y);\n if (debug > 1) {\n console.timeEnd('drilling down');\n }\n return this.tiles[id] ? transformTile(this.tiles[id], extent) : null;\n }\n /**\n * splits features from a parent tile to sub-tiles.\n * @param z, x, and y are the coordinates of the parent tile\n * @param cz, cx, and cy are the coordinates of the target tile\n *\n * If no target tile is specified, splitting stops when we reach the maximum\n * zoom or the number of points is low as specified in the options.\n */\n // eslint-disable-next-line max-params, max-statements, complexity\n splitTile(features, z, x, y, cz, cx, cy) {\n const stack = [features, z, x, y];\n const options = this.options;\n const debug = options.debug;\n // avoid recursion by using a processing queue\n while (stack.length) {\n y = stack.pop();\n x = stack.pop();\n z = stack.pop();\n features = stack.pop();\n const z2 = 1 << z;\n const id = toID(z, x, y);\n let tile = this.tiles[id];\n if (!tile) {\n if (debug > 1) {\n console.time('creation');\n }\n tile = this.tiles[id] = createTile(features, z, x, y, options);\n this.tileCoords.push({ z, x, y });\n if (debug) {\n if (debug > 1) {\n console.log('tile z%d-%d-%d (features: %d, points: %d, simplified: %d)', z, x, y, tile.numFeatures, tile.numPoints, tile.numSimplified);\n console.timeEnd('creation');\n }\n const key = `z${z}`;\n this.stats[key] = (this.stats[key] || 0) + 1;\n this.total++;\n }\n }\n // save reference to original geometry in tile so that we can drill down later if we stop now\n tile.source = features;\n // if it's the first-pass tiling\n if (cz === undefined) {\n // stop tiling if we reached max zoom, or if the tile is too simple\n if (z === options.indexMaxZoom || tile.numPoints <= options.indexMaxPoints)\n continue;\n // if a drilldown to a specific tile\n }\n else if (z === options.maxZoom || z === cz) {\n // stop tiling if we reached base zoom or our target tile zoom\n continue;\n }\n else if (cz !== undefined) {\n // stop tiling if it's not an ancestor of the target tile\n const zoomSteps = cz - z;\n // @ts-expect-error TODO fix the types of cx cy\n if (x !== cx >> zoomSteps || y !== cy >> zoomSteps)\n continue;\n }\n // if we slice further down, no need to keep source geometry\n tile.source = null;\n if (features.length === 0)\n continue;\n if (debug > 1)\n console.time('clipping');\n // values we'll use for clipping\n const k1 = (0.5 * options.buffer) / options.extent;\n const k2 = 0.5 - k1;\n const k3 = 0.5 + k1;\n const k4 = 1 + k1;\n let tl = null;\n let bl = null;\n let tr = null;\n let br = null;\n let left = clip(features, z2, x - k1, x + k3, 0, tile.minX, tile.maxX, options);\n let right = clip(features, z2, x + k2, x + k4, 0, tile.minX, tile.maxX, options);\n // @ts-expect-error - unclear why this is needed?\n features = null;\n if (left) {\n tl = clip(left, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, options);\n bl = clip(left, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, options);\n left = null;\n }\n if (right) {\n tr = clip(right, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, options);\n br = clip(right, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, options);\n right = null;\n }\n if (debug > 1)\n console.timeEnd('clipping');\n stack.push(tl || [], z + 1, x * 2, y * 2);\n stack.push(bl || [], z + 1, x * 2, y * 2 + 1);\n stack.push(tr || [], z + 1, x * 2 + 1, y * 2);\n stack.push(br || [], z + 1, x * 2 + 1, y * 2 + 1);\n }\n }\n}\nfunction toID(z, x, y) {\n return ((1 << z) * y + x) * 32 + z;\n}\n"],
4
+ "sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport { MVTLoader, MVTWorkerLoader } from \"./mvt-loader.js\";\nexport { TileJSONLoader } from \"./tilejson-loader.js\";\nexport { MVTSource } from \"./mvt-source.js\";\nexport { GeoJSONTiler } from \"./lib/geojson-tiler/geojson-tiler.js\";\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\nimport { flatGeojsonToBinary } from '@loaders.gl/gis';\nimport Protobuf from 'pbf';\nimport { VectorTile } from \"./mapbox-vector-tile/vector-tile.js\";\nimport { BinaryVectorTile } from \"./binary-vector-tile/vector-tile.js\";\n/**\n * Parse MVT arrayBuffer and return GeoJSON.\n *\n * @param arrayBuffer A MVT arrayBuffer\n * @param options\n * @returns A GeoJSON geometry object or a binary representation\n */\nexport function parseMVT(arrayBuffer, options) {\n const mvtOptions = normalizeOptions(options);\n const shape = options?.gis?.format || options?.mvt?.shape || options?.shape;\n switch (shape) {\n case 'columnar-table': // binary + some JS arrays\n return { shape: 'columnar-table', data: parseToBinary(arrayBuffer, mvtOptions) };\n case 'geojson-table': {\n const table = {\n shape: 'geojson-table',\n type: 'FeatureCollection',\n features: parseToGeojsonFeatures(arrayBuffer, mvtOptions)\n };\n return table;\n }\n case 'geojson':\n return parseToGeojsonFeatures(arrayBuffer, mvtOptions);\n case 'binary-geometry':\n return parseToBinary(arrayBuffer, mvtOptions);\n case 'binary':\n return parseToBinary(arrayBuffer, mvtOptions);\n default:\n throw new Error(shape || 'undefined shape');\n }\n}\nfunction parseToBinary(arrayBuffer, options) {\n const [flatGeoJsonFeatures, geometryInfo] = parseToFlatGeoJson(arrayBuffer, options);\n const binaryData = flatGeojsonToBinary(flatGeoJsonFeatures, geometryInfo);\n // Add the original byteLength (as a reasonable approximation of the size of the binary data)\n // TODO decide where to store extra fields like byteLength (header etc) and document\n // @ts-ignore\n binaryData.byteLength = arrayBuffer.byteLength;\n return binaryData;\n}\nfunction parseToFlatGeoJson(arrayBuffer, options) {\n const features = [];\n const geometryInfo = {\n coordLength: 2,\n pointPositionsCount: 0,\n pointFeaturesCount: 0,\n linePositionsCount: 0,\n linePathsCount: 0,\n lineFeaturesCount: 0,\n polygonPositionsCount: 0,\n polygonObjectsCount: 0,\n polygonRingsCount: 0,\n polygonFeaturesCount: 0\n };\n if (arrayBuffer.byteLength <= 0) {\n return [features, geometryInfo];\n }\n const tile = new BinaryVectorTile(new Protobuf(arrayBuffer));\n const selectedLayers = options && Array.isArray(options.layers) ? options.layers : Object.keys(tile.layers);\n selectedLayers.forEach((layerName) => {\n const vectorTileLayer = tile.layers[layerName];\n if (!vectorTileLayer) {\n return;\n }\n for (let i = 0; i < vectorTileLayer.length; i++) {\n const vectorTileFeature = vectorTileLayer.feature(i, geometryInfo);\n const decodedFeature = getDecodedFeatureBinary(vectorTileFeature, options, layerName);\n features.push(decodedFeature);\n }\n });\n return [features, geometryInfo];\n}\nfunction parseToGeojsonFeatures(arrayBuffer, options) {\n if (arrayBuffer.byteLength <= 0) {\n return [];\n }\n const features = [];\n const tile = new VectorTile(new Protobuf(arrayBuffer));\n const selectedLayers = Array.isArray(options.layers) ? options.layers : Object.keys(tile.layers);\n selectedLayers.forEach((layerName) => {\n const vectorTileLayer = tile.layers[layerName];\n if (!vectorTileLayer) {\n return;\n }\n for (let i = 0; i < vectorTileLayer.length; i++) {\n const vectorTileFeature = vectorTileLayer.feature(i);\n const decodedFeature = getDecodedFeature(vectorTileFeature, options, layerName);\n features.push(decodedFeature);\n }\n });\n return features;\n}\nfunction normalizeOptions(options) {\n if (!options?.mvt) {\n throw new Error('mvt options required');\n }\n // Validate\n const wgs84Coordinates = options.mvt?.coordinates === 'wgs84';\n const { tileIndex } = options.mvt;\n const hasTileIndex = tileIndex &&\n Number.isFinite(tileIndex.x) &&\n Number.isFinite(tileIndex.y) &&\n Number.isFinite(tileIndex.z);\n if (wgs84Coordinates && !hasTileIndex) {\n throw new Error('MVT Loader: WGS84 coordinates need tileIndex property');\n }\n return options.mvt;\n}\n/**\n * @param feature\n * @param options\n * @returns decoded feature\n */\nfunction getDecodedFeature(feature, options, layerName) {\n const decodedFeature = feature.toGeoJSON(\n // @ts-expect-error What is going on here?\n options.coordinates === 'wgs84' ? options.tileIndex : transformToLocalCoordinates);\n // Add layer name to GeoJSON properties\n if (options.layerProperty) {\n decodedFeature.properties[options.layerProperty] = layerName;\n }\n return decodedFeature;\n}\n/**\n * @param feature\n * @param options\n * @returns decoded binary feature\n */\nfunction getDecodedFeatureBinary(feature, options, layerName) {\n const decodedFeature = feature.toBinaryCoordinates(\n // @ts-expect-error\n options.coordinates === 'wgs84' ? options.tileIndex : transformToLocalCoordinatesBinary);\n // Add layer name to GeoJSON properties\n if (options.layerProperty && decodedFeature.properties) {\n decodedFeature.properties[options.layerProperty] = layerName;\n }\n return decodedFeature;\n}\n/**\n * @param line\n * @param feature\n */\nfunction transformToLocalCoordinates(line, feature) {\n // This function transforms local coordinates in a\n // [0 - bufferSize, this.extent + bufferSize] range to a\n // [0 - (bufferSize / this.extent), 1 + (bufferSize / this.extent)] range.\n // The resulting extent would be 1.\n const { extent } = feature;\n for (let i = 0; i < line.length; i++) {\n const p = line[i];\n p[0] /= extent;\n p[1] /= extent;\n }\n}\nfunction transformToLocalCoordinatesBinary(data, feature) {\n // For the binary code path, the feature data is just\n // one big flat array, so we just divide each value\n const { extent } = feature;\n for (let i = 0, il = data.length; i < il; ++i) {\n data[i] /= extent;\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\n/**\n * Classifies an array of rings into polygons with outer rings and holes\n * @param rings\n * @returns polygons\n */\nexport function classifyRings(rings) {\n const len = rings.length;\n if (len <= 1)\n return [rings];\n const polygons = [];\n let polygon;\n let ccw;\n for (let i = 0; i < len; i++) {\n const area = signedArea(rings[i]);\n if (area === 0)\n continue; // eslint-disable-line no-continue\n if (ccw === undefined)\n ccw = area < 0;\n if (ccw === area < 0) {\n if (polygon)\n polygons.push(polygon);\n polygon = [rings[i]];\n }\n else if (polygon)\n polygon.push(rings[i]);\n }\n if (polygon)\n polygons.push(polygon);\n return polygons;\n}\n/**\n *\n * @param ring\n * @returns sum\n */\nexport function signedArea(ring) {\n let sum = 0;\n for (let i = 0, j = ring.length - 1, p1, p2; i < ring.length; j = i++) {\n p1 = ring[i];\n p2 = ring[j];\n sum += (p2[0] - p1[0]) * (p1[1] + p2[1]);\n }\n return sum;\n}\n/**\n *\n * @param tag\n * @param feature\n * @param pbf\n */\nexport function readFeature(tag, feature, pbf) {\n if (feature && pbf) {\n if (tag === 1)\n feature.id = pbf.readVarint();\n else if (tag === 2)\n readTag(pbf, feature);\n else if (tag === 3)\n feature.type = pbf.readVarint();\n else if (tag === 4)\n feature._geometry = pbf.pos;\n }\n}\n/**\n *\n * @param pbf\n * @param feature\n */\nexport function readTag(pbf, feature) {\n const end = pbf.readVarint() + pbf.pos;\n while (pbf.pos < end) {\n const key = feature._keys[pbf.readVarint()];\n const value = feature._values[pbf.readVarint()];\n feature.properties[key] = value;\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\nimport { readFeature, classifyRings } from \"../../helpers/mapbox-util-functions.js\";\nexport class VectorTileFeature {\n properties;\n extent;\n type;\n id;\n _pbf;\n _geometry;\n _keys;\n _values;\n static get types() {\n return ['Unknown', 'Point', 'LineString', 'Polygon'];\n }\n constructor(pbf, end, extent, keys, values) {\n // Public\n this.properties = {};\n this.extent = extent;\n this.type = 0;\n this.id = null;\n // Private\n this._pbf = pbf;\n this._geometry = -1;\n this._keys = keys;\n this._values = values;\n pbf.readFields(readFeature, this, end);\n }\n // eslint-disable-next-line complexity, max-statements\n loadGeometry() {\n const pbf = this._pbf;\n pbf.pos = this._geometry;\n const end = pbf.readVarint() + pbf.pos;\n let cmd = 1;\n let length = 0;\n let x = 0;\n let y = 0;\n const lines = [];\n let line;\n while (pbf.pos < end) {\n if (length <= 0) {\n const cmdLen = pbf.readVarint();\n cmd = cmdLen & 0x7;\n length = cmdLen >> 3;\n }\n length--;\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n if (cmd === 1) {\n // moveTo\n if (line)\n lines.push(line);\n line = [];\n }\n if (line)\n line.push([x, y]);\n }\n else if (cmd === 7) {\n // Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90\n if (line) {\n line.push(line[0].slice()); // closePolygon\n }\n }\n else {\n throw new Error(`unknown command ${cmd}`);\n }\n }\n if (line)\n lines.push(line);\n return lines;\n }\n // eslint-disable-next-line max-statements\n bbox() {\n const pbf = this._pbf;\n pbf.pos = this._geometry;\n const end = pbf.readVarint() + pbf.pos;\n let cmd = 1;\n let length = 0;\n let x = 0;\n let y = 0;\n let x1 = Infinity;\n let x2 = -Infinity;\n let y1 = Infinity;\n let y2 = -Infinity;\n while (pbf.pos < end) {\n if (length <= 0) {\n const cmdLen = pbf.readVarint();\n cmd = cmdLen & 0x7;\n length = cmdLen >> 3;\n }\n length--;\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n if (x < x1)\n x1 = x;\n if (x > x2)\n x2 = x;\n if (y < y1)\n y1 = y;\n if (y > y2)\n y2 = y;\n }\n else if (cmd !== 7) {\n throw new Error(`unknown command ${cmd}`);\n }\n }\n return [x1, y1, x2, y2];\n }\n _toGeoJSON(transform) {\n let coords = this.loadGeometry();\n let type = VectorTileFeature.types[this.type];\n let i;\n let j;\n // eslint-disable-next-line default-case\n switch (this.type) {\n case 1:\n const points = [];\n for (i = 0; i < coords.length; i++) {\n points[i] = coords[i][0];\n }\n coords = points;\n transform(coords, this);\n break;\n case 2:\n for (i = 0; i < coords.length; i++) {\n transform(coords[i], this);\n }\n break;\n case 3:\n coords = classifyRings(coords);\n for (i = 0; i < coords.length; i++) {\n for (j = 0; j < coords[i].length; j++) {\n transform(coords[i][j], this);\n }\n }\n break;\n }\n if (coords.length === 1) {\n coords = coords[0];\n }\n else {\n type = `Multi${type}`;\n }\n const result = {\n type: 'Feature',\n geometry: {\n type,\n coordinates: coords\n },\n properties: this.properties\n };\n if (this.id !== null) {\n result.id = this.id;\n }\n return result;\n }\n toGeoJSON(options) {\n if (typeof options === 'function') {\n return this._toGeoJSON(options);\n }\n const { x, y, z } = options;\n const size = this.extent * Math.pow(2, z);\n const x0 = this.extent * x;\n const y0 = this.extent * y;\n function project(line) {\n for (let j = 0; j < line.length; j++) {\n const p = line[j];\n p[0] = ((p[0] + x0) * 360) / size - 180;\n const y2 = 180 - ((p[1] + y0) * 360) / size;\n p[1] = (360 / Math.PI) * Math.atan(Math.exp((y2 * Math.PI) / 180)) - 90;\n }\n }\n return this._toGeoJSON(project);\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\nimport { VectorTileFeature } from \"./vector-tile-feature.js\";\nexport class VectorTileLayer {\n version;\n name;\n extent;\n length;\n _pbf;\n _keys;\n _values;\n _features;\n constructor(pbf, end) {\n // Public\n this.version = 1;\n this.name = '';\n this.extent = 4096;\n this.length = 0;\n // Private\n this._pbf = pbf;\n this._keys = [];\n this._values = [];\n this._features = [];\n pbf.readFields(readLayer, this, end);\n this.length = this._features.length;\n }\n /**\n * return feature `i` from this layer as a `VectorTileFeature`\n * @param index\n * @returns feature\n */\n feature(i) {\n if (i < 0 || i >= this._features.length) {\n throw new Error('feature index out of bounds');\n }\n this._pbf.pos = this._features[i];\n const end = this._pbf.readVarint() + this._pbf.pos;\n return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);\n }\n}\n/**\n *\n * @param tag\n * @param layer\n * @param pbf\n */\nfunction readLayer(tag, layer, pbf) {\n if (layer && pbf) {\n if (tag === 15)\n layer.version = pbf.readVarint();\n else if (tag === 1)\n layer.name = pbf.readString();\n else if (tag === 5)\n layer.extent = pbf.readVarint();\n else if (tag === 2)\n layer._features.push(pbf.pos);\n else if (tag === 3)\n layer._keys.push(pbf.readString());\n else if (tag === 4)\n layer._values.push(readValueMessage(pbf));\n }\n}\n/**\n *\n * @param pbf\n * @returns value\n */\nfunction readValueMessage(pbf) {\n let value = null;\n const end = pbf.readVarint() + pbf.pos;\n while (pbf.pos < end) {\n const tag = pbf.readVarint() >> 3;\n value =\n tag === 1\n ? pbf.readString()\n : tag === 2\n ? pbf.readFloat()\n : tag === 3\n ? pbf.readDouble()\n : tag === 4\n ? pbf.readVarint64()\n : tag === 5\n ? pbf.readVarint()\n : tag === 6\n ? pbf.readSVarint()\n : tag === 7\n ? pbf.readBoolean()\n : null;\n }\n return value;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\n// This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.\nimport { VectorTileLayer } from \"./vector-tile-layer.js\";\nexport class VectorTile {\n layers;\n constructor(pbf, end) {\n this.layers = pbf.readFields(readTile, {}, end);\n }\n}\n/**\n *\n * @param tag\n * @param layers\n * @param pbf\n */\nfunction readTile(tag, layers, pbf) {\n if (tag === 3) {\n if (pbf) {\n const layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);\n if (layer.length && layers) {\n layers[layer.name] = layer;\n }\n }\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\nimport { getPolygonSignedArea } from '@math.gl/polygon';\n/**\n * Classifies an array of rings into polygons with outer rings and holes\n * The function also detects holes which have zero area and\n * removes them. In doing so it modifies the input\n * `geom.data` array to remove the unneeded data\n *\n * @param geometry\n * @returns object\n */\n// eslint-disable-next-line max-statements\nexport function classifyRings(geom) {\n const len = geom.indices.length;\n const type = 'Polygon';\n if (len <= 1) {\n return {\n type,\n data: geom.data,\n areas: [[getPolygonSignedArea(geom.data)]],\n indices: [geom.indices]\n };\n }\n const areas = [];\n const polygons = [];\n let ringAreas = [];\n let polygon = [];\n let ccw;\n let offset = 0;\n for (let endIndex, i = 0, startIndex; i < len; i++) {\n startIndex = geom.indices[i] - offset;\n endIndex = geom.indices[i + 1] - offset || geom.data.length;\n const shape = geom.data.slice(startIndex, endIndex);\n const area = getPolygonSignedArea(shape);\n if (area === 0) {\n // This polygon has no area, so remove it from the shape\n // Remove the section from the data array\n const before = geom.data.slice(0, startIndex);\n const after = geom.data.slice(endIndex);\n geom.data = before.concat(after);\n // Need to offset any remaining indices as we have\n // modified the data buffer\n offset += endIndex - startIndex;\n // Do not add this index to the output and process next shape\n continue; // eslint-disable-line no-continue\n }\n if (ccw === undefined)\n ccw = area < 0;\n if (ccw === area < 0) {\n if (polygon.length) {\n areas.push(ringAreas);\n polygons.push(polygon);\n }\n polygon = [startIndex];\n ringAreas = [area];\n }\n else {\n ringAreas.push(area);\n polygon.push(startIndex);\n }\n }\n if (ringAreas)\n areas.push(ringAreas);\n if (polygon.length)\n polygons.push(polygon);\n return { type, areas, indices: polygons, data: geom.data };\n}\n/**\n *\n * @param data\n * @param x0\n * @param y0\n * @param size\n */\nexport function project(data, x0, y0, size) {\n for (let j = 0, jl = data.length; j < jl; j += 2) {\n data[j] = ((data[j] + x0) * 360) / size - 180;\n const y2 = 180 - ((data[j + 1] + y0) * 360) / size;\n data[j + 1] = (360 / Math.PI) * Math.atan(Math.exp((y2 * Math.PI) / 180)) - 90;\n }\n}\n/**\n * All code below is unchanged from the original Mapbox implemenation\n *\n * @param tag\n * @param feature\n * @param pbf\n */\nexport function readFeature(tag, feature, pbf) {\n if (feature && pbf) {\n if (tag === 1)\n feature.id = pbf.readVarint();\n else if (tag === 2)\n readTag(pbf, feature);\n else if (tag === 3)\n feature.type = pbf.readVarint();\n else if (tag === 4)\n feature._geometry = pbf.pos;\n }\n}\n/**\n * @param pbf\n * @param feature\n */\nexport function readTag(pbf, feature) {\n const end = pbf.readVarint() + pbf.pos;\n while (pbf.pos < end) {\n const key = feature._keys[pbf.readVarint()];\n const value = feature._values[pbf.readVarint()];\n feature.properties[key] = value;\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\nimport { classifyRings, project, readFeature } from \"../../helpers/binary-util-functions.js\";\n// Reduce GC by reusing variables\nlet endPos;\nlet cmd;\nlet cmdLen;\nlet length;\nlet x;\nlet y;\nlet i;\nexport const TEST_EXPORTS = {\n classifyRings\n};\nexport class BinaryVectorTileFeature {\n properties;\n extent;\n type;\n id;\n _pbf;\n _geometry;\n _keys;\n _values;\n _geometryInfo;\n // eslint-disable-next-line max-params\n constructor(pbf, end, extent, keys, values, geometryInfo) {\n // Public\n this.properties = {};\n this.extent = extent;\n this.type = 0;\n this.id = null;\n // Private\n this._pbf = pbf;\n this._geometry = -1;\n this._keys = keys;\n this._values = values;\n this._geometryInfo = geometryInfo;\n pbf.readFields(readFeature, this, end);\n }\n // eslint-disable-next-line complexity, max-statements\n loadGeometry() {\n const pbf = this._pbf;\n pbf.pos = this._geometry;\n endPos = pbf.readVarint() + pbf.pos;\n cmd = 1;\n length = 0;\n x = 0;\n y = 0;\n i = 0;\n // Note: I attempted to replace the `data` array with a\n // Float32Array, but performance was worse, both using\n // `set()` and direct index access. Also, we cannot\n // know how large the buffer should be, so it would\n // increase memory usage\n const indices = []; // Indices where geometries start\n const data = []; // Flat array of coordinate data\n while (pbf.pos < endPos) {\n if (length <= 0) {\n cmdLen = pbf.readVarint();\n cmd = cmdLen & 0x7;\n length = cmdLen >> 3;\n }\n length--;\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n if (cmd === 1) {\n // New line\n indices.push(i);\n }\n data.push(x, y);\n i += 2;\n }\n else if (cmd === 7) {\n // Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90\n if (i > 0) {\n const start = indices[indices.length - 1]; // start index of polygon\n data.push(data[start], data[start + 1]); // closePolygon\n i += 2;\n }\n }\n else {\n throw new Error(`unknown command ${cmd}`);\n }\n }\n return { data, indices };\n }\n /**\n *\n * @param transform\n * @returns result\n */\n _toBinaryCoordinates(transform) {\n // Expands the protobuf data to an intermediate Flat GeoJSON\n // data format, which maps closely to the binary data buffers.\n // It is similar to GeoJSON, but rather than storing the coordinates\n // in multidimensional arrays, we have a 1D `data` with all the\n // coordinates, and then index into this using the `indices`\n // parameter, e.g.\n //\n // geometry: {\n // type: 'Point', data: [1,2], indices: [0]\n // }\n // geometry: {\n // type: 'LineString', data: [1,2,3,4,...], indices: [0]\n // }\n // geometry: {\n // type: 'Polygon', data: [1,2,3,4,...], indices: [[0, 2]]\n // }\n // Thus the indices member lets us look up the relevant range\n // from the data array.\n // The Multi* versions of the above types share the same data\n // structure, just with multiple elements in the indices array\n const geom = this.loadGeometry();\n let geometry;\n // Apply the supplied transformation to data\n transform(geom.data, this);\n const coordLength = 2;\n // eslint-disable-next-line default-case\n switch (this.type) {\n case 1: // Point\n this._geometryInfo.pointFeaturesCount++;\n this._geometryInfo.pointPositionsCount += geom.indices.length;\n geometry = { type: 'Point', ...geom };\n break;\n case 2: // LineString\n this._geometryInfo.lineFeaturesCount++;\n this._geometryInfo.linePathsCount += geom.indices.length;\n this._geometryInfo.linePositionsCount += geom.data.length / coordLength;\n geometry = { type: 'LineString', ...geom };\n break;\n case 3: // Polygon\n geometry = classifyRings(geom);\n // Unlike Point & LineString geom.indices is a 2D array, thanks\n // to the classifyRings method\n this._geometryInfo.polygonFeaturesCount++;\n this._geometryInfo.polygonObjectsCount += geometry.indices.length;\n for (const indices of geometry.indices) {\n this._geometryInfo.polygonRingsCount += indices.length;\n }\n this._geometryInfo.polygonPositionsCount += geometry.data.length / coordLength;\n break;\n default:\n throw new Error(`Invalid geometry type: ${this.type}`);\n }\n const result = { type: 'Feature', geometry, properties: this.properties };\n if (this.id !== null) {\n result.id = this.id;\n }\n return result;\n }\n toBinaryCoordinates(options) {\n if (typeof options === 'function') {\n return this._toBinaryCoordinates(options);\n }\n const { x, y, z } = options;\n const size = this.extent * Math.pow(2, z);\n const x0 = this.extent * x;\n const y0 = this.extent * y;\n return this._toBinaryCoordinates((data) => project(data, x0, y0, size));\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\n/* eslint-disable indent */\n// This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.\nimport { BinaryVectorTileFeature } from \"./vector-tile-feature.js\";\nexport class BinaryVectorTileLayer {\n version;\n name;\n extent;\n length;\n _pbf;\n _keys;\n _values;\n _features;\n constructor(pbf, end) {\n // Public\n this.version = 1;\n this.name = '';\n this.extent = 4096;\n this.length = 0;\n // Private\n this._pbf = pbf;\n this._keys = [];\n this._values = [];\n this._features = [];\n pbf.readFields(readLayer, this, end);\n this.length = this._features.length;\n }\n /**\n * return feature `i` from this layer as a `BinaryVectorTileFeature`\n *\n * @param index\n * @param geometryInfo\n * @returns {BinaryVectorTileFeature}\n */\n feature(i, geometryInfo) {\n if (i < 0 || i >= this._features.length) {\n throw new Error('feature index out of bounds');\n }\n this._pbf.pos = this._features[i];\n const end = this._pbf.readVarint() + this._pbf.pos;\n return new BinaryVectorTileFeature(this._pbf, end, this.extent, this._keys, this._values, geometryInfo);\n }\n}\n/**\n *\n * @param tag\n * @param layer\n * @param pbf\n */\nfunction readLayer(tag, layer, pbf) {\n if (layer && pbf) {\n if (tag === 15)\n layer.version = pbf.readVarint();\n else if (tag === 1)\n layer.name = pbf.readString();\n else if (tag === 5)\n layer.extent = pbf.readVarint();\n else if (tag === 2)\n layer._features.push(pbf.pos);\n else if (tag === 3)\n layer._keys.push(pbf.readString());\n else if (tag === 4)\n layer._values.push(readValueMessage(pbf));\n }\n}\n/**\n *\n * @param pbf\n * @returns value\n */\nfunction readValueMessage(pbf) {\n let value = null;\n const end = pbf.readVarint() + pbf.pos;\n while (pbf.pos < end) {\n const tag = pbf.readVarint() >> 3;\n value =\n tag === 1\n ? pbf.readString()\n : tag === 2\n ? pbf.readFloat()\n : tag === 3\n ? pbf.readDouble()\n : tag === 4\n ? pbf.readVarint64()\n : tag === 5\n ? pbf.readVarint()\n : tag === 6\n ? pbf.readSVarint()\n : tag === 7\n ? pbf.readBoolean()\n : null;\n }\n return value;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\n// This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.\nimport { BinaryVectorTileLayer } from \"./vector-tile-layer.js\";\nexport class BinaryVectorTile {\n layers;\n constructor(pbf, end) {\n this.layers = pbf.readFields(readTile, {}, end);\n }\n}\n/**\n *\n * @param tag\n * @param layers\n * @param pbf\n */\nfunction readTile(tag, layers, pbf) {\n if (tag === 3) {\n if (pbf) {\n const layer = new BinaryVectorTileLayer(pbf, pbf.readVarint() + pbf.pos);\n if (layer.length && layers) {\n layers[layer.name] = layer;\n }\n }\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\nimport { parseMVT } from \"./lib/parse-mvt.js\";\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.2.3\" !== 'undefined' ? \"4.2.3\" : 'latest';\n/**\n * Worker loader for the Mapbox Vector Tile format\n */\nexport const MVTWorkerLoader = {\n dataType: null,\n batchType: null,\n name: 'Mapbox Vector Tile',\n id: 'mvt',\n module: 'mvt',\n version: VERSION,\n // Note: ArcGIS uses '.pbf' extension and 'application/octet-stream'\n extensions: ['mvt', 'pbf'],\n mimeTypes: [\n // https://www.iana.org/assignments/media-types/application/vnd.mapbox-vector-tile\n 'application/vnd.mapbox-vector-tile',\n 'application/x-protobuf'\n // 'application/octet-stream'\n ],\n worker: true,\n category: 'geometry',\n options: {\n mvt: {\n shape: 'geojson',\n coordinates: 'local',\n layerProperty: 'layerName',\n layers: undefined,\n tileIndex: null\n }\n }\n};\n/**\n * Loader for the Mapbox Vector Tile format\n */\nexport const MVTLoader = {\n ...MVTWorkerLoader,\n parse: async (arrayBuffer, options) => parseMVT(arrayBuffer, options),\n parseSync: parseMVT,\n binary: true\n};\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nconst isObject = (x) => x !== null && typeof x === 'object';\n/**\n * Parse TileJSON from metadata\n * @param jsonMetadata - metadata object\n * @param options - options\n * @returns - parsed TileJSON\n */\n// eslint-disable-next-line complexity\nexport function parseTileJSON(jsonMetadata, options) {\n if (!jsonMetadata || !isObject(jsonMetadata)) {\n return null;\n }\n let tileJSON = {\n name: jsonMetadata.name || '',\n description: jsonMetadata.description || ''\n };\n // tippecanoe\n if (typeof jsonMetadata.generator === 'string') {\n tileJSON.generator = jsonMetadata.generator;\n }\n if (typeof jsonMetadata.generator_options === 'string') {\n tileJSON.generatorOptions = jsonMetadata.generator_options;\n }\n // Tippecanoe emits `antimeridian_adjusted_bounds` instead of `bounds`\n tileJSON.boundingBox =\n parseBounds(jsonMetadata.bounds) || parseBounds(jsonMetadata.antimeridian_adjusted_bounds);\n // TODO - can be undefined - we could set to center of bounds...\n tileJSON.center = parseCenter(jsonMetadata.center);\n // TODO - can be undefined, we could extract from layers...\n tileJSON.maxZoom = safeParseFloat(jsonMetadata.maxzoom);\n // TODO - can be undefined, we could extract from layers...\n tileJSON.minZoom = safeParseFloat(jsonMetadata.minzoom);\n // Look for nested metadata embedded in .json field\n // TODO - document what source this applies to, when is this needed?\n if (typeof jsonMetadata?.json === 'string') {\n // try to parse json\n try {\n tileJSON.metaJson = JSON.parse(jsonMetadata.json);\n }\n catch (error) {\n // eslint-disable-next-line no-console\n console.warn('Failed to parse tilejson.json field', error);\n // do nothing\n }\n }\n // Look for fields in tilestats\n const tilestats = jsonMetadata.tilestats || tileJSON.metaJson?.tilestats;\n const tileStatsLayers = parseTilestatsLayers(tilestats, options);\n const tileJSONlayers = parseTileJSONLayers(jsonMetadata.vector_layers); // eslint-disable-line camelcase\n // TODO - merge in description from tilejson\n const layers = mergeLayers(tileJSONlayers, tileStatsLayers);\n tileJSON = {\n ...tileJSON,\n layers\n };\n if (tileJSON.maxZoom === null && layers.length > 0) {\n tileJSON.maxZoom = layers[0].maxZoom || null;\n }\n if (tileJSON.minZoom === null && layers.length > 0) {\n tileJSON.minZoom = layers[0].minZoom || null;\n }\n return tileJSON;\n}\nfunction parseTileJSONLayers(layers) {\n // Look for fields in vector_layers\n if (!Array.isArray(layers)) {\n return [];\n }\n return layers.map((layer) => parseTileJSONLayer(layer));\n}\nfunction parseTileJSONLayer(layer) {\n const fields = Object.entries(layer.fields || []).map(([key, datatype]) => ({\n name: key,\n ...attributeTypeToFieldType(String(datatype))\n }));\n const layer2 = { ...layer };\n delete layer2.fields;\n return {\n name: layer.id || '',\n ...layer2,\n fields\n };\n}\n/** parse Layers array from tilestats */\nfunction parseTilestatsLayers(tilestats, options) {\n if (isObject(tilestats) && Array.isArray(tilestats.layers)) {\n // we are in luck!\n return tilestats.layers.map((layer) => parseTilestatsForLayer(layer, options));\n }\n return [];\n}\nfunction parseTilestatsForLayer(layer, options) {\n const fields = [];\n const indexedAttributes = {};\n const attributes = layer.attributes || [];\n for (const attribute of attributes) {\n const name = attribute.attribute;\n if (typeof name === 'string') {\n // TODO - code copied from kepler.gl, need sample tilestats files to test\n if (name.split('|').length > 1) {\n // indexed field\n const fname = name.split('|')[0];\n indexedAttributes[fname] = indexedAttributes[fname] || [];\n indexedAttributes[fname].push(attribute);\n // eslint-disable-next-line no-console\n console.warn('ignoring tilestats indexed field', fname);\n }\n else if (!fields[name]) {\n fields.push(attributeToField(attribute, options));\n }\n else {\n // return (fields[name], attribute);\n }\n }\n }\n return {\n name: layer.layer || '',\n dominantGeometry: layer.geometry,\n fields\n };\n}\nfunction mergeLayers(layers, tilestatsLayers) {\n return layers.map((layer) => {\n const tilestatsLayer = tilestatsLayers.find((tsLayer) => tsLayer.name === layer.name);\n // For aesthetics in JSON dumps, we preserve field order (make sure layers is last)\n const fields = tilestatsLayer?.fields || [];\n const layer2 = { ...layer };\n delete layer2.fields;\n return {\n ...layer2,\n ...tilestatsLayer,\n fields\n };\n });\n}\n/**\n * bounds should be [minLng, minLat, maxLng, maxLat]\n *`[[w, s], [e, n]]`, indicates the limits of the bounding box using the axis units and order of the specified CRS.\n */\nfunction parseBounds(bounds) {\n // supported formats\n // string: \"-96.657715,40.126127,-90.140061,43.516689\",\n // array: [ -180, -85.05112877980659, 180, 85.0511287798066 ]\n const result = fromArrayOrString(bounds);\n // validate bounds\n if (Array.isArray(result) &&\n result.length === 4 &&\n [result[0], result[2]].every(isLng) &&\n [result[1], result[3]].every(isLat)) {\n return [\n [result[0], result[1]],\n [result[2], result[3]]\n ];\n }\n return undefined;\n}\nfunction parseCenter(center) {\n // supported formats\n // string: \"-96.657715,40.126127,-90.140061,43.516689\",\n // array: [-91.505127,41.615442,14]\n const result = fromArrayOrString(center);\n if (Array.isArray(result) &&\n result.length === 3 &&\n isLng(result[0]) &&\n isLat(result[1]) &&\n isZoom(result[2])) {\n return result;\n }\n return null;\n}\nfunction safeParseFloat(input) {\n const result = typeof input === 'string' ? parseFloat(input) : typeof input === 'number' ? input : null;\n return result === null || isNaN(result) ? null : result;\n}\n// https://github.com/mapbox/tilejson-spec/tree/master/2.2.0\nfunction isLat(num) {\n return Number.isFinite(num) && num <= 90 && num >= -90;\n}\nfunction isLng(num) {\n return Number.isFinite(num) && num <= 180 && num >= -180;\n}\nfunction isZoom(num) {\n return Number.isFinite(num) && num >= 0 && num <= 22;\n}\nfunction fromArrayOrString(data) {\n if (typeof data === 'string') {\n return data.split(',').map(parseFloat);\n }\n else if (Array.isArray(data)) {\n return data;\n }\n return null;\n}\n// possible types https://github.com/mapbox/tippecanoe#modifying-feature-attributes\nconst attrTypeMap = {\n number: {\n type: 'float32'\n },\n numeric: {\n type: 'float32'\n },\n string: {\n type: 'utf8'\n },\n vachar: {\n type: 'utf8'\n },\n float: {\n type: 'float32'\n },\n int: {\n type: 'int32'\n },\n int4: {\n type: 'int32'\n },\n boolean: {\n type: 'boolean'\n },\n bool: {\n type: 'boolean'\n }\n};\nfunction attributeToField(attribute = {}, options) {\n const fieldTypes = attributeTypeToFieldType(attribute.type);\n const field = {\n name: attribute.attribute,\n // what happens if attribute type is string...\n // filterProps: getFilterProps(fieldTypes.type, attribute),\n ...fieldTypes\n };\n // attribute: \"_season_peaks_color\"\n // count: 1000\n // max: 0.95\n // min: 0.24375\n // type: \"number\"\n if (typeof attribute.min === 'number') {\n field.min = attribute.min;\n }\n if (typeof attribute.max === 'number') {\n field.max = attribute.max;\n }\n if (typeof attribute.count === 'number') {\n field.uniqueValueCount = attribute.count;\n }\n if (attribute.values) {\n // Too much data? Add option?\n field.values = attribute.values;\n }\n if (field.values && typeof options.maxValues === 'number') {\n // Too much data? Add option?\n field.values = field.values?.slice(0, options.maxValues);\n }\n return field;\n}\nfunction attributeTypeToFieldType(aType) {\n const type = aType.toLowerCase();\n if (!type || !attrTypeMap[type]) {\n // console.warn(\n // `cannot convert attribute type ${type} to loaders.gl data type, use string by default`\n // );\n }\n return attrTypeMap[type] || { type: 'string' };\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { parseTileJSON } from \"./lib/parse-tilejson.js\";\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.2.3\" !== 'undefined' ? \"4.2.3\" : 'latest';\n/**\n * Loader for TileJSON metadata\n */\nexport const TileJSONLoader = {\n dataType: null,\n batchType: null,\n name: 'TileJSON',\n id: 'tilejson',\n module: 'pmtiles',\n version: VERSION,\n worker: true,\n extensions: ['json'],\n mimeTypes: ['application/json'],\n text: true,\n options: {\n tilejson: {\n maxValues: undefined\n }\n },\n parse: async (arrayBuffer, options) => {\n const jsonString = new TextDecoder().decode(arrayBuffer);\n const json = JSON.parse(jsonString);\n const tilejsonOptions = { ...TileJSONLoader.options.tilejson, ...options?.tilejson };\n return parseTileJSON(json, tilejsonOptions);\n },\n parseTextSync: (text, options) => {\n const json = JSON.parse(text);\n const tilejsonOptions = { ...TileJSONLoader.options.tilejson, ...options?.tilejson };\n return parseTileJSON(json, tilejsonOptions);\n }\n};\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { DataSource, resolvePath } from '@loaders.gl/loader-utils';\nimport { ImageLoader, getBinaryImageMetadata } from '@loaders.gl/images';\nimport { MVTLoader, TileJSONLoader } from '@loaders.gl/mvt';\n/**\n * MVT data source for Mapbox Vector Tiles v1.\n */\n/**\n * A PMTiles data source\n * @note Can be either a raster or vector tile source depending on the contents of the PMTiles file.\n */\nexport class MVTSource extends DataSource {\n props;\n url;\n metadataUrl = null;\n data;\n schema = 'tms';\n metadata;\n extension;\n mimeType = null;\n constructor(props) {\n super(props);\n this.props = props;\n this.url = resolvePath(props.url);\n this.metadataUrl =\n props.metadataUrl === undefined ? `${this.url}/tilejson.json` : props.metadataUrl;\n this.extension = props.extension || '.png';\n this.data = this.url;\n this.getTileData = this.getTileData.bind(this);\n this.metadata = this.getMetadata();\n if (isURLTemplate(this.url)) {\n this.schema = 'template';\n }\n }\n // @ts-ignore - Metadata type misalignment\n async getMetadata() {\n if (!this.metadataUrl) {\n return null;\n }\n let response;\n try {\n // Annoyingly, on CORS errors, fetch doesn't use the response status/ok mechanism but instead throws\n // CORS errors are common when requesting an unavailable sub resource such as a metadata file or an unavailable tile)\n response = await this.fetch(this.metadataUrl);\n }\n catch (error) {\n // eslint-disable-next-line no-console\n console.error(error.message);\n return null;\n }\n if (!response.ok) {\n // eslint-disable-next-line no-console\n console.error(response.statusText);\n return null;\n }\n const tileJSON = await response.text();\n const metadata = TileJSONLoader.parseTextSync?.(tileJSON) || null;\n // TODO add metadata attributions\n // metadata.attributions = [...this.props.attributions, ...(metadata.attributions || [])];\n // if (metadata?.mimeType) {\n // this.mimeType = metadata?.tileMIMEType;\n // }\n return metadata;\n }\n getTileMIMEType() {\n return this.mimeType;\n }\n async getTile(tileParams) {\n const { x, y, zoom: z } = tileParams;\n const tileUrl = this.getTileURL(x, y, z);\n const response = await this.fetch(tileUrl);\n if (!response.ok) {\n return null;\n }\n const arrayBuffer = await response.arrayBuffer();\n return arrayBuffer;\n }\n // Tile Source interface implementation: deck.gl compatible API\n // TODO - currently only handles image tiles, not vector tiles\n async getTileData(tileParams) {\n const { x, y, z } = tileParams.index;\n // const metadata = await this.metadata;\n // mimeType = metadata?.tileMIMEType || 'application/vnd.mapbox-vector-tile';\n const arrayBuffer = await this.getTile({ x, y, zoom: z, layers: [] });\n if (arrayBuffer === null) {\n return null;\n }\n const imageMetadata = getBinaryImageMetadata(arrayBuffer);\n this.mimeType =\n this.mimeType || imageMetadata?.mimeType || 'application/vnd.mapbox-vector-tile';\n switch (this.mimeType) {\n case 'application/vnd.mapbox-vector-tile':\n return await this._parseVectorTile(arrayBuffer, { x, y, zoom: z, layers: [] });\n default:\n return await this._parseImageTile(arrayBuffer);\n }\n }\n // ImageTileSource interface implementation\n async getImageTile(tileParams) {\n const arrayBuffer = await this.getTile(tileParams);\n return arrayBuffer ? this._parseImageTile(arrayBuffer) : null;\n }\n async _parseImageTile(arrayBuffer) {\n return await ImageLoader.parse(arrayBuffer, this.loadOptions);\n }\n // VectorTileSource interface implementation\n async getVectorTile(tileParams) {\n const arrayBuffer = await this.getTile(tileParams);\n return arrayBuffer ? this._parseVectorTile(arrayBuffer, tileParams) : null;\n }\n async _parseVectorTile(arrayBuffer, tileParams) {\n const loadOptions = {\n shape: 'geojson-table',\n mvt: {\n coordinates: 'wgs84',\n tileIndex: { x: tileParams.x, y: tileParams.y, z: tileParams.zoom },\n ...this.loadOptions?.mvt\n },\n ...this.loadOptions\n };\n return await MVTLoader.parse(arrayBuffer, loadOptions);\n }\n getMetadataUrl() {\n return this.metadataUrl;\n }\n getTileURL(x, y, z) {\n switch (this.schema) {\n case 'xyz':\n return `${this.url}/${x}/${y}/${z}${this.extension}`;\n case 'tms':\n return `${this.url}/${z}/${x}/${y}${this.extension}`;\n case 'template':\n return getURLFromTemplate(this.url, x, y, z, '0');\n default:\n throw new Error(this.schema);\n }\n }\n}\nexport function isURLTemplate(s) {\n return /(?=.*{z})(?=.*{x})(?=.*({y}|{-y}))|(?=.*{x})(?=.*({y}|{-y})(?=.*{z}))/.test(s);\n}\nconst xRegex = new RegExp('{x}', 'g');\nconst yRegex = new RegExp('{y}', 'g');\nconst zRegex = new RegExp('{z}', 'g');\n/**\n * Get a URL from a URL template\n * @note copied from deck.gl/modules/geo-layers/src/tileset-2d/utils.ts\n * @param template - URL template\n * @param x - tile x coordinate\n * @param y - tile y coordinate\n * @param z - tile z coordinate\n * @param id - tile id\n * @returns URL\n */\nexport function getURLFromTemplate(template, x, y, z, id = '0') {\n if (Array.isArray(template)) {\n const i = stringHash(id) % template.length;\n template = template[i];\n }\n let url = template;\n url = url.replace(xRegex, String(x));\n url = url.replace(yRegex, String(y));\n url = url.replace(zRegex, String(z));\n // Back-compatible support for {-y}\n if (Number.isInteger(y) && Number.isInteger(z)) {\n url = url.replace(/\\{-y\\}/g, String(Math.pow(2, z) - y - 1));\n }\n return url;\n}\nfunction stringHash(s) {\n return Math.abs(s.split('').reduce((a, b) => ((a << 5) - a + b.charCodeAt(0)) | 0, 0));\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license\n/**\n * Calculate simplification data using optimized Douglas-Peucker algorithm\n *\n * @param coords contiguous list of coordinates\n * @param first first coord to simplify\n * @param last last coord to simplify\n * @param sqTolerance tolerance (square distance)\n */\nexport function simplify(coords, first, last, sqTolerance) {\n let maxSqDist = sqTolerance;\n const mid = (last - first) >> 1;\n let minPosToMid = last - first;\n let index;\n const ax = coords[first];\n const ay = coords[first + 1];\n const bx = coords[last];\n const by = coords[last + 1];\n for (let i = first + 3; i < last; i += 3) {\n const d = getSqSegDist(coords[i], coords[i + 1], ax, ay, bx, by);\n if (d > maxSqDist) {\n index = i;\n maxSqDist = d;\n }\n else if (d === maxSqDist) {\n // a workaround to ensure we choose a pivot close to the middle of the list,\n // reducing recursion depth, for certain degenerate inputs\n // https://github.com/mapbox/geojson-vt/issues/104\n const posToMid = Math.abs(i - mid);\n if (posToMid < minPosToMid) {\n index = i;\n minPosToMid = posToMid;\n }\n }\n }\n if (maxSqDist > sqTolerance) {\n if (index - first > 3)\n simplify(coords, first, index, sqTolerance);\n coords[index + 2] = maxSqDist;\n if (last - index > 3)\n simplify(coords, index, last, sqTolerance);\n }\n}\n/** square distance from a point to a segment */\n// eslint-disable-next-line max-params\nfunction getSqSegDist(px, py, x, y, bx, by) {\n let dx = bx - x;\n let dy = by - y;\n if (dx !== 0 || dy !== 0) {\n const t = ((px - x) * dx + (py - y) * dy) / (dx * dx + dy * dy);\n if (t > 1) {\n x = bx;\n y = by;\n }\n else if (t > 0) {\n x += dx * t;\n y += dy * t;\n }\n }\n dx = px - x;\n dy = py - y;\n return dx * dx + dy * dy;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license\nexport function createFeature(id, type, geom, tags) {\n const feature = {\n // eslint-disable-next-line\n id: id == null ? null : id,\n type,\n geometry: geom,\n tags,\n minX: Infinity,\n minY: Infinity,\n maxX: -Infinity,\n maxY: -Infinity\n };\n if (type === 'Point' || type === 'MultiPoint' || type === 'LineString') {\n calcLineBBox(feature, geom);\n }\n else if (type === 'Polygon') {\n // the outer ring (ie [0]) contains all inner rings\n calcLineBBox(feature, geom[0]);\n }\n else if (type === 'MultiLineString') {\n for (const line of geom) {\n calcLineBBox(feature, line);\n }\n }\n else if (type === 'MultiPolygon') {\n for (const polygon of geom) {\n // the outer ring (ie [0]) contains all inner rings\n calcLineBBox(feature, polygon[0]);\n }\n }\n return feature;\n}\nfunction calcLineBBox(feature, geom) {\n for (let i = 0; i < geom.length; i += 3) {\n feature.minX = Math.min(feature.minX, geom[i]);\n feature.minY = Math.min(feature.minY, geom[i + 1]);\n feature.maxX = Math.max(feature.maxX, geom[i]);\n feature.maxY = Math.max(feature.maxY, geom[i + 1]);\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license\nimport { simplify } from \"./simplify.js\";\nimport { createFeature } from \"./feature.js\";\n// converts GeoJSON feature into an intermediate projected JSON vector format with simplification data\nexport function convert(data, options) {\n const features = [];\n if (data.type === 'FeatureCollection') {\n for (let i = 0; i < data.features.length; i++) {\n convertFeature(features, data.features[i], options, i);\n }\n }\n else if (data.type === 'Feature') {\n convertFeature(features, data, options);\n }\n else {\n // single geometry or a geometry collection\n convertFeature(features, { geometry: data }, options);\n }\n return features;\n}\nfunction convertFeature(features, geojson, options, index) {\n if (!geojson.geometry) {\n return;\n }\n const coords = geojson.geometry.coordinates;\n const type = geojson.geometry.type;\n const tolerance = Math.pow(options.tolerance / ((1 << options.maxZoom) * options.extent), 2);\n let geometry = [];\n let id = geojson.id;\n if (options.promoteId) {\n id = geojson.properties[options.promoteId];\n }\n else if (options.generateId) {\n id = index || 0;\n }\n if (type === 'Point') {\n convertPoint(coords, geometry);\n }\n else if (type === 'MultiPoint') {\n for (const p of coords) {\n convertPoint(p, geometry);\n }\n }\n else if (type === 'LineString') {\n convertLine(coords, geometry, tolerance, false);\n }\n else if (type === 'MultiLineString') {\n if (options.lineMetrics) {\n // explode into linestrings to be able to track metrics\n for (const line of coords) {\n geometry = [];\n convertLine(line, geometry, tolerance, false);\n features.push(createFeature(id, 'LineString', geometry, geojson.properties));\n }\n return;\n }\n else {\n convertLines(coords, geometry, tolerance, false);\n }\n }\n else if (type === 'Polygon') {\n convertLines(coords, geometry, tolerance, true);\n }\n else if (type === 'MultiPolygon') {\n for (const polygon of coords) {\n const newPolygon = [];\n convertLines(polygon, newPolygon, tolerance, true);\n geometry.push(newPolygon);\n }\n }\n else if (type === 'GeometryCollection') {\n for (const singleGeometry of geojson.geometry.geometries) {\n convertFeature(features, {\n id,\n geometry: singleGeometry,\n properties: geojson.properties\n }, options, index);\n }\n return;\n }\n else {\n throw new Error('Input data is not a valid GeoJSON object.');\n }\n features.push(createFeature(id, type, geometry, geojson.properties));\n}\nfunction convertPoint(coords, out) {\n out.push(projectX(coords[0]), projectY(coords[1]), 0);\n}\nfunction convertLine(ring, out, tolerance, isPolygon) {\n let x0, y0;\n let size = 0;\n for (let j = 0; j < ring.length; j++) {\n const x = projectX(ring[j][0]);\n const y = projectY(ring[j][1]);\n out.push(x, y, 0);\n if (j > 0) {\n if (isPolygon) {\n size += (x0 * y - x * y0) / 2; // area\n }\n else {\n size += Math.sqrt(Math.pow(x - x0, 2) + Math.pow(y - y0, 2)); // length\n }\n }\n x0 = x;\n y0 = y;\n }\n const last = out.length - 3;\n out[2] = 1;\n simplify(out, 0, last, tolerance);\n out[last + 2] = 1;\n out.size = Math.abs(size);\n out.start = 0;\n out.end = out.size;\n}\nfunction convertLines(rings, out, tolerance, isPolygon) {\n for (let i = 0; i < rings.length; i++) {\n const geom = [];\n convertLine(rings[i], geom, tolerance, isPolygon);\n out.push(geom);\n }\n}\nfunction projectX(x) {\n return x / 360 + 0.5;\n}\nfunction projectY(y) {\n const sin = Math.sin((y * Math.PI) / 180);\n const y2 = 0.5 - (0.25 * Math.log((1 + sin) / (1 - sin))) / Math.PI;\n return y2 < 0 ? 0 : y2 > 1 ? 1 : y2;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license\nimport { createFeature } from \"./feature.js\";\n/* eslint-disable no-continue */\n/**\n * Clip features between two vertical or horizontal axis-parallel lines:\n * | |\n * ___|___ | /\n * / | \\____|____/\n * | |\n *\n * @param k1 and k2 are the line coordinates\n * @param axis: 0 for x, 1 for y\n * @param minAll and maxAll: minimum and maximum coordinate value for all features\n */\n// eslint-disable-next-line max-params, complexity, max-statements\nexport function clip(features, scale, k1, k2, axis, minAll, maxAll, options) {\n k1 /= scale;\n k2 /= scale;\n if (minAll >= k1 && maxAll < k2) {\n return features;\n }\n // trivial accept\n else if (maxAll < k1 || minAll >= k2) {\n return null; // trivial reject\n }\n const clipped = [];\n for (const feature of features) {\n const geometry = feature.geometry;\n let type = feature.type;\n const min = axis === 0 ? feature.minX : feature.minY;\n const max = axis === 0 ? feature.maxX : feature.maxY;\n if (min >= k1 && max < k2) {\n // trivial accept\n clipped.push(feature);\n continue;\n }\n else if (max < k1 || min >= k2) {\n // trivial reject\n continue;\n }\n let newGeometry = [];\n if (type === 'Point' || type === 'MultiPoint') {\n clipPoints(geometry, newGeometry, k1, k2, axis);\n }\n else if (type === 'LineString') {\n clipLine(geometry, newGeometry, k1, k2, axis, false, options.lineMetrics);\n }\n else if (type === 'MultiLineString') {\n clipLines(geometry, newGeometry, k1, k2, axis, false);\n }\n else if (type === 'Polygon') {\n clipLines(geometry, newGeometry, k1, k2, axis, true);\n }\n else if (type === 'MultiPolygon') {\n for (const polygon of geometry) {\n const newPolygon = [];\n clipLines(polygon, newPolygon, k1, k2, axis, true);\n if (newPolygon.length) {\n newGeometry.push(newPolygon);\n }\n }\n }\n if (newGeometry.length) {\n if (options.lineMetrics && type === 'LineString') {\n for (const line of newGeometry) {\n clipped.push(createFeature(feature.id, type, line, feature.tags));\n }\n continue;\n }\n if (type === 'LineString' || type === 'MultiLineString') {\n if (newGeometry.length === 1) {\n type = 'LineString';\n // @ts-expect-error TODO - use proper GeoJSON geometry types\n newGeometry = newGeometry[0];\n }\n else {\n type = 'MultiLineString';\n }\n }\n if (type === 'Point' || type === 'MultiPoint') {\n type = newGeometry.length === 3 ? 'Point' : 'MultiPoint';\n }\n clipped.push(createFeature(feature.id, type, newGeometry, feature.tags));\n }\n }\n return clipped.length ? clipped : null;\n}\nfunction clipPoints(geom, newGeom, k1, k2, axis) {\n for (let i = 0; i < geom.length; i += 3) {\n const a = geom[i + axis];\n if (a >= k1 && a <= k2) {\n addPoint(newGeom, geom[i], geom[i + 1], geom[i + 2]);\n }\n }\n}\n// eslint-disable-next-line max-params, complexity, max-statements\nfunction clipLine(geom, newGeom, k1, k2, axis, isPolygon, trackMetrics) {\n let slice = newSlice(geom);\n const intersect = axis === 0 ? intersectX : intersectY;\n let len = geom.start;\n let segLen;\n let t;\n for (let i = 0; i < geom.length - 3; i += 3) {\n const ax = geom[i];\n const ay = geom[i + 1];\n const az = geom[i + 2];\n const bx = geom[i + 3];\n const by = geom[i + 4];\n const a = axis === 0 ? ax : ay;\n const b = axis === 0 ? bx : by;\n let exited = false;\n if (trackMetrics) {\n segLen = Math.sqrt(Math.pow(ax - bx, 2) + Math.pow(ay - by, 2));\n }\n if (a < k1) {\n // ---|--> | (line enters the clip region from the left)\n if (b > k1) {\n t = intersect(slice, ax, ay, bx, by, k1);\n if (trackMetrics) {\n slice.start = len + segLen * t;\n }\n }\n }\n else if (a > k2) {\n // | <--|--- (line enters the clip region from the right)\n if (b < k2) {\n t = intersect(slice, ax, ay, bx, by, k2);\n if (trackMetrics) {\n slice.start = len + segLen * t;\n }\n }\n }\n else {\n addPoint(slice, ax, ay, az);\n }\n if (b < k1 && a >= k1) {\n // <--|--- | or <--|-----|--- (line exits the clip region on the left)\n t = intersect(slice, ax, ay, bx, by, k1);\n exited = true;\n }\n if (b > k2 && a <= k2) {\n // | ---|--> or ---|-----|--> (line exits the clip region on the right)\n t = intersect(slice, ax, ay, bx, by, k2);\n exited = true;\n }\n if (!isPolygon && exited) {\n if (trackMetrics) {\n slice.end = len + segLen * t;\n }\n newGeom.push(slice);\n slice = newSlice(geom);\n }\n if (trackMetrics) {\n len += segLen;\n }\n }\n // add the last point\n let last = geom.length - 3;\n const ax = geom[last];\n const ay = geom[last + 1];\n const az = geom[last + 2];\n const a = axis === 0 ? ax : ay;\n if (a >= k1 && a <= k2)\n addPoint(slice, ax, ay, az);\n // close the polygon if its endpoints are not the same after clipping\n last = slice.length - 3;\n if (isPolygon && last >= 3 && (slice[last] !== slice[0] || slice[last + 1] !== slice[1])) {\n addPoint(slice, slice[0], slice[1], slice[2]);\n }\n // add the final slice\n if (slice.length) {\n newGeom.push(slice);\n }\n}\nclass Slice extends Array {\n size;\n start;\n end;\n}\nfunction newSlice(line) {\n const slice = [];\n slice.size = line.size;\n slice.start = line.start;\n slice.end = line.end;\n return slice;\n}\n// eslint-disable-next-line max-params\nfunction clipLines(geom, newGeom, k1, k2, axis, isPolygon) {\n for (const line of geom) {\n clipLine(line, newGeom, k1, k2, axis, isPolygon, false);\n }\n}\nfunction addPoint(out, x, y, z) {\n out.push(x, y, z);\n}\n// eslint-disable-next-line max-params\nfunction intersectX(out, ax, ay, bx, by, x) {\n const t = (x - ax) / (bx - ax);\n addPoint(out, x, ay + (by - ay) * t, 1);\n return t;\n}\n// eslint-disable-next-line max-params\nfunction intersectY(out, ax, ay, bx, by, y) {\n const t = (y - ay) / (by - ay);\n addPoint(out, ax + (bx - ax) * t, y, 1);\n return t;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license\nimport { clip } from \"./clip.js\";\nimport { createFeature } from \"./feature.js\";\n/**\n * Wrap across antemeridian, by clipping into two tiles, shifting the overflowing x coordinates\n * @param features list of features to be wrapped\n * @param options buffer and extent\n * @returns\n */\nexport function wrap(features, options) {\n const buffer = options.buffer / options.extent;\n let merged = features;\n const left = clip(features, 1, -1 - buffer, buffer, 0, -1, 2, options); // left world copy\n const right = clip(features, 1, 1 - buffer, 2 + buffer, 0, -1, 2, options); // right world copy\n if (left || right) {\n merged = clip(features, 1, -buffer, 1 + buffer, 0, -1, 2, options) || []; // center world copy\n if (left) {\n merged = shiftFeatureCoords(left, 1).concat(merged); // merge left into center\n }\n if (right) {\n merged = merged.concat(shiftFeatureCoords(right, -1)); // merge right into center\n }\n }\n return merged;\n}\n/**\n * Shift the x coordinates of a list of features\n * @param features list of features to shift x coordinates for\n * @param offset\n * @returns\n */\nfunction shiftFeatureCoords(features, offset) {\n const newFeatures = [];\n for (let i = 0; i < features.length; i++) {\n const feature = features[i];\n const type = feature.type;\n let newGeometry;\n if (type === 'Point' || type === 'MultiPoint' || type === 'LineString') {\n newGeometry = shiftCoords(feature.geometry, offset);\n }\n else if (type === 'MultiLineString' || type === 'Polygon') {\n newGeometry = [];\n for (const line of feature.geometry) {\n newGeometry.push(shiftCoords(line, offset));\n }\n }\n else if (type === 'MultiPolygon') {\n newGeometry = [];\n for (const polygon of feature.geometry) {\n const newPolygon = [];\n for (const line of polygon) {\n // @ts-expect-error TODO\n newPolygon.push(shiftCoords(line, offset));\n }\n newGeometry.push(newPolygon);\n }\n }\n newFeatures.push(createFeature(feature.id, type, newGeometry, feature.tags));\n }\n return newFeatures;\n}\nclass Points extends Array {\n size;\n start;\n end;\n}\n/**\n * Shift the x coordinate of every point\n * @param points\n * @param offset\n * @returns\n */\nfunction shiftCoords(points, offset) {\n const newPoints = [];\n newPoints.size = points.size;\n if (points.start !== undefined) {\n newPoints.start = points.start;\n newPoints.end = points.end;\n }\n for (let i = 0; i < points.length; i += 3) {\n newPoints.push(points[i] + offset, points[i + 1], points[i + 2]);\n }\n return newPoints;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license\n/**\n * Transforms the coordinates of each feature in the given tile from\n * mercator-projected space into (extent x extent) tile space.\n */\nexport function transformTile(tile, extent) {\n if (tile.transformed) {\n return tile;\n }\n const z2 = 1 << tile.z;\n const tx = tile.x;\n const ty = tile.y;\n for (const feature of tile.features) {\n const geom = feature.geometry;\n const type = feature.type;\n feature.geometry = [];\n if (type === 1) {\n for (let j = 0; j < geom.length; j += 2) {\n feature.geometry.push(transformPoint(geom[j], geom[j + 1], extent, z2, tx, ty));\n }\n }\n else {\n for (let j = 0; j < geom.length; j++) {\n const ring = [];\n for (let k = 0; k < geom[j].length; k += 2) {\n ring.push(transformPoint(geom[j][k], geom[j][k + 1], extent, z2, tx, ty));\n }\n feature.geometry.push(ring);\n }\n }\n }\n tile.transformed = true;\n return tile;\n}\n// eslint-disable-next-line max-params\nfunction transformPoint(x, y, extent, z2, tx, ty) {\n return [Math.round(extent * (x * z2 - tx)), Math.round(extent * (y * z2 - ty))];\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license\n/**\n * Create a tile from features and tile index\n */\nexport function createTile(features, z, tx, ty, options) {\n const tolerance = z === options.maxZoom ? 0 : options.tolerance / ((1 << z) * options.extent);\n const tile = {\n features: [],\n numPoints: 0,\n numSimplified: 0,\n numFeatures: features.length,\n source: null,\n x: tx,\n y: ty,\n z,\n transformed: false,\n minX: 2,\n minY: 1,\n maxX: -1,\n maxY: 0\n };\n for (const feature of features) {\n addFeature(tile, feature, tolerance, options);\n }\n return tile;\n}\n// eslint-disable-next-line complexity, max-statements\nfunction addFeature(tile, feature, tolerance, options) {\n const geom = feature.geometry;\n const type = feature.type;\n const simplified = [];\n tile.minX = Math.min(tile.minX, feature.minX);\n tile.minY = Math.min(tile.minY, feature.minY);\n tile.maxX = Math.max(tile.maxX, feature.maxX);\n tile.maxY = Math.max(tile.maxY, feature.maxY);\n if (type === 'Point' || type === 'MultiPoint') {\n for (let i = 0; i < geom.length; i += 3) {\n simplified.push(geom[i], geom[i + 1]);\n tile.numPoints++;\n tile.numSimplified++;\n }\n }\n else if (type === 'LineString') {\n addLine(simplified, geom, tile, tolerance, false, false);\n }\n else if (type === 'MultiLineString' || type === 'Polygon') {\n for (let i = 0; i < geom.length; i++) {\n addLine(simplified, geom[i], tile, tolerance, type === 'Polygon', i === 0);\n }\n }\n else if (type === 'MultiPolygon') {\n for (let k = 0; k < geom.length; k++) {\n const polygon = geom[k];\n for (let i = 0; i < polygon.length; i++) {\n addLine(simplified, polygon[i], tile, tolerance, true, i === 0);\n }\n }\n }\n if (simplified.length) {\n let tags = feature.tags || null;\n if (type === 'LineString' && options.lineMetrics) {\n tags = {};\n for (const key in feature.tags)\n tags[key] = feature.tags[key];\n // eslint-disable-next-line camelcase\n tags.mapbox_clip_start = geom.start / geom.size;\n // eslint-disable-next-line camelcase\n tags.mapbox_clip_end = geom.end / geom.size;\n }\n // @ts-expect-error TODO - create sub type?\n const tileFeature = {\n geometry: simplified,\n type: type === 'Polygon' || type === 'MultiPolygon'\n ? 3\n : type === 'LineString' || type === 'MultiLineString'\n ? 2\n : 1,\n tags\n };\n if (feature.id !== null) {\n tileFeature.id = feature.id;\n }\n tile.features.push(tileFeature);\n }\n}\n// eslint-disable-next-line max-params, max-statements\nfunction addLine(result, geom, tile, tolerance, isPolygon, isOuter) {\n const sqTolerance = tolerance * tolerance;\n if (tolerance > 0 && geom.size < (isPolygon ? sqTolerance : tolerance)) {\n tile.numPoints += geom.length / 3;\n return;\n }\n const ring = [];\n for (let i = 0; i < geom.length; i += 3) {\n if (tolerance === 0 || geom[i + 2] > sqTolerance) {\n tile.numSimplified++;\n ring.push(geom[i], geom[i + 1]);\n }\n tile.numPoints++;\n }\n if (isPolygon)\n rewind(ring, isOuter);\n result.push(ring);\n}\nfunction rewind(ring, clockwise) {\n let area = 0;\n for (let i = 0, j = ring.length - 2; i < ring.length; j = i, i += 2) {\n area += (ring[i] - ring[j]) * (ring[i + 1] + ring[j + 1]);\n }\n if (area > 0 === clockwise) {\n for (let i = 0, len = ring.length; i < len / 2; i += 2) {\n const x = ring[i];\n const y = ring[i + 1];\n ring[i] = ring[len - 2 - i];\n ring[i + 1] = ring[len - 1 - i];\n ring[len - 2 - i] = x;\n ring[len - 1 - i] = y;\n }\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license\nimport { convert } from \"./convert.js\"; // GeoJSON conversion and preprocessing\nimport { clip } from \"./clip.js\"; // stripe clipping algorithm\nimport { wrap } from \"./wrap.js\"; // date line processing\nimport { transformTile } from \"./transform.js\"; // coordinate transformation\nimport { createTile } from \"./tile.js\"; // final simplified tile generation\nconst DEFAULT_OPTIONS = {\n maxZoom: 14, // max zoom to preserve detail on\n indexMaxZoom: 5, // max zoom in the tile index\n indexMaxPoints: 100000, // max number of points per tile in the tile index\n tolerance: 3, // simplification tolerance (higher means simpler)\n extent: 4096, // tile extent\n buffer: 64, // tile buffer on each side\n lineMetrics: false, // whether to calculate line metrics\n // @ts-expect-error Ensures all these required params have defaults\n promoteId: undefined, // name of a feature property to be promoted to feature.id\n generateId: false, // whether to generate feature ids. Cannot be used with promoteId\n debug: 0 // logging level (0, 1 or 2)\n};\nexport class GeoJSONTiler {\n options;\n // tiles and tileCoords are part of the public API\n tiles = {};\n tileCoords = [];\n stats = {};\n total = 0;\n constructor(data, options) {\n this.options = { ...DEFAULT_OPTIONS, ...options };\n options = this.options;\n const debug = options.debug;\n if (debug)\n console.time('preprocess data');\n if (this.options.maxZoom < 0 || this.options.maxZoom > 24) {\n throw new Error('maxZoom should be in the 0-24 range');\n }\n if (options.promoteId && this.options.generateId) {\n throw new Error('promoteId and generateId cannot be used together.');\n }\n // projects and adds simplification info\n let features = convert(data, options);\n if (debug) {\n console.timeEnd('preprocess data');\n console.log('index: maxZoom: %d, maxPoints: %d', options.indexMaxZoom, options.indexMaxPoints);\n console.time('generate tiles');\n }\n // wraps features (ie extreme west and extreme east)\n features = wrap(features, this.options);\n // start slicing from the top tile down\n if (features.length) {\n this.splitTile(features, 0, 0, 0);\n }\n if (debug) {\n if (features.length) {\n console.log('features: %d, points: %d', this.tiles[0].numFeatures, this.tiles[0].numPoints);\n }\n console.timeEnd('generate tiles');\n console.log('tiles generated:', this.total, JSON.stringify(this.stats));\n }\n }\n /**\n * Get a tile at the specified index\n * @param z\n * @param x\n * @param y\n * @returns\n */\n // eslint-disable-next-line complexity, max-statements\n getTile(z, x, y) {\n // z = +z;\n // x = +x;\n // y = +y;\n const { extent, debug } = this.options;\n if (z < 0 || z > 24) {\n return null;\n }\n const z2 = 1 << z;\n x = (x + z2) & (z2 - 1); // wrap tile x coordinate\n const id = toID(z, x, y);\n if (this.tiles[id]) {\n return transformTile(this.tiles[id], extent);\n }\n if (debug > 1)\n console.log('drilling down to z%d-%d-%d', z, x, y);\n let z0 = z;\n let x0 = x;\n let y0 = y;\n let parent;\n while (!parent && z0 > 0) {\n z0--;\n x0 = x0 >> 1;\n y0 = y0 >> 1;\n parent = this.tiles[toID(z0, x0, y0)];\n }\n if (!parent || !parent.source) {\n return null;\n }\n // if we found a parent tile containing the original geometry, we can drill down from it\n if (debug > 1) {\n console.log('found parent tile z%d-%d-%d', z0, x0, y0);\n console.time('drilling down');\n }\n this.splitTile(parent.source, z0, x0, y0, z, x, y);\n if (debug > 1) {\n console.timeEnd('drilling down');\n }\n return this.tiles[id] ? transformTile(this.tiles[id], extent) : null;\n }\n /**\n * splits features from a parent tile to sub-tiles.\n * @param z, x, and y are the coordinates of the parent tile\n * @param cz, cx, and cy are the coordinates of the target tile\n *\n * If no target tile is specified, splitting stops when we reach the maximum\n * zoom or the number of points is low as specified in the options.\n */\n // eslint-disable-next-line max-params, max-statements, complexity\n splitTile(features, z, x, y, cz, cx, cy) {\n const stack = [features, z, x, y];\n const options = this.options;\n const debug = options.debug;\n // avoid recursion by using a processing queue\n while (stack.length) {\n y = stack.pop();\n x = stack.pop();\n z = stack.pop();\n features = stack.pop();\n const z2 = 1 << z;\n const id = toID(z, x, y);\n let tile = this.tiles[id];\n if (!tile) {\n if (debug > 1) {\n console.time('creation');\n }\n tile = this.tiles[id] = createTile(features, z, x, y, options);\n this.tileCoords.push({ z, x, y });\n if (debug) {\n if (debug > 1) {\n console.log('tile z%d-%d-%d (features: %d, points: %d, simplified: %d)', z, x, y, tile.numFeatures, tile.numPoints, tile.numSimplified);\n console.timeEnd('creation');\n }\n const key = `z${z}`;\n this.stats[key] = (this.stats[key] || 0) + 1;\n this.total++;\n }\n }\n // save reference to original geometry in tile so that we can drill down later if we stop now\n tile.source = features;\n // if it's the first-pass tiling\n if (cz === undefined) {\n // stop tiling if we reached max zoom, or if the tile is too simple\n if (z === options.indexMaxZoom || tile.numPoints <= options.indexMaxPoints)\n continue;\n // if a drilldown to a specific tile\n }\n else if (z === options.maxZoom || z === cz) {\n // stop tiling if we reached base zoom or our target tile zoom\n continue;\n }\n else if (cz !== undefined) {\n // stop tiling if it's not an ancestor of the target tile\n const zoomSteps = cz - z;\n // @ts-expect-error TODO fix the types of cx cy\n if (x !== cx >> zoomSteps || y !== cy >> zoomSteps)\n continue;\n }\n // if we slice further down, no need to keep source geometry\n tile.source = null;\n if (features.length === 0)\n continue;\n if (debug > 1)\n console.time('clipping');\n // values we'll use for clipping\n const k1 = (0.5 * options.buffer) / options.extent;\n const k2 = 0.5 - k1;\n const k3 = 0.5 + k1;\n const k4 = 1 + k1;\n let tl = null;\n let bl = null;\n let tr = null;\n let br = null;\n let left = clip(features, z2, x - k1, x + k3, 0, tile.minX, tile.maxX, options);\n let right = clip(features, z2, x + k2, x + k4, 0, tile.minX, tile.maxX, options);\n // @ts-expect-error - unclear why this is needed?\n features = null;\n if (left) {\n tl = clip(left, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, options);\n bl = clip(left, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, options);\n left = null;\n }\n if (right) {\n tr = clip(right, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, options);\n br = clip(right, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, options);\n right = null;\n }\n if (debug > 1)\n console.timeEnd('clipping');\n stack.push(tl || [], z + 1, x * 2, y * 2);\n stack.push(bl || [], z + 1, x * 2, y * 2 + 1);\n stack.push(tr || [], z + 1, x * 2 + 1, y * 2);\n stack.push(br || [], z + 1, x * 2 + 1, y * 2 + 1);\n }\n }\n}\nfunction toID(z, x, y) {\n return ((1 << z) * y + x) * 32 + z;\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGA,iBAAoC;AACpC,iBAAqB;;;ACId,SAAS,cAAc,OAAO;AACjC,QAAM,MAAM,MAAM;AAClB,MAAI,OAAO;AACP,WAAO,CAAC,KAAK;AACjB,QAAM,WAAW,CAAC;AAClB,MAAI;AACJ,MAA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AK,MAAM,OAAO;AACpE,aAAK,KAAK,MAAM,IAAIA,KAAI,IAAIA,KAAI,IAAI,GAAG,KAAK,MAAM,KAAK,MAAM,OAAO;AACpE,eAAO;AAAA,MACX;AACA,UAAI,OAAO;AACP,aAAK,KAAK,OAAO,IAAIA,KAAI,IAAIA,KAAI,IAAI,GAAG,KAAK,MAAM,KAAK,MAAM,OAAO;AACrE,aAAK,KAAK,OAAO,IAAIA,KAAI,IAAIA,KAAI,IAAI,GAAG,KAAK,MAAM,KAAK,MAAM,OAAO;AACrE,gBAAQ;AAAA,MACZ;AACA,UAAI,QAAQ;AACR,gBAAQ,QAAQ,UAAU;AAC9B,YAAM,KAAK,MAAM,CAAC,GAAG,IAAI,GAAGD,KAAI,GAAGC,KAAI,CAAC;AACxC,YAAM,KAAK,MAAM,CAAC,GAAG,IAAI,GAAGD,KAAI,GAAGC,KAAI,IAAI,CAAC;AAC5C,YAAM,KAAK,MAAM,CAAC,GAAG,IAAI,GAAGD,KAAI,IAAI,GAAGC,KAAI,CAAC;AAC5C,YAAM,KAAK,MAAM,CAAC,GAAG,IAAI,GAAGD,KAAI,IAAI,GAAGC,KAAI,IAAI,CAAC;AAAA,IACpD;AAAA,EACJ;AACJ;AACA,SAAS,KAAK,GAAGD,IAAGC,IAAG;AACnB,WAAS,KAAK,KAAKA,KAAID,MAAK,KAAK;AACrC;",
6
6
  "names": ["i", "cmd", "length", "x", "y", "cmdLen", "x2", "y2", "i", "project", "i", "classifyRings", "i", "readFeature", "readTag", "readFeature", "classifyRings", "x", "y", "readLayer", "i", "readValueMessage", "readTile", "Protobuf", "i", "x", "VERSION", "x", "y", "i", "i", "x", "y", "i", "i", "x", "y", "y2", "i", "ax", "ay", "az", "a", "x", "y", "i", "i", "x", "y", "i", "x", "y", "x", "y"]
7
7
  }
@@ -4,7 +4,7 @@
4
4
  import { parseMVT } from "./lib/parse-mvt.js";
5
5
  // __VERSION__ is injected by babel-plugin-version-inline
6
6
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
- const VERSION = typeof "4.2.1" !== 'undefined' ? "4.2.1" : 'latest';
7
+ const VERSION = typeof "4.2.3" !== 'undefined' ? "4.2.3" : 'latest';
8
8
  /**
9
9
  * Worker loader for the Mapbox Vector Tile format
10
10
  */
@@ -2338,7 +2338,7 @@
2338
2338
  }
2339
2339
 
2340
2340
  // src/mvt-loader.ts
2341
- var VERSION = true ? "4.2.1" : "latest";
2341
+ var VERSION = true ? "4.2.3" : "latest";
2342
2342
  var MVTWorkerLoader = {
2343
2343
  dataType: null,
2344
2344
  batchType: null,
@@ -4,7 +4,7 @@
4
4
  import { parseTileJSON } from "./lib/parse-tilejson.js";
5
5
  // __VERSION__ is injected by babel-plugin-version-inline
6
6
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
- const VERSION = typeof "4.2.1" !== 'undefined' ? "4.2.1" : 'latest';
7
+ const VERSION = typeof "4.2.3" !== 'undefined' ? "4.2.3" : 'latest';
8
8
  /**
9
9
  * Loader for TileJSON metadata
10
10
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@loaders.gl/mvt",
3
3
  "description": "Loader for Mapbox Vector Tiles",
4
- "version": "4.2.2",
4
+ "version": "4.2.4",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "publishConfig": {
@@ -41,10 +41,10 @@
41
41
  "build-worker": "esbuild src/workers/mvt-worker.ts --bundle --outfile=dist/mvt-worker.js --define:__VERSION__=\\\"$npm_package_version\\\""
42
42
  },
43
43
  "dependencies": {
44
- "@loaders.gl/gis": "4.2.2",
45
- "@loaders.gl/images": "4.2.2",
46
- "@loaders.gl/loader-utils": "4.2.2",
47
- "@loaders.gl/schema": "4.2.2",
44
+ "@loaders.gl/gis": "4.2.4",
45
+ "@loaders.gl/images": "4.2.4",
46
+ "@loaders.gl/loader-utils": "4.2.4",
47
+ "@loaders.gl/schema": "4.2.4",
48
48
  "@math.gl/polygon": "^4.0.0",
49
49
  "pbf": "^3.2.1"
50
50
  },
@@ -54,5 +54,5 @@
54
54
  "peerDependencies": {
55
55
  "@loaders.gl/core": "^4.0.0"
56
56
  },
57
- "gitHead": "3e70b64ab0e6894bb359dfcdc85d5f370539fbe2"
57
+ "gitHead": "68ce51cb8ef8ca55a9cc66801e0aff504e925bb9"
58
58
  }