@loaders.gl/pmtiles 4.2.4 → 4.2.5
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 +1 -1
- package/package.json +6 -6
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 nr=Object.create;var Fe=Object.defineProperty;var rr=Object.getOwnPropertyDescriptor;var ir=Object.getOwnPropertyNames;var or=Object.getPrototypeOf,sr=Object.prototype.hasOwnProperty;var Je=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Mt=(e,t)=>{for(var n in t)Fe(e,n,{get:t[n],enumerable:!0})},Pe=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ir(t))!sr.call(e,i)&&i!==n&&Fe(e,i,{get:()=>t[i],enumerable:!(r=rr(t,i))||r.enumerable});return e},Ie=(e,t,n)=>(Pe(e,t,"default"),n&&Pe(n,t,"default")),Ut=(e,t,n)=>(n=e!=null?nr(or(e)):{},Pe(t||!e||!e.__esModule?Fe(n,"default",{value:e,enumerable:!0}):n,e)),ar=e=>Pe(Fe({},"__esModule",{value:!0}),e);var kt=Je((Ro,Lt)=>{Lt.exports=globalThis.loaders});var tn=Je(lt=>{lt.read=function(e,t,n,r,i){var o,s,a=i*8-r-1,l=(1<<a)-1,c=l>>1,f=-7,u=n?i-1:0,h=n?-1:1,d=e[t+u];for(u+=h,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=o*256+e[t+u],u+=h,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=r;f>0;s=s*256+e[t+u],u+=h,f-=8);if(o===0)o=1-c;else{if(o===l)return s?NaN:(d?-1:1)*(1/0);s=s+Math.pow(2,r),o=o-c}return(d?-1:1)*s*Math.pow(2,o-r)};lt.write=function(e,t,n,r,i,o){var s,a,l,c=o*8-i-1,f=(1<<c)-1,u=f>>1,h=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,p=r?1:-1,m=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=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),s+u>=1?t+=h/l:t+=h*Math.pow(2,1-u),t*l>=2&&(s++,l/=2),s+u>=f?(a=0,s=f):s+u>=1?(a=(t*l-1)*Math.pow(2,i),s=s+u):(a=t*Math.pow(2,u-1)*Math.pow(2,i),s=0));i>=8;e[n+d]=a&255,d+=p,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;e[n+d]=s&255,d+=p,s/=256,c-=8);e[n+d-p]|=m*128}});var ln=Je((Ta,an)=>{"use strict";an.exports=x;var Be=tn();function x(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}x.Varint=0;x.Fixed64=1;x.Bytes=2;x.Fixed32=5;var ct=(1<<16)*(1<<16),nn=1/ct,pi=12,sn=typeof TextDecoder>"u"?null:new TextDecoder("utf8");x.prototype={destroy:function(){this.buf=null},readFields:function(e,t,n){for(n=n||this.length;this.pos<n;){var r=this.readVarint(),i=r>>3,o=this.pos;this.type=r&7,e(i,t,this),this.pos===o&&this.skip(r)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=Ee(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=on(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=Ee(this.buf,this.pos)+Ee(this.buf,this.pos+4)*ct;return this.pos+=8,e},readSFixed64:function(){var e=Ee(this.buf,this.pos)+on(this.buf,this.pos+4)*ct;return this.pos+=8,e},readFloat:function(){var e=Be.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=Be.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t=this.buf,n,r;return r=t[this.pos++],n=r&127,r<128||(r=t[this.pos++],n|=(r&127)<<7,r<128)||(r=t[this.pos++],n|=(r&127)<<14,r<128)||(r=t[this.pos++],n|=(r&127)<<21,r<128)?n:(r=t[this.pos],n|=(r&15)<<28,gi(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>=pi&&sn?Ai(this.buf,t,e):bi(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!==x.Bytes)return e.push(this.readVarint(t));var n=z(this);for(e=e||[];this.pos<n;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==x.Bytes)return e.push(this.readSVarint());var t=z(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){if(this.type!==x.Bytes)return e.push(this.readBoolean());var t=z(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){if(this.type!==x.Bytes)return e.push(this.readFloat());var t=z(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){if(this.type!==x.Bytes)return e.push(this.readDouble());var t=z(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){if(this.type!==x.Bytes)return e.push(this.readFixed32());var t=z(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){if(this.type!==x.Bytes)return e.push(this.readSFixed32());var t=z(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){if(this.type!==x.Bytes)return e.push(this.readFixed64());var t=z(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){if(this.type!==x.Bytes)return e.push(this.readSFixed64());var t=z(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var t=e&7;if(t===x.Varint)for(;this.buf[this.pos++]>127;);else if(t===x.Bytes)this.pos=this.readVarint()+this.pos;else if(t===x.Fixed32)this.pos+=4;else if(t===x.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),Y(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),Y(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),Y(this.buf,e&-1,this.pos),Y(this.buf,Math.floor(e*nn),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),Y(this.buf,e&-1,this.pos),Y(this.buf,Math.floor(e*nn),this.pos+4),this.pos+=8},writeVarint:function(e){if(e=+e||0,e>268435455||e<0){yi(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=Bi(this.buf,e,this.pos);var n=this.pos-t;n>=128&&rn(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n},writeFloat:function(e){this.realloc(4),Be.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),Be.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 r=this.pos-n;r>=128&&rn(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r},writeMessage:function(e,t,n){this.writeTag(e,x.Bytes),this.writeRawMessage(t,n)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,wi,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,vi,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,Ii,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,Pi,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,Fi,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,Ti,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,Si,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,Di,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,Vi,t)},writeBytesField:function(e,t){this.writeTag(e,x.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,x.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,x.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,x.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,x.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,x.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,x.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,x.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,x.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,x.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};function gi(e,t,n){var r=n.buf,i,o;if(o=r[n.pos++],i=(o&112)>>4,o<128||(o=r[n.pos++],i|=(o&127)<<3,o<128)||(o=r[n.pos++],i|=(o&127)<<10,o<128)||(o=r[n.pos++],i|=(o&127)<<17,o<128)||(o=r[n.pos++],i|=(o&127)<<24,o<128)||(o=r[n.pos++],i|=(o&1)<<31,o<128))return X(e,i,t);throw new Error("Expected varint not more than 10 bytes")}function z(e){return e.type===x.Bytes?e.readVarint()+e.pos:e.pos+1}function X(e,t,n){return n?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function yi(e,t){var n,r;if(e>=0?(n=e%4294967296|0,r=e/4294967296|0):(n=~(-e%4294967296),r=~(-e/4294967296),n^4294967295?n=n+1|0:(n=0,r=r+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),mi(n,r,t),xi(r,t)}function mi(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 xi(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 rn(e,t,n){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(Math.LN2*7));n.realloc(r);for(var i=n.pos-1;i>=e;i--)n.buf[i+r]=n.buf[i]}function wi(e,t){for(var n=0;n<e.length;n++)t.writeVarint(e[n])}function vi(e,t){for(var n=0;n<e.length;n++)t.writeSVarint(e[n])}function Pi(e,t){for(var n=0;n<e.length;n++)t.writeFloat(e[n])}function Fi(e,t){for(var n=0;n<e.length;n++)t.writeDouble(e[n])}function Ii(e,t){for(var n=0;n<e.length;n++)t.writeBoolean(e[n])}function Ti(e,t){for(var n=0;n<e.length;n++)t.writeFixed32(e[n])}function Si(e,t){for(var n=0;n<e.length;n++)t.writeSFixed32(e[n])}function Di(e,t){for(var n=0;n<e.length;n++)t.writeFixed64(e[n])}function Vi(e,t){for(var n=0;n<e.length;n++)t.writeSFixed64(e[n])}function Ee(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+e[t+3]*16777216}function Y(e,t,n){e[n]=t,e[n+1]=t>>>8,e[n+2]=t>>>16,e[n+3]=t>>>24}function on(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}function bi(e,t,n){for(var r="",i=t;i<n;){var o=e[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a>n)break;var l,c,f;a===1?o<128&&(s=o):a===2?(l=e[i+1],(l&192)===128&&(s=(o&31)<<6|l&63,s<=127&&(s=null))):a===3?(l=e[i+1],c=e[i+2],(l&192)===128&&(c&192)===128&&(s=(o&15)<<12|(l&63)<<6|c&63,(s<=2047||s>=55296&&s<=57343)&&(s=null))):a===4&&(l=e[i+1],c=e[i+2],f=e[i+3],(l&192)===128&&(c&192)===128&&(f&192)===128&&(s=(o&15)<<18|(l&63)<<12|(c&63)<<6|f&63,(s<=65535||s>=1114112)&&(s=null))),s===null?(s=65533,a=1):s>65535&&(s-=65536,r+=String.fromCharCode(s>>>10&1023|55296),s=56320|s&1023),r+=String.fromCharCode(s),i+=a}return r}function Ai(e,t,n){return sn.decode(e.subarray(t,n))}function Bi(e,t,n){for(var r=0,i,o;r<t.length;r++){if(i=t.charCodeAt(r),i>55295&&i<57344)if(o)if(i<56320){e[n++]=239,e[n++]=191,e[n++]=189,o=i;continue}else i=o-55296<<10|i-56320|65536,o=null;else{i>56319||r+1===t.length?(e[n++]=239,e[n++]=191,e[n++]=189):o=i;continue}else o&&(e[n++]=239,e[n++]=191,e[n++]=189,o=null);i<128?e[n++]=i:(i<2048?e[n++]=i>>6|192:(i<65536?e[n++]=i>>12|224:(e[n++]=i>>18|240,e[n++]=i>>12&63|128),e[n++]=i>>6&63|128),e[n++]=i&63|128)}return n}});var we={};Mt(we,{PMTilesSource:()=>Ze});Ie(we,Ut(kt(),1));function re(e,t){if(!e)throw new Error(t||"loader assertion failed.")}var O={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},lr=O.self||O.window||O.global||{},cr=O.window||O.self||O.global||{},fr=O.global||O.self||O.window||{},ur=O.document||{};var We=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var Ct=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),hr=Ct&&parseFloat(Ct[1])||0;function R(e){return R=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},R(e)}function $e(e,t){if(R(e)!=="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(R(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ke(e){var t=$e(e,"string");return R(t)==="symbol"?t:String(t)}function B(e,t,n){return t=Ke(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var dr="",Ot={};function Xe(e){for(let t in Ot)if(e.startsWith(t)){let n=Ot[t];e=e.replace(t,n)}return!e.startsWith("http://")&&!e.startsWith("https://")&&(e=`${dr}${e}`),e}var ie=class{fetch;loadOptions;_needsRefresh=!0;props;constructor(t){this.props={...t},this.loadOptions={...t.loadOptions},this.fetch=pr(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 pr(e){let t=e?.fetch;if(t&&typeof t=="function")return(r,i)=>t(r,i);let n=e?.fetch;return n&&typeof n!="function"?r=>fetch(r,n):r=>fetch(r)}var Nt="4.2.3";var gr=globalThis.loaders?.parseImageNode,Ye=typeof Image<"u",Qe=typeof ImageBitmap<"u",yr=Boolean(gr),qe=We?!0:yr;function zt(e){switch(e){case"auto":return Qe||Ye||qe;case"imagebitmap":return Qe;case"image":return Ye;case"data":return qe;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}function Zt(){if(Qe)return"imagebitmap";if(Ye)return"image";if(qe)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function mr(e){let t=xr(e);if(!t)throw new Error("Not an image");return t}function Rt(e){switch(mr(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 xr(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 wr=/^data:image\/svg\+xml/,vr=/\.svg((\?|#).*)?$/;function Te(e){return e&&(wr.test(e)||vr.test(e))}function jt(e,t){if(Te(t)){let r=new TextDecoder().decode(e);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(r=unescape(encodeURIComponent(r)))}catch(o){throw new Error(o.message)}return`data:image/svg+xml;base64,${btoa(r)}`}return et(e,t)}function et(e,t){if(Te(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function Se(e,t,n){let r=jt(e,n),i=self.URL||self.webkitURL,o=typeof r!="string"&&i.createObjectURL(r);try{return await Pr(o||r,t)}finally{o&&i.revokeObjectURL(o)}}async function Pr(e,t){let n=new Image;return n.src=e,t.image&&t.image.decode&&n.decode?(await n.decode(),n):await new Promise((r,i)=>{try{n.onload=()=>r(n),n.onerror=o=>{let s=o instanceof Error?o.message:"error";i(new Error(s))}}catch(o){i(o)}})}var Fr={},Gt=!0;async function Ht(e,t,n){let r;Te(n)?r=await Se(e,t,n):r=et(e,n);let i=t&&t.imagebitmap;return await Ir(r,i)}async function Ir(e,t=null){if((Tr(t)||!Gt)&&(t=null),t)try{return await createImageBitmap(e,t)}catch(n){console.warn(n),Gt=!1}return await createImageBitmap(e)}function Tr(e){for(let t in e||Fr)return!1;return!0}function Jt(e){return!br(e,"ftyp",4)||!(e[8]&96)?null:Sr(e)}function Sr(e){switch(Dr(e,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function Dr(e,t,n){return String.fromCharCode(...e.slice(t,n))}function Vr(e){return[...e].map(t=>t.charCodeAt(0))}function br(e,t,n=0){let r=Vr(t);for(let i=0;i<r.length;++i)if(r[i]!==e[i+n])return!1;return!0}var N=!1,oe=!0;function De(e){let t=se(e);return Br(t)||Mr(t)||Er(t)||_r(t)||Ar(t)}function Ar(e){let t=new Uint8Array(e instanceof DataView?e.buffer:e),n=Jt(t);return n?{mimeType:n.mimeType,width:0,height:0}:null}function Br(e){let t=se(e);return t.byteLength>=24&&t.getUint32(0,N)===2303741511?{mimeType:"image/png",width:t.getUint32(16,N),height:t.getUint32(20,N)}:null}function Er(e){let t=se(e);return t.byteLength>=10&&t.getUint32(0,N)===1195984440?{mimeType:"image/gif",width:t.getUint16(6,oe),height:t.getUint16(8,oe)}:null}function _r(e){let t=se(e);return t.byteLength>=14&&t.getUint16(0,N)===16973&&t.getUint32(2,oe)===t.byteLength?{mimeType:"image/bmp",width:t.getUint32(18,oe),height:t.getUint32(22,oe)}:null}function Mr(e){let t=se(e);if(!(t.byteLength>=3&&t.getUint16(0,N)===65496&&t.getUint8(2)===255))return null;let{tableMarkers:r,sofMarkers:i}=Ur(),o=2;for(;o+9<t.byteLength;){let s=t.getUint16(o,N);if(i.has(s))return{mimeType:"image/jpeg",height:t.getUint16(o+5,N),width:t.getUint16(o+7,N)};if(!r.has(s))return null;o+=2,o+=t.getUint16(o,N)}return null}function Ur(){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 se(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 Wt(e,t){let{mimeType:n}=De(e)||{},r=globalThis.loaders?.parseImageNode;return re(r),await r(e,n)}async function $t(e,t,n){t=t||{};let i=(t.image||{}).type||"auto",{url:o}=n||{},s=Lr(i),a;switch(s){case"imagebitmap":a=await Ht(e,t,o);break;case"image":a=await Se(e,t,o);break;case"data":a=await Wt(e,t);break;default:re(!1)}return i==="data"&&(a=Rt(a)),a}function Lr(e){switch(e){case"auto":case"data":return Zt();default:return zt(e),e}}var kr=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],Cr=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],Or={image:{type:"auto",decode:!0}},tt={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:Nt,mimeTypes:Cr,extensions:kr,parse:$t,tests:[e=>Boolean(De(new DataView(e)))],options:Or};var ae={x:0,y:1,z:2};function j(e,t={}){let{start:n=0,end:r=e.length,plane:i="xy"}=t,o=t.size||2,s=0,a=ae[i[0]],l=ae[i[1]];for(let c=n,f=r-o;c<r;c+=o)s+=(e[c+a]-e[f+a])*(e[c+l]+e[f+l]),f=c;return s/2}function rt(e,t,n=2,r,i="xy"){let o=t&&t.length,s=o?t[0]*n:e.length,a=Xt(e,0,s,n,!0,r&&r[0],i),l=[];if(!a||a.next===a.prev)return l;let c,f,u,h,d,p,m;if(o&&(a=Hr(e,t,a,n,r,i)),e.length>80*n){h=f=e[0],d=u=e[1];for(let F=n;F<s;F+=n)p=e[F],m=e[F+1],p<h&&(h=p),m<d&&(d=m),p>f&&(f=p),m>u&&(u=m);c=Math.max(f-h,u-d),c=c!==0?32767/c:0}return le(a,l,n,h,d,c,0),l}function Xt(e,t,n,r,i,o,s){let a,l;o===void 0&&(o=j(e,{start:t,end:n,size:r,plane:s}));let c=ae[s[0]],f=ae[s[1]];if(i===o<0)for(a=t;a<n;a+=r)l=Kt(a,e[a+c],e[a+f],l);else for(a=n-r;a>=t;a-=r)l=Kt(a,e[a+c],e[a+f],l);return l&&Ae(l,l.next)&&(fe(l),l=l.next),l}function G(e,t){if(!e)return e;t||(t=e);let n=e,r;do if(r=!1,!n.steiner&&(Ae(n,n.next)||P(n.prev,n,n.next)===0)){if(fe(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function le(e,t,n,r,i,o,s){if(!e)return;!s&&o&&Xr(e,r,i,o);let a=e,l,c;for(;e.prev!==e.next;){if(l=e.prev,c=e.next,o?Rr(e,r,i,o):Zr(e)){t.push(l.i/n|0),t.push(e.i/n|0),t.push(c.i/n|0),fe(e),e=c.next,a=c.next;continue}if(e=c,e===a){s?s===1?(e=jr(G(e),t,n),le(e,t,n,r,i,o,2)):s===2&&Gr(e,t,n,r,i,o):le(G(e),t,n,r,i,o,1);break}}}function Zr(e){let t=e.prev,n=e,r=e.next;if(P(t,n,r)>=0)return!1;let i=t.x,o=n.x,s=r.x,a=t.y,l=n.y,c=r.y,f=i<o?i<s?i:s:o<s?o:s,u=a<l?a<c?a:c:l<c?l:c,h=i>o?i>s?i:s:o>s?o:s,d=a>l?a>c?a:c:l>c?l:c,p=r.next;for(;p!==t;){if(p.x>=f&&p.x<=h&&p.y>=u&&p.y<=d&&K(i,a,o,l,s,c,p.x,p.y)&&P(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Rr(e,t,n,r){let i=e.prev,o=e,s=e.next;if(P(i,o,s)>=0)return!1;let a=i.x,l=o.x,c=s.x,f=i.y,u=o.y,h=s.y,d=a<l?a<c?a:c:l<c?l:c,p=f<u?f<h?f:h:u<h?u:h,m=a>l?a>c?a:c:l>c?l:c,F=f>u?f>h?f:h:u>h?u:h,_=nt(d,p,t,n,r),v=nt(m,F,t,n,r),y=e.prevZ,g=e.nextZ;for(;y&&y.z>=_&&g&&g.z<=v;){if(y.x>=d&&y.x<=m&&y.y>=p&&y.y<=F&&y!==i&&y!==s&&K(a,f,l,u,c,h,y.x,y.y)&&P(y.prev,y,y.next)>=0||(y=y.prevZ,g.x>=d&&g.x<=m&&g.y>=p&&g.y<=F&&g!==i&&g!==s&&K(a,f,l,u,c,h,g.x,g.y)&&P(g.prev,g,g.next)>=0))return!1;g=g.nextZ}for(;y&&y.z>=_;){if(y.x>=d&&y.x<=m&&y.y>=p&&y.y<=F&&y!==i&&y!==s&&K(a,f,l,u,c,h,y.x,y.y)&&P(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;g&&g.z<=v;){if(g.x>=d&&g.x<=m&&g.y>=p&&g.y<=F&&g!==i&&g!==s&&K(a,f,l,u,c,h,g.x,g.y)&&P(g.prev,g,g.next)>=0)return!1;g=g.nextZ}return!0}function jr(e,t,n){let r=e;do{let i=r.prev,o=r.next.next;!Ae(i,o)&&Yt(i,r,r.next,o)&&ce(i,o)&&ce(o,i)&&(t.push(i.i/n|0),t.push(r.i/n|0),t.push(o.i/n|0),fe(r),fe(r.next),r=e=o),r=r.next}while(r!==e);return G(r)}function Gr(e,t,n,r,i,o){let s=e;do{let a=s.next.next;for(;a!==s.prev;){if(s.i!==a.i&&qr(s,a)){let l=Qt(s,a);s=G(s,s.next),l=G(l,l.next),le(s,t,n,r,i,o,0),le(l,t,n,r,i,o,0);return}a=a.next}s=s.next}while(s!==e)}function Hr(e,t,n,r,i,o){let s=[],a,l,c,f,u;for(a=0,l=t.length;a<l;a++)c=t[a]*r,f=a<l-1?t[a+1]*r:e.length,u=Xt(e,c,f,r,!1,i&&i[a+1],o),u===u.next&&(u.steiner=!0),s.push(Qr(u));for(s.sort(Jr),a=0;a<s.length;a++)n=Wr(s[a],n);return n}function Jr(e,t){return e.x-t.x}function Wr(e,t){let n=$r(e,t);if(!n)return t;let r=Qt(n,e);return G(r,r.next),G(n,n.next)}function $r(e,t){let n=t,r=e.x,i=e.y,o=-1/0,s;do{if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){let h=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(h<=r&&h>o&&(o=h,s=n.x<n.next.x?n:n.next,h===r))return s}n=n.next}while(n!==t);if(!s)return null;let a=s,l=s.x,c=s.y,f=1/0,u;n=s;do r>=n.x&&n.x>=l&&r!==n.x&&K(i<c?r:o,i,l,c,i<c?o:r,i,n.x,n.y)&&(u=Math.abs(i-n.y)/(r-n.x),ce(n,e)&&(u<f||u===f&&(n.x>s.x||n.x===s.x&&Kr(s,n)))&&(s=n,f=u)),n=n.next;while(n!==a);return s}function Kr(e,t){return P(e.prev,e,t.prev)<0&&P(t.next,e,e.next)<0}function Xr(e,t,n,r){let i=e;do i.z===0&&(i.z=nt(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,Yr(i)}function Yr(e){let t,n,r=1,i,o,s,a,l,c;do{for(o=e,e=null,c=null,i=0;o;){for(i++,a=o,s=0,n=0;n<r&&(s++,a=a.nextZ,!!a);n++);for(l=r;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--),c?c.nextZ=t:e=t,t.prevZ=c,c=t;o=a}c.nextZ=null,r*=2}while(i>1);return e}function nt(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|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 Qr(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 K(e,t,n,r,i,o,s,a){return(i-s)*(t-a)>=(e-s)*(o-a)&&(e-s)*(r-a)>=(n-s)*(t-a)&&(n-s)*(o-a)>=(i-s)*(r-a)}function qr(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!ei(e,t)&&(ce(e,t)&&ce(t,e)&&ti(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 Yt(e,t,n,r){let i=be(P(e,t,n)),o=be(P(e,t,r)),s=be(P(n,r,e)),a=be(P(n,r,t));return!!(i!==o&&s!==a||i===0&&Ve(e,n,t)||o===0&&Ve(e,r,t)||s===0&&Ve(n,e,r)||a===0&&Ve(n,t,r))}function Ve(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 be(e){return e>0?1:e<0?-1:0}function ei(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&&Yt(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function ce(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 ti(e,t){let n=e,r=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function Qt(e,t){let n=new ue(e.i,e.x,e.y),r=new ue(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function Kt(e,t,n,r){let i=new ue(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function fe(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 ue=class{constructor(t,n,r){B(this,"i",void 0),B(this,"x",void 0),B(this,"y",void 0),B(this,"prev",null),B(this,"next",null),B(this,"z",0),B(this,"prevZ",null),B(this,"nextZ",null),B(this,"steiner",!1),this.i=t,this.x=n,this.y=r}};function st(e,t,n){let r=si(e),i=Object.keys(r).filter(o=>r[o]!==Array);return ai(e,{propArrayTypes:r,...t},{numericPropKeys:n&&n.numericPropKeys||i,PositionDataType:n?n.PositionDataType:Float32Array,triangulate:n?n.triangulate:!0})}function si(e){let t={};for(let n of e)if(n.properties)for(let r in n.properties){let i=n.properties[r];t[r]=di(i,t[r])}return t}function ai(e,t,n){let{pointPositionsCount:r,pointFeaturesCount:i,linePositionsCount:o,linePathsCount:s,lineFeaturesCount:a,polygonPositionsCount:l,polygonObjectsCount:c,polygonRingsCount:f,polygonFeaturesCount:u,propArrayTypes:h,coordLength:d}=t,{numericPropKeys:p=[],PositionDataType:m=Float32Array,triangulate:F=!0}=n,_=e[0]&&"id"in e[0],v=e.length>65535?Uint32Array:Uint16Array,y={type:"Point",positions:new m(r*d),globalFeatureIds:new v(r),featureIds:i>65535?new Uint32Array(r):new Uint16Array(r),numericProps:{},properties:[],fields:[]},g={type:"LineString",pathIndices:o>65535?new Uint32Array(s+1):new Uint16Array(s+1),positions:new m(o*d),globalFeatureIds:new v(o),featureIds:a>65535?new Uint32Array(o):new Uint16Array(o),numericProps:{},properties:[],fields:[]},V={type:"Polygon",polygonIndices:l>65535?new Uint32Array(c+1):new Uint16Array(c+1),primitivePolygonIndices:l>65535?new Uint32Array(f+1):new Uint16Array(f+1),positions:new m(l*d),globalFeatureIds:new v(l),featureIds:u>65535?new Uint32Array(l):new Uint16Array(l),numericProps:{},properties:[],fields:[]};F&&(V.triangles=[]);for(let M of[y,g,V])for(let T of p){let b=h[T];M.numericProps[T]=new b(M.positions.length/d)}g.pathIndices[s]=o,V.polygonIndices[c]=l,V.primitivePolygonIndices[f]=l;let C={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(let M of e){let T=M.geometry,b=M.properties||{};switch(T.type){case"Point":li(T,y,C,d,b),y.properties.push(ot(b,p)),_&&y.fields.push({id:M.id}),C.pointFeature++;break;case"LineString":ci(T,g,C,d,b),g.properties.push(ot(b,p)),_&&g.fields.push({id:M.id}),C.lineFeature++;break;case"Polygon":fi(T,V,C,d,b),V.properties.push(ot(b,p)),_&&V.fields.push({id:M.id}),C.polygonFeature++;break;default:throw new Error("Invalid geometry type")}C.feature++}return hi(y,g,V,d)}function li(e,t,n,r,i){t.positions.set(e.data,n.pointPosition*r);let o=e.data.length/r;at(t,i,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 ci(e,t,n,r,i){t.positions.set(e.data,n.linePosition*r);let o=e.data.length/r;at(t,i,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],c=s===a-1?e.data.length:e.indices[s+1];t.pathIndices[n.linePath++]=n.linePosition,n.linePosition+=(c-l)/r}}function fi(e,t,n,r,i){t.positions.set(e.data,n.polygonPosition*r);let o=e.data.length/r;at(t,i,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 c=e.areas[s],f=e.indices[s],u=e.indices[s+1];for(let d=0,p=f.length;d<p;++d){let m=f[d],F=d===p-1?u===void 0?e.data.length:u[0]:f[d+1];t.primitivePolygonIndices[n.polygonRing++]=n.polygonPosition,n.polygonPosition+=(F-m)/r}let h=n.polygonPosition;ui(t,c,f,{startPosition:l,endPosition:h,coordLength:r})}}function ui(e,t,n,{startPosition:r,endPosition:i,coordLength:o}){if(!e.triangles)return;let s=r*o,a=i*o,l=e.positions.subarray(s,a),c=n[0],f=n.slice(1).map(h=>(h-c)/o),u=rt(l,f,o,t);for(let h=0,d=u.length;h<d;++h)e.triangles.push(r+u[h])}function it(e,t){let n={};for(let r in e)n[r]={value:e[r],size:t};return n}function hi(e,t,n,r){let i={shape:"binary-feature-collection",points:{...e,positions:{value:e.positions,size:r},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},numericProps:it(e.numericProps,1)},lines:{...t,positions:{value:t.positions,size:r},pathIndices:{value:t.pathIndices,size:1},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},numericProps:it(t.numericProps,1)},polygons:{...n,positions:{value:n.positions,size:r},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:it(n.numericProps,1)}};return i.polygons&&n.triangles&&(i.polygons.triangles={value:new Uint32Array(n.triangles),size:1}),i}function at(e,t,n,r){for(let i in e.numericProps)if(i in t){let o=t[i];e.numericProps[i].fill(o,n,n+r)}}function ot(e,t){let n={};for(let r in e)t.includes(r)||(n[r]=e[r]);return n}function di(e,t){return t===Array||!Number.isFinite(e)?Array:t===Float64Array||Math.fround(e)!==e?Float64Array:Float32Array}var pt=Ut(ln(),1);function cn(e){let t=e.length;if(t<=1)return[e];let n=[],r,i;for(let o=0;o<t;o++){let s=Ei(e[o]);s!==0&&(i===void 0&&(i=s<0),i===s<0?(r&&n.push(r),r=[e[o]]):r&&r.push(e[o]))}return r&&n.push(r),n}function Ei(e){let t=0;for(let n=0,r=e.length-1,i,o;n<e.length;r=n++)i=e[n],o=e[r],t+=(o[0]-i[0])*(i[1]+o[1]);return t}function fn(e,t,n){t&&n&&(e===1?t.id=n.readVarint():e===2?_i(n,t):e===3?t.type=n.readVarint():e===4&&(t._geometry=n.pos))}function _i(e,t){let n=e.readVarint()+e.pos;for(;e.pos<n;){let r=t._keys[e.readVarint()],i=t._values[e.readVarint()];t.properties[r]=i}}var Q=class{properties;extent;type;id;_pbf;_geometry;_keys;_values;static get types(){return["Unknown","Point","LineString","Polygon"]}constructor(t,n,r,i,o){this.properties={},this.extent=r,this.type=0,this.id=null,this._pbf=t,this._geometry=-1,this._keys=i,this._values=o,t.readFields(fn,this,n)}loadGeometry(){let t=this._pbf;t.pos=this._geometry;let n=t.readVarint()+t.pos,r=1,i=0,o=0,s=0,a=[],l;for(;t.pos<n;){if(i<=0){let c=t.readVarint();r=c&7,i=c>>3}if(i--,r===1||r===2)o+=t.readSVarint(),s+=t.readSVarint(),r===1&&(l&&a.push(l),l=[]),l&&l.push([o,s]);else if(r===7)l&&l.push(l[0].slice());else throw new Error(`unknown command ${r}`)}return l&&a.push(l),a}bbox(){let t=this._pbf;t.pos=this._geometry;let n=t.readVarint()+t.pos,r=1,i=0,o=0,s=0,a=1/0,l=-1/0,c=1/0,f=-1/0;for(;t.pos<n;){if(i<=0){let u=t.readVarint();r=u&7,i=u>>3}if(i--,r===1||r===2)o+=t.readSVarint(),s+=t.readSVarint(),o<a&&(a=o),o>l&&(l=o),s<c&&(c=s),s>f&&(f=s);else if(r!==7)throw new Error(`unknown command ${r}`)}return[a,c,l,f]}_toGeoJSON(t){let n=this.loadGeometry(),r=Q.types[this.type],i,o;switch(this.type){case 1:let a=[];for(i=0;i<n.length;i++)a[i]=n[i][0];n=a,t(n,this);break;case 2:for(i=0;i<n.length;i++)t(n[i],this);break;case 3:for(n=cn(n),i=0;i<n.length;i++)for(o=0;o<n[i].length;o++)t(n[i][o],this);break}n.length===1?n=n[0]:r=`Multi${r}`;let s={type:"Feature",geometry:{type:r,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:r,z:i}=t,o=this.extent*Math.pow(2,i),s=this.extent*n,a=this.extent*r;function l(c){for(let f=0;f<c.length;f++){let u=c[f];u[0]=(u[0]+s)*360/o-180;let h=180-(u[1]+a)*360/o;u[1]=360/Math.PI*Math.atan(Math.exp(h*Math.PI/180))-90}}return this._toGeoJSON(l)}};var _e=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(Mi,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 Q(this._pbf,n,this.extent,this._keys,this._values)}};function Mi(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(Ui(n)))}function Ui(e){let t=null,n=e.readVarint()+e.pos;for(;e.pos<n;){let r=e.readVarint()>>3;t=r===1?e.readString():r===2?e.readFloat():r===3?e.readDouble():r===4?e.readVarint64():r===5?e.readVarint():r===6?e.readSVarint():r===7?e.readBoolean():null}return t}var Me=class{layers;constructor(t,n){this.layers=t.readFields(Li,{},n)}};function Li(e,t,n){if(e===3&&n){let r=new _e(n,n.readVarint()+n.pos);r.length&&t&&(t[r.name]=r)}}function un(e){let t=e.indices.length,n="Polygon";if(t<=1)return{type:n,data:e.data,areas:[[j(e.data)]],indices:[e.indices]};let r=[],i=[],o=[],s=[],a,l=0;for(let c,f=0,u;f<t;f++){u=e.indices[f]-l,c=e.indices[f+1]-l||e.data.length;let h=e.data.slice(u,c),d=j(h);if(d===0){let p=e.data.slice(0,u),m=e.data.slice(c);e.data=p.concat(m),l+=c-u;continue}a===void 0&&(a=d<0),a===d<0?(s.length&&(r.push(o),i.push(s)),s=[u],o=[d]):(o.push(d),s.push(u))}return o&&r.push(o),s.length&&i.push(s),{type:n,areas:r,indices:i,data:e.data}}function hn(e,t,n,r){for(let i=0,o=e.length;i<o;i+=2){e[i]=(e[i]+t)*360/r-180;let s=180-(e[i+1]+n)*360/r;e[i+1]=360/Math.PI*Math.atan(Math.exp(s*Math.PI/180))-90}}function dn(e,t,n){t&&n&&(e===1?t.id=n.readVarint():e===2?ki(n,t):e===3?t.type=n.readVarint():e===4&&(t._geometry=n.pos))}function ki(e,t){let n=e.readVarint()+e.pos;for(;e.pos<n;){let r=t._keys[e.readVarint()],i=t._values[e.readVarint()];t.properties[r]=i}}var pn,H,ft,Ue,ut,ht,he;var Le=class{properties;extent;type;id;_pbf;_geometry;_keys;_values;_geometryInfo;constructor(t,n,r,i,o,s){this.properties={},this.extent=r,this.type=0,this.id=null,this._pbf=t,this._geometry=-1,this._keys=i,this._values=o,this._geometryInfo=s,t.readFields(dn,this,n)}loadGeometry(){let t=this._pbf;t.pos=this._geometry,pn=t.readVarint()+t.pos,H=1,Ue=0,ut=0,ht=0,he=0;let n=[],r=[];for(;t.pos<pn;)if(Ue<=0&&(ft=t.readVarint(),H=ft&7,Ue=ft>>3),Ue--,H===1||H===2)ut+=t.readSVarint(),ht+=t.readSVarint(),H===1&&n.push(he),r.push(ut,ht),he+=2;else if(H===7){if(he>0){let i=n[n.length-1];r.push(r[i],r[i+1]),he+=2}}else throw new Error(`unknown command ${H}`);return{data:r,indices:n}}_toBinaryCoordinates(t){let n=this.loadGeometry(),r;t(n.data,this);let i=2;switch(this.type){case 1:this._geometryInfo.pointFeaturesCount++,this._geometryInfo.pointPositionsCount+=n.indices.length,r={type:"Point",...n};break;case 2:this._geometryInfo.lineFeaturesCount++,this._geometryInfo.linePathsCount+=n.indices.length,this._geometryInfo.linePositionsCount+=n.data.length/i,r={type:"LineString",...n};break;case 3:r=un(n),this._geometryInfo.polygonFeaturesCount++,this._geometryInfo.polygonObjectsCount+=r.indices.length;for(let s of r.indices)this._geometryInfo.polygonRingsCount+=s.length;this._geometryInfo.polygonPositionsCount+=r.data.length/i;break;default:throw new Error(`Invalid geometry type: ${this.type}`)}let o={type:"Feature",geometry:r,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:r,z:i}=t,o=this.extent*Math.pow(2,i),s=this.extent*n,a=this.extent*r;return this._toBinaryCoordinates(l=>hn(l,s,a,o))}};var ke=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(Ci,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 r=this._pbf.readVarint()+this._pbf.pos;return new Le(this._pbf,r,this.extent,this._keys,this._values,n)}};function Ci(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 r=e.readVarint()>>3;t=r===1?e.readString():r===2?e.readFloat():r===3?e.readDouble():r===4?e.readVarint64():r===5?e.readVarint():r===6?e.readSVarint():r===7?e.readBoolean():null}return t}var Ce=class{layers;constructor(t,n){this.layers=t.readFields(Ni,{},n)}};function Ni(e,t,n){if(e===3&&n){let r=new ke(n,n.readVarint()+n.pos);r.length&&t&&(t[r.name]=r)}}function gt(e,t){let n=Zi(t),r=t?.gis?.format||t?.mvt?.shape||t?.shape;switch(r){case"columnar-table":return{shape:"columnar-table",data:dt(e,n)};case"geojson-table":return{shape:"geojson-table",type:"FeatureCollection",features:gn(e,n)};case"geojson":return gn(e,n);case"binary-geometry":return dt(e,n);case"binary":return dt(e,n);default:throw new Error(r||"undefined shape")}}function dt(e,t){let[n,r]=zi(e,t),i=st(n,r);return i.byteLength=e.byteLength,i}function zi(e,t){let n=[],r={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,r];let i=new Ce(new pt.default(e));return(t&&Array.isArray(t.layers)?t.layers:Object.keys(i.layers)).forEach(s=>{let a=i.layers[s];if(a)for(let l=0;l<a.length;l++){let c=a.feature(l,r),f=ji(c,t,s);n.push(f)}}),[n,r]}function gn(e,t){if(e.byteLength<=0)return[];let n=[],r=new Me(new pt.default(e));return(Array.isArray(t.layers)?t.layers:Object.keys(r.layers)).forEach(o=>{let s=r.layers[o];if(s)for(let a=0;a<s.length;a++){let l=s.feature(a),c=Ri(l,t,o);n.push(c)}}),n}function Zi(e){if(!e?.mvt)throw new Error("mvt options required");let t=e.mvt?.coordinates==="wgs84",{tileIndex:n}=e.mvt,r=n&&Number.isFinite(n.x)&&Number.isFinite(n.y)&&Number.isFinite(n.z);if(t&&!r)throw new Error("MVT Loader: WGS84 coordinates need tileIndex property");return e.mvt}function Ri(e,t,n){let r=e.toGeoJSON(t.coordinates==="wgs84"?t.tileIndex:Gi);return t.layerProperty&&(r.properties[t.layerProperty]=n),r}function ji(e,t,n){let r=e.toBinaryCoordinates(t.coordinates==="wgs84"?t.tileIndex:Hi);return t.layerProperty&&r.properties&&(r.properties[t.layerProperty]=n),r}function Gi(e,t){let{extent:n}=t;for(let r=0;r<e.length;r++){let i=e[r];i[0]/=n,i[1]/=n}}function Hi(e,t){let{extent:n}=t;for(let r=0,i=e.length;r<i;++r)e[r]/=n}var Ji="4.2.3",yn={dataType:null,batchType:null,name:"Mapbox Vector Tile",id:"mvt",module:"mvt",version:Ji,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}}},yt={...yn,parse:async(e,t)=>gt(e,t),parseSync:gt,binary:!0};var vn=e=>e!==null&&typeof e=="object";function mt(e,t){if(!e||!vn(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=mn(e.bounds)||mn(e.antimeridian_adjusted_bounds),n.center=Qi(e.center),n.maxZoom=xn(e.maxzoom),n.minZoom=xn(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 r=e.tilestats||n.metaJson?.tilestats,i=Ki(r,t),o=Wi(e.vector_layers),s=Yi(o,i);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 Wi(e){return Array.isArray(e)?e.map(t=>$i(t)):[]}function $i(e){let t=Object.entries(e.fields||[]).map(([r,i])=>({name:r,...Tn(String(i))})),n={...e};return delete n.fields,{name:e.id||"",...n,fields:t}}function Ki(e,t){return vn(e)&&Array.isArray(e.layers)?e.layers.map(n=>Xi(n,t)):[]}function Xi(e,t){let n=[],r={},i=e.attributes||[];for(let o of i){let s=o.attribute;if(typeof s=="string")if(s.split("|").length>1){let a=s.split("|")[0];r[a]=r[a]||[],r[a].push(o),console.warn("ignoring tilestats indexed field",a)}else n[s]||n.push(eo(o,t))}return{name:e.layer||"",dominantGeometry:e.geometry,fields:n}}function Yi(e,t){return e.map(n=>{let r=t.find(s=>s.name===n.name),i=r?.fields||[],o={...n};return delete o.fields,{...o,...r,fields:i}})}function mn(e){let t=In(e);if(Array.isArray(t)&&t.length===4&&[t[0],t[2]].every(Fn)&&[t[1],t[3]].every(Pn))return[[t[0],t[1]],[t[2],t[3]]]}function Qi(e){let t=In(e);return Array.isArray(t)&&t.length===3&&Fn(t[0])&&Pn(t[1])&&qi(t[2])?t:null}function xn(e){let t=typeof e=="string"?parseFloat(e):typeof e=="number"?e:null;return t===null||isNaN(t)?null:t}function Pn(e){return Number.isFinite(e)&&e<=90&&e>=-90}function Fn(e){return Number.isFinite(e)&&e<=180&&e>=-180}function qi(e){return Number.isFinite(e)&&e>=0&&e<=22}function In(e){return typeof e=="string"?e.split(",").map(parseFloat):Array.isArray(e)?e:null}var wn={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 eo(e={},t){let n=Tn(e.type),r={name:e.attribute,...n};return typeof e.min=="number"&&(r.min=e.min),typeof e.max=="number"&&(r.max=e.max),typeof e.count=="number"&&(r.uniqueValueCount=e.count),e.values&&(r.values=e.values),r.values&&typeof t.maxValues=="number"&&(r.values=r.values?.slice(0,t.maxValues)),r}function Tn(e){let t=e.toLowerCase();return!t||wn[t],wn[t]||{type:"string"}}var to="4.2.3",de={dataType:null,batchType:null,name:"TileJSON",id:"tilejson",module:"pmtiles",version:to,worker:!0,extensions:["json"],mimeTypes:["application/json"],text:!0,options:{tilejson:{maxValues:void 0}},parse:async(e,t)=>{let n=new TextDecoder().decode(e),r=JSON.parse(n),i={...de.options.tilejson,...t?.tilejson};return mt(r,i)},parseTextSync:(e,t)=>{let n=JSON.parse(e),r={...de.options.tilejson,...t?.tilejson};return mt(n,r)}};var me={};Mt(me,{Compression:()=>Zn,EtagMismatch:()=>Ne,FetchSource:()=>Gn,FileSource:()=>ko,PMTiles:()=>Ft,Protocol:()=>Bo,ResolvedValueCache:()=>Oo,SharedPromiseCache:()=>Kn,TileType:()=>Rn,bytesToHeader:()=>Hn,findTile:()=>jn,getUint64:()=>E,leafletRasterLayer:()=>bo,readVarint:()=>ee,tileIdToZxy:()=>Uo,zxyToTileId:()=>zn});var J=Math.pow,I=(e,t,n)=>new Promise((r,i)=>{var o=l=>{try{a(n.next(l))}catch(c){i(c)}},s=l=>{try{a(n.throw(l))}catch(c){i(c)}},a=l=>l.done?r(l.value):Promise.resolve(l.value).then(o,s);a((n=n.apply(e,t)).next())}),D=Uint8Array,te=Uint16Array,no=Int32Array,Vn=new D([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),bn=new D([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ro=new D([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),An=function(e,t){for(var n=new te(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new no(n[30]),r=1;r<30;++r)for(var o=n[r];o<n[r+1];++o)i[o]=o-n[r]<<5|r;return{b:n,r:i}},Bn=An(Vn,2),En=Bn.b,io=Bn.r;En[28]=258,io[258]=28;var _n=An(bn,0),oo=_n.b,Qa=_n.r,vt=new te(32768);for(w=0;w<32768;++w)Z=(w&43690)>>1|(w&21845)<<1,Z=(Z&52428)>>2|(Z&13107)<<2,Z=(Z&61680)>>4|(Z&3855)<<4,vt[w]=((Z&65280)>>8|(Z&255)<<8)>>1;var Z,w,ge=function(e,t,n){for(var r=e.length,i=0,o=new te(t);i<r;++i)e[i]&&++o[e[i]-1];var s=new te(t);for(i=1;i<t;++i)s[i]=s[i-1]+o[i-1]<<1;var a;if(n){a=new te(1<<t);var l=15-t;for(i=0;i<r;++i)if(e[i])for(var c=i<<4|e[i],f=t-e[i],u=s[e[i]-1]++<<f,h=u|(1<<f)-1;u<=h;++u)a[vt[u]>>l]=c}else for(a=new te(r),i=0;i<r;++i)e[i]&&(a[i]=vt[s[e[i]-1]++]>>15-e[i]);return a},ye=new D(288);for(w=0;w<144;++w)ye[w]=8;var w;for(w=144;w<256;++w)ye[w]=9;var w;for(w=256;w<280;++w)ye[w]=7;var w;for(w=280;w<288;++w)ye[w]=8;var w,Mn=new D(32);for(w=0;w<32;++w)Mn[w]=5;var w,so=ge(ye,9,1),ao=ge(Mn,5,1),xt=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},k=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},wt=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},lo=function(e){return(e+7)/8|0},co=function(e,t,n){(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length);var r=new D(n-t);return r.set(e.subarray(t,n)),r},fo=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],S=function(e,t,n){var r=new Error(t||fo[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,S),!n)throw r;return r},It=function(e,t,n,r){var i=e.length,o=r?r.length:0;if(!i||t.f&&!t.l)return n||new D(0);var s=!n||t.i!=2,a=t.i;n||(n=new D(i*3));var l=function(Bt){var Et=n.length;if(Bt>Et){var _t=new D(Math.max(Et*2,Bt));_t.set(n),n=_t}},c=t.f||0,f=t.p||0,u=t.b||0,h=t.l,d=t.d,p=t.m,m=t.n,F=i*8;do{if(!h){c=k(e,f,1);var _=k(e,f+1,3);if(f+=3,_)if(_==1)h=so,d=ao,p=9,m=5;else if(_==2){var V=k(e,f,31)+257,C=k(e,f+10,15)+4,M=V+k(e,f+5,31)+1;f+=14;for(var T=new D(M),b=new D(19),A=0;A<C;++A)b[ro[A]]=k(e,f+A*3,7);f+=C*3;for(var St=xt(b),Yn=(1<<St)-1,Qn=ge(b,St,1),A=0;A<M;){var Dt=Qn[k(e,f,Yn)];f+=Dt&15;var v=Dt>>4;if(v<16)T[A++]=v;else{var W=0,ve=0;for(v==16?(ve=3+k(e,f,3),f+=2,W=T[A-1]):v==17?(ve=3+k(e,f,7),f+=3):v==18&&(ve=11+k(e,f,127),f+=7);ve--;)T[A++]=W}}var Vt=T.subarray(0,V),U=T.subarray(V);p=xt(Vt),m=xt(U),h=ge(Vt,p,1),d=ge(U,m,1)}else S(1);else{var v=lo(f)+4,y=e[v-4]|e[v-3]<<8,g=v+y;if(g>i){a&&S(0);break}s&&l(u+y),n.set(e.subarray(v,g),u),t.b=u+=y,t.p=f=g*8,t.f=c;continue}if(f>F){a&&S(0);break}}s&&l(u+131072);for(var qn=(1<<p)-1,er=(1<<m)-1,Re=f;;Re=f){var W=h[wt(e,f)&qn],$=W>>4;if(f+=W&15,f>F){a&&S(0);break}if(W||S(2),$<256)n[u++]=$;else if($==256){Re=f,h=null;break}else{var bt=$-254;if($>264){var A=$-257,ne=Vn[A];bt=k(e,f,(1<<ne)-1)+En[A],f+=ne}var je=d[wt(e,f)&er],Ge=je>>4;je||S(3),f+=je&15;var U=oo[Ge];if(Ge>3){var ne=bn[Ge];U+=wt(e,f)&(1<<ne)-1,f+=ne}if(f>F){a&&S(0);break}s&&l(u+131072);var He=u+bt;if(u<U){var At=o-U,tr=Math.min(U,He);for(At+u<0&&S(3);u<tr;++u)n[u]=r[At+u]}for(;u<He;u+=4)n[u]=n[u-U],n[u+1]=n[u+1-U],n[u+2]=n[u+2-U],n[u+3]=n[u+3-U];u=He}}t.l=h,t.p=Re,t.b=u,t.f=c,h&&(c=1,t.m=p,t.d=d,t.n=m)}while(!c);return u==n.length?n:co(n,0,u)},uo=new D(0),ho=function(e){(e[0]!=31||e[1]!=139||e[2]!=8)&&S(6,"invalid gzip data");var t=e[3],n=10;t&4&&(n+=(e[10]|e[11]<<8)+2);for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[n++]);return n+(t&2)},po=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},go=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&S(6,"invalid zlib data"),(e[1]>>5&1)==+!t&&S(6,"invalid zlib data: "+(e[1]&32?"need":"unexpected")+" dictionary"),(e[1]>>3&4)+2};function yo(e,t){return It(e,{i:2},t&&t.out,t&&t.dictionary)}function mo(e,t){var n=ho(e);return n+8>e.length&&S(6,"invalid gzip data"),It(e.subarray(n,-8),{i:2},t&&t.out||new D(po(e)),t&&t.dictionary)}function xo(e,t){return It(e.subarray(go(e,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}function Pt(e,t){return e[0]==31&&e[1]==139&&e[2]==8?mo(e,t):(e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31?yo(e,t):xo(e,t)}var wo=typeof TextDecoder<"u"&&new TextDecoder,vo=0;try{wo.decode(uo,{stream:!0}),vo=1}catch{}var Un=(e,t)=>e*J(2,t),pe=(e,t)=>Math.floor(e/J(2,t)),Oe=(e,t)=>Un(e.getUint16(t+1,!0),8)+e.getUint8(t),Ln=(e,t)=>Un(e.getUint32(t+2,!0),16)+e.getUint16(t,!0),Po=(e,t,n,r,i)=>{if(e!==r.getUint8(i))return e-r.getUint8(i);let o=Oe(r,i+1);if(t!==o)return t-o;let s=Oe(r,i+4);return n!==s?n-s:0},Fo=(e,t,n,r)=>{let i=kn(e,t|128,n,r);return i?{z:t,x:n,y:r,offset:i[0],length:i[1],isDir:!0}:null},Sn=(e,t,n,r)=>{let i=kn(e,t,n,r);return i?{z:t,x:n,y:r,offset:i[0],length:i[1],isDir:!1}:null},kn=(e,t,n,r)=>{let i=0,o=e.byteLength/17-1;for(;i<=o;){let s=o+i>>1,a=Po(t,n,r,e,s*17);if(a>0)i=s+1;else if(a<0)o=s-1;else return[Ln(e,s*17+7),e.getUint32(s*17+13,!0)]}return null},Io=(e,t)=>e.isDir&&!t.isDir?1:!e.isDir&&t.isDir?-1:e.z!==t.z?e.z-t.z:e.x!==t.x?e.x-t.x:e.y-t.y,Cn=(e,t)=>{let n=e.getUint8(t*17);return{z:n&127,x:Oe(e,t*17+1),y:Oe(e,t*17+4),offset:Ln(e,t*17+7),length:e.getUint32(t*17+13,!0),isDir:n>>7===1}},Dn=e=>{let t=[],n=new DataView(e);for(let r=0;r<n.byteLength/17;r++)t.push(Cn(n,r));return To(t)},To=e=>{e.sort(Io);let t=new ArrayBuffer(17*e.length),n=new Uint8Array(t);for(let r=0;r<e.length;r++){let i=e[r],o=i.z;i.isDir&&(o=o|128),n[r*17]=o,n[r*17+1]=i.x&255,n[r*17+2]=i.x>>8&255,n[r*17+3]=i.x>>16&255,n[r*17+4]=i.y&255,n[r*17+5]=i.y>>8&255,n[r*17+6]=i.y>>16&255,n[r*17+7]=i.offset&255,n[r*17+8]=pe(i.offset,8)&255,n[r*17+9]=pe(i.offset,16)&255,n[r*17+10]=pe(i.offset,24)&255,n[r*17+11]=pe(i.offset,32)&255,n[r*17+12]=pe(i.offset,48)&255,n[r*17+13]=i.length&255,n[r*17+14]=i.length>>8&255,n[r*17+15]=i.length>>16&255,n[r*17+16]=i.length>>24&255}return t},So=(e,t)=>{if(e.byteLength<17)return null;let n=e.byteLength/17,r=Cn(e,n-1);if(r.isDir){let i=r.z,o=t.z-i,s=Math.trunc(t.x/(1<<o)),a=Math.trunc(t.y/(1<<o));return{z:i,x:s,y:a}}return null};function Do(e){return I(this,null,function*(){let t=yield e.getBytes(0,512e3),n=new DataView(t.data),r=n.getUint32(4,!0),i=n.getUint16(8,!0),o=new TextDecoder("utf-8"),s=JSON.parse(o.decode(new DataView(t.data,10,r))),a=0;s.compression==="gzip"&&(a=2);let l=0;"minzoom"in s&&(l=+s.minzoom);let c=0;"maxzoom"in s&&(c=+s.maxzoom);let f=0,u=0,h=0,d=-180,p=-85,m=180,F=85;if(s.bounds){let v=s.bounds.split(",");d=+v[0],p=+v[1],m=+v[2],F=+v[3]}if(s.center){let v=s.center.split(",");f=+v[0],u=+v[1],h=+v[2]}return{specVersion:n.getUint16(2,!0),rootDirectoryOffset:10+r,rootDirectoryLength:i*17,jsonMetadataOffset:10,jsonMetadataLength:r,leafDirectoryOffset:0,leafDirectoryLength:void 0,tileDataOffset:0,tileDataLength:void 0,numAddressedTiles:0,numTileEntries:0,numTileContents:0,clustered:!1,internalCompression:1,tileCompression:a,tileType:1,minZoom:l,maxZoom:c,minLon:d,minLat:p,maxLon:m,maxLat:F,centerZoom:h,centerLon:f,centerLat:u,etag:t.etag}})}function Vo(e,t,n,r,i,o,s){return I(this,null,function*(){let a=yield n.getArrayBuffer(t,e.rootDirectoryOffset,e.rootDirectoryLength,e);e.specVersion===1&&(a=Dn(a));let l=Sn(new DataView(a),r,i,o);if(l){let u=(yield t.getBytes(l.offset,l.length,s)).data,h=new DataView(u);return h.getUint8(0)===31&&h.getUint8(1)===139&&(u=Pt(new Uint8Array(u))),{data:u}}let c=So(new DataView(a),{z:r,x:i,y:o});if(c){let f=Fo(new DataView(a),c.z,c.x,c.y);if(f){let u=yield n.getArrayBuffer(t,f.offset,f.length,e);e.specVersion===1&&(u=Dn(u));let h=Sn(new DataView(u),r,i,o);if(h){let p=(yield t.getBytes(h.offset,h.length,s)).data,m=new DataView(p);return m.getUint8(0)===31&&m.getUint8(1)===139&&(p=Pt(new Uint8Array(p))),{data:p}}}}})}var On={getHeader:Do,getZxy:Vo},bo=(e,t)=>{let n=!1,r="",i=L.GridLayer.extend({createTile:(o,s)=>{let a=document.createElement("img"),l=new AbortController,c=l.signal;return a.cancel=()=>{l.abort()},n||(e.getHeader().then(f=>{f.tileType===1?console.error("Error: archive contains MVT vector tiles, but leafletRasterLayer is for displaying raster tiles. See https://github.com/protomaps/PMTiles/tree/main/js for details."):f.tileType===2?r="image/png":f.tileType===3?r="image/jpeg":f.tileType===4?r="image/webp":f.tileType===5&&(r="image/avif")}),n=!0),e.getZxy(o.z,o.x,o.y,c).then(f=>{if(f){let u=new Blob([f.data],{type:r}),h=window.URL.createObjectURL(u);a.src=h,a.cancel=void 0,s(void 0,a)}}).catch(f=>{if(f.name!=="AbortError")throw f}),a},_removeTile:function(o){let s=this._tiles[o];s&&(s.el.cancel&&s.el.cancel(),s.el.width=0,s.el.height=0,s.el.deleted=!0,L.DomUtil.remove(s.el),delete this._tiles[o],this.fire("tileunload",{tile:s.el,coords:this._keyToTileCoords(o)}))}});return new i(t)},Ao=e=>(t,n)=>{if(n instanceof AbortController)return e(t,n);let r=new AbortController;return e(t,r).then(i=>n(void 0,i.data,i.cacheControl||"",i.expires||""),i=>n(i)).catch(i=>n(i)),{cancel:()=>r.abort()}},Bo=class{constructor(){this.tilev4=(e,t)=>I(this,null,function*(){if(e.type==="json"){let u=e.url.substr(10),h=this.tiles.get(u);h||(h=new Ft(u),this.tiles.set(u,h));let d=yield h.getHeader();return{data:{tiles:[`${e.url}/{z}/{x}/{y}`],minzoom:d.minZoom,maxzoom:d.maxZoom,bounds:[d.minLon,d.minLat,d.maxLon,d.maxLat]}}}let n=new RegExp(/pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)/),r=e.url.match(n);if(!r)throw new Error("Invalid PMTiles protocol URL");let i=r[1],o=this.tiles.get(i);o||(o=new Ft(i),this.tiles.set(i,o));let s=r[2],a=r[3],l=r[4],c=yield o.getHeader(),f=yield o?.getZxy(+s,+a,+l,t.signal);return f?{data:new Uint8Array(f.data),cacheControl:f.cacheControl,expires:f.expires}:c.tileType===1?{data:new Uint8Array}:{data:null}}),this.tile=Ao(this.tilev4),this.tiles=new Map}add(e){this.tiles.set(e.source.getKey(),e)}get(e){return this.tiles.get(e)}};function q(e,t){return(t>>>0)*4294967296+(e>>>0)}function Eo(e,t){let n=t.buf,r=n[t.pos++],i=(r&112)>>4;if(r<128||(r=n[t.pos++],i|=(r&127)<<3,r<128)||(r=n[t.pos++],i|=(r&127)<<10,r<128)||(r=n[t.pos++],i|=(r&127)<<17,r<128)||(r=n[t.pos++],i|=(r&127)<<24,r<128)||(r=n[t.pos++],i|=(r&1)<<31,r<128))return q(e,i);throw new Error("Expected varint not more than 10 bytes")}function ee(e){let t=e.buf,n=t[e.pos++],r=n&127;return n<128||(n=t[e.pos++],r|=(n&127)<<7,n<128)||(n=t[e.pos++],r|=(n&127)<<14,n<128)||(n=t[e.pos++],r|=(n&127)<<21,n<128)?r:(n=t[e.pos],r|=(n&15)<<28,Eo(r,e))}function Nn(e,t,n,r){if(r===0){n===1&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);let i=t[0];t[0]=t[1],t[1]=i}}function _o(e,t){let n=J(2,e),r=t,i=t,o=t,s=[0,0],a=1;for(;a<n;)r=1&o/2,i=1&(o^r),Nn(a,s,r,i),s[0]+=a*r,s[1]+=a*i,o=o/4,a*=2;return[e,s[0],s[1]]}var Mo=[0,1,5,21,85,341,1365,5461,21845,87381,349525,1398101,5592405,22369621,89478485,357913941,1431655765,5726623061,22906492245,91625968981,366503875925,1466015503701,5864062014805,23456248059221,93824992236885,375299968947541,0x5555555555555];function zn(e,t,n){if(e>26)throw Error("Tile zoom level exceeds max safe number limit (26)");if(t>J(2,e)-1||n>J(2,e)-1)throw Error("tile x/y outside zoom level bounds");let r=Mo[e],i=J(2,e),o=0,s=0,a=0,l=[t,n],c=i/2;for(;c>0;)o=(l[0]&c)>0?1:0,s=(l[1]&c)>0?1:0,a+=c*c*(3*o^s),Nn(c,l,o,s),c=c/2;return r+a}function Uo(e){let t=0,n=0;for(let r=0;r<27;r++){let i=(1<<r)*(1<<r);if(t+i>e)return _o(r,e-t);t+=i}throw Error("Tile zoom level exceeds max safe number limit (26)")}var Zn=(e=>(e[e.Unknown=0]="Unknown",e[e.None=1]="None",e[e.Gzip=2]="Gzip",e[e.Brotli=3]="Brotli",e[e.Zstd=4]="Zstd",e))(Zn||{});function Tt(e,t){return I(this,null,function*(){if(t===1||t===0)return e;if(t===2){if(typeof globalThis.DecompressionStream>"u")return Pt(new Uint8Array(e));let n=new Response(e).body;if(!n)throw Error("Failed to read response stream");let r=n.pipeThrough(new globalThis.DecompressionStream("gzip"));return new Response(r).arrayBuffer()}throw Error("Compression method not supported")})}var Rn=(e=>(e[e.Unknown=0]="Unknown",e[e.Mvt=1]="Mvt",e[e.Png=2]="Png",e[e.Jpeg=3]="Jpeg",e[e.Webp=4]="Webp",e[e.Avif=5]="Avif",e))(Rn||{}),Lo=127;function jn(e,t){let n=0,r=e.length-1;for(;n<=r;){let i=r+n>>1,o=t-e[i].tileId;if(o>0)n=i+1;else if(o<0)r=i-1;else return e[i]}return r>=0&&(e[r].runLength===0||t-e[r].tileId<e[r].runLength)?e[r]:null}var ko=class{constructor(e){this.file=e}getKey(){return this.file.name}getBytes(e,t){return I(this,null,function*(){return{data:yield this.file.slice(e,e+t).arrayBuffer()}})}},Gn=class{constructor(e,t=new Headers){this.url=e,this.customHeaders=t,this.mustReload=!1}getKey(){return this.url}setHeaders(e){this.customHeaders=e}getBytes(e,t,n,r){return I(this,null,function*(){let i,o;n?o=n:(i=new AbortController,o=i.signal);let s=new Headers(this.customHeaders);s.set("range",`bytes=${e}-${e+t-1}`);let a;this.mustReload&&(a="reload");let l=yield fetch(this.url,{signal:o,cache:a,headers:s});if(e===0&&l.status===416){let h=l.headers.get("Content-Range");if(!h||!h.startsWith("bytes */"))throw Error("Missing content-length on 416 response");let d=+h.substr(8);l=yield fetch(this.url,{signal:o,cache:"reload",headers:{range:`bytes=0-${d-1}`}})}let c=l.headers.get("Etag");if(c?.startsWith("W/")&&(c=null),l.status===416||r&&c&&c!==r)throw this.mustReload=!0,new Ne(r);if(l.status>=300)throw Error(`Bad response code: ${l.status}`);let f=l.headers.get("Content-Length");if(l.status===200&&(!f||+f>t))throw i&&i.abort(),Error("Server returned no content-length header or content-length exceeding request. Check that your storage backend supports HTTP Byte Serving.");return{data:yield l.arrayBuffer(),etag:c||void 0,cacheControl:l.headers.get("Cache-Control")||void 0,expires:l.headers.get("Expires")||void 0}})}};function E(e,t){let n=e.getUint32(t+4,!0),r=e.getUint32(t+0,!0);return n*J(2,32)+r}function Hn(e,t){let n=new DataView(e),r=n.getUint8(7);if(r>3)throw Error(`Archive is spec version ${r} but this library supports up to spec version 3`);return{specVersion:r,rootDirectoryOffset:E(n,8),rootDirectoryLength:E(n,16),jsonMetadataOffset:E(n,24),jsonMetadataLength:E(n,32),leafDirectoryOffset:E(n,40),leafDirectoryLength:E(n,48),tileDataOffset:E(n,56),tileDataLength:E(n,64),numAddressedTiles:E(n,72),numTileEntries:E(n,80),numTileContents:E(n,88),clustered:n.getUint8(96)===1,internalCompression:n.getUint8(97),tileCompression:n.getUint8(98),tileType:n.getUint8(99),minZoom:n.getUint8(100),maxZoom:n.getUint8(101),minLon:n.getInt32(102,!0)/1e7,minLat:n.getInt32(106,!0)/1e7,maxLon:n.getInt32(110,!0)/1e7,maxLat:n.getInt32(114,!0)/1e7,centerZoom:n.getUint8(118),centerLon:n.getInt32(119,!0)/1e7,centerLat:n.getInt32(123,!0)/1e7,etag:t}}function Jn(e){let t={buf:new Uint8Array(e),pos:0},n=ee(t),r=[],i=0;for(let o=0;o<n;o++){let s=ee(t);r.push({tileId:i+s,offset:0,length:0,runLength:1}),i+=s}for(let o=0;o<n;o++)r[o].runLength=ee(t);for(let o=0;o<n;o++)r[o].length=ee(t);for(let o=0;o<n;o++){let s=ee(t);s===0&&o>0?r[o].offset=r[o-1].offset+r[o-1].length:r[o].offset=s-1}return r}function Co(e){let t=new DataView(e);return t.getUint16(2,!0)===2?(console.warn("PMTiles spec version 2 has been deprecated; please see github.com/protomaps/PMTiles for tools to upgrade"),2):t.getUint16(2,!0)===1?(console.warn("PMTiles spec version 1 has been deprecated; please see github.com/protomaps/PMTiles for tools to upgrade"),1):3}var Ne=class extends Error{};function Wn(e,t){return I(this,null,function*(){let n=yield e.getBytes(0,16384);if(new DataView(n.data).getUint16(0,!0)!==19792)throw new Error("Wrong magic number for PMTiles archive");if(Co(n.data)<3)return[yield On.getHeader(e)];let i=n.data.slice(0,Lo),o=Hn(i,n.etag),s=n.data.slice(o.rootDirectoryOffset,o.rootDirectoryOffset+o.rootDirectoryLength),a=`${e.getKey()}|${o.etag||""}|${o.rootDirectoryOffset}|${o.rootDirectoryLength}`,l=Jn(yield t(s,o.internalCompression));return[o,[a,l.length,l]]})}function $n(e,t,n,r,i){return I(this,null,function*(){let o=yield e.getBytes(n,r,void 0,i.etag),s=yield t(o.data,i.internalCompression),a=Jn(s);if(a.length===0)throw new Error("Empty directory is invalid");return a})}var Oo=class{constructor(e=100,t=!0,n=Tt){this.cache=new Map,this.maxCacheEntries=e,this.counter=1,this.decompress=n}getHeader(e){return I(this,null,function*(){let t=e.getKey(),n=this.cache.get(t);if(n)return n.lastUsed=this.counter++,n.data;let r=yield Wn(e,this.decompress);return r[1]&&this.cache.set(r[1][0],{lastUsed:this.counter++,data:r[1][2]}),this.cache.set(t,{lastUsed:this.counter++,data:r[0]}),this.prune(),r[0]})}getDirectory(e,t,n,r){return I(this,null,function*(){let i=`${e.getKey()}|${r.etag||""}|${t}|${n}`,o=this.cache.get(i);if(o)return o.lastUsed=this.counter++,o.data;let s=yield $n(e,this.decompress,t,n,r);return this.cache.set(i,{lastUsed:this.counter++,data:s}),this.prune(),s})}getArrayBuffer(e,t,n,r){return I(this,null,function*(){let i=`${e.getKey()}|${r.etag||""}|${t}|${n}`,o=this.cache.get(i);if(o)return o.lastUsed=this.counter++,yield o.data;let s=yield e.getBytes(t,n,void 0,r.etag);return this.cache.set(i,{lastUsed:this.counter++,data:s.data}),this.prune(),s.data})}prune(){if(this.cache.size>this.maxCacheEntries){let e=1/0,t;this.cache.forEach((n,r)=>{n.lastUsed<e&&(e=n.lastUsed,t=r)}),t&&this.cache.delete(t)}}invalidate(e){return I(this,null,function*(){this.cache.delete(e.getKey())})}},Kn=class{constructor(e=100,t=!0,n=Tt){this.cache=new Map,this.invalidations=new Map,this.maxCacheEntries=e,this.counter=1,this.decompress=n}getHeader(e){return I(this,null,function*(){let t=e.getKey(),n=this.cache.get(t);if(n)return n.lastUsed=this.counter++,yield n.data;let r=new Promise((i,o)=>{Wn(e,this.decompress).then(s=>{s[1]&&this.cache.set(s[1][0],{lastUsed:this.counter++,data:Promise.resolve(s[1][2])}),i(s[0]),this.prune()}).catch(s=>{o(s)})});return this.cache.set(t,{lastUsed:this.counter++,data:r}),r})}getDirectory(e,t,n,r){return I(this,null,function*(){let i=`${e.getKey()}|${r.etag||""}|${t}|${n}`,o=this.cache.get(i);if(o)return o.lastUsed=this.counter++,yield o.data;let s=new Promise((a,l)=>{$n(e,this.decompress,t,n,r).then(c=>{a(c),this.prune()}).catch(c=>{l(c)})});return this.cache.set(i,{lastUsed:this.counter++,data:s}),s})}getArrayBuffer(e,t,n,r){return I(this,null,function*(){let i=`${e.getKey()}|${r.etag||""}|${t}|${n}`,o=this.cache.get(i);if(o)return o.lastUsed=this.counter++,yield o.data;let s=new Promise((a,l)=>{e.getBytes(t,n,void 0,r.etag).then(c=>{a(c.data),this.cache.has(i),this.prune()}).catch(c=>{l(c)})});return this.cache.set(i,{lastUsed:this.counter++,data:s}),s})}prune(){if(this.cache.size>=this.maxCacheEntries){let e=1/0,t;this.cache.forEach((n,r)=>{n.lastUsed<e&&(e=n.lastUsed,t=r)}),t&&this.cache.delete(t)}}invalidate(e){return I(this,null,function*(){let t=e.getKey();if(this.invalidations.get(t))return yield this.invalidations.get(t);this.cache.delete(e.getKey());let n=new Promise((r,i)=>{this.getHeader(e).then(o=>{r(),this.invalidations.delete(t)}).catch(o=>{i(o)})});this.invalidations.set(t,n)})}},Ft=class{constructor(e,t,n){typeof e=="string"?this.source=new Gn(e):this.source=e,n?this.decompress=n:this.decompress=Tt,t?this.cache=t:this.cache=new Kn}getHeader(){return I(this,null,function*(){return yield this.cache.getHeader(this.source)})}getZxyAttempt(e,t,n,r){return I(this,null,function*(){let i=zn(e,t,n),o=yield this.cache.getHeader(this.source);if(o.specVersion<3)return On.getZxy(o,this.source,this.cache,e,t,n,r);if(e<o.minZoom||e>o.maxZoom)return;let s=o.rootDirectoryOffset,a=o.rootDirectoryLength;for(let l=0;l<=3;l++){let c=yield this.cache.getDirectory(this.source,s,a,o),f=jn(c,i);if(f){if(f.runLength>0){let u=yield this.source.getBytes(o.tileDataOffset+f.offset,f.length,r,o.etag);return{data:yield this.decompress(u.data,o.tileCompression),cacheControl:u.cacheControl,expires:u.expires}}s=o.leafDirectoryOffset+f.offset,a=f.length}else return}throw Error("Maximum directory depth exceeded")})}getZxy(e,t,n,r){return I(this,null,function*(){try{return yield this.getZxyAttempt(e,t,n,r)}catch(i){if(i instanceof Ne)return this.cache.invalidate(this.source),yield this.getZxyAttempt(e,t,n,r);throw i}})}getMetadataAttempt(){return I(this,null,function*(){let e=yield this.cache.getHeader(this.source),t=yield this.source.getBytes(e.jsonMetadataOffset,e.jsonMetadataLength,void 0,e.etag),n=yield this.decompress(t.data,e.internalCompression),r=new TextDecoder("utf-8");return JSON.parse(r.decode(n))})}getMetadata(){return I(this,null,function*(){try{return yield this.getMetadataAttempt()}catch(e){if(e instanceof Ne)return this.cache.invalidate(this.source),yield this.getMetadataAttempt();throw e}})}};var{TileType:xe}=me;function Xn(e,t,n,r){let i=t,o=null;if(i)try{let l=JSON.stringify(i);o=de.parseTextSync?.(l,r)||null}catch(l){console.warn("PMTiles metadata could not be interpreted as TileJSON",l)}let s={};typeof o?.name=="string"&&(s.name=o.name),typeof o?.htmlAttribution=="string"&&(s.attributions=[o.htmlAttribution]);let a={...s,format:"pmtiles",formatVersion:e.specVersion,attributions:[],tileMIMEType:No(e.tileType),minZoom:e.minZoom,maxZoom:e.maxZoom,boundingBox:[[e.minLon,e.minLat],[e.maxLon,e.maxLat]],center:[e.centerLon,e.centerLat],centerZoom:e.centerZoom,etag:e.etag};return o&&(a.tilejson=o),n?.includeFormatHeader&&(a.formatHeader=e,a.formatMetadata=a),a}function No(e){switch(e){case xe.Mvt:return"application/vnd.mapbox-vector-tile";case xe.Png:return"image/png";case xe.Jpeg:return"image/jpeg";case xe.Webp:return"image/webp";case xe.Avif:return"image/avif";default:return"application/octet-stream"}}var ze=class{blob;key;constructor(t,n){this.blob=t,this.key=n}getKey(){return this.blob.url||""}async getBytes(t,n,r){return{data:await this.blob.slice(t,t+n).arrayBuffer()}}};var{PMTiles:zo}=me;var Ze=class extends ie{data;props;mimeType=null;pmtiles;metadata;constructor(t){super(t),this.props=t;let n=typeof t.url=="string"?Xe(t.url):new ze(t.url,"pmtiles");this.data=t.url,this.pmtiles=new zo(n),this.getTileData=this.getTileData.bind(this),this.metadata=this.getMetadata()}async getMetadata(){let t=await this.pmtiles.getHeader(),n=await this.pmtiles.getMetadata(),r=Xn(t,n,{includeFormatHeader:!1},this.loadOptions);return this.props.attributions&&(r.attributions=[...this.props.attributions,...r.attributions||[]]),r?.tileMIMEType&&(this.mimeType=r?.tileMIMEType),r}async getTile(t){let{x:n,y:r,zoom:i}=t,s=(await this.pmtiles.getZxy(i,n,r))?.data;return s||null}async getTileData(t){let{x:n,y:r,z:i}=t.index;switch((await this.metadata).tileMIMEType){case"application/vnd.mapbox-vector-tile":return await this.getVectorTile({x:n,y:r,zoom:i,layers:[]});default:return await this.getImageTile({x:n,y:r,zoom:i,layers:[]})}}async getImageTile(t){let n=await this.getTile(t);return n?await tt.parse(n,this.loadOptions):null}async getVectorTile(t){let n=await this.getTile(t),r={shape:"geojson-table",mvt:{coordinates:"wgs84",tileIndex:{x:t.x,y:t.y,z:t.zoom},...this.loadOptions?.mvt},...this.loadOptions};return n?await yt.parse(n,r):null}};return ar(we);})();
|
|
7
|
+
"use strict";var __exports__=(()=>{var nr=Object.create;var Fe=Object.defineProperty;var rr=Object.getOwnPropertyDescriptor;var ir=Object.getOwnPropertyNames;var or=Object.getPrototypeOf,sr=Object.prototype.hasOwnProperty;var Je=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Mt=(e,t)=>{for(var n in t)Fe(e,n,{get:t[n],enumerable:!0})},Pe=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ir(t))!sr.call(e,i)&&i!==n&&Fe(e,i,{get:()=>t[i],enumerable:!(r=rr(t,i))||r.enumerable});return e},Ie=(e,t,n)=>(Pe(e,t,"default"),n&&Pe(n,t,"default")),Ut=(e,t,n)=>(n=e!=null?nr(or(e)):{},Pe(t||!e||!e.__esModule?Fe(n,"default",{value:e,enumerable:!0}):n,e)),ar=e=>Pe(Fe({},"__esModule",{value:!0}),e);var kt=Je((Ro,Lt)=>{Lt.exports=globalThis.loaders});var tn=Je(lt=>{lt.read=function(e,t,n,r,i){var o,s,a=i*8-r-1,l=(1<<a)-1,c=l>>1,f=-7,u=n?i-1:0,h=n?-1:1,d=e[t+u];for(u+=h,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=o*256+e[t+u],u+=h,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=r;f>0;s=s*256+e[t+u],u+=h,f-=8);if(o===0)o=1-c;else{if(o===l)return s?NaN:(d?-1:1)*(1/0);s=s+Math.pow(2,r),o=o-c}return(d?-1:1)*s*Math.pow(2,o-r)};lt.write=function(e,t,n,r,i,o){var s,a,l,c=o*8-i-1,f=(1<<c)-1,u=f>>1,h=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,p=r?1:-1,m=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=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),s+u>=1?t+=h/l:t+=h*Math.pow(2,1-u),t*l>=2&&(s++,l/=2),s+u>=f?(a=0,s=f):s+u>=1?(a=(t*l-1)*Math.pow(2,i),s=s+u):(a=t*Math.pow(2,u-1)*Math.pow(2,i),s=0));i>=8;e[n+d]=a&255,d+=p,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;e[n+d]=s&255,d+=p,s/=256,c-=8);e[n+d-p]|=m*128}});var ln=Je((Ta,an)=>{"use strict";an.exports=x;var Be=tn();function x(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}x.Varint=0;x.Fixed64=1;x.Bytes=2;x.Fixed32=5;var ct=(1<<16)*(1<<16),nn=1/ct,pi=12,sn=typeof TextDecoder>"u"?null:new TextDecoder("utf8");x.prototype={destroy:function(){this.buf=null},readFields:function(e,t,n){for(n=n||this.length;this.pos<n;){var r=this.readVarint(),i=r>>3,o=this.pos;this.type=r&7,e(i,t,this),this.pos===o&&this.skip(r)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=Ee(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=on(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=Ee(this.buf,this.pos)+Ee(this.buf,this.pos+4)*ct;return this.pos+=8,e},readSFixed64:function(){var e=Ee(this.buf,this.pos)+on(this.buf,this.pos+4)*ct;return this.pos+=8,e},readFloat:function(){var e=Be.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=Be.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t=this.buf,n,r;return r=t[this.pos++],n=r&127,r<128||(r=t[this.pos++],n|=(r&127)<<7,r<128)||(r=t[this.pos++],n|=(r&127)<<14,r<128)||(r=t[this.pos++],n|=(r&127)<<21,r<128)?n:(r=t[this.pos],n|=(r&15)<<28,gi(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>=pi&&sn?Ai(this.buf,t,e):bi(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!==x.Bytes)return e.push(this.readVarint(t));var n=z(this);for(e=e||[];this.pos<n;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==x.Bytes)return e.push(this.readSVarint());var t=z(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){if(this.type!==x.Bytes)return e.push(this.readBoolean());var t=z(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){if(this.type!==x.Bytes)return e.push(this.readFloat());var t=z(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){if(this.type!==x.Bytes)return e.push(this.readDouble());var t=z(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){if(this.type!==x.Bytes)return e.push(this.readFixed32());var t=z(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){if(this.type!==x.Bytes)return e.push(this.readSFixed32());var t=z(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){if(this.type!==x.Bytes)return e.push(this.readFixed64());var t=z(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){if(this.type!==x.Bytes)return e.push(this.readSFixed64());var t=z(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var t=e&7;if(t===x.Varint)for(;this.buf[this.pos++]>127;);else if(t===x.Bytes)this.pos=this.readVarint()+this.pos;else if(t===x.Fixed32)this.pos+=4;else if(t===x.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),Y(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),Y(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),Y(this.buf,e&-1,this.pos),Y(this.buf,Math.floor(e*nn),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),Y(this.buf,e&-1,this.pos),Y(this.buf,Math.floor(e*nn),this.pos+4),this.pos+=8},writeVarint:function(e){if(e=+e||0,e>268435455||e<0){yi(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=Bi(this.buf,e,this.pos);var n=this.pos-t;n>=128&&rn(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n},writeFloat:function(e){this.realloc(4),Be.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),Be.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 r=this.pos-n;r>=128&&rn(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r},writeMessage:function(e,t,n){this.writeTag(e,x.Bytes),this.writeRawMessage(t,n)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,wi,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,vi,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,Ii,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,Pi,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,Fi,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,Ti,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,Si,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,Di,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,Vi,t)},writeBytesField:function(e,t){this.writeTag(e,x.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,x.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,x.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,x.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,x.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,x.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,x.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,x.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,x.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,x.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};function gi(e,t,n){var r=n.buf,i,o;if(o=r[n.pos++],i=(o&112)>>4,o<128||(o=r[n.pos++],i|=(o&127)<<3,o<128)||(o=r[n.pos++],i|=(o&127)<<10,o<128)||(o=r[n.pos++],i|=(o&127)<<17,o<128)||(o=r[n.pos++],i|=(o&127)<<24,o<128)||(o=r[n.pos++],i|=(o&1)<<31,o<128))return X(e,i,t);throw new Error("Expected varint not more than 10 bytes")}function z(e){return e.type===x.Bytes?e.readVarint()+e.pos:e.pos+1}function X(e,t,n){return n?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function yi(e,t){var n,r;if(e>=0?(n=e%4294967296|0,r=e/4294967296|0):(n=~(-e%4294967296),r=~(-e/4294967296),n^4294967295?n=n+1|0:(n=0,r=r+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),mi(n,r,t),xi(r,t)}function mi(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 xi(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 rn(e,t,n){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(Math.LN2*7));n.realloc(r);for(var i=n.pos-1;i>=e;i--)n.buf[i+r]=n.buf[i]}function wi(e,t){for(var n=0;n<e.length;n++)t.writeVarint(e[n])}function vi(e,t){for(var n=0;n<e.length;n++)t.writeSVarint(e[n])}function Pi(e,t){for(var n=0;n<e.length;n++)t.writeFloat(e[n])}function Fi(e,t){for(var n=0;n<e.length;n++)t.writeDouble(e[n])}function Ii(e,t){for(var n=0;n<e.length;n++)t.writeBoolean(e[n])}function Ti(e,t){for(var n=0;n<e.length;n++)t.writeFixed32(e[n])}function Si(e,t){for(var n=0;n<e.length;n++)t.writeSFixed32(e[n])}function Di(e,t){for(var n=0;n<e.length;n++)t.writeFixed64(e[n])}function Vi(e,t){for(var n=0;n<e.length;n++)t.writeSFixed64(e[n])}function Ee(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+e[t+3]*16777216}function Y(e,t,n){e[n]=t,e[n+1]=t>>>8,e[n+2]=t>>>16,e[n+3]=t>>>24}function on(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}function bi(e,t,n){for(var r="",i=t;i<n;){var o=e[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a>n)break;var l,c,f;a===1?o<128&&(s=o):a===2?(l=e[i+1],(l&192)===128&&(s=(o&31)<<6|l&63,s<=127&&(s=null))):a===3?(l=e[i+1],c=e[i+2],(l&192)===128&&(c&192)===128&&(s=(o&15)<<12|(l&63)<<6|c&63,(s<=2047||s>=55296&&s<=57343)&&(s=null))):a===4&&(l=e[i+1],c=e[i+2],f=e[i+3],(l&192)===128&&(c&192)===128&&(f&192)===128&&(s=(o&15)<<18|(l&63)<<12|(c&63)<<6|f&63,(s<=65535||s>=1114112)&&(s=null))),s===null?(s=65533,a=1):s>65535&&(s-=65536,r+=String.fromCharCode(s>>>10&1023|55296),s=56320|s&1023),r+=String.fromCharCode(s),i+=a}return r}function Ai(e,t,n){return sn.decode(e.subarray(t,n))}function Bi(e,t,n){for(var r=0,i,o;r<t.length;r++){if(i=t.charCodeAt(r),i>55295&&i<57344)if(o)if(i<56320){e[n++]=239,e[n++]=191,e[n++]=189,o=i;continue}else i=o-55296<<10|i-56320|65536,o=null;else{i>56319||r+1===t.length?(e[n++]=239,e[n++]=191,e[n++]=189):o=i;continue}else o&&(e[n++]=239,e[n++]=191,e[n++]=189,o=null);i<128?e[n++]=i:(i<2048?e[n++]=i>>6|192:(i<65536?e[n++]=i>>12|224:(e[n++]=i>>18|240,e[n++]=i>>12&63|128),e[n++]=i>>6&63|128),e[n++]=i&63|128)}return n}});var we={};Mt(we,{PMTilesSource:()=>Ze});Ie(we,Ut(kt(),1));function re(e,t){if(!e)throw new Error(t||"loader assertion failed.")}var O={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},lr=O.self||O.window||O.global||{},cr=O.window||O.self||O.global||{},fr=O.global||O.self||O.window||{},ur=O.document||{};var We=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var Ct=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),hr=Ct&&parseFloat(Ct[1])||0;function R(e){return R=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},R(e)}function $e(e,t){if(R(e)!=="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(R(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ke(e){var t=$e(e,"string");return R(t)==="symbol"?t:String(t)}function B(e,t,n){return t=Ke(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var dr="",Ot={};function Xe(e){for(let t in Ot)if(e.startsWith(t)){let n=Ot[t];e=e.replace(t,n)}return!e.startsWith("http://")&&!e.startsWith("https://")&&(e=`${dr}${e}`),e}var ie=class{fetch;loadOptions;_needsRefresh=!0;props;constructor(t){this.props={...t},this.loadOptions={...t.loadOptions},this.fetch=pr(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 pr(e){let t=e?.fetch;if(t&&typeof t=="function")return(r,i)=>t(r,i);let n=e?.fetch;return n&&typeof n!="function"?r=>fetch(r,n):r=>fetch(r)}var Nt="4.2.4";var gr=globalThis.loaders?.parseImageNode,Ye=typeof Image<"u",Qe=typeof ImageBitmap<"u",yr=Boolean(gr),qe=We?!0:yr;function zt(e){switch(e){case"auto":return Qe||Ye||qe;case"imagebitmap":return Qe;case"image":return Ye;case"data":return qe;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}function Zt(){if(Qe)return"imagebitmap";if(Ye)return"image";if(qe)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function mr(e){let t=xr(e);if(!t)throw new Error("Not an image");return t}function Rt(e){switch(mr(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 xr(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 wr=/^data:image\/svg\+xml/,vr=/\.svg((\?|#).*)?$/;function Te(e){return e&&(wr.test(e)||vr.test(e))}function jt(e,t){if(Te(t)){let r=new TextDecoder().decode(e);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(r=unescape(encodeURIComponent(r)))}catch(o){throw new Error(o.message)}return`data:image/svg+xml;base64,${btoa(r)}`}return et(e,t)}function et(e,t){if(Te(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function Se(e,t,n){let r=jt(e,n),i=self.URL||self.webkitURL,o=typeof r!="string"&&i.createObjectURL(r);try{return await Pr(o||r,t)}finally{o&&i.revokeObjectURL(o)}}async function Pr(e,t){let n=new Image;return n.src=e,t.image&&t.image.decode&&n.decode?(await n.decode(),n):await new Promise((r,i)=>{try{n.onload=()=>r(n),n.onerror=o=>{let s=o instanceof Error?o.message:"error";i(new Error(s))}}catch(o){i(o)}})}var Fr={},Gt=!0;async function Ht(e,t,n){let r;Te(n)?r=await Se(e,t,n):r=et(e,n);let i=t&&t.imagebitmap;return await Ir(r,i)}async function Ir(e,t=null){if((Tr(t)||!Gt)&&(t=null),t)try{return await createImageBitmap(e,t)}catch(n){console.warn(n),Gt=!1}return await createImageBitmap(e)}function Tr(e){for(let t in e||Fr)return!1;return!0}function Jt(e){return!br(e,"ftyp",4)||!(e[8]&96)?null:Sr(e)}function Sr(e){switch(Dr(e,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function Dr(e,t,n){return String.fromCharCode(...e.slice(t,n))}function Vr(e){return[...e].map(t=>t.charCodeAt(0))}function br(e,t,n=0){let r=Vr(t);for(let i=0;i<r.length;++i)if(r[i]!==e[i+n])return!1;return!0}var N=!1,oe=!0;function De(e){let t=se(e);return Br(t)||Mr(t)||Er(t)||_r(t)||Ar(t)}function Ar(e){let t=new Uint8Array(e instanceof DataView?e.buffer:e),n=Jt(t);return n?{mimeType:n.mimeType,width:0,height:0}:null}function Br(e){let t=se(e);return t.byteLength>=24&&t.getUint32(0,N)===2303741511?{mimeType:"image/png",width:t.getUint32(16,N),height:t.getUint32(20,N)}:null}function Er(e){let t=se(e);return t.byteLength>=10&&t.getUint32(0,N)===1195984440?{mimeType:"image/gif",width:t.getUint16(6,oe),height:t.getUint16(8,oe)}:null}function _r(e){let t=se(e);return t.byteLength>=14&&t.getUint16(0,N)===16973&&t.getUint32(2,oe)===t.byteLength?{mimeType:"image/bmp",width:t.getUint32(18,oe),height:t.getUint32(22,oe)}:null}function Mr(e){let t=se(e);if(!(t.byteLength>=3&&t.getUint16(0,N)===65496&&t.getUint8(2)===255))return null;let{tableMarkers:r,sofMarkers:i}=Ur(),o=2;for(;o+9<t.byteLength;){let s=t.getUint16(o,N);if(i.has(s))return{mimeType:"image/jpeg",height:t.getUint16(o+5,N),width:t.getUint16(o+7,N)};if(!r.has(s))return null;o+=2,o+=t.getUint16(o,N)}return null}function Ur(){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 se(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 Wt(e,t){let{mimeType:n}=De(e)||{},r=globalThis.loaders?.parseImageNode;return re(r),await r(e,n)}async function $t(e,t,n){t=t||{};let i=(t.image||{}).type||"auto",{url:o}=n||{},s=Lr(i),a;switch(s){case"imagebitmap":a=await Ht(e,t,o);break;case"image":a=await Se(e,t,o);break;case"data":a=await Wt(e,t);break;default:re(!1)}return i==="data"&&(a=Rt(a)),a}function Lr(e){switch(e){case"auto":case"data":return Zt();default:return zt(e),e}}var kr=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],Cr=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],Or={image:{type:"auto",decode:!0}},tt={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:Nt,mimeTypes:Cr,extensions:kr,parse:$t,tests:[e=>Boolean(De(new DataView(e)))],options:Or};var ae={x:0,y:1,z:2};function j(e,t={}){let{start:n=0,end:r=e.length,plane:i="xy"}=t,o=t.size||2,s=0,a=ae[i[0]],l=ae[i[1]];for(let c=n,f=r-o;c<r;c+=o)s+=(e[c+a]-e[f+a])*(e[c+l]+e[f+l]),f=c;return s/2}function rt(e,t,n=2,r,i="xy"){let o=t&&t.length,s=o?t[0]*n:e.length,a=Xt(e,0,s,n,!0,r&&r[0],i),l=[];if(!a||a.next===a.prev)return l;let c,f,u,h,d,p,m;if(o&&(a=Hr(e,t,a,n,r,i)),e.length>80*n){h=f=e[0],d=u=e[1];for(let F=n;F<s;F+=n)p=e[F],m=e[F+1],p<h&&(h=p),m<d&&(d=m),p>f&&(f=p),m>u&&(u=m);c=Math.max(f-h,u-d),c=c!==0?32767/c:0}return le(a,l,n,h,d,c,0),l}function Xt(e,t,n,r,i,o,s){let a,l;o===void 0&&(o=j(e,{start:t,end:n,size:r,plane:s}));let c=ae[s[0]],f=ae[s[1]];if(i===o<0)for(a=t;a<n;a+=r)l=Kt(a,e[a+c],e[a+f],l);else for(a=n-r;a>=t;a-=r)l=Kt(a,e[a+c],e[a+f],l);return l&&Ae(l,l.next)&&(fe(l),l=l.next),l}function G(e,t){if(!e)return e;t||(t=e);let n=e,r;do if(r=!1,!n.steiner&&(Ae(n,n.next)||P(n.prev,n,n.next)===0)){if(fe(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function le(e,t,n,r,i,o,s){if(!e)return;!s&&o&&Xr(e,r,i,o);let a=e,l,c;for(;e.prev!==e.next;){if(l=e.prev,c=e.next,o?Rr(e,r,i,o):Zr(e)){t.push(l.i/n|0),t.push(e.i/n|0),t.push(c.i/n|0),fe(e),e=c.next,a=c.next;continue}if(e=c,e===a){s?s===1?(e=jr(G(e),t,n),le(e,t,n,r,i,o,2)):s===2&&Gr(e,t,n,r,i,o):le(G(e),t,n,r,i,o,1);break}}}function Zr(e){let t=e.prev,n=e,r=e.next;if(P(t,n,r)>=0)return!1;let i=t.x,o=n.x,s=r.x,a=t.y,l=n.y,c=r.y,f=i<o?i<s?i:s:o<s?o:s,u=a<l?a<c?a:c:l<c?l:c,h=i>o?i>s?i:s:o>s?o:s,d=a>l?a>c?a:c:l>c?l:c,p=r.next;for(;p!==t;){if(p.x>=f&&p.x<=h&&p.y>=u&&p.y<=d&&K(i,a,o,l,s,c,p.x,p.y)&&P(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Rr(e,t,n,r){let i=e.prev,o=e,s=e.next;if(P(i,o,s)>=0)return!1;let a=i.x,l=o.x,c=s.x,f=i.y,u=o.y,h=s.y,d=a<l?a<c?a:c:l<c?l:c,p=f<u?f<h?f:h:u<h?u:h,m=a>l?a>c?a:c:l>c?l:c,F=f>u?f>h?f:h:u>h?u:h,_=nt(d,p,t,n,r),v=nt(m,F,t,n,r),y=e.prevZ,g=e.nextZ;for(;y&&y.z>=_&&g&&g.z<=v;){if(y.x>=d&&y.x<=m&&y.y>=p&&y.y<=F&&y!==i&&y!==s&&K(a,f,l,u,c,h,y.x,y.y)&&P(y.prev,y,y.next)>=0||(y=y.prevZ,g.x>=d&&g.x<=m&&g.y>=p&&g.y<=F&&g!==i&&g!==s&&K(a,f,l,u,c,h,g.x,g.y)&&P(g.prev,g,g.next)>=0))return!1;g=g.nextZ}for(;y&&y.z>=_;){if(y.x>=d&&y.x<=m&&y.y>=p&&y.y<=F&&y!==i&&y!==s&&K(a,f,l,u,c,h,y.x,y.y)&&P(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;g&&g.z<=v;){if(g.x>=d&&g.x<=m&&g.y>=p&&g.y<=F&&g!==i&&g!==s&&K(a,f,l,u,c,h,g.x,g.y)&&P(g.prev,g,g.next)>=0)return!1;g=g.nextZ}return!0}function jr(e,t,n){let r=e;do{let i=r.prev,o=r.next.next;!Ae(i,o)&&Yt(i,r,r.next,o)&&ce(i,o)&&ce(o,i)&&(t.push(i.i/n|0),t.push(r.i/n|0),t.push(o.i/n|0),fe(r),fe(r.next),r=e=o),r=r.next}while(r!==e);return G(r)}function Gr(e,t,n,r,i,o){let s=e;do{let a=s.next.next;for(;a!==s.prev;){if(s.i!==a.i&&qr(s,a)){let l=Qt(s,a);s=G(s,s.next),l=G(l,l.next),le(s,t,n,r,i,o,0),le(l,t,n,r,i,o,0);return}a=a.next}s=s.next}while(s!==e)}function Hr(e,t,n,r,i,o){let s=[],a,l,c,f,u;for(a=0,l=t.length;a<l;a++)c=t[a]*r,f=a<l-1?t[a+1]*r:e.length,u=Xt(e,c,f,r,!1,i&&i[a+1],o),u===u.next&&(u.steiner=!0),s.push(Qr(u));for(s.sort(Jr),a=0;a<s.length;a++)n=Wr(s[a],n);return n}function Jr(e,t){return e.x-t.x}function Wr(e,t){let n=$r(e,t);if(!n)return t;let r=Qt(n,e);return G(r,r.next),G(n,n.next)}function $r(e,t){let n=t,r=e.x,i=e.y,o=-1/0,s;do{if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){let h=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(h<=r&&h>o&&(o=h,s=n.x<n.next.x?n:n.next,h===r))return s}n=n.next}while(n!==t);if(!s)return null;let a=s,l=s.x,c=s.y,f=1/0,u;n=s;do r>=n.x&&n.x>=l&&r!==n.x&&K(i<c?r:o,i,l,c,i<c?o:r,i,n.x,n.y)&&(u=Math.abs(i-n.y)/(r-n.x),ce(n,e)&&(u<f||u===f&&(n.x>s.x||n.x===s.x&&Kr(s,n)))&&(s=n,f=u)),n=n.next;while(n!==a);return s}function Kr(e,t){return P(e.prev,e,t.prev)<0&&P(t.next,e,e.next)<0}function Xr(e,t,n,r){let i=e;do i.z===0&&(i.z=nt(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,Yr(i)}function Yr(e){let t,n,r=1,i,o,s,a,l,c;do{for(o=e,e=null,c=null,i=0;o;){for(i++,a=o,s=0,n=0;n<r&&(s++,a=a.nextZ,!!a);n++);for(l=r;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--),c?c.nextZ=t:e=t,t.prevZ=c,c=t;o=a}c.nextZ=null,r*=2}while(i>1);return e}function nt(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|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 Qr(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 K(e,t,n,r,i,o,s,a){return(i-s)*(t-a)>=(e-s)*(o-a)&&(e-s)*(r-a)>=(n-s)*(t-a)&&(n-s)*(o-a)>=(i-s)*(r-a)}function qr(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!ei(e,t)&&(ce(e,t)&&ce(t,e)&&ti(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 Yt(e,t,n,r){let i=be(P(e,t,n)),o=be(P(e,t,r)),s=be(P(n,r,e)),a=be(P(n,r,t));return!!(i!==o&&s!==a||i===0&&Ve(e,n,t)||o===0&&Ve(e,r,t)||s===0&&Ve(n,e,r)||a===0&&Ve(n,t,r))}function Ve(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 be(e){return e>0?1:e<0?-1:0}function ei(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&&Yt(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function ce(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 ti(e,t){let n=e,r=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function Qt(e,t){let n=new ue(e.i,e.x,e.y),r=new ue(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function Kt(e,t,n,r){let i=new ue(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function fe(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 ue=class{constructor(t,n,r){B(this,"i",void 0),B(this,"x",void 0),B(this,"y",void 0),B(this,"prev",null),B(this,"next",null),B(this,"z",0),B(this,"prevZ",null),B(this,"nextZ",null),B(this,"steiner",!1),this.i=t,this.x=n,this.y=r}};function st(e,t,n){let r=si(e),i=Object.keys(r).filter(o=>r[o]!==Array);return ai(e,{propArrayTypes:r,...t},{numericPropKeys:n&&n.numericPropKeys||i,PositionDataType:n?n.PositionDataType:Float32Array,triangulate:n?n.triangulate:!0})}function si(e){let t={};for(let n of e)if(n.properties)for(let r in n.properties){let i=n.properties[r];t[r]=di(i,t[r])}return t}function ai(e,t,n){let{pointPositionsCount:r,pointFeaturesCount:i,linePositionsCount:o,linePathsCount:s,lineFeaturesCount:a,polygonPositionsCount:l,polygonObjectsCount:c,polygonRingsCount:f,polygonFeaturesCount:u,propArrayTypes:h,coordLength:d}=t,{numericPropKeys:p=[],PositionDataType:m=Float32Array,triangulate:F=!0}=n,_=e[0]&&"id"in e[0],v=e.length>65535?Uint32Array:Uint16Array,y={type:"Point",positions:new m(r*d),globalFeatureIds:new v(r),featureIds:i>65535?new Uint32Array(r):new Uint16Array(r),numericProps:{},properties:[],fields:[]},g={type:"LineString",pathIndices:o>65535?new Uint32Array(s+1):new Uint16Array(s+1),positions:new m(o*d),globalFeatureIds:new v(o),featureIds:a>65535?new Uint32Array(o):new Uint16Array(o),numericProps:{},properties:[],fields:[]},V={type:"Polygon",polygonIndices:l>65535?new Uint32Array(c+1):new Uint16Array(c+1),primitivePolygonIndices:l>65535?new Uint32Array(f+1):new Uint16Array(f+1),positions:new m(l*d),globalFeatureIds:new v(l),featureIds:u>65535?new Uint32Array(l):new Uint16Array(l),numericProps:{},properties:[],fields:[]};F&&(V.triangles=[]);for(let M of[y,g,V])for(let T of p){let b=h[T];M.numericProps[T]=new b(M.positions.length/d)}g.pathIndices[s]=o,V.polygonIndices[c]=l,V.primitivePolygonIndices[f]=l;let C={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(let M of e){let T=M.geometry,b=M.properties||{};switch(T.type){case"Point":li(T,y,C,d,b),y.properties.push(ot(b,p)),_&&y.fields.push({id:M.id}),C.pointFeature++;break;case"LineString":ci(T,g,C,d,b),g.properties.push(ot(b,p)),_&&g.fields.push({id:M.id}),C.lineFeature++;break;case"Polygon":fi(T,V,C,d,b),V.properties.push(ot(b,p)),_&&V.fields.push({id:M.id}),C.polygonFeature++;break;default:throw new Error("Invalid geometry type")}C.feature++}return hi(y,g,V,d)}function li(e,t,n,r,i){t.positions.set(e.data,n.pointPosition*r);let o=e.data.length/r;at(t,i,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 ci(e,t,n,r,i){t.positions.set(e.data,n.linePosition*r);let o=e.data.length/r;at(t,i,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],c=s===a-1?e.data.length:e.indices[s+1];t.pathIndices[n.linePath++]=n.linePosition,n.linePosition+=(c-l)/r}}function fi(e,t,n,r,i){t.positions.set(e.data,n.polygonPosition*r);let o=e.data.length/r;at(t,i,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 c=e.areas[s],f=e.indices[s],u=e.indices[s+1];for(let d=0,p=f.length;d<p;++d){let m=f[d],F=d===p-1?u===void 0?e.data.length:u[0]:f[d+1];t.primitivePolygonIndices[n.polygonRing++]=n.polygonPosition,n.polygonPosition+=(F-m)/r}let h=n.polygonPosition;ui(t,c,f,{startPosition:l,endPosition:h,coordLength:r})}}function ui(e,t,n,{startPosition:r,endPosition:i,coordLength:o}){if(!e.triangles)return;let s=r*o,a=i*o,l=e.positions.subarray(s,a),c=n[0],f=n.slice(1).map(h=>(h-c)/o),u=rt(l,f,o,t);for(let h=0,d=u.length;h<d;++h)e.triangles.push(r+u[h])}function it(e,t){let n={};for(let r in e)n[r]={value:e[r],size:t};return n}function hi(e,t,n,r){let i={shape:"binary-feature-collection",points:{...e,positions:{value:e.positions,size:r},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},numericProps:it(e.numericProps,1)},lines:{...t,positions:{value:t.positions,size:r},pathIndices:{value:t.pathIndices,size:1},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},numericProps:it(t.numericProps,1)},polygons:{...n,positions:{value:n.positions,size:r},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:it(n.numericProps,1)}};return i.polygons&&n.triangles&&(i.polygons.triangles={value:new Uint32Array(n.triangles),size:1}),i}function at(e,t,n,r){for(let i in e.numericProps)if(i in t){let o=t[i];e.numericProps[i].fill(o,n,n+r)}}function ot(e,t){let n={};for(let r in e)t.includes(r)||(n[r]=e[r]);return n}function di(e,t){return t===Array||!Number.isFinite(e)?Array:t===Float64Array||Math.fround(e)!==e?Float64Array:Float32Array}var pt=Ut(ln(),1);function cn(e){let t=e.length;if(t<=1)return[e];let n=[],r,i;for(let o=0;o<t;o++){let s=Ei(e[o]);s!==0&&(i===void 0&&(i=s<0),i===s<0?(r&&n.push(r),r=[e[o]]):r&&r.push(e[o]))}return r&&n.push(r),n}function Ei(e){let t=0;for(let n=0,r=e.length-1,i,o;n<e.length;r=n++)i=e[n],o=e[r],t+=(o[0]-i[0])*(i[1]+o[1]);return t}function fn(e,t,n){t&&n&&(e===1?t.id=n.readVarint():e===2?_i(n,t):e===3?t.type=n.readVarint():e===4&&(t._geometry=n.pos))}function _i(e,t){let n=e.readVarint()+e.pos;for(;e.pos<n;){let r=t._keys[e.readVarint()],i=t._values[e.readVarint()];t.properties[r]=i}}var Q=class{properties;extent;type;id;_pbf;_geometry;_keys;_values;static get types(){return["Unknown","Point","LineString","Polygon"]}constructor(t,n,r,i,o){this.properties={},this.extent=r,this.type=0,this.id=null,this._pbf=t,this._geometry=-1,this._keys=i,this._values=o,t.readFields(fn,this,n)}loadGeometry(){let t=this._pbf;t.pos=this._geometry;let n=t.readVarint()+t.pos,r=1,i=0,o=0,s=0,a=[],l;for(;t.pos<n;){if(i<=0){let c=t.readVarint();r=c&7,i=c>>3}if(i--,r===1||r===2)o+=t.readSVarint(),s+=t.readSVarint(),r===1&&(l&&a.push(l),l=[]),l&&l.push([o,s]);else if(r===7)l&&l.push(l[0].slice());else throw new Error(`unknown command ${r}`)}return l&&a.push(l),a}bbox(){let t=this._pbf;t.pos=this._geometry;let n=t.readVarint()+t.pos,r=1,i=0,o=0,s=0,a=1/0,l=-1/0,c=1/0,f=-1/0;for(;t.pos<n;){if(i<=0){let u=t.readVarint();r=u&7,i=u>>3}if(i--,r===1||r===2)o+=t.readSVarint(),s+=t.readSVarint(),o<a&&(a=o),o>l&&(l=o),s<c&&(c=s),s>f&&(f=s);else if(r!==7)throw new Error(`unknown command ${r}`)}return[a,c,l,f]}_toGeoJSON(t){let n=this.loadGeometry(),r=Q.types[this.type],i,o;switch(this.type){case 1:let a=[];for(i=0;i<n.length;i++)a[i]=n[i][0];n=a,t(n,this);break;case 2:for(i=0;i<n.length;i++)t(n[i],this);break;case 3:for(n=cn(n),i=0;i<n.length;i++)for(o=0;o<n[i].length;o++)t(n[i][o],this);break}n.length===1?n=n[0]:r=`Multi${r}`;let s={type:"Feature",geometry:{type:r,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:r,z:i}=t,o=this.extent*Math.pow(2,i),s=this.extent*n,a=this.extent*r;function l(c){for(let f=0;f<c.length;f++){let u=c[f];u[0]=(u[0]+s)*360/o-180;let h=180-(u[1]+a)*360/o;u[1]=360/Math.PI*Math.atan(Math.exp(h*Math.PI/180))-90}}return this._toGeoJSON(l)}};var _e=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(Mi,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 Q(this._pbf,n,this.extent,this._keys,this._values)}};function Mi(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(Ui(n)))}function Ui(e){let t=null,n=e.readVarint()+e.pos;for(;e.pos<n;){let r=e.readVarint()>>3;t=r===1?e.readString():r===2?e.readFloat():r===3?e.readDouble():r===4?e.readVarint64():r===5?e.readVarint():r===6?e.readSVarint():r===7?e.readBoolean():null}return t}var Me=class{layers;constructor(t,n){this.layers=t.readFields(Li,{},n)}};function Li(e,t,n){if(e===3&&n){let r=new _e(n,n.readVarint()+n.pos);r.length&&t&&(t[r.name]=r)}}function un(e){let t=e.indices.length,n="Polygon";if(t<=1)return{type:n,data:e.data,areas:[[j(e.data)]],indices:[e.indices]};let r=[],i=[],o=[],s=[],a,l=0;for(let c,f=0,u;f<t;f++){u=e.indices[f]-l,c=e.indices[f+1]-l||e.data.length;let h=e.data.slice(u,c),d=j(h);if(d===0){let p=e.data.slice(0,u),m=e.data.slice(c);e.data=p.concat(m),l+=c-u;continue}a===void 0&&(a=d<0),a===d<0?(s.length&&(r.push(o),i.push(s)),s=[u],o=[d]):(o.push(d),s.push(u))}return o&&r.push(o),s.length&&i.push(s),{type:n,areas:r,indices:i,data:e.data}}function hn(e,t,n,r){for(let i=0,o=e.length;i<o;i+=2){e[i]=(e[i]+t)*360/r-180;let s=180-(e[i+1]+n)*360/r;e[i+1]=360/Math.PI*Math.atan(Math.exp(s*Math.PI/180))-90}}function dn(e,t,n){t&&n&&(e===1?t.id=n.readVarint():e===2?ki(n,t):e===3?t.type=n.readVarint():e===4&&(t._geometry=n.pos))}function ki(e,t){let n=e.readVarint()+e.pos;for(;e.pos<n;){let r=t._keys[e.readVarint()],i=t._values[e.readVarint()];t.properties[r]=i}}var pn,H,ft,Ue,ut,ht,he;var Le=class{properties;extent;type;id;_pbf;_geometry;_keys;_values;_geometryInfo;constructor(t,n,r,i,o,s){this.properties={},this.extent=r,this.type=0,this.id=null,this._pbf=t,this._geometry=-1,this._keys=i,this._values=o,this._geometryInfo=s,t.readFields(dn,this,n)}loadGeometry(){let t=this._pbf;t.pos=this._geometry,pn=t.readVarint()+t.pos,H=1,Ue=0,ut=0,ht=0,he=0;let n=[],r=[];for(;t.pos<pn;)if(Ue<=0&&(ft=t.readVarint(),H=ft&7,Ue=ft>>3),Ue--,H===1||H===2)ut+=t.readSVarint(),ht+=t.readSVarint(),H===1&&n.push(he),r.push(ut,ht),he+=2;else if(H===7){if(he>0){let i=n[n.length-1];r.push(r[i],r[i+1]),he+=2}}else throw new Error(`unknown command ${H}`);return{data:r,indices:n}}_toBinaryCoordinates(t){let n=this.loadGeometry(),r;t(n.data,this);let i=2;switch(this.type){case 1:this._geometryInfo.pointFeaturesCount++,this._geometryInfo.pointPositionsCount+=n.indices.length,r={type:"Point",...n};break;case 2:this._geometryInfo.lineFeaturesCount++,this._geometryInfo.linePathsCount+=n.indices.length,this._geometryInfo.linePositionsCount+=n.data.length/i,r={type:"LineString",...n};break;case 3:r=un(n),this._geometryInfo.polygonFeaturesCount++,this._geometryInfo.polygonObjectsCount+=r.indices.length;for(let s of r.indices)this._geometryInfo.polygonRingsCount+=s.length;this._geometryInfo.polygonPositionsCount+=r.data.length/i;break;default:throw new Error(`Invalid geometry type: ${this.type}`)}let o={type:"Feature",geometry:r,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:r,z:i}=t,o=this.extent*Math.pow(2,i),s=this.extent*n,a=this.extent*r;return this._toBinaryCoordinates(l=>hn(l,s,a,o))}};var ke=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(Ci,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 r=this._pbf.readVarint()+this._pbf.pos;return new Le(this._pbf,r,this.extent,this._keys,this._values,n)}};function Ci(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 r=e.readVarint()>>3;t=r===1?e.readString():r===2?e.readFloat():r===3?e.readDouble():r===4?e.readVarint64():r===5?e.readVarint():r===6?e.readSVarint():r===7?e.readBoolean():null}return t}var Ce=class{layers;constructor(t,n){this.layers=t.readFields(Ni,{},n)}};function Ni(e,t,n){if(e===3&&n){let r=new ke(n,n.readVarint()+n.pos);r.length&&t&&(t[r.name]=r)}}function gt(e,t){let n=Zi(t),r=t?.gis?.format||t?.mvt?.shape||t?.shape;switch(r){case"columnar-table":return{shape:"columnar-table",data:dt(e,n)};case"geojson-table":return{shape:"geojson-table",type:"FeatureCollection",features:gn(e,n)};case"geojson":return gn(e,n);case"binary-geometry":return dt(e,n);case"binary":return dt(e,n);default:throw new Error(r||"undefined shape")}}function dt(e,t){let[n,r]=zi(e,t),i=st(n,r);return i.byteLength=e.byteLength,i}function zi(e,t){let n=[],r={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,r];let i=new Ce(new pt.default(e));return(t&&Array.isArray(t.layers)?t.layers:Object.keys(i.layers)).forEach(s=>{let a=i.layers[s];if(a)for(let l=0;l<a.length;l++){let c=a.feature(l,r),f=ji(c,t,s);n.push(f)}}),[n,r]}function gn(e,t){if(e.byteLength<=0)return[];let n=[],r=new Me(new pt.default(e));return(Array.isArray(t.layers)?t.layers:Object.keys(r.layers)).forEach(o=>{let s=r.layers[o];if(s)for(let a=0;a<s.length;a++){let l=s.feature(a),c=Ri(l,t,o);n.push(c)}}),n}function Zi(e){if(!e?.mvt)throw new Error("mvt options required");let t=e.mvt?.coordinates==="wgs84",{tileIndex:n}=e.mvt,r=n&&Number.isFinite(n.x)&&Number.isFinite(n.y)&&Number.isFinite(n.z);if(t&&!r)throw new Error("MVT Loader: WGS84 coordinates need tileIndex property");return e.mvt}function Ri(e,t,n){let r=e.toGeoJSON(t.coordinates==="wgs84"?t.tileIndex:Gi);return t.layerProperty&&(r.properties[t.layerProperty]=n),r}function ji(e,t,n){let r=e.toBinaryCoordinates(t.coordinates==="wgs84"?t.tileIndex:Hi);return t.layerProperty&&r.properties&&(r.properties[t.layerProperty]=n),r}function Gi(e,t){let{extent:n}=t;for(let r=0;r<e.length;r++){let i=e[r];i[0]/=n,i[1]/=n}}function Hi(e,t){let{extent:n}=t;for(let r=0,i=e.length;r<i;++r)e[r]/=n}var Ji="4.2.4",yn={dataType:null,batchType:null,name:"Mapbox Vector Tile",id:"mvt",module:"mvt",version:Ji,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}}},yt={...yn,parse:async(e,t)=>gt(e,t),parseSync:gt,binary:!0};var vn=e=>e!==null&&typeof e=="object";function mt(e,t){if(!e||!vn(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=mn(e.bounds)||mn(e.antimeridian_adjusted_bounds),n.center=Qi(e.center),n.maxZoom=xn(e.maxzoom),n.minZoom=xn(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 r=e.tilestats||n.metaJson?.tilestats,i=Ki(r,t),o=Wi(e.vector_layers),s=Yi(o,i);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 Wi(e){return Array.isArray(e)?e.map(t=>$i(t)):[]}function $i(e){let t=Object.entries(e.fields||[]).map(([r,i])=>({name:r,...Tn(String(i))})),n={...e};return delete n.fields,{name:e.id||"",...n,fields:t}}function Ki(e,t){return vn(e)&&Array.isArray(e.layers)?e.layers.map(n=>Xi(n,t)):[]}function Xi(e,t){let n=[],r={},i=e.attributes||[];for(let o of i){let s=o.attribute;if(typeof s=="string")if(s.split("|").length>1){let a=s.split("|")[0];r[a]=r[a]||[],r[a].push(o),console.warn("ignoring tilestats indexed field",a)}else n[s]||n.push(eo(o,t))}return{name:e.layer||"",dominantGeometry:e.geometry,fields:n}}function Yi(e,t){return e.map(n=>{let r=t.find(s=>s.name===n.name),i=r?.fields||[],o={...n};return delete o.fields,{...o,...r,fields:i}})}function mn(e){let t=In(e);if(Array.isArray(t)&&t.length===4&&[t[0],t[2]].every(Fn)&&[t[1],t[3]].every(Pn))return[[t[0],t[1]],[t[2],t[3]]]}function Qi(e){let t=In(e);return Array.isArray(t)&&t.length===3&&Fn(t[0])&&Pn(t[1])&&qi(t[2])?t:null}function xn(e){let t=typeof e=="string"?parseFloat(e):typeof e=="number"?e:null;return t===null||isNaN(t)?null:t}function Pn(e){return Number.isFinite(e)&&e<=90&&e>=-90}function Fn(e){return Number.isFinite(e)&&e<=180&&e>=-180}function qi(e){return Number.isFinite(e)&&e>=0&&e<=22}function In(e){return typeof e=="string"?e.split(",").map(parseFloat):Array.isArray(e)?e:null}var wn={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 eo(e={},t){let n=Tn(e.type),r={name:e.attribute,...n};return typeof e.min=="number"&&(r.min=e.min),typeof e.max=="number"&&(r.max=e.max),typeof e.count=="number"&&(r.uniqueValueCount=e.count),e.values&&(r.values=e.values),r.values&&typeof t.maxValues=="number"&&(r.values=r.values?.slice(0,t.maxValues)),r}function Tn(e){let t=e.toLowerCase();return!t||wn[t],wn[t]||{type:"string"}}var to="4.2.4",de={dataType:null,batchType:null,name:"TileJSON",id:"tilejson",module:"pmtiles",version:to,worker:!0,extensions:["json"],mimeTypes:["application/json"],text:!0,options:{tilejson:{maxValues:void 0}},parse:async(e,t)=>{let n=new TextDecoder().decode(e),r=JSON.parse(n),i={...de.options.tilejson,...t?.tilejson};return mt(r,i)},parseTextSync:(e,t)=>{let n=JSON.parse(e),r={...de.options.tilejson,...t?.tilejson};return mt(n,r)}};var me={};Mt(me,{Compression:()=>Zn,EtagMismatch:()=>Ne,FetchSource:()=>Gn,FileSource:()=>ko,PMTiles:()=>Ft,Protocol:()=>Bo,ResolvedValueCache:()=>Oo,SharedPromiseCache:()=>Kn,TileType:()=>Rn,bytesToHeader:()=>Hn,findTile:()=>jn,getUint64:()=>E,leafletRasterLayer:()=>bo,readVarint:()=>ee,tileIdToZxy:()=>Uo,zxyToTileId:()=>zn});var J=Math.pow,I=(e,t,n)=>new Promise((r,i)=>{var o=l=>{try{a(n.next(l))}catch(c){i(c)}},s=l=>{try{a(n.throw(l))}catch(c){i(c)}},a=l=>l.done?r(l.value):Promise.resolve(l.value).then(o,s);a((n=n.apply(e,t)).next())}),D=Uint8Array,te=Uint16Array,no=Int32Array,Vn=new D([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),bn=new D([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ro=new D([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),An=function(e,t){for(var n=new te(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new no(n[30]),r=1;r<30;++r)for(var o=n[r];o<n[r+1];++o)i[o]=o-n[r]<<5|r;return{b:n,r:i}},Bn=An(Vn,2),En=Bn.b,io=Bn.r;En[28]=258,io[258]=28;var _n=An(bn,0),oo=_n.b,Qa=_n.r,vt=new te(32768);for(w=0;w<32768;++w)Z=(w&43690)>>1|(w&21845)<<1,Z=(Z&52428)>>2|(Z&13107)<<2,Z=(Z&61680)>>4|(Z&3855)<<4,vt[w]=((Z&65280)>>8|(Z&255)<<8)>>1;var Z,w,ge=function(e,t,n){for(var r=e.length,i=0,o=new te(t);i<r;++i)e[i]&&++o[e[i]-1];var s=new te(t);for(i=1;i<t;++i)s[i]=s[i-1]+o[i-1]<<1;var a;if(n){a=new te(1<<t);var l=15-t;for(i=0;i<r;++i)if(e[i])for(var c=i<<4|e[i],f=t-e[i],u=s[e[i]-1]++<<f,h=u|(1<<f)-1;u<=h;++u)a[vt[u]>>l]=c}else for(a=new te(r),i=0;i<r;++i)e[i]&&(a[i]=vt[s[e[i]-1]++]>>15-e[i]);return a},ye=new D(288);for(w=0;w<144;++w)ye[w]=8;var w;for(w=144;w<256;++w)ye[w]=9;var w;for(w=256;w<280;++w)ye[w]=7;var w;for(w=280;w<288;++w)ye[w]=8;var w,Mn=new D(32);for(w=0;w<32;++w)Mn[w]=5;var w,so=ge(ye,9,1),ao=ge(Mn,5,1),xt=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},k=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},wt=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},lo=function(e){return(e+7)/8|0},co=function(e,t,n){(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length);var r=new D(n-t);return r.set(e.subarray(t,n)),r},fo=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],S=function(e,t,n){var r=new Error(t||fo[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,S),!n)throw r;return r},It=function(e,t,n,r){var i=e.length,o=r?r.length:0;if(!i||t.f&&!t.l)return n||new D(0);var s=!n||t.i!=2,a=t.i;n||(n=new D(i*3));var l=function(Bt){var Et=n.length;if(Bt>Et){var _t=new D(Math.max(Et*2,Bt));_t.set(n),n=_t}},c=t.f||0,f=t.p||0,u=t.b||0,h=t.l,d=t.d,p=t.m,m=t.n,F=i*8;do{if(!h){c=k(e,f,1);var _=k(e,f+1,3);if(f+=3,_)if(_==1)h=so,d=ao,p=9,m=5;else if(_==2){var V=k(e,f,31)+257,C=k(e,f+10,15)+4,M=V+k(e,f+5,31)+1;f+=14;for(var T=new D(M),b=new D(19),A=0;A<C;++A)b[ro[A]]=k(e,f+A*3,7);f+=C*3;for(var St=xt(b),Yn=(1<<St)-1,Qn=ge(b,St,1),A=0;A<M;){var Dt=Qn[k(e,f,Yn)];f+=Dt&15;var v=Dt>>4;if(v<16)T[A++]=v;else{var W=0,ve=0;for(v==16?(ve=3+k(e,f,3),f+=2,W=T[A-1]):v==17?(ve=3+k(e,f,7),f+=3):v==18&&(ve=11+k(e,f,127),f+=7);ve--;)T[A++]=W}}var Vt=T.subarray(0,V),U=T.subarray(V);p=xt(Vt),m=xt(U),h=ge(Vt,p,1),d=ge(U,m,1)}else S(1);else{var v=lo(f)+4,y=e[v-4]|e[v-3]<<8,g=v+y;if(g>i){a&&S(0);break}s&&l(u+y),n.set(e.subarray(v,g),u),t.b=u+=y,t.p=f=g*8,t.f=c;continue}if(f>F){a&&S(0);break}}s&&l(u+131072);for(var qn=(1<<p)-1,er=(1<<m)-1,Re=f;;Re=f){var W=h[wt(e,f)&qn],$=W>>4;if(f+=W&15,f>F){a&&S(0);break}if(W||S(2),$<256)n[u++]=$;else if($==256){Re=f,h=null;break}else{var bt=$-254;if($>264){var A=$-257,ne=Vn[A];bt=k(e,f,(1<<ne)-1)+En[A],f+=ne}var je=d[wt(e,f)&er],Ge=je>>4;je||S(3),f+=je&15;var U=oo[Ge];if(Ge>3){var ne=bn[Ge];U+=wt(e,f)&(1<<ne)-1,f+=ne}if(f>F){a&&S(0);break}s&&l(u+131072);var He=u+bt;if(u<U){var At=o-U,tr=Math.min(U,He);for(At+u<0&&S(3);u<tr;++u)n[u]=r[At+u]}for(;u<He;u+=4)n[u]=n[u-U],n[u+1]=n[u+1-U],n[u+2]=n[u+2-U],n[u+3]=n[u+3-U];u=He}}t.l=h,t.p=Re,t.b=u,t.f=c,h&&(c=1,t.m=p,t.d=d,t.n=m)}while(!c);return u==n.length?n:co(n,0,u)},uo=new D(0),ho=function(e){(e[0]!=31||e[1]!=139||e[2]!=8)&&S(6,"invalid gzip data");var t=e[3],n=10;t&4&&(n+=(e[10]|e[11]<<8)+2);for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[n++]);return n+(t&2)},po=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},go=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&S(6,"invalid zlib data"),(e[1]>>5&1)==+!t&&S(6,"invalid zlib data: "+(e[1]&32?"need":"unexpected")+" dictionary"),(e[1]>>3&4)+2};function yo(e,t){return It(e,{i:2},t&&t.out,t&&t.dictionary)}function mo(e,t){var n=ho(e);return n+8>e.length&&S(6,"invalid gzip data"),It(e.subarray(n,-8),{i:2},t&&t.out||new D(po(e)),t&&t.dictionary)}function xo(e,t){return It(e.subarray(go(e,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}function Pt(e,t){return e[0]==31&&e[1]==139&&e[2]==8?mo(e,t):(e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31?yo(e,t):xo(e,t)}var wo=typeof TextDecoder<"u"&&new TextDecoder,vo=0;try{wo.decode(uo,{stream:!0}),vo=1}catch{}var Un=(e,t)=>e*J(2,t),pe=(e,t)=>Math.floor(e/J(2,t)),Oe=(e,t)=>Un(e.getUint16(t+1,!0),8)+e.getUint8(t),Ln=(e,t)=>Un(e.getUint32(t+2,!0),16)+e.getUint16(t,!0),Po=(e,t,n,r,i)=>{if(e!==r.getUint8(i))return e-r.getUint8(i);let o=Oe(r,i+1);if(t!==o)return t-o;let s=Oe(r,i+4);return n!==s?n-s:0},Fo=(e,t,n,r)=>{let i=kn(e,t|128,n,r);return i?{z:t,x:n,y:r,offset:i[0],length:i[1],isDir:!0}:null},Sn=(e,t,n,r)=>{let i=kn(e,t,n,r);return i?{z:t,x:n,y:r,offset:i[0],length:i[1],isDir:!1}:null},kn=(e,t,n,r)=>{let i=0,o=e.byteLength/17-1;for(;i<=o;){let s=o+i>>1,a=Po(t,n,r,e,s*17);if(a>0)i=s+1;else if(a<0)o=s-1;else return[Ln(e,s*17+7),e.getUint32(s*17+13,!0)]}return null},Io=(e,t)=>e.isDir&&!t.isDir?1:!e.isDir&&t.isDir?-1:e.z!==t.z?e.z-t.z:e.x!==t.x?e.x-t.x:e.y-t.y,Cn=(e,t)=>{let n=e.getUint8(t*17);return{z:n&127,x:Oe(e,t*17+1),y:Oe(e,t*17+4),offset:Ln(e,t*17+7),length:e.getUint32(t*17+13,!0),isDir:n>>7===1}},Dn=e=>{let t=[],n=new DataView(e);for(let r=0;r<n.byteLength/17;r++)t.push(Cn(n,r));return To(t)},To=e=>{e.sort(Io);let t=new ArrayBuffer(17*e.length),n=new Uint8Array(t);for(let r=0;r<e.length;r++){let i=e[r],o=i.z;i.isDir&&(o=o|128),n[r*17]=o,n[r*17+1]=i.x&255,n[r*17+2]=i.x>>8&255,n[r*17+3]=i.x>>16&255,n[r*17+4]=i.y&255,n[r*17+5]=i.y>>8&255,n[r*17+6]=i.y>>16&255,n[r*17+7]=i.offset&255,n[r*17+8]=pe(i.offset,8)&255,n[r*17+9]=pe(i.offset,16)&255,n[r*17+10]=pe(i.offset,24)&255,n[r*17+11]=pe(i.offset,32)&255,n[r*17+12]=pe(i.offset,48)&255,n[r*17+13]=i.length&255,n[r*17+14]=i.length>>8&255,n[r*17+15]=i.length>>16&255,n[r*17+16]=i.length>>24&255}return t},So=(e,t)=>{if(e.byteLength<17)return null;let n=e.byteLength/17,r=Cn(e,n-1);if(r.isDir){let i=r.z,o=t.z-i,s=Math.trunc(t.x/(1<<o)),a=Math.trunc(t.y/(1<<o));return{z:i,x:s,y:a}}return null};function Do(e){return I(this,null,function*(){let t=yield e.getBytes(0,512e3),n=new DataView(t.data),r=n.getUint32(4,!0),i=n.getUint16(8,!0),o=new TextDecoder("utf-8"),s=JSON.parse(o.decode(new DataView(t.data,10,r))),a=0;s.compression==="gzip"&&(a=2);let l=0;"minzoom"in s&&(l=+s.minzoom);let c=0;"maxzoom"in s&&(c=+s.maxzoom);let f=0,u=0,h=0,d=-180,p=-85,m=180,F=85;if(s.bounds){let v=s.bounds.split(",");d=+v[0],p=+v[1],m=+v[2],F=+v[3]}if(s.center){let v=s.center.split(",");f=+v[0],u=+v[1],h=+v[2]}return{specVersion:n.getUint16(2,!0),rootDirectoryOffset:10+r,rootDirectoryLength:i*17,jsonMetadataOffset:10,jsonMetadataLength:r,leafDirectoryOffset:0,leafDirectoryLength:void 0,tileDataOffset:0,tileDataLength:void 0,numAddressedTiles:0,numTileEntries:0,numTileContents:0,clustered:!1,internalCompression:1,tileCompression:a,tileType:1,minZoom:l,maxZoom:c,minLon:d,minLat:p,maxLon:m,maxLat:F,centerZoom:h,centerLon:f,centerLat:u,etag:t.etag}})}function Vo(e,t,n,r,i,o,s){return I(this,null,function*(){let a=yield n.getArrayBuffer(t,e.rootDirectoryOffset,e.rootDirectoryLength,e);e.specVersion===1&&(a=Dn(a));let l=Sn(new DataView(a),r,i,o);if(l){let u=(yield t.getBytes(l.offset,l.length,s)).data,h=new DataView(u);return h.getUint8(0)===31&&h.getUint8(1)===139&&(u=Pt(new Uint8Array(u))),{data:u}}let c=So(new DataView(a),{z:r,x:i,y:o});if(c){let f=Fo(new DataView(a),c.z,c.x,c.y);if(f){let u=yield n.getArrayBuffer(t,f.offset,f.length,e);e.specVersion===1&&(u=Dn(u));let h=Sn(new DataView(u),r,i,o);if(h){let p=(yield t.getBytes(h.offset,h.length,s)).data,m=new DataView(p);return m.getUint8(0)===31&&m.getUint8(1)===139&&(p=Pt(new Uint8Array(p))),{data:p}}}}})}var On={getHeader:Do,getZxy:Vo},bo=(e,t)=>{let n=!1,r="",i=L.GridLayer.extend({createTile:(o,s)=>{let a=document.createElement("img"),l=new AbortController,c=l.signal;return a.cancel=()=>{l.abort()},n||(e.getHeader().then(f=>{f.tileType===1?console.error("Error: archive contains MVT vector tiles, but leafletRasterLayer is for displaying raster tiles. See https://github.com/protomaps/PMTiles/tree/main/js for details."):f.tileType===2?r="image/png":f.tileType===3?r="image/jpeg":f.tileType===4?r="image/webp":f.tileType===5&&(r="image/avif")}),n=!0),e.getZxy(o.z,o.x,o.y,c).then(f=>{if(f){let u=new Blob([f.data],{type:r}),h=window.URL.createObjectURL(u);a.src=h,a.cancel=void 0,s(void 0,a)}}).catch(f=>{if(f.name!=="AbortError")throw f}),a},_removeTile:function(o){let s=this._tiles[o];s&&(s.el.cancel&&s.el.cancel(),s.el.width=0,s.el.height=0,s.el.deleted=!0,L.DomUtil.remove(s.el),delete this._tiles[o],this.fire("tileunload",{tile:s.el,coords:this._keyToTileCoords(o)}))}});return new i(t)},Ao=e=>(t,n)=>{if(n instanceof AbortController)return e(t,n);let r=new AbortController;return e(t,r).then(i=>n(void 0,i.data,i.cacheControl||"",i.expires||""),i=>n(i)).catch(i=>n(i)),{cancel:()=>r.abort()}},Bo=class{constructor(){this.tilev4=(e,t)=>I(this,null,function*(){if(e.type==="json"){let u=e.url.substr(10),h=this.tiles.get(u);h||(h=new Ft(u),this.tiles.set(u,h));let d=yield h.getHeader();return{data:{tiles:[`${e.url}/{z}/{x}/{y}`],minzoom:d.minZoom,maxzoom:d.maxZoom,bounds:[d.minLon,d.minLat,d.maxLon,d.maxLat]}}}let n=new RegExp(/pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)/),r=e.url.match(n);if(!r)throw new Error("Invalid PMTiles protocol URL");let i=r[1],o=this.tiles.get(i);o||(o=new Ft(i),this.tiles.set(i,o));let s=r[2],a=r[3],l=r[4],c=yield o.getHeader(),f=yield o?.getZxy(+s,+a,+l,t.signal);return f?{data:new Uint8Array(f.data),cacheControl:f.cacheControl,expires:f.expires}:c.tileType===1?{data:new Uint8Array}:{data:null}}),this.tile=Ao(this.tilev4),this.tiles=new Map}add(e){this.tiles.set(e.source.getKey(),e)}get(e){return this.tiles.get(e)}};function q(e,t){return(t>>>0)*4294967296+(e>>>0)}function Eo(e,t){let n=t.buf,r=n[t.pos++],i=(r&112)>>4;if(r<128||(r=n[t.pos++],i|=(r&127)<<3,r<128)||(r=n[t.pos++],i|=(r&127)<<10,r<128)||(r=n[t.pos++],i|=(r&127)<<17,r<128)||(r=n[t.pos++],i|=(r&127)<<24,r<128)||(r=n[t.pos++],i|=(r&1)<<31,r<128))return q(e,i);throw new Error("Expected varint not more than 10 bytes")}function ee(e){let t=e.buf,n=t[e.pos++],r=n&127;return n<128||(n=t[e.pos++],r|=(n&127)<<7,n<128)||(n=t[e.pos++],r|=(n&127)<<14,n<128)||(n=t[e.pos++],r|=(n&127)<<21,n<128)?r:(n=t[e.pos],r|=(n&15)<<28,Eo(r,e))}function Nn(e,t,n,r){if(r===0){n===1&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);let i=t[0];t[0]=t[1],t[1]=i}}function _o(e,t){let n=J(2,e),r=t,i=t,o=t,s=[0,0],a=1;for(;a<n;)r=1&o/2,i=1&(o^r),Nn(a,s,r,i),s[0]+=a*r,s[1]+=a*i,o=o/4,a*=2;return[e,s[0],s[1]]}var Mo=[0,1,5,21,85,341,1365,5461,21845,87381,349525,1398101,5592405,22369621,89478485,357913941,1431655765,5726623061,22906492245,91625968981,366503875925,1466015503701,5864062014805,23456248059221,93824992236885,375299968947541,0x5555555555555];function zn(e,t,n){if(e>26)throw Error("Tile zoom level exceeds max safe number limit (26)");if(t>J(2,e)-1||n>J(2,e)-1)throw Error("tile x/y outside zoom level bounds");let r=Mo[e],i=J(2,e),o=0,s=0,a=0,l=[t,n],c=i/2;for(;c>0;)o=(l[0]&c)>0?1:0,s=(l[1]&c)>0?1:0,a+=c*c*(3*o^s),Nn(c,l,o,s),c=c/2;return r+a}function Uo(e){let t=0,n=0;for(let r=0;r<27;r++){let i=(1<<r)*(1<<r);if(t+i>e)return _o(r,e-t);t+=i}throw Error("Tile zoom level exceeds max safe number limit (26)")}var Zn=(e=>(e[e.Unknown=0]="Unknown",e[e.None=1]="None",e[e.Gzip=2]="Gzip",e[e.Brotli=3]="Brotli",e[e.Zstd=4]="Zstd",e))(Zn||{});function Tt(e,t){return I(this,null,function*(){if(t===1||t===0)return e;if(t===2){if(typeof globalThis.DecompressionStream>"u")return Pt(new Uint8Array(e));let n=new Response(e).body;if(!n)throw Error("Failed to read response stream");let r=n.pipeThrough(new globalThis.DecompressionStream("gzip"));return new Response(r).arrayBuffer()}throw Error("Compression method not supported")})}var Rn=(e=>(e[e.Unknown=0]="Unknown",e[e.Mvt=1]="Mvt",e[e.Png=2]="Png",e[e.Jpeg=3]="Jpeg",e[e.Webp=4]="Webp",e[e.Avif=5]="Avif",e))(Rn||{}),Lo=127;function jn(e,t){let n=0,r=e.length-1;for(;n<=r;){let i=r+n>>1,o=t-e[i].tileId;if(o>0)n=i+1;else if(o<0)r=i-1;else return e[i]}return r>=0&&(e[r].runLength===0||t-e[r].tileId<e[r].runLength)?e[r]:null}var ko=class{constructor(e){this.file=e}getKey(){return this.file.name}getBytes(e,t){return I(this,null,function*(){return{data:yield this.file.slice(e,e+t).arrayBuffer()}})}},Gn=class{constructor(e,t=new Headers){this.url=e,this.customHeaders=t,this.mustReload=!1}getKey(){return this.url}setHeaders(e){this.customHeaders=e}getBytes(e,t,n,r){return I(this,null,function*(){let i,o;n?o=n:(i=new AbortController,o=i.signal);let s=new Headers(this.customHeaders);s.set("range",`bytes=${e}-${e+t-1}`);let a;this.mustReload&&(a="reload");let l=yield fetch(this.url,{signal:o,cache:a,headers:s});if(e===0&&l.status===416){let h=l.headers.get("Content-Range");if(!h||!h.startsWith("bytes */"))throw Error("Missing content-length on 416 response");let d=+h.substr(8);l=yield fetch(this.url,{signal:o,cache:"reload",headers:{range:`bytes=0-${d-1}`}})}let c=l.headers.get("Etag");if(c?.startsWith("W/")&&(c=null),l.status===416||r&&c&&c!==r)throw this.mustReload=!0,new Ne(r);if(l.status>=300)throw Error(`Bad response code: ${l.status}`);let f=l.headers.get("Content-Length");if(l.status===200&&(!f||+f>t))throw i&&i.abort(),Error("Server returned no content-length header or content-length exceeding request. Check that your storage backend supports HTTP Byte Serving.");return{data:yield l.arrayBuffer(),etag:c||void 0,cacheControl:l.headers.get("Cache-Control")||void 0,expires:l.headers.get("Expires")||void 0}})}};function E(e,t){let n=e.getUint32(t+4,!0),r=e.getUint32(t+0,!0);return n*J(2,32)+r}function Hn(e,t){let n=new DataView(e),r=n.getUint8(7);if(r>3)throw Error(`Archive is spec version ${r} but this library supports up to spec version 3`);return{specVersion:r,rootDirectoryOffset:E(n,8),rootDirectoryLength:E(n,16),jsonMetadataOffset:E(n,24),jsonMetadataLength:E(n,32),leafDirectoryOffset:E(n,40),leafDirectoryLength:E(n,48),tileDataOffset:E(n,56),tileDataLength:E(n,64),numAddressedTiles:E(n,72),numTileEntries:E(n,80),numTileContents:E(n,88),clustered:n.getUint8(96)===1,internalCompression:n.getUint8(97),tileCompression:n.getUint8(98),tileType:n.getUint8(99),minZoom:n.getUint8(100),maxZoom:n.getUint8(101),minLon:n.getInt32(102,!0)/1e7,minLat:n.getInt32(106,!0)/1e7,maxLon:n.getInt32(110,!0)/1e7,maxLat:n.getInt32(114,!0)/1e7,centerZoom:n.getUint8(118),centerLon:n.getInt32(119,!0)/1e7,centerLat:n.getInt32(123,!0)/1e7,etag:t}}function Jn(e){let t={buf:new Uint8Array(e),pos:0},n=ee(t),r=[],i=0;for(let o=0;o<n;o++){let s=ee(t);r.push({tileId:i+s,offset:0,length:0,runLength:1}),i+=s}for(let o=0;o<n;o++)r[o].runLength=ee(t);for(let o=0;o<n;o++)r[o].length=ee(t);for(let o=0;o<n;o++){let s=ee(t);s===0&&o>0?r[o].offset=r[o-1].offset+r[o-1].length:r[o].offset=s-1}return r}function Co(e){let t=new DataView(e);return t.getUint16(2,!0)===2?(console.warn("PMTiles spec version 2 has been deprecated; please see github.com/protomaps/PMTiles for tools to upgrade"),2):t.getUint16(2,!0)===1?(console.warn("PMTiles spec version 1 has been deprecated; please see github.com/protomaps/PMTiles for tools to upgrade"),1):3}var Ne=class extends Error{};function Wn(e,t){return I(this,null,function*(){let n=yield e.getBytes(0,16384);if(new DataView(n.data).getUint16(0,!0)!==19792)throw new Error("Wrong magic number for PMTiles archive");if(Co(n.data)<3)return[yield On.getHeader(e)];let i=n.data.slice(0,Lo),o=Hn(i,n.etag),s=n.data.slice(o.rootDirectoryOffset,o.rootDirectoryOffset+o.rootDirectoryLength),a=`${e.getKey()}|${o.etag||""}|${o.rootDirectoryOffset}|${o.rootDirectoryLength}`,l=Jn(yield t(s,o.internalCompression));return[o,[a,l.length,l]]})}function $n(e,t,n,r,i){return I(this,null,function*(){let o=yield e.getBytes(n,r,void 0,i.etag),s=yield t(o.data,i.internalCompression),a=Jn(s);if(a.length===0)throw new Error("Empty directory is invalid");return a})}var Oo=class{constructor(e=100,t=!0,n=Tt){this.cache=new Map,this.maxCacheEntries=e,this.counter=1,this.decompress=n}getHeader(e){return I(this,null,function*(){let t=e.getKey(),n=this.cache.get(t);if(n)return n.lastUsed=this.counter++,n.data;let r=yield Wn(e,this.decompress);return r[1]&&this.cache.set(r[1][0],{lastUsed:this.counter++,data:r[1][2]}),this.cache.set(t,{lastUsed:this.counter++,data:r[0]}),this.prune(),r[0]})}getDirectory(e,t,n,r){return I(this,null,function*(){let i=`${e.getKey()}|${r.etag||""}|${t}|${n}`,o=this.cache.get(i);if(o)return o.lastUsed=this.counter++,o.data;let s=yield $n(e,this.decompress,t,n,r);return this.cache.set(i,{lastUsed:this.counter++,data:s}),this.prune(),s})}getArrayBuffer(e,t,n,r){return I(this,null,function*(){let i=`${e.getKey()}|${r.etag||""}|${t}|${n}`,o=this.cache.get(i);if(o)return o.lastUsed=this.counter++,yield o.data;let s=yield e.getBytes(t,n,void 0,r.etag);return this.cache.set(i,{lastUsed:this.counter++,data:s.data}),this.prune(),s.data})}prune(){if(this.cache.size>this.maxCacheEntries){let e=1/0,t;this.cache.forEach((n,r)=>{n.lastUsed<e&&(e=n.lastUsed,t=r)}),t&&this.cache.delete(t)}}invalidate(e){return I(this,null,function*(){this.cache.delete(e.getKey())})}},Kn=class{constructor(e=100,t=!0,n=Tt){this.cache=new Map,this.invalidations=new Map,this.maxCacheEntries=e,this.counter=1,this.decompress=n}getHeader(e){return I(this,null,function*(){let t=e.getKey(),n=this.cache.get(t);if(n)return n.lastUsed=this.counter++,yield n.data;let r=new Promise((i,o)=>{Wn(e,this.decompress).then(s=>{s[1]&&this.cache.set(s[1][0],{lastUsed:this.counter++,data:Promise.resolve(s[1][2])}),i(s[0]),this.prune()}).catch(s=>{o(s)})});return this.cache.set(t,{lastUsed:this.counter++,data:r}),r})}getDirectory(e,t,n,r){return I(this,null,function*(){let i=`${e.getKey()}|${r.etag||""}|${t}|${n}`,o=this.cache.get(i);if(o)return o.lastUsed=this.counter++,yield o.data;let s=new Promise((a,l)=>{$n(e,this.decompress,t,n,r).then(c=>{a(c),this.prune()}).catch(c=>{l(c)})});return this.cache.set(i,{lastUsed:this.counter++,data:s}),s})}getArrayBuffer(e,t,n,r){return I(this,null,function*(){let i=`${e.getKey()}|${r.etag||""}|${t}|${n}`,o=this.cache.get(i);if(o)return o.lastUsed=this.counter++,yield o.data;let s=new Promise((a,l)=>{e.getBytes(t,n,void 0,r.etag).then(c=>{a(c.data),this.cache.has(i),this.prune()}).catch(c=>{l(c)})});return this.cache.set(i,{lastUsed:this.counter++,data:s}),s})}prune(){if(this.cache.size>=this.maxCacheEntries){let e=1/0,t;this.cache.forEach((n,r)=>{n.lastUsed<e&&(e=n.lastUsed,t=r)}),t&&this.cache.delete(t)}}invalidate(e){return I(this,null,function*(){let t=e.getKey();if(this.invalidations.get(t))return yield this.invalidations.get(t);this.cache.delete(e.getKey());let n=new Promise((r,i)=>{this.getHeader(e).then(o=>{r(),this.invalidations.delete(t)}).catch(o=>{i(o)})});this.invalidations.set(t,n)})}},Ft=class{constructor(e,t,n){typeof e=="string"?this.source=new Gn(e):this.source=e,n?this.decompress=n:this.decompress=Tt,t?this.cache=t:this.cache=new Kn}getHeader(){return I(this,null,function*(){return yield this.cache.getHeader(this.source)})}getZxyAttempt(e,t,n,r){return I(this,null,function*(){let i=zn(e,t,n),o=yield this.cache.getHeader(this.source);if(o.specVersion<3)return On.getZxy(o,this.source,this.cache,e,t,n,r);if(e<o.minZoom||e>o.maxZoom)return;let s=o.rootDirectoryOffset,a=o.rootDirectoryLength;for(let l=0;l<=3;l++){let c=yield this.cache.getDirectory(this.source,s,a,o),f=jn(c,i);if(f){if(f.runLength>0){let u=yield this.source.getBytes(o.tileDataOffset+f.offset,f.length,r,o.etag);return{data:yield this.decompress(u.data,o.tileCompression),cacheControl:u.cacheControl,expires:u.expires}}s=o.leafDirectoryOffset+f.offset,a=f.length}else return}throw Error("Maximum directory depth exceeded")})}getZxy(e,t,n,r){return I(this,null,function*(){try{return yield this.getZxyAttempt(e,t,n,r)}catch(i){if(i instanceof Ne)return this.cache.invalidate(this.source),yield this.getZxyAttempt(e,t,n,r);throw i}})}getMetadataAttempt(){return I(this,null,function*(){let e=yield this.cache.getHeader(this.source),t=yield this.source.getBytes(e.jsonMetadataOffset,e.jsonMetadataLength,void 0,e.etag),n=yield this.decompress(t.data,e.internalCompression),r=new TextDecoder("utf-8");return JSON.parse(r.decode(n))})}getMetadata(){return I(this,null,function*(){try{return yield this.getMetadataAttempt()}catch(e){if(e instanceof Ne)return this.cache.invalidate(this.source),yield this.getMetadataAttempt();throw e}})}};var{TileType:xe}=me;function Xn(e,t,n,r){let i=t,o=null;if(i)try{let l=JSON.stringify(i);o=de.parseTextSync?.(l,r)||null}catch(l){console.warn("PMTiles metadata could not be interpreted as TileJSON",l)}let s={};typeof o?.name=="string"&&(s.name=o.name),typeof o?.htmlAttribution=="string"&&(s.attributions=[o.htmlAttribution]);let a={...s,format:"pmtiles",formatVersion:e.specVersion,attributions:[],tileMIMEType:No(e.tileType),minZoom:e.minZoom,maxZoom:e.maxZoom,boundingBox:[[e.minLon,e.minLat],[e.maxLon,e.maxLat]],center:[e.centerLon,e.centerLat],centerZoom:e.centerZoom,etag:e.etag};return o&&(a.tilejson=o),n?.includeFormatHeader&&(a.formatHeader=e,a.formatMetadata=a),a}function No(e){switch(e){case xe.Mvt:return"application/vnd.mapbox-vector-tile";case xe.Png:return"image/png";case xe.Jpeg:return"image/jpeg";case xe.Webp:return"image/webp";case xe.Avif:return"image/avif";default:return"application/octet-stream"}}var ze=class{blob;key;constructor(t,n){this.blob=t,this.key=n}getKey(){return this.blob.url||""}async getBytes(t,n,r){return{data:await this.blob.slice(t,t+n).arrayBuffer()}}};var{PMTiles:zo}=me;var Ze=class extends ie{data;props;mimeType=null;pmtiles;metadata;constructor(t){super(t),this.props=t;let n=typeof t.url=="string"?Xe(t.url):new ze(t.url,"pmtiles");this.data=t.url,this.pmtiles=new zo(n),this.getTileData=this.getTileData.bind(this),this.metadata=this.getMetadata()}async getMetadata(){let t=await this.pmtiles.getHeader(),n=await this.pmtiles.getMetadata(),r=Xn(t,n,{includeFormatHeader:!1},this.loadOptions);return this.props.attributions&&(r.attributions=[...this.props.attributions,...r.attributions||[]]),r?.tileMIMEType&&(this.mimeType=r?.tileMIMEType),r}async getTile(t){let{x:n,y:r,zoom:i}=t,s=(await this.pmtiles.getZxy(i,n,r))?.data;return s||null}async getTileData(t){let{x:n,y:r,z:i}=t.index;switch((await this.metadata).tileMIMEType){case"application/vnd.mapbox-vector-tile":return await this.getVectorTile({x:n,y:r,zoom:i,layers:[]});default:return await this.getImageTile({x:n,y:r,zoom:i,layers:[]})}}async getImageTile(t){let n=await this.getTile(t);return n?await tt.parse(n,this.loadOptions):null}async getVectorTile(t){let n=await this.getTile(t),r={shape:"geojson-table",mvt:{coordinates:"wgs84",tileIndex:{x:t.x,y:t.y,z:t.zoom},...this.loadOptions?.mvt},...this.loadOptions};return n?await yt.parse(n,r):null}};return ar(we);})();
|
|
8
8
|
/*! Bundled license information:
|
|
9
9
|
|
|
10
10
|
ieee754/index.js:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/pmtiles",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.5",
|
|
4
4
|
"description": "Framework-independent loader for the pmtiles format",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
"build-bundle-dev": "ocular-bundle ./bundle.ts --env=dev --output=dist/dist.dev.js"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@loaders.gl/images": "4.2.
|
|
50
|
-
"@loaders.gl/loader-utils": "4.2.
|
|
51
|
-
"@loaders.gl/mvt": "4.2.
|
|
52
|
-
"@loaders.gl/schema": "4.2.
|
|
49
|
+
"@loaders.gl/images": "4.2.5",
|
|
50
|
+
"@loaders.gl/loader-utils": "4.2.5",
|
|
51
|
+
"@loaders.gl/mvt": "4.2.5",
|
|
52
|
+
"@loaders.gl/schema": "4.2.5",
|
|
53
53
|
"pmtiles": "^3.0.4"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@loaders.gl/core": "^4.0.0"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "9279ea41bf49a2fdf895520888301315f871bb10"
|
|
59
59
|
}
|