@blogmcp/sdk 0.3.2 → 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 (59) hide show
  1. package/dist/core/client-types.d.ts +7 -1
  2. package/dist/core/client.d.ts +25 -1
  3. package/dist/core/client.js +38 -34
  4. package/dist/core/consultation-adapter.d.ts +90 -0
  5. package/dist/core/consultation-adapter.js +200 -0
  6. package/dist/core/consultations.d.ts +108 -0
  7. package/dist/core/consultations.js +95 -0
  8. package/dist/core/errors.d.ts +52 -0
  9. package/dist/core/errors.js +73 -0
  10. package/dist/core/index.d.ts +7 -1
  11. package/dist/core/index.js +80 -64
  12. package/dist/core/queries.d.ts +16 -1
  13. package/dist/core/queries.js +198 -61
  14. package/dist/core/review/format.d.ts +30 -0
  15. package/dist/core/review/format.js +78 -0
  16. package/dist/core/review/index.d.ts +6 -0
  17. package/dist/core/review/index.js +9 -0
  18. package/dist/core/review/types.d.ts +176 -0
  19. package/dist/core/review/types.js +9 -0
  20. package/dist/core/server-only.d.ts +12 -0
  21. package/dist/core/server-only.js +11 -0
  22. package/dist/core/types.d.ts +295 -0
  23. package/dist/packages/mdx-schema/dist/metadata/index.js +3 -3
  24. package/dist/packages/mdx-schema/dist/styles/index.js +7 -1
  25. package/dist/packages/mdx-schema/dist/tripmap.js +64 -51
  26. package/dist/packages/tripmap-core/dist/attribution.js +121 -6
  27. package/dist/packages/tripmap-core/dist/css.js +68 -16
  28. package/dist/packages/tripmap-core/dist/detail.js +10 -9
  29. package/dist/packages/tripmap-core/dist/engine.js +285 -247
  30. package/dist/packages/tripmap-core/dist/export.js +48 -46
  31. package/dist/packages/tripmap-core/dist/filmstrip.js +30 -17
  32. package/dist/packages/tripmap-core/dist/framing.js +30 -30
  33. package/dist/packages/tripmap-core/dist/generated/maplibre-worker.bundle.js +1 -1
  34. package/dist/packages/tripmap-core/dist/heading.js +8 -0
  35. package/dist/packages/tripmap-core/dist/href.js +18 -0
  36. package/dist/packages/tripmap-core/dist/index.js +32 -24
  37. package/dist/packages/tripmap-core/dist/lightbox.js +31 -29
  38. package/dist/packages/tripmap-core/dist/line.js +6 -6
  39. package/dist/packages/tripmap-core/dist/markers.js +47 -43
  40. package/dist/packages/tripmap-core/dist/nodes.js +56 -43
  41. package/dist/packages/tripmap-core/dist/playback.js +17 -17
  42. package/dist/packages/tripmap-core/dist/preload.js +14 -14
  43. package/dist/packages/tripmap-core/dist/theme.js +21 -21
  44. package/dist/{node_modules → packages/tripmap-core/node_modules}/maplibre-gl/dist/maplibre-gl.js +1890 -1720
  45. package/dist/{node_modules → packages/tripmap-core/node_modules}/pmtiles/dist/esm/index.js +1 -1
  46. package/package.json +8 -3
  47. package/src/core/client-types.ts +13 -2
  48. package/src/core/client.ts +40 -5
  49. package/src/core/consultation-adapter.ts +408 -0
  50. package/src/core/consultations.ts +224 -0
  51. package/src/core/errors.ts +145 -0
  52. package/src/core/index.ts +68 -0
  53. package/src/core/queries.ts +167 -3
  54. package/src/core/review/format.ts +138 -0
  55. package/src/core/review/index.ts +22 -0
  56. package/src/core/review/types.ts +168 -0
  57. package/src/core/server-only.ts +20 -0
  58. package/src/core/types.ts +337 -0
  59. /package/dist/{node_modules → packages/tripmap-core/node_modules}/maplibre-gl/dist/maplibre-gl-shared.js +0 -0
@@ -1,368 +1,406 @@
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
- }
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;
25
20
  let ae = !1;
26
- function Qe() {
27
- if (!ae) {
28
- ae = !0;
21
+ function rt() {
22
+ if (ae) return;
23
+ const i = new ke();
24
+ Qe("pmtiles", i.tile), ae = !0;
25
+ }
26
+ let le = !1;
27
+ function nt() {
28
+ if (!le) {
29
+ le = !0;
29
30
  try {
30
- const l = new Blob([Se], { type: "text/javascript" });
31
- Ce(URL.createObjectURL(l));
31
+ const i = new Blob([Te], { type: "text/javascript" });
32
+ Ee(URL.createObjectURL(i));
32
33
  } catch {
33
34
  }
34
35
  }
35
36
  }
36
- function re(l) {
37
+ function ie(i) {
37
38
  return {
38
39
  type: "FeatureCollection",
39
- features: l.map((n) => ({
40
+ features: i.map((r) => ({
40
41
  type: "Feature",
41
- geometry: { type: "Point", coordinates: [n.lng, n.lat] },
42
- properties: { id: n.id }
42
+ geometry: { type: "Point", coordinates: [r.lng, r.lat] },
43
+ properties: { id: r.id }
43
44
  }))
44
45
  };
45
46
  }
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({
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({
52
53
  container: f,
53
- style: G(n.theme),
54
- center: n.initialView?.center ?? [0, 0],
55
- zoom: n.initialView?.zoom ?? 1,
54
+ style: J(r.theme),
55
+ center: r.initialView?.center ?? [0, 0],
56
+ zoom: r.initialView?.zoom ?? 1,
56
57
  attributionControl: !1,
57
58
  locale: {
58
- "FullscreenControl.Enter": n.labels.fullscreen,
59
- "FullscreenControl.Exit": n.labels.exitFullscreen
59
+ "FullscreenControl.Enter": r.labels.fullscreen,
60
+ "FullscreenControl.Exit": r.labels.exitFullscreen,
61
+ "GeolocateControl.FindMyLocation": r.labels.findMyLocation,
62
+ "GeolocateControl.LocationNotAvailable": r.labels.locationNotAvailable
60
63
  }
61
64
  });
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());
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());
70
108
  };
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`);
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`);
75
113
  }
76
- B(), r.on("resize", B);
77
- const S = new Ee(I);
114
+ G(), l.on("resize", G);
115
+ const D = new Me(H);
78
116
  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"));
117
+ p || l.resize();
118
+ }), l.on("error", (e) => {
119
+ r.events.onError?.(e?.error instanceof Error ? e.error : new Error("tripmap: map error"));
82
120
  });
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);
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);
87
125
  },
88
126
  unmount: (e) => e.remove()
89
- });
90
- let x = null;
91
- n.showFilmstrip && (x = new De(l, {
92
- formatTime: z,
127
+ }), U = r.showTime !== !1 ? Ze : () => "";
128
+ let C = null;
129
+ r.showFilmstrip && (C = new ze(i, {
130
+ formatTime: U,
93
131
  onSelect: (e) => {
94
- $(e.id, { fly: !0 }), U(e);
132
+ M(e.id, { fly: !0 }), z(e);
95
133
  }
96
134
  }));
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 },
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 },
101
139
  {
102
- formatTime: z,
140
+ formatTime: U,
103
141
  preload: (e) => {
104
- S.preload(e);
142
+ D.preload(e);
105
143
  },
106
144
  onChange: (e) => {
107
- R = e, e.id !== N && $(e.id, { fly: !1 });
145
+ I = e, e.id !== S && M(e.id, { fly: !1 });
108
146
  },
109
147
  onClose: () => {
110
- const e = R;
111
- R = null, e && e.id !== H && !u && U(e), H = null;
148
+ const e = I;
149
+ I = null, e && e.id !== q && !p && z(e), q = null;
112
150
  }
113
151
  }
114
152
  );
115
- function K(e) {
116
- H = e.id, R = e, J.open(d, e.id);
153
+ function X(e) {
154
+ q = e.id, I = e, Q.open(d, e.id);
117
155
  }
118
- let Q = !1;
119
- const se = !n.detailHost, L = n.detail === "panel" ? new Ae(
120
- n.detailHost ?? l,
156
+ let ee = !1;
157
+ const se = !r.detailHost, E = r.detail === "panel" ? new Re(
158
+ r.detailHost ?? i,
121
159
  {
122
- formatTime: z,
123
- onImageClick: K,
124
- takePreloaded: (e) => S.take(e)
160
+ formatTime: U,
161
+ onImageClick: X,
162
+ takePreloaded: (e) => D.take(e)
125
163
  },
126
- { zoomImage: n.labels.zoomImage }
164
+ { zoomImage: r.labels.zoomImage }
127
165
  ) : null;
128
- function U(e) {
129
- L ? L.show(e) : pe(e);
166
+ function z(e) {
167
+ E ? E.show(e) : de(e);
130
168
  }
131
- function ie() {
132
- if (!L || !se || Q) return;
133
- const e = l.getBoundingClientRect().height;
169
+ function ce() {
170
+ if (!E || !se || ee) return;
171
+ const e = i.getBoundingClientRect().height;
134
172
  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();
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();
138
176
  }
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");
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);
183
+ const v = i.ownerDocument.createElement("div");
146
184
  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();
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();
155
193
  };
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));
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));
158
196
  }
159
- function le() {
160
- const e = l.ownerDocument;
197
+ function ue() {
198
+ const e = i.ownerDocument;
161
199
  h.textContent = "";
162
- const a = (s, c, p) => {
200
+ const o = (s, c, u) => {
163
201
  const m = e.createElement(s);
164
- if (m.className = "tripmap__menu-item", m.setAttribute("role", "menuitem"), m.appendChild(e.createTextNode(c)), p) {
202
+ if (m.className = "tripmap__menu-item", m.setAttribute("role", "menuitem"), m.appendChild(e.createTextNode(c)), u) {
165
203
  const b = e.createElement("small");
166
- b.textContent = p, m.appendChild(b);
204
+ b.textContent = u, m.appendChild(b);
167
205
  }
168
206
  return h.appendChild(m), m;
169
- }, t = a("button", n.labels.exportGpx, n.labels.exportGpxHint);
207
+ }, t = o("button", r.labels.exportGpx, r.labels.exportGpxHint);
170
208
  t.type = "button", t.addEventListener("click", () => {
171
- M(), ce();
209
+ k(), me();
172
210
  });
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 })]
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 })]
176
214
  ];
177
- for (const [s, c] of i) {
215
+ for (const [s, c] of a) {
178
216
  if (!c) continue;
179
- const p = a("a", s);
180
- p.href = c, p.target = "_blank", p.rel = "noopener", p.addEventListener("click", () => M());
217
+ const u = o("a", s);
218
+ u.href = c, u.target = "_blank", u.rel = "noopener", u.addEventListener("click", () => k());
181
219
  }
182
- h.hidden = !1, y.setAttribute("aria-expanded", "true"), e.addEventListener("pointerdown", X, !0), e.addEventListener("keydown", ee);
220
+ h.hidden = !1, y.setAttribute("aria-expanded", "true"), e.addEventListener("pointerdown", te, !0), e.addEventListener("keydown", re);
183
221
  }
184
222
  y.addEventListener("click", () => {
185
- h.hidden ? le() : M();
223
+ h.hidden ? ue() : k();
186
224
  });
187
- async function ce() {
188
- const e = ke(d, { name: n.title });
225
+ async function me() {
226
+ const e = Se(d, { name: r.title });
189
227
  if (!e) return;
190
- const a = l.ownerDocument, t = a.defaultView, o = _e(n.title), i = "application/gpx+xml";
228
+ const o = i.ownerDocument, t = o.defaultView, n = Ae(r.title), a = "application/gpx+xml";
191
229
  if (t && typeof t.File == "function" && t.navigator?.canShare) {
192
- const m = new t.File([e], o, { type: i });
230
+ const m = new t.File([e], n, { type: a });
193
231
  if (t.navigator.canShare({ files: [m] }))
194
232
  try {
195
- await t.navigator.share({ files: [m], title: n.title });
233
+ await t.navigator.share({ files: [m], title: r.title });
196
234
  return;
197
235
  } catch (b) {
198
236
  if (b?.name === "AbortError") return;
199
237
  }
200
238
  }
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);
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);
203
241
  }
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, {
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, {
208
246
  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;
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;
213
251
  const s = () => {
214
- !u && F === i && me(i);
252
+ !p && P === a && pe(a);
215
253
  };
216
254
  requestAnimationFrame(s);
217
- const c = o.querySelector("img");
255
+ const c = n.querySelector("img");
218
256
  c && !c.complete && c.addEventListener("load", s, { once: !0 });
219
257
  }
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;
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;
226
264
  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 });
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 });
228
266
  }
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) {
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) {
232
270
  const t = _.get(e);
233
- t && r.flyTo({
271
+ t && l.flyTo({
234
272
  center: [t.lng, t.lat],
235
- zoom: Math.max(r.getZoom(), 15),
273
+ zoom: Math.max(l.getZoom(), 15),
236
274
  essential: !0
237
275
  });
238
276
  }
239
- n.events.onActiveNodeChange?.(e);
277
+ r.events.onActiveNodeChange?.(e);
240
278
  }
241
279
  }
242
- function k() {
243
- P || u || (P = !0, requestAnimationFrame(() => {
244
- P = !1, de();
280
+ function N() {
281
+ B || p || (B = !0, requestAnimationFrame(() => {
282
+ B = !1, fe();
245
283
  }));
246
284
  }
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;
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;
254
292
  if (c.cluster) {
255
- const p = c.cluster_id, m = `c:${p}`;
293
+ const u = c.cluster_id, m = `c:${u}`;
256
294
  if (t.has(m)) continue;
257
295
  t.add(m);
258
296
  const b = c.point_count ?? 0;
259
- a.push({
297
+ o.push({
260
298
  key: m,
261
299
  lngLat: s,
262
300
  createEl: () => {
263
- const T = He(b, void 0, () => fe(p, s));
264
- return ue(T, p), T;
301
+ const R = je(b, void 0, () => ge(u, s));
302
+ return he(R, u), R;
265
303
  }
266
304
  });
267
305
  } else {
268
- const p = c.id, m = `n:${p}`;
306
+ const u = c.id, m = `n:${u}`;
269
307
  if (t.has(m)) continue;
270
308
  t.add(m);
271
- const b = _.get(p);
309
+ const b = _.get(u);
272
310
  if (!b) continue;
273
- a.push({
311
+ o.push({
274
312
  key: m,
275
313
  lngLat: s,
276
314
  createEl: () => {
277
- const T = qe(b, (Z) => {
278
- $(Z.id, { fly: !1 }), U(Z), n.events.onNodeClick?.(Z);
315
+ const R = We(b, (j) => {
316
+ M(j.id, { fly: !1 }), z(j), r.events.onNodeClick?.(j);
279
317
  });
280
- return p === N && O(T, !0), T;
318
+ return u === S && W(R, !0), R;
281
319
  }
282
320
  });
283
321
  }
284
322
  }
285
- D.sync(a);
323
+ F.sync(o);
286
324
  }
287
- async function ue(e, a) {
325
+ async function he(e, o) {
288
326
  try {
289
- const t = r.getSource(w);
327
+ const t = l.getSource(w);
290
328
  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);
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);
295
333
  } catch {
296
334
  }
297
335
  }
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) });
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) });
302
340
  }).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));
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));
306
344
  }).catch(() => {
307
345
  }));
308
346
  }
309
- function q() {
310
- if (u || !A) return;
311
- const e = r.getSource(w);
312
- e ? e.setData(re(d)) : (r.addSource(w, {
347
+ function $() {
348
+ if (p || !A) return;
349
+ const e = l.getSource(w);
350
+ e ? e.setData(ie(d)) : (l.addSource(w, {
313
351
  type: "geojson",
314
- data: re(d),
315
- cluster: n.cluster,
316
- clusterRadius: n.clusterRadius,
317
- clusterMaxZoom: Je
318
- }), r.addLayer({
319
- id: We,
352
+ data: ie(d),
353
+ cluster: r.cluster,
354
+ clusterRadius: r.clusterRadius,
355
+ clusterMaxZoom: tt
356
+ }), l.addLayer({
357
+ id: et,
320
358
  type: "circle",
321
359
  source: w,
322
360
  paint: { "circle-radius": 0, "circle-opacity": 0 }
323
361
  }));
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,
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,
327
365
  type: "line",
328
- source: j,
329
- layout: Pe,
330
- paint: ze
366
+ source: V,
367
+ layout: Ge,
368
+ paint: He
331
369
  }));
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);
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);
336
374
  }
337
- k();
375
+ N();
338
376
  }
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();
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();
343
381
  });
344
- const he = n.theme === "auto" ? Ve(() => {
345
- u || te("auto");
382
+ const ye = r.theme === "auto" ? Je(() => {
383
+ p || ne("auto");
346
384
  }) : () => {
347
385
  };
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();
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, $();
355
393
  });
356
394
  }
357
- function ne(e = {}) {
358
- C?.stop(), g.textContent = n.labels.stop;
359
- const a = Oe(
395
+ function oe(e = {}) {
396
+ x?.stop(), g.textContent = r.labels.stop;
397
+ const o = Ye(
360
398
  d,
361
399
  {
362
- flyTo: (t) => new Promise((o) => {
363
- r.once("moveend", () => o()), r.flyTo({
400
+ flyTo: (t) => new Promise((n) => {
401
+ l.once("moveend", () => n()), l.flyTo({
364
402
  center: [t.lng, t.lat],
365
- zoom: Math.max(r.getZoom(), 14),
403
+ zoom: Math.max(l.getZoom(), 14),
366
404
  speed: 0.9,
367
405
  essential: !0,
368
406
  // Land the node in the upper third so its popup (which opens
@@ -371,40 +409,40 @@ function gt(l, n) {
371
409
  });
372
410
  }),
373
411
  showNode: (t) => {
374
- $(t.id, { fly: !1 }), U(t);
412
+ M(t.id, { fly: !1 }), z(t);
375
413
  },
376
414
  preload: (t) => {
377
- const o = t.imageUrl || t.thumbnailUrl;
378
- return o ? S.preload(o) : void 0;
415
+ const n = t.imageUrl || t.thumbnailUrl;
416
+ return n ? D.preload(n) : void 0;
379
417
  },
380
418
  onDone: () => {
381
- C = null, g.textContent = n.labels.play;
419
+ x = null, g.textContent = r.labels.play;
382
420
  },
383
421
  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));
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));
386
424
  }
387
425
  },
388
426
  e
389
427
  );
390
- return C = a, a;
428
+ return x = o, o;
391
429
  }
392
430
  return {
393
- _map: r,
431
+ _map: l,
394
432
  setNodes(e) {
395
- d = e, _ = new Map(e.map((a) => [a.id, a])), q();
433
+ d = e, _ = new Map(e.map((o) => [o.id, o])), $();
396
434
  },
397
- setActiveNode: $,
398
- playSequence: ne,
399
- setTheme: te,
435
+ setActiveNode: M,
436
+ playSequence: oe,
437
+ setTheme: ne,
400
438
  resize() {
401
- u || r.resize();
439
+ p || l.resize();
402
440
  },
403
441
  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"));
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"));
405
443
  }
406
444
  };
407
445
  }
408
446
  export {
409
- gt as createEngine
447
+ Ct as createEngine
410
448
  };