isard 1.12.0 → 1.13.0
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/CHANGELOG.md +44 -0
- package/LICENSE +1 -1
- package/README.md +14 -7
- package/dist/basemap/vectortiles.js +10 -1
- package/dist/basemap/vectortiles.js.map +1 -1
- package/dist/basemap/workerpool.d.ts +2 -2
- package/dist/basemap/workerpool.js +3 -3
- package/dist/basemap/workerpool.js.map +1 -1
- package/dist/basemap.worker.js +2 -2
- package/dist/basemap.worker.js.map +4 -4
- package/dist/engine-loader.d.ts +2 -2
- package/dist/engine-loader.js +3 -2
- package/dist/engine-loader.js.map +1 -1
- package/dist/isard_bg.wasm +0 -0
- package/dist/isard_core_bg.wasm +0 -0
- package/dist/isard_tess_bg.wasm +0 -0
- package/dist/map/engines.d.ts +1 -1
- package/dist/map/engines.js.map +1 -1
- package/dist/map/quality.d.ts +7 -0
- package/dist/map/quality.js +12 -3
- package/dist/map/quality.js.map +1 -1
- package/dist/map/workers.d.ts +4 -2
- package/dist/map/workers.js +6 -3
- package/dist/map/workers.js.map +1 -1
- package/dist/map.js +3 -3
- package/dist/map.js.map +1 -1
- package/dist/workers/basemap/protocol.d.ts +2 -0
- package/dist/workers/basemap/tiles.d.ts +2 -2
- package/package.json +1 -1
package/dist/basemap.worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ie=(e,t)=>Error(`isard: ${String(e)}: HTTP ${t}`),kt=async(e,t)=>{let n=await fetch(e,t);if(!n.ok)throw ie(e,n.status);return n};class le{capacity;evict;entries=new Map;constructor(e,t){this.capacity=e;this.evict=t}get size(){return this.entries.size}get(e){let t=this.entries.get(e);if(t!==void 0)this.entries.delete(e),this.entries.set(e,t);return t}has(e){return this.entries.has(e)}set(e,t){this.entries.delete(e),this.entries.set(e,t);for(let[n,r]of this.entries){if(this.entries.size<=this.capacity)break;this.entries.delete(n),this.evict?.(r,n)}}delete(e){return this.entries.delete(e)}values(){return this.entries.values()}clear(){this.entries.clear()}}var vt=[];var Rt=(e)=>{vt=e};var oe=(e,t={})=>{let n=String(e),r=vt.filter(([s])=>n.startsWith(s));if(r.length===0)return t;let o=new Headers(t.headers);return r.forEach(([,s])=>{Object.entries(s).forEach(([a,i])=>{o.set(a,i)})}),{...t,headers:o}};var Hn=96,Jn=(e,t,n,r,o,s)=>{let a=new Uint8ClampedArray(s*s*4),i=s/o,c=o+1;for(let l=0;l<s;l+=1){let u=(l+0.5)/i,p=Math.min(o-1,Math.floor(u)),f=u-p;for(let d=0;d<s;d+=1){let w=(d+0.5)/i,h=Math.min(o-1,Math.floor(w)),A=w-h,m=2*(p*c+h),M=m+2*c,b=(1-A)*(1-f),x=A*(1-f),T=(1-A)*f,E=A*f,_=b*r[m]+x*r[m+2]+T*r[M]+E*r[M+2],g=b*r[m+1]+x*r[m+3]+T*r[M+1]+E*r[M+3],y=_-0.5,S=g-0.5;if(!(y>-1&&S>-1&&y<t&&S<n))continue;let k=Math.floor(y),v=Math.floor(S),R=y-k,U=S-v,B=0,P=0,L=0,I=0;for(let N=0;N<4;N+=1){let W=k+(N&1),V=v+(N>>1);if(W<0||V<0||W>=t||V>=n)continue;let J=4*(V*t+W),z=(N&1?R:1-R)*(N>>1?U:1-U)*e[J+3];B+=z*e[J],P+=z*e[J+1],L+=z*e[J+2],I+=z}if(I<=0)continue;let F=4*(l*s+d);a[F]=B/I,a[F+1]=P/I,a[F+2]=L/I,a[F+3]=I}}return a},Tt=(e=Hn)=>{let t=new Map,n=new Set,r=(l)=>{n.delete(l),l.then((u)=>u?.close(),()=>{return})},o=(l)=>{if(t.has(l))n.add(l);else r(l)},s=new le(e,o),a=(l)=>{let u=(t.get(l)??1)-1;if(u>0)t.set(l,u);else if(t.delete(l),n.has(l))r(l)},i=(l)=>{let u=()=>{let f=(async()=>{let d=await fetch(l,oe(l));if(d.status===404||d.status===204||d.status===410)return null;if(!d.ok)throw ie(l,d.status);return createImageBitmap(await d.blob())})();return f.catch(()=>s.delete(l)),s.set(l,f),f},p=s.get(l)??u();return t.set(p,(t.get(p)??0)+1),p};return{draw:async(l,u)=>{let p=l.sources.map((f)=>[f,i(f.url)]);try{let f=await Promise.all(p.map(async([m,M])=>[m,await M]));if(u.throwIfAborted(),!f.some(([,m])=>m))return null;let w=new OffscreenCanvas(l.width,l.height).getContext("2d",{willReadFrequently:!0});if(!w)throw Error("isard: no 2D canvas to reproject the tiles");f.forEach(([m,M])=>{if(M)w.drawImage(M,m.x,m.y,m.w,m.h)});let h=w.getImageData(0,0,l.width,l.height).data,A=Jn(h,l.width,l.height,l.mesh,l.n,l.size);return createImageBitmap(new ImageData(A,l.size,l.size),{premultiplyAlpha:"none"})}finally{p.forEach(([,f])=>{a(f)})}},cache:s,close:()=>{[...s.values()].forEach(o),s.clear()}}};var xe=(e,t,n)=>Math.max(t,Math.min(n,e));var Ho=Math.PI/180,Et=40075016.686,Jo=Et/360;var It=(e)=>e*360-180,Ft=(e)=>Math.atan(Math.sinh(Math.PI*(1-2*e)))*180/Math.PI;var rt=(e)=>Et*Math.cos(Math.atan(Math.sinh(Math.PI*(1-2*e)))),_e=(e,t)=>rt((t+0.5)/2**e)/2**e,K=(e,t,n,r)=>e.replaceAll("{z}",String(t)).replaceAll("{x}",String(n)).replaceAll("{y}",String(r));var fe=256,jn=(e,t,n=Number.NEGATIVE_INFINITY)=>{let r=e.length>>2,o=new Float32Array(r);if(t==="terrarium")for(let s=0,a=0;s<r;s+=1,a+=4){let i=e[a]*256+e[a+1]+e[a+2]/256-32768;o[s]=i>n?i:n}else for(let s=0,a=0;s<r;s+=1,a+=4){let i=-1e4+(e[a]*65536+e[a+1]*256+e[a+2])*0.1;o[s]=i>n?i:n}return o},Nt=async(e,t,n,r,o)=>{let s=await fetch(e,oe(e,{signal:r}));if(s.status===404||s.status===204||s.status===410)return null;if(!s.ok)throw ie(e,s.status);let a=await createImageBitmap(await s.blob(),{premultiplyAlpha:"none",colorSpaceConversion:"none"});try{o.canvas??=new OffscreenCanvas(fe,fe);let i=o.canvas.getContext("2d",{willReadFrequently:!0});if(!i)throw Error("isard: no 2D context");return i.imageSmoothingEnabled=!1,i.clearRect(0,0,fe,fe),i.drawImage(a,0,0,fe,fe),jn(i.getImageData(0,0,fe,fe).data,t,n)}finally{a.close()}};var qn="aliceblue f0f8ff antiquewhite faebd7 aqua 00ffff aquamarine 7fffd4 azure f0ffff beige f5f5dc bisque ffe4c4 black 000000 blanchedalmond ffebcd blue 0000ff blueviolet 8a2be2 brown a52a2a burlywood deb887 cadetblue 5f9ea0 chartreuse 7fff00 chocolate d2691e coral ff7f50 cornflowerblue 6495ed cornsilk fff8dc crimson dc143c cyan 00ffff darkblue 00008b darkcyan 008b8b darkgoldenrod b8860b darkgray a9a9a9 darkgreen 006400 darkgrey a9a9a9 darkkhaki bdb76b darkmagenta 8b008b darkolivegreen 556b2f darkorange ff8c00 darkorchid 9932cc darkred 8b0000 darksalmon e9967a darkseagreen 8fbc8f darkslateblue 483d8b darkslategray 2f4f4f darkslategrey 2f4f4f darkturquoise 00ced1 darkviolet 9400d3 deeppink ff1493 deepskyblue 00bfff dimgray 696969 dimgrey 696969 dodgerblue 1e90ff firebrick b22222 floralwhite fffaf0 forestgreen 228b22 fuchsia ff00ff gainsboro dcdcdc ghostwhite f8f8ff gold ffd700 goldenrod daa520 gray 808080 green 008000 greenyellow adff2f grey 808080 honeydew f0fff0 hotpink ff69b4 indianred cd5c5c indigo 4b0082 ivory fffff0 khaki f0e68c lavender e6e6fa lavenderblush fff0f5 lawngreen 7cfc00 lemonchiffon fffacd lightblue add8e6 lightcoral f08080 lightcyan e0ffff lightgoldenrodyellow fafad2 lightgray d3d3d3 lightgreen 90ee90 lightgrey d3d3d3 lightpink ffb6c1 lightsalmon ffa07a lightseagreen 20b2aa lightskyblue 87cefa lightslategray 778899 lightslategrey 778899 lightsteelblue b0c4de lightyellow ffffe0 lime 00ff00 limegreen 32cd32 linen faf0e6 magenta ff00ff maroon 800000 mediumaquamarine 66cdaa mediumblue 0000cd mediumorchid ba55d3 mediumpurple 9370db mediumseagreen 3cb371 mediumslateblue 7b68ee mediumspringgreen 00fa9a mediumturquoise 48d1cc mediumvioletred c71585 midnightblue 191970 mintcream f5fffa mistyrose ffe4e1 moccasin ffe4b5 navajowhite ffdead navy 000080 oldlace fdf5e6 olive 808000 olivedrab 6b8e23 orange ffa500 orangered ff4500 orchid da70d6 palegoldenrod eee8aa palegreen 98fb98 paleturquoise afeeee palevioletred db7093 papayawhip ffefd5 peachpuff ffdab9 peru cd853f pink ffc0cb plum dda0dd powderblue b0e0e6 purple 800080 rebeccapurple 663399 red ff0000 rosybrown bc8f8f royalblue 4169e1 saddlebrown 8b4513 salmon fa8072 sandybrown f4a460 seagreen 2e8b57 seashell fff5ee sienna a0522d silver c0c0c0 skyblue 87ceeb slateblue 6a5acd slategray 708090 slategrey 708090 snow fffafa springgreen 00ff7f steelblue 4682b4 tan d2b48c teal 008080 thistle d8bfd8 tomato ff6347 turquoise 40e0d0 violet ee82ee wheat f5deb3 white ffffff whitesmoke f5f5f5 yellow ffff00 yellowgreen 9acd32",ot,$n=(e)=>{if(!ot){let t=qn.split(" ");ot=new Map(Array.from({length:Math.floor(t.length/2)},(n,r)=>[t[2*r]??"",t[2*r+1]??""]))}return ot.get(e)},ze=(e)=>Number.isFinite(e)?xe(e,0,1):0,Ot=(e)=>{if(!/^[0-9a-f]+$/.test(e)||![3,4,6,8].includes(e.length))return;let t=e.length<=4?[...e].map((r)=>r+r).join(""):e,n=(r)=>Number.parseInt(t.slice(r,r+2),16)/255;return[n(0),n(2),n(4),t.length===8?n(6):1]},Yn=(e)=>{if(e===void 0)return 1;return ze(e.endsWith("%")?Number.parseFloat(e)/100:Number.parseFloat(e))},Gn=(e,t,n)=>{let r=n<0.5?n*(1+t):n+t-n*t,o=2*n-r,s=(a)=>{let i=(a%1+1)%1;if(i<0.16666666666666666)return o+(r-o)*6*i;if(i<0.5)return r;if(i<0.6666666666666666)return o+(r-o)*(0.6666666666666666-i)*6;return o};return[s(e+0.3333333333333333),s(e),s(e-0.3333333333333333)]},Pt=(e)=>{if(typeof e!=="string")return;let t=e.trim().toLowerCase();if(t.startsWith("#"))return Ot(t.slice(1));if(t==="transparent")return[0,0,0,0];let n=$n(t);if(n)return Ot(n);let r=/^(rgba?|hsla?)\(([^)]*)\)$/.exec(t);if(!r?.[1]||r[2]===void 0)return;let o=r[2].split(/[\s,/]+/).filter(Boolean);if(o.length<3||o.slice(0,3).some((u)=>Number.isNaN(Number.parseFloat(u))))return;let s=Yn(o[3]);if(r[1].startsWith("rgb")){let u=(p)=>ze(p.endsWith("%")?Number.parseFloat(p)/100:Number.parseFloat(p)/255);return[u(o[0]??""),u(o[1]??""),u(o[2]??""),s]}let a=Number.parseFloat(o[0]??"")/360,[i,c,l]=Gn(a,ze(Number.parseFloat(o[1]??"")/100),ze(Number.parseFloat(o[2]??"")/100));return[i,c,l,s]};var be=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);var Kn=["Unknown","Point","LineString","Polygon"],Z=(e,t)=>({zoom:t,properties:e.properties,type:Kn[e.type]??"Unknown"}),ce=(e)=>Pt(e),Je=([e,t,n,r])=>`rgba(${Math.round(e*255)},${Math.round(t*255)},${Math.round(n*255)},${r})`,Wt=(e,t,n,r=1)=>{let o=n-t;if(o===0)return 0;let s=e-t;return r===1?s/o:(r**s-1)/(r**o-1)},it=(e,t,n)=>{if(typeof e==="number"&&typeof t==="number")return e+(t-e)*n;let r=ce(e),o=ce(t);if(r&&o){let s=(a)=>r[a]+(o[a]-r[a])*n;return Je([s(0),s(1),s(2),s(3)])}if(Array.isArray(e)&&Array.isArray(t))return e.map((s,a)=>it(s,t[a],n));return n<0.5?e:t},Dt=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e)&&Array.isArray(e.stops),Zn=(e,t)=>{let n=e.property===void 0?t.zoom:t.properties[e.property],r=e.stops,o=e.type??(e.property===void 0||typeof r[0]?.[0]==="number"?"exponential":"categorical");if(o==="identity")return n??e.default;if(o==="categorical")return r.find(([u])=>u===n)?.[1]??e.default;if(typeof n!=="number"||!r.length)return e.default??r[0]?.[1];let s=([u])=>{if(Array.isArray(u))return Number.NaN;return be(u)?Number(u.zoom):Number(u)},a=r[0];if(!a)return e.default;if(n<=s(a))return a[1];let i=r.findIndex((u,p)=>p>0&&Boolean(r[p-1])&&Boolean(u)&&n<s(u)),[c,l]=[r[i-1],r[i]];if(i<0||!c||!l)return r.at(-1)?.[1];if(o==="interval")return c[1];return it(c[1],l[1],Wt(n,s(c),s(l),e.base??1))},st=(e)=>e,Lt={"<":(e,t)=>e<t,"<=":(e,t)=>e<=t,">":(e,t)=>e>t,">=":(e,t)=>e>=t},Bt=(e,t,n)=>{let r=(a)=>typeof a==="object"&&a!==null?String(a):a,[o,s]=[r(t),r(n)];return typeof o==="string"&&typeof s==="string"?Lt[e](o,s):Lt[e](Number(o),Number(s))},He=(e,t)=>{if(t==="$type")return e.type;return typeof t==="string"?e.properties[t]:void 0},Xn=new Set(["literal","zoom","get","has","!has","properties","id","geometry-type","concat","format","image","number-format","to-number","to-string","to-boolean","to-color","number","string","boolean","typeof","length","at","upcase","downcase","coalesce","!","all","any","==","!=","<","<=",">",">=","in","case","match","step","interpolate","interpolate-hcl","interpolate-lab","rgb","rgba","+","-","*","/","%","^","min","max","abs","round","floor","ceil","sqrt","ln","log10","log2","pi","e"]),ve=(e)=>Array.isArray(e)&&typeof e[0]==="string"&&Xn.has(e[0]),Ut=new Set,ke=(e)=>e===void 0||e===null?"":String(e),ae=(e,t)=>{if(Dt(e))return Zn(e,t);if(!Array.isArray(e))return e;let[n,...r]=e;if(typeof n!=="string")return e;let o=(i)=>ae(r[i]??null,t),s=(i)=>Number(o(i)),a=()=>r.map((i,c)=>s(c));switch(n){case"literal":return r[0];case"zoom":return t.zoom;case"get":return He(t,o(0));case"has":return He(t,o(0))!==void 0;case"!has":return He(t,o(0))===void 0;case"properties":return t.properties;case"id":return null;case"geometry-type":return t.type;case"concat":return r.map((i,c)=>ke(o(c))).join("");case"format":return r.map((i,c)=>i!==null&&typeof i==="object"&&!Array.isArray(i)?"":ke(o(c))).join("");case"image":return o(0);case"number-format":{let i=be(r[1])?r[1]:{},c=(u)=>{let p=i[u];return typeof p==="number"?p:void 0},l=s(0);if(!Number.isFinite(l))return"";return l.toLocaleString(typeof i.locale==="string"?i.locale:void 0,{minimumFractionDigits:c("min-fraction-digits"),maximumFractionDigits:c("max-fraction-digits")})}case"to-number":{for(let i=0;i<r.length;i+=1){let c=o(i),l=typeof c==="string"&&c.trim()===""?Number.NaN:Number(c);if(c!==null&&c!==void 0&&!Number.isNaN(l))return l}return 0}case"to-string":return ke(o(0));case"to-boolean":{let i=o(0);return!(i===""||i===0||i===!1||i===null||i===void 0||Number.isNaN(i))}case"to-color":case"number":case"string":case"boolean":{let i={"to-color":(c)=>ce(c)!==void 0,number:(c)=>typeof c==="number",string:(c)=>typeof c==="string",boolean:(c)=>typeof c==="boolean"};for(let c=0;c<r.length;c+=1){let l=o(c);if(i[n]?.(l))return l}return r.length?o(r.length-1):null}case"typeof":{let i=o(0);if(i===null||i===void 0)return"null";return Array.isArray(i)?"array":typeof i}case"length":{let i=o(0);return typeof i==="string"||Array.isArray(i)?i.length:0}case"at":{let i=o(1);return Array.isArray(i)?i[s(0)]??null:null}case"upcase":return ke(o(0)).toUpperCase();case"downcase":return ke(o(0)).toLowerCase();case"coalesce":for(let i=0;i<r.length;i+=1){let c=o(i);if(c!==void 0&&c!==null)return c}return null;case"!":return!o(0);case"all":return r.every((i,c)=>Boolean(o(c)));case"any":return r.some((i,c)=>Boolean(o(c)));case"==":return o(0)===o(1);case"!=":return o(0)!==o(1);case"<":case"<=":case">":case">=":return Bt(n,o(0),o(1));case"in":{let i=o(1),c=o(0);if(typeof i==="string")return i.includes(String(c));return Array.isArray(i)&&i.includes(c)}case"case":{let i=r.findIndex((c,l)=>l%2===0&&l+1<r.length&&Boolean(o(l)));return i<0?o(r.length-1):o(i+1)}case"match":{let i=o(0),c=r.findIndex((l,u)=>u%2===1&&u+1<r.length&&(Array.isArray(l)?st(l).includes(i):l===i));return c<0?o(r.length-1):o(c+1)}case"step":{let i=s(0),c=o(1);for(let l=2;l+1<r.length;l+=2)if(i>=Number(r[l]))c=o(l+1);else break;return c}case"interpolate":case"interpolate-hcl":case"interpolate-lab":{let i=r[0],c=s(1),l=Array.isArray(i)&&i[0]==="exponential"?Number(i[1]):1,u=Array.from({length:Math.floor((r.length-2)/2)},(h,A)=>[Number(r[2+2*A]),r[3+2*A]??null]),p=u[0];if(!p)return null;if(c<=p[0])return ae(p[1],t);let f=u.findIndex((h,A)=>A>0&&c<h[0]),[d,w]=[u[f-1],u[f]];if(f<0||!d||!w)return ae(u.at(-1)?.[1]??null,t);return it(ae(d[1],t),ae(w[1],t),Wt(c,d[0],w[0],l))}case"rgb":case"rgba":return Je([s(0)/255,s(1)/255,s(2)/255,r.length>3?s(3):1]);case"+":return a().reduce((i,c)=>i+c,0);case"*":return a().reduce((i,c)=>i*c,1);case"-":return r.length===1?-s(0):s(0)-s(1);case"/":return s(0)/s(1);case"%":return s(0)%s(1);case"^":return s(0)**s(1);case"min":return Math.min(...a());case"max":return Math.max(...a());case"abs":return Math.abs(s(0));case"round":return Math.sign(s(0))*Math.round(Math.abs(s(0)));case"floor":return Math.floor(s(0));case"ceil":return Math.ceil(s(0));case"sqrt":return Math.sqrt(s(0));case"ln":return Math.log(s(0));case"log10":return Math.log10(s(0));case"log2":return Math.log2(s(0));case"pi":return Math.PI;case"e":return Math.E;default:if(!Ut.has(n))Ut.add(n),console.warn(`isard: the style expression "${n}" is not supported`);return null}},Qn=new Set(["==","!=","<","<=",">",">="]),je=(e)=>{if(e.type==="line")return"line";if(e.type==="fill-extrusion")return"extrusion";if(e.type==="circle")return"circle";return e.type==="fill"||e.type==="background"?"fill":void 0},er=(e)=>{let[t,n,...r]=e;if(typeof t!=="string"||typeof n!=="string"||r.some(Array.isArray))return!1;if(Qn.has(t))return e.length===3;if(t==="in")return e.length!==3||!Array.isArray(e[2]);return t==="!in"||t==="has"||t==="!has"},tr=(e,t)=>{let[n,r,...o]=e,s=He(t,r);switch(n){case"==":return s===o[0];case"!=":return s!==o[0];case"<":case"<=":case">":case">=":return Bt(n,s,o[0]);case"in":return st(o).includes(s);case"!in":return!st(o).includes(s);case"has":return s!==void 0;case"!has":return s===void 0;default:return!0}},Ct=new WeakMap,Vt=(e)=>{if(!Array.isArray(e))return()=>Boolean(e);let t=Ct.get(e);if(t)return t;let r=(()=>{let o=e[0];if(o==="all"||o==="any"||o==="none"){let s=e.slice(1).map(Vt);if(o==="all")return(a)=>s.every((i)=>i(a));if(o==="any")return(a)=>s.some((i)=>i(a));return(a)=>!s.some((i)=>i(a))}if(er(e))return(s)=>tr(e,s);return(s)=>Boolean(ae(e,s))})();return Ct.set(e,r),r},Q=(e,t)=>{if(e===void 0||e===null)return!0;return Vt(e)(t)},at=(e)=>Array.isArray(e)&&(e[0]==="zoom"||e.some(at)),nr=new Set(["get","has","!has","geometry-type","properties","id"]),me=(e)=>{if(e!==void 0&&Dt(e))return e.property!==void 0;if(!Array.isArray(e))return!1;if(nr.has(e[0]))return!0;return e.some((t)=>me(t))},ct=(e,t)=>{if(e===void 0||e===null)return"";if(typeof e==="string")return e.replace(/\{([^}]+)\}/g,(r,o)=>{let s=t.properties[o];return s===void 0?"":String(s)});let n=ae(e,t);if(Array.isArray(n))return n.filter((r)=>typeof r==="string").join("");return n===void 0||n===null?"":String(n)},zt=(e)=>/Regular|Bold|Italic|Semibold|Light|Medium|Black/.test(e)?e:`${e} Regular`,lt=(e)=>{let t=new Set,n=(i)=>i.filter((c,l)=>l>=3&&l%2===1).map(Number),r=(i)=>{if(!Array.isArray(i))return;let c=(l)=>Array.isArray(l)&&l[0]==="zoom";if((i[0]==="interpolate"||i[0]==="interpolate-hcl"||i[0]==="interpolate-lab")&&c(i[2]))n(i).forEach((l)=>{t.add(l)});else if(i[0]==="step"&&c(i[1]))n(i).forEach((l)=>{t.add(l),t.add(l-0.01)});i.forEach(r)};r(e);let o=[...t].filter(Number.isFinite);if(o.length===0)o.push(0);let[s,a]=[Math.min(...o),Math.max(...o)];return o.push(...Array.from({length:Math.floor(a)-Math.ceil(s)+1},(i,c)=>Math.ceil(s)+c)),[...new Set(o)].sort((i,c)=>i-c).map((i)=>[i,Number(ae(e,{zoom:i,properties:{},type:"Unknown"}))])};class Fe{static __wrap(e){let t=Object.create(Fe.prototype);return t.__wbg_ptr=e,Ht.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Ht.unregister(this),e}free(){let e=this.__destroy_into_raw();D.__wbg_gridset_free(e,0)}count(){return D.gridset_count(this.__wbg_ptr)>>>0}meta(e){let t,n;try{let r=D.gridset_meta(this.__wbg_ptr,e);return t=r[0],n=r[1],ft(r[0],r[1])}finally{D.__wbindgen_free(t,n,1)}}values(e){return D.gridset_values(this.__wbg_ptr,e)}}if(Symbol.dispose)Fe.prototype[Symbol.dispose]=Fe.prototype.free;class Ne{static __wrap(e){let t=Object.create(Ne.prototype);return t.__wbg_ptr=e,Jt.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Jt.unregister(this),e}free(){let e=this.__destroy_into_raw();D.__wbg_streetflow_free(e,0)}eastU(){return D.streetflow_eastU(this.__wbg_ptr)}eastV(){return D.streetflow_eastV(this.__wbg_ptr)}northU(){return D.streetflow_northU(this.__wbg_ptr)}northV(){return D.streetflow_northV(this.__wbg_ptr)}}if(Symbol.dispose)Ne.prototype[Symbol.dispose]=Ne.prototype.free;function qt(e){let t=cr(e,D.__wbindgen_malloc),n=ye,r=D.readGrids(t,n);if(r[2])throw ur(r[1]);return Fe.__wrap(r[0])}function $t(e,t,n,r,o,s){let a=lr(e,D.__wbindgen_malloc),i=ye,c=jt(t,D.__wbindgen_malloc),l=ye,u=jt(n,D.__wbindgen_malloc),p=ye,f=D.streetFlow(a,i,c,l,u,p,r,o,s);return Ne.__wrap(f)}function rr(){return{__proto__:null,"./isard_grid_bg.js":{__proto__:null,__wbg___wbindgen_throw_41e9ee4f547fc59a:function(t,n){throw Error(ft(t,n))},__wbg_new_from_slice_ca6ad97db1f4779a:function(t,n){return new Float32Array(or(t,n))},__wbindgen_generic_0000000000000001:function(t,n){return ft(t,n)},__wbindgen_init_externref_table:function(){let t=D.__wbindgen_externrefs,n=t.grow(4);t.set(0,void 0),t.set(n+0,void 0),t.set(n+1,null),t.set(n+2,!0),t.set(n+3,!1)}}}}var Ht=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e)=>D.__wbg_gridset_free(e,1)),Jt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e)=>D.__wbg_streetflow_free(e,1));function or(e,t){return e=e>>>0,sr().subarray(e/4,e/4+t)}var Re=null;function sr(){if(Re===null||Re.byteLength===0)Re=new Float32Array(D.memory.buffer);return Re}var Te=null;function ir(){if(Te===null||Te.byteLength===0)Te=new Float64Array(D.memory.buffer);return Te}function ft(e,t){return mr(e>>>0,t)}var Ee=null;function ar(){if(Ee===null||Ee.byteLength===0)Ee=new Uint32Array(D.memory.buffer);return Ee}var Ie=null;function Yt(){if(Ie===null||Ie.byteLength===0)Ie=new Uint8Array(D.memory.buffer);return Ie}function jt(e,t){let n=t(e.length*4,4)>>>0;return ar().set(e,n/4),ye=e.length,n}function cr(e,t){let n=t(e.length*1,1)>>>0;return Yt().set(e,n/1),ye=e.length,n}function lr(e,t){let n=t(e.length*8,8)>>>0;return ir().set(e,n/8),ye=e.length,n}function ur(e){let t=D.__wbindgen_externrefs.get(e);return D.__externref_table_dealloc(e),t}var qe=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});qe.decode();var fr=2146435072,ut=0;function mr(e,t){if(ut+=t,ut>=fr)qe=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),qe.decode(),ut=t;return qe.decode(Yt().subarray(e,e+t))}var ye=0,pr,dr,D;function br(e,t){return dr=e,D=e.exports,pr=t,Re=null,Te=null,Ee=null,Ie=null,D.__wbindgen_start(),D}async function yr(e,t){if(typeof Response==="function"&&e instanceof Response){if(!e.ok)throw Error(`failed to fetch Wasm: ${e.status} ${e.statusText} fetching '${e.url}'`);if(typeof WebAssembly.instantiateStreaming==="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(o){if(n(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let r=await WebAssembly.instantiate(e,t);if(r instanceof WebAssembly.Instance)return{instance:r,module:e};else return r}function n(r){switch(r){case"basic":case"cors":case"default":return!0}return!1}}async function Gt(e){if(D!==void 0)return D;if(e!==void 0)if(Object.getPrototypeOf(e)===Object.prototype)({module_or_path:e}=e);else console.warn("using deprecated parameters for the initialization function; pass a single object instead");if(e===void 0)e=new URL("isard_grid_bg.wasm",import.meta.url);let t=rr();if(typeof e==="string"||typeof Request==="function"&&e instanceof Request||typeof URL==="function"&&e instanceof URL)e=fetch(e);let{instance:n,module:r}=await yr(await e,t);return br(n,r)}var mt={},Kt=async(e)=>{let t=mt.ready??Gt({module_or_path:e});mt.ready=t,await t.catch((n)=>{throw mt.ready=void 0,n})},Zt=async(e,t,n,r,o)=>{await Kt(o);let s=$t(e.points,e.ringStart,e.polygonStart,t,n,r);try{return{eastU:s.eastU(),eastV:s.eastV(),northU:s.northU(),northV:s.northV()}}finally{s.free()}},hr=(e)=>typeof e==="object"&&e!==null&&("name"in e)&&("width"in e)&&("height"in e)&&("bounds"in e)&&Array.isArray(e.bounds),Xt=async(e,t)=>{await Kt(t);let n=qt(e);try{let r=[],o=[];for(let s=0;s<n.count();s++){let a=JSON.parse(n.meta(s));if(!hr(a))throw Error("isard: a grid without its description");r.push(a),o.push(n.values(s))}return{grids:r,values:o}}finally{n.free()}};var he=6,Qt=4;var en=(e)=>e*7919%360,pt=["shelter","bin","postbox","fountain","rack","bench"];class dt{buf;end;pos;constructor(e,t=0,n=e.length){this.buf=e;this.end=n;this.pos=t}varint(){let e=0;for(let t=0;t<70;t+=7){let n=this.buf[this.pos++]??0;if(e+=(n&127)*2**t,n<128)break}return e}int64(){let e=0,t=0;for(let n=0;n<10;n+=1){let r=this.buf[this.pos++]??0,o=r&127;if(n<4)e|=o<<7*n;else if(n===4)e|=(o&15)<<28,t|=o>>4;else t|=o<<7*n-32;if(r<128)break}return(t|0)*4294967296+(e>>>0)}sint(){let e=this.varint();return e%2===1?-(e+1)/2:e/2}sub(){let e=this.varint(),t=Math.min(this.pos+e,this.end),n=new dt(this.buf,this.pos,t);return this.pos=t,n}string(){let e=this.varint(),t=Math.min(this.pos+e,this.end),n=gr.decode(this.buf.subarray(this.pos,t));return this.pos=t,n}float(){let e=this.pos+4<=this.end?this.view().getFloat32(this.pos,!0):0;return this.pos+=4,e}double(){let e=this.pos+8<=this.end?this.view().getFloat64(this.pos,!0):0;return this.pos+=8,e}view(){return new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength)}skip(e){if(e===0)this.varint();else if(e===1)this.pos+=8;else if(e===2)this.pos+=this.varint();else if(e===5)this.pos+=4}get more(){return this.pos<this.end}}var gr=new TextDecoder,wr=(e)=>{let t="";while(e.more){let n=e.varint();switch(n>>3){case 1:t=e.string();break;case 2:t=e.float();break;case 3:t=e.double();break;case 4:t=e.int64();break;case 5:t=e.varint();break;case 6:t=e.sint();break;case 7:t=e.varint()!==0;break;default:e.skip(n&7)}}return t},xr=(e)=>{let t=[],n,[r,o]=[0,0];while(e.more){let s=e.varint(),a=s&7,i=s>>3;if(a===7){if(n&&n.length>=2)n.push(n[0]??0,n[1]??0);continue}for(let c=0;c<i&&e.more;c+=1){if(r+=e.sint(),o+=e.sint(),a===1)n=[],t.push(n);n?.push(r,o)}}return t},bt=(e,t)=>{let n=new Map,r=new dt(e);while(r.more){let o=r.varint();if(o>>3!==3){r.skip(o&7);continue}let s=r.sub(),a="",i=4096,c=[],l=[],u=[];while(s.more){let f=s.varint();switch(f>>3){case 1:a=s.string();break;case 2:u.push(s.sub());break;case 3:c.push(s.string());break;case 4:l.push(wr(s.sub()));break;case 5:i=s.varint();break;default:s.skip(f&7)}}if(t&&!t.has(a))continue;let p=[];for(let f of u){let d=1,w={},h=[];while(f.more){let A=f.varint();switch(A>>3){case 2:{let m=f.sub();while(m.more){let M=c[m.varint()],b=l[m.varint()];if(M!==void 0&&b!==void 0)w[M]=b}break}case 3:d=Math.min(3,Math.max(1,f.varint()));break;case 4:h=xr(f.sub());break;default:f.skip(A&7)}}p.push({type:d,properties:w,geometry:h})}n.set(a,{extent:i,features:p})}return n};var _r=127,Ar=16384,Mr=["unknown","mvt","png","jpeg","webp","avif"],Sr=(e)=>(4**e-1)/3,kr=(e,t,n)=>{if(e>26)throw Error(`isard: PMTiles level ${e} past 26`);let r=2**e;if(t<0||n<0||t>=r||n>=r)throw Error(`isard: PMTiles tile ${e}/${t}/${n} out of its level`);let[o,s]=[t,n],a=0;for(let i=r/2;i>=1;i/=2){let c=(o&i)>0?1:0,l=(s&i)>0?1:0;if(a+=i*i*(3*c^l),l===0){if(c===1)[o,s]=[i-1-o,i-1-s];[o,s]=[s,o]}}return Sr(e)+a};class rn{bytes;pos=0;constructor(e){this.bytes=e}next(){let e=0,t=1;for(;;){let n=this.bytes[this.pos++];if(n===void 0)throw Error("isard: PMTiles directory truncated");if(e+=(n&127)*t,n<128)return e;if(t*=128,t>9223372036854776000)throw Error("isard: PMTiles varint too long")}}}var tn=(e)=>{let t=new rn(e),n=t.next();if(n>e.length)throw Error("isard: PMTiles directory larger than its bytes");let r=[],o=0;for(let s=0;s<n;s+=1)o+=t.next(),r.push({tileId:o,offset:0,length:0,runLength:1});for(let s of r)s.runLength=t.next();for(let s of r)s.length=t.next();return r.forEach((s,a)=>{let i=t.next(),c=r[a-1];s.offset=i===0&&c?c.offset+c.length:i-1}),r},vr=(e,t)=>{let[n,r]=[0,e.length-1];while(n<=r){let s=n+r>>1,a=e[s];if(!a)break;if(a.tileId===t)return a;if(a.tileId<t)n=s+1;else r=s-1}let o=e[r];if(!o)return;if(o.runLength===0||t-o.tileId<o.runLength)return o;return},Rr=(e)=>{if(e.length<_r||String.fromCharCode(...e.subarray(0,7))!=="PMTiles")throw Error("isard: not a PMTiles archive");if(e[7]!==3)throw Error(`isard: PMTiles version ${e[7]} (only 3 is read)`);let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=(o)=>Number(t.getBigUint64(o,!0)),r=(o)=>t.getInt32(o,!0)/1e7;return{rootDirectoryOffset:n(8),rootDirectoryLength:n(16),metadataOffset:n(24),metadataLength:n(32),leafDirectoryOffset:n(40),leafDirectoryLength:n(48),tileDataOffset:n(56),tileDataLength:n(64),internalCompression:t.getUint8(97),tileCompression:t.getUint8(98),tileType:Mr[t.getUint8(99)]??"unknown",minZoom:t.getUint8(100),maxZoom:t.getUint8(101),bounds:[r(102),r(106),r(110),r(114)],center:[r(119),r(123),t.getUint8(118)]}},$e=async(e,t)=>{if(t===0||t===1)return e;if(t!==2)throw Error(`isard: PMTiles compression ${t===3?"brotli":"zstd"} is not read (gzip only)`);let n=new Blob([e]).stream().pipeThrough(new DecompressionStream("gzip"));return new Uint8Array(await new Response(n).arrayBuffer())},Tr=67108864;class on{source;head;leaves=new le(64);whole;constructor(e){this.source=e}async range(e,t,n){if(typeof this.source!=="string")return new Uint8Array(await this.source.slice(e,e+t).arrayBuffer());if(this.whole)return(await this.whole).subarray(e,e+t);let r=await fetch(this.source,oe(this.source,{headers:{Range:`bytes=${e}-${e+Math.max(t,1)-1}`},...n?{signal:n}:{}}));if(!r.ok)throw ie(this.source,r.status);if(r.status===206)return new Uint8Array(await r.arrayBuffer());if(Number(r.headers.get("Content-Length"))>Tr)throw await r.body?.cancel(),Error(`isard: ${this.source}: the server ignores range requests (HTTP 206 expected)`);let s=r.arrayBuffer().then((a)=>new Uint8Array(a));return this.whole=s,s.catch(()=>{this.whole=void 0}),(await s).subarray(e,e+t)}load(){return this.head??=(async()=>{let e=await this.range(0,Ar),t=Rr(e),{rootDirectoryOffset:n,rootDirectoryLength:r}=t,o=n+r<=e.length?e.subarray(n,n+r):await this.range(n,r),s=tn(await $e(o,t.internalCompression));return{header:t,root:s}})(),this.head.catch(()=>{this.head=void 0}),this.head}async header(){return(await this.load()).header}async metadata(){let{header:e}=await this.load();if(e.metadataLength===0)return{};let t=await this.range(e.metadataOffset,e.metadataLength),n=new TextDecoder().decode(await $e(t,e.internalCompression)),r=JSON.parse(n);return be(r)?r:{}}leaf(e,t){let n=e.leafDirectoryOffset+t.offset,r=this.leaves.get(n);if(r)return r;let o=this.range(n,t.length).then(async(s)=>tn(await $e(s,e.internalCompression)));return o.catch(()=>this.leaves.delete(n)),this.leaves.set(n,o),o}async tile(e,t,n,r){let{header:o,root:s}=await this.load();if(e<o.minZoom||e>o.maxZoom)return;let a=kr(e,t,n),i=s;for(let c=0;c<4;c+=1){let l=vr(i,a);if(!l)return;if(l.runLength>0){let u=await this.range(o.tileDataOffset+l.offset,l.length,r);return $e(u,o.tileCompression)}i=await this.leaf(o,l)}throw Error("isard: PMTiles directories nested too deep")}}var nn=new le(16),Er=(e)=>{let t=nn.get(e);if(t)return t;let n=new on(e);return nn.set(e,n),n};var yt=(e,t)=>{let n=/^pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)$/.exec(e);if(!n)return!1;let[,r="",o,s,a]=n;return Er(r).tile(Number(o),Number(s),Number(a),t)};var gt=(e,t)=>{let n=e.sprites.find((o)=>Boolean(o.icons[t])),r=n?.icons[t];return n&&r?{icon:r,image:n.image}:void 0},Pe=new Map,sn=96,Oe=new le(sn),an=(e)=>Math.max(16,Math.ceil(sn/Math.max(1,e))),cn=30000,Ye=new Set,j=new Set,ht=new le(64,(e)=>e.then((t)=>setTimeout(()=>t?.close(),0),()=>{return})),ln=(e,t="auto")=>{let n=ht.get(e);if(n)return n;let r=(async()=>{let o=yt(e);if(o){let i=await o;return i&&createImageBitmap(new Blob([i]))}let s={priority:t,signal:AbortSignal.timeout(cn)},a=await fetch(e,oe(e,s));if(a.status===404||a.status===204)return;if(!a.ok)throw ie(e,a.status);return createImageBitmap(await a.blob())})();return r.catch(()=>ht.delete(e)),ht.set(e,r),r},ee=(e,t="auto")=>{let n=Oe.get(e);if(n)return n;let r=(async()=>{let o=yt(e);if(o){let s=await o;return s&&bt(s)}for(let s=0;;s+=1){let a={priority:t,signal:AbortSignal.timeout(cn)},i=await fetch(e,oe(e,a));if(i.status===404||i.status===204)return;if(i.ok)return bt(new Uint8Array(await i.arrayBuffer()));if(s>=2)throw ie(e,i.status);await new Promise((c)=>setTimeout(c,400*(s+1)))}})();return r.catch(()=>Oe.delete(e)),Oe.set(e,r),r},un=(e,t,n,r)=>{let o=xe(t-1,0,e.maxzoom),s=t-o,a=2**Math.max(0,s),[i,c]=s>=0?[Math.floor(n/a),Math.floor(r/a)]:[n,r],l=K(e.tiles,o,i,c),u=1/a;return{url:l,vz:o,vx:i,vy:c,part:u,ox:n%a*u,oy:r%a*u}},C=(e,t,n,r,o)=>{let s=e[t]?.[n];if(s===void 0)return o;let a=Array.isArray(s)&&!ve(s)?s:ae(s,r);return a===void 0||a===null?o:a},pe=(e,t)=>{let n=ce(e)??[0,0,0,1];return Je([n[0],n[1],n[2],n[3]*t])},Le=(e,t)=>{if(e.layout?.visibility==="none")return!1;return t>=(e.minzoom??0)&&t<(e.maxzoom??24)},H=(e,t,n,r,o,s)=>{let a=2**e;return[It((t+o/r)/a),Ft((n+s/r)/a)]};var Ir=300,fn=(e,t,n)=>{let r=Boolean(C(e,"layout",`${t}-allow-overlap`,n,!1)),o=Boolean(C(e,"layout",`${t}-ignore-placement`,n,!1));if(r&&o)return!0;if(r)return"allow";return o?"ignore":!1},mn=(e,t)=>Array.isArray(e)?[Number(e[0]??t[0]),Number(e[1]??t[1])]:t,Fr=(e)=>{let t=(Array.isArray(e)?e:[e]).map((a)=>Number(a)||0),[n=0,r=n,o=n,s=r]=t;return[n,r,o,s]},Nr=(e,t)=>{if(t==="uppercase")return e.toUpperCase();if(t==="lowercase")return e.toLowerCase();return e},Ae=(e,t)=>{let n=0;for(let a=2;a+1<e.length;a+=2)n+=Math.hypot((e[a]??0)-(e[a-2]??0),(e[a+1]??0)-(e[a-1]??0));let r=[];if(!(n>0)||!(t>0))return r;let o=Math.min(t/2,n/2),s=0;for(let a=2;a+1<e.length;a+=2){let[i,c,l,u]=[e[a-2]??0,e[a-1]??0,e[a]??0,e[a+1]??0],p=Math.hypot(l-i,u-c);while(p>0&&o<=s+p){let f=(o-s)/p;r.push([i+(l-i)*f,c+(u-c)*f,i,c,l,u,o]),o+=t}s+=p}return r},Ke=(e,t,n)=>{let[r=0,o=0,s=0,a=0,i=0,c=0]=e,l=Math.hypot(i-s,c-a)||1,u=t%2===0?1:-1,[p,f]=[-(c-a)/l*u,(i-s)/l*u];return[r+p*n,o+f*n,Math.atan2(-p,f)*180/Math.PI]},Or=(e,t,n)=>{let r=[],o=0;for(let s=2;s+1<e.length;s+=2){let[a,i,c,l]=[e[s-2]??0,e[s-1]??0,e[s]??0,e[s+1]??0],u=Math.hypot(c-a,l-i),[p,f]=[o,o+u];if(o=f,u<=0||f<t||p>n)continue;let d=(w)=>[a+(c-a)*(w-p)/u,i+(l-i)*(w-p)/u];if(r.length===0)r.push(...d(Math.max(t,p)));r.push(...d(Math.min(n,f)))}return r},Pr=(e,t,n,r,o)=>{let s=C(e,"layout","icon-rotation-alignment",n,"auto"),a=String(C(e,"layout","icon-text-fit",n,"none")),i=C(e,"layout","icon-text-fit-padding",n,[0,0,0,0]);return{image:t,size:me(e.layout?.["icon-size"])?Number(C(e,"layout","icon-size",n,1)):o(e),anchor:String(C(e,"layout","icon-anchor",n,"center")),offset:mn(C(e,"layout","icon-offset",n,[0,0]),[0,0]),rotate:Number(C(e,"layout","icon-rotate",n,0))||0,alignment:s==="map"||s==="auto"&&r==="line"?"map":"viewport",overlap:fn(e,"icon",n),optional:Boolean(C(e,"layout","icon-optional",n,!1)),fit:a==="width"||a==="height"||a==="both"?a:"none",padding:Fr(i),color:String(C(e,"paint","icon-color",n,"#000")),opacity:Number(C(e,"paint","icon-opacity",n,1))}},Ge=16,Lr=(e,t,n)=>{let r=[],o=new Map,s=4096;e.layers.forEach((c)=>{if(c.type!=="fill-extrusion"||!Le(c,n))return;let l=t.get(c["source-layer"]??"");if(!l)return;s=l.extent;for(let u of l.features){let p=Z(u,n);if(u.type!==3||!Q(c.filter,p))continue;let f=Number(C(c,"paint","fill-extrusion-height",p,0));if(!(f>0))continue;let d=[1/0,1/0,-1/0,-1/0];for(let w of u.geometry)for(let h=0;h+1<w.length;h+=2){let[A,m]=[w[h]??0,w[h+1]??0];d[0]=Math.min(d[0],A),d[1]=Math.min(d[1],m),d[2]=Math.max(d[2],A),d[3]=Math.max(d[3],m)}r.push({rings:u.geometry,height:f,box:d})}});let a=(c)=>Math.max(0,Math.min(Ge-1,Math.floor(c/s*Ge)));r.forEach(({box:c},l)=>{for(let u=a(c[1]);u<=a(c[3]);u++)for(let p=a(c[0]);p<=a(c[2]);p++){let f=u*Ge+p,d=o.get(f);if(d)d.push(l);else o.set(f,[l])}});let i=(c,l,u)=>{let p=!1;for(let f of c)for(let d=0,w=f.length-2;d+1<f.length;w=d,d+=2){let[h,A,m,M]=[f[d]??0,f[d+1]??0,f[w]??0,f[w+1]??0];if(A>u!==M>u&&l<(m-h)*(u-A)/(M-A)+h)p=!p}return p};return(c,l)=>(o.get(a(l)*Ge+a(c))??[]).reduce((u,p)=>{let f=r[p];return f&&i(f.rings,c,l)?Math.max(u??0,f.height):u},void 0)},pn=async(e,t)=>{let{z:n,x:r,y:o,id:s,priority:a,zoom:i=n,roofs:c=!1}=t,l=K(e.tiles,n,r,o),u=await ee(l,a);if(!u||j.has(s))return[];let p=[],f=c?Lr(e,u,i):()=>{return},d=new Map,w=(m)=>{let M=d.get(m);if(M!==void 0)return M;let b=m.layout?.["text-size"]??16,x=ve(b)?lt(b):b;return d.set(m,x),x},h=new Map,A=(m)=>{let M=h.get(m);if(M!==void 0)return M;let b=m.layout?.["icon-size"]??1,x=ve(b)?lt(b):b;return h.set(m,x),x};return e.layers.forEach((m,M)=>{let b=m.layout??{};if(m.type!=="symbol"||!Le(m,i))return;if(b["text-field"]===void 0&&b["icon-image"]===void 0)return;let x=u.get(m["source-layer"]??"");if(!x)return;let T={zoom:i,properties:{},type:"Unknown"},E=C(m,"layout","symbol-placement",T,"point")==="line"?"line":"point",_=E==="line"&&C(m,"layout","text-rotation-alignment",T,"auto")!=="viewport";for(let g of x.features){let y=Z(g,i);if(!Q(m.filter,y))continue;let S=ct(b["text-field"],y).trim(),k=ct(b["icon-image"],y).trim();if(!S&&!k)continue;let v=Nr(S,C(m,"layout","text-transform",y,"none")),R=C(m,"layout","text-font",y,["Noto Sans Regular"]),U=zt(Array.isArray(R)&&typeof R[0]==="string"?R[0]:"Noto Sans Regular"),B={layer:M,text:v,font:U,size:me(m.layout?.["text-size"])?Number(C(m,"layout","text-size",y,16)):w(m),color:String(C(m,"paint","text-color",y,"#000")),haloColor:String(C(m,"paint","text-halo-color",y,"rgba(0,0,0,0)")),haloWidth:Number(C(m,"paint","text-halo-width",y,0)),anchor:String(C(m,"layout","text-anchor",y,"center")),offset:mn(C(m,"layout","text-offset",y,[0,0]),[0,0]),maxWidth:Number(C(m,"layout","text-max-width",y,10)),lineHeight:Number(C(m,"layout","text-line-height",y,1.2)),overlap:fn(m,"text",y),..._?{textAlong:_}:{},...C(m,"layout","text-optional",y,!1)?{textOptional:!0}:{},...k?{icon:Pr(m,k,y,E,A)}:{}};if(g.type===1)for(let P of g.geometry)for(let L=0;L+1<P.length;L+=2){let[I,F]=[P[L]??0,P[L+1]??0];if(I<0||F<0||I>=x.extent||F>=x.extent)continue;let[N,W]=H(n,r,o,x.extent,I,F),V=f(I,F);p.push({...B,lon:N,lat:W,...V===void 0?{}:{height:V}})}else if(!v&&E==="line"){let P=Number(C(m,"layout","symbol-spacing",y,250))*x.extent/(512*2**(i-n));for(let L of g.geometry)for(let[I=0,F=0,N=0,W=0,V=0,J=0]of Ae(L,Math.max(P,1))){if(I<0||F<0||I>=x.extent||F>=x.extent)continue;let[z,te]=H(n,r,o,x.extent,I,F),[G,ne]=H(n,r,o,x.extent,V,J),[X,re]=H(n,r,o,x.extent,N,W);p.push({...B,lon:z,lat:te,along:[G-X,ne-re]})}}else if(v&&_){let P=x.extent/(512*2**(i-n)),L=Number(C(m,"layout","symbol-spacing",y,250))*P;for(let I of g.geometry){let F=0;for(let N=2;N+1<I.length;N+=2)F+=Math.hypot((I[N]??0)-(I[N-2]??0),(I[N+1]??0)-(I[N-1]??0));if(F<x.extent/32)continue;for(let[N=0,W=0,V=0,J=0,z=0,te=0,G=0]of Ae(I,Math.max(L,1))){if(N<0||W<0||N>=x.extent||W>=x.extent)continue;let ne=Math.min(G,F-G,Ir*P),X=Or(I,G-ne,G+ne),re=[];for(let Ve=0;Ve+1<X.length;Ve+=2)re.push(...H(n,r,o,x.extent,X[Ve]??0,X[Ve+1]??0));let[Me,Se]=H(n,r,o,x.extent,N,W),[nt,Bn]=H(n,r,o,x.extent,z,te),[Vn,zn]=H(n,r,o,x.extent,V,J);p.push({...B,lon:Me,lat:Se,along:[nt-Vn,Bn-zn],...re.length>=4?{path:re}:{}})}}}else{let P,L=0;for(let F of g.geometry){let N=0;for(let W=2;W+1<F.length;W+=2)N+=Math.hypot((F[W]??0)-(F[W-2]??0),(F[W+1]??0)-(F[W-1]??0));if(N>L)L=N,P=F}if(!P||L<x.extent/32)continue;let I=L/2;for(let F=2;F+1<P.length;F+=2){let[N,W,V,J]=[P[F-2]??0,P[F-1]??0,P[F]??0,P[F+1]??0],z=Math.hypot(V-N,J-W);if(z>=I&&z>0){let[te,G]=[N+(V-N)*I/z,W+(J-W)*I/z];if(te<0||G<0||te>=x.extent||G>=x.extent)break;let[ne,X]=H(n,r,o,x.extent,te,G),[re,Me]=H(n,r,o,x.extent,V,J),[Se,nt]=H(n,r,o,x.extent,N,W);p.push({...B,lon:ne,lat:X,...E==="line"?{along:[re-Se,Me-nt]}:{}});break}I-=z}}}}),p};var dn=(e)=>{let t=e.leaf_type,n=typeof e.nature==="string"?e.nature:"";if(t==="needleleaved"||/conif/i.test(n))return 1;if(t==="broadleaved"||/feuillu/i.test(n))return 0;if(t==="mixed"||/mixte/i.test(n))return 0.5;if(e.class==="wood")return e.subclass==="forest"?0.35:0.15;return 0};var Ze=(e,t)=>{let n=e.length/he,r=n>t?t/n:1,o=[];for(let s=0;s<n;s+=1)if(r>=1||(e[s*he+Qt]??0)<r)o.push(...e.slice(s*he,(s+1)*he));return Float64Array.from(o)},se=(e,t,n,r)=>{let o=Math.imul(e^2654435769,2246822507)^Math.imul(t^3266489909,668265263);return o=Math.imul(o^o>>>15^Math.imul(n,374761393),739982445),o=Math.imul(o^o>>>13^Math.imul(r,695872825),695872825),((o^o>>>16)>>>0)/4294967296},ge=(e,t,n)=>e.reduce((r,o)=>{let s=o.length/2,a=0;for(let i=0,c=s-1;i<s;c=i,i+=1){let[l,u,p,f]=[o[i*2]??0,o[i*2+1]??0,o[c*2]??0,o[c*2+1]??0];if(u>n!==f>n&&t<(p-l)*(n-u)/(f-u)+l)a+=1}return a%2===1?!r:r},!1),Ur=(e,t,n,r,o=Number.POSITIVE_INFINITY)=>{let s=e[0]??[],a=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(let T=0;T+1<s.length;T+=2){let[E,_]=[s[T]??0,s[T+1]??0];a[0]=Math.min(a[0]??E,E),a[1]=Math.min(a[1]??_,_),a[2]=Math.max(a[2]??E,E),a[3]=Math.max(a[3]??_,_)}let[i,c]=[Math.max(0,a[0]??0),Math.max(0,a[1]??0)],[l,u]=[Math.min(t,a[2]??0),Math.min(t,a[3]??0)];if(!(n>0)||i>=l||c>=u)return[];let p=(l-i)/n*((u-c)/n),f=p>o?n*Math.sqrt(p/o):n,[d,w,h,A]=[Math.floor(i/f),Math.ceil(l/f),Math.floor(c/f),Math.ceil(u/f)],[m,M,b]=r,x=Math.imul(m+1,16777619)^Math.imul(M,1540483477)^Math.imul(b,461845907);return Array.from({length:Math.max(0,A-h)},(T,E)=>h+E).flatMap((T)=>Array.from({length:Math.max(0,w-d)},(E,_)=>d+_).flatMap((E)=>{let _=(E+se(x,E,T,1))*f,g=(T+se(x,E,T,2))*f;if(_<0||g<0||_>=t||g>=t||!ge(e,_,g))return[];return[[_,g,se(x,E,T,3)]]}))},bn=async(e,t)=>{let{z:n,x:r,y:o,id:s,spacing:a,maxTrees:i,priority:c}=t,l=K(e.tiles,n,r,o),u=await ee(l,c);if(!u||j.has(s))return;let p=_e(n,o),f=[];e.layers.forEach((A,m)=>{let M=a[m]??0,b=u.get(A["source-layer"]??"");if(!b||!(M>0))return;let x=M/p*b.extent;b.features.forEach((T)=>{if(T.type!==3||!Q(A.filter,Z(T,n)))return;let E=dn(T.properties);T.geometry.reduce((g,y)=>{let S=0;for(let k=0;k+1<y.length;k+=2){let v=(k+2)%y.length;S+=(y[k]??0)*(y[v+1]??0)-(y[v]??0)*(y[k+1]??0)}if(S>0)g.push([y]);else if(S<0)g.at(-1)?.push(y);return g},[]).forEach((g)=>{Ur(g,b.extent,x,[n,r,o],i*4).forEach(([y,S,k])=>{f.push([y,S,k,b.extent,E])})})})});let d=f.length>i?i/f.length:1,w=f.filter(([,,A])=>d>=1||se(Math.floor(A*2147483648),n,r,o)<d),h=new Float64Array(w.length*he);return w.forEach(([A,m,M,b,x],T)=>{let[E,_]=H(n,r,o,b,A,m),g=se(Math.floor(M*2147483648),7,11,13),y=se(Math.floor(M*2147483648),3,5,17)<x?1:0;h.set([E,_,0.75+0.5*M,en(M),g,y],T*he)}),h};var Cr={bus_stop:"shelter",waste_basket:"bin",post_box:"postbox",drinking_water:"fountain",bicycle_parking:"rack"},Wr=new Set(["primary","secondary","tertiary","minor","service","trunk"]),Dr=25,yn={street:[24,3.2],path:[18,1.3]},Br=(e)=>e.filter((t)=>t.type===1),hn=async(e,t)=>{let{z:n,x:r,y:o,id:s,maxObjects:a,priority:i}=t,c=K(e.tiles,n,r,o),l=await ee(c,i);if(!l||j.has(s))return;let u=l.get("poi"),p=l.get("transportation"),f=p?.extent??u?.extent??4096,d=f/_e(n,o),w=(p?.features??[]).filter((_)=>_.type===2&&Wr.has(String(_.properties.class))),h=(l.get("landcover")?.features??[]).filter((_)=>_.type===3&&String(_.properties.class)==="grass").map((_)=>{let g=_.geometry[0]??[],y=g.filter((k,v)=>v%2===0),S=g.filter((k,v)=>v%2===1);return{rings:_.geometry,bounds:[Math.min(...y),Math.min(...S),Math.max(...y),Math.max(...S)]}}),A=(_,g)=>h.some(({rings:y,bounds:[S=0,k=0,v=0,R=0]})=>_>=S&&_<=v&&g>=k&&g<=R&&ge(y,_,g)),m=[],M=(_,g,y,S,k)=>{if(_<0||g<0||_>=f||g>=f)return;let[v,R]=H(n,r,o,f,_,g);m.push(v,R,1,y,S,pt.indexOf(k))},b=Dr*d,x=new Map,T=(_,g)=>(_+32768)*65536+g+32768;w.forEach((_)=>{_.geometry.forEach((g)=>{for(let y=2;y+1<g.length;y+=2){let[S,k,v,R]=[g[y-2]??0,g[y-1]??0,g[y]??0,g[y+1]??0],[U,B]=[Math.floor(Math.min(S,v)/b),Math.floor(Math.max(S,v)/b)],[P,L]=[Math.floor(Math.min(k,R)/b),Math.floor(Math.max(k,R)/b)];for(let I=U;I<=B;I+=1)for(let F=P;F<=L;F+=1){let N=x.get(T(I,F))??[];N.push(S,k,v,R),x.set(T(I,F),N)}}})});let E=(_,g,y)=>{let[S,k,v]=[b*b,0,0],[R,U]=[Math.floor(_/b),Math.floor(g/b)];for(let B=R-1;B<=R+1;B+=1)for(let P=U-1;P<=U+1;P+=1){let L=x.get(T(B,P))??[];for(let I=0;I+3<L.length;I+=4){let[F,N,W,V]=[L[I]??0,L[I+1]??0,L[I+2]??0,L[I+3]??0],[J,z]=[W-F,V-N],te=J*J+z*z,G=te>0?Math.max(0,Math.min(1,((_-F)*J+(g-N)*z)/te)):0,[ne,X]=[F+G*J-_,N+G*z-g],re=ne*ne+X*X;if(re<S)[S,k,v]=[re,ne,X]}}if(k===0&&v===0)return y;return Math.atan2(k,-v)*180/Math.PI};return Br(u?.features??[]).forEach((_)=>{let g=Cr[String(_.properties.subclass)];if(!g)return;_.geometry.forEach(([y=0,S=0])=>{let k=se(Math.floor(y),Math.floor(S),pt.indexOf(g),31);M(y,S,E(y,S,k*360),k,g)})}),(p?.features??[]).forEach((_)=>{let g=String(_.properties.subclass),y=String(_.properties.class)==="path"&&g==="pedestrian",S=String(_.properties.class)==="path"&&(g==="footway"||g==="path");if(_.type!==2||!(y||S))return;let[k,v]=y?yn.street:yn.path;_.geometry.forEach((R)=>{Ae(R,k*d).forEach((U,B)=>{let[P=0,L=0,,,,,I=0]=U;if(S&&!A(P,L))return;let F=se(Math.floor(P),Math.floor(L),Math.floor(I),37);M(...Ke(U,B,v*d),F,"bench")})})}),Ze(m,a)};var gn={flat:1,skillion:1,hipped:2,"half-hipped":2,side_hipped:2,dome:2,onion:2,round:2,gabled:3,saltbox:3,pyramidal:4,cone:4,mansard:5,gambrel:5},Vr=255,wn=(e)=>e==="generated"?Vr:gn[e],xn=(e,t)=>be(e)?t.map((n)=>e[n]).find((n)=>n!==void 0):void 0,_n=(e,t)=>{let n=xn(e,["roof:shape","roof_shape"]);if(t==="flat")return;if(typeof n==="string"&&gn[n]!==void 0)return n;return t==="generated"?"generated":void 0},An=(e)=>Number(xn(e,["roof:height","roof_height"])??Number.NaN);var wt=32,q={color:0,second:4,size:8,size2:16,range:24,blur:26,landmark:26,patternRatio:27,fillPattern:28,linePattern:29};class Be{static __wrap(e){let t=Object.create(Be.prototype);return t.__wbg_ptr=e,Mn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Mn.unregister(this),e}free(){let e=this.__destroy_into_raw();O.__wbg_tessellatedtile_free(e,0)}blockIndices(){return O.tessellatedtile_blockIndices(this.__wbg_ptr)}blockRanges(){let e=O.tessellatedtile_blockRanges(this.__wbg_ptr);var t=Qe(e[0],e[1]).slice();return O.__wbindgen_free(e[0],e[1]*4,4),t}blocks(){return O.tessellatedtile_blocks(this.__wbg_ptr)}bounds(){let e=O.tessellatedtile_bounds(this.__wbg_ptr);var t=Jr(e[0],e[1]).slice();return O.__wbindgen_free(e[0],e[1]*8,8),t}fillRanges(){let e=O.tessellatedtile_fillRanges(this.__wbg_ptr);var t=Qe(e[0],e[1]).slice();return O.__wbindgen_free(e[0],e[1]*4,4),t}indices(){return O.tessellatedtile_indices(this.__wbg_ptr)}lineRanges(){let e=O.tessellatedtile_lineRanges(this.__wbg_ptr);var t=Qe(e[0],e[1]).slice();return O.__wbindgen_free(e[0],e[1]*4,4),t}lineTable(){return O.tessellatedtile_lineTable(this.__wbg_ptr)}pieces(){return O.tessellatedtile_pieces(this.__wbg_ptr)}prism(){return O.tessellatedtile_prism(this.__wbg_ptr)!==0}vertices(){return O.tessellatedtile_vertices(this.__wbg_ptr)}}if(Symbol.dispose)Be.prototype[Symbol.dispose]=Be.prototype.free;function kn(e,t,n,r,o,s,a,i,c,l,u,p,f,d,w,h,A){let m=Xe(e,O.__wbindgen_malloc),M=Y,b=de(t,O.__wbindgen_malloc),x=Y,T=de(n,O.__wbindgen_malloc),E=Y,_=de(r,O.__wbindgen_malloc),g=Y,y=de(o,O.__wbindgen_malloc),S=Y,k=Xe(s,O.__wbindgen_malloc),v=Y,R=de(a,O.__wbindgen_malloc),U=Y,B=de(i,O.__wbindgen_malloc),P=Y,L=de(c,O.__wbindgen_malloc),I=Y,F=Sn(l,O.__wbindgen_malloc),N=Y,W=Sn(u,O.__wbindgen_malloc),V=Y,J=$r(p,O.__wbindgen_malloc),z=Y,te=Xe(f,O.__wbindgen_malloc),G=Y,ne=de(d,O.__wbindgen_malloc),X=Y,re=Xe(A,O.__wbindgen_malloc),Me=Y,Se=O.tessellateVectorTile(m,M,b,x,T,E,_,g,y,S,k,v,R,U,B,P,L,I,F,N,W,V,J,z,te,G,ne,X,w,h,re,Me);return Be.__wrap(Se)}function zr(){return{__proto__:null,"./isard_tess_bg.js":{__proto__:null,__wbg___wbindgen_throw_41e9ee4f547fc59a:function(t,n){throw Error(qr(t,n))},__wbg_new_from_slice_37a3c3a194266cb8:function(t,n){return new Uint32Array(Qe(t,n))},__wbg_new_from_slice_9a868026ffa4208a:function(t,n){return new Uint8Array(jr(t,n))},__wbg_new_from_slice_ca6ad97db1f4779a:function(t,n){return new Float32Array(Hr(t,n))},__wbindgen_init_externref_table:function(){let t=O.__wbindgen_externrefs,n=t.grow(4);t.set(0,void 0),t.set(n+0,void 0),t.set(n+1,null),t.set(n+2,!0),t.set(n+3,!1)}}}}var Mn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e)=>O.__wbg_tessellatedtile_free(e,1));function Hr(e,t){return e=e>>>0,vn().subarray(e/4,e/4+t)}function Jr(e,t){return e=e>>>0,Rn().subarray(e/8,e/8+t)}function Qe(e,t){return e=e>>>0,Tn().subarray(e/4,e/4+t)}function jr(e,t){return e=e>>>0,_t().subarray(e/1,e/1+t)}var Ue=null;function vn(){if(Ue===null||Ue.byteLength===0)Ue=new Float32Array(O.memory.buffer);return Ue}var Ce=null;function Rn(){if(Ce===null||Ce.byteLength===0)Ce=new Float64Array(O.memory.buffer);return Ce}function qr(e,t){return Gr(e>>>0,t)}var We=null;function Tn(){if(We===null||We.byteLength===0)We=new Uint32Array(O.memory.buffer);return We}var De=null;function _t(){if(De===null||De.byteLength===0)De=new Uint8Array(O.memory.buffer);return De}function de(e,t){let n=t(e.length*4,4)>>>0;return Tn().set(e,n/4),Y=e.length,n}function Sn(e,t){let n=t(e.length*1,1)>>>0;return _t().set(e,n/1),Y=e.length,n}function $r(e,t){let n=t(e.length*4,4)>>>0;return vn().set(e,n/4),Y=e.length,n}function Xe(e,t){let n=t(e.length*8,8)>>>0;return Rn().set(e,n/8),Y=e.length,n}var et=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});et.decode();var Yr=2146435072,xt=0;function Gr(e,t){if(xt+=t,xt>=Yr)et=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),et.decode(),xt=t;return et.decode(_t().subarray(e,e+t))}var Y=0,Kr,Zr,O;function Xr(e,t){return Zr=e,O=e.exports,Kr=t,Ue=null,Ce=null,We=null,De=null,O.__wbindgen_start(),O}async function Qr(e,t){if(typeof Response==="function"&&e instanceof Response){if(!e.ok)throw Error(`failed to fetch Wasm: ${e.status} ${e.statusText} fetching '${e.url}'`);if(typeof WebAssembly.instantiateStreaming==="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(o){if(n(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let r=await WebAssembly.instantiate(e,t);if(r instanceof WebAssembly.Instance)return{instance:r,module:e};else return r}function n(r){switch(r){case"basic":case"cors":case"default":return!0}return!1}}async function En(e){if(O!==void 0)return O;if(e!==void 0)if(Object.getPrototypeOf(e)===Object.prototype)({module_or_path:e}=e);else console.warn("using deprecated parameters for the initialization function; pass a single object instead");if(e===void 0)e=new URL("isard_tess_bg.wasm",import.meta.url);let t=zr();if(typeof e==="string"||typeof Request==="function"&&e instanceof Request||typeof URL==="function"&&e instanceof URL)e=fetch(e);let{instance:n,module:r}=await Qr(await e,t);return Xr(n,r)}var tt=async(e,t)=>{let{z:n,x:r,y:o,id:s,priority:a}=t,i=K(e.tiles,n,r,o),c=await ee(i,a),l={points:[],ringStart:[],polygonStart:[],feature:[]},u=[];if(!c||j.has(s))return;let p=new Set,f=2**n;return e.layers.forEach((d)=>{let w=c.get(d["source-layer"]??"");if(!w)return;w.features.forEach((h)=>{if(h.type!==3||p.has(h)||!Q(d.filter,Z(h,n)))return;p.add(h);let A=u.length;u.push(h.properties),h.geometry.forEach((m)=>{let M=0;for(let b=0;b+1<m.length;b+=2){let x=(b+2)%m.length;M+=(m[b]??0)*(m[x+1]??0)-(m[x]??0)*(m[b+1]??0)}if(M===0)return;if(M>0||l.polygonStart.length===0||l.feature.at(-1)!==A)l.polygonStart.push(l.ringStart.length),l.feature.push(A);l.ringStart.push(l.points.length/2);for(let b=0;b+1<m.length;b+=2)l.points.push((r+(m[b]??0)/w.extent)/f,(o+(m[b+1]??0)/w.extent)/f)})})}),l.ringStart.push(l.points.length/2),l.polygonStart.push(l.ringStart.length-1),{arrays:{points:Float64Array.from(l.points),ringStart:Uint32Array.from(l.ringStart),polygonStart:Uint32Array.from(l.polygonStart),feature:Uint32Array.from(l.feature)},properties:u}},eo=new Set(["theatre","museum","place_of_worship","castle","monument","attraction","town_hall"]),to=(e)=>(e?.get("poi")?.features??[]).filter((t)=>t.type===1&&eo.has(String(t.properties.class))).flatMap((t)=>t.geometry.flat()),At=(e)=>{let[t,n,r,o]=[1/0,1/0,-1/0,-1/0];for(let s=0;s+1<e.length;s+=2)[t,n]=[Math.min(t,e[s]??0),Math.min(n,e[s+1]??0)],[r,o]=[Math.max(r,e[s]??0),Math.max(o,e[s+1]??0)];return[t,n,r,o]},no=(e,t)=>{if(t.length===0)return!1;let[n,r,o,s]=At(e[0]??[]);for(let a=0;a+1<t.length;a+=2){let[i,c]=[t[a]??0,t[a+1]??0];if(i>=n&&i<=o&&c>=r&&c<=s&&ge(e,i,c))return!0}return!1},In=(e)=>{let t=e.length>2&&e[0]===e[e.length-2]&&e[1]===e[e.length-1],n=Math.max(1,e.length/2-(t?1:0)),[r,o]=[0,0];for(let s=0;s<n;s+=1)[r,o]=[r+(e[s*2]??0),o+(e[s*2+1]??0)];return[r/n,o/n]},ro=(e,t)=>{let n=e.filter((s)=>s.type===3),r=n.filter((s)=>no(s.geometry,t)),o=new Set(r);return r.forEach((s)=>{let[a,i,c,l]=At(s.geometry[0]??[]),u=In(s.geometry[0]??[]);n.forEach((p)=>{if(o.has(p))return;let[f,d,w,h]=At(p.geometry[0]??[]);if(w<a||f>c||h<i||d>l)return;if(ge(s.geometry,...In(p.geometry[0]??[]))||ge(p.geometry,...u))o.add(p)})}),o},oo={line:(e)=>e!==1,circle:(e)=>e===1,fill:(e)=>e===3,extrusion:(e)=>e===3},so=(e,t)=>{let n=_n(e,t);return[n===void 0?0:wn(n)??0,An(e)]},io=24,ao=(e,t,n,r)=>{if(!at(e.filter))return Q(e.filter,Z(t,n))?[0,0]:void 0;let o,s=0;for(let a=n-1;a<=r;a+=1)if(Q(e.filter,Z(t,a)))o??=a,s=a+1;else if(o!==void 0)break;return o===void 0?void 0:[o<=n-1?0:o,s>r?99:s]},co=(e,t)=>{let n=e.slice(),r=[[0,0,(o)=>o>=0],[0,t,(o)=>o<=t],[1,0,(o)=>o>=0],[1,t,(o)=>o<=t]];for(let[o,s,a]of r){let i=[],c=n.length/2;for(let l=0;l<c;l+=1){let[u,p]=[n[l*2]??0,n[l*2+1]??0],f=(l+1)%c,[d,w]=[n[f*2]??0,n[f*2+1]??0],[h,A]=o===0?[u,d]:[p,w];if(a(h))i.push(u,p);if(a(h)!==a(A)){let m=(s-h)/(A-h);i.push(o===0?s:u+(d-u)*m,o===0?p+(w-p)*m:s)}}if(n=i,n.length===0)break}return n},lo=0.00048828125,uo=(e,t)=>{let n=e.length/2;if(n<=2)return[...e];let r=new Uint8Array(n),o=[[0,n-1]],s=t*t;r[0]=1,r[n-1]=1;while(o.length>0){let[a,i]=o.pop()??[0,0],[c,l,u,p]=[e[a*2]??0,e[a*2+1]??0,e[i*2]??0,e[i*2+1]??0],[f,d]=[u-c,p-l],w=f*f+d*d,[h,A]=[-1,s];for(let m=a+1;m<i;m+=1){let[M,b]=[(e[m*2]??0)-c,(e[m*2+1]??0)-l],x=w>0?Math.max(0,Math.min(1,(M*f+b*d)/w)):0,T=(M-x*f)**2+(b-x*d)**2;if(T>A)[h,A]=[m,T]}if(h>=0)r[h]=1,o.push([a,h],[h,i])}return e.filter((a,i)=>r[i>>1]===1)},fo=(e,t)=>{let n=[],r=[],o=()=>{if(r.length>=4)n.push(r);r=[]};for(let s=2;s+1<e.length;s+=2){let[a,i,c,l]=[e[s-2]??0,e[s-1]??0,e[s]??0,e[s+1]??0],[u,p]=[c-a,l-i],[f,d]=[0,1];for(let[w,h]of[[-u,a],[u,t-a],[-p,i],[p,t-i]])if(w===0){if(h<0)d=-1}else if(w<0)f=Math.max(f,h/w);else d=Math.min(d,h/w);if(f>d){o();continue}if(r.length===0||f>0)o(),r.push(a+u*f,i+p*f);if(r.push(a+u*d,i+p*d),d<1)o()}return o(),n},mo=(e,t)=>e>=t?[e-0.5,e+1,e+3,e+6]:[e-0.5,e-0.16666666666666666,e+0.16666666666666666,e+0.5],po=(e,t,n,r,o)=>{let s=2**n,[a,i]=[r*t,o*t],c=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];e.forEach((d)=>{for(let w=0;w+1<d.length;w+=2){let[h,A]=[(d[w]??0)*s-a,(d[w+1]??0)*s-i];c[0]=Math.min(c[0]??h,h),c[1]=Math.min(c[1]??A,A),c[2]=Math.max(c[2]??h,h),c[3]=Math.max(c[3]??A,A)}});let[l=0,u=0,p=0,f=0]=c;if(p<=0||f<=0||l>=t||u>=t)return;return e.map((d)=>d.map((w,h)=>w*s-(h%2===0?a:i)))},bo=(e)=>{let t=[],n=[],r=[],o=[];return{add:(i,c,l,u,p,f=!1)=>{let d=(b,x,T)=>C(c,"paint",b,{...l,zoom:T},x),w=`${c.type}-opacity`,h=me(c.paint?.[w]),A=(b)=>{let[x,T,E,_]=ce(d(f?"fill-outline-color":`${c.type}-color`,"#000",b))??[0,0,0,1];return[x,T,E,_*(h?Number(d(w,1,b)):1)]},m=Array(wt).fill(0),M=e[3]-e[0]>1.5?e[1]:e[3];if(m.splice(q.color,8,...A(e[0]),...A(M)),m.splice(q.range,2,...p),!f&&["fill","background","line","fill-extrusion"].includes(c.type)){let b=d(`${c.type}-pattern`,"",(e[0]+M)/2);if(typeof b==="string"&&b){let x=n.indexOf(b);m[c.type==="fill"||c.type==="background"?q.fillPattern:q.linePattern]=(x>=0?x:n.push(b)-1)+1}}if(c.type==="circle"){let b=(e[0]+M)/2,[x,T,E,_]=ce(d("circle-stroke-color","#000",b))??[0,0,0,1];m.splice(q.color,8,...A(b),x,T,E,_*Number(d("circle-stroke-opacity",1,b)))}return e.forEach((b,x)=>{if(m[q.size+x]=b,f){m[q.size+4+x]=1;return}if(c.type==="circle"){m[q.size+4+x]=Math.max(0,Number(d("circle-radius",5,b))||0),m[q.size2+x]=b,m[q.size2+4+x]=Math.max(0,Number(d("circle-stroke-width",0,b))||0);return}if(c.type==="fill-extrusion"){m[q.size+4+x]=Math.max(0,Number(d("fill-extrusion-height",0,b))||0),m[q.size2+x]=b,m[q.size2+4+x]=Math.max(0,Number(d("fill-extrusion-base",0,b))||0);return}if(c.type!=="line")return;if(x===0)m[q.blur]=Math.max(0,Number(d("line-blur",0,(e[0]+M)/2))||0);let T=Number(d("line-width",1,b)),E=Number(d("line-gap-width",0,b));m[q.size+4+x]=Math.max(0,E>0?E+2*T:T),m[q.size2+x]=b,m[q.size2+4+x]=Number(d("line-offset",0,b))||0}),t.push(...m),r.push(u),o.push(i),r.length-1},landmark:(i)=>{t[i*wt+q.landmark]=1},styles:t,patterns:n,properties:r,sublayer:o}},yo=(e,t,n)=>{let r={points:[],ringStart:[],polygonStart:[],feature:[],roofs:[],roofHeights:[],roofOutlines:[],roofOutlineStart:[]},o={points:[],start:[],feature:[]},s={points:[],feature:[]},a={fill:[],line:[],circle:[]},i=(u,p,f)=>[(e+u/f)/n,(t+p/f)/n],c=(u,p,f)=>{r.polygonStart.push(r.ringStart.length),r.feature.push(u),r.roofs.push(p),r.roofHeights.push(f),r.roofOutlineStart.push(r.roofOutlines.length/2)},l=()=>{a.fill.push(r.polygonStart.length),a.line.push(o.start.length),a.circle.push(s.feature.length)};return{sublayer:l,background:(u)=>{c(u,0,Number.NaN),r.ringStart.push(r.points.length/2),r.points.push(e/n,t/n,(e+1)/n,t/n,(e+1)/n,(t+1)/n,e/n,(t+1)/n)},circles:(u,p,f)=>{u.forEach((d)=>{for(let w=0;w+1<d.length;w+=2){let[h=0,A=0]=[d[w],d[w+1]];if(h<0||A<0||h>=f||A>=f)continue;s.points.push(...i(h,A,f)),s.feature.push(p)}})},lines:(u,p,f,d)=>{u.forEach((w)=>{let h=p&&w.length>=2?[...w,w[0]??0,w[1]??0]:w;fo(h,d).forEach((A)=>{let m=uo(A,d*lo);o.start.push(o.points.length/2),o.feature.push(f);for(let M=0;M+1<m.length;M+=2)o.points.push(...i(m[M]??0,m[M+1]??0,d))})})},polygons:(u,p,[f,d],w)=>{let h=!1;u.forEach((A)=>{let m=0;for(let b=0;b+1<A.length;b+=2){let x=(b+2)%A.length;m+=(A[b]??0)*(A[x+1]??0)-(A[x]??0)*(A[b+1]??0)}if(m===0)return;if(m<0&&!h)return;let M=co(A,w);if(m>0)h=M.length>=6;if(M.length<6)return;if(m>0){if(c(p,f,d),f>1&&A.some((b)=>b<0||b>w))for(let b=0;b+1<A.length;b+=2)r.roofOutlines.push(...i(A[b]??0,A[b+1]??0,w))}r.ringStart.push(r.points.length/2);for(let b=0;b+1<M.length;b+=2)r.points.push(...i(M[b]??0,M[b+1]??0,w))})},done:()=>(l(),r.ringStart.push(r.points.length/2),r.polygonStart.push(r.ringStart.length-1),r.roofOutlineStart.push(r.roofOutlines.length/2),o.start.push(o.points.length/2),{fills:{points:Float64Array.from(r.points),ringStart:Uint32Array.from(r.ringStart),polygonStart:Uint32Array.from(r.polygonStart),feature:Uint32Array.from(r.feature),fillStart:Uint32Array.from(a.fill),roofs:Uint8Array.from(r.roofs),roofHeights:Float32Array.from(r.roofHeights),roofOutlines:Float64Array.from(r.roofOutlines),roofOutlineStart:Uint32Array.from(r.roofOutlineStart),roofMetres:rt((t+0.5)/n)},lines:{points:Float64Array.from(o.points),start:Uint32Array.from(o.start),feature:Uint32Array.from(o.feature),lineStart:Uint32Array.from(a.line)},circles:{points:Float64Array.from(s.points),feature:Uint32Array.from(s.feature),circleStart:Uint32Array.from(a.circle)},tile:Float64Array.of(e/n,t/n,(e+1)/n,(t+1)/n)})}},Fn=async(e,t,n)=>{let{z:r,x:o,y:s,id:a,priority:i,deepest:c=e.maxzoom,roofs:l="data",covered:u=[]}=t,p=Math.max(0,r-e.maxzoom),[f,d,w]=[r-p,Math.floor(o/2**p),Math.floor(s/2**p)],[h,A]=[o-d*2**p,s-w*2**p],m=await ee(K(e.tiles,f,d,w),i);if(j.has(a))return;let M=to(m),b=new Map,x=(g)=>{let y=b.get(g)??(M.length>0?ro(g,M):new Set);return b.set(g,y),y},T=(g,y)=>{if(u.length===0)return!1;let[S=0,k=0]=g.geometry[0]??[],[v,R]=H(f,d,w,y,S,k);for(let U=0;U+3<u.length;U+=4)if(v>=(u[U]??0)&&R>=(u[U+1]??0)&&v<=(u[U+2]??0)){if(R<=(u[U+3]??0))return!0}return!1},E=bo(mo(r,Math.max(c,e.maxzoom))),_=r>=Math.max(c,e.maxzoom)?io:r;return e.layers.forEach((g,y)=>{n?.sublayer();let S=je(g),k=g.type==="fill"&&g.paint?.["fill-outline-color"]!==void 0&&g.paint?.["fill-antialias"]!==!1;if(!S)return;if(g.type==="background"){let R=E.add(y,g,{zoom:r,properties:{},type:"Unknown"},{},[0,0]);n?.background(R);return}let v=m?.get(g["source-layer"]??"");v?.features.forEach((R)=>{if(!oo[S](R.type))return;if(S==="extrusion"&&T(R,v.extent))return;let U=Z(R,r),B=ao(g,R,r,_);if(!B)return;let P=p>0?po(R.geometry,v.extent,p,h,A):R.geometry;if(!P)return;let L=E.add(y,g,U,R.properties,B),I=k?E.add(y,g,U,R.properties,B,!0):-1;if(S==="extrusion"&&x(v.features).has(R))E.landmark(L);if(!n)return;if(S==="circle"){n.circles(P,L,v.extent);return}if(S==="line"){n.lines(P,R.type===3,L,v.extent);return}if(I>=0)n.lines(P,!0,I,v.extent);let F=S==="extrusion"?so(R.properties,l):[0,Number.NaN];n.polygons(P,L,F,v.extent)})}),E},Nn=async(e,t)=>{let n=await Fn(e,t);return n&&{styles:Float32Array.from(n.styles),patterns:n.patterns}},On=async(e,t)=>{let n=yo(t.x,t.y,2**t.z),r=await Fn(e,t,n);if(!r)return;return{...n.done(),styles:Float32Array.from(r.styles),patterns:r.patterns,properties:r.properties,sublayer:Uint16Array.from(r.sublayer)}},we={},Pn=()=>{if(!we.url)return Promise.resolve(!1);let e=we.ready??En({module_or_path:we.url}).then(()=>!0,(t)=>(console.warn("isard: the tessellation module failed to load, the main thread does its work",t),!1));return we.ready=e,e},Ln=(e,t,n)=>{let{fills:r,lines:o}=e;try{let s=kn(r.points,r.ringStart,r.polygonStart,r.feature,r.fillStart,o.points,o.start,o.feature,o.lineStart,t,r.roofs??new Uint8Array,r.roofHeights??new Float32Array,r.roofOutlines??new Float64Array,r.roofOutlineStart??new Uint32Array,r.roofMetres??0,n,e.tile??new Float64Array),a={vertices:s.vertices(),indices:s.indices(),fillRanges:s.fillRanges(),prism:s.prism(),pieces:s.pieces(),lineTable:s.lineTable(),lineRanges:s.lineRanges(),blocks:s.blocks(),blockIndices:s.blockIndices(),blockRanges:s.blockRanges(),bounds:s.bounds()};return s.free(),a}catch(s){console.warn("isard: the tessellation module failed, the main thread does its work",s),we.ready=Promise.resolve(!1);return}};var ho={primary:8,secondary:7,tertiary:6,minor:5,service:4},Un=async(e,t)=>{let{z:n,x:r,y:o,id:s,spacing:a,maxLamps:i,priority:c}=t,l=K(e.tiles,n,r,o),u=await ee(l,c);if(!u||j.has(s))return;let p=_e(n,o),f=new Set,d=[];return e.layers.forEach((w)=>{let h=u.get(w["source-layer"]??"");if(!h)return;let A=h.extent/p;h.features.forEach((m)=>{let M=ho[String(m.properties.class)];if(m.type!==2||M===void 0||f.has(m)||!Q(w.filter,Z(m,n)))return;f.add(m),m.geometry.forEach((b)=>{Ae(b,a*A).forEach((x,T)=>{let[E,_,g]=Ke(x,T,M*A);if(E<0||_<0||E>=h.extent||_>=h.extent)return;let[y,S]=H(n,r,o,h.extent,E,_),k=se(Math.floor(E),Math.floor(_),Math.floor(x[6]??0),29);d.push(y,S,1,g,k,0)})})})}),Ze(d,i)};var go=new Set(["butt","round","square"]),wo=new Set(["bevel","miter","round"]),xo=(e)=>go.has(e),_o=(e)=>wo.has(e),Ao=(e)=>xo(e)?e:"butt",Mo=(e)=>_o(e)?e:"miter",So=(e,t)=>{if(e.patterns.has(t))return e.patterns.get(t);let r=(()=>{let o=gt(e,t);if(!o||!(o.icon.width>0)||!(o.icon.height>0))return;let{icon:s}=o,a=new OffscreenCanvas(s.width,s.height);return a.getContext("2d")?.drawImage(o.image,s.x,s.y,s.width,s.height,0,0,s.width,s.height),a})();return e.patterns.set(t,r),r},Mt=new Map,ko=(e)=>{let t=Mt.get(e)?.pop()??new OffscreenCanvas(e,e),n=t.getContext("2d",{willReadFrequently:!0});if(!n)throw Error("isard: no 2D context");return n.setTransform(1,0,0,1,0,0),n.globalAlpha=1,n.setLineDash([]),n.clearRect(0,0,e,e),{canvas:t,g:n}},vo=(e)=>{let t=Mt.get(e.width)??[];if(Mt.set(e.width,t),t.length<4)t.push(e)},Ro=(e,t,n)=>{if(n)return Promise.resolve(e.transferToImageBitmap());return createImageBitmap(t.getImageData(0,0,e.width,e.height),{premultiplyAlpha:"none"})},Cn=async(e,t)=>{let{z:n,x:r,y:o,size:s,id:a,priority:i}=t,c=un(e,n,r,o),l=await ee(c.url,i);if(j.has(a))return;let{canvas:u,g:p}=ko(s);try{return await To(e,c,l,u,p,n,r,o,s,a,i)}finally{vo(u)}},To=async(e,t,n,r,o,s,a,i,c,l,u)=>{let p=Math.max(0,s-1),f=c/256,d=!1,w=!1;for(let h of e.layers){if(!Le(h,p))continue;let A={zoom:p,properties:{},type:"Unknown"};if(h.type==="background"){let g=C(h,"paint","background-color",A,"#000"),y=Number(C(h,"paint","background-opacity",A,1));if(o.fillStyle=pe(g,y),o.fillRect(0,0,c,c),(ce(g)??[0,0,0,1])[3]*y>=1)w=!0;d=!0;continue}if(h.type==="raster"){let g=h.source===void 0?void 0:e.rasters[h.source];if(!g)continue;let y=xe(s-(g.tileSize>=512?1:0),0,g.maxzoom),S=2**(s-y),k=K(g.tiles,y,Math.floor(a/S),Math.floor(i/S)),v=await ln(k,u);if(j.has(l))return;if(!v)continue;let[R,U]=[v.width/S,v.height/S];o.globalAlpha=Number(C(h,"paint","raster-opacity",A,1)),o.drawImage(v,a%S*R,i%S*U,R,U,0,0,c,c),o.globalAlpha=1,d=!0;continue}let m=n?.get(h["source-layer"]??"");if(!m)continue;let M=c/(m.extent*t.part),[b,x]=[t.ox*m.extent,t.oy*m.extent],T=(g,y)=>{o.beginPath();for(let S of g.geometry){for(let k=0;k+1<S.length;k+=2){let[v,R]=[((S[k]??0)-b)*M,((S[k+1]??0)-x)*M];if(k===0)o.moveTo(v,R);else o.lineTo(v,R)}if(y)o.closePath()}},E=new Map,_=(g,y,S,k)=>{let v=E.get(y),R=v??me(h[g]?.[y]);if(v===void 0)E.set(y,R);return C(h,g,y,R?S:A,k)};for(let g of m.features){let y=Z(g,p);if(!Q(h.filter,y))continue;if(h.type==="fill-extrusion"&&g.type===3)T(g,!0),o.fillStyle=pe(_("paint","fill-extrusion-color",y,"#000"),Number(_("paint","fill-extrusion-opacity",y,1))),o.fill("evenodd"),d=!0;else if(h.type==="fill"&&g.type===3){let S=Number(_("paint","fill-opacity",y,1)),k=_("paint","fill-pattern",y,void 0);T(g,!0);let v=typeof k==="string"?gt(e,k)?.icon:void 0,R=v&&typeof k==="string"&&So(e,k);if(v&&R){let U=o.createPattern(R,"repeat");if(U)U.setTransform(new DOMMatrix().scale(f/(v.pixelRatio??1))),o.globalAlpha=S,o.fillStyle=U,o.fill("evenodd"),o.globalAlpha=1}else{o.fillStyle=pe(_("paint","fill-color",y,"#000"),S),o.fill("evenodd");let U=_("paint","fill-outline-color",y,void 0);if(U!==void 0)o.strokeStyle=pe(U,S),o.lineWidth=f,o.setLineDash([]),o.stroke()}d=!0}else if(h.type==="line"&&g.type!==1){let S=Number(_("paint","line-width",y,1));if(S<=0)continue;let k=Number(_("paint","line-gap-width",y,0));o.strokeStyle=pe(_("paint","line-color",y,"#000"),Number(_("paint","line-opacity",y,1))),o.lineWidth=(k>0?k+2*S:S)*f,o.lineCap=Ao(_("layout","line-cap",y,"butt")),o.lineJoin=Mo(_("layout","line-join",y,"miter"));let v=_("paint","line-dasharray",y,void 0);o.setLineDash(Array.isArray(v)?v.map((R)=>Number(R)*S*f):[]),T(g,g.type===3),o.stroke(),d=!0}else if(h.type==="circle"&&g.type===1){let S=Number(_("paint","circle-radius",y,5))*f;o.fillStyle=pe(_("paint","circle-color",y,"#000"),Number(_("paint","circle-opacity",y,1)));let k=Number(_("paint","circle-stroke-width",y,0))*f;o.strokeStyle=pe(_("paint","circle-stroke-color",y,"#000"),Number(_("paint","circle-stroke-opacity",y,1))),o.lineWidth=k;for(let v of g.geometry)for(let R=0;R+1<v.length;R+=2)if(o.beginPath(),o.arc(((v[R]??0)-b)*M,((v[R+1]??0)-x)*M,S,0,2*Math.PI),o.fill(),k>0)o.stroke();d=!0}}}if(!d&&!n)return null;return Ro(r,o,w)};var Wn=async(e,t)=>{let{z:n,tiles:r,bounds:o,width:s,height:a,iterations:i,module:c,priority:l,id:u}=t,[p,f,d,w]=o,h=[],A=[],m=[],M=2**n;for(let b=0;b+1<r.length;b+=2){let x=r[b]??0,T=(x%M+M)%M,E=(x-T)/M,_=await tt(e,{z:n,x:T,y:r[b+1]??0,id:u,priority:l});if(j.has(u))throw Error("aborted");if(!_)continue;let{points:g,ringStart:y,polygonStart:S}=_.arrays;for(let k=0;k+1<S.length;k++){let[v,R]=[S[k]??0,S[k+1]??0],U=y[v]??0,B=y[R]??0,[P,L,I,F]=[1/0,1/0,-1/0,-1/0];for(let N=U;N<B;N++){let[W,V]=[(g[N*2]??0)+E,g[N*2+1]??0];P=Math.min(P,W),L=Math.min(L,V),I=Math.max(I,W),F=Math.max(F,V)}if(I<p||P>d||F<f||L>w)continue;m.push(A.length);for(let N=v;N<R;N++){A.push(h.length/2);for(let W=y[N]??0;W<(y[N+1]??0);W++)h.push(((g[W*2]??0)+E-p)/(d-p)*s,((g[W*2+1]??0)-f)/(w-f)*a)}}}return A.push(h.length/2),m.push(A.length-1),Zt({points:Float64Array.from(h),ringStart:Uint32Array.from(A),polygonStart:Uint32Array.from(m)},s,a,i,c)};var St=new Map,Eo={},Dn=Tt(),ue=(e,t=[])=>self.postMessage(e,t),Io=({fills:e,lines:t,circles:n,styles:r,sublayer:o,mesh:s})=>[e.points,e.ringStart,e.polygonStart,e.feature,e.fillStart,e.roofs,e.roofHeights,e.roofOutlines,e.roofOutlineStart,t.points,t.start,t.feature,t.lineStart,n?.points,n?.feature,n?.circleStart,r,o,s?.vertices,s?.indices,s?.fillRanges,s?.pieces,s?.lineTable,s?.lineRanges,s?.blocks,s?.blockIndices,s?.blockRanges,s?.bounds].flatMap((a)=>a?[a.buffer]:[]),Fo={render:async(e,t)=>{let n=await Cn(e,t);return n?[{image:n},[n]]:void 0},labels:async(e,t)=>[{labels:await pn(e,t)},[]],polygons:async(e,t)=>{let n=await tt(e,t);if(!n)return;let{points:r,ringStart:o,polygonStart:s,feature:a}=n.arrays;return[{polygons:n},[r.buffer,o.buffer,s.buffer,a.buffer]]},trees:async(e,t)=>{let n=await bn(e,t);return n&&[{trees:n},[n.buffer]]},furniture:async(e,t)=>{let n=await hn(e,t);return n&&[{furniture:n},[n.buffer]]},lamps:async(e,t)=>{let n=await Un(e,t);return n&&[{lamps:n},[n.buffer]]},street:async(e,t)=>{let n=await Wn(e,t);return[{street:n},[n.eastU,n.eastV,n.northU,n.northV].map((r)=>r.buffer)]},vectors:async(e,t)=>{if(t.styles){let a=await Nn(e,t);return a&&[a,[a.styles.buffer]]}let n=await On(e,t);if(!n)return;let r=Uint8Array.from(e.layers,(a)=>je(a)==="extrusion"?1:0),o=await Pn()?Ln(n,r,t.prism===!0):void 0,s=o?{...n,mesh:o}:n;return[{vectors:s},Io(s)]}},No=(e,t,n)=>Fo[t](e,n);self.onmessage=async({data:e})=>{if(e.type==="headers"){Rt(e.rules);return}if(e.type==="tess"){we.url=e.url;return}if(e.type==="init"){if(e.workers!==void 0)Oe.capacity=an(e.workers);Pe.set(e.key,{tiles:e.tiles,maxzoom:e.maxzoom,layers:e.layers,rasters:e.rasters??{},sprites:e.sprites??[],patterns:new Map});return}if(e.type==="drop"){Pe.get(e.key)?.sprites.forEach((t)=>{t.image.close()}),Pe.delete(e.key);return}if(e.type==="abort"){if(Ye.has(e.id))j.add(e.id);St.get(e.id)?.abort();return}if(e.type==="heights"||e.type==="reproject"||e.type==="grids"){await Po(e);return}Ye.add(e.id);try{let t=Pe.get(e.key);if(!t)throw Error(`isard: no renderer ${e.key}`);let n=await No(t,e.type,e);if(n)ue({id:e.id,...n[0]},n[1]);else ue({id:e.id,missing:!0})}catch(t){ue({id:e.id,error:String(t)})}finally{Ye.delete(e.id),j.delete(e.id)}};var Oo=async(e,t)=>(await kt(e,oe(e,{signal:t}))).arrayBuffer(),Po=async(e)=>{let t=new AbortController;St.set(e.id,t);try{if(e.type==="grids"){let{module:n,url:r,bytes:o}=e,s=o??(r?await Oo(r,t.signal):new ArrayBuffer(0)),{grids:a,values:i}=await Xt(new Uint8Array(s),n);ue({id:e.id,grids:a,values:i},i.map((c)=>c.buffer))}else if(e.type==="heights"){let n=await Nt(e.url,e.encoding,e.floor,t.signal,Eo);if(n)ue({id:e.id,heights:n},[n.buffer]);else ue({id:e.id,missing:!0})}else{Dn.cache.capacity=e.cached;let n=await Dn.draw(e.job,t.signal);if(n)ue({id:e.id,image:n},[n]);else ue({id:e.id,missing:!0})}}catch(n){ue({id:e.id,error:String(n)})}finally{St.delete(e.id)}};
|
|
1
|
+
var ie=(e,t)=>Error(`isard: ${String(e)}: HTTP ${t}`),kt=async(e,t)=>{let n=await fetch(e,t);if(!n.ok)throw ie(e,n.status);return n};class le{capacity;evict;entries=new Map;constructor(e,t){this.capacity=e;this.evict=t}get size(){return this.entries.size}get(e){let t=this.entries.get(e);if(t!==void 0)this.entries.delete(e),this.entries.set(e,t);return t}has(e){return this.entries.has(e)}set(e,t){this.entries.delete(e),this.entries.set(e,t);for(let[n,r]of this.entries){if(this.entries.size<=this.capacity)break;this.entries.delete(n),this.evict?.(r,n)}}delete(e){return this.entries.delete(e)}values(){return this.entries.values()}clear(){this.entries.clear()}}var vt=[];var Rt=(e)=>{vt=e};var oe=(e,t={})=>{let n=String(e),r=vt.filter(([s])=>n.startsWith(s));if(r.length===0)return t;let o=new Headers(t.headers);return r.forEach(([,s])=>{Object.entries(s).forEach(([a,i])=>{o.set(a,i)})}),{...t,headers:o}};var Hn=96,Jn=(e,t,n,r,o,s)=>{let a=new Uint8ClampedArray(s*s*4),i=s/o,c=o+1;for(let l=0;l<s;l+=1){let u=(l+0.5)/i,p=Math.min(o-1,Math.floor(u)),f=u-p;for(let d=0;d<s;d+=1){let w=(d+0.5)/i,h=Math.min(o-1,Math.floor(w)),A=w-h,m=2*(p*c+h),M=m+2*c,b=(1-A)*(1-f),x=A*(1-f),T=(1-A)*f,E=A*f,_=b*r[m]+x*r[m+2]+T*r[M]+E*r[M+2],g=b*r[m+1]+x*r[m+3]+T*r[M+1]+E*r[M+3],y=_-0.5,S=g-0.5;if(!(y>-1&&S>-1&&y<t&&S<n))continue;let k=Math.floor(y),v=Math.floor(S),R=y-k,U=S-v,B=0,P=0,L=0,I=0;for(let N=0;N<4;N+=1){let W=k+(N&1),V=v+(N>>1);if(W<0||V<0||W>=t||V>=n)continue;let J=4*(V*t+W),z=(N&1?R:1-R)*(N>>1?U:1-U)*e[J+3];B+=z*e[J],P+=z*e[J+1],L+=z*e[J+2],I+=z}if(I<=0)continue;let F=4*(l*s+d);a[F]=B/I,a[F+1]=P/I,a[F+2]=L/I,a[F+3]=I}}return a},Tt=(e=Hn)=>{let t=new Map,n=new Set,r=(l)=>{n.delete(l),l.then((u)=>u?.close(),()=>{return})},o=(l)=>{if(t.has(l))n.add(l);else r(l)},s=new le(e,o),a=(l)=>{let u=(t.get(l)??1)-1;if(u>0)t.set(l,u);else if(t.delete(l),n.has(l))r(l)},i=(l)=>{let u=()=>{let f=(async()=>{let d=await fetch(l,oe(l));if(d.status===404||d.status===204||d.status===410)return null;if(!d.ok)throw ie(l,d.status);return createImageBitmap(await d.blob())})();return f.catch(()=>s.delete(l)),s.set(l,f),f},p=s.get(l)??u();return t.set(p,(t.get(p)??0)+1),p};return{draw:async(l,u)=>{let p=l.sources.map((f)=>[f,i(f.url)]);try{let f=await Promise.all(p.map(async([m,M])=>[m,await M]));if(u.throwIfAborted(),!f.some(([,m])=>m))return null;let w=new OffscreenCanvas(l.width,l.height).getContext("2d",{willReadFrequently:!0});if(!w)throw Error("isard: no 2D canvas to reproject the tiles");f.forEach(([m,M])=>{if(M)w.drawImage(M,m.x,m.y,m.w,m.h)});let h=w.getImageData(0,0,l.width,l.height).data,A=Jn(h,l.width,l.height,l.mesh,l.n,l.size);return createImageBitmap(new ImageData(A,l.size,l.size),{premultiplyAlpha:"none"})}finally{p.forEach(([,f])=>{a(f)})}},cache:s,close:()=>{[...s.values()].forEach(o),s.clear()}}};var xe=(e,t,n)=>Math.max(t,Math.min(n,e));var Ho=Math.PI/180,Et=40075016.686,Jo=Et/360;var It=(e)=>e*360-180,Ft=(e)=>Math.atan(Math.sinh(Math.PI*(1-2*e)))*180/Math.PI;var rt=(e)=>Et*Math.cos(Math.atan(Math.sinh(Math.PI*(1-2*e)))),_e=(e,t)=>rt((t+0.5)/2**e)/2**e,K=(e,t,n,r)=>e.replaceAll("{z}",String(t)).replaceAll("{x}",String(n)).replaceAll("{y}",String(r));var fe=256,jn=(e,t,n=Number.NEGATIVE_INFINITY)=>{let r=e.length>>2,o=new Float32Array(r);if(t==="terrarium")for(let s=0,a=0;s<r;s+=1,a+=4){let i=e[a]*256+e[a+1]+e[a+2]/256-32768;o[s]=i>n?i:n}else for(let s=0,a=0;s<r;s+=1,a+=4){let i=-1e4+(e[a]*65536+e[a+1]*256+e[a+2])*0.1;o[s]=i>n?i:n}return o},Nt=async(e,t,n,r,o)=>{let s=await fetch(e,oe(e,{signal:r}));if(s.status===404||s.status===204||s.status===410)return null;if(!s.ok)throw ie(e,s.status);let a=await createImageBitmap(await s.blob(),{premultiplyAlpha:"none",colorSpaceConversion:"none"});try{o.canvas??=new OffscreenCanvas(fe,fe);let i=o.canvas.getContext("2d",{willReadFrequently:!0});if(!i)throw Error("isard: no 2D context");return i.imageSmoothingEnabled=!1,i.clearRect(0,0,fe,fe),i.drawImage(a,0,0,fe,fe),jn(i.getImageData(0,0,fe,fe).data,t,n)}finally{a.close()}};var qn="aliceblue f0f8ff antiquewhite faebd7 aqua 00ffff aquamarine 7fffd4 azure f0ffff beige f5f5dc bisque ffe4c4 black 000000 blanchedalmond ffebcd blue 0000ff blueviolet 8a2be2 brown a52a2a burlywood deb887 cadetblue 5f9ea0 chartreuse 7fff00 chocolate d2691e coral ff7f50 cornflowerblue 6495ed cornsilk fff8dc crimson dc143c cyan 00ffff darkblue 00008b darkcyan 008b8b darkgoldenrod b8860b darkgray a9a9a9 darkgreen 006400 darkgrey a9a9a9 darkkhaki bdb76b darkmagenta 8b008b darkolivegreen 556b2f darkorange ff8c00 darkorchid 9932cc darkred 8b0000 darksalmon e9967a darkseagreen 8fbc8f darkslateblue 483d8b darkslategray 2f4f4f darkslategrey 2f4f4f darkturquoise 00ced1 darkviolet 9400d3 deeppink ff1493 deepskyblue 00bfff dimgray 696969 dimgrey 696969 dodgerblue 1e90ff firebrick b22222 floralwhite fffaf0 forestgreen 228b22 fuchsia ff00ff gainsboro dcdcdc ghostwhite f8f8ff gold ffd700 goldenrod daa520 gray 808080 green 008000 greenyellow adff2f grey 808080 honeydew f0fff0 hotpink ff69b4 indianred cd5c5c indigo 4b0082 ivory fffff0 khaki f0e68c lavender e6e6fa lavenderblush fff0f5 lawngreen 7cfc00 lemonchiffon fffacd lightblue add8e6 lightcoral f08080 lightcyan e0ffff lightgoldenrodyellow fafad2 lightgray d3d3d3 lightgreen 90ee90 lightgrey d3d3d3 lightpink ffb6c1 lightsalmon ffa07a lightseagreen 20b2aa lightskyblue 87cefa lightslategray 778899 lightslategrey 778899 lightsteelblue b0c4de lightyellow ffffe0 lime 00ff00 limegreen 32cd32 linen faf0e6 magenta ff00ff maroon 800000 mediumaquamarine 66cdaa mediumblue 0000cd mediumorchid ba55d3 mediumpurple 9370db mediumseagreen 3cb371 mediumslateblue 7b68ee mediumspringgreen 00fa9a mediumturquoise 48d1cc mediumvioletred c71585 midnightblue 191970 mintcream f5fffa mistyrose ffe4e1 moccasin ffe4b5 navajowhite ffdead navy 000080 oldlace fdf5e6 olive 808000 olivedrab 6b8e23 orange ffa500 orangered ff4500 orchid da70d6 palegoldenrod eee8aa palegreen 98fb98 paleturquoise afeeee palevioletred db7093 papayawhip ffefd5 peachpuff ffdab9 peru cd853f pink ffc0cb plum dda0dd powderblue b0e0e6 purple 800080 rebeccapurple 663399 red ff0000 rosybrown bc8f8f royalblue 4169e1 saddlebrown 8b4513 salmon fa8072 sandybrown f4a460 seagreen 2e8b57 seashell fff5ee sienna a0522d silver c0c0c0 skyblue 87ceeb slateblue 6a5acd slategray 708090 slategrey 708090 snow fffafa springgreen 00ff7f steelblue 4682b4 tan d2b48c teal 008080 thistle d8bfd8 tomato ff6347 turquoise 40e0d0 violet ee82ee wheat f5deb3 white ffffff whitesmoke f5f5f5 yellow ffff00 yellowgreen 9acd32",ot,$n=(e)=>{if(!ot){let t=qn.split(" ");ot=new Map(Array.from({length:Math.floor(t.length/2)},(n,r)=>[t[2*r]??"",t[2*r+1]??""]))}return ot.get(e)},ze=(e)=>Number.isFinite(e)?xe(e,0,1):0,Ot=(e)=>{if(!/^[0-9a-f]+$/.test(e)||![3,4,6,8].includes(e.length))return;let t=e.length<=4?[...e].map((r)=>r+r).join(""):e,n=(r)=>Number.parseInt(t.slice(r,r+2),16)/255;return[n(0),n(2),n(4),t.length===8?n(6):1]},Yn=(e)=>{if(e===void 0)return 1;return ze(e.endsWith("%")?Number.parseFloat(e)/100:Number.parseFloat(e))},Gn=(e,t,n)=>{let r=n<0.5?n*(1+t):n+t-n*t,o=2*n-r,s=(a)=>{let i=(a%1+1)%1;if(i<0.16666666666666666)return o+(r-o)*6*i;if(i<0.5)return r;if(i<0.6666666666666666)return o+(r-o)*(0.6666666666666666-i)*6;return o};return[s(e+0.3333333333333333),s(e),s(e-0.3333333333333333)]},Pt=(e)=>{if(typeof e!=="string")return;let t=e.trim().toLowerCase();if(t.startsWith("#"))return Ot(t.slice(1));if(t==="transparent")return[0,0,0,0];let n=$n(t);if(n)return Ot(n);let r=/^(rgba?|hsla?)\(([^)]*)\)$/.exec(t);if(!r?.[1]||r[2]===void 0)return;let o=r[2].split(/[\s,/]+/).filter(Boolean);if(o.length<3||o.slice(0,3).some((u)=>Number.isNaN(Number.parseFloat(u))))return;let s=Yn(o[3]);if(r[1].startsWith("rgb")){let u=(p)=>ze(p.endsWith("%")?Number.parseFloat(p)/100:Number.parseFloat(p)/255);return[u(o[0]??""),u(o[1]??""),u(o[2]??""),s]}let a=Number.parseFloat(o[0]??"")/360,[i,c,l]=Gn(a,ze(Number.parseFloat(o[1]??"")/100),ze(Number.parseFloat(o[2]??"")/100));return[i,c,l,s]};var be=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);var Kn=["Unknown","Point","LineString","Polygon"],Z=(e,t)=>({zoom:t,properties:e.properties,type:Kn[e.type]??"Unknown"}),ce=(e)=>Pt(e),Je=([e,t,n,r])=>`rgba(${Math.round(e*255)},${Math.round(t*255)},${Math.round(n*255)},${r})`,Wt=(e,t,n,r=1)=>{let o=n-t;if(o===0)return 0;let s=e-t;return r===1?s/o:(r**s-1)/(r**o-1)},it=(e,t,n)=>{if(typeof e==="number"&&typeof t==="number")return e+(t-e)*n;let r=ce(e),o=ce(t);if(r&&o){let s=(a)=>r[a]+(o[a]-r[a])*n;return Je([s(0),s(1),s(2),s(3)])}if(Array.isArray(e)&&Array.isArray(t))return e.map((s,a)=>it(s,t[a],n));return n<0.5?e:t},Dt=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e)&&Array.isArray(e.stops),Zn=(e,t)=>{let n=e.property===void 0?t.zoom:t.properties[e.property],r=e.stops,o=e.type??(e.property===void 0||typeof r[0]?.[0]==="number"?"exponential":"categorical");if(o==="identity")return n??e.default;if(o==="categorical")return r.find(([u])=>u===n)?.[1]??e.default;if(typeof n!=="number"||!r.length)return e.default??r[0]?.[1];let s=([u])=>{if(Array.isArray(u))return Number.NaN;return be(u)?Number(u.zoom):Number(u)},a=r[0];if(!a)return e.default;if(n<=s(a))return a[1];let i=r.findIndex((u,p)=>p>0&&Boolean(r[p-1])&&Boolean(u)&&n<s(u)),[c,l]=[r[i-1],r[i]];if(i<0||!c||!l)return r.at(-1)?.[1];if(o==="interval")return c[1];return it(c[1],l[1],Wt(n,s(c),s(l),e.base??1))},st=(e)=>e,Lt={"<":(e,t)=>e<t,"<=":(e,t)=>e<=t,">":(e,t)=>e>t,">=":(e,t)=>e>=t},Bt=(e,t,n)=>{let r=(a)=>typeof a==="object"&&a!==null?String(a):a,[o,s]=[r(t),r(n)];return typeof o==="string"&&typeof s==="string"?Lt[e](o,s):Lt[e](Number(o),Number(s))},He=(e,t)=>{if(t==="$type")return e.type;return typeof t==="string"?e.properties[t]:void 0},Xn=new Set(["literal","zoom","get","has","!has","properties","id","geometry-type","concat","format","image","number-format","to-number","to-string","to-boolean","to-color","number","string","boolean","typeof","length","at","upcase","downcase","coalesce","!","all","any","==","!=","<","<=",">",">=","in","case","match","step","interpolate","interpolate-hcl","interpolate-lab","rgb","rgba","+","-","*","/","%","^","min","max","abs","round","floor","ceil","sqrt","ln","log10","log2","pi","e"]),ve=(e)=>Array.isArray(e)&&typeof e[0]==="string"&&Xn.has(e[0]),Ut=new Set,ke=(e)=>e===void 0||e===null?"":String(e),ae=(e,t)=>{if(Dt(e))return Zn(e,t);if(!Array.isArray(e))return e;let[n,...r]=e;if(typeof n!=="string")return e;let o=(i)=>ae(r[i]??null,t),s=(i)=>Number(o(i)),a=()=>r.map((i,c)=>s(c));switch(n){case"literal":return r[0];case"zoom":return t.zoom;case"get":return He(t,o(0));case"has":return He(t,o(0))!==void 0;case"!has":return He(t,o(0))===void 0;case"properties":return t.properties;case"id":return null;case"geometry-type":return t.type;case"concat":return r.map((i,c)=>ke(o(c))).join("");case"format":return r.map((i,c)=>i!==null&&typeof i==="object"&&!Array.isArray(i)?"":ke(o(c))).join("");case"image":return o(0);case"number-format":{let i=be(r[1])?r[1]:{},c=(u)=>{let p=i[u];return typeof p==="number"?p:void 0},l=s(0);if(!Number.isFinite(l))return"";return l.toLocaleString(typeof i.locale==="string"?i.locale:void 0,{minimumFractionDigits:c("min-fraction-digits"),maximumFractionDigits:c("max-fraction-digits")})}case"to-number":{for(let i=0;i<r.length;i+=1){let c=o(i),l=typeof c==="string"&&c.trim()===""?Number.NaN:Number(c);if(c!==null&&c!==void 0&&!Number.isNaN(l))return l}return 0}case"to-string":return ke(o(0));case"to-boolean":{let i=o(0);return!(i===""||i===0||i===!1||i===null||i===void 0||Number.isNaN(i))}case"to-color":case"number":case"string":case"boolean":{let i={"to-color":(c)=>ce(c)!==void 0,number:(c)=>typeof c==="number",string:(c)=>typeof c==="string",boolean:(c)=>typeof c==="boolean"};for(let c=0;c<r.length;c+=1){let l=o(c);if(i[n]?.(l))return l}return r.length?o(r.length-1):null}case"typeof":{let i=o(0);if(i===null||i===void 0)return"null";return Array.isArray(i)?"array":typeof i}case"length":{let i=o(0);return typeof i==="string"||Array.isArray(i)?i.length:0}case"at":{let i=o(1);return Array.isArray(i)?i[s(0)]??null:null}case"upcase":return ke(o(0)).toUpperCase();case"downcase":return ke(o(0)).toLowerCase();case"coalesce":for(let i=0;i<r.length;i+=1){let c=o(i);if(c!==void 0&&c!==null)return c}return null;case"!":return!o(0);case"all":return r.every((i,c)=>Boolean(o(c)));case"any":return r.some((i,c)=>Boolean(o(c)));case"==":return o(0)===o(1);case"!=":return o(0)!==o(1);case"<":case"<=":case">":case">=":return Bt(n,o(0),o(1));case"in":{let i=o(1),c=o(0);if(typeof i==="string")return i.includes(String(c));return Array.isArray(i)&&i.includes(c)}case"case":{let i=r.findIndex((c,l)=>l%2===0&&l+1<r.length&&Boolean(o(l)));return i<0?o(r.length-1):o(i+1)}case"match":{let i=o(0),c=r.findIndex((l,u)=>u%2===1&&u+1<r.length&&(Array.isArray(l)?st(l).includes(i):l===i));return c<0?o(r.length-1):o(c+1)}case"step":{let i=s(0),c=o(1);for(let l=2;l+1<r.length;l+=2)if(i>=Number(r[l]))c=o(l+1);else break;return c}case"interpolate":case"interpolate-hcl":case"interpolate-lab":{let i=r[0],c=s(1),l=Array.isArray(i)&&i[0]==="exponential"?Number(i[1]):1,u=Array.from({length:Math.floor((r.length-2)/2)},(h,A)=>[Number(r[2+2*A]),r[3+2*A]??null]),p=u[0];if(!p)return null;if(c<=p[0])return ae(p[1],t);let f=u.findIndex((h,A)=>A>0&&c<h[0]),[d,w]=[u[f-1],u[f]];if(f<0||!d||!w)return ae(u.at(-1)?.[1]??null,t);return it(ae(d[1],t),ae(w[1],t),Wt(c,d[0],w[0],l))}case"rgb":case"rgba":return Je([s(0)/255,s(1)/255,s(2)/255,r.length>3?s(3):1]);case"+":return a().reduce((i,c)=>i+c,0);case"*":return a().reduce((i,c)=>i*c,1);case"-":return r.length===1?-s(0):s(0)-s(1);case"/":return s(0)/s(1);case"%":return s(0)%s(1);case"^":return s(0)**s(1);case"min":return Math.min(...a());case"max":return Math.max(...a());case"abs":return Math.abs(s(0));case"round":return Math.sign(s(0))*Math.round(Math.abs(s(0)));case"floor":return Math.floor(s(0));case"ceil":return Math.ceil(s(0));case"sqrt":return Math.sqrt(s(0));case"ln":return Math.log(s(0));case"log10":return Math.log10(s(0));case"log2":return Math.log2(s(0));case"pi":return Math.PI;case"e":return Math.E;default:if(!Ut.has(n))Ut.add(n),console.warn(`isard: the style expression "${n}" is not supported`);return null}},Qn=new Set(["==","!=","<","<=",">",">="]),je=(e)=>{if(e.type==="line")return"line";if(e.type==="fill-extrusion")return"extrusion";if(e.type==="circle")return"circle";return e.type==="fill"||e.type==="background"?"fill":void 0},er=(e)=>{let[t,n,...r]=e;if(typeof t!=="string"||typeof n!=="string"||r.some(Array.isArray))return!1;if(Qn.has(t))return e.length===3;if(t==="in")return e.length!==3||!Array.isArray(e[2]);return t==="!in"||t==="has"||t==="!has"},tr=(e,t)=>{let[n,r,...o]=e,s=He(t,r);switch(n){case"==":return s===o[0];case"!=":return s!==o[0];case"<":case"<=":case">":case">=":return Bt(n,s,o[0]);case"in":return st(o).includes(s);case"!in":return!st(o).includes(s);case"has":return s!==void 0;case"!has":return s===void 0;default:return!0}},Ct=new WeakMap,Vt=(e)=>{if(!Array.isArray(e))return()=>Boolean(e);let t=Ct.get(e);if(t)return t;let r=(()=>{let o=e[0];if(o==="all"||o==="any"||o==="none"){let s=e.slice(1).map(Vt);if(o==="all")return(a)=>s.every((i)=>i(a));if(o==="any")return(a)=>s.some((i)=>i(a));return(a)=>!s.some((i)=>i(a))}if(er(e))return(s)=>tr(e,s);return(s)=>Boolean(ae(e,s))})();return Ct.set(e,r),r},Q=(e,t)=>{if(e===void 0||e===null)return!0;return Vt(e)(t)},at=(e)=>Array.isArray(e)&&(e[0]==="zoom"||e.some(at)),nr=new Set(["get","has","!has","geometry-type","properties","id"]),me=(e)=>{if(e!==void 0&&Dt(e))return e.property!==void 0;if(!Array.isArray(e))return!1;if(nr.has(e[0]))return!0;return e.some((t)=>me(t))},ct=(e,t)=>{if(e===void 0||e===null)return"";if(typeof e==="string")return e.replace(/\{([^}]+)\}/g,(r,o)=>{let s=t.properties[o];return s===void 0?"":String(s)});let n=ae(e,t);if(Array.isArray(n))return n.filter((r)=>typeof r==="string").join("");return n===void 0||n===null?"":String(n)},zt=(e)=>/Regular|Bold|Italic|Semibold|Light|Medium|Black/.test(e)?e:`${e} Regular`,lt=(e)=>{let t=new Set,n=(i)=>i.filter((c,l)=>l>=3&&l%2===1).map(Number),r=(i)=>{if(!Array.isArray(i))return;let c=(l)=>Array.isArray(l)&&l[0]==="zoom";if((i[0]==="interpolate"||i[0]==="interpolate-hcl"||i[0]==="interpolate-lab")&&c(i[2]))n(i).forEach((l)=>{t.add(l)});else if(i[0]==="step"&&c(i[1]))n(i).forEach((l)=>{t.add(l),t.add(l-0.01)});i.forEach(r)};r(e);let o=[...t].filter(Number.isFinite);if(o.length===0)o.push(0);let[s,a]=[Math.min(...o),Math.max(...o)];return o.push(...Array.from({length:Math.floor(a)-Math.ceil(s)+1},(i,c)=>Math.ceil(s)+c)),[...new Set(o)].sort((i,c)=>i-c).map((i)=>[i,Number(ae(e,{zoom:i,properties:{},type:"Unknown"}))])};class Fe{static __wrap(e){let t=Object.create(Fe.prototype);return t.__wbg_ptr=e,Ht.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Ht.unregister(this),e}free(){let e=this.__destroy_into_raw();D.__wbg_gridset_free(e,0)}count(){return D.gridset_count(this.__wbg_ptr)>>>0}meta(e){let t,n;try{let r=D.gridset_meta(this.__wbg_ptr,e);return t=r[0],n=r[1],ft(r[0],r[1])}finally{D.__wbindgen_free(t,n,1)}}values(e){return D.gridset_values(this.__wbg_ptr,e)}}if(Symbol.dispose)Fe.prototype[Symbol.dispose]=Fe.prototype.free;class Ne{static __wrap(e){let t=Object.create(Ne.prototype);return t.__wbg_ptr=e,Jt.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Jt.unregister(this),e}free(){let e=this.__destroy_into_raw();D.__wbg_streetflow_free(e,0)}eastU(){return D.streetflow_eastU(this.__wbg_ptr)}eastV(){return D.streetflow_eastV(this.__wbg_ptr)}northU(){return D.streetflow_northU(this.__wbg_ptr)}northV(){return D.streetflow_northV(this.__wbg_ptr)}}if(Symbol.dispose)Ne.prototype[Symbol.dispose]=Ne.prototype.free;function qt(e){let t=cr(e,D.__wbindgen_malloc),n=ye,r=D.readGrids(t,n);if(r[2])throw ur(r[1]);return Fe.__wrap(r[0])}function $t(e,t,n,r,o,s){let a=lr(e,D.__wbindgen_malloc),i=ye,c=jt(t,D.__wbindgen_malloc),l=ye,u=jt(n,D.__wbindgen_malloc),p=ye,f=D.streetFlow(a,i,c,l,u,p,r,o,s);return Ne.__wrap(f)}function rr(){return{__proto__:null,"./isard_grid_bg.js":{__proto__:null,__wbg___wbindgen_throw_41e9ee4f547fc59a:function(t,n){throw Error(ft(t,n))},__wbg_new_from_slice_ca6ad97db1f4779a:function(t,n){return new Float32Array(or(t,n))},__wbindgen_generic_0000000000000001:function(t,n){return ft(t,n)},__wbindgen_init_externref_table:function(){let t=D.__wbindgen_externrefs,n=t.grow(4);t.set(0,void 0),t.set(n+0,void 0),t.set(n+1,null),t.set(n+2,!0),t.set(n+3,!1)}}}}var Ht=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e)=>D.__wbg_gridset_free(e,1)),Jt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e)=>D.__wbg_streetflow_free(e,1));function or(e,t){return e=e>>>0,sr().subarray(e/4,e/4+t)}var Re=null;function sr(){if(Re===null||Re.byteLength===0)Re=new Float32Array(D.memory.buffer);return Re}var Te=null;function ir(){if(Te===null||Te.byteLength===0)Te=new Float64Array(D.memory.buffer);return Te}function ft(e,t){return mr(e>>>0,t)}var Ee=null;function ar(){if(Ee===null||Ee.byteLength===0)Ee=new Uint32Array(D.memory.buffer);return Ee}var Ie=null;function Yt(){if(Ie===null||Ie.byteLength===0)Ie=new Uint8Array(D.memory.buffer);return Ie}function jt(e,t){let n=t(e.length*4,4)>>>0;return ar().set(e,n/4),ye=e.length,n}function cr(e,t){let n=t(e.length*1,1)>>>0;return Yt().set(e,n/1),ye=e.length,n}function lr(e,t){let n=t(e.length*8,8)>>>0;return ir().set(e,n/8),ye=e.length,n}function ur(e){let t=D.__wbindgen_externrefs.get(e);return D.__externref_table_dealloc(e),t}var qe=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});qe.decode();var fr=2146435072,ut=0;function mr(e,t){if(ut+=t,ut>=fr)qe=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),qe.decode(),ut=t;return qe.decode(Yt().subarray(e,e+t))}var ye=0,pr,dr,D;function br(e,t){return dr=e,D=e.exports,pr=t,Re=null,Te=null,Ee=null,Ie=null,D.__wbindgen_start(),D}async function yr(e,t){if(typeof Response==="function"&&e instanceof Response){if(!e.ok)throw Error(`failed to fetch Wasm: ${e.status} ${e.statusText} fetching '${e.url}'`);if(typeof WebAssembly.instantiateStreaming==="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(o){if(n(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let r=await WebAssembly.instantiate(e,t);if(r instanceof WebAssembly.Instance)return{instance:r,module:e};else return r}function n(r){switch(r){case"basic":case"cors":case"default":return!0}return!1}}async function Gt(e){if(D!==void 0)return D;if(e!==void 0)if(Object.getPrototypeOf(e)===Object.prototype)({module_or_path:e}=e);else console.warn("using deprecated parameters for the initialization function; pass a single object instead");if(e===void 0)e=new URL("isard_grid_bg.wasm",import.meta.url);let t=rr();if(typeof e==="string"||typeof Request==="function"&&e instanceof Request||typeof URL==="function"&&e instanceof URL)e=fetch(e);let{instance:n,module:r}=await yr(await e,t);return br(n,r)}var mt={},Kt=async(e)=>{let t=mt.ready??Gt({module_or_path:e});mt.ready=t,await t.catch((n)=>{throw mt.ready=void 0,n})},Zt=async(e,t,n,r,o)=>{await Kt(o);let s=$t(e.points,e.ringStart,e.polygonStart,t,n,r);try{return{eastU:s.eastU(),eastV:s.eastV(),northU:s.northU(),northV:s.northV()}}finally{s.free()}},hr=(e)=>typeof e==="object"&&e!==null&&("name"in e)&&("width"in e)&&("height"in e)&&("bounds"in e)&&Array.isArray(e.bounds),Xt=async(e,t)=>{await Kt(t);let n=qt(e);try{let r=[],o=[];for(let s=0;s<n.count();s++){let a=JSON.parse(n.meta(s));if(!hr(a))throw Error("isard: a grid without its description");r.push(a),o.push(n.values(s))}return{grids:r,values:o}}finally{n.free()}};var he=6,Qt=4;var en=(e)=>e*7919%360,pt=["shelter","bin","postbox","fountain","rack","bench"];class dt{buf;end;pos;constructor(e,t=0,n=e.length){this.buf=e;this.end=n;this.pos=t}varint(){let e=0;for(let t=0;t<70;t+=7){let n=this.buf[this.pos++]??0;if(e+=(n&127)*2**t,n<128)break}return e}int64(){let e=0,t=0;for(let n=0;n<10;n+=1){let r=this.buf[this.pos++]??0,o=r&127;if(n<4)e|=o<<7*n;else if(n===4)e|=(o&15)<<28,t|=o>>4;else t|=o<<7*n-32;if(r<128)break}return(t|0)*4294967296+(e>>>0)}sint(){let e=this.varint();return e%2===1?-(e+1)/2:e/2}sub(){let e=this.varint(),t=Math.min(this.pos+e,this.end),n=new dt(this.buf,this.pos,t);return this.pos=t,n}string(){let e=this.varint(),t=Math.min(this.pos+e,this.end),n=gr.decode(this.buf.subarray(this.pos,t));return this.pos=t,n}float(){let e=this.pos+4<=this.end?this.view().getFloat32(this.pos,!0):0;return this.pos+=4,e}double(){let e=this.pos+8<=this.end?this.view().getFloat64(this.pos,!0):0;return this.pos+=8,e}view(){return new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength)}skip(e){if(e===0)this.varint();else if(e===1)this.pos+=8;else if(e===2)this.pos+=this.varint();else if(e===5)this.pos+=4}get more(){return this.pos<this.end}}var gr=new TextDecoder,wr=(e)=>{let t="";while(e.more){let n=e.varint();switch(n>>3){case 1:t=e.string();break;case 2:t=e.float();break;case 3:t=e.double();break;case 4:t=e.int64();break;case 5:t=e.varint();break;case 6:t=e.sint();break;case 7:t=e.varint()!==0;break;default:e.skip(n&7)}}return t},xr=(e)=>{let t=[],n,[r,o]=[0,0];while(e.more){let s=e.varint(),a=s&7,i=s>>3;if(a===7){if(n&&n.length>=2)n.push(n[0]??0,n[1]??0);continue}for(let c=0;c<i&&e.more;c+=1){if(r+=e.sint(),o+=e.sint(),a===1)n=[],t.push(n);n?.push(r,o)}}return t},bt=(e,t)=>{let n=new Map,r=new dt(e);while(r.more){let o=r.varint();if(o>>3!==3){r.skip(o&7);continue}let s=r.sub(),a="",i=4096,c=[],l=[],u=[];while(s.more){let f=s.varint();switch(f>>3){case 1:a=s.string();break;case 2:u.push(s.sub());break;case 3:c.push(s.string());break;case 4:l.push(wr(s.sub()));break;case 5:i=s.varint();break;default:s.skip(f&7)}}if(t&&!t.has(a))continue;let p=[];for(let f of u){let d=1,w={},h=[];while(f.more){let A=f.varint();switch(A>>3){case 2:{let m=f.sub();while(m.more){let M=c[m.varint()],b=l[m.varint()];if(M!==void 0&&b!==void 0)w[M]=b}break}case 3:d=Math.min(3,Math.max(1,f.varint()));break;case 4:h=xr(f.sub());break;default:f.skip(A&7)}}p.push({type:d,properties:w,geometry:h})}n.set(a,{extent:i,features:p})}return n};var _r=127,Ar=16384,Mr=["unknown","mvt","png","jpeg","webp","avif"],Sr=(e)=>(4**e-1)/3,kr=(e,t,n)=>{if(e>26)throw Error(`isard: PMTiles level ${e} past 26`);let r=2**e;if(t<0||n<0||t>=r||n>=r)throw Error(`isard: PMTiles tile ${e}/${t}/${n} out of its level`);let[o,s]=[t,n],a=0;for(let i=r/2;i>=1;i/=2){let c=(o&i)>0?1:0,l=(s&i)>0?1:0;if(a+=i*i*(3*c^l),l===0){if(c===1)[o,s]=[i-1-o,i-1-s];[o,s]=[s,o]}}return Sr(e)+a};class rn{bytes;pos=0;constructor(e){this.bytes=e}next(){let e=0,t=1;for(;;){let n=this.bytes[this.pos++];if(n===void 0)throw Error("isard: PMTiles directory truncated");if(e+=(n&127)*t,n<128)return e;if(t*=128,t>9223372036854776000)throw Error("isard: PMTiles varint too long")}}}var tn=(e)=>{let t=new rn(e),n=t.next();if(n>e.length)throw Error("isard: PMTiles directory larger than its bytes");let r=[],o=0;for(let s=0;s<n;s+=1)o+=t.next(),r.push({tileId:o,offset:0,length:0,runLength:1});for(let s of r)s.runLength=t.next();for(let s of r)s.length=t.next();return r.forEach((s,a)=>{let i=t.next(),c=r[a-1];s.offset=i===0&&c?c.offset+c.length:i-1}),r},vr=(e,t)=>{let[n,r]=[0,e.length-1];while(n<=r){let s=n+r>>1,a=e[s];if(!a)break;if(a.tileId===t)return a;if(a.tileId<t)n=s+1;else r=s-1}let o=e[r];if(!o)return;if(o.runLength===0||t-o.tileId<o.runLength)return o;return},Rr=(e)=>{if(e.length<_r||String.fromCharCode(...e.subarray(0,7))!=="PMTiles")throw Error("isard: not a PMTiles archive");if(e[7]!==3)throw Error(`isard: PMTiles version ${e[7]} (only 3 is read)`);let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=(o)=>Number(t.getBigUint64(o,!0)),r=(o)=>t.getInt32(o,!0)/1e7;return{rootDirectoryOffset:n(8),rootDirectoryLength:n(16),metadataOffset:n(24),metadataLength:n(32),leafDirectoryOffset:n(40),leafDirectoryLength:n(48),tileDataOffset:n(56),tileDataLength:n(64),internalCompression:t.getUint8(97),tileCompression:t.getUint8(98),tileType:Mr[t.getUint8(99)]??"unknown",minZoom:t.getUint8(100),maxZoom:t.getUint8(101),bounds:[r(102),r(106),r(110),r(114)],center:[r(119),r(123),t.getUint8(118)]}},$e=async(e,t)=>{if(t===0||t===1)return e;if(t!==2)throw Error(`isard: PMTiles compression ${t===3?"brotli":"zstd"} is not read (gzip only)`);let n=new Blob([e]).stream().pipeThrough(new DecompressionStream("gzip"));return new Uint8Array(await new Response(n).arrayBuffer())},Tr=67108864;class on{source;head;leaves=new le(64);whole;constructor(e){this.source=e}async range(e,t,n){if(typeof this.source!=="string")return new Uint8Array(await this.source.slice(e,e+t).arrayBuffer());if(this.whole)return(await this.whole).subarray(e,e+t);let r=await fetch(this.source,oe(this.source,{headers:{Range:`bytes=${e}-${e+Math.max(t,1)-1}`},...n?{signal:n}:{}}));if(!r.ok)throw ie(this.source,r.status);if(r.status===206)return new Uint8Array(await r.arrayBuffer());if(Number(r.headers.get("Content-Length"))>Tr)throw await r.body?.cancel(),Error(`isard: ${this.source}: the server ignores range requests (HTTP 206 expected)`);let s=r.arrayBuffer().then((a)=>new Uint8Array(a));return this.whole=s,s.catch(()=>{this.whole=void 0}),(await s).subarray(e,e+t)}load(){return this.head??=(async()=>{let e=await this.range(0,Ar),t=Rr(e),{rootDirectoryOffset:n,rootDirectoryLength:r}=t,o=n+r<=e.length?e.subarray(n,n+r):await this.range(n,r),s=tn(await $e(o,t.internalCompression));return{header:t,root:s}})(),this.head.catch(()=>{this.head=void 0}),this.head}async header(){return(await this.load()).header}async metadata(){let{header:e}=await this.load();if(e.metadataLength===0)return{};let t=await this.range(e.metadataOffset,e.metadataLength),n=new TextDecoder().decode(await $e(t,e.internalCompression)),r=JSON.parse(n);return be(r)?r:{}}leaf(e,t){let n=e.leafDirectoryOffset+t.offset,r=this.leaves.get(n);if(r)return r;let o=this.range(n,t.length).then(async(s)=>tn(await $e(s,e.internalCompression)));return o.catch(()=>this.leaves.delete(n)),this.leaves.set(n,o),o}async tile(e,t,n,r){let{header:o,root:s}=await this.load();if(e<o.minZoom||e>o.maxZoom)return;let a=kr(e,t,n),i=s;for(let c=0;c<4;c+=1){let l=vr(i,a);if(!l)return;if(l.runLength>0){let u=await this.range(o.tileDataOffset+l.offset,l.length,r);return $e(u,o.tileCompression)}i=await this.leaf(o,l)}throw Error("isard: PMTiles directories nested too deep")}}var nn=new le(16),Er=(e)=>{let t=nn.get(e);if(t)return t;let n=new on(e);return nn.set(e,n),n};var yt=(e,t)=>{let n=/^pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)$/.exec(e);if(!n)return!1;let[,r="",o,s,a]=n;return Er(r).tile(Number(o),Number(s),Number(a),t)};var gt=(e,t)=>{let n=e.sprites.find((o)=>Boolean(o.icons[t])),r=n?.icons[t];return n&&r?{icon:r,image:n.image}:void 0},Pe=new Map,sn=96,Oe=new le(sn),an=(e,t=sn)=>Math.max(16,Math.ceil(t/Math.max(1,e))),cn=30000,Ye=new Set,j=new Set,ht=new le(64,(e)=>e.then((t)=>setTimeout(()=>t?.close(),0),()=>{return})),ln=(e,t="auto")=>{let n=ht.get(e);if(n)return n;let r=(async()=>{let o=yt(e);if(o){let i=await o;return i&&createImageBitmap(new Blob([i]))}let s={priority:t,signal:AbortSignal.timeout(cn)},a=await fetch(e,oe(e,s));if(a.status===404||a.status===204)return;if(!a.ok)throw ie(e,a.status);return createImageBitmap(await a.blob())})();return r.catch(()=>ht.delete(e)),ht.set(e,r),r},ee=(e,t="auto")=>{let n=Oe.get(e);if(n)return n;let r=(async()=>{let o=yt(e);if(o){let s=await o;return s&&bt(s)}for(let s=0;;s+=1){let a={priority:t,signal:AbortSignal.timeout(cn)},i=await fetch(e,oe(e,a));if(i.status===404||i.status===204)return;if(i.ok)return bt(new Uint8Array(await i.arrayBuffer()));if(s>=2)throw ie(e,i.status);await new Promise((c)=>setTimeout(c,400*(s+1)))}})();return r.catch(()=>Oe.delete(e)),Oe.set(e,r),r},un=(e,t,n,r)=>{let o=xe(t-1,0,e.maxzoom),s=t-o,a=2**Math.max(0,s),[i,c]=s>=0?[Math.floor(n/a),Math.floor(r/a)]:[n,r],l=K(e.tiles,o,i,c),u=1/a;return{url:l,vz:o,vx:i,vy:c,part:u,ox:n%a*u,oy:r%a*u}},C=(e,t,n,r,o)=>{let s=e[t]?.[n];if(s===void 0)return o;let a=Array.isArray(s)&&!ve(s)?s:ae(s,r);return a===void 0||a===null?o:a},pe=(e,t)=>{let n=ce(e)??[0,0,0,1];return Je([n[0],n[1],n[2],n[3]*t])},Le=(e,t)=>{if(e.layout?.visibility==="none")return!1;return t>=(e.minzoom??0)&&t<(e.maxzoom??24)},H=(e,t,n,r,o,s)=>{let a=2**e;return[It((t+o/r)/a),Ft((n+s/r)/a)]};var Ir=300,fn=(e,t,n)=>{let r=Boolean(C(e,"layout",`${t}-allow-overlap`,n,!1)),o=Boolean(C(e,"layout",`${t}-ignore-placement`,n,!1));if(r&&o)return!0;if(r)return"allow";return o?"ignore":!1},mn=(e,t)=>Array.isArray(e)?[Number(e[0]??t[0]),Number(e[1]??t[1])]:t,Fr=(e)=>{let t=(Array.isArray(e)?e:[e]).map((a)=>Number(a)||0),[n=0,r=n,o=n,s=r]=t;return[n,r,o,s]},Nr=(e,t)=>{if(t==="uppercase")return e.toUpperCase();if(t==="lowercase")return e.toLowerCase();return e},Ae=(e,t)=>{let n=0;for(let a=2;a+1<e.length;a+=2)n+=Math.hypot((e[a]??0)-(e[a-2]??0),(e[a+1]??0)-(e[a-1]??0));let r=[];if(!(n>0)||!(t>0))return r;let o=Math.min(t/2,n/2),s=0;for(let a=2;a+1<e.length;a+=2){let[i,c,l,u]=[e[a-2]??0,e[a-1]??0,e[a]??0,e[a+1]??0],p=Math.hypot(l-i,u-c);while(p>0&&o<=s+p){let f=(o-s)/p;r.push([i+(l-i)*f,c+(u-c)*f,i,c,l,u,o]),o+=t}s+=p}return r},Ke=(e,t,n)=>{let[r=0,o=0,s=0,a=0,i=0,c=0]=e,l=Math.hypot(i-s,c-a)||1,u=t%2===0?1:-1,[p,f]=[-(c-a)/l*u,(i-s)/l*u];return[r+p*n,o+f*n,Math.atan2(-p,f)*180/Math.PI]},Or=(e,t,n)=>{let r=[],o=0;for(let s=2;s+1<e.length;s+=2){let[a,i,c,l]=[e[s-2]??0,e[s-1]??0,e[s]??0,e[s+1]??0],u=Math.hypot(c-a,l-i),[p,f]=[o,o+u];if(o=f,u<=0||f<t||p>n)continue;let d=(w)=>[a+(c-a)*(w-p)/u,i+(l-i)*(w-p)/u];if(r.length===0)r.push(...d(Math.max(t,p)));r.push(...d(Math.min(n,f)))}return r},Pr=(e,t,n,r,o)=>{let s=C(e,"layout","icon-rotation-alignment",n,"auto"),a=String(C(e,"layout","icon-text-fit",n,"none")),i=C(e,"layout","icon-text-fit-padding",n,[0,0,0,0]);return{image:t,size:me(e.layout?.["icon-size"])?Number(C(e,"layout","icon-size",n,1)):o(e),anchor:String(C(e,"layout","icon-anchor",n,"center")),offset:mn(C(e,"layout","icon-offset",n,[0,0]),[0,0]),rotate:Number(C(e,"layout","icon-rotate",n,0))||0,alignment:s==="map"||s==="auto"&&r==="line"?"map":"viewport",overlap:fn(e,"icon",n),optional:Boolean(C(e,"layout","icon-optional",n,!1)),fit:a==="width"||a==="height"||a==="both"?a:"none",padding:Fr(i),color:String(C(e,"paint","icon-color",n,"#000")),opacity:Number(C(e,"paint","icon-opacity",n,1))}},Ge=16,Lr=(e,t,n)=>{let r=[],o=new Map,s=4096;e.layers.forEach((c)=>{if(c.type!=="fill-extrusion"||!Le(c,n))return;let l=t.get(c["source-layer"]??"");if(!l)return;s=l.extent;for(let u of l.features){let p=Z(u,n);if(u.type!==3||!Q(c.filter,p))continue;let f=Number(C(c,"paint","fill-extrusion-height",p,0));if(!(f>0))continue;let d=[1/0,1/0,-1/0,-1/0];for(let w of u.geometry)for(let h=0;h+1<w.length;h+=2){let[A,m]=[w[h]??0,w[h+1]??0];d[0]=Math.min(d[0],A),d[1]=Math.min(d[1],m),d[2]=Math.max(d[2],A),d[3]=Math.max(d[3],m)}r.push({rings:u.geometry,height:f,box:d})}});let a=(c)=>Math.max(0,Math.min(Ge-1,Math.floor(c/s*Ge)));r.forEach(({box:c},l)=>{for(let u=a(c[1]);u<=a(c[3]);u++)for(let p=a(c[0]);p<=a(c[2]);p++){let f=u*Ge+p,d=o.get(f);if(d)d.push(l);else o.set(f,[l])}});let i=(c,l,u)=>{let p=!1;for(let f of c)for(let d=0,w=f.length-2;d+1<f.length;w=d,d+=2){let[h,A,m,M]=[f[d]??0,f[d+1]??0,f[w]??0,f[w+1]??0];if(A>u!==M>u&&l<(m-h)*(u-A)/(M-A)+h)p=!p}return p};return(c,l)=>(o.get(a(l)*Ge+a(c))??[]).reduce((u,p)=>{let f=r[p];return f&&i(f.rings,c,l)?Math.max(u??0,f.height):u},void 0)},pn=async(e,t)=>{let{z:n,x:r,y:o,id:s,priority:a,zoom:i=n,roofs:c=!1}=t,l=K(e.tiles,n,r,o),u=await ee(l,a);if(!u||j.has(s))return[];let p=[],f=c?Lr(e,u,i):()=>{return},d=new Map,w=(m)=>{let M=d.get(m);if(M!==void 0)return M;let b=m.layout?.["text-size"]??16,x=ve(b)?lt(b):b;return d.set(m,x),x},h=new Map,A=(m)=>{let M=h.get(m);if(M!==void 0)return M;let b=m.layout?.["icon-size"]??1,x=ve(b)?lt(b):b;return h.set(m,x),x};return e.layers.forEach((m,M)=>{let b=m.layout??{};if(m.type!=="symbol"||!Le(m,i))return;if(b["text-field"]===void 0&&b["icon-image"]===void 0)return;let x=u.get(m["source-layer"]??"");if(!x)return;let T={zoom:i,properties:{},type:"Unknown"},E=C(m,"layout","symbol-placement",T,"point")==="line"?"line":"point",_=E==="line"&&C(m,"layout","text-rotation-alignment",T,"auto")!=="viewport";for(let g of x.features){let y=Z(g,i);if(!Q(m.filter,y))continue;let S=ct(b["text-field"],y).trim(),k=ct(b["icon-image"],y).trim();if(!S&&!k)continue;let v=Nr(S,C(m,"layout","text-transform",y,"none")),R=C(m,"layout","text-font",y,["Noto Sans Regular"]),U=zt(Array.isArray(R)&&typeof R[0]==="string"?R[0]:"Noto Sans Regular"),B={layer:M,text:v,font:U,size:me(m.layout?.["text-size"])?Number(C(m,"layout","text-size",y,16)):w(m),color:String(C(m,"paint","text-color",y,"#000")),haloColor:String(C(m,"paint","text-halo-color",y,"rgba(0,0,0,0)")),haloWidth:Number(C(m,"paint","text-halo-width",y,0)),anchor:String(C(m,"layout","text-anchor",y,"center")),offset:mn(C(m,"layout","text-offset",y,[0,0]),[0,0]),maxWidth:Number(C(m,"layout","text-max-width",y,10)),lineHeight:Number(C(m,"layout","text-line-height",y,1.2)),overlap:fn(m,"text",y),..._?{textAlong:_}:{},...C(m,"layout","text-optional",y,!1)?{textOptional:!0}:{},...k?{icon:Pr(m,k,y,E,A)}:{}};if(g.type===1)for(let P of g.geometry)for(let L=0;L+1<P.length;L+=2){let[I,F]=[P[L]??0,P[L+1]??0];if(I<0||F<0||I>=x.extent||F>=x.extent)continue;let[N,W]=H(n,r,o,x.extent,I,F),V=f(I,F);p.push({...B,lon:N,lat:W,...V===void 0?{}:{height:V}})}else if(!v&&E==="line"){let P=Number(C(m,"layout","symbol-spacing",y,250))*x.extent/(512*2**(i-n));for(let L of g.geometry)for(let[I=0,F=0,N=0,W=0,V=0,J=0]of Ae(L,Math.max(P,1))){if(I<0||F<0||I>=x.extent||F>=x.extent)continue;let[z,te]=H(n,r,o,x.extent,I,F),[G,ne]=H(n,r,o,x.extent,V,J),[X,re]=H(n,r,o,x.extent,N,W);p.push({...B,lon:z,lat:te,along:[G-X,ne-re]})}}else if(v&&_){let P=x.extent/(512*2**(i-n)),L=Number(C(m,"layout","symbol-spacing",y,250))*P;for(let I of g.geometry){let F=0;for(let N=2;N+1<I.length;N+=2)F+=Math.hypot((I[N]??0)-(I[N-2]??0),(I[N+1]??0)-(I[N-1]??0));if(F<x.extent/32)continue;for(let[N=0,W=0,V=0,J=0,z=0,te=0,G=0]of Ae(I,Math.max(L,1))){if(N<0||W<0||N>=x.extent||W>=x.extent)continue;let ne=Math.min(G,F-G,Ir*P),X=Or(I,G-ne,G+ne),re=[];for(let Ve=0;Ve+1<X.length;Ve+=2)re.push(...H(n,r,o,x.extent,X[Ve]??0,X[Ve+1]??0));let[Me,Se]=H(n,r,o,x.extent,N,W),[nt,Bn]=H(n,r,o,x.extent,z,te),[Vn,zn]=H(n,r,o,x.extent,V,J);p.push({...B,lon:Me,lat:Se,along:[nt-Vn,Bn-zn],...re.length>=4?{path:re}:{}})}}}else{let P,L=0;for(let F of g.geometry){let N=0;for(let W=2;W+1<F.length;W+=2)N+=Math.hypot((F[W]??0)-(F[W-2]??0),(F[W+1]??0)-(F[W-1]??0));if(N>L)L=N,P=F}if(!P||L<x.extent/32)continue;let I=L/2;for(let F=2;F+1<P.length;F+=2){let[N,W,V,J]=[P[F-2]??0,P[F-1]??0,P[F]??0,P[F+1]??0],z=Math.hypot(V-N,J-W);if(z>=I&&z>0){let[te,G]=[N+(V-N)*I/z,W+(J-W)*I/z];if(te<0||G<0||te>=x.extent||G>=x.extent)break;let[ne,X]=H(n,r,o,x.extent,te,G),[re,Me]=H(n,r,o,x.extent,V,J),[Se,nt]=H(n,r,o,x.extent,N,W);p.push({...B,lon:ne,lat:X,...E==="line"?{along:[re-Se,Me-nt]}:{}});break}I-=z}}}}),p};var dn=(e)=>{let t=e.leaf_type,n=typeof e.nature==="string"?e.nature:"";if(t==="needleleaved"||/conif/i.test(n))return 1;if(t==="broadleaved"||/feuillu/i.test(n))return 0;if(t==="mixed"||/mixte/i.test(n))return 0.5;if(e.class==="wood")return e.subclass==="forest"?0.35:0.15;return 0};var Ze=(e,t)=>{let n=e.length/he,r=n>t?t/n:1,o=[];for(let s=0;s<n;s+=1)if(r>=1||(e[s*he+Qt]??0)<r)o.push(...e.slice(s*he,(s+1)*he));return Float64Array.from(o)},se=(e,t,n,r)=>{let o=Math.imul(e^2654435769,2246822507)^Math.imul(t^3266489909,668265263);return o=Math.imul(o^o>>>15^Math.imul(n,374761393),739982445),o=Math.imul(o^o>>>13^Math.imul(r,695872825),695872825),((o^o>>>16)>>>0)/4294967296},ge=(e,t,n)=>e.reduce((r,o)=>{let s=o.length/2,a=0;for(let i=0,c=s-1;i<s;c=i,i+=1){let[l,u,p,f]=[o[i*2]??0,o[i*2+1]??0,o[c*2]??0,o[c*2+1]??0];if(u>n!==f>n&&t<(p-l)*(n-u)/(f-u)+l)a+=1}return a%2===1?!r:r},!1),Ur=(e,t,n,r,o=Number.POSITIVE_INFINITY)=>{let s=e[0]??[],a=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(let T=0;T+1<s.length;T+=2){let[E,_]=[s[T]??0,s[T+1]??0];a[0]=Math.min(a[0]??E,E),a[1]=Math.min(a[1]??_,_),a[2]=Math.max(a[2]??E,E),a[3]=Math.max(a[3]??_,_)}let[i,c]=[Math.max(0,a[0]??0),Math.max(0,a[1]??0)],[l,u]=[Math.min(t,a[2]??0),Math.min(t,a[3]??0)];if(!(n>0)||i>=l||c>=u)return[];let p=(l-i)/n*((u-c)/n),f=p>o?n*Math.sqrt(p/o):n,[d,w,h,A]=[Math.floor(i/f),Math.ceil(l/f),Math.floor(c/f),Math.ceil(u/f)],[m,M,b]=r,x=Math.imul(m+1,16777619)^Math.imul(M,1540483477)^Math.imul(b,461845907);return Array.from({length:Math.max(0,A-h)},(T,E)=>h+E).flatMap((T)=>Array.from({length:Math.max(0,w-d)},(E,_)=>d+_).flatMap((E)=>{let _=(E+se(x,E,T,1))*f,g=(T+se(x,E,T,2))*f;if(_<0||g<0||_>=t||g>=t||!ge(e,_,g))return[];return[[_,g,se(x,E,T,3)]]}))},bn=async(e,t)=>{let{z:n,x:r,y:o,id:s,spacing:a,maxTrees:i,priority:c}=t,l=K(e.tiles,n,r,o),u=await ee(l,c);if(!u||j.has(s))return;let p=_e(n,o),f=[];e.layers.forEach((A,m)=>{let M=a[m]??0,b=u.get(A["source-layer"]??"");if(!b||!(M>0))return;let x=M/p*b.extent;b.features.forEach((T)=>{if(T.type!==3||!Q(A.filter,Z(T,n)))return;let E=dn(T.properties);T.geometry.reduce((g,y)=>{let S=0;for(let k=0;k+1<y.length;k+=2){let v=(k+2)%y.length;S+=(y[k]??0)*(y[v+1]??0)-(y[v]??0)*(y[k+1]??0)}if(S>0)g.push([y]);else if(S<0)g.at(-1)?.push(y);return g},[]).forEach((g)=>{Ur(g,b.extent,x,[n,r,o],i*4).forEach(([y,S,k])=>{f.push([y,S,k,b.extent,E])})})})});let d=f.length>i?i/f.length:1,w=f.filter(([,,A])=>d>=1||se(Math.floor(A*2147483648),n,r,o)<d),h=new Float64Array(w.length*he);return w.forEach(([A,m,M,b,x],T)=>{let[E,_]=H(n,r,o,b,A,m),g=se(Math.floor(M*2147483648),7,11,13),y=se(Math.floor(M*2147483648),3,5,17)<x?1:0;h.set([E,_,0.75+0.5*M,en(M),g,y],T*he)}),h};var Cr={bus_stop:"shelter",waste_basket:"bin",post_box:"postbox",drinking_water:"fountain",bicycle_parking:"rack"},Wr=new Set(["primary","secondary","tertiary","minor","service","trunk"]),Dr=25,yn={street:[24,3.2],path:[18,1.3]},Br=(e)=>e.filter((t)=>t.type===1),hn=async(e,t)=>{let{z:n,x:r,y:o,id:s,maxObjects:a,priority:i}=t,c=K(e.tiles,n,r,o),l=await ee(c,i);if(!l||j.has(s))return;let u=l.get("poi"),p=l.get("transportation"),f=p?.extent??u?.extent??4096,d=f/_e(n,o),w=(p?.features??[]).filter((_)=>_.type===2&&Wr.has(String(_.properties.class))),h=(l.get("landcover")?.features??[]).filter((_)=>_.type===3&&String(_.properties.class)==="grass").map((_)=>{let g=_.geometry[0]??[],y=g.filter((k,v)=>v%2===0),S=g.filter((k,v)=>v%2===1);return{rings:_.geometry,bounds:[Math.min(...y),Math.min(...S),Math.max(...y),Math.max(...S)]}}),A=(_,g)=>h.some(({rings:y,bounds:[S=0,k=0,v=0,R=0]})=>_>=S&&_<=v&&g>=k&&g<=R&&ge(y,_,g)),m=[],M=(_,g,y,S,k)=>{if(_<0||g<0||_>=f||g>=f)return;let[v,R]=H(n,r,o,f,_,g);m.push(v,R,1,y,S,pt.indexOf(k))},b=Dr*d,x=new Map,T=(_,g)=>(_+32768)*65536+g+32768;w.forEach((_)=>{_.geometry.forEach((g)=>{for(let y=2;y+1<g.length;y+=2){let[S,k,v,R]=[g[y-2]??0,g[y-1]??0,g[y]??0,g[y+1]??0],[U,B]=[Math.floor(Math.min(S,v)/b),Math.floor(Math.max(S,v)/b)],[P,L]=[Math.floor(Math.min(k,R)/b),Math.floor(Math.max(k,R)/b)];for(let I=U;I<=B;I+=1)for(let F=P;F<=L;F+=1){let N=x.get(T(I,F))??[];N.push(S,k,v,R),x.set(T(I,F),N)}}})});let E=(_,g,y)=>{let[S,k,v]=[b*b,0,0],[R,U]=[Math.floor(_/b),Math.floor(g/b)];for(let B=R-1;B<=R+1;B+=1)for(let P=U-1;P<=U+1;P+=1){let L=x.get(T(B,P))??[];for(let I=0;I+3<L.length;I+=4){let[F,N,W,V]=[L[I]??0,L[I+1]??0,L[I+2]??0,L[I+3]??0],[J,z]=[W-F,V-N],te=J*J+z*z,G=te>0?Math.max(0,Math.min(1,((_-F)*J+(g-N)*z)/te)):0,[ne,X]=[F+G*J-_,N+G*z-g],re=ne*ne+X*X;if(re<S)[S,k,v]=[re,ne,X]}}if(k===0&&v===0)return y;return Math.atan2(k,-v)*180/Math.PI};return Br(u?.features??[]).forEach((_)=>{let g=Cr[String(_.properties.subclass)];if(!g)return;_.geometry.forEach(([y=0,S=0])=>{let k=se(Math.floor(y),Math.floor(S),pt.indexOf(g),31);M(y,S,E(y,S,k*360),k,g)})}),(p?.features??[]).forEach((_)=>{let g=String(_.properties.subclass),y=String(_.properties.class)==="path"&&g==="pedestrian",S=String(_.properties.class)==="path"&&(g==="footway"||g==="path");if(_.type!==2||!(y||S))return;let[k,v]=y?yn.street:yn.path;_.geometry.forEach((R)=>{Ae(R,k*d).forEach((U,B)=>{let[P=0,L=0,,,,,I=0]=U;if(S&&!A(P,L))return;let F=se(Math.floor(P),Math.floor(L),Math.floor(I),37);M(...Ke(U,B,v*d),F,"bench")})})}),Ze(m,a)};var gn={flat:1,skillion:1,hipped:2,"half-hipped":2,side_hipped:2,dome:2,onion:2,round:2,gabled:3,saltbox:3,pyramidal:4,cone:4,mansard:5,gambrel:5},Vr=255,wn=(e)=>e==="generated"?Vr:gn[e],xn=(e,t)=>be(e)?t.map((n)=>e[n]).find((n)=>n!==void 0):void 0,_n=(e,t)=>{let n=xn(e,["roof:shape","roof_shape"]);if(t==="flat")return;if(typeof n==="string"&&gn[n]!==void 0)return n;return t==="generated"?"generated":void 0},An=(e)=>Number(xn(e,["roof:height","roof_height"])??Number.NaN);var wt=32,q={color:0,second:4,size:8,size2:16,range:24,blur:26,landmark:26,patternRatio:27,fillPattern:28,linePattern:29};class Be{static __wrap(e){let t=Object.create(Be.prototype);return t.__wbg_ptr=e,Mn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Mn.unregister(this),e}free(){let e=this.__destroy_into_raw();O.__wbg_tessellatedtile_free(e,0)}blockIndices(){return O.tessellatedtile_blockIndices(this.__wbg_ptr)}blockRanges(){let e=O.tessellatedtile_blockRanges(this.__wbg_ptr);var t=Qe(e[0],e[1]).slice();return O.__wbindgen_free(e[0],e[1]*4,4),t}blocks(){return O.tessellatedtile_blocks(this.__wbg_ptr)}bounds(){let e=O.tessellatedtile_bounds(this.__wbg_ptr);var t=Jr(e[0],e[1]).slice();return O.__wbindgen_free(e[0],e[1]*8,8),t}fillRanges(){let e=O.tessellatedtile_fillRanges(this.__wbg_ptr);var t=Qe(e[0],e[1]).slice();return O.__wbindgen_free(e[0],e[1]*4,4),t}indices(){return O.tessellatedtile_indices(this.__wbg_ptr)}lineRanges(){let e=O.tessellatedtile_lineRanges(this.__wbg_ptr);var t=Qe(e[0],e[1]).slice();return O.__wbindgen_free(e[0],e[1]*4,4),t}lineTable(){return O.tessellatedtile_lineTable(this.__wbg_ptr)}pieces(){return O.tessellatedtile_pieces(this.__wbg_ptr)}prism(){return O.tessellatedtile_prism(this.__wbg_ptr)!==0}vertices(){return O.tessellatedtile_vertices(this.__wbg_ptr)}}if(Symbol.dispose)Be.prototype[Symbol.dispose]=Be.prototype.free;function kn(e,t,n,r,o,s,a,i,c,l,u,p,f,d,w,h,A){let m=Xe(e,O.__wbindgen_malloc),M=Y,b=de(t,O.__wbindgen_malloc),x=Y,T=de(n,O.__wbindgen_malloc),E=Y,_=de(r,O.__wbindgen_malloc),g=Y,y=de(o,O.__wbindgen_malloc),S=Y,k=Xe(s,O.__wbindgen_malloc),v=Y,R=de(a,O.__wbindgen_malloc),U=Y,B=de(i,O.__wbindgen_malloc),P=Y,L=de(c,O.__wbindgen_malloc),I=Y,F=Sn(l,O.__wbindgen_malloc),N=Y,W=Sn(u,O.__wbindgen_malloc),V=Y,J=$r(p,O.__wbindgen_malloc),z=Y,te=Xe(f,O.__wbindgen_malloc),G=Y,ne=de(d,O.__wbindgen_malloc),X=Y,re=Xe(A,O.__wbindgen_malloc),Me=Y,Se=O.tessellateVectorTile(m,M,b,x,T,E,_,g,y,S,k,v,R,U,B,P,L,I,F,N,W,V,J,z,te,G,ne,X,w,h,re,Me);return Be.__wrap(Se)}function zr(){return{__proto__:null,"./isard_tess_bg.js":{__proto__:null,__wbg___wbindgen_throw_41e9ee4f547fc59a:function(t,n){throw Error(qr(t,n))},__wbg_new_from_slice_37a3c3a194266cb8:function(t,n){return new Uint32Array(Qe(t,n))},__wbg_new_from_slice_9a868026ffa4208a:function(t,n){return new Uint8Array(jr(t,n))},__wbg_new_from_slice_ca6ad97db1f4779a:function(t,n){return new Float32Array(Hr(t,n))},__wbindgen_init_externref_table:function(){let t=O.__wbindgen_externrefs,n=t.grow(4);t.set(0,void 0),t.set(n+0,void 0),t.set(n+1,null),t.set(n+2,!0),t.set(n+3,!1)}}}}var Mn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e)=>O.__wbg_tessellatedtile_free(e,1));function Hr(e,t){return e=e>>>0,vn().subarray(e/4,e/4+t)}function Jr(e,t){return e=e>>>0,Rn().subarray(e/8,e/8+t)}function Qe(e,t){return e=e>>>0,Tn().subarray(e/4,e/4+t)}function jr(e,t){return e=e>>>0,_t().subarray(e/1,e/1+t)}var Ue=null;function vn(){if(Ue===null||Ue.byteLength===0)Ue=new Float32Array(O.memory.buffer);return Ue}var Ce=null;function Rn(){if(Ce===null||Ce.byteLength===0)Ce=new Float64Array(O.memory.buffer);return Ce}function qr(e,t){return Gr(e>>>0,t)}var We=null;function Tn(){if(We===null||We.byteLength===0)We=new Uint32Array(O.memory.buffer);return We}var De=null;function _t(){if(De===null||De.byteLength===0)De=new Uint8Array(O.memory.buffer);return De}function de(e,t){let n=t(e.length*4,4)>>>0;return Tn().set(e,n/4),Y=e.length,n}function Sn(e,t){let n=t(e.length*1,1)>>>0;return _t().set(e,n/1),Y=e.length,n}function $r(e,t){let n=t(e.length*4,4)>>>0;return vn().set(e,n/4),Y=e.length,n}function Xe(e,t){let n=t(e.length*8,8)>>>0;return Rn().set(e,n/8),Y=e.length,n}var et=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});et.decode();var Yr=2146435072,xt=0;function Gr(e,t){if(xt+=t,xt>=Yr)et=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),et.decode(),xt=t;return et.decode(_t().subarray(e,e+t))}var Y=0,Kr,Zr,O;function Xr(e,t){return Zr=e,O=e.exports,Kr=t,Ue=null,Ce=null,We=null,De=null,O.__wbindgen_start(),O}async function Qr(e,t){if(typeof Response==="function"&&e instanceof Response){if(!e.ok)throw Error(`failed to fetch Wasm: ${e.status} ${e.statusText} fetching '${e.url}'`);if(typeof WebAssembly.instantiateStreaming==="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(o){if(n(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let r=await WebAssembly.instantiate(e,t);if(r instanceof WebAssembly.Instance)return{instance:r,module:e};else return r}function n(r){switch(r){case"basic":case"cors":case"default":return!0}return!1}}async function En(e){if(O!==void 0)return O;if(e!==void 0)if(Object.getPrototypeOf(e)===Object.prototype)({module_or_path:e}=e);else console.warn("using deprecated parameters for the initialization function; pass a single object instead");if(e===void 0)e=new URL("isard_tess_bg.wasm",import.meta.url);let t=zr();if(typeof e==="string"||typeof Request==="function"&&e instanceof Request||typeof URL==="function"&&e instanceof URL)e=fetch(e);let{instance:n,module:r}=await Qr(await e,t);return Xr(n,r)}var tt=async(e,t)=>{let{z:n,x:r,y:o,id:s,priority:a}=t,i=K(e.tiles,n,r,o),c=await ee(i,a),l={points:[],ringStart:[],polygonStart:[],feature:[]},u=[];if(!c||j.has(s))return;let p=new Set,f=2**n;return e.layers.forEach((d)=>{let w=c.get(d["source-layer"]??"");if(!w)return;w.features.forEach((h)=>{if(h.type!==3||p.has(h)||!Q(d.filter,Z(h,n)))return;p.add(h);let A=u.length;u.push(h.properties),h.geometry.forEach((m)=>{let M=0;for(let b=0;b+1<m.length;b+=2){let x=(b+2)%m.length;M+=(m[b]??0)*(m[x+1]??0)-(m[x]??0)*(m[b+1]??0)}if(M===0)return;if(M>0||l.polygonStart.length===0||l.feature.at(-1)!==A)l.polygonStart.push(l.ringStart.length),l.feature.push(A);l.ringStart.push(l.points.length/2);for(let b=0;b+1<m.length;b+=2)l.points.push((r+(m[b]??0)/w.extent)/f,(o+(m[b+1]??0)/w.extent)/f)})})}),l.ringStart.push(l.points.length/2),l.polygonStart.push(l.ringStart.length-1),{arrays:{points:Float64Array.from(l.points),ringStart:Uint32Array.from(l.ringStart),polygonStart:Uint32Array.from(l.polygonStart),feature:Uint32Array.from(l.feature)},properties:u}},eo=new Set(["theatre","museum","place_of_worship","castle","monument","attraction","town_hall"]),to=(e)=>(e?.get("poi")?.features??[]).filter((t)=>t.type===1&&eo.has(String(t.properties.class))).flatMap((t)=>t.geometry.flat()),At=(e)=>{let[t,n,r,o]=[1/0,1/0,-1/0,-1/0];for(let s=0;s+1<e.length;s+=2)[t,n]=[Math.min(t,e[s]??0),Math.min(n,e[s+1]??0)],[r,o]=[Math.max(r,e[s]??0),Math.max(o,e[s+1]??0)];return[t,n,r,o]},no=(e,t)=>{if(t.length===0)return!1;let[n,r,o,s]=At(e[0]??[]);for(let a=0;a+1<t.length;a+=2){let[i,c]=[t[a]??0,t[a+1]??0];if(i>=n&&i<=o&&c>=r&&c<=s&&ge(e,i,c))return!0}return!1},In=(e)=>{let t=e.length>2&&e[0]===e[e.length-2]&&e[1]===e[e.length-1],n=Math.max(1,e.length/2-(t?1:0)),[r,o]=[0,0];for(let s=0;s<n;s+=1)[r,o]=[r+(e[s*2]??0),o+(e[s*2+1]??0)];return[r/n,o/n]},ro=(e,t)=>{let n=e.filter((s)=>s.type===3),r=n.filter((s)=>no(s.geometry,t)),o=new Set(r);return r.forEach((s)=>{let[a,i,c,l]=At(s.geometry[0]??[]),u=In(s.geometry[0]??[]);n.forEach((p)=>{if(o.has(p))return;let[f,d,w,h]=At(p.geometry[0]??[]);if(w<a||f>c||h<i||d>l)return;if(ge(s.geometry,...In(p.geometry[0]??[]))||ge(p.geometry,...u))o.add(p)})}),o},oo={line:(e)=>e!==1,circle:(e)=>e===1,fill:(e)=>e===3,extrusion:(e)=>e===3},so=(e,t)=>{let n=_n(e,t);return[n===void 0?0:wn(n)??0,An(e)]},io=24,ao=(e,t,n,r)=>{if(!at(e.filter))return Q(e.filter,Z(t,n))?[0,0]:void 0;let o,s=0;for(let a=n-1;a<=r;a+=1)if(Q(e.filter,Z(t,a)))o??=a,s=a+1;else if(o!==void 0)break;return o===void 0?void 0:[o<=n-1?0:o,s>r?99:s]},co=(e,t)=>{let n=e.slice(),r=[[0,0,(o)=>o>=0],[0,t,(o)=>o<=t],[1,0,(o)=>o>=0],[1,t,(o)=>o<=t]];for(let[o,s,a]of r){let i=[],c=n.length/2;for(let l=0;l<c;l+=1){let[u,p]=[n[l*2]??0,n[l*2+1]??0],f=(l+1)%c,[d,w]=[n[f*2]??0,n[f*2+1]??0],[h,A]=o===0?[u,d]:[p,w];if(a(h))i.push(u,p);if(a(h)!==a(A)){let m=(s-h)/(A-h);i.push(o===0?s:u+(d-u)*m,o===0?p+(w-p)*m:s)}}if(n=i,n.length===0)break}return n},lo=0.00048828125,uo=(e,t)=>{let n=e.length/2;if(n<=2)return[...e];let r=new Uint8Array(n),o=[[0,n-1]],s=t*t;r[0]=1,r[n-1]=1;while(o.length>0){let[a,i]=o.pop()??[0,0],[c,l,u,p]=[e[a*2]??0,e[a*2+1]??0,e[i*2]??0,e[i*2+1]??0],[f,d]=[u-c,p-l],w=f*f+d*d,[h,A]=[-1,s];for(let m=a+1;m<i;m+=1){let[M,b]=[(e[m*2]??0)-c,(e[m*2+1]??0)-l],x=w>0?Math.max(0,Math.min(1,(M*f+b*d)/w)):0,T=(M-x*f)**2+(b-x*d)**2;if(T>A)[h,A]=[m,T]}if(h>=0)r[h]=1,o.push([a,h],[h,i])}return e.filter((a,i)=>r[i>>1]===1)},fo=(e,t)=>{let n=[],r=[],o=()=>{if(r.length>=4)n.push(r);r=[]};for(let s=2;s+1<e.length;s+=2){let[a,i,c,l]=[e[s-2]??0,e[s-1]??0,e[s]??0,e[s+1]??0],[u,p]=[c-a,l-i],[f,d]=[0,1];for(let[w,h]of[[-u,a],[u,t-a],[-p,i],[p,t-i]])if(w===0){if(h<0)d=-1}else if(w<0)f=Math.max(f,h/w);else d=Math.min(d,h/w);if(f>d){o();continue}if(r.length===0||f>0)o(),r.push(a+u*f,i+p*f);if(r.push(a+u*d,i+p*d),d<1)o()}return o(),n},mo=(e,t)=>e>=t?[e-0.5,e+1,e+3,e+6]:[e-0.5,e-0.16666666666666666,e+0.16666666666666666,e+0.5],po=(e,t,n,r,o)=>{let s=2**n,[a,i]=[r*t,o*t],c=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];e.forEach((d)=>{for(let w=0;w+1<d.length;w+=2){let[h,A]=[(d[w]??0)*s-a,(d[w+1]??0)*s-i];c[0]=Math.min(c[0]??h,h),c[1]=Math.min(c[1]??A,A),c[2]=Math.max(c[2]??h,h),c[3]=Math.max(c[3]??A,A)}});let[l=0,u=0,p=0,f=0]=c;if(p<=0||f<=0||l>=t||u>=t)return;return e.map((d)=>d.map((w,h)=>w*s-(h%2===0?a:i)))},bo=(e)=>{let t=[],n=[],r=[],o=[];return{add:(i,c,l,u,p,f=!1)=>{let d=(b,x,T)=>C(c,"paint",b,{...l,zoom:T},x),w=`${c.type}-opacity`,h=me(c.paint?.[w]),A=(b)=>{let[x,T,E,_]=ce(d(f?"fill-outline-color":`${c.type}-color`,"#000",b))??[0,0,0,1];return[x,T,E,_*(h?Number(d(w,1,b)):1)]},m=Array(wt).fill(0),M=e[3]-e[0]>1.5?e[1]:e[3];if(m.splice(q.color,8,...A(e[0]),...A(M)),m.splice(q.range,2,...p),!f&&["fill","background","line","fill-extrusion"].includes(c.type)){let b=d(`${c.type}-pattern`,"",(e[0]+M)/2);if(typeof b==="string"&&b){let x=n.indexOf(b);m[c.type==="fill"||c.type==="background"?q.fillPattern:q.linePattern]=(x>=0?x:n.push(b)-1)+1}}if(c.type==="circle"){let b=(e[0]+M)/2,[x,T,E,_]=ce(d("circle-stroke-color","#000",b))??[0,0,0,1];m.splice(q.color,8,...A(b),x,T,E,_*Number(d("circle-stroke-opacity",1,b)))}return e.forEach((b,x)=>{if(m[q.size+x]=b,f){m[q.size+4+x]=1;return}if(c.type==="circle"){m[q.size+4+x]=Math.max(0,Number(d("circle-radius",5,b))||0),m[q.size2+x]=b,m[q.size2+4+x]=Math.max(0,Number(d("circle-stroke-width",0,b))||0);return}if(c.type==="fill-extrusion"){m[q.size+4+x]=Math.max(0,Number(d("fill-extrusion-height",0,b))||0),m[q.size2+x]=b,m[q.size2+4+x]=Math.max(0,Number(d("fill-extrusion-base",0,b))||0);return}if(c.type!=="line")return;if(x===0)m[q.blur]=Math.max(0,Number(d("line-blur",0,(e[0]+M)/2))||0);let T=Number(d("line-width",1,b)),E=Number(d("line-gap-width",0,b));m[q.size+4+x]=Math.max(0,E>0?E+2*T:T),m[q.size2+x]=b,m[q.size2+4+x]=Number(d("line-offset",0,b))||0}),t.push(...m),r.push(u),o.push(i),r.length-1},landmark:(i)=>{t[i*wt+q.landmark]=1},styles:t,patterns:n,properties:r,sublayer:o}},yo=(e,t,n)=>{let r={points:[],ringStart:[],polygonStart:[],feature:[],roofs:[],roofHeights:[],roofOutlines:[],roofOutlineStart:[]},o={points:[],start:[],feature:[]},s={points:[],feature:[]},a={fill:[],line:[],circle:[]},i=(u,p,f)=>[(e+u/f)/n,(t+p/f)/n],c=(u,p,f)=>{r.polygonStart.push(r.ringStart.length),r.feature.push(u),r.roofs.push(p),r.roofHeights.push(f),r.roofOutlineStart.push(r.roofOutlines.length/2)},l=()=>{a.fill.push(r.polygonStart.length),a.line.push(o.start.length),a.circle.push(s.feature.length)};return{sublayer:l,background:(u)=>{c(u,0,Number.NaN),r.ringStart.push(r.points.length/2),r.points.push(e/n,t/n,(e+1)/n,t/n,(e+1)/n,(t+1)/n,e/n,(t+1)/n)},circles:(u,p,f)=>{u.forEach((d)=>{for(let w=0;w+1<d.length;w+=2){let[h=0,A=0]=[d[w],d[w+1]];if(h<0||A<0||h>=f||A>=f)continue;s.points.push(...i(h,A,f)),s.feature.push(p)}})},lines:(u,p,f,d)=>{u.forEach((w)=>{let h=p&&w.length>=2?[...w,w[0]??0,w[1]??0]:w;fo(h,d).forEach((A)=>{let m=uo(A,d*lo);o.start.push(o.points.length/2),o.feature.push(f);for(let M=0;M+1<m.length;M+=2)o.points.push(...i(m[M]??0,m[M+1]??0,d))})})},polygons:(u,p,[f,d],w)=>{let h=!1;u.forEach((A)=>{let m=0;for(let b=0;b+1<A.length;b+=2){let x=(b+2)%A.length;m+=(A[b]??0)*(A[x+1]??0)-(A[x]??0)*(A[b+1]??0)}if(m===0)return;if(m<0&&!h)return;let M=co(A,w);if(m>0)h=M.length>=6;if(M.length<6)return;if(m>0){if(c(p,f,d),f>1&&A.some((b)=>b<0||b>w))for(let b=0;b+1<A.length;b+=2)r.roofOutlines.push(...i(A[b]??0,A[b+1]??0,w))}r.ringStart.push(r.points.length/2);for(let b=0;b+1<M.length;b+=2)r.points.push(...i(M[b]??0,M[b+1]??0,w))})},done:()=>(l(),r.ringStart.push(r.points.length/2),r.polygonStart.push(r.ringStart.length-1),r.roofOutlineStart.push(r.roofOutlines.length/2),o.start.push(o.points.length/2),{fills:{points:Float64Array.from(r.points),ringStart:Uint32Array.from(r.ringStart),polygonStart:Uint32Array.from(r.polygonStart),feature:Uint32Array.from(r.feature),fillStart:Uint32Array.from(a.fill),roofs:Uint8Array.from(r.roofs),roofHeights:Float32Array.from(r.roofHeights),roofOutlines:Float64Array.from(r.roofOutlines),roofOutlineStart:Uint32Array.from(r.roofOutlineStart),roofMetres:rt((t+0.5)/n)},lines:{points:Float64Array.from(o.points),start:Uint32Array.from(o.start),feature:Uint32Array.from(o.feature),lineStart:Uint32Array.from(a.line)},circles:{points:Float64Array.from(s.points),feature:Uint32Array.from(s.feature),circleStart:Uint32Array.from(a.circle)},tile:Float64Array.of(e/n,t/n,(e+1)/n,(t+1)/n)})}},Fn=async(e,t,n)=>{let{z:r,x:o,y:s,id:a,priority:i,deepest:c=e.maxzoom,roofs:l="data",covered:u=[]}=t,p=Math.max(0,r-e.maxzoom),[f,d,w]=[r-p,Math.floor(o/2**p),Math.floor(s/2**p)],[h,A]=[o-d*2**p,s-w*2**p],m=await ee(K(e.tiles,f,d,w),i);if(j.has(a))return;let M=to(m),b=new Map,x=(g)=>{let y=b.get(g)??(M.length>0?ro(g,M):new Set);return b.set(g,y),y},T=(g,y)=>{if(u.length===0)return!1;let[S=0,k=0]=g.geometry[0]??[],[v,R]=H(f,d,w,y,S,k);for(let U=0;U+3<u.length;U+=4)if(v>=(u[U]??0)&&R>=(u[U+1]??0)&&v<=(u[U+2]??0)){if(R<=(u[U+3]??0))return!0}return!1},E=bo(mo(r,Math.max(c,e.maxzoom))),_=r>=Math.max(c,e.maxzoom)?io:r;return e.layers.forEach((g,y)=>{n?.sublayer();let S=je(g),k=g.type==="fill"&&g.paint?.["fill-outline-color"]!==void 0&&g.paint?.["fill-antialias"]!==!1;if(!S)return;if(g.type==="background"){let R=E.add(y,g,{zoom:r,properties:{},type:"Unknown"},{},[0,0]);n?.background(R);return}let v=m?.get(g["source-layer"]??"");v?.features.forEach((R)=>{if(!oo[S](R.type))return;if(S==="extrusion"&&T(R,v.extent))return;let U=Z(R,r),B=ao(g,R,r,_);if(!B)return;let P=p>0?po(R.geometry,v.extent,p,h,A):R.geometry;if(!P)return;let L=E.add(y,g,U,R.properties,B),I=k?E.add(y,g,U,R.properties,B,!0):-1;if(S==="extrusion"&&x(v.features).has(R))E.landmark(L);if(!n)return;if(S==="circle"){n.circles(P,L,v.extent);return}if(S==="line"){n.lines(P,R.type===3,L,v.extent);return}if(I>=0)n.lines(P,!0,I,v.extent);let F=S==="extrusion"?so(R.properties,l):[0,Number.NaN];n.polygons(P,L,F,v.extent)})}),E},Nn=async(e,t)=>{let n=await Fn(e,t);return n&&{styles:Float32Array.from(n.styles),patterns:n.patterns}},On=async(e,t)=>{let n=yo(t.x,t.y,2**t.z),r=await Fn(e,t,n);if(!r)return;return{...n.done(),styles:Float32Array.from(r.styles),patterns:r.patterns,properties:r.properties,sublayer:Uint16Array.from(r.sublayer)}},we={},Pn=()=>{if(!we.url)return Promise.resolve(!1);let e=we.ready??En({module_or_path:we.url}).then(()=>!0,(t)=>(console.warn("isard: the tessellation module failed to load, the main thread does its work",t),!1));return we.ready=e,e},Ln=(e,t,n)=>{let{fills:r,lines:o}=e;try{let s=kn(r.points,r.ringStart,r.polygonStart,r.feature,r.fillStart,o.points,o.start,o.feature,o.lineStart,t,r.roofs??new Uint8Array,r.roofHeights??new Float32Array,r.roofOutlines??new Float64Array,r.roofOutlineStart??new Uint32Array,r.roofMetres??0,n,e.tile??new Float64Array),a={vertices:s.vertices(),indices:s.indices(),fillRanges:s.fillRanges(),prism:s.prism(),pieces:s.pieces(),lineTable:s.lineTable(),lineRanges:s.lineRanges(),blocks:s.blocks(),blockIndices:s.blockIndices(),blockRanges:s.blockRanges(),bounds:s.bounds()};return s.free(),a}catch(s){console.warn("isard: the tessellation module failed, the main thread does its work",s),we.ready=Promise.resolve(!1);return}};var ho={primary:8,secondary:7,tertiary:6,minor:5,service:4},Un=async(e,t)=>{let{z:n,x:r,y:o,id:s,spacing:a,maxLamps:i,priority:c}=t,l=K(e.tiles,n,r,o),u=await ee(l,c);if(!u||j.has(s))return;let p=_e(n,o),f=new Set,d=[];return e.layers.forEach((w)=>{let h=u.get(w["source-layer"]??"");if(!h)return;let A=h.extent/p;h.features.forEach((m)=>{let M=ho[String(m.properties.class)];if(m.type!==2||M===void 0||f.has(m)||!Q(w.filter,Z(m,n)))return;f.add(m),m.geometry.forEach((b)=>{Ae(b,a*A).forEach((x,T)=>{let[E,_,g]=Ke(x,T,M*A);if(E<0||_<0||E>=h.extent||_>=h.extent)return;let[y,S]=H(n,r,o,h.extent,E,_),k=se(Math.floor(E),Math.floor(_),Math.floor(x[6]??0),29);d.push(y,S,1,g,k,0)})})})}),Ze(d,i)};var go=new Set(["butt","round","square"]),wo=new Set(["bevel","miter","round"]),xo=(e)=>go.has(e),_o=(e)=>wo.has(e),Ao=(e)=>xo(e)?e:"butt",Mo=(e)=>_o(e)?e:"miter",So=(e,t)=>{if(e.patterns.has(t))return e.patterns.get(t);let r=(()=>{let o=gt(e,t);if(!o||!(o.icon.width>0)||!(o.icon.height>0))return;let{icon:s}=o,a=new OffscreenCanvas(s.width,s.height);return a.getContext("2d")?.drawImage(o.image,s.x,s.y,s.width,s.height,0,0,s.width,s.height),a})();return e.patterns.set(t,r),r},Mt=new Map,ko=(e)=>{let t=Mt.get(e)?.pop()??new OffscreenCanvas(e,e),n=t.getContext("2d",{willReadFrequently:!0});if(!n)throw Error("isard: no 2D context");return n.setTransform(1,0,0,1,0,0),n.globalAlpha=1,n.setLineDash([]),n.clearRect(0,0,e,e),{canvas:t,g:n}},vo=(e)=>{let t=Mt.get(e.width)??[];if(Mt.set(e.width,t),t.length<4)t.push(e)},Ro=(e,t,n)=>{if(n)return Promise.resolve(e.transferToImageBitmap());return createImageBitmap(t.getImageData(0,0,e.width,e.height),{premultiplyAlpha:"none"})},Cn=async(e,t)=>{let{z:n,x:r,y:o,size:s,id:a,priority:i}=t,c=un(e,n,r,o),l=await ee(c.url,i);if(j.has(a))return;let{canvas:u,g:p}=ko(s);try{return await To(e,c,l,u,p,n,r,o,s,a,i)}finally{vo(u)}},To=async(e,t,n,r,o,s,a,i,c,l,u)=>{let p=Math.max(0,s-1),f=c/256,d=!1,w=!1;for(let h of e.layers){if(!Le(h,p))continue;let A={zoom:p,properties:{},type:"Unknown"};if(h.type==="background"){let g=C(h,"paint","background-color",A,"#000"),y=Number(C(h,"paint","background-opacity",A,1));if(o.fillStyle=pe(g,y),o.fillRect(0,0,c,c),(ce(g)??[0,0,0,1])[3]*y>=1)w=!0;d=!0;continue}if(h.type==="raster"){let g=h.source===void 0?void 0:e.rasters[h.source];if(!g)continue;let y=xe(s-(g.tileSize>=512?1:0),0,g.maxzoom),S=2**(s-y),k=K(g.tiles,y,Math.floor(a/S),Math.floor(i/S)),v=await ln(k,u);if(j.has(l))return;if(!v)continue;let[R,U]=[v.width/S,v.height/S];o.globalAlpha=Number(C(h,"paint","raster-opacity",A,1)),o.drawImage(v,a%S*R,i%S*U,R,U,0,0,c,c),o.globalAlpha=1,d=!0;continue}let m=n?.get(h["source-layer"]??"");if(!m)continue;let M=c/(m.extent*t.part),[b,x]=[t.ox*m.extent,t.oy*m.extent],T=(g,y)=>{o.beginPath();for(let S of g.geometry){for(let k=0;k+1<S.length;k+=2){let[v,R]=[((S[k]??0)-b)*M,((S[k+1]??0)-x)*M];if(k===0)o.moveTo(v,R);else o.lineTo(v,R)}if(y)o.closePath()}},E=new Map,_=(g,y,S,k)=>{let v=E.get(y),R=v??me(h[g]?.[y]);if(v===void 0)E.set(y,R);return C(h,g,y,R?S:A,k)};for(let g of m.features){let y=Z(g,p);if(!Q(h.filter,y))continue;if(h.type==="fill-extrusion"&&g.type===3)T(g,!0),o.fillStyle=pe(_("paint","fill-extrusion-color",y,"#000"),Number(_("paint","fill-extrusion-opacity",y,1))),o.fill("evenodd"),d=!0;else if(h.type==="fill"&&g.type===3){let S=Number(_("paint","fill-opacity",y,1)),k=_("paint","fill-pattern",y,void 0);T(g,!0);let v=typeof k==="string"?gt(e,k)?.icon:void 0,R=v&&typeof k==="string"&&So(e,k);if(v&&R){let U=o.createPattern(R,"repeat");if(U)U.setTransform(new DOMMatrix().scale(f/(v.pixelRatio??1))),o.globalAlpha=S,o.fillStyle=U,o.fill("evenodd"),o.globalAlpha=1}else{o.fillStyle=pe(_("paint","fill-color",y,"#000"),S),o.fill("evenodd");let U=_("paint","fill-outline-color",y,void 0);if(U!==void 0)o.strokeStyle=pe(U,S),o.lineWidth=f,o.setLineDash([]),o.stroke()}d=!0}else if(h.type==="line"&&g.type!==1){let S=Number(_("paint","line-width",y,1));if(S<=0)continue;let k=Number(_("paint","line-gap-width",y,0));o.strokeStyle=pe(_("paint","line-color",y,"#000"),Number(_("paint","line-opacity",y,1))),o.lineWidth=(k>0?k+2*S:S)*f,o.lineCap=Ao(_("layout","line-cap",y,"butt")),o.lineJoin=Mo(_("layout","line-join",y,"miter"));let v=_("paint","line-dasharray",y,void 0);o.setLineDash(Array.isArray(v)?v.map((R)=>Number(R)*S*f):[]),T(g,g.type===3),o.stroke(),d=!0}else if(h.type==="circle"&&g.type===1){let S=Number(_("paint","circle-radius",y,5))*f;o.fillStyle=pe(_("paint","circle-color",y,"#000"),Number(_("paint","circle-opacity",y,1)));let k=Number(_("paint","circle-stroke-width",y,0))*f;o.strokeStyle=pe(_("paint","circle-stroke-color",y,"#000"),Number(_("paint","circle-stroke-opacity",y,1))),o.lineWidth=k;for(let v of g.geometry)for(let R=0;R+1<v.length;R+=2)if(o.beginPath(),o.arc(((v[R]??0)-b)*M,((v[R+1]??0)-x)*M,S,0,2*Math.PI),o.fill(),k>0)o.stroke();d=!0}}}if(!d&&!n)return null;return Ro(r,o,w)};var Wn=async(e,t)=>{let{z:n,tiles:r,bounds:o,width:s,height:a,iterations:i,module:c,priority:l,id:u}=t,[p,f,d,w]=o,h=[],A=[],m=[],M=2**n;for(let b=0;b+1<r.length;b+=2){let x=r[b]??0,T=(x%M+M)%M,E=(x-T)/M,_=await tt(e,{z:n,x:T,y:r[b+1]??0,id:u,priority:l});if(j.has(u))throw Error("aborted");if(!_)continue;let{points:g,ringStart:y,polygonStart:S}=_.arrays;for(let k=0;k+1<S.length;k++){let[v,R]=[S[k]??0,S[k+1]??0],U=y[v]??0,B=y[R]??0,[P,L,I,F]=[1/0,1/0,-1/0,-1/0];for(let N=U;N<B;N++){let[W,V]=[(g[N*2]??0)+E,g[N*2+1]??0];P=Math.min(P,W),L=Math.min(L,V),I=Math.max(I,W),F=Math.max(F,V)}if(I<p||P>d||F<f||L>w)continue;m.push(A.length);for(let N=v;N<R;N++){A.push(h.length/2);for(let W=y[N]??0;W<(y[N+1]??0);W++)h.push(((g[W*2]??0)+E-p)/(d-p)*s,((g[W*2+1]??0)-f)/(w-f)*a)}}}return A.push(h.length/2),m.push(A.length-1),Zt({points:Float64Array.from(h),ringStart:Uint32Array.from(A),polygonStart:Uint32Array.from(m)},s,a,i,c)};var St=new Map,Eo={},Dn=Tt(),ue=(e,t=[])=>self.postMessage(e,t),Io=({fills:e,lines:t,circles:n,styles:r,sublayer:o,mesh:s})=>[e.points,e.ringStart,e.polygonStart,e.feature,e.fillStart,e.roofs,e.roofHeights,e.roofOutlines,e.roofOutlineStart,t.points,t.start,t.feature,t.lineStart,n?.points,n?.feature,n?.circleStart,r,o,s?.vertices,s?.indices,s?.fillRanges,s?.pieces,s?.lineTable,s?.lineRanges,s?.blocks,s?.blockIndices,s?.blockRanges,s?.bounds].flatMap((a)=>a?[a.buffer]:[]),Fo={render:async(e,t)=>{let n=await Cn(e,t);return n?[{image:n},[n]]:void 0},labels:async(e,t)=>[{labels:await pn(e,t)},[]],polygons:async(e,t)=>{let n=await tt(e,t);if(!n)return;let{points:r,ringStart:o,polygonStart:s,feature:a}=n.arrays;return[{polygons:n},[r.buffer,o.buffer,s.buffer,a.buffer]]},trees:async(e,t)=>{let n=await bn(e,t);return n&&[{trees:n},[n.buffer]]},furniture:async(e,t)=>{let n=await hn(e,t);return n&&[{furniture:n},[n.buffer]]},lamps:async(e,t)=>{let n=await Un(e,t);return n&&[{lamps:n},[n.buffer]]},street:async(e,t)=>{let n=await Wn(e,t);return[{street:n},[n.eastU,n.eastV,n.northU,n.northV].map((r)=>r.buffer)]},vectors:async(e,t)=>{if(t.styles){let a=await Nn(e,t);return a&&[a,[a.styles.buffer]]}let n=await On(e,t);if(!n)return;let r=Uint8Array.from(e.layers,(a)=>je(a)==="extrusion"?1:0),o=await Pn()?Ln(n,r,t.prism===!0):void 0,s=o?{...n,mesh:o}:n;return[{vectors:s},Io(s)]}},No=(e,t,n)=>Fo[t](e,n);self.onmessage=async({data:e})=>{if(e.type==="headers"){Rt(e.rules);return}if(e.type==="tess"){we.url=e.url;return}if(e.type==="init"){if(e.workers!==void 0)Oe.capacity=an(e.workers,e.cached);Pe.set(e.key,{tiles:e.tiles,maxzoom:e.maxzoom,layers:e.layers,rasters:e.rasters??{},sprites:e.sprites??[],patterns:new Map});return}if(e.type==="drop"){Pe.get(e.key)?.sprites.forEach((t)=>{t.image.close()}),Pe.delete(e.key);return}if(e.type==="abort"){if(Ye.has(e.id))j.add(e.id);St.get(e.id)?.abort();return}if(e.type==="heights"||e.type==="reproject"||e.type==="grids"){await Po(e);return}Ye.add(e.id);try{let t=Pe.get(e.key);if(!t)throw Error(`isard: no renderer ${e.key}`);let n=await No(t,e.type,e);if(n)ue({id:e.id,...n[0]},n[1]);else ue({id:e.id,missing:!0})}catch(t){ue({id:e.id,error:String(t)})}finally{Ye.delete(e.id),j.delete(e.id)}};var Oo=async(e,t)=>(await kt(e,oe(e,{signal:t}))).arrayBuffer(),Po=async(e)=>{let t=new AbortController;St.set(e.id,t);try{if(e.type==="grids"){let{module:n,url:r,bytes:o}=e,s=o??(r?await Oo(r,t.signal):new ArrayBuffer(0)),{grids:a,values:i}=await Xt(new Uint8Array(s),n);ue({id:e.id,grids:a,values:i},i.map((c)=>c.buffer))}else if(e.type==="heights"){let n=await Nt(e.url,e.encoding,e.floor,t.signal,Eo);if(n)ue({id:e.id,heights:n},[n.buffer]);else ue({id:e.id,missing:!0})}else{Dn.cache.capacity=e.cached;let n=await Dn.draw(e.job,t.signal);if(n)ue({id:e.id,image:n},[n]);else ue({id:e.id,missing:!0})}}catch(n){ue({id:e.id,error:String(n)})}finally{St.delete(e.id)}};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=C9CE549B5C08D87A64756E2164756E21
|
|
4
4
|
//# sourceMappingURL=basemap.worker.js.map
|