@blogmcp/sdk 0.3.1 → 0.3.2

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.
@@ -0,0 +1,50 @@
1
+ class r {
2
+ constructor(e, a, s) {
3
+ this.callbacks = a, this.labels = s, this.root = e.ownerDocument.createElement("div"), this.root.className = "tripmap-detail", this.root.hidden = !0, e.appendChild(this.root);
4
+ }
5
+ root;
6
+ nodeId = null;
7
+ get element() {
8
+ return this.root;
9
+ }
10
+ get currentId() {
11
+ return this.nodeId;
12
+ }
13
+ show(e) {
14
+ const a = this.root.ownerDocument;
15
+ this.root.textContent = "", this.nodeId = e.id, this.root.dataset.tripmapNode = e.id;
16
+ const s = e.imageUrl || e.thumbnailUrl;
17
+ if (s) {
18
+ const t = this.callbacks.takePreloaded?.(s) ?? a.createElement("img");
19
+ if (t.getAttribute("src") || (t.src = s, t.loading = "eager", t.decoding = "async"), t.alt = e.altText || e.title || "", t.className = "tripmap-detail__img", t.draggable = !1, this.callbacks.onImageClick) {
20
+ const o = a.createElement("button");
21
+ o.type = "button", o.className = "tripmap-detail__zoom", o.setAttribute("aria-label", this.labels.zoomImage), o.appendChild(t), o.addEventListener("click", () => this.callbacks.onImageClick?.(e)), this.root.appendChild(o);
22
+ } else
23
+ this.root.appendChild(t);
24
+ }
25
+ const i = a.createElement("div");
26
+ if (i.className = "tripmap-detail__meta", e.title) {
27
+ const t = a.createElement("strong");
28
+ t.className = "tripmap-detail__title", t.textContent = e.title, i.appendChild(t);
29
+ }
30
+ if (e.capturedAt) {
31
+ const t = a.createElement("span");
32
+ t.className = "tripmap-detail__time", t.textContent = this.callbacks.formatTime(e.capturedAt), i.appendChild(t);
33
+ }
34
+ const l = e.description || e.altText;
35
+ if (l) {
36
+ const t = a.createElement("p");
37
+ t.className = "tripmap-detail__desc", t.textContent = l, i.appendChild(t);
38
+ }
39
+ i.childNodes.length > 0 && this.root.appendChild(i), this.root.hidden = !1;
40
+ }
41
+ clear() {
42
+ this.root.textContent = "", this.root.hidden = !0, this.nodeId = null, delete this.root.dataset.tripmapNode;
43
+ }
44
+ destroy() {
45
+ this.root.remove();
46
+ }
47
+ }
48
+ export {
49
+ r as DetailPanel
50
+ };
@@ -1,255 +1,410 @@
1
- import { Map as W, AttributionControl as Q, NavigationControl as G, Popup as J, setWorkerUrl as K, Marker as X } from "../../../node_modules/maplibre-gl/dist/maplibre-gl.js";
2
- import { Protocol as $ } from "../../../node_modules/pmtiles/dist/esm/index.js";
3
- import ee from "./generated/maplibre-worker.bundle.js";
4
- import { buildAttributions as te } from "./attribution.js";
5
- import { injectTripMapCss as ne } from "./css.js";
6
- import { Filmstrip as oe } from "./filmstrip.js";
7
- import { computeFramingBounds as re } from "./framing.js";
8
- import { buildLineFeature as ae, LINE_LAYER_PAINT as se, LINE_LAYER_LAYOUT as ie } from "./line.js";
9
- import { createPopupContent as ce, setMarkerActive as P, MarkerPool as le, createClusterMarkerEl as me, createNodeMarkerEl as ue } from "./markers.js";
10
- import { formatTimeHHMM as B, lineNodes as pe } from "./nodes.js";
11
- import { startPlayback as de } from "./playback.js";
12
- import { watchSystemTheme as fe, resolveTheme as ye, carryTripMapLayers as ge } from "./theme.js";
13
- import { Mn as he } from "../../../node_modules/maplibre-gl/dist/maplibre-gl-shared.js";
14
- const u = "tripmap-nodes", z = "tripmap-line", ve = "tripmap-line-layer", we = "tripmap-nodes-anchor", Le = 17;
15
- let I = !1;
16
- function Ce() {
17
- if (I) return;
18
- const i = new $();
19
- he("pmtiles", i.tile), I = !0;
1
+ import { Map as ge, AttributionControl as ye, NavigationControl as be, FullscreenControl as we, Popup as ve, setWorkerUrl as Ce, Marker as xe } from "../../../node_modules/maplibre-gl/dist/maplibre-gl.js";
2
+ import { Protocol as Le } from "../../../node_modules/pmtiles/dist/esm/index.js";
3
+ import { ImagePreloader as Ee } from "./preload.js";
4
+ import { mapyRouteUrl as Me, googleMapsRouteUrl as $e, buildGpx as ke, gpxFileName as _e } from "./export.js";
5
+ import { Lightbox as Ne } from "./lightbox.js";
6
+ import { DetailPanel as Ae } from "./detail.js";
7
+ import Se from "./generated/maplibre-worker.bundle.js";
8
+ import { buildAttributions as Te } from "./attribution.js";
9
+ import { injectTripMapCss as Fe } from "./css.js";
10
+ import { Filmstrip as De } from "./filmstrip.js";
11
+ import { computeFramingBounds as Re } from "./framing.js";
12
+ import { buildLineFeature as Ue, LINE_LAYER_PAINT as ze, LINE_LAYER_LAYOUT as Pe } from "./line.js";
13
+ import { createPopupContent as Ie, setMarkerActive as O, MarkerPool as Be, createClusterMarkerEl as He, createNodeMarkerEl as qe } from "./markers.js";
14
+ import { formatTimeHHMM as z, lineNodes as Ze } from "./nodes.js";
15
+ import { startPlayback as Oe } from "./playback.js";
16
+ import { watchSystemTheme as Ve, resolveTheme as V, carryTripMapLayers as je } from "./theme.js";
17
+ import { Mn as Ye } from "../../../node_modules/maplibre-gl/dist/maplibre-gl-shared.js";
18
+ const w = "tripmap-nodes", j = "tripmap-line", Ge = "tripmap-line-layer", We = "tripmap-nodes-anchor", Je = 17;
19
+ let oe = !1;
20
+ function Ke() {
21
+ if (oe) return;
22
+ const l = new Le();
23
+ Ye("pmtiles", l.tile), oe = !0;
20
24
  }
21
- let Z = !1;
22
- function Ee() {
23
- if (!Z) {
24
- Z = !0;
25
+ let ae = !1;
26
+ function Qe() {
27
+ if (!ae) {
28
+ ae = !0;
25
29
  try {
26
- const i = new Blob([ee], { type: "text/javascript" });
27
- K(URL.createObjectURL(i));
30
+ const l = new Blob([Se], { type: "text/javascript" });
31
+ Ce(URL.createObjectURL(l));
28
32
  } catch {
29
33
  }
30
34
  }
31
35
  }
32
- function R(i) {
36
+ function re(l) {
33
37
  return {
34
38
  type: "FeatureCollection",
35
- features: i.map((o) => ({
39
+ features: l.map((n) => ({
36
40
  type: "Feature",
37
- geometry: { type: "Point", coordinates: [o.lng, o.lat] },
38
- properties: { id: o.id }
41
+ geometry: { type: "Point", coordinates: [n.lng, n.lat] },
42
+ properties: { id: n.id }
39
43
  }))
40
44
  };
41
45
  }
42
- function Ue(i, o) {
43
- Ee(), Ce(), ne(i.ownerDocument), i.classList.add("tripmap");
44
- const g = i.ownerDocument.createElement("div");
45
- g.className = "tripmap__map", i.appendChild(g);
46
- let m = [], C = /* @__PURE__ */ new Map(), E = null, c = !1, h = !1, D = !1, y = null, A = null, T = !1;
47
- const U = (e) => ye(e) === "dark" ? o.darkStyleUrl : o.styleUrl, t = new W({
48
- container: g,
49
- style: U(o.theme),
50
- center: o.initialView?.center ?? [0, 0],
51
- zoom: o.initialView?.zoom ?? 1,
52
- attributionControl: !1
46
+ function gt(l, n) {
47
+ Qe(), Ke(), Fe(l.ownerDocument), l.classList.add("tripmap");
48
+ const f = l.ownerDocument.createElement("div");
49
+ f.className = "tripmap__map", l.appendChild(f);
50
+ let d = [], _ = /* @__PURE__ */ new Map(), N = null, u = !1, A = !1, Y = !1, C = null, F = null, P = !1;
51
+ const G = (e) => V(e) === "dark" ? n.darkStyleUrl : n.styleUrl, r = new ge({
52
+ container: f,
53
+ style: G(n.theme),
54
+ center: n.initialView?.center ?? [0, 0],
55
+ zoom: n.initialView?.zoom ?? 1,
56
+ attributionControl: !1,
57
+ locale: {
58
+ "FullscreenControl.Enter": n.labels.fullscreen,
59
+ "FullscreenControl.Exit": n.labels.exitFullscreen
60
+ }
53
61
  });
54
- t.addControl(
55
- new Q({
62
+ r.addControl(
63
+ new ye({
56
64
  compact: !1,
57
- customAttribution: te(o.extraAttribution)
65
+ customAttribution: Te(n.extraAttribution)
58
66
  })
59
- ), t.addControl(new G({ showCompass: !1 }), "top-right"), typeof requestAnimationFrame == "function" && requestAnimationFrame(() => {
60
- c || t.resize();
61
- }), t.on("error", (e) => {
62
- o.events.onError?.(e?.error instanceof Error ? e.error : new Error("tripmap: map error"));
67
+ ), r.addControl(new be({ showCompass: !1 }), "top-right"), n.showFullscreen && r.addControl(new we({ container: l }), "top-right");
68
+ const I = l.ownerDocument, W = () => {
69
+ u || (r.resize(), B(), k());
70
+ };
71
+ I.addEventListener("fullscreenchange", W);
72
+ function B() {
73
+ const e = f.clientHeight || 0, a = e > 0 ? Math.max(96, Math.min(180, Math.round(e * 0.4))) : 180;
74
+ l.style.setProperty("--tripmap-popup-img-max", `${a}px`), e > 0 && l.style.setProperty("--tripmap-map-h", `${e}px`);
75
+ }
76
+ B(), r.on("resize", B);
77
+ const S = new Ee(I);
78
+ typeof requestAnimationFrame == "function" && requestAnimationFrame(() => {
79
+ u || r.resize();
80
+ }), r.on("error", (e) => {
81
+ n.events.onError?.(e?.error instanceof Error ? e.error : new Error("tripmap: map error"));
63
82
  });
64
- const b = new le({
65
- mount: (e, r) => new X({ element: e }).setLngLat(r).addTo(t),
66
- move: (e, r) => {
67
- e.setLngLat(r);
83
+ const D = new Be({
84
+ mount: (e, a) => new xe({ element: e }).setLngLat(a).addTo(r),
85
+ move: (e, a) => {
86
+ e.setLngLat(a);
68
87
  },
69
88
  unmount: (e) => e.remove()
70
89
  });
71
- let M = null;
72
- o.showFilmstrip && (M = new oe(i, {
73
- formatTime: B,
90
+ let x = null;
91
+ n.showFilmstrip && (x = new De(l, {
92
+ formatTime: z,
74
93
  onSelect: (e) => {
75
- N(e.id, { fly: !0 }), _(e);
94
+ $(e.id, { fly: !0 }), U(e);
76
95
  }
77
96
  }));
78
- const v = i.ownerDocument.createElement("div");
79
- v.className = "tripmap__controls";
80
- const p = i.ownerDocument.createElement("button");
81
- p.type = "button", p.className = "tripmap__play", p.textContent = o.labels.play, p.addEventListener("click", () => {
82
- y ? y.stop() : q();
83
- }), v.appendChild(p), g.appendChild(v), v.style.display = "none";
84
- function _(e) {
85
- A?.remove(), A = new J({ offset: 26, maxWidth: "280px", className: "tripmap-popup-anchor" }).setLngLat([e.lng, e.lat]).setDOMContent(ce(e, B)).addTo(t);
86
- }
87
- function N(e, r = {}) {
88
- if (!c) {
89
- if (E && P(b.get(`n:${E}`), !1), E = e, e && P(b.get(`n:${e}`), !0), M?.setActive(e), e && r.fly) {
90
- const n = C.get(e);
91
- n && t.flyTo({
92
- center: [n.lng, n.lat],
93
- zoom: Math.max(t.getZoom(), 15),
97
+ let H = null, R = null;
98
+ const J = new Ne(
99
+ l,
100
+ { close: n.labels.lightboxClose, prev: n.labels.lightboxPrev, next: n.labels.lightboxNext },
101
+ {
102
+ formatTime: z,
103
+ preload: (e) => {
104
+ S.preload(e);
105
+ },
106
+ onChange: (e) => {
107
+ R = e, e.id !== N && $(e.id, { fly: !1 });
108
+ },
109
+ onClose: () => {
110
+ const e = R;
111
+ R = null, e && e.id !== H && !u && U(e), H = null;
112
+ }
113
+ }
114
+ );
115
+ function K(e) {
116
+ H = e.id, R = e, J.open(d, e.id);
117
+ }
118
+ let Q = !1;
119
+ const se = !n.detailHost, L = n.detail === "panel" ? new Ae(
120
+ n.detailHost ?? l,
121
+ {
122
+ formatTime: z,
123
+ onImageClick: K,
124
+ takePreloaded: (e) => S.take(e)
125
+ },
126
+ { zoomImage: n.labels.zoomImage }
127
+ ) : null;
128
+ function U(e) {
129
+ L ? L.show(e) : pe(e);
130
+ }
131
+ function ie() {
132
+ if (!L || !se || Q) return;
133
+ const e = l.getBoundingClientRect().height;
134
+ if (e <= 0) return;
135
+ Q = !0;
136
+ const a = x ? x.element.getBoundingClientRect().height : 0;
137
+ l.classList.add("tripmap--panel"), l.style.height = "auto", f.style.flex = "0 0 auto", f.style.height = `${Math.max(180, Math.round(e - a - (a > 0 ? 8 : 0)))}px`, r.resize();
138
+ }
139
+ const E = l.ownerDocument.createElement("div");
140
+ E.className = "tripmap__controls";
141
+ const g = l.ownerDocument.createElement("button");
142
+ g.type = "button", g.className = "tripmap__ctrl tripmap__play", g.textContent = n.labels.play, g.addEventListener("click", () => {
143
+ C ? C.stop() : ne();
144
+ }), E.appendChild(g);
145
+ const v = l.ownerDocument.createElement("div");
146
+ v.className = "tripmap__export";
147
+ const y = l.ownerDocument.createElement("button");
148
+ y.type = "button", y.className = "tripmap__ctrl tripmap__export-btn", y.textContent = n.labels.export, y.setAttribute("aria-haspopup", "menu"), y.setAttribute("aria-expanded", "false");
149
+ const h = l.ownerDocument.createElement("div");
150
+ h.className = "tripmap__menu", h.setAttribute("role", "menu"), h.hidden = !0, v.appendChild(y), v.appendChild(h), E.appendChild(v);
151
+ const X = (e) => {
152
+ v.contains(e.target) || M();
153
+ }, ee = (e) => {
154
+ e.key === "Escape" && M();
155
+ };
156
+ function M() {
157
+ h.hidden || (h.hidden = !0, y.setAttribute("aria-expanded", "false"), l.ownerDocument.removeEventListener("pointerdown", X, !0), l.ownerDocument.removeEventListener("keydown", ee));
158
+ }
159
+ function le() {
160
+ const e = l.ownerDocument;
161
+ h.textContent = "";
162
+ const a = (s, c, p) => {
163
+ const m = e.createElement(s);
164
+ if (m.className = "tripmap__menu-item", m.setAttribute("role", "menuitem"), m.appendChild(e.createTextNode(c)), p) {
165
+ const b = e.createElement("small");
166
+ b.textContent = p, m.appendChild(b);
167
+ }
168
+ return h.appendChild(m), m;
169
+ }, t = a("button", n.labels.exportGpx, n.labels.exportGpxHint);
170
+ t.type = "button", t.addEventListener("click", () => {
171
+ M(), ce();
172
+ });
173
+ const o = e.defaultView?.matchMedia?.("(pointer: coarse)").matches ?? !1, i = [
174
+ [n.labels.openInMapy, Me(d)],
175
+ [n.labels.openInGoogleMaps, $e(d, { maxWaypoints: o ? 3 : 9 })]
176
+ ];
177
+ for (const [s, c] of i) {
178
+ if (!c) continue;
179
+ const p = a("a", s);
180
+ p.href = c, p.target = "_blank", p.rel = "noopener", p.addEventListener("click", () => M());
181
+ }
182
+ h.hidden = !1, y.setAttribute("aria-expanded", "true"), e.addEventListener("pointerdown", X, !0), e.addEventListener("keydown", ee);
183
+ }
184
+ y.addEventListener("click", () => {
185
+ h.hidden ? le() : M();
186
+ });
187
+ async function ce() {
188
+ const e = ke(d, { name: n.title });
189
+ if (!e) return;
190
+ const a = l.ownerDocument, t = a.defaultView, o = _e(n.title), i = "application/gpx+xml";
191
+ if (t && typeof t.File == "function" && t.navigator?.canShare) {
192
+ const m = new t.File([e], o, { type: i });
193
+ if (t.navigator.canShare({ files: [m] }))
194
+ try {
195
+ await t.navigator.share({ files: [m], title: n.title });
196
+ return;
197
+ } catch (b) {
198
+ if (b?.name === "AbortError") return;
199
+ }
200
+ }
201
+ const s = new Blob([e], { type: i }), c = URL.createObjectURL(s), p = a.createElement("a");
202
+ p.href = c, p.download = o, p.rel = "noopener", p.style.display = "none", a.body.appendChild(p), p.click(), p.remove(), setTimeout(() => URL.revokeObjectURL(c), 1e4);
203
+ }
204
+ f.appendChild(E), E.style.display = "none";
205
+ function pe(e) {
206
+ F?.remove();
207
+ const a = e.imageUrl || e.thumbnailUrl, t = a ? S.take(a) : null, o = Ie(e, z, {
208
+ image: t ?? void 0,
209
+ onImageClick: K,
210
+ zoomLabel: n.labels.zoomImage
211
+ }), i = new ve({ offset: 26, maxWidth: "280px", className: "tripmap-popup-anchor" }).setLngLat([e.lng, e.lat]).setDOMContent(o).addTo(r);
212
+ F = i;
213
+ const s = () => {
214
+ !u && F === i && me(i);
215
+ };
216
+ requestAnimationFrame(s);
217
+ const c = o.querySelector("img");
218
+ c && !c.complete && c.addEventListener("load", s, { once: !0 });
219
+ }
220
+ function me(e) {
221
+ const a = e.getElement();
222
+ if (!a) return;
223
+ const t = a.getBoundingClientRect(), o = f.getBoundingClientRect();
224
+ if (t.width === 0 || o.width === 0) return;
225
+ const i = 8;
226
+ let s = 0, c = 0;
227
+ t.width > o.width - 2 * i ? s = t.left - (o.left + i) : t.right > o.right - i ? s = t.right - (o.right - i) : t.left < o.left + i && (s = t.left - (o.left + i)), t.height > o.height - 2 * i ? c = t.top - (o.top + i) : t.bottom > o.bottom - i ? c = t.bottom - (o.bottom - i) : t.top < o.top + i && (c = t.top - (o.top + i)), !(Math.abs(s) < 1 && Math.abs(c) < 1) && r.panBy([s, c], { duration: 300, essential: !0 });
228
+ }
229
+ function $(e, a = {}) {
230
+ if (!u) {
231
+ if (N && O(D.get(`n:${N}`), !1), N = e, e && O(D.get(`n:${e}`), !0), x?.setActive(e), e && a.fly) {
232
+ const t = _.get(e);
233
+ t && r.flyTo({
234
+ center: [t.lng, t.lat],
235
+ zoom: Math.max(r.getZoom(), 15),
94
236
  essential: !0
95
237
  });
96
238
  }
97
- o.events.onActiveNodeChange?.(e);
239
+ n.events.onActiveNodeChange?.(e);
98
240
  }
99
241
  }
100
- function w() {
101
- T || c || (T = !0, requestAnimationFrame(() => {
102
- T = !1, O();
242
+ function k() {
243
+ P || u || (P = !0, requestAnimationFrame(() => {
244
+ P = !1, de();
103
245
  }));
104
246
  }
105
- function O() {
106
- if (c || !h || !t.getSource(u)) return;
107
- const e = t.querySourceFeatures(u), r = [], n = /* @__PURE__ */ new Set();
108
- for (const a of e) {
109
- const l = a.geometry;
110
- if (l.type !== "Point") continue;
111
- const s = l.coordinates, S = a.properties;
112
- if (S.cluster) {
113
- const d = S.cluster_id, f = `c:${d}`;
114
- if (n.has(f)) continue;
115
- n.add(f);
116
- const k = S.point_count ?? 0;
117
- r.push({
118
- key: f,
247
+ function de() {
248
+ if (u || !A || !r.getSource(w)) return;
249
+ const e = r.querySourceFeatures(w), a = [], t = /* @__PURE__ */ new Set();
250
+ for (const o of e) {
251
+ const i = o.geometry;
252
+ if (i.type !== "Point") continue;
253
+ const s = i.coordinates, c = o.properties;
254
+ if (c.cluster) {
255
+ const p = c.cluster_id, m = `c:${p}`;
256
+ if (t.has(m)) continue;
257
+ t.add(m);
258
+ const b = c.point_count ?? 0;
259
+ a.push({
260
+ key: m,
119
261
  lngLat: s,
120
262
  createEl: () => {
121
- const L = me(k, void 0, () => H(d, s));
122
- return Y(L, d), L;
263
+ const T = He(b, void 0, () => fe(p, s));
264
+ return ue(T, p), T;
123
265
  }
124
266
  });
125
267
  } else {
126
- const d = S.id, f = `n:${d}`;
127
- if (n.has(f)) continue;
128
- n.add(f);
129
- const k = C.get(d);
130
- if (!k) continue;
131
- r.push({
132
- key: f,
268
+ const p = c.id, m = `n:${p}`;
269
+ if (t.has(m)) continue;
270
+ t.add(m);
271
+ const b = _.get(p);
272
+ if (!b) continue;
273
+ a.push({
274
+ key: m,
133
275
  lngLat: s,
134
276
  createEl: () => {
135
- const L = ue(k, (F) => {
136
- N(F.id, { fly: !1 }), _(F), o.events.onNodeClick?.(F);
277
+ const T = qe(b, (Z) => {
278
+ $(Z.id, { fly: !1 }), U(Z), n.events.onNodeClick?.(Z);
137
279
  });
138
- return d === E && P(L, !0), L;
280
+ return p === N && O(T, !0), T;
139
281
  }
140
282
  });
141
283
  }
142
284
  }
143
- b.sync(r);
285
+ D.sync(a);
144
286
  }
145
- async function Y(e, r) {
287
+ async function ue(e, a) {
146
288
  try {
147
- const n = t.getSource(u);
148
- if (!n) return;
149
- const a = (await n.getClusterLeaves(r, 1, 0))?.[0]?.properties?.id, l = a ? C.get(a)?.thumbnailUrl : void 0;
150
- if (!l || !e.isConnected) return;
289
+ const t = r.getSource(w);
290
+ if (!t) return;
291
+ const o = (await t.getClusterLeaves(a, 1, 0))?.[0]?.properties?.id, i = o ? _.get(o)?.thumbnailUrl : void 0;
292
+ if (!i || !e.isConnected) return;
151
293
  const s = e.ownerDocument.createElement("img");
152
- s.src = l, s.alt = "", s.loading = "lazy", s.decoding = "async", s.draggable = !1, s.className = "tripmap-marker__img", e.prepend(s);
294
+ s.src = i, s.alt = "", s.loading = "lazy", s.decoding = "async", s.draggable = !1, s.className = "tripmap-marker__img", e.prepend(s);
153
295
  } catch {
154
296
  }
155
297
  }
156
- function H(e, r) {
157
- const n = t.getSource(u);
158
- n && n.getClusterExpansionZoom(e).then((a) => {
159
- c || t.easeTo({ center: r, zoom: Math.min(a + 0.5, 19) });
298
+ function fe(e, a) {
299
+ const t = r.getSource(w);
300
+ t && (t.getClusterExpansionZoom(e).then((o) => {
301
+ u || r.easeTo({ center: a, zoom: Math.min(o + 0.5, 19) });
160
302
  }).catch(() => {
161
- });
303
+ }), t.getClusterLeaves(e, 1, 0).then((o) => {
304
+ const i = o?.[0]?.properties?.id, s = i ? _.get(i) : void 0;
305
+ u || !s || ($(s.id, { fly: !1 }), L && L.show(s));
306
+ }).catch(() => {
307
+ }));
162
308
  }
163
- function x() {
164
- if (c || !h) return;
165
- const e = t.getSource(u);
166
- e ? e.setData(R(m)) : (t.addSource(u, {
309
+ function q() {
310
+ if (u || !A) return;
311
+ const e = r.getSource(w);
312
+ e ? e.setData(re(d)) : (r.addSource(w, {
167
313
  type: "geojson",
168
- data: R(m),
169
- cluster: o.cluster,
170
- clusterRadius: o.clusterRadius,
171
- clusterMaxZoom: Le
172
- }), t.addLayer({
173
- id: we,
314
+ data: re(d),
315
+ cluster: n.cluster,
316
+ clusterRadius: n.clusterRadius,
317
+ clusterMaxZoom: Je
318
+ }), r.addLayer({
319
+ id: We,
174
320
  type: "circle",
175
- source: u,
321
+ source: w,
176
322
  paint: { "circle-radius": 0, "circle-opacity": 0 }
177
323
  }));
178
- const r = o.showLine ? ae(m) : null, n = t.getSource(z), a = r ?? { type: "FeatureCollection", features: [] };
179
- if (n ? n.setData(a) : r && (t.addSource(z, { type: "geojson", data: a, lineMetrics: !0 }), t.addLayer({
180
- id: ve,
324
+ const a = n.showLine ? Ue(d) : null, t = r.getSource(j), o = a ?? { type: "FeatureCollection", features: [] };
325
+ t ? t.setData(o) : a && (r.addSource(j, { type: "geojson", data: o, lineMetrics: !0 }), r.addLayer({
326
+ id: Ge,
181
327
  type: "line",
182
- source: z,
183
- layout: ie,
184
- paint: se
185
- })), v.style.display = o.showPlayback && pe(m).length >= 2 ? "" : "none", M?.setNodes(m), !D && m.length > 0 && !o.initialView?.center) {
186
- const l = re(m);
187
- l && (t.fitBounds(l, { padding: 56, maxZoom: 15, duration: 0 }), D = !0);
328
+ source: j,
329
+ layout: Pe,
330
+ paint: ze
331
+ }));
332
+ const i = Ze(d).length, s = i >= 2;
333
+ if (g.hidden = !(n.showPlayback && s), v.hidden = !(n.showExport && s), E.style.display = g.hidden && v.hidden ? "none" : "", l.dataset.tripmapNodes = String(d.length), l.dataset.tripmapRoute = String(i), l.dataset.tripmapLine = String(!!a), l.dataset.tripmapTheme = V(n.theme), x?.setNodes(d), d.length > 0 && ie(), !Y && d.length > 0 && !n.initialView?.center) {
334
+ const c = Re(d);
335
+ c && (r.fitBounds(c, { padding: 56, maxZoom: 15, duration: 0 }), Y = !0);
188
336
  }
189
- w();
337
+ k();
190
338
  }
191
- t.on("load", () => {
192
- h = !0, x(), o.events.onReady?.();
193
- }), t.on("moveend", w), t.on("zoomend", w), t.on("idle", w), t.on("sourcedata", (e) => {
194
- e.sourceId === u && e.isSourceLoaded && w();
339
+ r.on("load", () => {
340
+ A = !0, q(), n.events.onReady?.();
341
+ }), r.on("moveend", k), r.on("zoomend", k), r.on("idle", k), r.on("sourcedata", (e) => {
342
+ e.sourceId === w && e.isSourceLoaded && k();
195
343
  });
196
- const V = o.theme === "auto" ? fe(() => {
197
- c || j("auto");
344
+ const he = n.theme === "auto" ? Ve(() => {
345
+ u || te("auto");
198
346
  }) : () => {
199
347
  };
200
- function j(e) {
201
- if (c) return;
202
- const r = U(e);
203
- h = !1, t.setStyle(r, {
204
- transformStyle: (n, a) => ge(n, a)
205
- }), t.once("styledata", () => {
206
- h = !0, x();
348
+ function te(e) {
349
+ if (u) return;
350
+ const a = G(e);
351
+ l.dataset.tripmapTheme = V(e), A = !1, r.setStyle(a, {
352
+ transformStyle: (t, o) => je(t, o)
353
+ }), r.once("styledata", () => {
354
+ A = !0, q();
207
355
  });
208
356
  }
209
- function q(e = {}) {
210
- y?.stop(), p.textContent = o.labels.stop;
211
- const r = de(
212
- m,
357
+ function ne(e = {}) {
358
+ C?.stop(), g.textContent = n.labels.stop;
359
+ const a = Oe(
360
+ d,
213
361
  {
214
- flyTo: (n) => new Promise((a) => {
215
- t.once("moveend", () => a()), t.flyTo({
216
- center: [n.lng, n.lat],
217
- zoom: Math.max(t.getZoom(), 14),
362
+ flyTo: (t) => new Promise((o) => {
363
+ r.once("moveend", () => o()), r.flyTo({
364
+ center: [t.lng, t.lat],
365
+ zoom: Math.max(r.getZoom(), 14),
218
366
  speed: 0.9,
219
- essential: !0
367
+ essential: !0,
368
+ // Land the node in the upper third so its popup (which opens
369
+ // below it) has two thirds of the viewport instead of one half.
370
+ offset: [0, -Math.round((f.clientHeight || 0) * 0.18)]
220
371
  });
221
372
  }),
222
- showNode: (n) => {
223
- N(n.id, { fly: !1 }), _(n);
373
+ showNode: (t) => {
374
+ $(t.id, { fly: !1 }), U(t);
375
+ },
376
+ preload: (t) => {
377
+ const o = t.imageUrl || t.thumbnailUrl;
378
+ return o ? S.preload(o) : void 0;
224
379
  },
225
380
  onDone: () => {
226
- y = null, p.textContent = o.labels.play;
381
+ C = null, g.textContent = n.labels.play;
227
382
  },
228
- onUserInterrupt: (n) => {
229
- const a = t.getCanvasContainer(), l = ["pointerdown", "wheel"];
230
- return l.forEach((s) => a.addEventListener(s, n, { passive: !0 })), () => l.forEach((s) => a.removeEventListener(s, n));
383
+ onUserInterrupt: (t) => {
384
+ const o = r.getCanvasContainer(), i = ["pointerdown", "wheel"];
385
+ return i.forEach((s) => o.addEventListener(s, t, { passive: !0 })), () => i.forEach((s) => o.removeEventListener(s, t));
231
386
  }
232
387
  },
233
388
  e
234
389
  );
235
- return y = r, r;
390
+ return C = a, a;
236
391
  }
237
392
  return {
238
- _map: t,
393
+ _map: r,
239
394
  setNodes(e) {
240
- m = e, C = new Map(e.map((r) => [r.id, r])), x();
395
+ d = e, _ = new Map(e.map((a) => [a.id, a])), q();
241
396
  },
242
- setActiveNode: N,
243
- playSequence: q,
244
- setTheme: j,
397
+ setActiveNode: $,
398
+ playSequence: ne,
399
+ setTheme: te,
245
400
  resize() {
246
- c || t.resize();
401
+ u || r.resize();
247
402
  },
248
403
  destroy() {
249
- c || (c = !0, y?.stop(), V(), A?.remove(), b.clear(), M?.destroy(), t.remove(), g.remove(), i.classList.remove("tripmap"));
404
+ u || (u = !0, C?.stop(), he(), I.removeEventListener("fullscreenchange", W), M(), J.destroy(), L?.destroy(), S.clear(), F?.remove(), D.clear(), x?.destroy(), r.remove(), f.remove(), l.classList.remove("tripmap"));
250
405
  }
251
406
  };
252
407
  }
253
408
  export {
254
- Ue as createEngine
409
+ gt as createEngine
255
410
  };