@mapcreator/sdk 0.0.0-video.7 → 0.0.0-video.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mapcreator-sdk.js +16 -15
- package/dist/mapcreator-sdk.umd.cjs +2 -2
- package/dist/report.html +1 -1
- package/dist/utils/overlays.d.ts +1 -1
- package/package.json +1 -1
package/dist/mapcreator-sdk.js
CHANGED
|
@@ -38810,9 +38810,13 @@ function xl(e, t, n, r, i) {
|
|
|
38810
38810
|
}
|
|
38811
38811
|
//#endregion
|
|
38812
38812
|
//#region src/utils/overlays.ts
|
|
38813
|
-
async function Sl(e, t, n, r, i) {
|
|
38814
|
-
let
|
|
38815
|
-
|
|
38813
|
+
async function Sl(e, t, n, r, i, a) {
|
|
38814
|
+
let o = await Promise.all(t.map((e) => `${r}/styles/${e}.json?access_token=${i}`).map((e) => fetch(e).then((e) => e.json())));
|
|
38815
|
+
for (let t = 0; t < e.length; t++) {
|
|
38816
|
+
let n = e[t], r = o[t];
|
|
38817
|
+
for (let e of r.layers) e.metadata === void 0 && (e.metadata = {}), e.metadata["mc-original-layer-id"] = e.id, e.id = `${n} | ${e.id}`;
|
|
38818
|
+
}
|
|
38819
|
+
return await Promise.all(o.map((e) => Cl(e, n, i, a))), o;
|
|
38816
38820
|
}
|
|
38817
38821
|
async function Cl(e, t, n, r) {
|
|
38818
38822
|
for (let n in e.sources) t.getSource(n) === void 0 && t.addSource(n, e.sources[n]);
|
|
@@ -38824,22 +38828,22 @@ async function Cl(e, t, n, r) {
|
|
|
38824
38828
|
}
|
|
38825
38829
|
}
|
|
38826
38830
|
function wl(e, t) {
|
|
38827
|
-
let n =
|
|
38831
|
+
let n = t ?? {}, r = e.metadata?.["mc-original-layer-id"], i = r === void 0 ? {} : n[r] ?? {}, a = {
|
|
38828
38832
|
...e,
|
|
38829
38833
|
layout: {
|
|
38830
38834
|
...e.layout,
|
|
38831
|
-
...
|
|
38835
|
+
...i.layout
|
|
38832
38836
|
},
|
|
38833
38837
|
paint: {
|
|
38834
38838
|
...e.paint,
|
|
38835
|
-
...
|
|
38839
|
+
...i.paint
|
|
38836
38840
|
},
|
|
38837
38841
|
metadata: {
|
|
38838
38842
|
...e.metadata,
|
|
38839
|
-
...
|
|
38843
|
+
...i.metadata
|
|
38840
38844
|
}
|
|
38841
38845
|
};
|
|
38842
|
-
return
|
|
38846
|
+
return i.minzoom !== void 0 && (a.minzoom = i.minzoom), i.maxzoom !== void 0 && (a.maxzoom = i.maxzoom), "filter" in i && a.type !== "background" && (a.filter = i.filter), a;
|
|
38843
38847
|
}
|
|
38844
38848
|
async function Tl(e, t, n) {
|
|
38845
38849
|
try {
|
|
@@ -40330,8 +40334,8 @@ async function Fu(e) {
|
|
|
40330
40334
|
}
|
|
40331
40335
|
let I = await fetch(`${i}/styles/${o.meta.mapstyleSet}.json?access_token=${t}`).then((e) => e.json());
|
|
40332
40336
|
s.setStyle(null), s.setStyle(I), await s.once("style.load"), n === "app" && Vu(s.getStyle().metadata?.customCssFilePath, t), u(h, s);
|
|
40333
|
-
let te = await Sl(o.meta.layers ?? [], s, i, t, I.metadata?.styleOverride), ne = (o.map.overlays ?? []).reduce((e, t, n) => e.set(t, te[n]), /* @__PURE__ */ new Map());
|
|
40334
|
-
return Uu(s, d, A, j, M, i, t), u(h, s), p.setPublication(I.metadata?.publication), p.setpopupElements(), p.setHighlightManager(), s.setProjection({ type: C === "globe" ? "globe" : "mercator" }), Ru(s, C), w && zu(s, i, t, T), Hu(s,
|
|
40337
|
+
let te = await Sl(o.map.overlays ?? [], o.meta.layers ?? [], s, i, t, I.metadata?.styleOverride), ne = (o.map.overlays ?? []).reduce((e, t, n) => e.set(t, te[n]), /* @__PURE__ */ new Map());
|
|
40338
|
+
return Uu(s, d, A, j, M, i, t), u(h, s), p.setPublication(I.metadata?.publication), p.setpopupElements(), p.setHighlightManager(), s.setProjection({ type: C === "globe" ? "globe" : "mercator" }), Ru(s, C), w && zu(s, i, t, T), Hu(s, x, !b), new Pu(s, o, M, d, I, ne);
|
|
40335
40339
|
}
|
|
40336
40340
|
function Iu(e, t, n) {
|
|
40337
40341
|
return fetch(`${t}/jobs/${e}.json?access_token=${n}`).then((e) => e.json());
|
|
@@ -40373,11 +40377,8 @@ function Vu(e, t) {
|
|
|
40373
40377
|
let n;
|
|
40374
40378
|
e.startsWith("http") ? (e = `${e}?access_token=${t}`, n = document.createElement("link"), n.setAttribute("rel", "stylesheet"), n.setAttribute("href", e.replace(/https?:/, ""))) : (n = document.createElement("style"), n.appendChild(document.createTextNode(e))), n.setAttribute("id", "custom-style"), n.setAttribute("type", "text/css"), document.head.appendChild(n);
|
|
40375
40379
|
}
|
|
40376
|
-
function Hu(e, t, n
|
|
40377
|
-
for (let
|
|
40378
|
-
let n = t.layers.find((e) => i.id === e.id || i.id.endsWith(` | ${e.id}`));
|
|
40379
|
-
n && e.setLayoutProperty(n.id, "visibility", i.visibility && r ? "visible" : "none");
|
|
40380
|
-
}
|
|
40380
|
+
function Hu(e, t, n) {
|
|
40381
|
+
for (let r of t) e.getLayer(r.id) !== void 0 && e.setLayoutProperty(r.id, "visibility", r.visibility && n ? "visible" : "none");
|
|
40381
40382
|
}
|
|
40382
40383
|
function Uu(e, t, n, r, i, a, o) {
|
|
40383
40384
|
let { beforeNone: s = [], beforeNames: c = [], beforeBoundaries: l = [], beforeWaters: u = [] } = r;
|
|
@@ -1118,7 +1118,7 @@ vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matr
|
|
|
1118
1118
|
${m?.humanized??``}
|
|
1119
1119
|
</text>
|
|
1120
1120
|
</svg>
|
|
1121
|
-
`}function ol(e,t,n){let r=document.createElement(`div`);r.className=`adornment`;let i=`ArialMT`,a=[e.titleFont??i,e.subtitleFont??i];return Dr(Array.from(new Set(a)),t,n).then(()=>r.innerHTML=sl(e,i)),r}function sl(e,t){let{title:n,titleColor:r=`#000000`,titleFont:i=t,titleFontSize:a=20,titleJustify:o=`center`,subtitle:s,subtitleColor:c=`#000000`,subtitleFont:l=t,subtitleFontSize:u=12,subtitleJustify:d=`center`,background:f=`#ffffff`,showBackground:p=!1}=e,m=0,h=0,g=0,_=0,v=0,y=n.trim().length>0?Ur([n],i,a):null,b=s.trim().length>0?Ur([s],l,u):null;if(m=Math.max(y?.width??0,b?.width??0),y){let{ascent:e,descent:t}=y;h=e+t,_=8+e}if(b){let{ascent:e,descent:t}=b;g=e+t,v=y?_+y.descent+e+6:8+e}let x=m+16,S=h+g+16,C=o===`center`?x/2:o===`right`?x-8:8,w=d===`center`?x/2:d===`right`?x-8:8,T=``;if(T+=`<svg xmlns="http://www.w3.org/2000/svg" width="${x}" height="${S}" viewBox="0 0 ${x} ${S}">`,T+=`<rect x="0" y="0" width="${x}" height="${S}" fill="${f}" rx="6" style="visibility:${p?`visible`:`hidden`}" />`,y||b){let e=o===`center`?`middle`:o===`right`?`end`:`start`,t=d===`center`?`middle`:d===`right`?`end`:`start`;T+=`<text x="${C}" y="${_}" fill="${r}" font-family="${i}" font-size="${a}" text-anchor="${e}">`,y&&(T+=`${Er(n)}`),b&&(T+=`<tspan x="${w}" y="${v}" fill="${c}" font-family="${l}" font-size="${u}" text-anchor="${t}">`,T+=`${Er(s)}`,T+=`</tspan>`),T+=`</text>`}return T+=`</svg>`,T}var cl=[`top_left`,`top_right`,`bottom_left`,`bottom_right`,`top_center`,`left_center`,`right_center`,`bottom_center`],ll=new Map;function ul(e,t,n,r,i,a,o,s,c){let{adornments:l=[]}=e;dl(n,t,s,c),l.forEach(t=>{t.type===`custom`?pl(te(t),t.position,t.stacking):t.type===`scalebar`?pl(il(t,n),t.position,t.stacking):t.type===`northArrow`?pl(di(t,n),t.position,t.stacking):t.type===`webControls`&&t.buttons?pl(Ui(t,n,r),t.position,t.stacking):t.type===`insetMap`?pl(Jc(t,n,a),t.position,t.stacking):t.type===`heading`?pl(ol(t,i,o),t.position,t.stacking):t.type===`manualLegend`?pl(ui(t,i,o),t.position,t.stacking):t.type===`connectedLegend`?pl(ni(t,e,n,i,o),t.position,t.stacking):t.type===`copyright`&&c===`video`&&pl(Gi(t,n),t.position,t.stacking)}),ml(n),n.on(`moveend`,()=>ml(n))}function dl(e,t,n,r){let i=e.getContainer();for(let e of cl){let a=document.createElement(`div`);a.classList.add(`adornment-container`,e),a.style.cssText=fl(e,t[e],n,r);let o=document.createElement(`div`),s=document.createElement(`div`);o.classList.add(`inner`),s.classList.add(`inner`,`vertical`),a.append(o,s),i.appendChild(a),ll.set(e,{horizontal:o,vertical:s})}}function fl(e,t,n,r){let i=v[e],a=``,o=[],s=t.x*n,c=t.y*n;o.push(`scale(${n})`);let{unit:l}=t;return i.x===`center`?o.push(`translateX(${s}${l})`):a+=`${i.x}: ${s}${l};`,i.y===`center`?o.push(`translateY(${c}${l})`):e===`bottom_right`&&r!==`video`?a+=`${i.y}: max(${c}${l}, 25px);`:a+=`${i.y}: ${c}${l};`,o.length&&(a+=`transform: ${o.join(` `)};`),a}function pl(e,t,n){n||=[`left_center`,`right_center`].includes(t)?`vertical`:`horizontal`;let r=ll.get(t),i=t===`left_center`||t===`right_center`?`vertical`:`horizontal`;r?.[i].hasChildNodes()||(n=i),(r?.[n])?.appendChild(e)}function ml(e){let t=Array.from(document.querySelectorAll(`.adornment, .maplibregl-ctrl-attrib`)),n=[];t.forEach(e=>{let t=e.getBoundingClientRect();t&&n.push([t.x,t.y,t.x+t.width,t.y+t.height])}),e.setLabelFreeAreas(n)}function hl(e,t,n,r,i){e.addSource(t.id,{type:`geojson`,data:{type:`FeatureCollection`,features:t.models.filter(e=>e.visible??!0).map(e=>gl(t,e,r,i))}}),e.addLayer({id:t.id,type:`fill`,source:t.id,metadata:{"mc-model-type":`polygon`,"mc-group-id":t.id},paint:{"fill-color":[`get`,`fill-color`],"fill-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]}},n),e.addLayer({id:`${t.id}-pattern`,type:`fill`,source:t.id,filter:[`has`,`fill-pattern`],paint:{"fill-pattern":[`get`,`fill-pattern`],"fill-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]},metadata:{"mc-model-type":`polygon`,"mc-group-id":t.id}},n),e.addLayer({id:`${t.id}-outline`,type:`line`,source:t.id,metadata:{"mc-model-type":`polygon`,"mc-group-id":t.id},layout:{"line-cap":`round`,"line-join":`round`},paint:{"line-width":[`get`,`outline-width`],"line-color":[`get`,`outline-color`],"line-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]}},n)}function gl(e,t,n,r){let i=t.fillPattern===void 0?void 0:r.getMapLibreImageKey(n[t.fillPattern],2*window.devicePixelRatio);return{type:`Feature`,id:C(t.id),properties:{id:t.id,"fill-color":e.fillColor||t.fillColor?Wr(t.dataBindings??{},t.fillColor,e.fillColor):`#000000`,"outline-color":e.outlineColor||t.outlineColor?Wr(t.dataBindings??{},t.outlineColor,e.outlineColor):`#000000`,"outline-width":t.outlineWidth??0,"fill-pattern":i},geometry:{type:`Polygon`,coordinates:or(t)}}}function _l(e,t,n,r,i){e.addSource(t.id,{type:`geojson`,data:{type:`FeatureCollection`,features:t.models.filter(e=>e.visible??!0).map(e=>vl(t,e,1,r,i))}}),e.addLayer({id:t.id,type:`fill`,source:t.id,metadata:{"mc-model-type":`circle`,"mc-group-id":t.id},filter:[`==`,[`geometry-type`],`Polygon`],paint:{"fill-color":[`get`,`fill-color`],"fill-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]}},n),e.addLayer({id:`${t.id}-pattern`,type:`fill`,source:t.id,filter:[`has`,`fill-pattern`],paint:{"fill-pattern":[`get`,`fill-pattern`],"fill-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]},metadata:{"mc-model-type":`circle`,"mc-group-id":t.id}},n),e.addLayer({id:`${t.id}-radius-line`,type:`line`,source:t.id,metadata:{"mc-model-type":`circle`,"mc-group-id":t.id},filter:[`all`,[`==`,[`geometry-type`],`LineString`],[`get`,`radius-line-enabled`]],paint:{"line-color":[`get`,`radius-line-color`],"line-width":[`get`,`radius-line-width`],"line-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]}},n),e.addLayer({id:`${t.id}-outline`,type:`line`,source:t.id,metadata:{"mc-model-type":`circle`,"mc-group-id":t.id},filter:[`==`,[`geometry-type`],`Polygon`],layout:{"line-cap":`round`,"line-join":`round`},paint:{"line-width":[`get`,`outline-width`],"line-color":[`get`,`outline-color`],"line-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]}},n)}function vl(e,t,n,r,i){let a=t.fillPattern===void 0?void 0:i.getMapLibreImageKey(r[t.fillPattern],2*window.devicePixelRatio);return{type:`Feature`,id:C(t.id),properties:{id:t.id,"fill-color":e.fillColor||t.fillColor?Wr(t.dataBindings??{},t.fillColor,e.fillColor):`#000000`,"outline-color":e.outlineColor||t.outlineColor?Wr(t.dataBindings??{},t.outlineColor,e.outlineColor):`#000000`,"outline-width":t.outlineWidth??0,"fill-pattern":a,"radius-line-enabled":t.radiusLineEnabled??!1,"radius-line-color":e.radiusLineColor||t.radiusLineColor?Wr(t.dataBindings??{},t.radiusLineColor,e.radiusLineColor):`#000000`,"radius-line-width":t.radiusLineWidth??0},geometry:{type:`GeometryCollection`,geometries:[{type:`Polygon`,coordinates:[tr(t.center,t.radius*n)]},{type:`LineString`,coordinates:nr(t.center,t.radius*n,t.radiusLineBearing??0)}]}}}var yl=`Roboto-Regular`;function bl(e,t,n,r,i){let a=[],o=new Set,s=new Set,c=[`match`,[`get`,`text-font`]],l=!!t.clustering;for(let e of t.models)(e.visible??!0)&&a.push(Sl(t,e,1,r,i)),o.add(e.textFont),s.add(e.textLineHeight??1.2);if(Array.from(o).length>0){for(let e of Array.from(o))c.push(e,[`literal`,[e,yl]]);c.push([`literal`,[yl]])}e.addSource(t.id,{type:`geojson`,data:{type:`FeatureCollection`,features:a},cluster:l,clusterRadius:t.clusterRadius??50,clusterMaxZoom:t.clusterMaxZoom??14}),s.forEach(r=>{e.addLayer({id:`${t.id}-${r}`,type:`symbol`,source:t.id,metadata:{"mc-model-type":`marker`,"mc-group-id":t.id},layout:{"icon-allow-overlap":!t.collisionDetection,"icon-ignore-placement":!t.collisionDetection,"text-allow-overlap":!t.collisionDetection,"text-ignore-placement":!t.collisionDetection,"icon-image":[`get`,`mc-image-key`],"icon-anchor":[`get`,`icon-anchor`],"icon-size":[`get`,`icon-size`],"icon-rotate":[`get`,`icon-rotate`],"icon-offset":[`get`,`icon-offset`],"text-field":`{text}`,"text-font":c,"text-max-width":[`get`,`text-max-width`],"text-offset":[`get`,`text-offset`],"text-rotate":[`get`,`text-rotate`],"text-size":[`get`,`text-size`],"text-anchor":[`get`,`text-anchor`],"text-letter-spacing":[`get`,`text-letter-spacing`],"text-line-height":r,"text-justify":[`get`,`text-justify`]},paint:{"icon-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1],"text-color":[`get`,`text-color`],"text-halo-color":[`get`,`text-halo-color`],"text-halo-width":[`get`,`text-halo-width`],"text-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]},filter:[`all`,[`==`,[`get`,`text-line-height`],r],[`!`,[`has`,`point_count`]]]},n)}),l&&(e.addLayer({id:`${t.id}-circle-cluster`,type:`circle`,source:t.id,filter:[`has`,`point_count`],paint:{"circle-color":{property:`point_count`,type:`interval`,stops:t.clusterCircleColor??[]},"circle-radius":{property:`point_count`,type:`interval`,stops:t.clusterCircleRadius??[]}}}),e.addLayer({id:`${t.id}-text-cluster`,type:`symbol`,source:t.id,filter:[`has`,`point_count`],paint:{"text-color":{property:`point_count`,type:`interval`,stops:t.clusterTextColor??[]}},layout:{"text-font":[`literal`,[yl]],"text-field":`{point_count_abbreviated}`,"text-size":{property:`point_count`,type:`interval`,stops:t.clusterTextSize??[]}}}),xl(e,t))}function xl(e,t){e.on(`click`,`${t.id}-circle-cluster`,async t=>{let n=e.queryRenderedFeatures(t.point).find(e=>e.properties.cluster);if(!n)return;let r=e.getSource(n.source);if(!r)return;let i=await r.getClusterExpansionZoom(Number(n.id));e.easeTo({center:n.geometry.coordinates,zoom:i})})}function Sl(e,t,n,r,i){let a=t.svg===void 0?void 0:i.getMapLibreImageKey(Kr(t.dataBindings??{},r[t.svg],e.svg?r[e.svg]:void 0),window.devicePixelRatio*(t.iconScale??1));return{type:`Feature`,id:C(t.id),properties:{id:t.id,"mc-image-key":a,"icon-anchor":t.iconAnchor??`center`,"icon-rotate":t.iconRotation??0,"icon-offset":t.iconOffset??[0,0],"icon-size":(t.iconScale??1)*n,text:e.text||t.text?Gr(t.dataBindings??{},t.text,e.text):void 0,"text-anchor":t.textAnchor??`center`,"text-font":t.textFont,"text-offset":[(t.textOffset?.[0]??0)/(t.textSize??16),(t.textOffset?.[1]??0)/(t.textSize??16)],"text-rotate":t.textRotation??0,"text-max-width":t.textMaxWidth??10,"text-size":(t.textSize??16)*n,"text-color":e.textColor||t.textColor?Wr(t.dataBindings??{},t.textColor,e.textColor):`#000000`,"text-halo-color":e.textHaloColor||t.textHaloColor?Wr(t.dataBindings??{},t.textHaloColor,e.textHaloColor):`#000000`,"text-halo-width":t.textHaloWidth??0,"text-line-height":t.textLineHeight??1.2,"text-letter-spacing":t.textLetterSpacing??0,"text-justify":t.textJustify??`center`},geometry:{type:`Point`,coordinates:[t.lngLat.lng,t.lngLat.lat]}}}async function Cl(e,t,n,r,i){let a=e.map(e=>`${n}/styles/${e}.json?access_token=${r}`).map(e=>fetch(e).then(e=>e.json())),o=await Promise.all(a);return await Promise.all(o.map(e=>wl(e,t,r,i))),o}async function wl(e,t,n,r){for(let n in e.sources)t.getSource(n)===void 0&&t.addSource(n,e.sources[n]);e.sprite!==void 0&&await El(t,e.sprite,n);for(let n of e.layers){t.getLayer(n.id)!==void 0&&t.removeLayer(n.id);let e=n.metadata?.[`mc-add-before`]??`mc-before-none`;t.addLayer(Tl(n,r),e)}}function Tl(e,t){let n=(t??{})[e.id]??{},r={...e,layout:{...e.layout,...n.layout},paint:{...e.paint,...n.paint},metadata:{...e.metadata,...n.metadata}};return n.minzoom!==void 0&&(r.minzoom=n.minzoom),n.maxzoom!==void 0&&(r.maxzoom=n.maxzoom),`filter`in n&&r.type!==`background`&&(r.filter=n.filter),r}async function El(e,t,n){try{let r=`${t}.json?access_token=${n}`,i=`${t}.png?access_token=${n}`,[a,o]=await Promise.all([fetch(r),fetch(i)]);if(!a.ok||!o.ok)throw Error(`Failed to load sprite from ${t}`);let s=await a.json(),c=await o.blob(),l=await new Promise((e,t)=>{let n=new Image;n.onload=()=>e(n),n.onerror=e=>t(e),n.src=URL.createObjectURL(c)}),u=document.createElement(`canvas`),d=u.getContext(`2d`,{willReadFrequently:!0});if(!d)throw Error(`Failed to get canvas context`);for(let[t,n]of Object.entries(s)){if(e.hasImage(t))continue;let{x:r,y:i,width:a,height:o,pixelRatio:s}=n;u.width=a*s,u.height=o*s,d.clearRect(0,0,u.width,u.height),d.drawImage(l,r,i,a,o,0,0,u.width,u.height);let c=d.getImageData(0,0,u.width,u.height);e.addImage(t,c,{pixelRatio:s})}}catch(e){console.error(e)}}var Dl=`<svg xmlns="http://www.w3.org/2000/svg" width="6" height="10" viewBox="0 0 6 10" fill="currentColor"><path d="m0 4.647 4.282 4.4a.814.814 0 0 0 1.166-1.134L2.27 4.647l3.178-3.266A.814.814 0 1 0 4.282.246z"/></svg>
|
|
1121
|
+
`}function ol(e,t,n){let r=document.createElement(`div`);r.className=`adornment`;let i=`ArialMT`,a=[e.titleFont??i,e.subtitleFont??i];return Dr(Array.from(new Set(a)),t,n).then(()=>r.innerHTML=sl(e,i)),r}function sl(e,t){let{title:n,titleColor:r=`#000000`,titleFont:i=t,titleFontSize:a=20,titleJustify:o=`center`,subtitle:s,subtitleColor:c=`#000000`,subtitleFont:l=t,subtitleFontSize:u=12,subtitleJustify:d=`center`,background:f=`#ffffff`,showBackground:p=!1}=e,m=0,h=0,g=0,_=0,v=0,y=n.trim().length>0?Ur([n],i,a):null,b=s.trim().length>0?Ur([s],l,u):null;if(m=Math.max(y?.width??0,b?.width??0),y){let{ascent:e,descent:t}=y;h=e+t,_=8+e}if(b){let{ascent:e,descent:t}=b;g=e+t,v=y?_+y.descent+e+6:8+e}let x=m+16,S=h+g+16,C=o===`center`?x/2:o===`right`?x-8:8,w=d===`center`?x/2:d===`right`?x-8:8,T=``;if(T+=`<svg xmlns="http://www.w3.org/2000/svg" width="${x}" height="${S}" viewBox="0 0 ${x} ${S}">`,T+=`<rect x="0" y="0" width="${x}" height="${S}" fill="${f}" rx="6" style="visibility:${p?`visible`:`hidden`}" />`,y||b){let e=o===`center`?`middle`:o===`right`?`end`:`start`,t=d===`center`?`middle`:d===`right`?`end`:`start`;T+=`<text x="${C}" y="${_}" fill="${r}" font-family="${i}" font-size="${a}" text-anchor="${e}">`,y&&(T+=`${Er(n)}`),b&&(T+=`<tspan x="${w}" y="${v}" fill="${c}" font-family="${l}" font-size="${u}" text-anchor="${t}">`,T+=`${Er(s)}`,T+=`</tspan>`),T+=`</text>`}return T+=`</svg>`,T}var cl=[`top_left`,`top_right`,`bottom_left`,`bottom_right`,`top_center`,`left_center`,`right_center`,`bottom_center`],ll=new Map;function ul(e,t,n,r,i,a,o,s,c){let{adornments:l=[]}=e;dl(n,t,s,c),l.forEach(t=>{t.type===`custom`?pl(te(t),t.position,t.stacking):t.type===`scalebar`?pl(il(t,n),t.position,t.stacking):t.type===`northArrow`?pl(di(t,n),t.position,t.stacking):t.type===`webControls`&&t.buttons?pl(Ui(t,n,r),t.position,t.stacking):t.type===`insetMap`?pl(Jc(t,n,a),t.position,t.stacking):t.type===`heading`?pl(ol(t,i,o),t.position,t.stacking):t.type===`manualLegend`?pl(ui(t,i,o),t.position,t.stacking):t.type===`connectedLegend`?pl(ni(t,e,n,i,o),t.position,t.stacking):t.type===`copyright`&&c===`video`&&pl(Gi(t,n),t.position,t.stacking)}),ml(n),n.on(`moveend`,()=>ml(n))}function dl(e,t,n,r){let i=e.getContainer();for(let e of cl){let a=document.createElement(`div`);a.classList.add(`adornment-container`,e),a.style.cssText=fl(e,t[e],n,r);let o=document.createElement(`div`),s=document.createElement(`div`);o.classList.add(`inner`),s.classList.add(`inner`,`vertical`),a.append(o,s),i.appendChild(a),ll.set(e,{horizontal:o,vertical:s})}}function fl(e,t,n,r){let i=v[e],a=``,o=[],s=t.x*n,c=t.y*n;o.push(`scale(${n})`);let{unit:l}=t;return i.x===`center`?o.push(`translateX(${s}${l})`):a+=`${i.x}: ${s}${l};`,i.y===`center`?o.push(`translateY(${c}${l})`):e===`bottom_right`&&r!==`video`?a+=`${i.y}: max(${c}${l}, 25px);`:a+=`${i.y}: ${c}${l};`,o.length&&(a+=`transform: ${o.join(` `)};`),a}function pl(e,t,n){n||=[`left_center`,`right_center`].includes(t)?`vertical`:`horizontal`;let r=ll.get(t),i=t===`left_center`||t===`right_center`?`vertical`:`horizontal`;r?.[i].hasChildNodes()||(n=i),(r?.[n])?.appendChild(e)}function ml(e){let t=Array.from(document.querySelectorAll(`.adornment, .maplibregl-ctrl-attrib`)),n=[];t.forEach(e=>{let t=e.getBoundingClientRect();t&&n.push([t.x,t.y,t.x+t.width,t.y+t.height])}),e.setLabelFreeAreas(n)}function hl(e,t,n,r,i){e.addSource(t.id,{type:`geojson`,data:{type:`FeatureCollection`,features:t.models.filter(e=>e.visible??!0).map(e=>gl(t,e,r,i))}}),e.addLayer({id:t.id,type:`fill`,source:t.id,metadata:{"mc-model-type":`polygon`,"mc-group-id":t.id},paint:{"fill-color":[`get`,`fill-color`],"fill-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]}},n),e.addLayer({id:`${t.id}-pattern`,type:`fill`,source:t.id,filter:[`has`,`fill-pattern`],paint:{"fill-pattern":[`get`,`fill-pattern`],"fill-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]},metadata:{"mc-model-type":`polygon`,"mc-group-id":t.id}},n),e.addLayer({id:`${t.id}-outline`,type:`line`,source:t.id,metadata:{"mc-model-type":`polygon`,"mc-group-id":t.id},layout:{"line-cap":`round`,"line-join":`round`},paint:{"line-width":[`get`,`outline-width`],"line-color":[`get`,`outline-color`],"line-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]}},n)}function gl(e,t,n,r){let i=t.fillPattern===void 0?void 0:r.getMapLibreImageKey(n[t.fillPattern],2*window.devicePixelRatio);return{type:`Feature`,id:C(t.id),properties:{id:t.id,"fill-color":e.fillColor||t.fillColor?Wr(t.dataBindings??{},t.fillColor,e.fillColor):`#000000`,"outline-color":e.outlineColor||t.outlineColor?Wr(t.dataBindings??{},t.outlineColor,e.outlineColor):`#000000`,"outline-width":t.outlineWidth??0,"fill-pattern":i},geometry:{type:`Polygon`,coordinates:or(t)}}}function _l(e,t,n,r,i){e.addSource(t.id,{type:`geojson`,data:{type:`FeatureCollection`,features:t.models.filter(e=>e.visible??!0).map(e=>vl(t,e,1,r,i))}}),e.addLayer({id:t.id,type:`fill`,source:t.id,metadata:{"mc-model-type":`circle`,"mc-group-id":t.id},filter:[`==`,[`geometry-type`],`Polygon`],paint:{"fill-color":[`get`,`fill-color`],"fill-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]}},n),e.addLayer({id:`${t.id}-pattern`,type:`fill`,source:t.id,filter:[`has`,`fill-pattern`],paint:{"fill-pattern":[`get`,`fill-pattern`],"fill-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]},metadata:{"mc-model-type":`circle`,"mc-group-id":t.id}},n),e.addLayer({id:`${t.id}-radius-line`,type:`line`,source:t.id,metadata:{"mc-model-type":`circle`,"mc-group-id":t.id},filter:[`all`,[`==`,[`geometry-type`],`LineString`],[`get`,`radius-line-enabled`]],paint:{"line-color":[`get`,`radius-line-color`],"line-width":[`get`,`radius-line-width`],"line-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]}},n),e.addLayer({id:`${t.id}-outline`,type:`line`,source:t.id,metadata:{"mc-model-type":`circle`,"mc-group-id":t.id},filter:[`==`,[`geometry-type`],`Polygon`],layout:{"line-cap":`round`,"line-join":`round`},paint:{"line-width":[`get`,`outline-width`],"line-color":[`get`,`outline-color`],"line-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]}},n)}function vl(e,t,n,r,i){let a=t.fillPattern===void 0?void 0:i.getMapLibreImageKey(r[t.fillPattern],2*window.devicePixelRatio);return{type:`Feature`,id:C(t.id),properties:{id:t.id,"fill-color":e.fillColor||t.fillColor?Wr(t.dataBindings??{},t.fillColor,e.fillColor):`#000000`,"outline-color":e.outlineColor||t.outlineColor?Wr(t.dataBindings??{},t.outlineColor,e.outlineColor):`#000000`,"outline-width":t.outlineWidth??0,"fill-pattern":a,"radius-line-enabled":t.radiusLineEnabled??!1,"radius-line-color":e.radiusLineColor||t.radiusLineColor?Wr(t.dataBindings??{},t.radiusLineColor,e.radiusLineColor):`#000000`,"radius-line-width":t.radiusLineWidth??0},geometry:{type:`GeometryCollection`,geometries:[{type:`Polygon`,coordinates:[tr(t.center,t.radius*n)]},{type:`LineString`,coordinates:nr(t.center,t.radius*n,t.radiusLineBearing??0)}]}}}var yl=`Roboto-Regular`;function bl(e,t,n,r,i){let a=[],o=new Set,s=new Set,c=[`match`,[`get`,`text-font`]],l=!!t.clustering;for(let e of t.models)(e.visible??!0)&&a.push(Sl(t,e,1,r,i)),o.add(e.textFont),s.add(e.textLineHeight??1.2);if(Array.from(o).length>0){for(let e of Array.from(o))c.push(e,[`literal`,[e,yl]]);c.push([`literal`,[yl]])}e.addSource(t.id,{type:`geojson`,data:{type:`FeatureCollection`,features:a},cluster:l,clusterRadius:t.clusterRadius??50,clusterMaxZoom:t.clusterMaxZoom??14}),s.forEach(r=>{e.addLayer({id:`${t.id}-${r}`,type:`symbol`,source:t.id,metadata:{"mc-model-type":`marker`,"mc-group-id":t.id},layout:{"icon-allow-overlap":!t.collisionDetection,"icon-ignore-placement":!t.collisionDetection,"text-allow-overlap":!t.collisionDetection,"text-ignore-placement":!t.collisionDetection,"icon-image":[`get`,`mc-image-key`],"icon-anchor":[`get`,`icon-anchor`],"icon-size":[`get`,`icon-size`],"icon-rotate":[`get`,`icon-rotate`],"icon-offset":[`get`,`icon-offset`],"text-field":`{text}`,"text-font":c,"text-max-width":[`get`,`text-max-width`],"text-offset":[`get`,`text-offset`],"text-rotate":[`get`,`text-rotate`],"text-size":[`get`,`text-size`],"text-anchor":[`get`,`text-anchor`],"text-letter-spacing":[`get`,`text-letter-spacing`],"text-line-height":r,"text-justify":[`get`,`text-justify`]},paint:{"icon-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1],"text-color":[`get`,`text-color`],"text-halo-color":[`get`,`text-halo-color`],"text-halo-width":[`get`,`text-halo-width`],"text-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]},filter:[`all`,[`==`,[`get`,`text-line-height`],r],[`!`,[`has`,`point_count`]]]},n)}),l&&(e.addLayer({id:`${t.id}-circle-cluster`,type:`circle`,source:t.id,filter:[`has`,`point_count`],paint:{"circle-color":{property:`point_count`,type:`interval`,stops:t.clusterCircleColor??[]},"circle-radius":{property:`point_count`,type:`interval`,stops:t.clusterCircleRadius??[]}}}),e.addLayer({id:`${t.id}-text-cluster`,type:`symbol`,source:t.id,filter:[`has`,`point_count`],paint:{"text-color":{property:`point_count`,type:`interval`,stops:t.clusterTextColor??[]}},layout:{"text-font":[`literal`,[yl]],"text-field":`{point_count_abbreviated}`,"text-size":{property:`point_count`,type:`interval`,stops:t.clusterTextSize??[]}}}),xl(e,t))}function xl(e,t){e.on(`click`,`${t.id}-circle-cluster`,async t=>{let n=e.queryRenderedFeatures(t.point).find(e=>e.properties.cluster);if(!n)return;let r=e.getSource(n.source);if(!r)return;let i=await r.getClusterExpansionZoom(Number(n.id));e.easeTo({center:n.geometry.coordinates,zoom:i})})}function Sl(e,t,n,r,i){let a=t.svg===void 0?void 0:i.getMapLibreImageKey(Kr(t.dataBindings??{},r[t.svg],e.svg?r[e.svg]:void 0),window.devicePixelRatio*(t.iconScale??1));return{type:`Feature`,id:C(t.id),properties:{id:t.id,"mc-image-key":a,"icon-anchor":t.iconAnchor??`center`,"icon-rotate":t.iconRotation??0,"icon-offset":t.iconOffset??[0,0],"icon-size":(t.iconScale??1)*n,text:e.text||t.text?Gr(t.dataBindings??{},t.text,e.text):void 0,"text-anchor":t.textAnchor??`center`,"text-font":t.textFont,"text-offset":[(t.textOffset?.[0]??0)/(t.textSize??16),(t.textOffset?.[1]??0)/(t.textSize??16)],"text-rotate":t.textRotation??0,"text-max-width":t.textMaxWidth??10,"text-size":(t.textSize??16)*n,"text-color":e.textColor||t.textColor?Wr(t.dataBindings??{},t.textColor,e.textColor):`#000000`,"text-halo-color":e.textHaloColor||t.textHaloColor?Wr(t.dataBindings??{},t.textHaloColor,e.textHaloColor):`#000000`,"text-halo-width":t.textHaloWidth??0,"text-line-height":t.textLineHeight??1.2,"text-letter-spacing":t.textLetterSpacing??0,"text-justify":t.textJustify??`center`},geometry:{type:`Point`,coordinates:[t.lngLat.lng,t.lngLat.lat]}}}async function Cl(e,t,n,r,i,a){let o=await Promise.all(t.map(e=>`${r}/styles/${e}.json?access_token=${i}`).map(e=>fetch(e).then(e=>e.json())));for(let t=0;t<e.length;t++){let n=e[t],r=o[t];for(let e of r.layers)e.metadata===void 0&&(e.metadata={}),e.metadata[`mc-original-layer-id`]=e.id,e.id=`${n} | ${e.id}`}return await Promise.all(o.map(e=>wl(e,n,i,a))),o}async function wl(e,t,n,r){for(let n in e.sources)t.getSource(n)===void 0&&t.addSource(n,e.sources[n]);e.sprite!==void 0&&await El(t,e.sprite,n);for(let n of e.layers){t.getLayer(n.id)!==void 0&&t.removeLayer(n.id);let e=n.metadata?.[`mc-add-before`]??`mc-before-none`;t.addLayer(Tl(n,r),e)}}function Tl(e,t){let n=t??{},r=e.metadata?.[`mc-original-layer-id`],i=r===void 0?{}:n[r]??{},a={...e,layout:{...e.layout,...i.layout},paint:{...e.paint,...i.paint},metadata:{...e.metadata,...i.metadata}};return i.minzoom!==void 0&&(a.minzoom=i.minzoom),i.maxzoom!==void 0&&(a.maxzoom=i.maxzoom),`filter`in i&&a.type!==`background`&&(a.filter=i.filter),a}async function El(e,t,n){try{let r=`${t}.json?access_token=${n}`,i=`${t}.png?access_token=${n}`,[a,o]=await Promise.all([fetch(r),fetch(i)]);if(!a.ok||!o.ok)throw Error(`Failed to load sprite from ${t}`);let s=await a.json(),c=await o.blob(),l=await new Promise((e,t)=>{let n=new Image;n.onload=()=>e(n),n.onerror=e=>t(e),n.src=URL.createObjectURL(c)}),u=document.createElement(`canvas`),d=u.getContext(`2d`,{willReadFrequently:!0});if(!d)throw Error(`Failed to get canvas context`);for(let[t,n]of Object.entries(s)){if(e.hasImage(t))continue;let{x:r,y:i,width:a,height:o,pixelRatio:s}=n;u.width=a*s,u.height=o*s,d.clearRect(0,0,u.width,u.height),d.drawImage(l,r,i,a,o,0,0,u.width,u.height);let c=d.getImageData(0,0,u.width,u.height);e.addImage(t,c,{pixelRatio:s})}}catch(e){console.error(e)}}var Dl=`<svg xmlns="http://www.w3.org/2000/svg" width="6" height="10" viewBox="0 0 6 10" fill="currentColor"><path d="m0 4.647 4.282 4.4a.814.814 0 0 0 1.166-1.134L2.27 4.647l3.178-3.266A.814.814 0 1 0 4.282.246z"/></svg>
|
|
1122
1122
|
`,Ol=`<svg xmlns="http://www.w3.org/2000/svg" width="10" height="11" viewBox="0 0 10 11" fill="currentColor"><path d="M.21.71a.714.714 0 0 1 1.011 0l3.78 3.78L8.778.71a.715.715 0 0 1 1.013 1.01L6.01 5.501l3.78 3.778a.715.715 0 0 1-1.01 1.012L5 6.51l-3.779 3.78A.716.716 0 0 1 .21 9.28L3.99 5.5.21 1.721A.714.714 0 0 1 .21.71"/></svg>
|
|
1123
1123
|
`,kl=`<svg xmlns="http://www.w3.org/2000/svg" width="6" height="10" viewBox="0 0 6 10" fill="currentColor"><path d="m5.678 4.647-4.282 4.4A.814.814 0 1 1 .23 7.914l3.177-3.266L.23 1.381A.814.814 0 1 1 1.396.246z"/></svg>
|
|
1124
1124
|
`,Al=`<svg width="20" height="20" viewBox="0 0 40 40" stroke="currentColor" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M20 4.167 1.667 35.834h36.667z" stroke-width="2" stroke-linejoin="round"/><path d="M20 29.167v.834m0-14.167.007 8.333" stroke-width="2" stroke-linecap="round"/></svg>
|
|
@@ -1165,4 +1165,4 @@ vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matr
|
|
|
1165
1165
|
<div class="popup-scroll-wrapper">
|
|
1166
1166
|
<div class="mc-popup data-layer text-content">${n}</div>
|
|
1167
1167
|
</div>
|
|
1168
|
-
`}return n}htmlToElement(e){let t=document.createElement(`template`);return t.innerHTML=e.trim(),t.content.firstElementChild}addPopupControls(){let e=this.htmlToElement(Fl);if(e&&(e.addEventListener(`click`,()=>{this.hidePopup(),this.highlightManager.highlight(void 0)}),this.popupContainer.appendChild(e)),this.popupElements.length<2)return;let t=this.htmlToElement(Il);t&&(t.querySelector(`.prev`)?.addEventListener(`click`,()=>this.cyclePopups(!1)),t.querySelector(`.next`)?.addEventListener(`click`,()=>this.cyclePopups()),this.popupContainer.appendChild(t))}fillDatalayerTemplate(e,t,n){let r=`data-mention-id`,i=new DOMParser().parseFromString(t,`text/html`).body;for(let t of i.querySelectorAll(`[${r}]`)){let i=this.getProperty(e,t.getAttribute(r),n);i!==void 0&&(t.innerText=i)}return i.innerHTML}getProperty(e,t,n){if(!t)return;let r=t.endsWith(`:en`)?[t.replace(`:en`,n),t]:[t];for(let t of r){let n=e.properties[t]??this.getVectorProperty(e,t);if(n!==void 0)return n}}getVectorProperty(e,t){let n=this.promoteIdCache.get(e.source);n===void 0&&(n=this.map.getSource(e.source)?.serialize().promoteId||`id`,this.promoteIdCache.set(e.source,n));try{let r=e.properties[n];return e.layer.metadata.properties[t][r]}catch{return}}cyclePopups(e=!0){let t=this.popupElements?.findIndex(e=>e.modelId===this.currentModelId);if(t!==-1){let n=0;n=e?t===this.popupElements.length-1?0:t+1:t===0?this.popupElements.length-1:t-1;let r=this.popupElements?.[n];this.highlightManager.highlight(r);let i=Pl(r.popup,r.popupMedia,r.dataBindings??{},this.mode),a=this.popupContainer;this.popupContainer.remove(),a.innerHTML=i,this.mapContainer.appendChild(a),this.currentModelId=r.modelId,this.addPopupControls(),e?this.popupContainer.querySelector(`.mc-popup-button.next`)?.focus():this.popupContainer.querySelector(`.mc-popup-button.prev`)?.focus(),this.currentFeatureId=void 0}}},Wl=class e{static#e(e){let t=0,n=[t];for(let r=1;r<e.length;++r){let i=e[r-1],a=e[r],o=a.x-i.x,s=a.y-i.y;t+=Math.sqrt(o*o+s*s),n.push(t)}return n}static#t(e,t){return e.x===t.x&&e.y===t.y}#n;#r;#i;#a;constructor(t){this.#n=t.filter((e,n)=>n===0||t[n][0]!==t[n-1][0]||t[n][1]!==t[n-1][1]),this.#r=this.#n.map(e=>u.MercatorCoordinate.fromLngLat(e)),this.#i=e.#e(this.#r),this.#a=this.#i[this.#i.length-1]}sample(e){let t=this.#r,n=this.#i;if(t.length<2)return t[0];e*=this.#a;for(let r=1;r<t.length;++r){let i=t[r-1],a=t[r],o=n[r-1],s=n[r];if(s>=e){let t=(e-o)/(s-o);return new u.MercatorCoordinate(A(i.x,a.x,t),A(i.y,a.y,t))}}return new u.MercatorCoordinate(t[t.length-1].x,t[t.length-1].y)}slice(t,n){if(this.#n.length<2)return this.#n;let r=this.#r.filter((e,r)=>this.#i[r]>=t*this.#a&&this.#i[r]<=n*this.#a);if(t>0){let n=this.sample(t);e.#t(n,r[0])||r.unshift(n)}if(n<1){let t=this.sample(n);e.#t(t,r[r.length-1])||r.push(t)}return r.map(e=>{let{lng:t,lat:n}=e.toLngLat();return[t,n]})}get length(){return this.#a}},Gl={solid:[1,0],dotted:[.7,.3],dashed:[3.5,1.5]};function Kl(e,t,n,r){e.addSource(t.id,{type:`geojson`,data:{type:`FeatureCollection`,features:t.models.filter(e=>e.visible??!0).map(n=>ql(e,t,n,1,r))}}),Object.entries(Gl).forEach(([r,i])=>{t.models.some(e=>(e.lineStyle??`solid`)===r)&&e.addLayer({id:`${t.id}-${r}`,type:`line`,source:t.id,metadata:{"mc-model-type":`line`,"mc-group-id":t.id},filter:[`all`,[`==`,[`geometry-type`],`LineString`],[`==`,[`get`,`line-style`],r]],paint:{"line-width":[`get`,`line-width`],"line-color":[`get`,`line-color`],"line-dasharray":i,"line-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]}},n)}),e.addLayer({id:`${t.id}-clickable`,type:`line`,source:t.id,metadata:{"mc-model-type":`line`,"mc-group-id":t.id},paint:{"line-width":[`max`,[`get`,`line-width`],15],"line-opacity":0},filter:[`==`,[`geometry-type`],`LineString`]},n),t.models.some(e=>e.svg)&&e.addLayer({id:`${t.id}-icon`,type:`symbol`,source:t.id,metadata:{"mc-model-type":`line`,"mc-group-id":t.id},layout:{"icon-allow-overlap":!0,"icon-ignore-placement":!0,"icon-image":[`get`,`mc-image-key`],"icon-anchor":`center`,"icon-size":[`get`,`icon-size`],"icon-rotate":[`get`,`icon-rotate`],"icon-offset":[`get`,`icon-offset`]},paint:{"icon-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]},filter:[`==`,[`geometry-type`],`Point`]},n)}function ql(e,t,n,r,i){let a=new Wl(n.geometry).slice(0,r),o=n.svg===void 0?void 0:i.getMapLibreImageKey(Kr(n.dataBindings??{},n.svg,void 0),window.devicePixelRatio*(n.iconScale??1));return{type:`Feature`,id:C(n.id),properties:{id:n.id,"line-width":n.lineWidth??3,"line-color":t.lineColor||n.lineColor?Wr(n.dataBindings??{},n.lineColor,t.lineColor):`#000000`,"line-style":n.lineStyle??`solid`,"mc-image-key":o,"icon-rotate":Jl(n,a,e),"icon-offset":n.iconOffset,"icon-size":n.iconScale},geometry:{type:`GeometryCollection`,geometries:[{type:`LineString`,coordinates:a},{type:`Point`,coordinates:a[a.length-1]}]}}}function Jl(e,t,n){return e.iconRotation?e.iconAlign?ur(t,n)+e.iconRotation:e.iconRotation:0}function Yl(e,t,n,r,i,a,o){let s=_r(t),c=new Map,l=new Map;for(let e of t.models){let n=e.featureId,a=t.id,o=[],u=cr(e),d=sr(a,e),f=l.get(d)??{model:e,featureIds:o,modelIdToFillColor:{},modelIdToFillPattern:{},modelIdToOutlineColor:{},modelIdToOutlineWidth:{}};if(e.visible??!0){f.featureIds.push(n);let a=e.fillPattern===void 0?null:i.getMapLibreImageKey(r[e.fillPattern],2*window.devicePixelRatio);f.modelIdToFillColor[n]=t.fillColor||e.fillColor?Wr(e.dataBindings??{},e.fillColor,t.fillColor,s,t.choropleth?.unmatchedColor):`#000000`,f.modelIdToFillPattern[n]=a,f.modelIdToOutlineColor[n]=t.outlineColor||e.outlineColor?Wr(e.dataBindings??{},e.outlineColor,t.outlineColor):`#000000`,f.modelIdToOutlineWidth[n]=e.outlineWidth??.5}c.set(u,e),l.set(d,f)}for(let t of c.keys())e.getSource(t)||e.addSource(t,{type:`vector`,url:`${a}${c.get(t).vectorUrl}?access_token=${o}`});for(let r of l.keys()){let{model:i}=l.get(r),{sourceLayerId:a}=i,o=cr(i);e.addLayer({id:r,type:`fill`,source:o,"source-layer":a,filter:[`literal`,!1],metadata:{"mc-model-type":`area`,"mc-model-id-prefix":i.vectorUrl,"mc-group-id":t.id},paint:{"fill-color":`#ffffff`,"fill-outline-color":`#000000`,"fill-antialias":!1}},n),e.addLayer({id:`${r}-pattern`,type:`fill`,source:o,"source-layer":a,filter:[`literal`,!1],metadata:{"mc-model-type":`area`,"mc-model-id-prefix":i.vectorUrl,"mc-group-id":t.id},paint:{"fill-pattern":[`get`,`fill-pattern`]},layout:{visibility:`visible`}},n),e.addLayer({id:`${r}-outline`,type:`line`,source:o,"source-layer":a,filter:[`literal`,!1],metadata:{"mc-model-type":`area`,"mc-model-id-prefix":i.vectorUrl,"mc-group-id":t.id},paint:{"line-color":`#000000`,"line-width":.5}},n)}l.forEach((t,n)=>{let{featureIds:r,modelIdToFillColor:i,modelIdToFillPattern:a,modelIdToOutlineColor:o,modelIdToOutlineWidth:s}=t;e.setFilter(n,[`in`,`id`,...r]),e.setFilter(`${n}-outline`,[`in`,`id`,...r]),e.setPaintProperty(n,`fill-color`,[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,i]]),e.setPaintProperty(`${n}-outline`,`line-color`,[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,o]]),e.setPaintProperty(`${n}-outline`,`line-width`,[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,s]]),e.setFilter(`${n}-pattern`,[`to-boolean`,[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,a]]]),e.setPaintProperty(`${n}-pattern`,`fill-pattern`,[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,a]])})}function Xl(e,t,n){e.addSource(t.id,{type:`geojson`,data:{type:`FeatureCollection`,features:t.models.filter(e=>e.visible??!0).map(e=>Zl(t,e))}}),e.addLayer({id:t.id,type:`circle`,source:t.id,metadata:{"mc-model-type":`dot`,"mc-group-id":t.id},paint:{"circle-color":[`get`,`circle-color`],"circle-radius":[`get`,`circle-radius`],"circle-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]}},n)}function Zl(e,t){return{type:`Feature`,id:t.id,properties:{id:t.id,"circle-radius":t.radius,"circle-color":e.fillColor||t.fillColor?Wr(t.dataBindings??{},t.fillColor,e.fillColor):`#000000`},geometry:{type:`Point`,coordinates:[t.center.lng,t.center.lat]}}}function Ql(e,t,n,r){return t+n/r*e}function $l(e,t,n,r){return n*((e=e/r-1)*e*e+1)+t}function eu(e,t,n,r){let i=1.70158,a=0,o=n;return e===0?t:(e/=r)===1?t+n:(a||=r*.3,o<Math.abs(n)?(o=n,i=a/4):i=a/(2*Math.PI)*Math.asin(n/o),o*2**(-10*e)*Math.sin((e*r-i)*(2*Math.PI)/a)+n+t)}function tu(e,t,n,r,i){return i===void 0&&(i=1.70158),n*((e=e/r-1)*e*((i+1)*e+i)+1)+t}function nu(e,t,n,r){return(e/=r)<1/2.75?n*(7.5625*e*e)+t:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+t:n*(7.5625*(e-=2.625/2.75)*e+.984375)+t}var ru={linear:Ql,easeOutCubic:$l,easeOutBack:tu,easeOutBounce:nu,easeOutElastic:eu};function iu(e){return e.entryType===`fade`||e.exitType===`fade`||e.entryType===`instant`||e.exitType===`instant`}function au(e){return e.entryType===`grow`||e.exitType===`grow`}function ou(e,t,n){let{entry:r,entryDuration:i,exit:a,exitDuration:o}=e,{entryType:s,entryEasing:c,exitType:l,exitEasing:u}=e;return n<r&&(s===t||s===`instant`&&t===`fade`)||n>a&&(l===t||l===`instant`&&t===`fade`)?0:i>0&&n<r+i&&s===t?ru[c](n-r,0,1,i):o>0&&n>a-o&&l===t?ru[u](n-(a-o),1,-1,o):1}function su(e){let t=e.length>0?[cu(e[0])]:[],n=0,r=0;for(let i=1;i<e.length;++i){let a=cu(e[i]);n+=lu(e[i-1].center[0],a.center[0]),r+=lu(e[i-1].bearing,a.bearing),a.center[0]+=n*360,a.x+=n,a.bearing+=r*360,t.push(a)}return t}function cu(e){return{...e,center:[e.center[0],e.center[1]]}}function lu(e,t){if(Math.abs(e)+Math.abs(t)>180){if(e>0&&t<0)return 1;if(e<0&&t>0)return-1}return 0}function uu(e){return 2**-e}function du(e){return e.length>0?e[e.length-1].time:0}function fu(e){return P(e,23.976)?24e3/1001:P(e,29.97)?3e4/1001:P(e,59.94)?6e4/1001:e}function pu(e){return e<0?-1:1}function mu(e,t,n){var r=e._x1-e._x0,i=t-e._x1,a=(e._y1-e._y0)/(r||i<0&&-0),o=(n-e._y1)/(i||r<0&&-0),s=(a*i+o*r)/(r+i);return(pu(a)+pu(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(s))||0}function hu(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function gu(e,t,n){var r=e._x0,i=e._y0,a=e._x1,o=e._y1,s=(a-r)/3;e._context.bezierCurveTo(r+s,i+s*t,a-s,o-s*n,a,o)}function _u(e){this._context=e}_u.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:gu(this,this._t0,hu(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,gu(this,hu(this,n=mu(this,e,t)),n);break;default:gu(this,this._t0,n=mu(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function vu(e){this._context=new yu(e)}(vu.prototype=Object.create(_u.prototype)).point=function(e,t){_u.prototype.point.call(this,t,e)};function yu(e){this._context=e}yu.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,a){this._context.bezierCurveTo(t,e,r,n,a,i)}};function bu(e){return new _u(e)}function xu(e){return e}var{cbrt:Su,sqrt:Cu,PI:wu}=Math,Tu=(e,t,n,r,i)=>{let a=t+n*e,o=a**2+r;if(o>0){let e=Cu(o);return Su(a+e)+Su(a-e)-i}let s=Su(Cu(a*a-o)),c=a?Math.atan(Cu(-o)/a):-wu/2,l;return l=n<0?(a>0?2*wu:wu)-c:i<0?(a>0?2*wu:-3*wu)+c:(a>0?0:wu)+c,2*s*Math.cos(l/3)-i},Eu=(e,t,n,r)=>((t*e+3*n)*e+r)*e;function Du(e,t,n,r){if(!(0<=e&&e<=1&&0<=n&&n<=1))throw Error(`bezier x values must be in [0, 1] range`);if(e===t&&n===r)return xu;let i=6*(3*e-3*n+1),a=6*(n-2*e),o=3*e,s=i*i,c=a*a,l=a/i,u=3*a*o/s-c*a/(s*i),d=2*o/i-c/s,f=d*d*d,p=3/i,m=3*t-3*r+1,h=r-2*t,g=3*t,_=i?Tu:xu;return function(e){return e===0||e===1?e:Eu(_(e,u,p,f,l),m,h,g)}}var Ou=l(s(((e,t)=>{t.exports=n;function n(e,t,n,r){var i,a,o,s,c,l,u,d,f,p,m,h,g,_;for(typeof t!=`function`&&(r=n,n=t,t=null),r||={},s=r.tolerance===void 0?1e-7:r.tolerance,_=r.epsilon===void 0?2220446049250313e-31:r.epsilon,c=r.maxIterations===void 0?20:r.maxIterations,m=r.h===void 0?1e-4:r.h,g=r.verbose===void 0?!1:r.verbose,h=1/m,l=0;l++<c;){if(a=e(n),t?o=t(n):(u=e(n+m),d=e(n-m),f=e(n+2*m),p=e(n-2*m),o=(p-f+8*(u-d))*h/12),Math.abs(o)<=_*Math.abs(a))return g&&console.log(`Newton-Raphson: failed to converged due to nearly zero first derivative`),!1;if(i=n-a/o,Math.abs(i-n)<=s*Math.abs(i))return g&&console.log(`Newton-Raphson: converged to x = `+i+` after `+l+` iterations`),i;n=i}return g&&console.log(`Newton-Raphson: Maximum iterations reached (`+c+`)`),!1}}))(),1),ku=class{segments;constructor(e){this.segments=[];let t=new Au,n=bu(t);n.lineStart();for(let t of e)n.point(t.x,t.y);n.lineEnd(),this.segments=t.segments}sample(e){if(e<=0)return this.segments[0].startY;if(e>=this.segments[this.segments.length-1].endX)return this.segments[this.segments.length-1].endY;let t=this.segments.find(t=>e>=t.startX&&e<t.endX),n=j(t.startX,t.endX,e);return t.startY!==t.endY&&t.easing!==void 0?A(t.startY,t.endY,t.easing(n)):A(t.startY,t.endY,n)}solve(e,t){let n=(0,Ou.default)(t=>this.sample(t)-e,t);return n===!1?t:n}},Au=class{previousPoint={x:0,y:0};segments=[];bezierCurveTo(e,t,n,r,i,a){let o=this.previousPoint.x,s=this.previousPoint.y,c=i===o?void 0:Du((e-o)/(i-o),(t-s)/(a-s),(n-o)/(i-o),(r-s)/(a-s));this.segments.push({startX:o,endX:i,startY:s,endY:a,easing:c}),this.previousPoint={x:i,y:a}}lineTo(e,t){this.segments.push({startX:this.previousPoint.x,endX:e,startY:this.previousPoint.y,endY:t,easing:void 0}),this.previousPoint={x:e,y:t}}moveTo(e,t){this.previousPoint={x:e,y:t}}closePath(){}arc(){}rect(){}arcTo(){}quadraticCurveTo(){}},ju=class{script;xCurve;yCurve;fovCurve;zoomCurve;pitchCurve;bearingCurve;altitudeCurve;elevationCurve;constructor(e){this.script=su(e),this.xCurve=this.createMonotonicCurve(this.script,`x`),this.yCurve=this.createMonotonicCurve(this.script,`y`),this.fovCurve=this.createMonotonicCurve(this.script,`fov`),this.zoomCurve=this.createMonotonicCurve(this.script,`zoom`),this.pitchCurve=this.createMonotonicCurve(this.script,`pitch`),this.bearingCurve=this.createMonotonicCurve(this.script,`bearing`),this.altitudeCurve=this.createMonotonicCurve(this.script,`altitude`),this.elevationCurve=this.createMonotonicCurve(this.script,`elevation`)}sample(e){let t=this.zoomCurve.sample(e),n=this.altitudeCurve.solve(uu(t),e),r=this.xCurve.sample(n),i=this.yCurve.sample(n),a=this.elevationCurve.sample(n),o=this.bearingCurve.sample(e),s=this.pitchCurve.sample(e),c=this.fovCurve.sample(e);return{center:new u.MercatorCoordinate(r,i).toLngLat(),zoom:t,bearing:o,pitch:s,fov:c,elevation:a}}createMonotonicCurve(e,t){let n=[];for(let r=0;r<e.length;r++){let i=r===0,a=r===e.length-1,o=e[r],s=e[r+1],c=e[r-1],l=this.getKeyframeValue(o,t);if(i&&n.push({x:-1,y:l}),n.push({x:o.time,y:l}),!i&&!a&&c.transition===`instant`&&o.transition===`ease`&&n.push({x:o.time+.1,y:l}),!a)if(o.transition===`linear`){let e=o.time+.1,r=s.time-.1,i=j(o.time,s.time,e),a=j(o.time,s.time,r),c=this.getKeyframeValue(s,t);n.push({x:e,y:A(l,c,i)}),n.push({x:r,y:A(l,c,a)})}else o.transition===`instant`&&(n.push({x:o.time+.1,y:l}),n.push({x:s.time-.1,y:l}));a&&n.push({x:o.time+1,y:l})}return new ku(n)}sampleAutoHideOpacity(e){let t=this.script;if(t.length<2)return 1;let n=this.getKeyframeIndexByTime(e);if(n===-1||n===t.length-1)return 1;let r=t[n],i=t[n+1],a=n>0?t[n-1]:void 0,o;if(r.hideLabels===(a?.hideLabels??!1))o=r.hideLabels?0:1;else{let t=e-r.time,n=Math.min(400,i.time-r.time);o=ee($l(t,r.hideLabels?1:0,r.hideLabels?-1:1,n),0,1)}let s;if(n===t.length-2&&r.hideLabels){let t=Math.max(r.time,i.time-400);s=ee($l(e-t,0,1,i.time-t),0,1)}else s=0;return Math.max(o,s)}getKeyframeIndexByTime(e){let t=this.script;if(t.length!==0){for(let n=0;n<t.length;n++)if(e<t[n].time)return n-1;return t.length-1}}getKeyframeValue(e,t){return t===`altitude`?uu(e.zoom):e[t]}},Mu=Nu;function Nu(e,t,n){var r=null,i=null,a=function(){r&&=(clearTimeout(r),i=null,null)},o=function(){var e=i;a(),e&&e()},s=function(){if(!t)return e.apply(this,arguments);var o=this,s=arguments,c=n&&!r;if(a(),i=function(){e.apply(o,s)},r=setTimeout(function(){if(r=null,!c){var e=i;return i=null,e()}},t),c)return i()};return s.cancel=a,s.flush=o,s}var Pu=class{mcMap;cameraCurve;jobObject;svgs;svgCache;duration;mapstyle;overlays;layerInfo;playhead;playbackContext;constructor(e,t,n,r,i,a){this.mcMap=e,this.playhead=0,this.playbackContext=void 0;let o=(t.video?.keyframes??[]).map(e=>{let{x:t,y:n}=u.MercatorCoordinate.fromLngLat(e.center);return{...e,x:t,y:n,fov:e.fov??36.87,elevation:e.elevation??0}});this.duration=du(o),this.cameraCurve=new ju(o),this.jobObject=t,this.svgs=n,this.svgCache=r,this.mapstyle=i,this.overlays=a,this.layerInfo=t.map.layerInfo?.reduce((e,t)=>(e[t.id]={visibility:t.visibility},e),{})??{}}play(){this.playbackContext===void 0&&this.duration>0&&(this.playhead>=this.duration&&(this.playhead=0),this.playbackContext={startTime:Date.now(),startPlayhead:this.playhead},this.mcMap.fire(`playstart`,{time:this.playhead}),this.playFrame())}pause(){this.playbackContext!==void 0&&(this.playbackContext=void 0,this.mcMap.fire(`playend`,{time:this.playhead}))}seekTo(e){this.duration>0&&(e=ee(e,0,this.duration),this.prepareForPlayback(),this.setCamera(e),this.playbackContext!==void 0&&(this.playbackContext={startTime:Date.now(),startPlayhead:e}))}async*frames(){let e=this.mcMap.map,t=fu(this.jobObject.export?.frameRate??60),n=Math.ceil(this.duration*t/1e3);e._fadeDuration=0,e.style.stylesheet.transition={duration:0,delay:0},e.setCenterClampedToGround(!1);let r=e.getCanvas(),{width:i,height:a}=r,o=new OffscreenCanvas(i,a).getContext(`2d`,{desynchronized:!0,willReadFrequently:!0});for(let e=0;e<n;e++)yield this.captureFrame(e*1e3/t,r,o,i,a);e._fadeDuration=300,e.style.stylesheet.transition=void 0,e.setCenterClampedToGround(!0)}async captureFrame(e,t,n,r,i){return this.setCamera(e),await this.mcMap.map.once(`idle`),n.fillStyle=`#ffffff`,n.fillRect(0,0,r,i),n.drawImage(t,0,0),n.getImageData(0,0,r,i)}playFrame(){if(this.playbackContext!==void 0){let e=this.playbackContext.startPlayhead+(Date.now()-this.playbackContext.startTime);this.prepareForPlayback(),e>this.duration?(this.setCamera(this.duration),this.playbackContext=void 0,this.mcMap.fire(`playend`,{time:this.playhead})):(this.setCamera(e),requestAnimationFrame(()=>this.playFrame()))}}setCamera(e){this.playhead=e;let t=this.mcMap.map,n=this.cameraCurve.sample(e),r=t.getCenter(),i=t.getZoom(),a=t.getBearing(),o=t.getPitch(),s=t.getCenterElevation(),c=t.getVerticalFieldOfView();n.center.lat!==r.lat||n.center.lng!==r.lng||n.zoom!==i||n.bearing!==a||n.pitch!==o||n.elevation!==s||n.fov!==c?(t.setVerticalFieldOfView(n.fov),t.jumpTo(n)):t.triggerRepaint(),this.applyAnimations(e),this.mcMap.fire(`play`,{time:e})}applyAnimations(e){let t=this.mcMap.map,{svgs:n,svgCache:r}=this,i=this.jobObject.video?.animations??[];for(let n of i){let{target:r}=n;if(r.type===`model`&&iu(n)){let{modelType:i,groupId:a,modelId:o}=r,s=ou(n,`fade`,e);(i===`polygon`||i===`circle`||i===`line`||i===`marker`||i===`dot`)&&(o===void 0?t.setGlobalStateProperty(`opacity-${a}`,s===1?null:s):t.setFeatureState({source:a,id:C(o)},{opacity:s}))}}for(let n of this.jobObject.registry?.models?.area??[]){let{groupAnimation:r,modelAnimations:a}=this.getGroupAnimations(i,`area`,n.id,`opacity`);if(!(r===void 0&&a.size===0))if(r!==void 0&&a.size===0){let i=ou(r,`fade`,e);n.models.reduce((e,t)=>e.add(sr(n.id,t)),new Set).forEach(e=>{t.setPaintProperty(e,`fill-opacity`,i),t.setPaintProperty(`${e}-outline`,`line-opacity`,i),t.setPaintProperty(`${e}-pattern`,`fill-opacity`,i)})}else{let i=r===void 0?1:ou(r,`fade`,e),o={};for(let t of n.models){let r=t.featureId===void 0?t.id:String(t.featureId),s=sr(n.id,t),c=a.get(t.id),l=c===void 0?i:ou(c,`fade`,e);o[s]??={},o[s][r]=l}for(let[e,n]of Object.entries(o)){let r=[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,n]];t.setPaintProperty(e,`fill-opacity`,r),t.setPaintProperty(`${e}-outline`,`line-opacity`,r),t.setPaintProperty(`${e}-pattern`,`fill-opacity`,r)}}}for(let a of this.jobObject.registry?.models?.circle??[]){let{groupAnimation:o,modelAnimations:s}=this.getGroupAnimations(i,`circle`,a.id,`scale`),c=o===void 0?1:ou(o,`grow`,e);(o!==void 0||s.size>0)&&t.getSource(a.id).setData({type:`FeatureCollection`,features:a.models.filter(e=>e.visible??!0).map(t=>{let i=s.get(t.id);return vl(a,t,i===void 0?c:ou(i,`grow`,e),n,r)})})}for(let n of this.jobObject.registry?.models?.line??[]){let{groupAnimation:a,modelAnimations:o}=this.getGroupAnimations(i,`line`,n.id,`scale`),s=a===void 0?1:ou(a,`grow`,e);(a!==void 0||o.size>0)&&t.getSource(n.id).setData({type:`FeatureCollection`,features:n.models.filter(e=>e.visible??!0).map(i=>{let a=o.get(i.id);return ql(t,n,i,a===void 0?s:ou(a,`grow`,e),r)})})}for(let a of this.jobObject.registry?.models?.marker??[]){let{groupAnimation:o,modelAnimations:s}=this.getGroupAnimations(i,`marker`,a.id,`scale`),c=o===void 0?1:ou(o,`grow`,e);(o!==void 0||s.size>0)&&t.getSource(a.id).setData({type:`FeatureCollection`,features:a.models.filter(e=>e.visible??!0).map(t=>{let i=s.get(t.id);return Sl(a,t,i===void 0?c:ou(i,`grow`,e),n,r)})})}let a=this.cameraCurve.sampleAutoHideOpacity(e);for(let t of this.mapstyle.layers){let n=this.getLayerOpacity(i,t,e,void 0);n===void 0?t.type===`symbol`&&this.setLayerOpacity(t,a):this.setLayerOpacity(t,n)}for(let[t,n]of this.overlays)for(let r of n.layers){let n=this.getLayerOpacity(i,r,e,t);n===void 0?this.resetLayerOpacity(r):this.setLayerOpacity(r,n)}}prepareForPlayback(){let e=this.mcMap.map;e.setCenterClampedToGround(!1),e.style?.stylesheet&&(e.style.stylesheet.transition={duration:0,delay:0}),this.restoreAfterPlayback()}restoreAfterPlayback=Mu(()=>{let e=this.mcMap.map;e.setCenterClampedToGround(!0),e.style?.stylesheet&&(e.style.stylesheet.transition=void 0)},300);getGroupAnimations(e,t,n,r){let i,a=new Map;for(let o of e){let{target:e}=o;e.type===`model`&&e.modelType===t&&e.groupId===n&&(r===`opacity`&&iu(o)||r===`scale`&&au(o))&&(e.modelId===void 0?i=o:a.set(e.modelId,o))}return{groupAnimation:i,modelAnimations:a}}getLayerOpacity(e,t,n,r){let i,a,o=1/0;r!==void 0&&(i=e.find(e=>e.target.type===`overlay`&&e.target.id===r));for(let n of e){let{target:e}=n;e.type===`layer`&&e.ids.includes(t.id)&&e.ids.length<o&&(a=n,o=e.ids.length)}return a===void 0?i===void 0?void 0:ou(i,`fade`,n):ou(a,`fade`,n)}setLayerOpacity(e,t){let n=this.mcMap.map;e.type===`fill`?n.setPaintProperty(e.id,`fill-opacity`,t):e.type===`line`?n.setPaintProperty(e.id,`line-opacity`,t):e.type===`circle`?(n.setPaintProperty(e.id,`circle-opacity`,t),n.setPaintProperty(e.id,`circle-stroke-opacity`,t)):e.type===`heatmap`?n.setPaintProperty(e.id,`heatmap-opacity`,t):e.type===`fill-extrusion`?n.setPaintProperty(e.id,`fill-extrusion-opacity`,t):e.type===`symbol`?(n.setPaintProperty(e.id,`icon-opacity`,t),n.setPaintProperty(e.id,`text-opacity`,t)):e.type===`raster`?n.setPaintProperty(e.id,`raster-opacity`,t):e.type===`hillshade`?n.setPaintProperty(e.id,`hillshade-exaggeration`,t*.5):e.type===`color-relief`?n.setPaintProperty(e.id,`color-relief-opacity`,t):e.type===`background`&&n.setPaintProperty(e.id,`background-opacity`,t),n.setLayoutProperty(e.id,`visibility`,t===0?`none`:this.layerInfo[e.id]?.visibility?`visible`:`none`)}resetLayerOpacity(e){let t=this.mcMap.map;e.type===`fill`?t.setPaintProperty(e.id,`fill-opacity`,e.paint?.[`fill-opacity`]??1):e.type===`line`?t.setPaintProperty(e.id,`line-opacity`,e.paint?.[`line-opacity`]??1):e.type===`circle`?(t.setPaintProperty(e.id,`circle-opacity`,e.paint?.[`circle-opacity`]??1),t.setPaintProperty(e.id,`circle-stroke-opacity`,e.paint?.[`circle-stroke-opacity`]??1)):e.type===`heatmap`?t.setPaintProperty(e.id,`heatmap-opacity`,e.paint?.[`heatmap-opacity`]??1):e.type===`fill-extrusion`?t.setPaintProperty(e.id,`fill-extrusion-opacity`,e.paint?.[`fill-extrusion-opacity`]??1):e.type===`symbol`?(t.setPaintProperty(e.id,`icon-opacity`,e.paint?.[`icon-opacity`]??1),t.setPaintProperty(e.id,`text-opacity`,e.paint?.[`text-opacity`]??1)):e.type===`raster`?t.setPaintProperty(e.id,`raster-opacity`,e.paint?.[`raster-opacity`]??1):e.type===`hillshade`?t.setPaintProperty(e.id,`hillshade-exaggeration`,e.paint?.[`hillshade-exaggeration`]??.5):e.type===`color-relief`?t.setPaintProperty(e.id,`color-relief-opacity`,e.paint?.[`color-relief-opacity`]??1):e.type===`background`&&t.setPaintProperty(e.id,`background-opacity`,e.paint?.[`background-opacity`]??1),t.setLayoutProperty(e.id,`visibility`,this.layerInfo[e.id]?.visibility?`visible`:`none`)}},Fu=class extends u.Evented{map;video;constructor(e,t,n,r,i,a){super(),this.map=e,this.video=new Pu(this,t,n,r,i,a)}on(e,t){return super.on(e,t)}once(e,t){return super.once(e,t)}off(e,t){return super.off(e,t)}fire(e,t){return super.fire(e,t)}play(){this.video.play()}pause(){this.video.pause()}seekTo(e){this.video.seekTo(e)}frames(){return this.video.frames()}};async function Iu(e){let{accessToken:t,mode:n=`sdk`,env:r=`production`}=e,i=r===`bleeding`?`https://vapi.bleeding.mc-cdn.io`:r===`beta`?`https://vapi.beta.mc-cdn.io`:`https://vapi.mc-cdn.io`,a=r===`bleeding`?`https://cdn.bleeding.mapcreator.io`:r===`beta`?`https://cdn.beta.mapcreator.io`:`https://cdn.mapcreator.io`,o=typeof e.job==`string`?await Lu(e.job,a,t):e.job;await Ru();let s=new u.Map({container:e.container,attributionControl:!1,style:null,maxBounds:[-1/0,-90,1/0,90],maxPitch:85,maxZoom:22,locale:{"CooperativeGesturesHandler.WindowsHelpText":Bi(`windowsHelpText`),"CooperativeGesturesHandler.MacHelpText":Bi(`macHelpText`),"CooperativeGesturesHandler.MobileHelpText":Bi(`mobileHelpText`)},canvasContextAttributes:{preserveDrawingBuffer:n===`video`}}),c=s.getContainer();c.classList.add(`mc-map`),c.classList.add(`mc-mode-${n}`);let l=new zr(s),f=new Ul(s,n),{map:{language:m,pitch:g=0,rotation:v=0,center:y,hideBasemap:b,layerInfo:x=[],detailLevel:S=0,projection:C=`mercator`,terrain:w=!1,terrainExaggeration:T=1},registry:E={},web:D,positionOffsets:O,title:k}=o,{models:A={},slots:j={},svgs:ee={}}=E;Vu(r,i,t),s.resize(),n===`app`&&(document.title=k?`${k} - Mapcreator`:`Mapcreator`),s.setPitch(g),s.setBearing(v);let M=N(o,c),P,te;if(n===`video`?(te=o.map.zoom-S,P=M):(te=o.map.zoom-S+Math.log2(M),P=1),s.setScale(P),s.setZoom(te),s.setCenter(y),s.setDetailLevel(S),s.setMinZoom(S),s.addControl(new u.AttributionControl({compact:!1})),n===`app`&&s.cooperativeGestures.enable(),ul(o,O??_,s,{center:y,zoom:te,pitch:g,rotation:v},i,a,t,P,n),f.setJobObject(o),D){let{restrictMapMovement:e,popupPosition:t}=D;e&&(s.boxZoom.disable(),s.doubleClickZoom.disable(),s.dragPan.disable(),s.dragRotate.disable(),s.keyboard.disable(),s.scrollZoom.disable(),s.touchPitch.disable(),s.touchZoomRotate.disable()),f.setParams(t,h(m,p.TWO),e,y)}let F=await fetch(`${i}/styles/${o.meta.mapstyleSet}.json?access_token=${t}`).then(e=>e.json());s.setStyle(null),s.setStyle(F),await s.once(`style.load`),n===`app`&&Hu(s.getStyle().metadata?.customCssFilePath,t),d(m,s);let ne=await Cl(o.meta.layers??[],s,i,t,F.metadata?.styleOverride),I=(o.map.overlays??[]).reduce((e,t,n)=>e.set(t,ne[n]),new Map);return Wu(s,l,A,j,ee,i,t),d(m,s),f.setPublication(F.metadata?.publication),f.setpopupElements(),f.setHighlightManager(),s.setProjection({type:C===`globe`?`globe`:`mercator`}),zu(s,C),w&&Bu(s,i,t,T),Uu(s,s.getStyle(),x,!b),new Fu(s,o,ee,l,F,I)}function Lu(e,t,n){return fetch(`${t}/jobs/${e}.json?access_token=${n}`).then(e=>e.json())}function Ru(){return new Promise(e=>{let t=()=>{window.innerWidth>0&&window.innerHeight>0&&(window.removeEventListener(`resize`,t),e())};window.addEventListener(`resize`,t),t()})}function zu(e,t){let n=e.getStyle().metadata??{},r=n[`mc:background-color`]??`#f8f8f8`,i=n[`mc:background-color-globe`]??`#000000`;e.getContainer().style.backgroundColor=t===`globe`?i:r,e.setSky(e.getStyle().sky??g),e.setLight({position:[1.15,210,45]})}function Bu(e,t,n,r){e.addSource(`mc-dem`,{type:`raster-dem`,tiles:[`${t}/dataset/jaxa_terrainrgb/{z}/{x}/{y}?access_token=${n}`],attribution:`<a href="https://earth.jaxa.jp/en/data/policy" target="_blank">© AW3D30 (JAXA)</a>`,minzoom:0,maxzoom:12}),e.setTerrain({source:`mc-dem`,exaggeration:r})}function Vu(e,t,n){let r=`${t}/stylesheets/ff-${e===`beta`?`b-`:``}${n}.css?access_token=${n}`,i=document.createElement(`link`);i.setAttribute(`rel`,`stylesheet`),i.setAttribute(`href`,r),i.setAttribute(`type`,`text/css`),document.head.insertBefore(i,document.head.firstChild)}function Hu(e,t){if(document.getElementById(`custom-style`)?.remove(),!e)return;let n;e.startsWith(`http`)?(e=`${e}?access_token=${t}`,n=document.createElement(`link`),n.setAttribute(`rel`,`stylesheet`),n.setAttribute(`href`,e.replace(/https?:/,``))):(n=document.createElement(`style`),n.appendChild(document.createTextNode(e))),n.setAttribute(`id`,`custom-style`),n.setAttribute(`type`,`text/css`),document.head.appendChild(n)}function Uu(e,t,n,r){for(let i of n){let n=t.layers.find(e=>i.id===e.id||i.id.endsWith(` | ${e.id}`));n&&e.setLayoutProperty(n.id,`visibility`,i.visibility&&r?`visible`:`none`)}}function Wu(e,t,n,r,i,a,o){let{beforeNone:s=[],beforeNames:c=[],beforeBoundaries:l=[],beforeWaters:u=[]}=r;s.forEach(r=>{Gu(e,t,n,r,i,`mc-before-none`,a,o)}),c.forEach(r=>{Gu(e,t,n,r,i,`mc-before-names`,a,o)}),l.forEach(r=>{Gu(e,t,n,r,i,`mc-before-boundaries`,a,o)}),u.forEach(r=>{Gu(e,t,n,r,i,`mc-before-waters`,a,o)})}function Gu(e,t,n,r,i,a,o,s){if(r.type===`marker`){let o=n.marker?.find(e=>e.id===r.groupId);o&&bl(e,o,a,i,t)}else if(r.type===`polygon`){let o=n.polygon?.find(e=>e.id===r.groupId);o&&hl(e,o,a,i,t)}else if(r.type===`circle`){let o=n.circle?.find(e=>e.id===r.groupId);o&&_l(e,o,a,i,t)}else if(r.type===`line`){let i=n.line?.find(e=>e.id===r.groupId);i&&Kl(e,i,a,t)}else if(r.type===`dot`){let t=n.dot?.find(e=>e.id===r.groupId);t&&Xl(e,t,a)}else if(r.type===`area`){let c=n.area?.find(e=>e.id===r.groupId);c&&Yl(e,c,a,i,t,o,s)}}e.initMap=Iu,e.setRTLTextPlugin=u.setRTLTextPlugin});
|
|
1168
|
+
`}return n}htmlToElement(e){let t=document.createElement(`template`);return t.innerHTML=e.trim(),t.content.firstElementChild}addPopupControls(){let e=this.htmlToElement(Fl);if(e&&(e.addEventListener(`click`,()=>{this.hidePopup(),this.highlightManager.highlight(void 0)}),this.popupContainer.appendChild(e)),this.popupElements.length<2)return;let t=this.htmlToElement(Il);t&&(t.querySelector(`.prev`)?.addEventListener(`click`,()=>this.cyclePopups(!1)),t.querySelector(`.next`)?.addEventListener(`click`,()=>this.cyclePopups()),this.popupContainer.appendChild(t))}fillDatalayerTemplate(e,t,n){let r=`data-mention-id`,i=new DOMParser().parseFromString(t,`text/html`).body;for(let t of i.querySelectorAll(`[${r}]`)){let i=this.getProperty(e,t.getAttribute(r),n);i!==void 0&&(t.innerText=i)}return i.innerHTML}getProperty(e,t,n){if(!t)return;let r=t.endsWith(`:en`)?[t.replace(`:en`,n),t]:[t];for(let t of r){let n=e.properties[t]??this.getVectorProperty(e,t);if(n!==void 0)return n}}getVectorProperty(e,t){let n=this.promoteIdCache.get(e.source);n===void 0&&(n=this.map.getSource(e.source)?.serialize().promoteId||`id`,this.promoteIdCache.set(e.source,n));try{let r=e.properties[n];return e.layer.metadata.properties[t][r]}catch{return}}cyclePopups(e=!0){let t=this.popupElements?.findIndex(e=>e.modelId===this.currentModelId);if(t!==-1){let n=0;n=e?t===this.popupElements.length-1?0:t+1:t===0?this.popupElements.length-1:t-1;let r=this.popupElements?.[n];this.highlightManager.highlight(r);let i=Pl(r.popup,r.popupMedia,r.dataBindings??{},this.mode),a=this.popupContainer;this.popupContainer.remove(),a.innerHTML=i,this.mapContainer.appendChild(a),this.currentModelId=r.modelId,this.addPopupControls(),e?this.popupContainer.querySelector(`.mc-popup-button.next`)?.focus():this.popupContainer.querySelector(`.mc-popup-button.prev`)?.focus(),this.currentFeatureId=void 0}}},Wl=class e{static#e(e){let t=0,n=[t];for(let r=1;r<e.length;++r){let i=e[r-1],a=e[r],o=a.x-i.x,s=a.y-i.y;t+=Math.sqrt(o*o+s*s),n.push(t)}return n}static#t(e,t){return e.x===t.x&&e.y===t.y}#n;#r;#i;#a;constructor(t){this.#n=t.filter((e,n)=>n===0||t[n][0]!==t[n-1][0]||t[n][1]!==t[n-1][1]),this.#r=this.#n.map(e=>u.MercatorCoordinate.fromLngLat(e)),this.#i=e.#e(this.#r),this.#a=this.#i[this.#i.length-1]}sample(e){let t=this.#r,n=this.#i;if(t.length<2)return t[0];e*=this.#a;for(let r=1;r<t.length;++r){let i=t[r-1],a=t[r],o=n[r-1],s=n[r];if(s>=e){let t=(e-o)/(s-o);return new u.MercatorCoordinate(A(i.x,a.x,t),A(i.y,a.y,t))}}return new u.MercatorCoordinate(t[t.length-1].x,t[t.length-1].y)}slice(t,n){if(this.#n.length<2)return this.#n;let r=this.#r.filter((e,r)=>this.#i[r]>=t*this.#a&&this.#i[r]<=n*this.#a);if(t>0){let n=this.sample(t);e.#t(n,r[0])||r.unshift(n)}if(n<1){let t=this.sample(n);e.#t(t,r[r.length-1])||r.push(t)}return r.map(e=>{let{lng:t,lat:n}=e.toLngLat();return[t,n]})}get length(){return this.#a}},Gl={solid:[1,0],dotted:[.7,.3],dashed:[3.5,1.5]};function Kl(e,t,n,r){e.addSource(t.id,{type:`geojson`,data:{type:`FeatureCollection`,features:t.models.filter(e=>e.visible??!0).map(n=>ql(e,t,n,1,r))}}),Object.entries(Gl).forEach(([r,i])=>{t.models.some(e=>(e.lineStyle??`solid`)===r)&&e.addLayer({id:`${t.id}-${r}`,type:`line`,source:t.id,metadata:{"mc-model-type":`line`,"mc-group-id":t.id},filter:[`all`,[`==`,[`geometry-type`],`LineString`],[`==`,[`get`,`line-style`],r]],paint:{"line-width":[`get`,`line-width`],"line-color":[`get`,`line-color`],"line-dasharray":i,"line-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]}},n)}),e.addLayer({id:`${t.id}-clickable`,type:`line`,source:t.id,metadata:{"mc-model-type":`line`,"mc-group-id":t.id},paint:{"line-width":[`max`,[`get`,`line-width`],15],"line-opacity":0},filter:[`==`,[`geometry-type`],`LineString`]},n),t.models.some(e=>e.svg)&&e.addLayer({id:`${t.id}-icon`,type:`symbol`,source:t.id,metadata:{"mc-model-type":`line`,"mc-group-id":t.id},layout:{"icon-allow-overlap":!0,"icon-ignore-placement":!0,"icon-image":[`get`,`mc-image-key`],"icon-anchor":`center`,"icon-size":[`get`,`icon-size`],"icon-rotate":[`get`,`icon-rotate`],"icon-offset":[`get`,`icon-offset`]},paint:{"icon-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]},filter:[`==`,[`geometry-type`],`Point`]},n)}function ql(e,t,n,r,i){let a=new Wl(n.geometry).slice(0,r),o=n.svg===void 0?void 0:i.getMapLibreImageKey(Kr(n.dataBindings??{},n.svg,void 0),window.devicePixelRatio*(n.iconScale??1));return{type:`Feature`,id:C(n.id),properties:{id:n.id,"line-width":n.lineWidth??3,"line-color":t.lineColor||n.lineColor?Wr(n.dataBindings??{},n.lineColor,t.lineColor):`#000000`,"line-style":n.lineStyle??`solid`,"mc-image-key":o,"icon-rotate":Jl(n,a,e),"icon-offset":n.iconOffset,"icon-size":n.iconScale},geometry:{type:`GeometryCollection`,geometries:[{type:`LineString`,coordinates:a},{type:`Point`,coordinates:a[a.length-1]}]}}}function Jl(e,t,n){return e.iconRotation?e.iconAlign?ur(t,n)+e.iconRotation:e.iconRotation:0}function Yl(e,t,n,r,i,a,o){let s=_r(t),c=new Map,l=new Map;for(let e of t.models){let n=e.featureId,a=t.id,o=[],u=cr(e),d=sr(a,e),f=l.get(d)??{model:e,featureIds:o,modelIdToFillColor:{},modelIdToFillPattern:{},modelIdToOutlineColor:{},modelIdToOutlineWidth:{}};if(e.visible??!0){f.featureIds.push(n);let a=e.fillPattern===void 0?null:i.getMapLibreImageKey(r[e.fillPattern],2*window.devicePixelRatio);f.modelIdToFillColor[n]=t.fillColor||e.fillColor?Wr(e.dataBindings??{},e.fillColor,t.fillColor,s,t.choropleth?.unmatchedColor):`#000000`,f.modelIdToFillPattern[n]=a,f.modelIdToOutlineColor[n]=t.outlineColor||e.outlineColor?Wr(e.dataBindings??{},e.outlineColor,t.outlineColor):`#000000`,f.modelIdToOutlineWidth[n]=e.outlineWidth??.5}c.set(u,e),l.set(d,f)}for(let t of c.keys())e.getSource(t)||e.addSource(t,{type:`vector`,url:`${a}${c.get(t).vectorUrl}?access_token=${o}`});for(let r of l.keys()){let{model:i}=l.get(r),{sourceLayerId:a}=i,o=cr(i);e.addLayer({id:r,type:`fill`,source:o,"source-layer":a,filter:[`literal`,!1],metadata:{"mc-model-type":`area`,"mc-model-id-prefix":i.vectorUrl,"mc-group-id":t.id},paint:{"fill-color":`#ffffff`,"fill-outline-color":`#000000`,"fill-antialias":!1}},n),e.addLayer({id:`${r}-pattern`,type:`fill`,source:o,"source-layer":a,filter:[`literal`,!1],metadata:{"mc-model-type":`area`,"mc-model-id-prefix":i.vectorUrl,"mc-group-id":t.id},paint:{"fill-pattern":[`get`,`fill-pattern`]},layout:{visibility:`visible`}},n),e.addLayer({id:`${r}-outline`,type:`line`,source:o,"source-layer":a,filter:[`literal`,!1],metadata:{"mc-model-type":`area`,"mc-model-id-prefix":i.vectorUrl,"mc-group-id":t.id},paint:{"line-color":`#000000`,"line-width":.5}},n)}l.forEach((t,n)=>{let{featureIds:r,modelIdToFillColor:i,modelIdToFillPattern:a,modelIdToOutlineColor:o,modelIdToOutlineWidth:s}=t;e.setFilter(n,[`in`,`id`,...r]),e.setFilter(`${n}-outline`,[`in`,`id`,...r]),e.setPaintProperty(n,`fill-color`,[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,i]]),e.setPaintProperty(`${n}-outline`,`line-color`,[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,o]]),e.setPaintProperty(`${n}-outline`,`line-width`,[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,s]]),e.setFilter(`${n}-pattern`,[`to-boolean`,[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,a]]]),e.setPaintProperty(`${n}-pattern`,`fill-pattern`,[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,a]])})}function Xl(e,t,n){e.addSource(t.id,{type:`geojson`,data:{type:`FeatureCollection`,features:t.models.filter(e=>e.visible??!0).map(e=>Zl(t,e))}}),e.addLayer({id:t.id,type:`circle`,source:t.id,metadata:{"mc-model-type":`dot`,"mc-group-id":t.id},paint:{"circle-color":[`get`,`circle-color`],"circle-radius":[`get`,`circle-radius`],"circle-opacity":[`coalesce`,[`feature-state`,`opacity`],[`global-state`,`opacity-${t.id}`],1]}},n)}function Zl(e,t){return{type:`Feature`,id:t.id,properties:{id:t.id,"circle-radius":t.radius,"circle-color":e.fillColor||t.fillColor?Wr(t.dataBindings??{},t.fillColor,e.fillColor):`#000000`},geometry:{type:`Point`,coordinates:[t.center.lng,t.center.lat]}}}function Ql(e,t,n,r){return t+n/r*e}function $l(e,t,n,r){return n*((e=e/r-1)*e*e+1)+t}function eu(e,t,n,r){let i=1.70158,a=0,o=n;return e===0?t:(e/=r)===1?t+n:(a||=r*.3,o<Math.abs(n)?(o=n,i=a/4):i=a/(2*Math.PI)*Math.asin(n/o),o*2**(-10*e)*Math.sin((e*r-i)*(2*Math.PI)/a)+n+t)}function tu(e,t,n,r,i){return i===void 0&&(i=1.70158),n*((e=e/r-1)*e*((i+1)*e+i)+1)+t}function nu(e,t,n,r){return(e/=r)<1/2.75?n*(7.5625*e*e)+t:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+t:n*(7.5625*(e-=2.625/2.75)*e+.984375)+t}var ru={linear:Ql,easeOutCubic:$l,easeOutBack:tu,easeOutBounce:nu,easeOutElastic:eu};function iu(e){return e.entryType===`fade`||e.exitType===`fade`||e.entryType===`instant`||e.exitType===`instant`}function au(e){return e.entryType===`grow`||e.exitType===`grow`}function ou(e,t,n){let{entry:r,entryDuration:i,exit:a,exitDuration:o}=e,{entryType:s,entryEasing:c,exitType:l,exitEasing:u}=e;return n<r&&(s===t||s===`instant`&&t===`fade`)||n>a&&(l===t||l===`instant`&&t===`fade`)?0:i>0&&n<r+i&&s===t?ru[c](n-r,0,1,i):o>0&&n>a-o&&l===t?ru[u](n-(a-o),1,-1,o):1}function su(e){let t=e.length>0?[cu(e[0])]:[],n=0,r=0;for(let i=1;i<e.length;++i){let a=cu(e[i]);n+=lu(e[i-1].center[0],a.center[0]),r+=lu(e[i-1].bearing,a.bearing),a.center[0]+=n*360,a.x+=n,a.bearing+=r*360,t.push(a)}return t}function cu(e){return{...e,center:[e.center[0],e.center[1]]}}function lu(e,t){if(Math.abs(e)+Math.abs(t)>180){if(e>0&&t<0)return 1;if(e<0&&t>0)return-1}return 0}function uu(e){return 2**-e}function du(e){return e.length>0?e[e.length-1].time:0}function fu(e){return P(e,23.976)?24e3/1001:P(e,29.97)?3e4/1001:P(e,59.94)?6e4/1001:e}function pu(e){return e<0?-1:1}function mu(e,t,n){var r=e._x1-e._x0,i=t-e._x1,a=(e._y1-e._y0)/(r||i<0&&-0),o=(n-e._y1)/(i||r<0&&-0),s=(a*i+o*r)/(r+i);return(pu(a)+pu(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(s))||0}function hu(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function gu(e,t,n){var r=e._x0,i=e._y0,a=e._x1,o=e._y1,s=(a-r)/3;e._context.bezierCurveTo(r+s,i+s*t,a-s,o-s*n,a,o)}function _u(e){this._context=e}_u.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:gu(this,this._t0,hu(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,gu(this,hu(this,n=mu(this,e,t)),n);break;default:gu(this,this._t0,n=mu(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function vu(e){this._context=new yu(e)}(vu.prototype=Object.create(_u.prototype)).point=function(e,t){_u.prototype.point.call(this,t,e)};function yu(e){this._context=e}yu.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,a){this._context.bezierCurveTo(t,e,r,n,a,i)}};function bu(e){return new _u(e)}function xu(e){return e}var{cbrt:Su,sqrt:Cu,PI:wu}=Math,Tu=(e,t,n,r,i)=>{let a=t+n*e,o=a**2+r;if(o>0){let e=Cu(o);return Su(a+e)+Su(a-e)-i}let s=Su(Cu(a*a-o)),c=a?Math.atan(Cu(-o)/a):-wu/2,l;return l=n<0?(a>0?2*wu:wu)-c:i<0?(a>0?2*wu:-3*wu)+c:(a>0?0:wu)+c,2*s*Math.cos(l/3)-i},Eu=(e,t,n,r)=>((t*e+3*n)*e+r)*e;function Du(e,t,n,r){if(!(0<=e&&e<=1&&0<=n&&n<=1))throw Error(`bezier x values must be in [0, 1] range`);if(e===t&&n===r)return xu;let i=6*(3*e-3*n+1),a=6*(n-2*e),o=3*e,s=i*i,c=a*a,l=a/i,u=3*a*o/s-c*a/(s*i),d=2*o/i-c/s,f=d*d*d,p=3/i,m=3*t-3*r+1,h=r-2*t,g=3*t,_=i?Tu:xu;return function(e){return e===0||e===1?e:Eu(_(e,u,p,f,l),m,h,g)}}var Ou=l(s(((e,t)=>{t.exports=n;function n(e,t,n,r){var i,a,o,s,c,l,u,d,f,p,m,h,g,_;for(typeof t!=`function`&&(r=n,n=t,t=null),r||={},s=r.tolerance===void 0?1e-7:r.tolerance,_=r.epsilon===void 0?2220446049250313e-31:r.epsilon,c=r.maxIterations===void 0?20:r.maxIterations,m=r.h===void 0?1e-4:r.h,g=r.verbose===void 0?!1:r.verbose,h=1/m,l=0;l++<c;){if(a=e(n),t?o=t(n):(u=e(n+m),d=e(n-m),f=e(n+2*m),p=e(n-2*m),o=(p-f+8*(u-d))*h/12),Math.abs(o)<=_*Math.abs(a))return g&&console.log(`Newton-Raphson: failed to converged due to nearly zero first derivative`),!1;if(i=n-a/o,Math.abs(i-n)<=s*Math.abs(i))return g&&console.log(`Newton-Raphson: converged to x = `+i+` after `+l+` iterations`),i;n=i}return g&&console.log(`Newton-Raphson: Maximum iterations reached (`+c+`)`),!1}}))(),1),ku=class{segments;constructor(e){this.segments=[];let t=new Au,n=bu(t);n.lineStart();for(let t of e)n.point(t.x,t.y);n.lineEnd(),this.segments=t.segments}sample(e){if(e<=0)return this.segments[0].startY;if(e>=this.segments[this.segments.length-1].endX)return this.segments[this.segments.length-1].endY;let t=this.segments.find(t=>e>=t.startX&&e<t.endX),n=j(t.startX,t.endX,e);return t.startY!==t.endY&&t.easing!==void 0?A(t.startY,t.endY,t.easing(n)):A(t.startY,t.endY,n)}solve(e,t){let n=(0,Ou.default)(t=>this.sample(t)-e,t);return n===!1?t:n}},Au=class{previousPoint={x:0,y:0};segments=[];bezierCurveTo(e,t,n,r,i,a){let o=this.previousPoint.x,s=this.previousPoint.y,c=i===o?void 0:Du((e-o)/(i-o),(t-s)/(a-s),(n-o)/(i-o),(r-s)/(a-s));this.segments.push({startX:o,endX:i,startY:s,endY:a,easing:c}),this.previousPoint={x:i,y:a}}lineTo(e,t){this.segments.push({startX:this.previousPoint.x,endX:e,startY:this.previousPoint.y,endY:t,easing:void 0}),this.previousPoint={x:e,y:t}}moveTo(e,t){this.previousPoint={x:e,y:t}}closePath(){}arc(){}rect(){}arcTo(){}quadraticCurveTo(){}},ju=class{script;xCurve;yCurve;fovCurve;zoomCurve;pitchCurve;bearingCurve;altitudeCurve;elevationCurve;constructor(e){this.script=su(e),this.xCurve=this.createMonotonicCurve(this.script,`x`),this.yCurve=this.createMonotonicCurve(this.script,`y`),this.fovCurve=this.createMonotonicCurve(this.script,`fov`),this.zoomCurve=this.createMonotonicCurve(this.script,`zoom`),this.pitchCurve=this.createMonotonicCurve(this.script,`pitch`),this.bearingCurve=this.createMonotonicCurve(this.script,`bearing`),this.altitudeCurve=this.createMonotonicCurve(this.script,`altitude`),this.elevationCurve=this.createMonotonicCurve(this.script,`elevation`)}sample(e){let t=this.zoomCurve.sample(e),n=this.altitudeCurve.solve(uu(t),e),r=this.xCurve.sample(n),i=this.yCurve.sample(n),a=this.elevationCurve.sample(n),o=this.bearingCurve.sample(e),s=this.pitchCurve.sample(e),c=this.fovCurve.sample(e);return{center:new u.MercatorCoordinate(r,i).toLngLat(),zoom:t,bearing:o,pitch:s,fov:c,elevation:a}}createMonotonicCurve(e,t){let n=[];for(let r=0;r<e.length;r++){let i=r===0,a=r===e.length-1,o=e[r],s=e[r+1],c=e[r-1],l=this.getKeyframeValue(o,t);if(i&&n.push({x:-1,y:l}),n.push({x:o.time,y:l}),!i&&!a&&c.transition===`instant`&&o.transition===`ease`&&n.push({x:o.time+.1,y:l}),!a)if(o.transition===`linear`){let e=o.time+.1,r=s.time-.1,i=j(o.time,s.time,e),a=j(o.time,s.time,r),c=this.getKeyframeValue(s,t);n.push({x:e,y:A(l,c,i)}),n.push({x:r,y:A(l,c,a)})}else o.transition===`instant`&&(n.push({x:o.time+.1,y:l}),n.push({x:s.time-.1,y:l}));a&&n.push({x:o.time+1,y:l})}return new ku(n)}sampleAutoHideOpacity(e){let t=this.script;if(t.length<2)return 1;let n=this.getKeyframeIndexByTime(e);if(n===-1||n===t.length-1)return 1;let r=t[n],i=t[n+1],a=n>0?t[n-1]:void 0,o;if(r.hideLabels===(a?.hideLabels??!1))o=r.hideLabels?0:1;else{let t=e-r.time,n=Math.min(400,i.time-r.time);o=ee($l(t,r.hideLabels?1:0,r.hideLabels?-1:1,n),0,1)}let s;if(n===t.length-2&&r.hideLabels){let t=Math.max(r.time,i.time-400);s=ee($l(e-t,0,1,i.time-t),0,1)}else s=0;return Math.max(o,s)}getKeyframeIndexByTime(e){let t=this.script;if(t.length!==0){for(let n=0;n<t.length;n++)if(e<t[n].time)return n-1;return t.length-1}}getKeyframeValue(e,t){return t===`altitude`?uu(e.zoom):e[t]}},Mu=Nu;function Nu(e,t,n){var r=null,i=null,a=function(){r&&=(clearTimeout(r),i=null,null)},o=function(){var e=i;a(),e&&e()},s=function(){if(!t)return e.apply(this,arguments);var o=this,s=arguments,c=n&&!r;if(a(),i=function(){e.apply(o,s)},r=setTimeout(function(){if(r=null,!c){var e=i;return i=null,e()}},t),c)return i()};return s.cancel=a,s.flush=o,s}var Pu=class{mcMap;cameraCurve;jobObject;svgs;svgCache;duration;mapstyle;overlays;layerInfo;playhead;playbackContext;constructor(e,t,n,r,i,a){this.mcMap=e,this.playhead=0,this.playbackContext=void 0;let o=(t.video?.keyframes??[]).map(e=>{let{x:t,y:n}=u.MercatorCoordinate.fromLngLat(e.center);return{...e,x:t,y:n,fov:e.fov??36.87,elevation:e.elevation??0}});this.duration=du(o),this.cameraCurve=new ju(o),this.jobObject=t,this.svgs=n,this.svgCache=r,this.mapstyle=i,this.overlays=a,this.layerInfo=t.map.layerInfo?.reduce((e,t)=>(e[t.id]={visibility:t.visibility},e),{})??{}}play(){this.playbackContext===void 0&&this.duration>0&&(this.playhead>=this.duration&&(this.playhead=0),this.playbackContext={startTime:Date.now(),startPlayhead:this.playhead},this.mcMap.fire(`playstart`,{time:this.playhead}),this.playFrame())}pause(){this.playbackContext!==void 0&&(this.playbackContext=void 0,this.mcMap.fire(`playend`,{time:this.playhead}))}seekTo(e){this.duration>0&&(e=ee(e,0,this.duration),this.prepareForPlayback(),this.setCamera(e),this.playbackContext!==void 0&&(this.playbackContext={startTime:Date.now(),startPlayhead:e}))}async*frames(){let e=this.mcMap.map,t=fu(this.jobObject.export?.frameRate??60),n=Math.ceil(this.duration*t/1e3);e._fadeDuration=0,e.style.stylesheet.transition={duration:0,delay:0},e.setCenterClampedToGround(!1);let r=e.getCanvas(),{width:i,height:a}=r,o=new OffscreenCanvas(i,a).getContext(`2d`,{desynchronized:!0,willReadFrequently:!0});for(let e=0;e<n;e++)yield this.captureFrame(e*1e3/t,r,o,i,a);e._fadeDuration=300,e.style.stylesheet.transition=void 0,e.setCenterClampedToGround(!0)}async captureFrame(e,t,n,r,i){return this.setCamera(e),await this.mcMap.map.once(`idle`),n.fillStyle=`#ffffff`,n.fillRect(0,0,r,i),n.drawImage(t,0,0),n.getImageData(0,0,r,i)}playFrame(){if(this.playbackContext!==void 0){let e=this.playbackContext.startPlayhead+(Date.now()-this.playbackContext.startTime);this.prepareForPlayback(),e>this.duration?(this.setCamera(this.duration),this.playbackContext=void 0,this.mcMap.fire(`playend`,{time:this.playhead})):(this.setCamera(e),requestAnimationFrame(()=>this.playFrame()))}}setCamera(e){this.playhead=e;let t=this.mcMap.map,n=this.cameraCurve.sample(e),r=t.getCenter(),i=t.getZoom(),a=t.getBearing(),o=t.getPitch(),s=t.getCenterElevation(),c=t.getVerticalFieldOfView();n.center.lat!==r.lat||n.center.lng!==r.lng||n.zoom!==i||n.bearing!==a||n.pitch!==o||n.elevation!==s||n.fov!==c?(t.setVerticalFieldOfView(n.fov),t.jumpTo(n)):t.triggerRepaint(),this.applyAnimations(e),this.mcMap.fire(`play`,{time:e})}applyAnimations(e){let t=this.mcMap.map,{svgs:n,svgCache:r}=this,i=this.jobObject.video?.animations??[];for(let n of i){let{target:r}=n;if(r.type===`model`&&iu(n)){let{modelType:i,groupId:a,modelId:o}=r,s=ou(n,`fade`,e);(i===`polygon`||i===`circle`||i===`line`||i===`marker`||i===`dot`)&&(o===void 0?t.setGlobalStateProperty(`opacity-${a}`,s===1?null:s):t.setFeatureState({source:a,id:C(o)},{opacity:s}))}}for(let n of this.jobObject.registry?.models?.area??[]){let{groupAnimation:r,modelAnimations:a}=this.getGroupAnimations(i,`area`,n.id,`opacity`);if(!(r===void 0&&a.size===0))if(r!==void 0&&a.size===0){let i=ou(r,`fade`,e);n.models.reduce((e,t)=>e.add(sr(n.id,t)),new Set).forEach(e=>{t.setPaintProperty(e,`fill-opacity`,i),t.setPaintProperty(`${e}-outline`,`line-opacity`,i),t.setPaintProperty(`${e}-pattern`,`fill-opacity`,i)})}else{let i=r===void 0?1:ou(r,`fade`,e),o={};for(let t of n.models){let r=t.featureId===void 0?t.id:String(t.featureId),s=sr(n.id,t),c=a.get(t.id),l=c===void 0?i:ou(c,`fade`,e);o[s]??={},o[s][r]=l}for(let[e,n]of Object.entries(o)){let r=[`get`,[`case`,[`==`,[`typeof`,[`get`,`id`]],`number`],[`to-string`,[`get`,`id`]],[`get`,`id`]],[`literal`,n]];t.setPaintProperty(e,`fill-opacity`,r),t.setPaintProperty(`${e}-outline`,`line-opacity`,r),t.setPaintProperty(`${e}-pattern`,`fill-opacity`,r)}}}for(let a of this.jobObject.registry?.models?.circle??[]){let{groupAnimation:o,modelAnimations:s}=this.getGroupAnimations(i,`circle`,a.id,`scale`),c=o===void 0?1:ou(o,`grow`,e);(o!==void 0||s.size>0)&&t.getSource(a.id).setData({type:`FeatureCollection`,features:a.models.filter(e=>e.visible??!0).map(t=>{let i=s.get(t.id);return vl(a,t,i===void 0?c:ou(i,`grow`,e),n,r)})})}for(let n of this.jobObject.registry?.models?.line??[]){let{groupAnimation:a,modelAnimations:o}=this.getGroupAnimations(i,`line`,n.id,`scale`),s=a===void 0?1:ou(a,`grow`,e);(a!==void 0||o.size>0)&&t.getSource(n.id).setData({type:`FeatureCollection`,features:n.models.filter(e=>e.visible??!0).map(i=>{let a=o.get(i.id);return ql(t,n,i,a===void 0?s:ou(a,`grow`,e),r)})})}for(let a of this.jobObject.registry?.models?.marker??[]){let{groupAnimation:o,modelAnimations:s}=this.getGroupAnimations(i,`marker`,a.id,`scale`),c=o===void 0?1:ou(o,`grow`,e);(o!==void 0||s.size>0)&&t.getSource(a.id).setData({type:`FeatureCollection`,features:a.models.filter(e=>e.visible??!0).map(t=>{let i=s.get(t.id);return Sl(a,t,i===void 0?c:ou(i,`grow`,e),n,r)})})}let a=this.cameraCurve.sampleAutoHideOpacity(e);for(let t of this.mapstyle.layers){let n=this.getLayerOpacity(i,t,e,void 0);n===void 0?t.type===`symbol`&&this.setLayerOpacity(t,a):this.setLayerOpacity(t,n)}for(let[t,n]of this.overlays)for(let r of n.layers){let n=this.getLayerOpacity(i,r,e,t);n===void 0?this.resetLayerOpacity(r):this.setLayerOpacity(r,n)}}prepareForPlayback(){let e=this.mcMap.map;e.setCenterClampedToGround(!1),e.style?.stylesheet&&(e.style.stylesheet.transition={duration:0,delay:0}),this.restoreAfterPlayback()}restoreAfterPlayback=Mu(()=>{let e=this.mcMap.map;e.setCenterClampedToGround(!0),e.style?.stylesheet&&(e.style.stylesheet.transition=void 0)},300);getGroupAnimations(e,t,n,r){let i,a=new Map;for(let o of e){let{target:e}=o;e.type===`model`&&e.modelType===t&&e.groupId===n&&(r===`opacity`&&iu(o)||r===`scale`&&au(o))&&(e.modelId===void 0?i=o:a.set(e.modelId,o))}return{groupAnimation:i,modelAnimations:a}}getLayerOpacity(e,t,n,r){let i,a,o=1/0;r!==void 0&&(i=e.find(e=>e.target.type===`overlay`&&e.target.id===r));for(let n of e){let{target:e}=n;e.type===`layer`&&e.ids.includes(t.id)&&e.ids.length<o&&(a=n,o=e.ids.length)}return a===void 0?i===void 0?void 0:ou(i,`fade`,n):ou(a,`fade`,n)}setLayerOpacity(e,t){let n=this.mcMap.map;e.type===`fill`?n.setPaintProperty(e.id,`fill-opacity`,t):e.type===`line`?n.setPaintProperty(e.id,`line-opacity`,t):e.type===`circle`?(n.setPaintProperty(e.id,`circle-opacity`,t),n.setPaintProperty(e.id,`circle-stroke-opacity`,t)):e.type===`heatmap`?n.setPaintProperty(e.id,`heatmap-opacity`,t):e.type===`fill-extrusion`?n.setPaintProperty(e.id,`fill-extrusion-opacity`,t):e.type===`symbol`?(n.setPaintProperty(e.id,`icon-opacity`,t),n.setPaintProperty(e.id,`text-opacity`,t)):e.type===`raster`?n.setPaintProperty(e.id,`raster-opacity`,t):e.type===`hillshade`?n.setPaintProperty(e.id,`hillshade-exaggeration`,t*.5):e.type===`color-relief`?n.setPaintProperty(e.id,`color-relief-opacity`,t):e.type===`background`&&n.setPaintProperty(e.id,`background-opacity`,t),n.setLayoutProperty(e.id,`visibility`,t===0?`none`:this.layerInfo[e.id]?.visibility?`visible`:`none`)}resetLayerOpacity(e){let t=this.mcMap.map;e.type===`fill`?t.setPaintProperty(e.id,`fill-opacity`,e.paint?.[`fill-opacity`]??1):e.type===`line`?t.setPaintProperty(e.id,`line-opacity`,e.paint?.[`line-opacity`]??1):e.type===`circle`?(t.setPaintProperty(e.id,`circle-opacity`,e.paint?.[`circle-opacity`]??1),t.setPaintProperty(e.id,`circle-stroke-opacity`,e.paint?.[`circle-stroke-opacity`]??1)):e.type===`heatmap`?t.setPaintProperty(e.id,`heatmap-opacity`,e.paint?.[`heatmap-opacity`]??1):e.type===`fill-extrusion`?t.setPaintProperty(e.id,`fill-extrusion-opacity`,e.paint?.[`fill-extrusion-opacity`]??1):e.type===`symbol`?(t.setPaintProperty(e.id,`icon-opacity`,e.paint?.[`icon-opacity`]??1),t.setPaintProperty(e.id,`text-opacity`,e.paint?.[`text-opacity`]??1)):e.type===`raster`?t.setPaintProperty(e.id,`raster-opacity`,e.paint?.[`raster-opacity`]??1):e.type===`hillshade`?t.setPaintProperty(e.id,`hillshade-exaggeration`,e.paint?.[`hillshade-exaggeration`]??.5):e.type===`color-relief`?t.setPaintProperty(e.id,`color-relief-opacity`,e.paint?.[`color-relief-opacity`]??1):e.type===`background`&&t.setPaintProperty(e.id,`background-opacity`,e.paint?.[`background-opacity`]??1),t.setLayoutProperty(e.id,`visibility`,this.layerInfo[e.id]?.visibility?`visible`:`none`)}},Fu=class extends u.Evented{map;video;constructor(e,t,n,r,i,a){super(),this.map=e,this.video=new Pu(this,t,n,r,i,a)}on(e,t){return super.on(e,t)}once(e,t){return super.once(e,t)}off(e,t){return super.off(e,t)}fire(e,t){return super.fire(e,t)}play(){this.video.play()}pause(){this.video.pause()}seekTo(e){this.video.seekTo(e)}frames(){return this.video.frames()}};async function Iu(e){let{accessToken:t,mode:n=`sdk`,env:r=`production`}=e,i=r===`bleeding`?`https://vapi.bleeding.mc-cdn.io`:r===`beta`?`https://vapi.beta.mc-cdn.io`:`https://vapi.mc-cdn.io`,a=r===`bleeding`?`https://cdn.bleeding.mapcreator.io`:r===`beta`?`https://cdn.beta.mapcreator.io`:`https://cdn.mapcreator.io`,o=typeof e.job==`string`?await Lu(e.job,a,t):e.job;await Ru();let s=new u.Map({container:e.container,attributionControl:!1,style:null,maxBounds:[-1/0,-90,1/0,90],maxPitch:85,maxZoom:22,locale:{"CooperativeGesturesHandler.WindowsHelpText":Bi(`windowsHelpText`),"CooperativeGesturesHandler.MacHelpText":Bi(`macHelpText`),"CooperativeGesturesHandler.MobileHelpText":Bi(`mobileHelpText`)},canvasContextAttributes:{preserveDrawingBuffer:n===`video`}}),c=s.getContainer();c.classList.add(`mc-map`),c.classList.add(`mc-mode-${n}`);let l=new zr(s),f=new Ul(s,n),{map:{language:m,pitch:g=0,rotation:v=0,center:y,hideBasemap:b,layerInfo:x=[],detailLevel:S=0,projection:C=`mercator`,terrain:w=!1,terrainExaggeration:T=1},registry:E={},web:D,positionOffsets:O,title:k}=o,{models:A={},slots:j={},svgs:ee={}}=E;Vu(r,i,t),s.resize(),n===`app`&&(document.title=k?`${k} - Mapcreator`:`Mapcreator`),s.setPitch(g),s.setBearing(v);let M=N(o,c),P,te;if(n===`video`?(te=o.map.zoom-S,P=M):(te=o.map.zoom-S+Math.log2(M),P=1),s.setScale(P),s.setZoom(te),s.setCenter(y),s.setDetailLevel(S),s.setMinZoom(S),s.addControl(new u.AttributionControl({compact:!1})),n===`app`&&s.cooperativeGestures.enable(),ul(o,O??_,s,{center:y,zoom:te,pitch:g,rotation:v},i,a,t,P,n),f.setJobObject(o),D){let{restrictMapMovement:e,popupPosition:t}=D;e&&(s.boxZoom.disable(),s.doubleClickZoom.disable(),s.dragPan.disable(),s.dragRotate.disable(),s.keyboard.disable(),s.scrollZoom.disable(),s.touchPitch.disable(),s.touchZoomRotate.disable()),f.setParams(t,h(m,p.TWO),e,y)}let F=await fetch(`${i}/styles/${o.meta.mapstyleSet}.json?access_token=${t}`).then(e=>e.json());s.setStyle(null),s.setStyle(F),await s.once(`style.load`),n===`app`&&Hu(s.getStyle().metadata?.customCssFilePath,t),d(m,s);let ne=await Cl(o.map.overlays??[],o.meta.layers??[],s,i,t,F.metadata?.styleOverride),I=(o.map.overlays??[]).reduce((e,t,n)=>e.set(t,ne[n]),new Map);return Wu(s,l,A,j,ee,i,t),d(m,s),f.setPublication(F.metadata?.publication),f.setpopupElements(),f.setHighlightManager(),s.setProjection({type:C===`globe`?`globe`:`mercator`}),zu(s,C),w&&Bu(s,i,t,T),Uu(s,x,!b),new Fu(s,o,ee,l,F,I)}function Lu(e,t,n){return fetch(`${t}/jobs/${e}.json?access_token=${n}`).then(e=>e.json())}function Ru(){return new Promise(e=>{let t=()=>{window.innerWidth>0&&window.innerHeight>0&&(window.removeEventListener(`resize`,t),e())};window.addEventListener(`resize`,t),t()})}function zu(e,t){let n=e.getStyle().metadata??{},r=n[`mc:background-color`]??`#f8f8f8`,i=n[`mc:background-color-globe`]??`#000000`;e.getContainer().style.backgroundColor=t===`globe`?i:r,e.setSky(e.getStyle().sky??g),e.setLight({position:[1.15,210,45]})}function Bu(e,t,n,r){e.addSource(`mc-dem`,{type:`raster-dem`,tiles:[`${t}/dataset/jaxa_terrainrgb/{z}/{x}/{y}?access_token=${n}`],attribution:`<a href="https://earth.jaxa.jp/en/data/policy" target="_blank">© AW3D30 (JAXA)</a>`,minzoom:0,maxzoom:12}),e.setTerrain({source:`mc-dem`,exaggeration:r})}function Vu(e,t,n){let r=`${t}/stylesheets/ff-${e===`beta`?`b-`:``}${n}.css?access_token=${n}`,i=document.createElement(`link`);i.setAttribute(`rel`,`stylesheet`),i.setAttribute(`href`,r),i.setAttribute(`type`,`text/css`),document.head.insertBefore(i,document.head.firstChild)}function Hu(e,t){if(document.getElementById(`custom-style`)?.remove(),!e)return;let n;e.startsWith(`http`)?(e=`${e}?access_token=${t}`,n=document.createElement(`link`),n.setAttribute(`rel`,`stylesheet`),n.setAttribute(`href`,e.replace(/https?:/,``))):(n=document.createElement(`style`),n.appendChild(document.createTextNode(e))),n.setAttribute(`id`,`custom-style`),n.setAttribute(`type`,`text/css`),document.head.appendChild(n)}function Uu(e,t,n){for(let r of t)e.getLayer(r.id)!==void 0&&e.setLayoutProperty(r.id,`visibility`,r.visibility&&n?`visible`:`none`)}function Wu(e,t,n,r,i,a,o){let{beforeNone:s=[],beforeNames:c=[],beforeBoundaries:l=[],beforeWaters:u=[]}=r;s.forEach(r=>{Gu(e,t,n,r,i,`mc-before-none`,a,o)}),c.forEach(r=>{Gu(e,t,n,r,i,`mc-before-names`,a,o)}),l.forEach(r=>{Gu(e,t,n,r,i,`mc-before-boundaries`,a,o)}),u.forEach(r=>{Gu(e,t,n,r,i,`mc-before-waters`,a,o)})}function Gu(e,t,n,r,i,a,o,s){if(r.type===`marker`){let o=n.marker?.find(e=>e.id===r.groupId);o&&bl(e,o,a,i,t)}else if(r.type===`polygon`){let o=n.polygon?.find(e=>e.id===r.groupId);o&&hl(e,o,a,i,t)}else if(r.type===`circle`){let o=n.circle?.find(e=>e.id===r.groupId);o&&_l(e,o,a,i,t)}else if(r.type===`line`){let i=n.line?.find(e=>e.id===r.groupId);i&&Kl(e,i,a,t)}else if(r.type===`dot`){let t=n.dot?.find(e=>e.id===r.groupId);t&&Xl(e,t,a)}else if(r.type===`area`){let c=n.area?.find(e=>e.id===r.groupId);c&&Yl(e,c,a,i,t,o,s)}}e.initMap=Iu,e.setRTLTextPlugin=u.setRTLTextPlugin});
|