@blogmcp/sdk 0.3.1 → 0.6.0

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