mirror of
https://github.com/protomaps/PMTiles.git
synced 2026-02-04 02:41:09 +00:00
2 lines
38 KiB
JavaScript
2 lines
38 KiB
JavaScript
(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;i<e.observers.length;i+=1){const s=e.observers[i],a=$e&&$e.running;a&&$e.disposed.has(s),(a?!s.tState:!s.state)&&(s.pure?U.push(s):z.push(s),s.observers&&rt(s)),a||(s.state=F)}if(U.length>1e6)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<me);)e.state&&t.push(e);for(let r=t.length-1;r>=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<e.length;t++)he(e[t])}function It(e){let t,r=0;for(t=0;t<e.length;t++){const n=e[t];n.user?e[r++]=n:he(n)}for(t=0;t<r;t++)he(e[t])}function de(e,t){e.state=0;for(let r=0;r<e.sources.length;r+=1){const n=e.sources[r];if(n.sources){const i=n.state;i===F?n!==t&&(!n.updatedAt||n.updatedAt<me)&&he(n):i===fe&&de(n,t)}}}function rt(e){for(let t=0;t<e.observers.length;t+=1){const r=e.observers[t];r.state||(r.state=fe,r.pure?U.push(r):z.push(r),r.observers&&rt(r))}}function se(e){let t;if(e.sources)for(;e.sources.length;){const r=e.sources.pop(),n=e.sourceSlots.pop(),i=r.observers;if(i&&i.length){const s=i.pop(),a=r.observerSlots.pop();n<i.length&&(s.sourceSlots[a]=n,i[n]=s,r.observerSlots[n]=a)}}if(e.tOwned){for(t=e.tOwned.length-1;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;t<e.length;t++)e[t]()}function Zt(e,t,r={}){let n=[],i=[],s=[],a=0,l=t.length>1?[]: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<f;o++)n[o]=u[o],i[o]=ce(h);a=f}else{for(g=new Array(f),M=new Array(f),l&&(P=new Array(f)),$=0,v=Math.min(a,f);$<v&&n[$]===u[$];$++);for(v=a-1,m=f-1;v>=$&&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=$;o<f;o++)o in g?(i[o]=g[o],s[o]=M[o],l&&(l[o]=P[o],l[o](o))):i[o]=ce(h);i=i.slice(0,a=f),n=u.slice(0)}return i});function h(d){if(s[o]=d,l){const[p,g]=Z(o);return l[o]=g,t(u[o],p)}return t(u[o])}}}function K(e,t){return H(()=>e(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(;a<i||l<s;){if(t[a]===r[l]){a++,l++;continue}for(;t[i-1]===r[s-1];)i--,s--;if(i===a){const c=s<n?l?r[l-1].nextSibling:r[s-l]:u;for(;l<s;)e.insertBefore(r[l++],c)}else if(s===l)for(;a<i;)(!f||!f.has(t[a]))&&t[a].remove(),a++;else if(t[a]===r[s-1]&&r[l]===t[i-1]){const c=t[--i].nextSibling;e.insertBefore(r[l++],t[a++].nextSibling),e.insertBefore(r[--s],c),t[i]=r[s]}else{if(!f){f=new Map;let o=l;for(;o<s;)f.set(r[o],o++)}const c=f.get(t[a]);if(c!=null)if(l<c&&c<s){let o=a,h=1,d;for(;++o<i&&o<s&&!((d=f.get(t[o]))==null||d!==c+h);)h++;if(h>c-l){const p=t[a];for(;l<c;)e.insertBefore(r[l++],p)}else e.replaceChild(r[l++],t[a++])}else a++;else t[a++].remove()}}}const We="_$DX_DELEGATE";function Kr(e,t,r,n={}){let i;return ce(s=>{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;n<i;n++){const s=e[n];r.has(s)||(r.add(s),t.addEventListener(s,qt))}}function it(e,t,r){r==null?e.removeAttribute(t):e.setAttribute(t,r)}function Wr(e,t,r={}){const n=Object.keys(t||{}),i=Object.keys(r);let s,a;for(s=0,a=i.length;s<a;s++){const l=i[s];!l||l==="undefined"||t[l]||(qe(e,l,!1),delete r[l])}for(s=0,a=n.length;s<a;s++){const l=n[s],u=!!t[l];!l||l==="undefined"||r[l]===u||!u||(qe(e,l,!0),r[l]=u)}return r}function qr(e,t,r){return H(()=>e(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;i<s;i++)e.classList.toggle(n[i],r)}function qt(e){let t=e.target;const r=`$$${e.type}`,n=e.target,i=e.currentTarget,s=u=>Object.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<u.length-2&&(t=u[f],!!a());f++){if(t._$host){t=t._$host,l();break}if(t.parentNode===i)break}}else l();s(n)}function ge(e,t,r,n,i){for(;typeof r=="function";)r=r();if(t===r)return r;const s=typeof t,a=n!==void 0;if(e=a&&r[0]&&r[0].parentNode||e,s==="string"||s==="number"){if(s==="number"&&(t=t.toString(),t===r))return r;if(a){let l=r[0];l&&l.nodeType===3?l.data!==t&&(l.data=t):l=document.createTextNode(t),r=Y(e,r,n,l)}else r!==""&&typeof r=="string"?r=e.firstChild.data=t:r=e.textContent=t}else if(t==null||s==="boolean")r=Y(e,r,n);else{if(s==="function")return W(()=>{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<a;s++){let l=t[s],u=r&&r[e.length],f;if(!(l==null||l===!0||l===!1))if((f=typeof l)=="object"&&l.nodeType)e.push(l);else if(Array.isArray(l))i=Ae(e,l,u)||i;else if(f==="function")if(n){for(;typeof l=="function";)l=l();i=Ae(e,Array.isArray(l)?l:[l],Array.isArray(u)?u:[u])||i}else e.push(l),i=!0;else{const c=String(l);u&&u.nodeType===3&&u.data===c?e.push(u):e.push(document.createTextNode(c))}}return i}function Ge(e,t,r=null){for(let n=0,i=t.length;n<i;n++)e.insertBefore(t[n],r)}function Y(e,t,r,n){if(r===void 0)return e.textContent="";const i=n||document.createTextNode("");if(t.length){let s=!1;for(let a=t.length-1;a>=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<<e[n-1];for(var i=new Gt(r[30]),n=1;n<30;++n)for(var s=r[n];s<r[n+1];++s)i[s]=s-r[n]<<5|n;return{b:r,r:i}},ot=at(st,2),ct=ot.b,Qt=ot.r;ct[28]=258,Qt[258]=28;var Xt=at(lt,0),Yt=Xt.b,Me=new te(32768);for(var b=0;b<32768;++b){var R=(b&43690)>>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<n;++i)e[i]&&++s[e[i]-1];var a=new te(t);for(i=1;i<t;++i)a[i]=a[i-1]+s[i-1]<<1;var l;if(r){l=new te(1<<t);var u=15-t;for(i=0;i<n;++i)if(e[i])for(var f=i<<4|e[i],c=t-e[i],o=a[e[i]-1]++<<c,h=o|(1<<c)-1;o<=h;++o)l[Me[o]>>u]=f}else for(l=new te(n),i=0;i<n;++i)e[i]&&(l[i]=Me[a[e[i]-1]++]>>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;r<e.length;++r)e[r]>t&&(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<J;++C)x[Jt[C]]=j(e,o+C*3,7);o+=J*3;for(var je=Le(x),St=(1<<je)-1,At=ie(x,je,1),C=0;C<S;){var He=At[j(e,o,St)];o+=He&15;var v=He>>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<<g)-1,Ut=(1<<M)-1,we=o;;we=o){var Q=d[Ee(e,o)&Mt],X=Q>>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<<ne)-1)+ct[C],o+=ne}var be=p[Ee(e,o)&Ut],xe=be>>4;be||_(3),o+=be&15;var I=Yt[xe];if(xe>3){var ne=lt[xe];I+=Ee(e,o)&(1<<ne)-1,o+=ne}if(o>P){u&&_(0);break}l&&f(h+131072);var Fe=h+ze;if(h<I){var Ie=s-I,kt=Math.min(I,Fe);for(Ie+h<0&&_(3);h<kt;++h)r[h]=n[Ie+h]}for(;h<Fe;++h)r[h]=r[h-I]}}t.l=d,t.p=we,t.b=h,t.f=c,d&&(c=1,t.m=g,t.d=p,t.n=M)}while(!c);return h!=r.length&&a?nr(r,0,h):r.subarray(0,h)},sr=new O(0),lr=function(e){(e[0]!=31||e[1]!=139||e[2]!=8)&&_(6,"invalid gzip data");var t=e[3],r=10;t&4&&(r+=(e[10]|e[11]<<8)+2);for(var n=(t>>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<<e||r>=1<<e)throw new Error("tile x/y outside zoom level bounds");let n=((1<<e)*(1<<e)-1)/3,i=e-1,[s,a]=[t,r];for(let l=1<<i;l>0;l>>=1){let u=s&l,f=a&l;n+=(3*u^f)*(1<<i),[s,a]=Oe(l,s,a,u,f),i--}return n}y(gt,"zxyToTileId");function pt(e){let t=3*e+1;return t<4294967296?31-Math.clz32(t):63-Math.clz32(t/4294967296)}y(pt,"tileIdToZ");function yr(e){let t=pt(e)>>1;if(t>26)throw new Error("Tile zoom level exceeds max safe number limit (26)");let r=((1<<t)*(1<<t)-1)/3,n=e-r,i=0,s=0,a=1<<t;for(let l=1;l<a;l<<=1){let u=l&n/2,f=l&(n^u);[i,s]=Oe(l,i,s,u,f),n=n/2,i+=u,s+=f}return[t,i,s]}y(yr,"tileIdToZxy");var wr=(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))(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<e[n].runLength)?e[n]:null}y(vt,"findTile");var yt=class{constructor(t){this.file=t}getKey(){return this.file.name}getBytes(t,r){return A(this,null,function*(){return{data:yield this.file.slice(t,t+r).arrayBuffer()}})}};y(yt,"FileSource");var xr=yt,wt=class{constructor(t,r=new Headers){var n,i;this.url=t,this.customHeaders=r,this.mustReload=!1;let s="";"navigator"in globalThis&&(s=(i=(n=globalThis.navigator)==null?void 0:n.userAgent)!=null?i:"");let a=s.indexOf("Windows")>-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;s<r;s++){let a=ee(t);n.push({tileId:i+a,offset:0,length:0,runLength:1}),i+=a}for(let s=0;s<r;s++)n[s].runLength=ee(t);for(let s=0;s<r;s++)n[s].length=ee(t);for(let s=0;s<r;s++){let a=ee(t);a===0&&s>0?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<t&&(t=n.lastUsed,r=i)}),r&&this.cache.delete(r)}}invalidate(t){return A(this,null,function*(){this.cache.delete(t.getKey())})}};y($r,"ResolvedValueCache");var Tt=class{constructor(t=100,r=!0,n=ye){this.cache=new Map,this.invalidations=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++,yield n.data;let i=new Promise((s,a)=>{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<t&&(t=n.lastUsed,r=i)}),r&&this.cache.delete(r)}}invalidate(t){return A(this,null,function*(){let r=t.getKey();if(this.invalidations.get(r))return yield this.invalidations.get(r);this.cache.delete(t.getKey());let n=new Promise((i,s)=>{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(t<a.minZoom||t>a.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;n<t;)r[n]="#"+e.slice(n*6,++n*6);return r}const Mr=Ar("8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f"),Ur="9598b8a".substr(0,8);function nn(e){return Mr[e%12]}function kr(e){const t={};for(const r of e.replace("#","").split("&")){const n=r.split("=");t[n[0]]=n[1]}return t}function sn(e,t){const n={...kr(e),...t};return`#${Object.entries(n).filter(([i,s])=>s!==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('<div class="h-full flex items-center justify-center p-4"><div><div class="mb-2 app-text-light">Load an example:</div><div class="app-border divide-y"><button class="block p-2 flex text-left flex-col hover:bg-slate dark:hover:bg-purple w-full cursor-pointer"type=button><div>v4.pmtiles</div><div class="text-xs app-text-light">vector basemap, Protomaps daily build channel (OpenStreetMap data)</div></button><button class="block p-2 flex text-left flex-col hover:bg-slate dark:hover:bg-purple w-full cursor-pointer"type=button><div>flowers.pmtiles</div><div class="text-xs app-text-light">raster overlay, aerial orthomosaic</div></button><button class="block p-2 flex text-left flex-col hover:bg-slate dark:hover:bg-purple w-full cursor-pointer"type=button><div>places.pmtiles</div><div class="text-xs app-text-light">vector overlay, Overture Places, 2025-04-23 release</div></button><button class="block p-2 flex text-left flex-col hover:bg-slate dark:hover:bg-purple app-bg-hover w-full cursor-pointer"type=button><div>tilezen.pmtiles</div><div class="text-xs app-text-light">vector basemap, 2019 Mapzen Tiles (legacy)</div></button></div><input class="text-left mt-4 px-4 py-2 btn-primary cursor-pointer rounded w-full"type=file><div class="mt-2 app-text-light">Drag and drop a local file here'),Or=V('<a class="py-2 px-4">'),Pr=V('<span class="flex-1 app-well rounded px-2 m-1 text-sm">'),Dr=V('<button type=button class="mr-2 text-sm px-2 btn-secondary cursor-pointer">clear'),Br=V('<div class="flex-none flex items-center px-4 md:px-0 pt-4 md:pt-0 flex-col md:flex-row"><div class="flex items-center flex-grow flex-1"><h1 class="hidden md:inline text-xl mx-5"></h1><form class="flex flex-1 items-center"><span class="relative flex flex-1 items-center app-border"></span><button class="px-4 ml-2 btn-primary cursor-pointer"type=submit>load</button><a href=https://github.com/protomaps/PMTiles target=_blank rel=noreferrer class="hidden md:inline text-xs mx-4">@</a></form></div><div class=flex>'),jr=V('<div class="bg-red-900 px-2 py-3 flex justify-between"><span></span><span><button type=button>close'),Hr=V('<div class="flex flex-col h-dvh w-full app-bg"><div class="flex-1 overflow-auto">'),Nr=V('<input class="px-2 flex-1"type=text name=url>');const cn=e=>{const t=n=>{e.setTileset(Et(n))},r=n=>{const i=n.currentTarget.files?.[0];i&&e.setTileset(Ct(i))};return(()=>{var n=_r(),i=n.firstChild,s=i.firstChild,a=s.nextSibling,l=a.firstChild,u=l.nextSibling,f=u.nextSibling,c=f.nextSibling,o=a.nextSibling;return l.$$click=()=>{t("https://demo-bucket.protomaps.com/v4.pmtiles")},u.$$click=()=>{t("https://air.mtn.tw/flowers.pmtiles")},f.$$click=()=>{t("https://overturemaps-tiles-us-west-2-beta.s3.amazonaws.com/2025-04-23/places.pmtiles")},c.$$click=()=>{t("https://r2-public.protomaps.com/protomaps-sample-datasets/tilezen.pmtiles")},o.addEventListener("change",r),n})()};function Ce(e){const t=q(()=>{const r=e.tileset();if(r){const n=r.getStateUrl();if(n)return`#url=${n}`}return""});return(()=>{var r=Or();return k(r,()=>e.page),W(n=>{var i=!!e.selected,s=!e.selected,a=`/${e.page==="map"?"":`${e.page}/`}${t()}`;return i!==n.e&&r.classList.toggle("font-bold",n.e=i),s!==n.t&&r.classList.toggle("underline",n.t=s),a!==n.a&&it(r,"href",n.a=a),n},{e:void 0,t:void 0,a:void 0}),r})()}function un(e){const[t,r]=Z(),[n,i]=Z(!1),s=c=>{try{e.setTileset(Et(c))}catch(o){o instanceof Error&&r(o.message)}},a=c=>{r(void 0),c.preventDefault();const h=new FormData(c.target).get("url");typeof h=="string"&&h.length>0&&s(h)};Xe(async()=>{const c=e.tileset();if(c)try{await c.test()}catch(o){o instanceof Error&&r(o.message)}});const l=c=>{c.preventDefault(),i(!1),c.dataTransfer&&e.setTileset(Ct(c.dataTransfer.files[0]))},u=c=>(c.preventDefault(),i(!0),!1);let f="PMTiles viewer";return e.page==="archive"?f="PMTiles archive inspector":e.page==="tile"&&(f="PMTiles tile inspector"),(()=>{var c=Hr(),o=c.firstChild;return c.addEventListener("drop",l),c.addEventListener("dragover",u),k(c,K(oe,{get when(){return!e.iframe},get children(){var h=Br(),d=h.firstChild,p=d.firstChild,g=p.nextSibling,M=g.firstChild,P=M.nextSibling,$=P.nextSibling;$.firstChild;var v=d.nextSibling;return k(p,f),g.addEventListener("submit",a),k(M,K(oe,{get when(){return q(()=>!!e.tileset())()&&e.tileset()?.getStateUrl()===void 0},get fallback(){return(()=>{var m=Nr();return W(()=>it(m,"placeholder",`${e.pmtilesOnly?"":"TileJSON or "}.pmtiles`)),W(()=>m.value=e.tileset()?.getStateUrl()||""),m})()},get children(){var m=Pr();return k(m,()=>e.tileset()?.getLocalFileName()),m}}),null),k(M,K(oe,{get when(){return e.tileset()},get children(){var m=Dr();return m.$$click=()=>e.setTileset(void 0),m}}),null),k($,Ur,null),k(v,K(Ce,{page:"map",get selected(){return e.page==="map"},get tileset(){return e.tileset}}),null),k(v,K(Ce,{page:"archive",get selected(){return e.page==="archive"},get tileset(){return e.tileset}}),null),k(v,K(Ce,{page:"tile",get selected(){return e.page==="tile"},get tileset(){return e.tileset}}),null),h}}),o),k(c,K(oe,{get when(){return t()},get children(){var h=jr(),d=h.firstChild,p=d.nextSibling,g=p.firstChild;return k(d,t),g.$$click=()=>r(void 0),h}}),o),k(o,()=>e.children),W(h=>{var d=!!e.iframe,p=!!n();return d!==h.e&&c.classList.toggle("iframe",h.e=d),p!==h.t&&o.classList.toggle("bg-gray-600",h.t=p),h},{e:void 0,t:void 0}),c})()}Wt(["click"]);export{cn as E,un as F,wr as J,Lt as P,oe as S,mt as _,sn as a,Z as b,K as c,Wt as d,Xe as e,q as f,Jr as g,V as h,k as i,W as j,Wr as k,nn as l,zr as m,Ir as n,Fr as o,kr as p,an as q,Kr as r,it as s,Et as t,qr as u,on as v,yr as w,Vr as x,ln as z};
|