commit b392a31945d5b1feea30048cd5377c768cb5185a Author: bdon Date: Tue Feb 3 22:58:48 2026 +0000 deploy: 9598b8abeba6ca165c2bd005e55f9ef059029348 diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/CNAME b/CNAME new file mode 100644 index 0000000..cb422b1 --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +pmtiles.io diff --git a/archive/index.html b/archive/index.html new file mode 100644 index 0000000..cc97c5c --- /dev/null +++ b/archive/index.html @@ -0,0 +1,21 @@ + + + + + + + PMTiles archive inspector + + + + + + + + + + + +
+ + diff --git a/assets/Frame-Cpo70DD7.js b/assets/Frame-Cpo70DD7.js new file mode 100644 index 0000000..fa64a16 --- /dev/null +++ b/assets/Frame-Cpo70DD7.js @@ -0,0 +1 @@ +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&n(a)}).observe(document,{childList:!0,subtree:!0});function r(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(i){if(i.ep)return;i.ep=!0;const s=r(i);fetch(i.href,s)}})();const _t=!1,Ot=(e,t)=>e===t,Pt=Symbol("solid-track"),ue={equals:Ot};let Je=tt;const F=1,fe=2,Qe={owned:null,cleanups:null,context:null,owner:null},Te={};var E=null;let $e=null,Dt=null,T=null,U=null,z=null,me=0;function ce(e,t){const r=T,n=E,i=e.length===0,s=t===void 0?n:t,a=i?Qe:{owned:null,cleanups:null,context:s?s.context:null,owner:s},l=i?e:()=>e(()=>H(()=>se(a)));E=a,T=null;try{return G(l,!0)}finally{T=r,E=n}}function Z(e,t){t=t?Object.assign({},ue,t):ue;const r={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},n=i=>(typeof i=="function"&&(i=i(r.value)),et(r,i));return[Ye.bind(r),n]}function Bt(e,t,r){const n=ve(e,t,!0,F);re(n)}function W(e,t,r){const n=ve(e,t,!1,F);re(n)}function Xe(e,t,r){Je=It;const n=ve(e,t,!1,F);n.user=!0,z?z.push(n):re(n)}function q(e,t,r){r=r?Object.assign({},ue,r):ue;const n=ve(e,t,!0,0);return n.observers=null,n.observerSlots=null,n.comparator=r.equals||void 0,re(n),Ye.bind(n)}function jt(e){return e&&typeof e=="object"&&"then"in e}function zr(e,t,r){let n,i,s;typeof t=="function"?(n=e,i=t,s={}):(n=!0,i=e,s=t||{});let a=null,l=Te,u=!1,f="initialValue"in s,c=typeof n=="function"&&q(n);const o=new Set,[h,d]=(s.storage||Z)(s.initialValue),[p,g]=Z(void 0),[M,P]=Z(void 0,{equals:!1}),[$,v]=Z(f?"ready":"unresolved");function m(S,w,x,C){return a===S&&(a=null,C!==void 0&&(f=!0),(S===l||w===l)&&s.onHydrated&&queueMicrotask(()=>s.onHydrated(C,{value:w})),l=Te,D(w,x)),w}function D(S,w){G(()=>{w===void 0&&d(()=>S),v(w!==void 0?"errored":f?"ready":"unresolved"),g(w);for(const x of o.keys())x.decrement();o.clear()},!1)}function N(){const S=Nt,w=h(),x=p();if(x!==void 0&&!a)throw x;return T&&T.user,w}function J(S=!0){if(S!==!1&&u)return;u=!1;const w=c?c():n;if(w==null||w===!1){m(a,H(h));return}const x=l!==Te?l:H(()=>i(w,{value:h(),refetching:S}));return jt(x)?(a=x,"value"in x?(x.status==="success"?m(a,x.value,void 0,w):m(a,void 0,Se(x.value),w),x):(u=!0,queueMicrotask(()=>u=!1),G(()=>{v(f?"refreshing":"pending"),P()},!1),x.then(C=>m(x,C,void 0,w),C=>m(x,void 0,Se(C),w)))):(m(a,x,void 0,w),x)}return Object.defineProperties(N,{state:{get:()=>$()},error:{get:()=>p()},loading:{get(){const S=$();return S==="pending"||S==="refreshing"}},latest:{get(){if(!f)return N();const S=p();if(S&&!a)throw S;return h()}}}),c?Bt(()=>J(!1)):J(!1),[N,{refetch:J,mutate:d}]}function H(e){if(T===null)return e();const t=T;T=null;try{return e()}finally{T=t}}function Fr(e){Xe(()=>H(e))}function Ht(e){return E===null||(E.cleanups===null?E.cleanups=[e]:E.cleanups.push(e)),e}function Ir(){return E}const[Rr,Zr]=Z(!1);let Nt;function Ye(){if(this.sources&&this.state)if(this.state===F)re(this);else{const e=U;U=null,G(()=>de(this),!1),U=e}if(T){const e=this.observers?this.observers.length:0;T.sources?(T.sources.push(this),T.sourceSlots.push(e)):(T.sources=[this],T.sourceSlots=[e]),this.observers?(this.observers.push(T),this.observerSlots.push(T.sources.length-1)):(this.observers=[T],this.observerSlots=[T.sources.length-1])}return this.value}function et(e,t,r){let n=e.value;return(!e.comparator||!e.comparator(n,t))&&(e.value=t,e.observers&&e.observers.length&&G(()=>{for(let i=0;i1e6)throw U=[],new Error},!1)),t}function re(e){if(!e.fn)return;se(e);const t=me;zt(e,e.value,t)}function zt(e,t,r){let n;const i=E,s=T;T=E=e;try{n=e.fn(t)}catch(a){return e.pure&&(e.state=F,e.owned&&e.owned.forEach(se),e.owned=null),e.updatedAt=r+1,nt(a)}finally{T=s,E=i}(!e.updatedAt||e.updatedAt<=r)&&(e.updatedAt!=null&&"observers"in e?et(e,n):e.value=n,e.updatedAt=r)}function ve(e,t,r,n=F,i){const s={fn:e,state:n,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:E,context:E?E.context:null,pure:r};return E===null||E!==Qe&&(E.owned?E.owned.push(s):E.owned=[s]),s}function he(e){if(e.state===0)return;if(e.state===fe)return de(e);if(e.suspense&&H(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt=0;r--)if(e=t[r],e.state===F)re(e);else if(e.state===fe){const n=U;U=null,G(()=>de(e,t[0]),!1),U=n}}function G(e,t){if(U)return e();let r=!1;t||(U=[]),z?r=!0:z=[],me++;try{const n=e();return Ft(r),n}catch(n){r||(z=null),U=null,nt(n)}}function Ft(e){if(U&&(tt(U),U=null),e)return;const t=z;z=null,t.length&&G(()=>Je(t),!1)}function tt(e){for(let t=0;t=0;t--)se(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)se(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function Se(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function nt(e,t=E){throw Se(e)}const Rt=Symbol("fallback");function Ke(e){for(let t=0;t1?[]:null;return Ht(()=>Ke(s)),()=>{let u=e()||[],f=u.length,c,o;return u[Pt],H(()=>{let d,p,g,M,P,$,v,m,D;if(f===0)a!==0&&(Ke(s),s=[],n=[],i=[],a=0,l&&(l=[])),r.fallback&&(n=[Rt],i[0]=ce(N=>(s[0]=N,r.fallback())),a=1);else if(a===0){for(i=new Array(f),o=0;o=$&&m>=$&&n[v]===u[m];v--,m--)g[m]=i[v],M[m]=s[v],l&&(P[m]=l[v]);for(d=new Map,p=new Array(m+1),o=m;o>=$;o--)D=u[o],c=d.get(D),p[o]=c===void 0?-1:c,d.set(D,o);for(c=$;c<=v;c++)D=n[c],o=d.get(D),o!==void 0&&o!==-1?(g[o]=i[c],M[o]=s[c],l&&(P[o]=l[c]),o=p[o],d.set(D,o)):s[c]();for(o=$;oe(t||{}))}const Vt=e=>`Stale read from <${e}>.`;function Vr(e){const t="fallback"in e&&{fallback:()=>e.fallback};return q(Zt(()=>e.each,e.children,t||void 0))}function oe(e){const t=e.keyed,r=q(()=>e.when,void 0,void 0),n=t?r:q(r,void 0,{equals:(i,s)=>!i==!s});return q(()=>{const i=n();if(i){const s=e.children;return typeof s=="function"&&s.length>0?H(()=>s(t?i:()=>{if(!H(n))throw Vt("Show");return r()})):s}return e.fallback},void 0,void 0)}function Kt(e,t,r){let n=r.length,i=t.length,s=n,a=0,l=0,u=t[i-1].nextSibling,f=null;for(;ac-l){const p=t[a];for(;l{i=s,t===document?e():k(t,e(),t.firstChild?null:void 0,r)},n.owner),()=>{i(),t.textContent=""}}function V(e,t,r,n){let i;const s=()=>{const l=document.createElement("template");return l.innerHTML=e,r?l.content.firstChild.firstChild:l.content.firstChild},a=t?()=>H(()=>document.importNode(i||(i=s()),!0)):()=>(i||(i=s())).cloneNode(!0);return a.cloneNode=a,a}function Wt(e,t=window.document){const r=t[We]||(t[We]=new Set);for(let n=0,i=e.length;ne(t,r))}function k(e,t,r,n){if(r!==void 0&&!n&&(n=[]),typeof t!="function")return ge(e,t,n,r);W(i=>ge(e,t(),i,r),n)}function qe(e,t,r){const n=t.trim().split(/\s+/);for(let i=0,s=n.length;iObject.defineProperty(e,"target",{configurable:!0,value:u}),a=()=>{const u=t[r];if(u&&!t.disabled){const f=t[`${r}Data`];if(f!==void 0?u.call(t,f,e):u.call(t,e),e.cancelBubble)return}return t.host&&typeof t.host!="string"&&!t.host._$host&&t.contains(e.target)&&s(t.host),!0},l=()=>{for(;a()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return t||document}}),e.composedPath){const u=e.composedPath();s(u[0]);for(let f=0;f{let l=t();for(;typeof l=="function";)l=l();r=ge(e,l,r,n)}),()=>r;if(Array.isArray(t)){const l=[],u=r&&Array.isArray(r);if(Ae(l,t,r,i))return W(()=>r=ge(e,l,r,n,!0)),()=>r;if(l.length===0){if(r=Y(e,r,n),a)return r}else u?r.length===0?Ge(e,l,n):Kt(e,r,l):(r&&Y(e),Ge(e,l));r=l}else if(t.nodeType){if(Array.isArray(r)){if(a)return r=Y(e,r,n,t);Y(e,r,null,t)}else r==null||r===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);r=t}}return r}function Ae(e,t,r,n){let i=!1;for(let s=0,a=t.length;s=0;a--){const l=t[a];if(i!==l){const u=l.parentNode===e;!s&&!a?u?e.replaceChild(i,l):e.insertBefore(i,r):u&&l.remove()}else s=!0}}else e.insertBefore(i,r);return[i]}var O=Uint8Array,te=Uint16Array,Gt=Int32Array,st=new O([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]),lt=new O([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]),Jt=new O([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),at=function(e,t){for(var r=new te(31),n=0;n<31;++n)r[n]=t+=1<>1|(b&21845)<<1;R=(R&52428)>>2|(R&13107)<<2,R=(R&61680)>>4|(R&3855)<<4,Me[b]=((R&65280)>>8|(R&255)<<8)>>1}var ie=function(e,t,r){for(var n=e.length,i=0,s=new te(t);i>u]=f}else for(l=new te(n),i=0;i>15-e[i]);return l},le=new O(288);for(var b=0;b<144;++b)le[b]=8;for(var b=144;b<256;++b)le[b]=9;for(var b=256;b<280;++b)le[b]=7;for(var b=280;b<288;++b)le[b]=8;var ut=new O(32);for(var b=0;b<32;++b)ut[b]=5;var er=ie(le,9,1),tr=ie(ut,5,1),Le=function(e){for(var t=e[0],r=1;rt&&(t=e[r]);return t},j=function(e,t,r){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(t&7)&r},Ee=function(e,t){var r=t/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(t&7)},rr=function(e){return(e+7)/8|0},nr=function(e,t,r){return(r==null||r>e.length)&&(r=e.length),new O(e.subarray(t,r))},ir=["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"],_=function(e,t,r){var n=new Error(t||ir[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,_),!r)throw n;return n},_e=function(e,t,r,n){var i=e.length,s=0;if(!i||t.f&&!t.l)return r||new O(0);var a=!r,l=a||t.i!=2,u=t.i;a&&(r=new O(i*3));var f=function(Re){var Ze=r.length;if(Re>Ze){var Ve=new O(Math.max(Ze*2,Re));Ve.set(r),r=Ve}},c=t.f||0,o=t.p||0,h=t.b||0,d=t.l,p=t.d,g=t.m,M=t.n,P=i*8;do{if(!d){c=j(e,o,1);var $=j(e,o+1,3);if(o+=3,$)if($==1)d=er,p=tr,g=9,M=5;else if($==2){var N=j(e,o,31)+257,J=j(e,o+10,15)+4,S=N+j(e,o+5,31)+1;o+=14;for(var w=new O(S),x=new O(19),C=0;C>4;if(v<16)w[C++]=v;else{var Q=0,ae=0;for(v==16?(ae=3+j(e,o,3),o+=2,Q=w[C-1]):v==17?(ae=3+j(e,o,7),o+=3):v==18&&(ae=11+j(e,o,127),o+=7);ae--;)w[C++]=Q}}var Ne=w.subarray(0,N),I=w.subarray(N);g=Le(Ne),M=Le(I),d=ie(Ne,g,1),p=ie(I,M,1)}else _(1);else{var v=rr(o)+4,m=e[v-4]|e[v-3]<<8,D=v+m;if(D>i){u&&_(0);break}l&&f(h+m),r.set(e.subarray(v,D),h),t.b=h+=m,t.p=o=D*8,t.f=c;continue}if(o>P){u&&_(0);break}}l&&f(h+131072);for(var Mt=(1<>4;if(o+=Q&15,o>P){u&&_(0);break}if(Q||_(2),X<256)r[h++]=X;else if(X==256){we=o,d=null;break}else{var ze=X-254;if(X>264){var C=X-257,ne=st[C];ze=j(e,o,(1<>4;be||_(3),o+=be&15;var I=Yt[xe];if(xe>3){var ne=lt[xe];I+=Ee(e,o)&(1<P){u&&_(0);break}l&&f(h+131072);var Fe=h+ze;if(h>3&1)+(t>>4&1);n>0;n-=!e[r++]);return r+(t&2)},ar=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},or=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&_(6,"invalid zlib data"),(e[1]>>5&1)==1&&_(6,"invalid zlib data: "+(e[1]&32?"need":"unexpected")+" dictionary"),(e[1]>>3&4)+2};function cr(e,t){return _e(e,{i:2},t,t)}function ur(e,t){var r=lr(e);return r+8>e.length&&_(6,"invalid gzip data"),_e(e.subarray(r,-8),{i:2},new O(ar(e)),t)}function fr(e,t){return _e(e.subarray(or(e),-4),{i:2},t,t)}function hr(e,t){return e[0]==31&&e[1]==139&&e[2]==8?ur(e,t):(e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31?cr(e,t):fr(e,t)}var dr=typeof TextDecoder<"u"&&new TextDecoder,gr=0;try{dr.decode(sr,{stream:!0}),gr=1}catch{}var pr=Object.defineProperty,mr=Math.pow,y=(e,t)=>pr(e,"name",{value:t,configurable:!0}),A=(e,t,r)=>new Promise((n,i)=>{var s=u=>{try{l(r.next(u))}catch(f){i(f)}},a=u=>{try{l(r.throw(u))}catch(f){i(f)}},l=u=>u.done?n(u.value):Promise.resolve(u.value).then(s,a);l((r=r.apply(e,t)).next())});y((e,t)=>{let r=!1,n="",i=L.GridLayer.extend({createTile:y((s,a)=>{let l=document.createElement("img"),u=new AbortController,f=u.signal;return l.cancel=()=>{u.abort()},r||(e.getHeader().then(c=>{c.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."):c.tileType===2?n="image/png":c.tileType===3?n="image/jpeg":c.tileType===4?n="image/webp":c.tileType===5&&(n="image/avif")}),r=!0),e.getZxy(s.z,s.x,s.y,f).then(c=>{if(c){let o=new Blob([c.data],{type:n}),h=window.URL.createObjectURL(o);l.src=h}else l.style.display="none";l.cancel=void 0,a(void 0,l)}).catch(c=>{if(c.name!=="AbortError")throw c}),l},"createTile"),_removeTile:y(function(s){let a=this._tiles[s];a&&(a.el.cancel&&a.el.cancel(),a.el.width=0,a.el.height=0,a.el.deleted=!0,L.DomUtil.remove(a.el),delete this._tiles[s],this.fire("tileunload",{tile:a.el,coords:this._keyToTileCoords(s)}))},"_removeTile")});return new i(t)},"leafletRasterLayer");var vr=y(e=>(t,r)=>{if(r instanceof AbortController)return e(t,r);let n=new AbortController;return e(t,n).then(i=>r(void 0,i.data,i.cacheControl||"",i.expires||""),i=>r(i)).catch(i=>r(i)),{cancel:y(()=>n.abort(),"cancel")}},"v3compat"),ft=class{constructor(t){this.tilev4=y((r,n)=>A(this,null,function*(){if(r.type==="json"){let d=r.url.substr(10),p=this.tiles.get(d);if(p||(p=new pe(d),this.tiles.set(d,p)),this.metadata){let M=yield p.getTileJson(r.url);return n.signal.throwIfAborted(),{data:M}}let g=yield p.getHeader();return n.signal.throwIfAborted(),(g.minLon>=g.maxLon||g.minLat>=g.maxLat)&&console.error(`Bounds of PMTiles archive ${g.minLon},${g.minLat},${g.maxLon},${g.maxLat} are not valid.`),{data:{tiles:[`${r.url}/{z}/{x}/{y}`],minzoom:g.minZoom,maxzoom:g.maxZoom,bounds:[g.minLon,g.minLat,g.maxLon,g.maxLat]}}}let i=new RegExp(/pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)/),s=r.url.match(i);if(!s)throw new Error("Invalid PMTiles protocol URL");let a=s[1],l=this.tiles.get(a);l||(l=new pe(a),this.tiles.set(a,l));let u=s[2],f=s[3],c=s[4],o=yield l.getHeader(),h=yield l?.getZxy(+u,+f,+c,n.signal);if(n.signal.throwIfAborted(),h)return{data:new Uint8Array(h.data),cacheControl:h.cacheControl,expires:h.expires};if(o.tileType===1){if(this.errorOnMissingTile)throw new Error("Tile not found.");return{data:new Uint8Array}}return{data:null}}),"tilev4"),this.tile=vr(this.tilev4),this.tiles=new Map,this.metadata=t?.metadata||!1,this.errorOnMissingTile=t?.errorOnMissingTile||!1}add(t){this.tiles.set(t.source.getKey(),t)}get(t){return this.tiles.get(t)}};y(ft,"Protocol");var Jr=ft;function ht(e,t){return(t>>>0)*4294967296+(e>>>0)}y(ht,"toNum");function dt(e,t){let r=t.buf,n=r[t.pos++],i=(n&112)>>4;if(n<128||(n=r[t.pos++],i|=(n&127)<<3,n<128)||(n=r[t.pos++],i|=(n&127)<<10,n<128)||(n=r[t.pos++],i|=(n&127)<<17,n<128)||(n=r[t.pos++],i|=(n&127)<<24,n<128)||(n=r[t.pos++],i|=(n&1)<<31,n<128))return ht(e,i);throw new Error("Expected varint not more than 10 bytes")}y(dt,"readVarintRemainder");function ee(e){let t=e.buf,r=t[e.pos++],n=r&127;return r<128||(r=t[e.pos++],n|=(r&127)<<7,r<128)||(r=t[e.pos++],n|=(r&127)<<14,r<128)||(r=t[e.pos++],n|=(r&127)<<21,r<128)?n:(r=t[e.pos],n|=(r&15)<<28,dt(n,e))}y(ee,"readVarint");function Oe(e,t,r,n,i){return i===0?n!==0?[e-1-r,e-1-t]:[r,t]:[t,r]}y(Oe,"rotate");function gt(e,t,r){if(e>26)throw new Error("Tile zoom level exceeds max safe number limit (26)");if(t>=1<=1<0;l>>=1){let u=s&l,f=a&l;n+=(3*u^f)*(1<>1;if(t>26)throw new Error("Tile zoom level exceeds max safe number limit (26)");let r=((1<(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))(wr||{});function ye(e,t){return A(this,null,function*(){if(t===1||t===0)return e;if(t===2){if(typeof globalThis.DecompressionStream>"u")return hr(new Uint8Array(e));let r=new Response(e).body;if(!r)throw new Error("Failed to read response stream");let n=r.pipeThrough(new globalThis.DecompressionStream("gzip"));return new Response(n).arrayBuffer()}throw new Error("Compression method not supported")})}y(ye,"defaultDecompress");var Ue=(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[e.Mlt=6]="Mlt",e))(Ue||{});function mt(e){return e===1?".mvt":e===2?".png":e===3?".jpg":e===4?".webp":e===5?".avif":e===6?".mlt":""}y(mt,"tileTypeExt");var br=127;function vt(e,t){let r=0,n=e.length-1;for(;r<=n;){let i=n+r>>1,s=t-e[i].tileId;if(s>0)r=i+1;else if(s<0)n=i-1;else return e[i]}return n>=0&&(e[n].runLength===0||t-e[n].tileId-1,l=/Chrome|Chromium|Edg|OPR|Brave/.test(s);this.chromeWindowsNoCache=!1,a&&l&&(this.chromeWindowsNoCache=!0)}getKey(){return this.url}setHeaders(t){this.customHeaders=t}getBytes(t,r,n,i){return A(this,null,function*(){let s,a;n?a=n:(s=new AbortController,a=s.signal);let l=new Headers(this.customHeaders);l.set("range",`bytes=${t}-${t+r-1}`);let u;this.mustReload?u="reload":this.chromeWindowsNoCache&&(u="no-store");let f=yield fetch(this.url,{signal:a,cache:u,headers:l});if(t===0&&f.status===416){let h=f.headers.get("Content-Range");if(!h||!h.startsWith("bytes */"))throw new Error("Missing content-length on 416 response");let d=+h.substr(8);f=yield fetch(this.url,{signal:a,cache:"reload",headers:{range:`bytes=0-${d-1}`}})}let c=f.headers.get("Etag");if(c!=null&&c.startsWith("W/")&&(c=null),f.status===416||i&&c&&c!==i)throw this.mustReload=!0,new ke(`Server returned non-matching ETag ${i} after one retry. Check browser extensions and servers for issues that may affect correct ETag headers.`);if(f.status>=300)throw new Error(`Bad response code: ${f.status}`);let o=f.headers.get("Content-Length");if(f.status===200&&(!o||+o>r))throw s&&s.abort(),new Error("Server returned no content-length header or content-length exceeding request. Check that your storage backend supports HTTP Byte Serving.");return{data:yield f.arrayBuffer(),etag:c||void 0,cacheControl:f.headers.get("Cache-Control")||void 0,expires:f.headers.get("Expires")||void 0}})}};y(wt,"FetchSource");var Tr=wt;function B(e,t){let r=e.getUint32(t+4,!0),n=e.getUint32(t+0,!0);return r*mr(2,32)+n}y(B,"getUint64");function bt(e,t){let r=new DataView(e),n=r.getUint8(7);if(n>3)throw new Error(`Archive is spec version ${n} but this library supports up to spec version 3`);return{specVersion:n,rootDirectoryOffset:B(r,8),rootDirectoryLength:B(r,16),jsonMetadataOffset:B(r,24),jsonMetadataLength:B(r,32),leafDirectoryOffset:B(r,40),leafDirectoryLength:B(r,48),tileDataOffset:B(r,56),tileDataLength:B(r,64),numAddressedTiles:B(r,72),numTileEntries:B(r,80),numTileContents:B(r,88),clustered:r.getUint8(96)===1,internalCompression:r.getUint8(97),tileCompression:r.getUint8(98),tileType:r.getUint8(99),minZoom:r.getUint8(100),maxZoom:r.getUint8(101),minLon:r.getInt32(102,!0)/1e7,minLat:r.getInt32(106,!0)/1e7,maxLon:r.getInt32(110,!0)/1e7,maxLat:r.getInt32(114,!0)/1e7,centerZoom:r.getUint8(118),centerLon:r.getInt32(119,!0)/1e7,centerLat:r.getInt32(123,!0)/1e7,etag:t}}y(bt,"bytesToHeader");function Pe(e){let t={buf:new Uint8Array(e),pos:0},r=ee(t),n=[],i=0;for(let s=0;s0?n[s].offset=n[s-1].offset+n[s-1].length:n[s].offset=a-1}return n}y(Pe,"deserializeIndex");var xt=class extends Error{};y(xt,"EtagMismatch");var ke=xt;function De(e,t){return A(this,null,function*(){let r=yield e.getBytes(0,16384);if(new DataView(r.data).getUint16(0,!0)!==19792)throw new Error("Wrong magic number for PMTiles archive");let n=r.data.slice(0,br),i=bt(n,r.etag),s=r.data.slice(i.rootDirectoryOffset,i.rootDirectoryOffset+i.rootDirectoryLength),a=`${e.getKey()}|${i.etag||""}|${i.rootDirectoryOffset}|${i.rootDirectoryLength}`,l=Pe(yield t(s,i.internalCompression));return[i,[a,l.length,l]]})}y(De,"getHeaderAndRoot");function Be(e,t,r,n,i){return A(this,null,function*(){let s=yield e.getBytes(r,n,void 0,i.etag),a=yield t(s.data,i.internalCompression),l=Pe(a);if(l.length===0)throw new Error("Empty directory is invalid");return l})}y(Be,"getDirectory");var $r=class{constructor(t=100,r=!0,n=ye){this.cache=new Map,this.maxCacheEntries=t,this.counter=1,this.decompress=n}getHeader(t){return A(this,null,function*(){let r=t.getKey(),n=this.cache.get(r);if(n)return n.lastUsed=this.counter++,n.data;let i=yield De(t,this.decompress);return i[1]&&this.cache.set(i[1][0],{lastUsed:this.counter++,data:i[1][2]}),this.cache.set(r,{lastUsed:this.counter++,data:i[0]}),this.prune(),i[0]})}getDirectory(t,r,n,i){return A(this,null,function*(){let s=`${t.getKey()}|${i.etag||""}|${r}|${n}`,a=this.cache.get(s);if(a)return a.lastUsed=this.counter++,a.data;let l=yield Be(t,this.decompress,r,n,i);return this.cache.set(s,{lastUsed:this.counter++,data:l}),this.prune(),l})}prune(){if(this.cache.size>this.maxCacheEntries){let t=1/0,r;this.cache.forEach((n,i)=>{n.lastUsed{De(t,this.decompress).then(l=>{l[1]&&this.cache.set(l[1][0],{lastUsed:this.counter++,data:Promise.resolve(l[1][2])}),s(l[0]),this.prune()}).catch(l=>{a(l)})});return this.cache.set(r,{lastUsed:this.counter++,data:i}),i})}getDirectory(t,r,n,i){return A(this,null,function*(){let s=`${t.getKey()}|${i.etag||""}|${r}|${n}`,a=this.cache.get(s);if(a)return a.lastUsed=this.counter++,yield a.data;let l=new Promise((u,f)=>{Be(t,this.decompress,r,n,i).then(c=>{u(c),this.prune()}).catch(c=>{f(c)})});return this.cache.set(s,{lastUsed:this.counter++,data:l}),l})}prune(){if(this.cache.size>=this.maxCacheEntries){let t=1/0,r;this.cache.forEach((n,i)=>{n.lastUsed{this.getHeader(t).then(a=>{i(),this.invalidations.delete(r)}).catch(a=>{s(a)})});this.invalidations.set(r,n)})}};y(Tt,"SharedPromiseCache");var Lr=Tt,$t=class{constructor(t,r,n){typeof t=="string"?this.source=new Tr(t):this.source=t,n?this.decompress=n:this.decompress=ye,r?this.cache=r:this.cache=new Lr}getHeader(){return A(this,null,function*(){return yield this.cache.getHeader(this.source)})}getZxyAttempt(t,r,n,i){return A(this,null,function*(){let s=gt(t,r,n),a=yield this.cache.getHeader(this.source);if(ta.maxZoom)return;let l=a.rootDirectoryOffset,u=a.rootDirectoryLength;for(let f=0;f<=3;f++){let c=yield this.cache.getDirectory(this.source,l,u,a),o=vt(c,s);if(o){if(o.runLength>0){let h=yield this.source.getBytes(a.tileDataOffset+o.offset,o.length,i,a.etag);return{data:yield this.decompress(h.data,a.tileCompression),cacheControl:h.cacheControl,expires:h.expires}}l=a.leafDirectoryOffset+o.offset,u=o.length}else return}throw new Error("Maximum directory depth exceeded")})}getZxy(t,r,n,i){return A(this,null,function*(){try{return yield this.getZxyAttempt(t,r,n,i)}catch(s){if(s instanceof ke)return this.cache.invalidate(this.source),yield this.getZxyAttempt(t,r,n,i);throw s}})}getMetadataAttempt(){return A(this,null,function*(){let t=yield this.cache.getHeader(this.source),r=yield this.source.getBytes(t.jsonMetadataOffset,t.jsonMetadataLength,void 0,t.etag),n=yield this.decompress(r.data,t.internalCompression),i=new TextDecoder("utf-8");return JSON.parse(i.decode(n))})}getMetadata(){return A(this,null,function*(){try{return yield this.getMetadataAttempt()}catch(t){if(t instanceof ke)return this.cache.invalidate(this.source),yield this.getMetadataAttempt();throw t}})}getTileJson(t){return A(this,null,function*(){let r=yield this.getHeader(),n=yield this.getMetadata(),i=mt(r.tileType);return{tilejson:"3.0.0",scheme:"xyz",tiles:[`${t}/{z}/{x}/{y}${i}`],vector_layers:n.vector_layers,attribution:n.attribution,description:n.description,name:n.name,version:n.version,bounds:[r.minLon,r.minLat,r.maxLon,r.maxLat],center:[r.centerLon,r.centerLat,r.centerZoom],minzoom:r.minZoom,maxzoom:r.maxZoom}})}};y($t,"PMTiles");var pe=$t;class Lt{archive;constructor(t){this.archive=t}async getZxy(t,r,n){const i=await this.archive.getZxy(t,r,n);if(i)return i.data}async getBounds(){const t=await this.getHeader();return[t.minLon,t.minLat,t.maxLon,t.maxLat]}async getMaxZoom(){return(await this.getHeader()).maxZoom}async isVector(){const t=await this.getHeader();return t.tileType===Ue.Mvt||t.tileType===Ue.Mlt}async getHeader(){return await this.archive.getHeader()}async test(){await this.archive.getHeader()}async getMetadata(){return await this.archive.getMetadata()}async isOverlay(){return(await this.getMetadata()).type==="overlay"}async getVectorLayers(){return(await this.getMetadata()).vector_layers.map(r=>r.id)}}class Er extends Lt{url;constructor(t){super(new pe(t)),this.url=t}getStateUrl(){return this.url}getLocalFileName(){return""}getMaplibreSourceUrl(){return`pmtiles://${this.url}`}archiveForProtocol(){}}class Cr extends Lt{name;constructor(t){super(new pe(new xr(t))),this.name=t.name}getStateUrl(){}getLocalFileName(){return this.name}getMaplibreSourceUrl(){return`pmtiles://${this.name}`}archiveForProtocol(){return this.archive}}class Sr{url;constructor(t){this.url=t}archiveForProtocol(){}async test(){await fetch(this.url)}async getBounds(){return(await(await fetch(this.url)).json()).bounds}async getMaxZoom(){return(await(await fetch(this.url)).json()).maxzoom}getMaplibreSourceUrl(){return this.url}async isOverlay(){return!0}async isVector(){const n=(await(await fetch(this.url)).json()).tiles[0],i=new URL(n).pathname;return i.endsWith(".pbf")||i.endsWith(".mvt")||i.endsWith(".mlt")}getStateUrl(){return this.url}getLocalFileName(){return""}async getZxy(t,r,n){const l=(await(await fetch(this.url)).json()).tiles[0].replace("{z}",t).replace("{x}",r).replace("{y}",n);return await(await fetch(l)).arrayBuffer()}async getMetadata(){return await(await fetch(this.url)).json()}async getVectorLayers(){return(await this.getMetadata()).vector_layers.map(r=>r.id)}}const Et=e=>new URL(e).pathname.endsWith(".json")?new Sr(e):new Er(e),Ct=e=>new Cr(e);function Ar(e){for(var t=e.length/6|0,r=new Array(t),n=0;ns!==void 0).map(([i,s])=>`${i}=${s}`).join("&")}`}function ln(e){const t=e.split("/");if(t.length===3)return t.map(r=>+r)}function an(e,t){const r=[`zxy=${t[0]}/${t[1]}/${t[2]}`];return e&&r.push(`url=${e}`),`/tile/#${r.join("&")}`}function on(e,t=2){if(!+e)return"0 Bytes";const r=1024,n=t<0?0:t,i=["Bytes","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],s=Math.floor(Math.log(e)/Math.log(r));return`${Number.parseFloat((e/r**s).toFixed(n))} ${i[s]}`}var _r=V('
Load an example:
Drag and drop a local file here'),Or=V(''),Pr=V(''),Dr=V('
'),jr=V('