@blogmcp/sdk 0.3.0 → 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.
Files changed (37) hide show
  1. package/LICENSE +21 -0
  2. package/dist/core/queries.d.ts +2 -2
  3. package/dist/core/queries.js +10 -4
  4. package/dist/core/types.d.ts +9 -0
  5. package/dist/node_modules/fflate/esm/browser.js +284 -0
  6. package/dist/node_modules/maplibre-gl/dist/maplibre-gl-shared.js +11606 -0
  7. package/dist/node_modules/maplibre-gl/dist/maplibre-gl.js +12334 -0
  8. package/dist/node_modules/pmtiles/dist/esm/index.js +441 -0
  9. package/dist/packages/mdx-render-vue/dist/composables/useTripMap.js +27 -0
  10. package/dist/packages/mdx-render-vue/dist/edit/TripMapEdit.vue.js +44 -0
  11. package/dist/packages/mdx-render-vue/dist/edit/TripMapEdit.vue2.js +4 -0
  12. package/dist/packages/mdx-render-vue/dist/registry.js +29 -22
  13. package/dist/packages/mdx-render-vue/dist/render/tripmap/TripMapDefault.vue.js +180 -0
  14. package/dist/packages/mdx-render-vue/dist/render/tripmap/TripMapDefault.vue2.js +4 -0
  15. package/dist/packages/mdx-schema/dist/metadata/index.js +117 -6
  16. package/dist/packages/mdx-schema/dist/styles/index.js +31 -9
  17. package/dist/packages/mdx-schema/dist/tripmap.js +88 -0
  18. package/dist/packages/tripmap-core/dist/attribution.js +9 -0
  19. package/dist/packages/tripmap-core/dist/css.js +151 -0
  20. package/dist/packages/tripmap-core/dist/detail.js +50 -0
  21. package/dist/packages/tripmap-core/dist/engine.js +410 -0
  22. package/dist/packages/tripmap-core/dist/export.js +70 -0
  23. package/dist/packages/tripmap-core/dist/filmstrip.js +46 -0
  24. package/dist/packages/tripmap-core/dist/framing.js +44 -0
  25. package/dist/packages/tripmap-core/dist/generated/maplibre-worker.bundle.js +4 -0
  26. package/dist/packages/tripmap-core/dist/index.js +106 -0
  27. package/dist/packages/tripmap-core/dist/lightbox.js +94 -0
  28. package/dist/packages/tripmap-core/dist/line.js +34 -0
  29. package/dist/packages/tripmap-core/dist/markers.js +95 -0
  30. package/dist/packages/tripmap-core/dist/node_modules/maplibre-gl/dist/maplibre-gl.css.js +4 -0
  31. package/dist/packages/tripmap-core/dist/nodes.js +55 -0
  32. package/dist/packages/tripmap-core/dist/playback.js +29 -0
  33. package/dist/packages/tripmap-core/dist/preload.js +44 -0
  34. package/dist/packages/tripmap-core/dist/theme.js +42 -0
  35. package/package.json +2 -2
  36. package/src/core/queries.ts +6 -0
  37. package/src/core/types.ts +9 -0
@@ -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
+ };
@@ -0,0 +1,410 @@
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;
24
+ }
25
+ let ae = !1;
26
+ function Qe() {
27
+ if (!ae) {
28
+ ae = !0;
29
+ try {
30
+ const l = new Blob([Se], { type: "text/javascript" });
31
+ Ce(URL.createObjectURL(l));
32
+ } catch {
33
+ }
34
+ }
35
+ }
36
+ function re(l) {
37
+ return {
38
+ type: "FeatureCollection",
39
+ features: l.map((n) => ({
40
+ type: "Feature",
41
+ geometry: { type: "Point", coordinates: [n.lng, n.lat] },
42
+ properties: { id: n.id }
43
+ }))
44
+ };
45
+ }
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
+ }
61
+ });
62
+ r.addControl(
63
+ new ye({
64
+ compact: !1,
65
+ customAttribution: Te(n.extraAttribution)
66
+ })
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"));
82
+ });
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);
87
+ },
88
+ unmount: (e) => e.remove()
89
+ });
90
+ let x = null;
91
+ n.showFilmstrip && (x = new De(l, {
92
+ formatTime: z,
93
+ onSelect: (e) => {
94
+ $(e.id, { fly: !0 }), U(e);
95
+ }
96
+ }));
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),
236
+ essential: !0
237
+ });
238
+ }
239
+ n.events.onActiveNodeChange?.(e);
240
+ }
241
+ }
242
+ function k() {
243
+ P || u || (P = !0, requestAnimationFrame(() => {
244
+ P = !1, de();
245
+ }));
246
+ }
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,
261
+ lngLat: s,
262
+ createEl: () => {
263
+ const T = He(b, void 0, () => fe(p, s));
264
+ return ue(T, p), T;
265
+ }
266
+ });
267
+ } else {
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,
275
+ lngLat: s,
276
+ createEl: () => {
277
+ const T = qe(b, (Z) => {
278
+ $(Z.id, { fly: !1 }), U(Z), n.events.onNodeClick?.(Z);
279
+ });
280
+ return p === N && O(T, !0), T;
281
+ }
282
+ });
283
+ }
284
+ }
285
+ D.sync(a);
286
+ }
287
+ async function ue(e, a) {
288
+ try {
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;
293
+ const s = e.ownerDocument.createElement("img");
294
+ s.src = i, s.alt = "", s.loading = "lazy", s.decoding = "async", s.draggable = !1, s.className = "tripmap-marker__img", e.prepend(s);
295
+ } catch {
296
+ }
297
+ }
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) });
302
+ }).catch(() => {
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
+ }));
308
+ }
309
+ function q() {
310
+ if (u || !A) return;
311
+ const e = r.getSource(w);
312
+ e ? e.setData(re(d)) : (r.addSource(w, {
313
+ type: "geojson",
314
+ data: re(d),
315
+ cluster: n.cluster,
316
+ clusterRadius: n.clusterRadius,
317
+ clusterMaxZoom: Je
318
+ }), r.addLayer({
319
+ id: We,
320
+ type: "circle",
321
+ source: w,
322
+ paint: { "circle-radius": 0, "circle-opacity": 0 }
323
+ }));
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,
327
+ type: "line",
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);
336
+ }
337
+ k();
338
+ }
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();
343
+ });
344
+ const he = n.theme === "auto" ? Ve(() => {
345
+ u || te("auto");
346
+ }) : () => {
347
+ };
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();
355
+ });
356
+ }
357
+ function ne(e = {}) {
358
+ C?.stop(), g.textContent = n.labels.stop;
359
+ const a = Oe(
360
+ d,
361
+ {
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),
366
+ speed: 0.9,
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)]
371
+ });
372
+ }),
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;
379
+ },
380
+ onDone: () => {
381
+ C = null, g.textContent = n.labels.play;
382
+ },
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));
386
+ }
387
+ },
388
+ e
389
+ );
390
+ return C = a, a;
391
+ }
392
+ return {
393
+ _map: r,
394
+ setNodes(e) {
395
+ d = e, _ = new Map(e.map((a) => [a.id, a])), q();
396
+ },
397
+ setActiveNode: $,
398
+ playSequence: ne,
399
+ setTheme: te,
400
+ resize() {
401
+ u || r.resize();
402
+ },
403
+ destroy() {
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"));
405
+ }
406
+ };
407
+ }
408
+ export {
409
+ gt as createEngine
410
+ };
@@ -0,0 +1,70 @@
1
+ import { lineNodes as m } from "./nodes.js";
2
+ function u(a) {
3
+ return m(a);
4
+ }
5
+ function c(a, e) {
6
+ const t = a.slice(1, -1);
7
+ if (e <= 0 || t.length === 0) return [];
8
+ if (t.length <= e) return t;
9
+ const r = [];
10
+ for (let o = 0; o < e; o++) {
11
+ const n = Math.round((o + 1) * (t.length - 1) / (e + 1)), i = t[Math.min(n, t.length - 1)];
12
+ r[r.length - 1] !== i && r.push(i);
13
+ }
14
+ return r;
15
+ }
16
+ const p = (a) => a.toFixed(5).replace(/\.?0+$/, "");
17
+ function $(a, e = {}) {
18
+ const t = u(a);
19
+ if (t.length < 2) return null;
20
+ const r = (i) => `${p(i.lng)},${p(i.lat)}`, o = [
21
+ `mapset=${e.mapset ?? "outdoor"}`,
22
+ `start=${r(t[0])}`,
23
+ `end=${r(t[t.length - 1])}`,
24
+ `routeType=${e.routeType ?? "foot_hiking"}`
25
+ ], n = c(t, Math.min(e.maxWaypoints ?? 15, 15));
26
+ return n.length > 0 && o.push(`waypoints=${n.map(r).join(";")}`), e.navigate && o.push("navigate=true"), `https://mapy.com/fnc/v1/route?${o.join("&")}`;
27
+ }
28
+ function h(a, e = {}) {
29
+ const t = u(a);
30
+ if (t.length < 2) return null;
31
+ const r = (i) => `${p(i.lat)},${p(i.lng)}`, o = [
32
+ "api=1",
33
+ `origin=${r(t[0])}`,
34
+ `destination=${r(t[t.length - 1])}`,
35
+ `travelmode=${e.travelmode ?? "walking"}`
36
+ ], n = c(t, Math.min(e.maxWaypoints ?? 9, 9));
37
+ return n.length > 0 && o.push(`waypoints=${n.map(r).join("%7C")}`), `https://www.google.com/maps/dir/?${o.join("&")}`;
38
+ }
39
+ const s = (a) => a.replace(/[<>&'"]/g, (e) => ({ "<": "&lt;", ">": "&gt;", "&": "&amp;", "'": "&apos;", '"': "&quot;" })[e]), l = (a) => s(a);
40
+ function d(a, e = {}) {
41
+ const t = u(a);
42
+ if (t.length < 2) return null;
43
+ const r = s(e.name || "Trip"), o = [
44
+ '<?xml version="1.0" encoding="UTF-8"?>',
45
+ `<gpx version="1.1" creator="${s(e.creator || "blogmcp TripMap")}" xmlns="http://www.topografix.com/GPX/1/1">`,
46
+ ` <metadata><name>${r}</name>${t[0].capturedAt ? `<time>${l(t[0].capturedAt)}</time>` : ""}</metadata>`
47
+ ];
48
+ for (const n of a)
49
+ n.title && o.push(
50
+ ` <wpt lat="${p(n.lat)}" lon="${p(n.lng)}">` + (n.capturedAt ? `<time>${l(n.capturedAt)}</time>` : "") + `<name>${s(n.title)}</name>` + (n.description ? `<desc>${s(n.description)}</desc>` : "") + "</wpt>"
51
+ );
52
+ o.push(` <trk><name>${r}</name><trkseg>`);
53
+ for (const n of t)
54
+ o.push(
55
+ ` <trkpt lat="${p(n.lat)}" lon="${p(n.lng)}">` + (n.capturedAt ? `<time>${l(n.capturedAt)}</time>` : "") + "</trkpt>"
56
+ );
57
+ return o.push(" </trkseg></trk>", "</gpx>", ""), o.join(`
58
+ `);
59
+ }
60
+ function f(a, e = "trasa") {
61
+ return `${(a ?? "").normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || e}.gpx`;
62
+ }
63
+ export {
64
+ d as buildGpx,
65
+ h as googleMapsRouteUrl,
66
+ f as gpxFileName,
67
+ $ as mapyRouteUrl,
68
+ u as routePoints,
69
+ c as sampleWaypoints
70
+ };
@@ -0,0 +1,46 @@
1
+ const a = "tripmap-filmstrip__item--active";
2
+ class l {
3
+ constructor(s, i) {
4
+ this.callbacks = i, this.root = document.createElement("div"), this.root.className = "tripmap-filmstrip", this.root.setAttribute("role", "listbox"), s.appendChild(this.root);
5
+ }
6
+ root;
7
+ items = /* @__PURE__ */ new Map();
8
+ setNodes(s) {
9
+ this.root.textContent = "", this.items.clear();
10
+ for (const i of s) {
11
+ const e = document.createElement("button");
12
+ if (e.type = "button", e.className = "tripmap-filmstrip__item", e.dataset.tripmapNode = i.id, e.setAttribute("role", "option"), e.setAttribute("aria-selected", "false"), e.setAttribute("aria-label", i.title || i.altText || i.id), i.thumbnailUrl) {
13
+ const t = document.createElement("img");
14
+ t.src = i.thumbnailUrl, t.alt = "", t.loading = "lazy", t.decoding = "async", t.draggable = !1, t.className = "tripmap-filmstrip__img", e.appendChild(t);
15
+ } else {
16
+ e.classList.add("tripmap-filmstrip__item--waypoint");
17
+ const t = document.createElement("span");
18
+ t.className = "tripmap-filmstrip__label", t.textContent = i.title || "·", e.appendChild(t);
19
+ }
20
+ if (i.capturedAt) {
21
+ const t = document.createElement("span");
22
+ t.className = "tripmap-filmstrip__time", t.textContent = this.callbacks.formatTime(i.capturedAt), e.appendChild(t);
23
+ }
24
+ e.addEventListener("click", () => this.callbacks.onSelect(i)), this.items.set(i.id, e), this.root.appendChild(e);
25
+ }
26
+ }
27
+ setActive(s) {
28
+ for (const [i, e] of this.items) {
29
+ const t = i === s;
30
+ if (e.classList.toggle(a, t), e.setAttribute("aria-selected", t ? "true" : "false"), t && typeof e.scrollIntoView == "function")
31
+ try {
32
+ e.scrollIntoView({ block: "nearest", inline: "nearest", behavior: "smooth" });
33
+ } catch {
34
+ }
35
+ }
36
+ }
37
+ get element() {
38
+ return this.root;
39
+ }
40
+ destroy() {
41
+ this.root.remove(), this.items.clear();
42
+ }
43
+ }
44
+ export {
45
+ l as Filmstrip
46
+ };
@@ -0,0 +1,44 @@
1
+ function i(l) {
2
+ const t = [...l].sort((a, o) => a - o), n = Math.floor(t.length / 2);
3
+ return t.length % 2 ? t[n] : (t[n - 1] + t[n]) / 2;
4
+ }
5
+ function h(l, t) {
6
+ const n = (l.lat - t.lat) * 111.32, a = (l.lng - t.lng) * 111.32 * Math.cos((l.lat + t.lat) / 2 * (Math.PI / 180));
7
+ return Math.sqrt(n * n + a * a);
8
+ }
9
+ function c(l) {
10
+ let t = 1 / 0, n = 1 / 0, a = -1 / 0, o = -1 / 0;
11
+ for (const e of l)
12
+ e.lng < t && (t = e.lng), e.lng > a && (a = e.lng), e.lat < n && (n = e.lat), e.lat > o && (o = e.lat);
13
+ return [
14
+ [t, n],
15
+ [a, o]
16
+ ];
17
+ }
18
+ function f(l) {
19
+ return h({ lat: l[0][1], lng: l[0][0] }, { lat: l[1][1], lng: l[1][0] });
20
+ }
21
+ function M(l) {
22
+ const t = l.filter((r) => Number.isFinite(r.lat) && Number.isFinite(r.lng));
23
+ if (t.length === 0) return null;
24
+ if (t.length === 1) {
25
+ const r = t[0];
26
+ return [
27
+ [r.lng, r.lat],
28
+ [r.lng, r.lat]
29
+ ];
30
+ }
31
+ const n = c(t);
32
+ if (t.length < 5) return n;
33
+ const a = {
34
+ lat: i(t.map((r) => r.lat)),
35
+ lng: i(t.map((r) => r.lng))
36
+ }, o = t.map((r) => h(r, a)), e = Math.max(5, 3 * i(o)), g = t.filter((r, p) => o[p] <= e);
37
+ if (g.length === t.length || g.length < 2) return n;
38
+ const u = c(g), s = f(n), m = f(u);
39
+ return s > 0 && m / s < 0.5 ? u : n;
40
+ }
41
+ export {
42
+ h as approxDistanceKm,
43
+ M as computeFramingBounds
44
+ };