@nika-js/onlymap 0.8.0 → 0.8.1

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.
@@ -1,16 +1,16 @@
1
- let $t = null, Z = null;
1
+ let kt = null, Z = null;
2
2
  function ye(r) {
3
- $t = r;
3
+ kt = r;
4
4
  }
5
5
  function Ze() {
6
- return B !== null;
6
+ return V !== null;
7
7
  }
8
- let B = null;
9
- function H() {
10
- return B;
8
+ let V = null;
9
+ function G() {
10
+ return V;
11
11
  }
12
12
  function we() {
13
- return B ? Promise.resolve(B) : Z || ($t ? (Z = Promise.resolve($t()).then((r) => (B = r, B)).catch((r) => {
13
+ return V ? Promise.resolve(V) : Z || (kt ? (Z = Promise.resolve(kt()).then((r) => (V = r, V)).catch((r) => {
14
14
  throw Z = null, r;
15
15
  }), Z) : Promise.reject(
16
16
  new Error(
@@ -22,32 +22,32 @@ const Je = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
22
22
  __proto__: null,
23
23
  isCoreLoaded: Ze,
24
24
  loadCore: we,
25
- peekCore: H,
25
+ peekCore: G,
26
26
  setCoreLoader: ye
27
27
  }, Symbol.toStringTag, { value: "Module" }));
28
- function _t(r) {
28
+ function Ot(r) {
29
29
  return { scale: r / 96, pxPerMm: r / 25.4 };
30
30
  }
31
31
  function ft(r) {
32
32
  return typeof r?.paintCartograph == "function";
33
33
  }
34
- const q = (r, t) => {
34
+ const B = (r, t) => {
35
35
  const e = r.getAttribute(t);
36
36
  if (e == null || e.trim() === "") return null;
37
37
  const n = Number(e);
38
38
  return Number.isFinite(n) ? n : null;
39
39
  };
40
- function C(r) {
40
+ function S(r) {
41
41
  return {
42
- x: q(r, "x") ?? 0,
43
- y: q(r, "y") ?? 0,
44
- w: q(r, "w") ?? 0,
45
- h: q(r, "h") ?? 0,
46
- rotation: q(r, "rotation") ?? 0,
47
- z: q(r, "z")
42
+ x: B(r, "x") ?? 0,
43
+ y: B(r, "y") ?? 0,
44
+ w: B(r, "w") ?? 0,
45
+ h: B(r, "h") ?? 0,
46
+ rotation: B(r, "rotation") ?? 0,
47
+ z: B(r, "z")
48
48
  };
49
49
  }
50
- function kt(r, t = 0) {
50
+ function $t(r, t = 0) {
51
51
  if (!r) return t;
52
52
  const e = Number.parseFloat(r);
53
53
  return Number.isFinite(e) ? e : t;
@@ -57,7 +57,7 @@ function L(r) {
57
57
  const t = r.trim().toLowerCase();
58
58
  return t === "transparent" || t === "rgba(0, 0, 0, 0)" || t === "none" ? null : r;
59
59
  }
60
- const W = 96 / 25.4, Ot = {
60
+ const j = 96 / 25.4, Ut = {
61
61
  A0: { widthMm: 841, heightMm: 1189 },
62
62
  A1: { widthMm: 594, heightMm: 841 },
63
63
  A2: { widthMm: 420, heightMm: 594 },
@@ -66,25 +66,25 @@ const W = 96 / 25.4, Ot = {
66
66
  A5: { widthMm: 148, heightMm: 210 },
67
67
  Letter: { widthMm: 215.9, heightMm: 279.4 },
68
68
  Legal: { widthMm: 215.9, heightMm: 355.6 }
69
- }, Ut = "A4";
69
+ }, jt = "A4";
70
70
  function ct(r, t, e, n) {
71
71
  const i = t != null ? Number(t) : NaN, s = e != null ? Number(e) : NaN;
72
72
  if (Number.isFinite(i) && i > 0 && Number.isFinite(s) && s > 0) return { widthMm: i, heightMm: s };
73
- const o = Ot[r ?? Ut] ?? Ot[Ut];
73
+ const o = Ut[r ?? jt] ?? Ut[jt];
74
74
  return n === "landscape" ? { widthMm: o.heightMm, heightMm: o.widthMm } : { ...o };
75
75
  }
76
- let tt = null;
76
+ let et = null;
77
77
  function Qe(r) {
78
- if (!tt) {
79
- tt = new Uint32Array(256);
78
+ if (!et) {
79
+ et = new Uint32Array(256);
80
80
  for (let e = 0; e < 256; e++) {
81
81
  let n = e;
82
82
  for (let i = 0; i < 8; i++) n = n & 1 ? 3988292384 ^ n >>> 1 : n >>> 1;
83
- tt[e] = n >>> 0;
83
+ et[e] = n >>> 0;
84
84
  }
85
85
  }
86
86
  let t = 4294967295;
87
- for (let e = 0; e < r.length; e++) t = tt[(t ^ r[e]) & 255] ^ t >>> 8;
87
+ for (let e = 0; e < r.length; e++) t = et[(t ^ r[e]) & 255] ^ t >>> 8;
88
88
  return (t ^ 4294967295) >>> 0;
89
89
  }
90
90
  function tr(r) {
@@ -115,19 +115,19 @@ const dt = ["protanopia", "deuteranopia", "tritanopia", "achromatopsia"], Me = {
115
115
  tritan: "tritanopia",
116
116
  achroma: "achromatopsia"
117
117
  };
118
- function Lt(r) {
118
+ function Ft(r) {
119
119
  const t = r?.trim().toLowerCase();
120
120
  return !t || t === "none" ? null : dt.includes(t) ? t : Me[t] ?? null;
121
121
  }
122
- const rr = ["none", ...dt, ...Object.keys(Me)], Ft = {
122
+ const rr = ["none", ...dt, ...Object.keys(Me)], It = {
123
123
  protanopia: [0.11238, 0.88762, 0, 0.11238, 0.88762, 0, 401e-5, -401e-5, 1],
124
124
  deuteranopia: [0.29275, 0.70725, 0, 0.29275, 0.70725, 0, -0.02234, 0.02234, 1],
125
125
  tritanopia: [1, 0.14461, -0.14461, 0, 0.85659, 0.14341, 0, 0.85659, 0.14341],
126
126
  achromatopsia: [0.2126, 0.7152, 0.0722, 0.2126, 0.7152, 0.0722, 0.2126, 0.7152, 0.0722]
127
- }, D = (r) => {
127
+ }, q = (r) => {
128
128
  const t = r / 255;
129
129
  return t <= 0.04045 ? t / 12.92 : ((t + 0.055) / 1.055) ** 2.4;
130
- }, at = (r) => {
130
+ }, lt = (r) => {
131
131
  const t = Math.min(1, Math.max(0, r));
132
132
  return 255 * (t <= 31308e-7 ? t * 12.92 : 1.055 * t ** (1 / 2.4) - 0.055);
133
133
  };
@@ -140,31 +140,31 @@ function nr(r) {
140
140
  const n = /^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/.exec(t);
141
141
  return n ? { r: Number(n[1]), g: Number(n[2]), b: Number(n[3]) } : null;
142
142
  }
143
- function jt(r, t) {
144
- const e = Ft[t], [n, i, s] = [D(r.r), D(r.g), D(r.b)];
143
+ function zt(r, t) {
144
+ const e = It[t], [n, i, s] = [q(r.r), q(r.g), q(r.b)];
145
145
  return {
146
- r: at(e[0] * n + e[1] * i + e[2] * s),
147
- g: at(e[3] * n + e[4] * i + e[5] * s),
148
- b: at(e[6] * n + e[7] * i + e[8] * s)
146
+ r: lt(e[0] * n + e[1] * i + e[2] * s),
147
+ g: lt(e[3] * n + e[4] * i + e[5] * s),
148
+ b: lt(e[6] * n + e[7] * i + e[8] * s)
149
149
  };
150
150
  }
151
- function zt({ r, g: t, b: e }) {
152
- const [n, i, s] = [D(r), D(t), D(e)], o = (n * 0.4124564 + i * 0.3575761 + s * 0.1804375) / 0.95047, a = n * 0.2126729 + i * 0.7151522 + s * 0.072175, l = (n * 0.0193339 + i * 0.119192 + s * 0.9503041) / 1.08883, c = (h) => h > 216 / 24389 ? Math.cbrt(h) : 841 / 108 * h + 4 / 29, [u, m, d] = [c(o), c(a), c(l)];
151
+ function Dt({ r, g: t, b: e }) {
152
+ const [n, i, s] = [q(r), q(t), q(e)], o = (n * 0.4124564 + i * 0.3575761 + s * 0.1804375) / 0.95047, a = n * 0.2126729 + i * 0.7151522 + s * 0.072175, l = (n * 0.0193339 + i * 0.119192 + s * 0.9503041) / 1.08883, c = (h) => h > 216 / 24389 ? Math.cbrt(h) : 841 / 108 * h + 4 / 29, [u, m, d] = [c(o), c(a), c(l)];
153
153
  return [116 * m - 16, 500 * (u - m), 200 * (m - d)];
154
154
  }
155
- function Dt(r, t) {
156
- const [e, n, i] = zt(r), [s, o, a] = zt(t), l = Math.PI / 180, c = 180 / Math.PI, u = (Math.hypot(n, i) + Math.hypot(o, a)) / 2, m = 0.5 * (1 - Math.sqrt(u ** 7 / (u ** 7 + 25 ** 7))), [d, h] = [n * (1 + m), o * (1 + m)], [f, p] = [Math.hypot(d, i), Math.hypot(h, a)], g = (U, Q) => {
157
- if (U === 0 && Q === 0) return 0;
158
- const X = Math.atan2(Q, U) * c;
155
+ function Gt(r, t) {
156
+ const [e, n, i] = Dt(r), [s, o, a] = Dt(t), l = Math.PI / 180, c = 180 / Math.PI, u = (Math.hypot(n, i) + Math.hypot(o, a)) / 2, m = 0.5 * (1 - Math.sqrt(u ** 7 / (u ** 7 + 25 ** 7))), [d, h] = [n * (1 + m), o * (1 + m)], [f, p] = [Math.hypot(d, i), Math.hypot(h, a)], g = (U, tt) => {
157
+ if (U === 0 && tt === 0) return 0;
158
+ const X = Math.atan2(tt, U) * c;
159
159
  return X >= 0 ? X : X + 360;
160
- }, [b, w] = [g(d, i), g(h, a)], y = s - e, S = p - f;
160
+ }, [b, w] = [g(d, i), g(h, a)], y = s - e, C = p - f;
161
161
  let M = 0;
162
162
  f * p !== 0 && (M = w - b, M > 180 ? M -= 360 : M < -180 && (M += 360));
163
- const F = 2 * Math.sqrt(f * p) * Math.sin(M * l / 2), _ = (e + s) / 2, $ = (f + p) / 2;
163
+ const F = 2 * Math.sqrt(f * p) * Math.sin(M * l / 2), _ = (e + s) / 2, k = (f + p) / 2;
164
164
  let N = b + w;
165
165
  f * p !== 0 && (Math.abs(b - w) > 180 && (N += b + w < 360 ? 360 : -360), N /= 2);
166
- const T = 1 - 0.17 * Math.cos((N - 30) * l) + 0.24 * Math.cos(2 * N * l) + 0.32 * Math.cos((3 * N + 6) * l) - 0.2 * Math.cos((4 * N - 63) * l), v = 1 + 0.015 * (_ - 50) ** 2 / Math.sqrt(20 + (_ - 50) ** 2), A = 1 + 0.045 * $, k = 1 + 0.015 * $ * T, E = -2 * Math.sqrt($ ** 7 / ($ ** 7 + 25 ** 7)) * Math.sin(60 * Math.exp(-(((N - 275) / 25) ** 2)) * l);
167
- return Math.sqrt((y / v) ** 2 + (S / A) ** 2 + (F / k) ** 2 + E * (S / A) * (F / k));
166
+ const T = 1 - 0.17 * Math.cos((N - 30) * l) + 0.24 * Math.cos(2 * N * l) + 0.32 * Math.cos((3 * N + 6) * l) - 0.2 * Math.cos((4 * N - 63) * l), v = 1 + 0.015 * (_ - 50) ** 2 / Math.sqrt(20 + (_ - 50) ** 2), A = 1 + 0.045 * k, $ = 1 + 0.015 * k * T, E = -2 * Math.sqrt(k ** 7 / (k ** 7 + 25 ** 7)) * Math.sin(60 * Math.exp(-(((N - 275) / 25) ** 2)) * l);
167
+ return Math.sqrt((y / v) ** 2 + (C / A) ** 2 + (F / $) ** 2 + E * (C / A) * (F / $));
168
168
  }
169
169
  const ir = 10;
170
170
  function or(r, t = ir) {
@@ -180,8 +180,8 @@ function or(r, t = ir) {
180
180
  for (const l of e.values())
181
181
  for (let c = 0; c < l.length; c++)
182
182
  for (let u = c + 1; u < l.length; u++) {
183
- if (Dt(l[c].rgb, l[u].rgb) < t) continue;
184
- const d = Dt(jt(l[c].rgb, a), jt(l[u].rgb, a));
183
+ if (Gt(l[c].rgb, l[u].rgb) < t) continue;
184
+ const d = Gt(zt(l[c].rgb, a), zt(l[u].rgb, a));
185
185
  d < t && (n.push({ type: a, a: l[c].entry, b: l[u].entry, distance: d }), i.set(a, (i.get(a) ?? 0) + 1));
186
186
  }
187
187
  let s = null, o = 0;
@@ -198,13 +198,13 @@ function sr(r, t, e, n) {
198
198
  return !1;
199
199
  }
200
200
  const s = new Float64Array(256);
201
- for (let m = 0; m < 256; m++) s[m] = D(m);
201
+ for (let m = 0; m < 256; m++) s[m] = q(m);
202
202
  const o = 1024, a = new Float64Array(o + 1);
203
- for (let m = 0; m <= o; m++) a[m] = at(m / o);
203
+ for (let m = 0; m <= o; m++) a[m] = lt(m / o);
204
204
  const l = (m) => {
205
205
  const d = Math.min(1, Math.max(0, m)) * o, h = Math.floor(d);
206
206
  return h >= o ? a[o] : a[h] + (a[h + 1] - a[h]) * (d - h);
207
- }, c = Ft[n], u = i.data;
207
+ }, c = It[n], u = i.data;
208
208
  for (let m = 0; m < u.length; m += 4) {
209
209
  const d = s[u[m]], h = s[u[m + 1]], f = s[u[m + 2]];
210
210
  u[m] = l(c[0] * d + c[1] * h + c[2] * f), u[m + 1] = l(c[3] * d + c[4] * h + c[5] * f), u[m + 2] = l(c[6] * d + c[7] * h + c[8] * f);
@@ -221,7 +221,7 @@ function ar(r) {
221
221
  n.id = ve(e), n.setAttribute("color-interpolation-filters", "linearRGB");
222
222
  const i = r.createElementNS("http://www.w3.org/2000/svg", "feColorMatrix");
223
223
  i.setAttribute("type", "matrix");
224
- const s = Ft[e];
224
+ const s = It[e];
225
225
  i.setAttribute("values", [s[0], s[1], s[2], 0, 0, s[3], s[4], s[5], 0, 0, s[6], s[7], s[8], 0, 0, 0, 0, 0, 1, 0].join(" ")), n.appendChild(i), t.appendChild(n);
226
226
  }
227
227
  r.body.appendChild(t);
@@ -243,9 +243,9 @@ async function lr(r) {
243
243
  function cr(r) {
244
244
  return [...r.children].filter(
245
245
  (t) => !t.hasAttribute("hidden") && !t.hasAttribute("data-om-carto-marks") && !t.hasAttribute("data-om-carto-flattened") && t.tagName.toLowerCase() !== "style" && t.tagName.toLowerCase() !== "script"
246
- ).map((t, e) => ({ el: t, index: e, z: C(t).z ?? 0 })).sort((t, e) => t.z - e.z || t.index - e.index).map((t) => t.el);
246
+ ).map((t, e) => ({ el: t, index: e, z: S(t).z ?? 0 })).sort((t, e) => t.z - e.z || t.index - e.index).map((t) => t.el);
247
247
  }
248
- async function It(r, t = {}) {
248
+ async function Rt(r, t = {}) {
249
249
  const e = r ?? document.querySelector("om-cartograph");
250
250
  if (!e) throw new Error("[onlymapjs/cartograph] renderCartograph: no <om-cartograph> to render.");
251
251
  const n = [], i = t.dpi ?? (Number(e.getAttribute("dpi")) || 300);
@@ -259,45 +259,45 @@ async function It(r, t = {}) {
259
259
  let d = i;
260
260
  const h = Math.min(u / (l / 25.4), u / (c / 25.4)), f = Math.sqrt(m / (l / 25.4 * (c / 25.4))), p = Math.min(h, f);
261
261
  d > p && (d = Math.floor(p), n.push(`Requested ${i} dpi exceeds this browser's canvas budget for a ${l.toFixed(0)}×${c.toFixed(0)}mm page; rendered at ${d} dpi instead.`)), n.push(...await lr(e)), typeof document < "u" && document.fonts?.ready && await document.fonts.ready;
262
- const g = _t(d), b = Math.max(1, Math.round(l * g.pxPerMm)), w = Math.max(1, Math.round(c * g.pxPerMm)), y = cr(e);
262
+ const g = Ot(d), b = Math.max(1, Math.round(l * g.pxPerMm)), w = Math.max(1, Math.round(c * g.pxPerMm)), y = cr(e);
263
263
  for (const v of y)
264
264
  if (!(!ft(v) || !v.prepareCartograph))
265
265
  try {
266
- await v.prepareCartograph(_t(d));
266
+ await v.prepareCartograph(Ot(d));
267
267
  } catch (A) {
268
268
  v.discardCartograph?.(), n.push(`${v.tagName.toLowerCase()}${v.id ? `#${v.id}` : ""} could not be captured: ${A.message}`);
269
269
  }
270
- const S = document.createElement("canvas");
271
- S.width = b, S.height = w;
272
- const M = S.getContext("2d");
270
+ const C = document.createElement("canvas");
271
+ C.width = b, C.height = w;
272
+ const M = C.getContext("2d");
273
273
  if (!M) throw new Error("[onlymapjs/cartograph] renderCartograph: could not get a 2D canvas context.");
274
274
  const F = typeof getComputedStyle == "function" ? getComputedStyle(e) : null;
275
275
  M.fillStyle = L(F?.backgroundColor) ?? "#ffffff", M.fillRect(0, 0, b, w);
276
276
  for (const v of y) {
277
277
  if (!ft(v)) continue;
278
- const A = C(v);
278
+ const A = S(v);
279
279
  if (M.save(), M.translate((A.x + a) * g.pxPerMm, (A.y + a) * g.pxPerMm), A.rotation) {
280
- const k = A.w / 2 * g.pxPerMm, E = A.h / 2 * g.pxPerMm;
281
- M.translate(k, E), M.rotate(A.rotation * Math.PI / 180), M.translate(-k, -E);
280
+ const $ = A.w / 2 * g.pxPerMm, E = A.h / 2 * g.pxPerMm;
281
+ M.translate($, E), M.rotate(A.rotation * Math.PI / 180), M.translate(-$, -E);
282
282
  }
283
283
  try {
284
284
  v.paintCartograph(M, g);
285
- } catch (k) {
286
- n.push(`${v.tagName.toLowerCase()}${v.id ? `#${v.id}` : ""} failed to render: ${k.message}`);
285
+ } catch ($) {
286
+ n.push(`${v.tagName.toLowerCase()}${v.id ? `#${v.id}` : ""} failed to render: ${$.message}`);
287
287
  }
288
288
  M.restore();
289
289
  }
290
290
  const _ = e.querySelector(":scope > [data-om-carto-marks]");
291
291
  for (const v of _?.querySelectorAll("line") ?? []) {
292
- const A = Number(v.getAttribute("x1")), k = Number(v.getAttribute("y1")), E = Number(v.getAttribute("x2")), U = Number(v.getAttribute("y2"));
293
- [A, k, E, U].every(Number.isFinite) && (M.save(), M.strokeStyle = v.getAttribute("stroke") || "#000000", M.lineWidth = (Number(v.getAttribute("stroke-width")) || 0.2) * g.pxPerMm, M.beginPath(), M.moveTo((A + a) * g.pxPerMm, (k + a) * g.pxPerMm), M.lineTo((E + a) * g.pxPerMm, (U + a) * g.pxPerMm), M.stroke(), M.restore());
292
+ const A = Number(v.getAttribute("x1")), $ = Number(v.getAttribute("y1")), E = Number(v.getAttribute("x2")), U = Number(v.getAttribute("y2"));
293
+ [A, $, E, U].every(Number.isFinite) && (M.save(), M.strokeStyle = v.getAttribute("stroke") || "#000000", M.lineWidth = (Number(v.getAttribute("stroke-width")) || 0.2) * g.pxPerMm, M.beginPath(), M.moveTo((A + a) * g.pxPerMm, ($ + a) * g.pxPerMm), M.lineTo((E + a) * g.pxPerMm, (U + a) * g.pxPerMm), M.stroke(), M.restore());
294
294
  }
295
- const $ = Lt(t.cvd === "page" ? e.getAttribute("cvd") : t.cvd);
296
- $ && !sr(M, b, w, $) && n.push("Colour-vision simulation was skipped: a cross-origin image on the page makes the export canvas unreadable.");
295
+ const k = Ft(t.cvd === "page" ? e.getAttribute("cvd") : t.cvd);
296
+ k && !sr(M, b, w, k) && n.push("Colour-vision simulation was skipped: a cross-origin image on the page makes the export canvas unreadable.");
297
297
  for (const v of y) ft(v) && v.discardCartograph?.();
298
298
  const N = t.format === "jpeg" ? "image/jpeg" : "image/png";
299
299
  N === "image/jpeg" && e.querySelector("om-text") && n.push("JPEG compresses text edges — prefer PNG for a page carrying labels.");
300
- const T = await new Promise((v) => S.toBlob(v, N, t.quality));
300
+ const T = await new Promise((v) => C.toBlob(v, N, t.quality));
301
301
  if (!T) throw new Error("[onlymapjs/cartograph] renderCartograph: the canvas produced no image (it may have exceeded a browser limit).");
302
302
  return { blob: T, widthPx: b, heightPx: w, dpi: d, warnings: n };
303
303
  }
@@ -317,14 +317,14 @@ async function Ce(r, t = {}) {
317
317
  if (!Number.isInteger(m) || m < 0 || m >= i)
318
318
  throw new Error(`[onlymapjs/cartograph] renderCartographAtlas: page ${t.page} is out of range (this atlas has ${i}).`);
319
319
  n.seek(m);
320
- const d = await Gt(e, t, a);
320
+ const d = await qt(e, t, a);
321
321
  return { blob: d.blob, filenames: [o[m]], pages: 1, dpi: d.dpi, warnings: a };
322
322
  }
323
323
  const c = [];
324
324
  let u = t.dpi ?? 300;
325
325
  for (let m = 0; m < i; m++) {
326
326
  n.seek(m);
327
- const d = await Gt(e, t, a);
327
+ const d = await qt(e, t, a);
328
328
  u = d.dpi, c.push({ name: o[m], data: d.blob }), t.onPage?.(m + 1, i);
329
329
  }
330
330
  return { blob: await er(c), filenames: o, pages: i, dpi: u, warnings: a };
@@ -332,27 +332,27 @@ async function Ce(r, t = {}) {
332
332
  n.seek(l);
333
333
  }
334
334
  }
335
- async function Gt(r, t, e) {
335
+ async function qt(r, t, e) {
336
336
  for (const i of r.querySelectorAll("om-frame"))
337
337
  await i.mapElement?.whenSettled?.({ timeout: 2e4 });
338
- const n = await It(r, t);
338
+ const n = await Rt(r, t);
339
339
  return e.push(...n.warnings), n;
340
340
  }
341
341
  const ur = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
342
342
  __proto__: null,
343
343
  MAX_CANVAS_AREA: Se,
344
344
  MAX_CANVAS_DIMENSION: Ae,
345
- renderCartograph: It,
345
+ renderCartograph: Rt,
346
346
  renderCartographAtlas: Ce
347
347
  }, Symbol.toStringTag, { value: "Module" }));
348
- function qt(r, t, e = {}) {
348
+ function Wt(r, t, e = {}) {
349
349
  const n = URL.createObjectURL(r), i = document.createElement("a");
350
350
  i.href = n, i.download = t, document.body.appendChild(i), i.click(), i.remove();
351
351
  const s = e.revokeAfterMs ?? 0;
352
352
  s > 0 ? setTimeout(() => URL.revokeObjectURL(n), s) : URL.revokeObjectURL(n);
353
353
  }
354
354
  const hr = 3e4;
355
- async function Wt(r, t = hr) {
355
+ async function Bt(r, t = hr) {
356
356
  let e = !1;
357
357
  const n = new Promise(
358
358
  (s) => setTimeout(() => {
@@ -380,7 +380,7 @@ async function mr(r, t = {}) {
380
380
  i && r.setAttribute("cvd", i);
381
381
  const s = n.get("export");
382
382
  if (s) {
383
- await Wt(r, t.timeoutMs);
383
+ await Bt(r, t.timeoutMs);
384
384
  const o = s === "jpeg" ? "jpeg" : "png", a = Number(n.get("dpi")) || void 0, l = r.getAttribute("cartograph-id") || "cartograph", c = n.get("page");
385
385
  if (c != null) {
386
386
  const m = r.querySelector("om-atlas");
@@ -390,13 +390,13 @@ async function mr(r, t = {}) {
390
390
  m.refresh?.();
391
391
  const h = await Ce(r, { dpi: a, format: o, page: d - 1 });
392
392
  for (const f of h.warnings) console.warn(`[onlymapjs/cartograph] ${f}`);
393
- return qt(h.blob, h.filenames[0] ?? `${l}.${o === "jpeg" ? "jpg" : "png"}`, { revokeAfterMs: 1e4 }), "export";
393
+ return Wt(h.blob, h.filenames[0] ?? `${l}.${o === "jpeg" ? "jpg" : "png"}`, { revokeAfterMs: 1e4 }), "export";
394
394
  }
395
- const u = await It(r, { dpi: a, format: o });
395
+ const u = await Rt(r, { dpi: a, format: o });
396
396
  for (const m of u.warnings) console.warn(`[onlymapjs/cartograph] ${m}`);
397
- return qt(u.blob, `${l}.${o === "jpeg" ? "jpg" : "png"}`, { revokeAfterMs: 1e4 }), "export";
397
+ return Wt(u.blob, `${l}.${o === "jpeg" ? "jpg" : "png"}`, { revokeAfterMs: 1e4 }), "export";
398
398
  }
399
- return n.get("print") === "1" ? (await Wt(r, t.timeoutMs), typeof r.print == "function" ? await r.print({ dpi: Number(n.get("dpi")) || void 0 }) : typeof window < "u" && window.print(), "print") : i ? "cvd" : null;
399
+ return n.get("print") === "1" ? (await Bt(r, t.timeoutMs), typeof r.print == "function" ? await r.print({ dpi: Number(n.get("dpi")) || void 0 }) : typeof window < "u" && window.print(), "print") : i ? "cvd" : null;
400
400
  }
401
401
  function dr() {
402
402
  if (typeof document > "u") return;
@@ -450,34 +450,34 @@ class R extends fr {
450
450
  a != null && Number.isInteger(a) ? this.style.zIndex = String(a) : this.style.removeProperty("z-index");
451
451
  }
452
452
  }
453
- const pt = "cartograph/2", qn = ["default", "dark", "sepia", "blueprint", "minimal"], Bt = ["A0", "A1", "A2", "A3", "A4", "A5", "Letter", "Legal"], gr = /* @__PURE__ */ new Map([
453
+ const pt = "cartograph/2", Wn = ["default", "dark", "sepia", "blueprint", "minimal"], Vt = ["A0", "A1", "A2", "A3", "A4", "A5", "Letter", "Legal"], gr = /* @__PURE__ */ new Map([
454
454
  ["projection", "live frames render Web Mercator (EPSG:3857) only — Globe support is design-only; use a static frame for other projections"]
455
- ]), j = ["id", "x", "y", "w", "h", "rotation", "z", "locked", "hidden"], P = {
455
+ ]), z = ["id", "x", "y", "w", "h", "rotation", "z", "locked", "hidden"], P = {
456
456
  "om-cartograph": ["cartograph-id", "format", "size", "width", "height", "orientation", "theme", "title", "attribution", "notes", "cvd", "bleed", "crop-marks", "safe-zone", "dpi", "flatten", "color-profile", "allow-url-actions"],
457
- "om-frame": [...j, "src", "mode", "center", "zoom", "bearing", "pitch", "dpi", "crs", "corners", "crs-def", "overview-of", "overview-stroke", "atlas-fit", "atlas-margin", "frame-stroke", "frame-bg"],
458
- "om-legend": [...j, "for", "title", "columns", "derived"],
457
+ "om-frame": [...z, "src", "mode", "center", "zoom", "bearing", "pitch", "dpi", "crs", "corners", "crs-def", "overview-of", "overview-stroke", "atlas-fit", "atlas-margin", "frame-stroke", "frame-bg"],
458
+ "om-legend": [...z, "for", "title", "columns", "derived"],
459
459
  "om-legend-row": ["layer", "match", "label", "hide", "order", "color", "shape"],
460
460
  // NOTE: the discriminator on furniture is `kind`, never `style` — `style` is
461
461
  // the global HTML attribute the runtime itself writes for mm placement, so
462
462
  // `style="double"` would be erased on the first render. `kind` also matches
463
463
  // om-text/om-shape, so the whole vocabulary has ONE discriminator word.
464
- "om-scalebar": [...j, "for", "units", "segments", "segment-length", "kind"],
465
- "om-north": [...j, "for", "kind"],
466
- "om-graticule": [...j, "for", "crs", "crs-def", "interval", "interval-x", "interval-y", "kind", "labels", "format"],
467
- "om-text": [...j, "kind", "font-size", "weight", "align", "font", "color", "bg"],
468
- "om-shape": [...j, "kind", "fill", "fill-opacity", "stroke", "stroke-width", "radius"],
469
- "om-image": [...j, "src", "fit"],
464
+ "om-scalebar": [...z, "for", "units", "segments", "segment-length", "kind"],
465
+ "om-north": [...z, "for", "kind"],
466
+ "om-graticule": [...z, "for", "crs", "crs-def", "interval", "interval-x", "interval-y", "kind", "labels", "format"],
467
+ "om-text": [...z, "kind", "font-size", "weight", "align", "font", "color", "bg"],
468
+ "om-shape": [...z, "kind", "fill", "fill-opacity", "stroke", "stroke-width", "radius"],
469
+ "om-image": [...z, "src", "fit"],
470
470
  "om-atlas": ["id", "for", "layer", "filter", "sort", "filename", "page-name"]
471
471
  }, gt = Object.keys(P), br = ["metric", "imperial", "nautical"], yr = 0.3048, wr = 1609.344, Mr = 1852;
472
472
  function vr(r) {
473
473
  return r != null && br.includes(r) ? r : null;
474
474
  }
475
- function $e(r) {
475
+ function ke(r) {
476
476
  if (!isFinite(r) || r <= 0) return 0;
477
477
  const t = Math.pow(10, Math.floor(Math.log10(r))), e = r / t;
478
478
  return (e >= 5 ? 5 : e >= 2 ? 2 : 1) * t;
479
479
  }
480
- const Vt = {
480
+ const Ht = {
481
481
  // Finest first; the largest tier whose snapped length is ≥ 1 unit wins.
482
482
  metric: [
483
483
  { metersPerUnit: 1, label: "m" },
@@ -489,15 +489,15 @@ const Vt = {
489
489
  ],
490
490
  nautical: [{ metersPerUnit: Mr, label: "nmi" }]
491
491
  };
492
- function ke({ groundMetersPerMm: r, maxWidthMm: t, segments: e = 4, units: n = "metric", segmentLengthMeters: i }) {
492
+ function $e({ groundMetersPerMm: r, maxWidthMm: t, segments: e = 4, units: n = "metric", segmentLengthMeters: i }) {
493
493
  if (!Number.isFinite(r) || r <= 0 || !Number.isFinite(t) || t <= 0) return null;
494
- const s = Number.isInteger(e) && e > 0 ? e : 4, o = Vt[n] ?? Vt.metric, a = t / s * r;
494
+ const s = Number.isInteger(e) && e > 0 ? e : 4, o = Ht[n] ?? Ht.metric, a = t / s * r;
495
495
  let l, c;
496
496
  if (i != null && Number.isFinite(i) && i > 0)
497
- l = i, c = Ht(o, l);
497
+ l = i, c = Yt(o, l);
498
498
  else {
499
- c = Ht(o, a);
500
- const f = $e(a / c.metersPerUnit);
499
+ c = Yt(o, a);
500
+ const f = ke(a / c.metersPerUnit);
501
501
  if (f <= 0) return null;
502
502
  l = f * c.metersPerUnit;
503
503
  }
@@ -558,7 +558,7 @@ function Ar(r, t, e) {
558
558
  }
559
559
  return { bars: c, strokes: u, labels: f, fontMm: n, strokeMm: i, segmentMeters: r.segmentMeters, unitLabel: r.unitLabel, scaleDenominator: r.scaleDenominator };
560
560
  }
561
- function Ht(r, t) {
561
+ function Yt(r, t) {
562
562
  let e = r[0];
563
563
  for (const n of r)
564
564
  t / n.metersPerUnit >= 1 && (e = n);
@@ -588,11 +588,11 @@ function Ne(r, t) {
588
588
  return o === void 0 ? (e.push(s), i) : o;
589
589
  }), unresolved: e };
590
590
  }
591
- function $r(r) {
591
+ function kr(r) {
592
592
  return [...r.matchAll(Ee)].map((t) => t[1]);
593
593
  }
594
- const Yt = /* @__PURE__ */ new WeakMap();
595
- function kr(r, t) {
594
+ const Kt = /* @__PURE__ */ new WeakMap();
595
+ function $r(r, t) {
596
596
  const e = [], n = r.ownerDocument ?? (typeof document < "u" ? document : null);
597
597
  if (!n) return e;
598
598
  const i = n.createTreeWalker(
@@ -602,10 +602,10 @@ function kr(r, t) {
602
602
  ), s = [];
603
603
  for (let o = i.nextNode(); o; o = i.nextNode()) s.push(o);
604
604
  for (const o of s) {
605
- let a = Yt.get(o);
605
+ let a = Kt.get(o);
606
606
  if (a === void 0) {
607
607
  if (a = o.data, !a.includes("{{")) continue;
608
- Yt.set(o, a);
608
+ Kt.set(o, a);
609
609
  }
610
610
  const l = Ne(a, t);
611
611
  o.data !== l.text && (o.data = l.text), e.push(...l.unresolved);
@@ -639,7 +639,7 @@ function O(r) {
639
639
  const t = r.getAttribute("for");
640
640
  return t ? Te(r, t) : Nr(r);
641
641
  }
642
- function G(r, t) {
642
+ function W(r, t) {
643
643
  let e = r.querySelector(`:scope > [${Et}]`);
644
644
  if (!e) {
645
645
  for (const n of [...r.children])
@@ -651,7 +651,7 @@ function G(r, t) {
651
651
  function Pr(r) {
652
652
  r.querySelector(`:scope > [${Et}]`)?.remove();
653
653
  }
654
- const Kt = "data-om-carto-page", Xt = "data-om-carto-marks", bt = "data-om-carto-credit", yt = "Built with OnlyMap by NIKA · free for non-commercial use", et = 2, Zt = 1.2, wt = 2.4, Jt = 1.5, Mt = 1.2, Qt = 0.3, te = 0.8, vt = "http://www.w3.org/2000/svg", Tr = 6e4;
654
+ const Xt = "data-om-carto-page", Zt = "data-om-carto-marks", bt = "data-om-carto-credit", yt = "Built with OnlyMap by NIKA · free for non-commercial use", rt = 2, Jt = 1.2, wt = 2.4, Qt = 1.5, Mt = 1.2, te = 0.3, ee = 0.8, vt = "http://www.w3.org/2000/svg", Tr = 6e4;
655
655
  class Fe extends R {
656
656
  static observedAttributes = [...P["om-cartograph"]];
657
657
  frameListenerBound = !1;
@@ -689,7 +689,7 @@ class Fe extends R {
689
689
  * runtime's job (issue #41 §9: the om-map carries the key).
690
690
  */
691
691
  renderCredit() {
692
- const t = H();
692
+ const t = G();
693
693
  t && !this.unsubscribeLicense && typeof t.subscribeLicense == "function" && (this.unsubscribeLicense = t.subscribeLicense(() => this.renderCredit()));
694
694
  const e = t ? t.getEntitlements().hideBadge : !1, n = [...this.querySelectorAll("om-text")].some((o) => /onlymap/i.test(o.textContent ?? "")), i = this.querySelector(`:scope > [${bt}]`);
695
695
  if (e || n) {
@@ -701,15 +701,15 @@ class Fe extends R {
701
701
  return;
702
702
  }
703
703
  const s = this.ownerDocument.createElement("div");
704
- s.setAttribute(bt, ""), s.setAttribute("z", "2147483644"), s.textContent = yt, s.style.cssText = `position:absolute;left:${et}mm;bottom:${Zt}mm;z-index:2147483644;font:${wt}mm/${Jt} system-ui,sans-serif;color:#374151;background:rgba(255,255,255,.72);padding:${Qt}mm ${Mt}mm;border-radius:${te}mm;pointer-events:none;`, this.armCreditPainter(s), this.appendChild(s);
704
+ s.setAttribute(bt, ""), s.setAttribute("z", "2147483644"), s.textContent = yt, s.style.cssText = `position:absolute;left:${rt}mm;bottom:${Jt}mm;z-index:2147483644;font:${wt}mm/${Qt} system-ui,sans-serif;color:#374151;background:rgba(255,255,255,.72);padding:${te}mm ${Mt}mm;border-radius:${ee}mm;pointer-events:none;`, this.armCreditPainter(s), this.appendChild(s);
705
705
  }
706
706
  /** Give the runtime-owned DOM credit the same canvas paint contract as authored furniture. */
707
707
  armCreditPainter(t) {
708
708
  t.paintCartograph = (e, n) => {
709
- const i = (c) => c * n.pxPerMm, o = wt * Jt + Qt * 2, a = this.pageSize.heightMm - Zt - o;
709
+ const i = (c) => c * n.pxPerMm, o = wt * Qt + te * 2, a = this.pageSize.heightMm - Jt - o;
710
710
  e.save(), e.font = `${i(wt)}px system-ui, sans-serif`;
711
711
  const l = e.measureText(yt).width / n.pxPerMm + Mt * 2;
712
- e.fillStyle = "rgba(255,255,255,.72)", e.beginPath(), typeof e.roundRect == "function" ? e.roundRect(i(et), i(a), i(l), i(o), i(te)) : e.rect(i(et), i(a), i(l), i(o)), e.fill(), e.fillStyle = "#374151", e.textAlign = "left", e.textBaseline = "middle", e.fillText(yt, i(et + Mt), i(a + o / 2)), e.restore();
712
+ e.fillStyle = "rgba(255,255,255,.72)", e.beginPath(), typeof e.roundRect == "function" ? e.roundRect(i(rt), i(a), i(l), i(o), i(ee)) : e.rect(i(rt), i(a), i(l), i(o)), e.fill(), e.fillStyle = "#374151", e.textAlign = "left", e.textBaseline = "middle", e.fillText(yt, i(rt + Mt), i(a + o / 2)), e.restore();
713
713
  };
714
714
  }
715
715
  /**
@@ -795,8 +795,8 @@ class Fe extends R {
795
795
  renderNow() {
796
796
  const { widthMm: t, heightMm: e } = this.pageSize, n = this.bleedMm;
797
797
  this.style.display = "block", this.style.position = "relative", this.style.width = `${t}mm`, this.style.height = `${e}mm`, this.style.margin = n > 0 ? `${n}mm` : "", this.style.overflow = n > 0 ? "visible" : "hidden";
798
- let i = this.querySelector(`style[${Kt}]`);
799
- i || (i = document.createElement("style"), i.setAttribute(Kt, ""), this.prepend(i));
798
+ let i = this.querySelector(`style[${Xt}]`);
799
+ i || (i = document.createElement("style"), i.setAttribute(Xt, ""), this.prepend(i));
800
800
  const s = t + n * 2, o = e + n * 2;
801
801
  i.textContent = `@page { size: ${s}mm ${o}mm; margin: 0; }
802
802
  @media print { html, body { margin: 0; padding: 0; } om-cartograph { break-after: page; } }`, this.renderPrintMarks(t, e, n), this.applyCvd(), this.refreshTokens(), this.renderCredit();
@@ -811,13 +811,13 @@ class Fe extends R {
811
811
  * worse than no guide.
812
812
  */
813
813
  renderPrintMarks(t, e, n) {
814
- const i = this.hasAttribute("crop-marks") && n > 0, s = Number(this.getAttribute("safe-zone")), o = Number.isFinite(s) && s > 0, a = this.querySelector(`:scope > [${Xt}]`);
814
+ const i = this.hasAttribute("crop-marks") && n > 0, s = Number(this.getAttribute("safe-zone")), o = Number.isFinite(s) && s > 0, a = this.querySelector(`:scope > [${Zt}]`);
815
815
  if (!i && !o) {
816
816
  a?.remove();
817
817
  return;
818
818
  }
819
819
  const l = this.ownerDocument, c = a ?? l.createElementNS(vt, "svg");
820
- if (c.setAttribute(Xt, ""), c.setAttribute("viewBox", `${-n} ${-n} ${t + n * 2} ${e + n * 2}`), c.setAttribute("width", `${t + n * 2}mm`), c.setAttribute("height", `${e + n * 2}mm`), c.style.cssText = `position:absolute;left:${-n}mm;top:${-n}mm;pointer-events:none;z-index:2147483646;`, c.replaceChildren(), i) {
820
+ if (c.setAttribute(Zt, ""), c.setAttribute("viewBox", `${-n} ${-n} ${t + n * 2} ${e + n * 2}`), c.setAttribute("width", `${t + n * 2}mm`), c.setAttribute("height", `${e + n * 2}mm`), c.style.cssText = `position:absolute;left:${-n}mm;top:${-n}mm;pointer-events:none;z-index:2147483646;`, c.replaceChildren(), i) {
821
821
  const u = Math.min(n, 4), m = Math.min(n * 0.35, 1.5), d = [];
822
822
  for (const h of [0, t])
823
823
  for (const f of [0, e]) {
@@ -844,7 +844,7 @@ class Fe extends R {
844
844
  * injected only when a page actually asks for one.
845
845
  */
846
846
  applyCvd() {
847
- const t = Lt(this.getAttribute("cvd"));
847
+ const t = Ft(this.getAttribute("cvd"));
848
848
  if (!t) {
849
849
  this.style.removeProperty("filter");
850
850
  return;
@@ -883,7 +883,7 @@ function Lr({ text: r, maxWidth: t, fontSizePx: e, lineHeightPx: n, measure: i }
883
883
  c.baselineY = a + u * s, c.width > l && (l = c.width);
884
884
  }), { lines: o, lineHeight: s, maxWidth: l };
885
885
  }
886
- function Wn(r) {
886
+ function Bn(r) {
887
887
  if (typeof document > "u") return null;
888
888
  const e = document.createElement("canvas").getContext("2d");
889
889
  return e ? (e.font = r, (n) => e.measureText(n).width) : null;
@@ -911,16 +911,16 @@ class Ie extends R {
911
911
  /** Re-run token substitution from the authored templates. */
912
912
  resolveTokens() {
913
913
  const t = this.closest("om-cartograph");
914
- t && typeof t.tokenContext == "function" && kr(this, t.tokenContext());
914
+ t && typeof t.tokenContext == "function" && $r(this, t.tokenContext());
915
915
  }
916
916
  paintCartograph(t, e) {
917
- const { w: n, h: i } = C(this), s = n * e.pxPerMm, o = i * e.pxPerMm;
917
+ const { w: n, h: i } = S(this), s = n * e.pxPerMm, o = i * e.pxPerMm;
918
918
  if (s <= 0 || o <= 0) return;
919
919
  const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = L(a?.backgroundColor);
920
920
  l && (t.fillStyle = l, t.fillRect(0, 0, s, o));
921
921
  const c = (this.textContent ?? "").trim();
922
922
  if (c === "") return;
923
- const u = kt(a?.fontSize, 12), m = a?.lineHeight === "normal" ? u * 1.4 : kt(a?.lineHeight, u * 1.4), d = a?.fontFamily || "system-ui, sans-serif", h = a?.fontWeight || "400", f = u * e.scale, p = m * e.scale, g = `${h} ${f}px ${d}`;
923
+ const u = $t(a?.fontSize, 12), m = a?.lineHeight === "normal" ? u * 1.4 : $t(a?.lineHeight, u * 1.4), d = a?.fontFamily || "system-ui, sans-serif", h = a?.fontWeight || "400", f = u * e.scale, p = m * e.scale, g = `${h} ${f}px ${d}`;
924
924
  t.save(), t.font = g, t.fillStyle = L(a?.color) ?? "#000", t.textBaseline = "alphabetic", t.textAlign = "left";
925
925
  const b = Lr({
926
926
  text: c,
@@ -939,15 +939,15 @@ class Ie extends R {
939
939
  x("om-text", Ie);
940
940
  const Ir = 63710087714e-4;
941
941
  let Rr = Ir;
942
- const rt = Math.PI / 180;
942
+ const nt = Math.PI / 180;
943
943
  function Re(r, t, e = Rr) {
944
- const n = (t[1] - r[1]) * rt, i = (t[0] - r[0]) * rt, s = r[1] * rt, o = t[1] * rt, a = Math.sin(n / 2) ** 2 + Math.cos(s) * Math.cos(o) * Math.sin(i / 2) ** 2;
944
+ const n = (t[1] - r[1]) * nt, i = (t[0] - r[0]) * nt, s = r[1] * nt, o = t[1] * nt, a = Math.sin(n / 2) ** 2 + Math.cos(s) * Math.cos(o) * Math.sin(i / 2) ** 2;
945
945
  return 2 * e * Math.asin(Math.min(1, Math.sqrt(a)));
946
946
  }
947
- const ut = 6378137, ee = Math.PI / 180, Nt = 180 / Math.PI, re = 85.0511287798066;
947
+ const ut = 6378137, re = Math.PI / 180, Nt = 180 / Math.PI, ne = 85.0511287798066;
948
948
  function _r([r, t]) {
949
- const e = Math.max(-re, Math.min(re, t));
950
- return [ut * r * ee, ut * Math.log(Math.tan(Math.PI / 4 + e * ee / 2))];
949
+ const e = Math.max(-ne, Math.min(ne, t));
950
+ return [ut * r * re, ut * Math.log(Math.tan(Math.PI / 4 + e * re / 2))];
951
951
  }
952
952
  function Or([r, t]) {
953
953
  return [r / ut * Nt, (2 * Math.atan(Math.exp(t / ut)) - Math.PI / 2) * Nt];
@@ -976,14 +976,14 @@ async function Oe(r, t) {
976
976
  inverse: (l) => a.forward(l)
977
977
  };
978
978
  }
979
- function ne(r, t) {
979
+ function ie(r, t) {
980
980
  return !Number.isInteger(r) || r < 1 || r > 60 ? null : `+proj=utm +zone=${r}${t === "S" ? " +south" : ""} +datum=WGS84 +units=m +no_defs`;
981
981
  }
982
982
  async function jr(r) {
983
983
  const t = Number(/^EPSG:(\d+)$/.exec(r)?.[1]);
984
984
  if (!Number.isFinite(t)) return null;
985
- if (t >= 32601 && t <= 32660) return ne(t - 32600, "N");
986
- if (t >= 32701 && t <= 32760) return ne(t - 32700, "S");
985
+ if (t >= 32601 && t <= 32660) return ie(t - 32600, "N");
986
+ if (t >= 32701 && t <= 32760) return ie(t - 32700, "S");
987
987
  const { CRS_DEFS: e } = await import("./crs-DsDQ4Q4i.js");
988
988
  return e[t]?.def ?? null;
989
989
  }
@@ -1015,7 +1015,7 @@ function Dr(r, t) {
1015
1015
  const u = (m) => [m[0] / s + e, m[1] / s + n];
1016
1016
  return { matrix: [c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], 1], normalize: o, denormalize: u };
1017
1017
  }
1018
- function ie(r, [t, e]) {
1018
+ function oe(r, [t, e]) {
1019
1019
  const n = r[6] * t + r[7] * e + r[8];
1020
1020
  return Math.abs(n) < 1e-12 ? null : [(r[0] * t + r[1] * e + r[2]) / n, (r[3] * t + r[4] * e + r[5]) / n];
1021
1021
  }
@@ -1033,7 +1033,7 @@ function Gr(r) {
1033
1033
  (t * s - e * i) / u
1034
1034
  ];
1035
1035
  }
1036
- function oe(r, t) {
1036
+ function se(r, t) {
1037
1037
  let e = r;
1038
1038
  for (; e - t > 180; ) e -= 360;
1039
1039
  for (; t - e > 180; ) e += 360;
@@ -1044,7 +1044,7 @@ const qr = (r) => {
1044
1044
  return t === -180 && (t = 180), t;
1045
1045
  };
1046
1046
  function ht({ corners: r, widthMm: t, heightMm: e, crsForward: n }) {
1047
- const i = n ?? _e, s = r[0][0], o = r.map(([h, f]) => [oe(h, s), f]), a = o.map((h) => i.forward(h)), l = [
1047
+ const i = n ?? _e, s = r[0][0], o = r.map(([h, f]) => [se(h, s), f]), a = o.map((h) => i.forward(h)), l = [
1048
1048
  [0, 0],
1049
1049
  [t, 0],
1050
1050
  [t, e],
@@ -1057,12 +1057,12 @@ function ht({ corners: r, widthMm: t, heightMm: e, crsForward: n }) {
1057
1057
  degenerate: m,
1058
1058
  project(h) {
1059
1059
  if (!c) return null;
1060
- const f = i.forward([oe(h[0], s), h[1]]), p = ie(c.matrix, c.normalize(f));
1060
+ const f = i.forward([se(h[0], s), h[1]]), p = oe(c.matrix, c.normalize(f));
1061
1061
  return p && Number.isFinite(p[0]) && Number.isFinite(p[1]) ? { xMm: p[0], yMm: p[1] } : null;
1062
1062
  },
1063
1063
  unproject(h, f) {
1064
1064
  if (!c || !u) return null;
1065
- const p = ie(u, [h, f]);
1065
+ const p = oe(u, [h, f]);
1066
1066
  if (!p) return null;
1067
1067
  const g = i.inverse(c.denormalize(p));
1068
1068
  return Number.isFinite(g[0]) && Number.isFinite(g[1]) ? [qr(g[0]), g[1]] : null;
@@ -1130,7 +1130,7 @@ function Br(r) {
1130
1130
  const i = Math.min(...n), s = Math.max(...n);
1131
1131
  return i > 0 ? (s - i) / i : null;
1132
1132
  }
1133
- function Bn(r, t, e, n) {
1133
+ function Vn(r, t, e, n) {
1134
1134
  return [
1135
1135
  [r, n],
1136
1136
  [e, n],
@@ -1170,7 +1170,7 @@ async function Yr(r, t = document) {
1170
1170
  if (!o) throw new Error(`${r} could not be adopted`);
1171
1171
  return o;
1172
1172
  }
1173
- function lt(r) {
1173
+ function Q(r) {
1174
1174
  const t = r.getAttribute("center"), e = r.getAttribute("zoom");
1175
1175
  if (!t || e == null || e.trim() === "") return null;
1176
1176
  const n = Number(e);
@@ -1191,7 +1191,18 @@ function lt(r) {
1191
1191
  pitch: Number(r.getAttribute("pitch")) || 0
1192
1192
  };
1193
1193
  }
1194
- function se(r, t, e, n) {
1194
+ function Kr(r, t, e, n, i = 60) {
1195
+ const s = (l) => Pt(r, { ...t, pitch: l }, e, n) !== null;
1196
+ if (s(i)) return i;
1197
+ if (!s(0)) return 0;
1198
+ let o = 0, a = i;
1199
+ for (; a - o > 1; ) {
1200
+ const l = Math.floor((o + a) / 2);
1201
+ s(l) ? o = l : a = l;
1202
+ }
1203
+ return o;
1204
+ }
1205
+ function Pt(r, t, e, n) {
1195
1206
  if (!(e > 0) || !(n > 0)) return null;
1196
1207
  const i = new r.WebMercatorViewport({
1197
1208
  width: e,
@@ -1214,7 +1225,7 @@ function se(r, t, e, n) {
1214
1225
  }
1215
1226
  return o;
1216
1227
  }
1217
- async function Kr(r) {
1228
+ async function Xr(r) {
1218
1229
  const t = await we(), e = r.querySelector(":scope > om-map");
1219
1230
  if (e) return { core: t, map: e };
1220
1231
  const n = r.getAttribute("src");
@@ -1223,9 +1234,9 @@ async function Kr(r) {
1223
1234
  return { core: t, map: i };
1224
1235
  }
1225
1236
  function At(r, t) {
1226
- r.setAttribute("center", JSON.stringify(t.center)), r.setAttribute("zoom", String(t.zoom)), r.setAttribute("bearing", String(t.bearing)), r.setAttribute("pitch", String(t.pitch)), Xr(r, t);
1237
+ r.setAttribute("center", JSON.stringify(t.center)), r.setAttribute("zoom", String(t.zoom)), r.setAttribute("bearing", String(t.bearing)), r.setAttribute("pitch", String(t.pitch)), Zr(r, t);
1227
1238
  }
1228
- function Xr(r, t) {
1239
+ function Zr(r, t) {
1229
1240
  const e = r;
1230
1241
  typeof e.setViewInternal == "function" ? e.setViewInternal({ longitude: t.center[0], latitude: t.center[1], zoom: t.zoom, pitch: t.pitch, bearing: t.bearing }) : typeof e.flyTo == "function" && e.flyTo(t.center, t.zoom, { duration: 0 });
1231
1242
  }
@@ -1281,7 +1292,7 @@ class Ue extends R {
1281
1292
  * than caching it correctly.
1282
1293
  */
1283
1294
  get georef() {
1284
- const { w: t, h: e } = C(this);
1295
+ const { w: t, h: e } = S(this);
1285
1296
  if (t <= 0 || e <= 0) return null;
1286
1297
  if (this.mode === "live")
1287
1298
  return this.liveCorners ? ht({ corners: this.liveCorners, widthMm: t, heightMm: e }) : null;
@@ -1350,25 +1361,27 @@ class Ue extends R {
1350
1361
  // Live
1351
1362
  // -------------------------------------------------------------------------
1352
1363
  renderLive() {
1353
- const t = lt(this);
1354
- if (!t) {
1364
+ const t = this.raster;
1365
+ t && (t.style.display = "none");
1366
+ const e = Q(this);
1367
+ if (!e) {
1355
1368
  this.showPlaceholder("no-camera", 'Live frame needs its own camera — center="[lng, lat]" and zoom=.');
1356
1369
  return;
1357
1370
  }
1358
- this.updateLiveCorners(t);
1359
- const e = this.liveSource();
1371
+ this.updateLiveCorners(e);
1372
+ const n = this.liveSource();
1360
1373
  if (this.liveMap)
1361
- if (this.mountedSource !== e)
1374
+ if (this.mountedSource !== n)
1362
1375
  this.releaseLiveMap();
1363
1376
  else {
1364
- At(this.liveMap, t), this.sizeLiveMap();
1377
+ At(this.liveMap, e), this.sizeLiveMap();
1365
1378
  return;
1366
1379
  }
1367
1380
  if (this.mounting) {
1368
- if (this.mountingSource === e) return;
1381
+ if (this.mountingSource === n) return;
1369
1382
  this.abandonMount();
1370
1383
  }
1371
- this.mountLive(e);
1384
+ this.mountLive(n);
1372
1385
  }
1373
1386
  /** Inline maps are identified by node identity; fetched maps by their src=. */
1374
1387
  liveSource() {
@@ -1383,11 +1396,11 @@ class Ue extends R {
1383
1396
  releaseLiveMap() {
1384
1397
  this.liveMapOwned ? this.liveMap?.remove() : this.liveMap && (this.liveMap.hidden = !0), this.liveMap = null, this.liveMapOwned = !1, this.mountedSource = null, this.liveCorners = null, this.captureImage = null;
1385
1398
  }
1386
- updateLiveCorners(t = lt(this)) {
1399
+ updateLiveCorners(t = Q(this)) {
1387
1400
  if (!t) return;
1388
- const e = H();
1401
+ const e = G();
1389
1402
  if (!e) return;
1390
- const { w: n, h: i } = C(this), s = se(e, t, n * W, i * W);
1403
+ const { w: n, h: i } = S(this), s = Pt(e, t, n * j, i * j);
1391
1404
  this.liveCorners = s, s ? this.lastError === "degenerate-view" && this.clearPlaceholder() : this.showPlaceholder(
1392
1405
  "degenerate-view",
1393
1406
  "This camera cannot be georeferenced — the frame's top edge reaches the horizon. Reduce pitch below ~60°."
@@ -1397,15 +1410,15 @@ class Ue extends R {
1397
1410
  const e = ++this.mountToken;
1398
1411
  this.mounting = !0, this.mountingSource = t;
1399
1412
  try {
1400
- const { core: n, map: i } = await Kr(this);
1413
+ const { core: n, map: i } = await Xr(this);
1401
1414
  if (e !== this.mountToken || !this.isConnected || this.mode !== "live" || this.liveSource() !== t) return;
1402
- const s = lt(this);
1415
+ const s = Q(this);
1403
1416
  if (!s) return;
1404
1417
  At(i, s);
1405
1418
  const o = i;
1406
1419
  o.style.position = "absolute", o.style.inset = "0", o.style.display = "block", this.liveMapOwned = i.parentElement !== this, this.liveMapOwned && this.appendChild(i), i.setAttribute("data-om-carto-frame", ""), this.liveMap = o, this.mountedSource = t, this.sizeLiveMap(), this.clearPlaceholder();
1407
- const { w: a, h: l } = C(this);
1408
- if (this.liveCorners = se(n, s, a * W, l * W), await o.ready, e !== this.mountToken || (At(i, s), await o.whenSettled?.({ timeout: 2e4 }), e !== this.mountToken)) return;
1420
+ const { w: a, h: l } = S(this);
1421
+ if (this.liveCorners = Pt(n, s, a * j, l * j), await o.ready, e !== this.mountToken || (At(i, s), await o.whenSettled?.({ timeout: 2e4 }), e !== this.mountToken)) return;
1409
1422
  this.signalReady();
1410
1423
  } catch (n) {
1411
1424
  if (e !== this.mountToken) return;
@@ -1416,7 +1429,22 @@ class Ue extends R {
1416
1429
  }
1417
1430
  }
1418
1431
  sizeLiveMap() {
1419
- this.liveMap && (this.liveMap.style.width = "100%", this.liveMap.style.height = "100%", this.liveMap.hidden = this.printing);
1432
+ this.liveMap && (this.liveMap.style.width = "100%", this.liveMap.style.height = "100%", this.liveMap.hidden = this.printing, this.capMapPitch());
1433
+ }
1434
+ /**
1435
+ * Stop the adopted map tilting past what this frame can georeference.
1436
+ *
1437
+ * A frame without a georeference has no scale bar, no north arrow, no
1438
+ * graticule and no export — so letting a host drive the camera past the
1439
+ * limit produces a frame that renders an error instead of a map. The ceiling
1440
+ * is the frame's own, recomputed whenever its box changes, because it
1441
+ * depends on the box's aspect and the current zoom.
1442
+ */
1443
+ capMapPitch() {
1444
+ const t = G(), e = Q(this);
1445
+ if (!t || !e || !this.liveMap) return;
1446
+ const { w: n, h: i } = S(this), s = Kr(t, e, n * j, i * j);
1447
+ s >= 60 ? this.liveMap.removeAttribute("max-pitch") : this.liveMap.setAttribute("max-pitch", String(s));
1420
1448
  }
1421
1449
  // -------------------------------------------------------------------------
1422
1450
  // Locator inset (overview-of)
@@ -1438,7 +1466,7 @@ class Ue extends R {
1438
1466
  e?.remove();
1439
1467
  return;
1440
1468
  }
1441
- const { w: o, h: a } = C(this), l = [], [c, u, m, d] = s.corners, h = [
1469
+ const { w: o, h: a } = S(this), l = [], [c, u, m, d] = s.corners, h = [
1442
1470
  [c, u],
1443
1471
  [u, m],
1444
1472
  [m, d],
@@ -1446,7 +1474,7 @@ class Ue extends R {
1446
1474
  ];
1447
1475
  for (const [b, w] of h)
1448
1476
  for (let y = 0; y < le; y++) {
1449
- const S = y / le, M = [b[0] + (w[0] - b[0]) * S, b[1] + (w[1] - b[1]) * S], F = i.project(M);
1477
+ const C = y / le, M = [b[0] + (w[0] - b[0]) * C, b[1] + (w[1] - b[1]) * C], F = i.project(M);
1450
1478
  F && l.push(`${F.xMm.toFixed(3)},${F.yMm.toFixed(3)}`);
1451
1479
  }
1452
1480
  if (l.length < 3) {
@@ -1504,11 +1532,11 @@ class Ue extends R {
1504
1532
  * follows from the same source as any authored camera.
1505
1533
  */
1506
1534
  fitBounds(t) {
1507
- const [e, n, i, s] = t, { w: o, h: a } = C(this);
1535
+ const [e, n, i, s] = t, { w: o, h: a } = S(this);
1508
1536
  if (o <= 0 || a <= 0) return;
1509
- const l = H();
1537
+ const l = G();
1510
1538
  if (!l) return;
1511
- const c = new l.WebMercatorViewport({ width: o * W, height: a * W, longitude: 0, latitude: 0, zoom: 0 }).fitBounds([
1539
+ const c = new l.WebMercatorViewport({ width: o * j, height: a * j, longitude: 0, latitude: 0, zoom: 0 }).fitBounds([
1512
1540
  [e, n],
1513
1541
  [i, s]
1514
1542
  ]);
@@ -1537,7 +1565,7 @@ class Ue extends R {
1537
1565
  this.printing = !1, this.querySelector(":scope > img[data-om-carto-print]")?.remove(), this.liveMap && (this.liveMap.hidden = !1);
1538
1566
  }
1539
1567
  paintCartograph(t, e) {
1540
- const { w: n, h: i } = C(this), s = n * e.pxPerMm, o = i * e.pxPerMm;
1568
+ const { w: n, h: i } = S(this), s = n * e.pxPerMm, o = i * e.pxPerMm;
1541
1569
  if (s <= 0 || o <= 0) return;
1542
1570
  const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = L(a?.backgroundColor);
1543
1571
  l && (t.fillStyle = l, t.fillRect(0, 0, s, o));
@@ -1555,14 +1583,14 @@ class Ue extends R {
1555
1583
  }
1556
1584
  }
1557
1585
  x("om-frame", Ue);
1558
- const nt = "http://www.w3.org/2000/svg", Zr = ["single", "double", "line", "ticks"];
1586
+ const it = "http://www.w3.org/2000/svg", Jr = ["single", "double", "line", "ticks"];
1559
1587
  class je extends R {
1560
1588
  static observedAttributes = [...P["om-scalebar"]];
1561
1589
  /** The geometry currently drawn — reused by the canvas exporter. */
1562
1590
  get drawing() {
1563
1591
  const e = O(this)?.georef;
1564
1592
  if (!e) return null;
1565
- const { w: n, h: i } = C(this), s = ke({
1593
+ const { w: n, h: i } = S(this), s = $e({
1566
1594
  groundMetersPerMm: e.groundMetersPerMm(),
1567
1595
  maxWidthMm: n,
1568
1596
  segments: Number(this.getAttribute("segments")) || void 0,
@@ -1573,7 +1601,7 @@ class je extends R {
1573
1601
  }
1574
1602
  get barStyle() {
1575
1603
  const t = this.getAttribute("kind");
1576
- return Zr.includes(t) ? t : "single";
1604
+ return Jr.includes(t) ? t : "single";
1577
1605
  }
1578
1606
  get unitSystem() {
1579
1607
  return vr(this.getAttribute("units")) ?? "metric";
@@ -1581,30 +1609,30 @@ class je extends R {
1581
1609
  renderNow() {
1582
1610
  if (this.applyPlacement(), this.style.display = "block", !O(this)) {
1583
1611
  const n = this.getAttribute("for");
1584
- G(this, n ? `Scale bar references no frame with id "${n}".` : "Scale bar has no frame to measure (set for=).");
1612
+ W(this, n ? `Scale bar references no frame with id "${n}".` : "Scale bar has no frame to measure (set for=).");
1585
1613
  return;
1586
1614
  }
1587
1615
  const e = this.drawing;
1588
1616
  if (!e) {
1589
- G(this, "Scale bar cannot derive a scale from this frame yet.");
1617
+ W(this, "Scale bar cannot derive a scale from this frame yet.");
1590
1618
  return;
1591
1619
  }
1592
1620
  this.renderSvg(e);
1593
1621
  }
1594
1622
  renderSvg(t) {
1595
- const { w: e, h: n } = C(this), i = this.ownerDocument, s = i.createElementNS(nt, "svg");
1623
+ const { w: e, h: n } = S(this), i = this.ownerDocument, s = i.createElementNS(it, "svg");
1596
1624
  s.setAttribute("width", `${e}mm`), s.setAttribute("height", `${n}mm`), s.setAttribute("viewBox", `0 0 ${e} ${n}`), s.setAttribute("part", "scalebar"), s.style.display = "block", s.style.overflow = "visible";
1597
1625
  const o = "var(--om-carto-scalebar-ink)";
1598
1626
  for (const a of t.bars) {
1599
- const l = i.createElementNS(nt, "rect");
1627
+ const l = i.createElementNS(it, "rect");
1600
1628
  l.setAttribute("x", String(a.x)), l.setAttribute("y", String(a.y)), l.setAttribute("width", String(a.w)), l.setAttribute("height", String(a.h)), l.setAttribute("fill", a.filled ? o : "none"), l.setAttribute("stroke", o), l.setAttribute("stroke-width", String(t.strokeMm)), s.appendChild(l);
1601
1629
  }
1602
1630
  for (const a of t.strokes) {
1603
- const l = i.createElementNS(nt, "line");
1631
+ const l = i.createElementNS(it, "line");
1604
1632
  l.setAttribute("x1", String(a.x1)), l.setAttribute("y1", String(a.y1)), l.setAttribute("x2", String(a.x2)), l.setAttribute("y2", String(a.y2)), l.setAttribute("stroke", o), l.setAttribute("stroke-width", String(t.strokeMm)), s.appendChild(l);
1605
1633
  }
1606
1634
  for (const a of t.labels) {
1607
- const l = i.createElementNS(nt, "text");
1635
+ const l = i.createElementNS(it, "text");
1608
1636
  l.setAttribute("x", String(a.x)), l.setAttribute("y", String(a.y)), l.setAttribute("font-size", String(t.fontMm)), l.setAttribute("fill", o), l.setAttribute("text-anchor", a.anchor), l.setAttribute("font-family", "var(--om-carto-font)"), l.textContent = a.text, s.appendChild(l);
1609
1637
  }
1610
1638
  this.replaceChildren(s);
@@ -1641,15 +1669,15 @@ class ze extends R {
1641
1669
  renderNow() {
1642
1670
  if (this.applyPlacement(), this.style.display = "block", !O(this)) {
1643
1671
  const l = this.getAttribute("for");
1644
- G(this, l ? `North indicator references no frame with id "${l}".` : "North indicator has no frame (set for=).");
1672
+ W(this, l ? `North indicator references no frame with id "${l}".` : "North indicator has no frame (set for=).");
1645
1673
  return;
1646
1674
  }
1647
1675
  const e = this.bearing;
1648
1676
  if (e == null) {
1649
- G(this, "North indicator cannot derive a direction from this frame yet.");
1677
+ W(this, "North indicator cannot derive a direction from this frame yet.");
1650
1678
  return;
1651
1679
  }
1652
- const { w: n, h: i } = C(this), s = this.ownerDocument, o = s.createElementNS(J, "svg");
1680
+ const { w: n, h: i } = S(this), s = this.ownerDocument, o = s.createElementNS(J, "svg");
1653
1681
  o.setAttribute("width", `${n}mm`), o.setAttribute("height", `${i}mm`), o.setAttribute("viewBox", `0 0 ${n} ${i}`), o.style.display = "block";
1654
1682
  const a = s.createElementNS(J, "g");
1655
1683
  a.setAttribute("transform", `rotate(${e.toFixed(3)} ${n / 2} ${i / 2})`);
@@ -1670,17 +1698,17 @@ class ze extends R {
1670
1698
  paintCartograph(t, e) {
1671
1699
  const n = this.bearing;
1672
1700
  if (n == null) return;
1673
- const { w: i, h: s } = C(this), o = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, a = L(o?.color) ?? "#000", l = (h) => h * e.pxPerMm, c = Math.min(3, s * 0.24), u = s - c * 1.2, m = i / 2, d = Math.min(i * 0.3, 4);
1701
+ const { w: i, h: s } = S(this), o = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, a = L(o?.color) ?? "#000", l = (h) => h * e.pxPerMm, c = Math.min(3, s * 0.24), u = s - c * 1.2, m = i / 2, d = Math.min(i * 0.3, 4);
1674
1702
  t.save(), t.translate(l(m), l(s / 2)), t.rotate(n * Math.PI / 180), t.translate(-l(m), -l(s / 2)), t.fillStyle = a, t.strokeStyle = a, this.indicatorKind === "rose" && (t.lineWidth = l(0.2), t.beginPath(), t.arc(l(m), l(u / 2), l(Math.min(i, u) / 2), 0, Math.PI * 2), t.stroke()), t.beginPath(), t.moveTo(l(m), 0), t.lineTo(l(m + d), l(u)), t.lineTo(l(m), l(u - d * 0.55)), t.lineTo(l(m - d), l(u)), t.closePath(), t.fill(), t.font = `${l(c)}px ${o?.fontFamily || "system-ui, sans-serif"}`, t.textAlign = "center", t.textBaseline = "alphabetic", t.fillText("N", l(m), l(s)), t.restore();
1675
1703
  }
1676
1704
  }
1677
1705
  x("om-north", ze);
1678
- const it = "http://www.w3.org/2000/svg", Jr = ["rect", "ellipse", "line", "arrow"];
1706
+ const ot = "http://www.w3.org/2000/svg", Qr = ["rect", "ellipse", "line", "arrow"];
1679
1707
  class De extends R {
1680
1708
  static observedAttributes = [...P["om-shape"]];
1681
1709
  get kind() {
1682
1710
  const t = this.getAttribute("kind");
1683
- return Jr.includes(t) ? t : "rect";
1711
+ return Qr.includes(t) ? t : "rect";
1684
1712
  }
1685
1713
  get fill() {
1686
1714
  return this.getAttribute("fill") || "var(--om-carto-shape-fill)";
@@ -1706,11 +1734,11 @@ class De extends R {
1706
1734
  }
1707
1735
  renderNow() {
1708
1736
  this.applyPlacement(), this.style.display = "block";
1709
- const { w: t, h: e } = C(this), n = this.ownerDocument, i = n.createElementNS(it, "svg");
1737
+ const { w: t, h: e } = S(this), n = this.ownerDocument, i = n.createElementNS(ot, "svg");
1710
1738
  i.setAttribute("width", `${t}mm`), i.setAttribute("height", `${e}mm`), i.setAttribute("viewBox", `0 0 ${t} ${e}`), i.style.display = "block", i.style.overflow = "visible";
1711
1739
  const s = this.strokeWidthMm / 2, o = this.kind;
1712
1740
  let a;
1713
- o === "ellipse" ? (a = n.createElementNS(it, "ellipse"), a.setAttribute("cx", String(t / 2)), a.setAttribute("cy", String(e / 2)), a.setAttribute("rx", String(Math.max(0, t / 2 - s))), a.setAttribute("ry", String(Math.max(0, e / 2 - s)))) : o === "line" || o === "arrow" ? (a = n.createElementNS(it, "path"), a.setAttribute("d", o === "arrow" ? this.arrowPath(t, e) : `M 0 0 L ${t} ${e}`)) : (a = n.createElementNS(it, "rect"), a.setAttribute("x", String(s)), a.setAttribute("y", String(s)), a.setAttribute("width", String(Math.max(0, t - this.strokeWidthMm))), a.setAttribute("height", String(Math.max(0, e - this.strokeWidthMm))), this.radiusMm > 0 && a.setAttribute("rx", String(this.radiusMm)));
1741
+ o === "ellipse" ? (a = n.createElementNS(ot, "ellipse"), a.setAttribute("cx", String(t / 2)), a.setAttribute("cy", String(e / 2)), a.setAttribute("rx", String(Math.max(0, t / 2 - s))), a.setAttribute("ry", String(Math.max(0, e / 2 - s)))) : o === "line" || o === "arrow" ? (a = n.createElementNS(ot, "path"), a.setAttribute("d", o === "arrow" ? this.arrowPath(t, e) : `M 0 0 L ${t} ${e}`)) : (a = n.createElementNS(ot, "rect"), a.setAttribute("x", String(s)), a.setAttribute("y", String(s)), a.setAttribute("width", String(Math.max(0, t - this.strokeWidthMm))), a.setAttribute("height", String(Math.max(0, e - this.strokeWidthMm))), this.radiusMm > 0 && a.setAttribute("rx", String(this.radiusMm)));
1714
1742
  const l = o === "rect" || o === "ellipse" || o === "arrow";
1715
1743
  a.setAttribute("fill", l ? this.fill : "none"), l && a.setAttribute("fill-opacity", String(this.fillOpacity)), a.setAttribute("stroke", this.stroke), a.setAttribute("stroke-width", String(this.strokeWidthMm)), i.appendChild(a), this.replaceChildren(i);
1716
1744
  }
@@ -1720,7 +1748,7 @@ class De extends R {
1720
1748
  return `M 0 0 L ${s} ${o} M ${s} ${o} L ${a.x} ${a.y} L ${l.x} ${l.y} Z`;
1721
1749
  }
1722
1750
  paintCartograph(t, e) {
1723
- const { w: n, h: i } = C(this);
1751
+ const { w: n, h: i } = S(this);
1724
1752
  if (n <= 0 || i <= 0) return;
1725
1753
  const s = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, o = (d) => d * e.pxPerMm, a = this.getAttribute("fill") || s?.getPropertyValue("--om-carto-shape-fill")?.trim() || "#cccccc", l = this.getAttribute("stroke") || s?.getPropertyValue("--om-carto-shape-stroke")?.trim() || "#333333", c = o(this.strokeWidthMm), u = c / 2, m = this.kind;
1726
1754
  if (t.save(), t.globalAlpha = this.fillOpacity, t.fillStyle = a, t.strokeStyle = l, t.lineWidth = c, m === "ellipse")
@@ -1738,12 +1766,12 @@ class De extends R {
1738
1766
  }
1739
1767
  }
1740
1768
  x("om-shape", De);
1741
- const ue = "data-om-carto-owned", Qr = ["contain", "cover", "fill"];
1769
+ const ue = "data-om-carto-owned", tn = ["contain", "cover", "fill"];
1742
1770
  class Ge extends R {
1743
1771
  static observedAttributes = [...P["om-image"]];
1744
1772
  get fit() {
1745
1773
  const t = this.getAttribute("fit");
1746
- return Qr.includes(t ?? "") ? t : "contain";
1774
+ return tn.includes(t ?? "") ? t : "contain";
1747
1775
  }
1748
1776
  get image() {
1749
1777
  return this.querySelector(":scope > img");
@@ -1757,7 +1785,7 @@ class Ge extends R {
1757
1785
  paintCartograph(t, e) {
1758
1786
  const n = this.image;
1759
1787
  if (!n || !n.complete || n.naturalWidth === 0) return;
1760
- const { w: i, h: s } = C(this), o = i * e.pxPerMm, a = s * e.pxPerMm;
1788
+ const { w: i, h: s } = S(this), o = i * e.pxPerMm, a = s * e.pxPerMm;
1761
1789
  if (o <= 0 || a <= 0) return;
1762
1790
  const l = this.fit;
1763
1791
  if (l === "fill") {
@@ -1769,12 +1797,12 @@ class Ge extends R {
1769
1797
  }
1770
1798
  }
1771
1799
  x("om-image", Ge);
1772
- const tn = /* @__PURE__ */ new Set(["PathLayer", "LineLayer", "ArcLayer", "TripsLayer", "GreatCircleLayer", "PathStyleLayer"]), en = /* @__PURE__ */ new Set(["ScatterplotLayer", "IconLayer", "TextLayer", "PointCloudLayer", "HeatmapLayer", "ScreenGridLayer"]), rn = /* @__PURE__ */ new Set(["COGLayer", "ZarrLayer", "BitmapLayer", "TerrainLayer", "ImageOverlay"]);
1773
- function nn(r) {
1800
+ const en = /* @__PURE__ */ new Set(["PathLayer", "LineLayer", "ArcLayer", "TripsLayer", "GreatCircleLayer", "PathStyleLayer"]), rn = /* @__PURE__ */ new Set(["ScatterplotLayer", "IconLayer", "TextLayer", "PointCloudLayer", "HeatmapLayer", "ScreenGridLayer"]), nn = /* @__PURE__ */ new Set(["COGLayer", "ZarrLayer", "BitmapLayer", "TerrainLayer", "ImageOverlay"]);
1801
+ function on(r) {
1774
1802
  const t = r.type ?? "";
1775
- if (rn.has(t)) return "ramp";
1776
- if (tn.has(t)) return "line";
1777
- if (en.has(t)) return "point";
1803
+ if (nn.has(t)) return "ramp";
1804
+ if (en.has(t)) return "line";
1805
+ if (rn.has(t)) return "point";
1778
1806
  if (t === "GeoJsonLayer") {
1779
1807
  const e = r.props ?? {}, n = e.getFillColor !== void 0, i = e.getLineColor !== void 0;
1780
1808
  if (n && !i) return "polygon";
@@ -1782,24 +1810,24 @@ function nn(r) {
1782
1810
  }
1783
1811
  return "polygon";
1784
1812
  }
1785
- function on(r) {
1813
+ function sn(r) {
1786
1814
  const t = r.meta?.legend;
1787
1815
  return r.meta?.color ?? (t?.kind === "ramp" ? t.colors[0] : t?.entries[0]?.color) ?? "#999";
1788
1816
  }
1789
1817
  const xt = 12;
1790
- function sn(r, t = []) {
1818
+ function an(r, t = []) {
1791
1819
  const e = [];
1792
1820
  for (const n of r) {
1793
1821
  if (n.props?.visible === !1) continue;
1794
1822
  const i = t.filter((a) => a.layer === n.id), s = i.find((a) => a.match == null);
1795
1823
  if (s?.hide) continue;
1796
- const o = an(n.meta?.legend);
1824
+ const o = ln(n.meta?.legend);
1797
1825
  e.push({
1798
1826
  layerId: n.id,
1799
1827
  label: s?.label ?? n.meta?.label ?? n.id,
1800
- color: s?.color ?? on(n),
1801
- shape: s?.shape ?? nn(n),
1802
- legend: ln(o, i),
1828
+ color: s?.color ?? sn(n),
1829
+ shape: s?.shape ?? on(n),
1830
+ legend: cn(o, i),
1803
1831
  order: s?.order
1804
1832
  });
1805
1833
  }
@@ -1808,7 +1836,7 @@ function sn(r, t = []) {
1808
1836
  return s - o || n.index - i.index;
1809
1837
  }).map((n) => n.row);
1810
1838
  }
1811
- function an(r) {
1839
+ function ln(r) {
1812
1840
  if (!r || r.kind !== "categories" || r.entries.length <= xt) return r;
1813
1841
  const t = r.entries.slice(0, xt), e = r.entries.length - xt;
1814
1842
  return {
@@ -1816,7 +1844,7 @@ function an(r) {
1816
1844
  entries: [...t, { color: r.defaultColor ?? "#999", label: `+${e} more` }]
1817
1845
  };
1818
1846
  }
1819
- function ln(r, t) {
1847
+ function cn(r, t) {
1820
1848
  const e = t.filter((i) => i.match != null);
1821
1849
  if (!r || r.kind === "ramp" || e.length === 0) return r;
1822
1850
  const n = [];
@@ -1826,7 +1854,7 @@ function ln(r, t) {
1826
1854
  }
1827
1855
  return { ...r, entries: n };
1828
1856
  }
1829
- function cn(r) {
1857
+ function un(r) {
1830
1858
  const t = [];
1831
1859
  for (const e of r.querySelectorAll(":scope > om-legend-row")) {
1832
1860
  const n = e.getAttribute("layer");
@@ -1869,17 +1897,17 @@ class We extends R {
1869
1897
  get rows() {
1870
1898
  if (!this.derived) return qe(this);
1871
1899
  const n = O(this)?.mapElement?.getLayers?.();
1872
- return n ? sn(n, cn(this)) : [];
1900
+ return n ? an(n, un(this)) : [];
1873
1901
  }
1874
1902
  renderNow() {
1875
1903
  if (this.applyPlacement(), this.style.display = "block", this.style.boxSizing = "border-box", this.style.overflow = "hidden", this.derived && !O(this)) {
1876
1904
  const e = this.getAttribute("for");
1877
- G(this, e ? `Legend references no frame with id "${e}".` : "Legend has no frame to derive from (set for=).");
1905
+ W(this, e ? `Legend references no frame with id "${e}".` : "Legend has no frame to derive from (set for=).");
1878
1906
  return;
1879
1907
  }
1880
1908
  const t = this.rows;
1881
1909
  if (t.length === 0 && this.derived) {
1882
- G(this, "Legend is waiting for its frame's layers.");
1910
+ W(this, "Legend is waiting for its frame's layers.");
1883
1911
  return;
1884
1912
  }
1885
1913
  this.renderRows(t);
@@ -1919,47 +1947,47 @@ class We extends R {
1919
1947
  const o = t.createElement("div");
1920
1948
  o.style.cssText = `height:2.4mm;background:linear-gradient(to right, ${i.colors.join(", ")});border:0.15mm solid rgba(0,0,0,.25);`, n.appendChild(o);
1921
1949
  const a = t.createElement("div");
1922
- return a.style.cssText = "display:flex;justify-content:space-between;font-size:2.1mm;opacity:.75;", a.append(ot(t, i.domain[0].toLocaleString("en-US")), ot(t, i.domain[1].toLocaleString("en-US"))), n.appendChild(a), n;
1950
+ return a.style.cssText = "display:flex;justify-content:space-between;font-size:2.1mm;opacity:.75;", a.append(st(t, i.domain[0].toLocaleString("en-US")), st(t, i.domain[1].toLocaleString("en-US"))), n.appendChild(a), n;
1923
1951
  }
1924
1952
  for (const o of i.entries) {
1925
1953
  const a = t.createElement("div");
1926
- a.style.cssText = "display:flex;align-items:center;gap:1.2mm;margin:0.3mm 0;font-size:2.3mm;", a.appendChild(this.buildSwatch(t, o.color, "polygon")), a.appendChild(ot(t, o.label)), n.appendChild(a);
1954
+ a.style.cssText = "display:flex;align-items:center;gap:1.2mm;margin:0.3mm 0;font-size:2.3mm;", a.appendChild(this.buildSwatch(t, o.color, "polygon")), a.appendChild(st(t, o.label)), n.appendChild(a);
1927
1955
  }
1928
1956
  if (i.kind === "categories" && i.defaultColor) {
1929
1957
  const o = t.createElement("div");
1930
- o.style.cssText = "display:flex;align-items:center;gap:1.2mm;margin:0.3mm 0;font-size:2.3mm;", o.appendChild(this.buildSwatch(t, i.defaultColor, "polygon")), o.appendChild(ot(t, "other")), n.appendChild(o);
1958
+ o.style.cssText = "display:flex;align-items:center;gap:1.2mm;margin:0.3mm 0;font-size:2.3mm;", o.appendChild(this.buildSwatch(t, i.defaultColor, "polygon")), o.appendChild(st(t, "other")), n.appendChild(o);
1931
1959
  }
1932
1960
  return n;
1933
1961
  }
1934
1962
  paintCartograph(t, e) {
1935
- const { w: n, h: i } = C(this), s = n * e.pxPerMm, o = i * e.pxPerMm;
1963
+ const { w: n, h: i } = S(this), s = n * e.pxPerMm, o = i * e.pxPerMm;
1936
1964
  if (s <= 0 || o <= 0) return;
1937
1965
  const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = L(a?.backgroundColor);
1938
1966
  l && (t.fillStyle = l, t.fillRect(0, 0, s, o));
1939
- const c = L(a?.borderTopColor), u = kt(a?.borderTopWidth) * e.scale;
1967
+ const c = L(a?.borderTopColor), u = $t(a?.borderTopWidth) * e.scale;
1940
1968
  c && u > 0 && (t.strokeStyle = c, t.lineWidth = u, t.strokeRect(u / 2, u / 2, s - u, o - u));
1941
1969
  const m = L(a?.color) ?? "#111", d = a?.fontFamily || "system-ui, sans-serif", h = (N) => N * e.pxPerMm;
1942
1970
  let f = h(2);
1943
1971
  const p = this.getAttribute("title");
1944
1972
  p && (t.fillStyle = m, t.font = `600 ${h(2.6)}px ${d}`, t.textBaseline = "top", t.fillText(p, h(2), f), f += h(4));
1945
- const g = this.rows, b = Number(this.getAttribute("columns")), w = Math.min(g.length || 1, Number.isFinite(b) && b > 1 ? Math.floor(b) : 1), y = Math.max(1, Math.ceil(g.length / w)), S = 3, M = Math.max(1, (n - 4 - S * (w - 1)) / w), F = f;
1946
- let _ = -1, $ = 2;
1973
+ const g = this.rows, b = Number(this.getAttribute("columns")), w = Math.min(g.length || 1, Number.isFinite(b) && b > 1 ? Math.floor(b) : 1), y = Math.max(1, Math.ceil(g.length / w)), C = 3, M = Math.max(1, (n - 4 - C * (w - 1)) / w), F = f;
1974
+ let _ = -1, k = 2;
1947
1975
  t.font = `${h(2.6)}px ${d}`;
1948
1976
  for (const [N, T] of g.entries()) {
1949
1977
  const v = Math.min(w - 1, Math.floor(N / y));
1950
- if (v !== _ && (_ = v, $ = 2 + _ * (M + S), f = _ === 0 ? F : h(2)), f > o || (t.fillStyle = T.color, T.shape === "line" ? t.fillRect(h($), f + h(1.2), h(3.2), h(0.9)) : T.shape === "point" ? (t.beginPath(), t.arc(h($ + 1.6), f + h(1.6), h(1.6), 0, Math.PI * 2), t.fill()) : t.fillRect(h($), f, h(3.2), h(3.2)), t.fillStyle = m, t.textBaseline = "top", t.fillText(T.label, h($ + 4.7), f + h(0.3)), f += h(4.2), !T.legend)) continue;
1978
+ if (v !== _ && (_ = v, k = 2 + _ * (M + C), f = _ === 0 ? F : h(2)), f > o || (t.fillStyle = T.color, T.shape === "line" ? t.fillRect(h(k), f + h(1.2), h(3.2), h(0.9)) : T.shape === "point" ? (t.beginPath(), t.arc(h(k + 1.6), f + h(1.6), h(1.6), 0, Math.PI * 2), t.fill()) : t.fillRect(h(k), f, h(3.2), h(3.2)), t.fillStyle = m, t.textBaseline = "top", t.fillText(T.label, h(k + 4.7), f + h(0.3)), f += h(4.2), !T.legend)) continue;
1951
1979
  const A = T.legend;
1952
- if (t.save(), t.font = `${h(2.1)}px ${d}`, t.globalAlpha = 0.7, t.fillText(A.field, h($ + 2.7), f), t.globalAlpha = 1, f += h(2.8), A.kind === "ramp") {
1953
- const k = Math.min(24, Math.max(1, M - 2.7)), E = $ + 2.7, U = t.createLinearGradient(h(E), 0, h(E + k), 0);
1954
- A.colors.forEach((X, Xe) => U.addColorStop(A.colors.length === 1 ? 0 : Xe / (A.colors.length - 1), X)), t.fillStyle = U, t.fillRect(h(E), f, h(k), h(2.4)), f += h(3.4), t.fillStyle = m, t.font = `${h(2.1)}px ${d}`, t.fillText(A.domain[0].toLocaleString("en-US"), h(E), f);
1955
- const Q = A.domain[1].toLocaleString("en-US");
1956
- t.textAlign = "right", t.fillText(Q, h(E + k), f), t.textAlign = "left", f += h(3.2);
1980
+ if (t.save(), t.font = `${h(2.1)}px ${d}`, t.globalAlpha = 0.7, t.fillText(A.field, h(k + 2.7), f), t.globalAlpha = 1, f += h(2.8), A.kind === "ramp") {
1981
+ const $ = Math.min(24, Math.max(1, M - 2.7)), E = k + 2.7, U = t.createLinearGradient(h(E), 0, h(E + $), 0);
1982
+ A.colors.forEach((X, Xe) => U.addColorStop(A.colors.length === 1 ? 0 : Xe / (A.colors.length - 1), X)), t.fillStyle = U, t.fillRect(h(E), f, h($), h(2.4)), f += h(3.4), t.fillStyle = m, t.font = `${h(2.1)}px ${d}`, t.fillText(A.domain[0].toLocaleString("en-US"), h(E), f);
1983
+ const tt = A.domain[1].toLocaleString("en-US");
1984
+ t.textAlign = "right", t.fillText(tt, h(E + $), f), t.textAlign = "left", f += h(3.2);
1957
1985
  } else {
1958
- const k = [...A.entries];
1959
- A.kind === "categories" && A.defaultColor && k.push({ color: A.defaultColor, label: "other" }), t.font = `${h(2.3)}px ${d}`;
1960
- for (const E of k) {
1986
+ const $ = [...A.entries];
1987
+ A.kind === "categories" && A.defaultColor && $.push({ color: A.defaultColor, label: "other" }), t.font = `${h(2.3)}px ${d}`;
1988
+ for (const E of $) {
1961
1989
  if (f > o) break;
1962
- t.fillStyle = E.color, t.fillRect(h($ + 2.7), f, h(2.6), h(2.6)), t.fillStyle = m, t.fillText(E.label, h($ + 6.3), f + h(0.2)), f += h(3.2);
1990
+ t.fillStyle = E.color, t.fillRect(h(k + 2.7), f, h(2.6), h(2.6)), t.fillStyle = m, t.fillText(E.label, h(k + 6.3), f + h(0.2)), f += h(3.2);
1963
1991
  }
1964
1992
  f += h(1);
1965
1993
  }
@@ -1967,7 +1995,7 @@ class We extends R {
1967
1995
  }
1968
1996
  }
1969
1997
  }
1970
- const ot = (r, t) => {
1998
+ const st = (r, t) => {
1971
1999
  const e = r.createElement("span");
1972
2000
  return e.textContent = t, e;
1973
2001
  };
@@ -1977,22 +2005,22 @@ const me = 48, Be = {
1977
2005
  fromLngLat: (r) => [r[0], r[1]]
1978
2006
  };
1979
2007
  function de(r, t = 5) {
1980
- return !Number.isFinite(r) || r <= 0 ? 0 : $e(r / Math.max(1, t));
2008
+ return !Number.isFinite(r) || r <= 0 ? 0 : ke(r / Math.max(1, t));
1981
2009
  }
1982
- function un({ georef: r, plane: t = Be, interval: e, intervalX: n, intervalY: i, labels: s = "outside", format: o }) {
2010
+ function hn({ georef: r, plane: t = Be, interval: e, intervalX: n, intervalY: i, labels: s = "outside", format: o }) {
1983
2011
  if (r.degenerate) return null;
1984
2012
  const a = r.corners.map((y) => t.fromLngLat(y)), l = a.map((y) => y[0]), c = a.map((y) => y[1]);
1985
2013
  if (l.some((y) => !Number.isFinite(y)) || c.some((y) => !Number.isFinite(y))) return null;
1986
2014
  const u = Math.min(...l), m = Math.max(...l), d = Math.min(...c), h = Math.max(...c), f = fe(n ?? e, de(m - u)), p = fe(i ?? e, de(h - d));
1987
2015
  if (f <= 0 || p <= 0 || (m - u) / f > 500 || (h - d) / p > 500) return null;
1988
- const g = [], b = [], w = o ?? mn;
2016
+ const g = [], b = [], w = o ?? dn;
1989
2017
  for (let y = Math.ceil(u / f) * f; y <= m + 1e-9; y += f) {
1990
- const S = pe(r, t, y, d, h, "x");
1991
- S && (g.push(S), s !== "none" && be(b, S, r, w(y, "x"), "x", s));
2018
+ const C = pe(r, t, y, d, h, "x");
2019
+ C && (g.push(C), s !== "none" && be(b, C, r, w(y, "x"), "x", s));
1992
2020
  }
1993
2021
  for (let y = Math.ceil(d / p) * p; y <= h + 1e-9; y += p) {
1994
- const S = pe(r, t, y, u, m, "y");
1995
- S && (g.push(S), s !== "none" && be(b, S, r, w(y, "y"), "y", s));
2022
+ const C = pe(r, t, y, u, m, "y");
2023
+ C && (g.push(C), s !== "none" && be(b, C, r, w(y, "y"), "y", s));
1996
2024
  }
1997
2025
  return { lines: g, labels: b, intervalX: f, intervalY: p };
1998
2026
  }
@@ -2005,10 +2033,10 @@ function pe(r, t, e, n, i, s) {
2005
2033
  const m = r.project(u);
2006
2034
  m && o.push(m);
2007
2035
  }
2008
- const a = hn(o, r.widthMm, r.heightMm);
2036
+ const a = mn(o, r.widthMm, r.heightMm);
2009
2037
  return a.length >= 2 ? { points: a, value: e, axis: s } : null;
2010
2038
  }
2011
- function hn(r, t, e) {
2039
+ function mn(r, t, e) {
2012
2040
  const n = (a) => a.xMm >= -0.01 && a.xMm <= t + 0.01 && a.yMm >= -0.01 && a.yMm <= e + 0.01, i = r.findIndex(n);
2013
2041
  if (i === -1) return [];
2014
2042
  let s = r.length - 1;
@@ -2027,16 +2055,16 @@ function be(r, t, e, n, i, s) {
2027
2055
  r.push({ text: n, xMm: s === "outside" ? -1.2 : 1.2, yMm: o.yMm, edge: "left", axis: i });
2028
2056
  }
2029
2057
  }
2030
- function mn(r, t) {
2058
+ function dn(r, t) {
2031
2059
  if (Math.abs(r) >= 1e3) return Math.round(r).toLocaleString("en-US");
2032
2060
  const e = Math.abs(r) < 1 ? 3 : Math.abs(r) < 10 ? 2 : 1;
2033
2061
  return `${Number(r.toFixed(e))}°`;
2034
2062
  }
2035
- function dn(r, t) {
2063
+ function fn(r, t) {
2036
2064
  const e = t === "x" ? r < 0 ? "W" : "E" : r < 0 ? "S" : "N", n = Math.abs(r), i = Math.floor(n), s = (n - i) * 60, o = Math.floor(s), a = Math.round((s - o) * 60), l = a === 60 ? o + 1 : o, c = l === 60 ? i + 1 : i, u = l === 60 ? 0 : l, m = a === 60 ? 0 : a;
2037
2065
  return `${c}°${String(u).padStart(2, "0")}′${String(m).padStart(2, "0")}″${e}`;
2038
2066
  }
2039
- const st = "http://www.w3.org/2000/svg", fn = ["solid", "cross", "markers"], z = 1.4;
2067
+ const at = "http://www.w3.org/2000/svg", pn = ["solid", "cross", "markers"], D = 1.4;
2040
2068
  class Ve extends R {
2041
2069
  static observedAttributes = [...P["om-graticule"]];
2042
2070
  resolvedPlane = null;
@@ -2044,7 +2072,7 @@ class Ve extends R {
2044
2072
  resolveToken = 0;
2045
2073
  get kind() {
2046
2074
  const t = this.getAttribute("kind");
2047
- return fn.includes(t) ? t : "solid";
2075
+ return pn.includes(t) ? t : "solid";
2048
2076
  }
2049
2077
  get labelPlacement() {
2050
2078
  const t = this.getAttribute("labels");
@@ -2060,14 +2088,14 @@ class Ve extends R {
2060
2088
  const s = Number(this.getAttribute(i));
2061
2089
  return Number.isFinite(s) && s > 0 ? s : null;
2062
2090
  };
2063
- return un({
2091
+ return hn({
2064
2092
  georef: t,
2065
2093
  plane: e,
2066
2094
  interval: n("interval"),
2067
2095
  intervalX: n("interval-x"),
2068
2096
  intervalY: n("interval-y"),
2069
2097
  labels: this.labelPlacement,
2070
- format: this.getAttribute("format") === "dms" ? dn : void 0
2098
+ format: this.getAttribute("format") === "dms" ? fn : void 0
2071
2099
  });
2072
2100
  }
2073
2101
  /**
@@ -2094,7 +2122,7 @@ class Ve extends R {
2094
2122
  renderNow() {
2095
2123
  if (this.applyPlacement(), this.style.display = "block", this.style.pointerEvents = "none", !O(this)) {
2096
2124
  const n = this.getAttribute("for");
2097
- G(this, n ? `Graticule references no frame with id "${n}".` : "Graticule has no frame to cover (set for=).");
2125
+ W(this, n ? `Graticule references no frame with id "${n}".` : "Graticule has no frame to cover (set for=).");
2098
2126
  return;
2099
2127
  }
2100
2128
  const e = this.graticule;
@@ -2105,20 +2133,20 @@ class Ve extends R {
2105
2133
  this.renderSvg(e);
2106
2134
  }
2107
2135
  renderSvg(t) {
2108
- const { w: e, h: n } = C(this), i = this.ownerDocument, s = i.createElementNS(st, "svg");
2136
+ const { w: e, h: n } = S(this), i = this.ownerDocument, s = i.createElementNS(at, "svg");
2109
2137
  s.setAttribute("width", `${e}mm`), s.setAttribute("height", `${n}mm`), s.setAttribute("viewBox", `0 0 ${e} ${n}`), s.style.cssText = "display:block;overflow:visible;";
2110
2138
  const o = "var(--om-carto-graticule-ink)", a = this.kind;
2111
2139
  for (const l of t.lines)
2112
2140
  if (a === "solid") {
2113
- const c = i.createElementNS(st, "polyline");
2141
+ const c = i.createElementNS(at, "polyline");
2114
2142
  c.setAttribute("points", l.points.map((u) => `${u.xMm.toFixed(3)},${u.yMm.toFixed(3)}`).join(" ")), c.setAttribute("fill", "none"), c.setAttribute("stroke", o), c.setAttribute("stroke-width", "0.15"), s.appendChild(c);
2115
2143
  } else
2116
2144
  for (const c of this.tickPoints(l, a, t)) {
2117
- const u = i.createElementNS(st, "path");
2118
- u.setAttribute("d", `M ${c.xMm - z} ${c.yMm} H ${c.xMm + z} M ${c.xMm} ${c.yMm - z} V ${c.yMm + z}`), u.setAttribute("stroke", o), u.setAttribute("stroke-width", "0.15"), s.appendChild(u);
2145
+ const u = i.createElementNS(at, "path");
2146
+ u.setAttribute("d", `M ${c.xMm - D} ${c.yMm} H ${c.xMm + D} M ${c.xMm} ${c.yMm - D} V ${c.yMm + D}`), u.setAttribute("stroke", o), u.setAttribute("stroke-width", "0.15"), s.appendChild(u);
2119
2147
  }
2120
2148
  for (const l of t.labels) {
2121
- const c = i.createElementNS(st, "text");
2149
+ const c = i.createElementNS(at, "text");
2122
2150
  c.setAttribute("x", String(l.xMm)), c.setAttribute("y", String(l.yMm)), c.setAttribute("font-size", "2.2"), c.setAttribute("fill", o), c.setAttribute("font-family", "var(--om-carto-font)"), c.setAttribute("text-anchor", l.edge === "left" ? "end" : "middle"), c.textContent = l.text, s.appendChild(c);
2123
2151
  }
2124
2152
  this.replaceChildren(s);
@@ -2128,7 +2156,7 @@ class Ve extends R {
2128
2156
  if (e === "markers") return [t.points[0], t.points[t.points.length - 1]];
2129
2157
  const i = n.lines.filter((o) => o.axis !== t.axis), s = [];
2130
2158
  for (const o of i) {
2131
- const a = pn(t.points, o.points);
2159
+ const a = gn(t.points, o.points);
2132
2160
  a && s.push(a);
2133
2161
  }
2134
2162
  return s;
@@ -2143,14 +2171,14 @@ class Ve extends R {
2143
2171
  t.beginPath(), l.points.forEach((c, u) => u === 0 ? t.moveTo(o(c.xMm), o(c.yMm)) : t.lineTo(o(c.xMm), o(c.yMm))), t.stroke();
2144
2172
  else
2145
2173
  for (const c of this.tickPoints(l, a, n))
2146
- t.beginPath(), t.moveTo(o(c.xMm - z), o(c.yMm)), t.lineTo(o(c.xMm + z), o(c.yMm)), t.moveTo(o(c.xMm), o(c.yMm - z)), t.lineTo(o(c.xMm), o(c.yMm + z)), t.stroke();
2174
+ t.beginPath(), t.moveTo(o(c.xMm - D), o(c.yMm)), t.lineTo(o(c.xMm + D), o(c.yMm)), t.moveTo(o(c.xMm), o(c.yMm - D)), t.lineTo(o(c.xMm), o(c.yMm + D)), t.stroke();
2147
2175
  t.font = `${o(2.2)}px ${i?.fontFamily || "system-ui, sans-serif"}`, t.textBaseline = "alphabetic";
2148
2176
  for (const l of n.labels)
2149
2177
  t.textAlign = l.edge === "left" ? "right" : "center", t.fillText(l.text, o(l.xMm), o(l.yMm));
2150
2178
  t.restore();
2151
2179
  }
2152
2180
  }
2153
- function pn(r, t) {
2181
+ function gn(r, t) {
2154
2182
  let e = null, n = Number.POSITIVE_INFINITY;
2155
2183
  for (const i of r)
2156
2184
  for (const s of t) {
@@ -2160,27 +2188,27 @@ function pn(r, t) {
2160
2188
  return n <= 1 ? e : null;
2161
2189
  }
2162
2190
  x("om-graticule", Ve);
2163
- function gn(r, t) {
2191
+ function bn(r, t) {
2164
2192
  if (r == null || typeof r != "object") return;
2165
2193
  const e = r.properties;
2166
2194
  return e && t in e ? e[t] : r[t];
2167
2195
  }
2168
- function Pt(r, t) {
2196
+ function Tt(r, t) {
2169
2197
  if (Array.isArray(r)) {
2170
2198
  if (typeof r[0] == "number") {
2171
2199
  t.push([r[0], r[1]]);
2172
2200
  return;
2173
2201
  }
2174
- for (const e of r) Pt(e, t);
2202
+ for (const e of r) Tt(e, t);
2175
2203
  }
2176
2204
  }
2177
- function bn(r) {
2205
+ function yn(r) {
2178
2206
  return r ? r.tileData != null ? "tiled" : r.asset != null ? "asset" : null : "empty";
2179
2207
  }
2180
2208
  function I(r, t) {
2181
- return gn(r, t);
2209
+ return bn(r, t);
2182
2210
  }
2183
- function Tt(r) {
2211
+ function Lt(r) {
2184
2212
  const t = {}, e = (i) => {
2185
2213
  for (const [s, o] of Object.entries(i))
2186
2214
  o == null || typeof o == "object" || (t[s] = String(o));
@@ -2189,11 +2217,11 @@ function Tt(r) {
2189
2217
  const n = r.properties;
2190
2218
  return n && typeof n == "object" && e(n), t;
2191
2219
  }
2192
- function yn(r) {
2220
+ function wn(r) {
2193
2221
  let t = 1 / 0, e = 1 / 0, n = -1 / 0, i = -1 / 0;
2194
2222
  const s = [], o = r.geometry;
2195
- if (o?.coordinates != null) Pt(o.coordinates, s);
2196
- else if (Array.isArray(r.coordinates)) Pt(r.coordinates, s);
2223
+ if (o?.coordinates != null) Tt(o.coordinates, s);
2224
+ else if (Array.isArray(r.coordinates)) Tt(r.coordinates, s);
2197
2225
  else {
2198
2226
  const a = Number(I(r, "lng") ?? I(r, "longitude") ?? I(r, "lon") ?? I(r, "x")), l = Number(I(r, "lat") ?? I(r, "latitude") ?? I(r, "y"));
2199
2227
  Number.isFinite(a) && Number.isFinite(l) && s.push([a, l]);
@@ -2202,47 +2230,47 @@ function yn(r) {
2202
2230
  !Number.isFinite(a) || !Number.isFinite(l) || (t = Math.min(t, a), n = Math.max(n, a), e = Math.min(e, l), i = Math.max(i, l));
2203
2231
  return !Number.isFinite(t) || !Number.isFinite(e) ? null : [t, e, n, i];
2204
2232
  }
2205
- function wn(r, t) {
2233
+ function Mn(r, t) {
2206
2234
  const [e, n, i, s] = r, o = Math.max(i - e, 1e-4), a = Math.max(s - n, 1e-4), l = o * t, c = a * t;
2207
2235
  return [e - l, n - c, i + l, s + c];
2208
2236
  }
2209
- const Vn = ([r, t, e, n]) => Math.max(0, e - r) * Math.max(0, n - t);
2210
- function Mn({ features: r, filter: t, sort: e }) {
2211
- let n = t ? r.filter((s) => vn(t, s)) : [...r];
2212
- const i = An(e);
2237
+ const Hn = ([r, t, e, n]) => Math.max(0, e - r) * Math.max(0, n - t);
2238
+ function vn({ features: r, filter: t, sort: e }) {
2239
+ let n = t ? r.filter((s) => An(t, s)) : [...r];
2240
+ const i = Sn(e);
2213
2241
  return i.length > 0 && (n = [...n].sort((s, o) => {
2214
2242
  for (const { field: a, descending: l } of i) {
2215
2243
  const c = I(s, a), u = I(o, a);
2216
2244
  if (c == null && u == null) continue;
2217
2245
  if (c == null) return 1;
2218
2246
  if (u == null) return -1;
2219
- const m = Sn(c, u);
2247
+ const m = Cn(c, u);
2220
2248
  if (m !== 0) return l ? -m : m;
2221
2249
  }
2222
2250
  return 0;
2223
2251
  })), n;
2224
2252
  }
2225
- function vn(r, t) {
2253
+ function An(r, t) {
2226
2254
  try {
2227
2255
  return !!r(t);
2228
2256
  } catch {
2229
2257
  return !1;
2230
2258
  }
2231
2259
  }
2232
- function An(r) {
2260
+ function Sn(r) {
2233
2261
  return r ? r.split(",").map((t) => t.trim()).filter(Boolean).map((t) => t.startsWith("-") ? { field: t.slice(1), descending: !0 } : { field: t, descending: !1 }) : [];
2234
2262
  }
2235
- function Sn(r, t) {
2263
+ function Cn(r, t) {
2236
2264
  return typeof r == "number" && typeof t == "number" ? r - t : String(r).localeCompare(String(t), void 0, { numeric: !0, sensitivity: "base" });
2237
2265
  }
2238
- function Cn(r) {
2266
+ function xn(r) {
2239
2267
  const t = r.replace(/[\x00-\x1f<>:"/\\|?*]+/g, "-").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^[-.]+|[-.]+$/g, "").slice(0, 100);
2240
2268
  return t === "" ? "page" : t;
2241
2269
  }
2242
- function xn(r, t, e) {
2270
+ function kn(r, t, e) {
2243
2271
  const n = /* @__PURE__ */ new Map();
2244
2272
  return t.map((i, s) => {
2245
- const o = Tt(i), a = (r ?? "page-{{atlas.index}}").replace(/\{\{\s*atlas\.([\w]+)\s*\}\}/g, (u, m) => m === "index" ? String(s + 1) : m === "count" ? String(t.length) : o[m] ?? u), l = Cn(a), c = n.get(l) ?? 0;
2273
+ const o = Lt(i), a = (r ?? "page-{{atlas.index}}").replace(/\{\{\s*atlas\.([\w]+)\s*\}\}/g, (u, m) => m === "index" ? String(s + 1) : m === "count" ? String(t.length) : o[m] ?? u), l = xn(a), c = n.get(l) ?? 0;
2246
2274
  return n.set(l, c + 1), `${c === 0 ? l : `${l}-${c + 1}`}.${e}`;
2247
2275
  });
2248
2276
  }
@@ -2275,13 +2303,13 @@ class He extends R {
2275
2303
  }
2276
2304
  /** Export filenames, one per page, already de-duplicated. */
2277
2305
  filenames(t = "png") {
2278
- return xn(this.getAttribute("filename"), this.ensurePages(), t);
2306
+ return kn(this.getAttribute("filename"), this.ensurePages(), t);
2279
2307
  }
2280
2308
  /** Human page labels, for an editor's stepper and PDF bookmarks. */
2281
2309
  pageName(t) {
2282
2310
  const e = this.ensurePages()[t];
2283
2311
  if (!e) return `Page ${t + 1}`;
2284
- const n = Tt(e), i = this.getAttribute("page-name");
2312
+ const n = Lt(e), i = this.getAttribute("page-name");
2285
2313
  return i ? i.replace(
2286
2314
  /\{\{\s*atlas\.([\w]+)\s*\}\}/g,
2287
2315
  (s, o) => o === "index" ? String(t + 1) : o === "count" ? String(this.count) : n[o] ?? s
@@ -2299,11 +2327,11 @@ class He extends R {
2299
2327
  }
2300
2328
  ensurePages() {
2301
2329
  if (this.pages) return this.pages;
2302
- const e = this.frame?.mapElement?.getLayers?.(), n = this.getAttribute("layer"), i = e?.find((a) => a.id === n), s = e ? bn(i) : null;
2330
+ const e = this.frame?.mapElement?.getLayers?.(), n = this.getAttribute("layer"), i = e?.find((a) => a.id === n), s = e ? yn(i) : null;
2303
2331
  if (!e || s)
2304
2332
  return this.rejection = e ? s : null, this.pages = [];
2305
2333
  const o = this.materialize(i);
2306
- return this.pages = Mn({ features: o, filter: this.compileFilter(), sort: this.getAttribute("sort") }), this.currentIndex = Math.min(this.currentIndex, Math.max(0, this.pages.length - 1)), this.pages;
2334
+ return this.pages = vn({ features: o, filter: this.compileFilter(), sort: this.getAttribute("sort") }), this.currentIndex = Math.min(this.currentIndex, Math.max(0, this.pages.length - 1)), this.pages;
2307
2335
  }
2308
2336
  /**
2309
2337
  * Rows from the layer, with the layer's OWN declarative filters applied —
@@ -2311,7 +2339,7 @@ class He extends R {
2311
2339
  * sheets for features the map itself is hiding.
2312
2340
  */
2313
2341
  materialize(t) {
2314
- const e = H(), n = t.data;
2342
+ const e = G(), n = t.data;
2315
2343
  if (!n) return [];
2316
2344
  const i = e?.asRows ? e.asRows(n) : Array.isArray(n) ? n : [], s = [t.filter, t.categoryFilter].filter(Boolean);
2317
2345
  return s.length === 0 ? i : i.filter(
@@ -2330,7 +2358,7 @@ class He extends R {
2330
2358
  compileFilter() {
2331
2359
  const t = this.getAttribute("filter");
2332
2360
  if (!t) return;
2333
- const e = H();
2361
+ const e = G();
2334
2362
  if (e?.compileExpression)
2335
2363
  try {
2336
2364
  const n = e.compileExpression(t, { shape: "geojson", paramName: "d" });
@@ -2354,12 +2382,12 @@ class He extends R {
2354
2382
  const e = this.closest("om-cartograph");
2355
2383
  for (const n of e?.querySelectorAll("om-frame") ?? []) {
2356
2384
  if (n.getAttribute("atlas-fit") !== "feature") continue;
2357
- const i = yn(t);
2385
+ const i = wn(t);
2358
2386
  if (!i) continue;
2359
- const s = Number(n.getAttribute("atlas-margin")), o = wn(i, Number.isFinite(s) && s > 0 ? s : 0.15);
2387
+ const s = Number(n.getAttribute("atlas-margin")), o = Mn(i, Number.isFinite(s) && s > 0 ? s : 0.15);
2360
2388
  n.fitBounds?.(o);
2361
2389
  }
2362
- e?.setAtlasFields({ ...Tt(t), index: String(this.currentIndex + 1), count: String(this.count) }), e?.refreshFurniture(), this.dispatchEvent(
2390
+ e?.setAtlasFields({ ...Lt(t), index: String(this.currentIndex + 1), count: String(this.count) }), e?.refreshFurniture(), this.dispatchEvent(
2363
2391
  new CustomEvent("om-atlas-page", {
2364
2392
  bubbles: !0,
2365
2393
  detail: { index: this.currentIndex, count: this.count, name: this.pageName(this.currentIndex), feature: t }
@@ -2371,21 +2399,21 @@ class He extends R {
2371
2399
  }
2372
2400
  }
2373
2401
  x("om-atlas", He);
2374
- const $n = /* @__PURE__ */ new Set(["class", "style", "id", "hidden", "title", "lang", "dir", "slot", "part", "role", "tabindex"]), kn = /* @__PURE__ */ new Set(["style", "script", "img", "template", "om-map"]), En = ["data-om-carto-credit", "data-om-carto-marks", "data-om-carto-flattened"], Nn = /* @__PURE__ */ new Set(["om-text", "om-legend", "om-scalebar", "om-north", "om-shape", "om-image"]), Pn = /* @__PURE__ */ new Set(["om-frame", "om-legend", "om-scalebar", "om-north", "om-graticule", "om-text", "om-shape", "om-image"]), Tn = 0.02, Ln = (r) => Math.max(0, Number(r.getAttribute("bleed")) || 0);
2402
+ const $n = /* @__PURE__ */ new Set(["class", "style", "id", "hidden", "title", "lang", "dir", "slot", "part", "role", "tabindex"]), En = /* @__PURE__ */ new Set(["style", "script", "img", "template", "om-map"]), Nn = ["data-om-carto-credit", "data-om-carto-marks", "data-om-carto-flattened"], Pn = /* @__PURE__ */ new Set(["om-text", "om-legend", "om-scalebar", "om-north", "om-shape", "om-image"]), Tn = /* @__PURE__ */ new Set(["om-frame", "om-legend", "om-scalebar", "om-north", "om-graticule", "om-text", "om-shape", "om-image"]), Ln = 0.02, Fn = (r) => Math.max(0, Number(r.getAttribute("bleed")) || 0);
2375
2403
  function Ye(r) {
2376
2404
  const t = r.tagName.toLowerCase();
2377
2405
  return r.id ? `${t}#${r.id}` : t;
2378
2406
  }
2379
- function V(r, t) {
2407
+ function H(r, t) {
2380
2408
  const e = r.getAttribute(t);
2381
2409
  if (e == null || e.trim() === "") return null;
2382
2410
  const n = Number(e);
2383
2411
  return Number.isFinite(n) ? n : null;
2384
2412
  }
2385
- function Fn(r, t) {
2413
+ function In(r, t) {
2386
2414
  return r.x < t.x + t.w && t.x < r.x + r.w && r.y < t.y + t.h && t.y < r.y + r.h;
2387
2415
  }
2388
- function In(r, t) {
2416
+ function Rn(r, t) {
2389
2417
  const e = r.getAttribute("style");
2390
2418
  if (!e) return null;
2391
2419
  const n = new RegExp(`(?:^|;)\\s*${t}\\s*:\\s*(-?[\\d.]+)mm`, "i").exec(e);
@@ -2397,45 +2425,45 @@ function Ke(r) {
2397
2425
  }, n = [...r.querySelectorAll("om-cartograph")];
2398
2426
  if (n.length === 0 && r.tagName?.toLowerCase() === "om-cartograph" && n.push(r), n.length === 0)
2399
2427
  return { valid: !0, errors: [], warnings: [] };
2400
- for (const o of n) Rn(o, e);
2428
+ for (const o of n) _n(o, e);
2401
2429
  const i = t.filter((o) => o.severity === "error"), s = t.filter((o) => o.severity === "warning");
2402
2430
  return { valid: i.length === 0, errors: i, warnings: s };
2403
2431
  }
2404
- function Rn(r, t) {
2405
- const e = r.getAttribute("size"), n = V(r, "width") != null && V(r, "height") != null;
2406
- e && !Bt.includes(e) && !n && t(
2432
+ function _n(r, t) {
2433
+ const e = r.getAttribute("size"), n = H(r, "width") != null && H(r, "height") != null;
2434
+ e && !Vt.includes(e) && !n && t(
2407
2435
  "error",
2408
2436
  r,
2409
2437
  `Unknown page size "${e}" and no width/height to fall back on.`,
2410
- `Use one of ${Bt.join(", ")}, or give width= and height= in millimetres.`,
2438
+ `Use one of ${Vt.join(", ")}, or give width= and height= in millimetres.`,
2411
2439
  "size"
2412
2440
  );
2413
2441
  const i = r.getAttribute("cvd");
2414
- i && i.trim().toLowerCase() !== "none" && !Lt(i) && t("warning", r, `Unknown cvd="${i}" — no simulation applied.`, `Use one of ${rr.join(", ")}.`, "cvd"), r.hasAttribute("crop-marks") && Ln(r) <= 0 && t("warning", r, "crop-marks needs bleed to draw into — trim marks sit outside the page box.", 'Add bleed="3" (mm), or drop crop-marks.', "crop-marks");
2415
- const s = V(r, "safe-zone");
2442
+ i && i.trim().toLowerCase() !== "none" && !Ft(i) && t("warning", r, `Unknown cvd="${i}" — no simulation applied.`, `Use one of ${rr.join(", ")}.`, "cvd"), r.hasAttribute("crop-marks") && Fn(r) <= 0 && t("warning", r, "crop-marks needs bleed to draw into — trim marks sit outside the page box.", 'Add bleed="3" (mm), or drop crop-marks.', "crop-marks");
2443
+ const s = H(r, "safe-zone");
2416
2444
  if (s != null && s > 0) {
2417
2445
  const h = ct(r.getAttribute("size"), r.getAttribute("width"), r.getAttribute("height"), r.getAttribute("orientation"));
2418
2446
  s * 2 >= Math.min(h.widthMm, h.heightMm) && t("warning", r, `safe-zone=${s}mm leaves no usable area on a ${h.widthMm} × ${h.heightMm} mm page.`, "Use a smaller inset — 5–10mm is typical.", "safe-zone");
2419
2447
  }
2420
2448
  const o = r.getAttribute("format");
2421
2449
  o == null ? t("warning", r, "No format= on the cartograph root.", `Add format="${pt}" so future runtimes can migrate this document.`, "format") : o !== pt && t("warning", r, `Unrecognised document format "${o}".`, `This build understands "${pt}".`, "format");
2422
- const { widthMm: a, heightMm: l } = ct(e, r.getAttribute("width"), r.getAttribute("height"), r.getAttribute("orientation")), c = Math.max(0, V(r, "bleed") ?? 0), u = /* @__PURE__ */ new Set(), m = [...r.querySelectorAll("om-frame")];
2450
+ const { widthMm: a, heightMm: l } = ct(e, r.getAttribute("width"), r.getAttribute("height"), r.getAttribute("orientation")), c = Math.max(0, H(r, "bleed") ?? 0), u = /* @__PURE__ */ new Set(), m = [...r.querySelectorAll("om-frame")];
2423
2451
  for (const h of m)
2424
2452
  h.id ? u.add(h.id) : t("error", h, "Frame has no id.", "Give every frame an id so furniture can reference it with for=.", "id");
2425
2453
  for (const h of r.children) {
2426
- if (En.some((p) => h.hasAttribute(p))) continue;
2454
+ if (Nn.some((p) => h.hasAttribute(p))) continue;
2427
2455
  const f = h.tagName.toLowerCase();
2428
- !gt.includes(f) && !kn.has(f) && t("error", h, `<${f}> is not a cartograph element.`, `Use one of ${gt.join(", ")}, or move this content inside an <om-text>.`);
2456
+ !gt.includes(f) && !En.has(f) && t("error", h, `<${f}> is not a cartograph element.`, `Use one of ${gt.join(", ")}, or move this content inside an <om-text>.`);
2429
2457
  }
2430
2458
  const d = [];
2431
2459
  for (const h of [r, ...r.querySelectorAll("*")]) {
2432
2460
  const f = h.tagName.toLowerCase();
2433
2461
  if (gt.includes(f) && !h.closest("om-map")) {
2434
- if (_n(h, f, t), Pn.has(f)) {
2435
- const p = C(h);
2436
- On(h, p, a, l, c, t), Nn.has(f) && !h.hasAttribute("hidden") && d.push({ el: h, box: p });
2462
+ if (On(h, f, t), Tn.has(f)) {
2463
+ const p = S(h);
2464
+ Un(h, p, a, l, c, t), Pn.has(f) && !h.hasAttribute("hidden") && d.push({ el: h, box: p });
2437
2465
  }
2438
- f === "om-frame" && Un(h, t), f === "om-legend" && jn(h, m, t), f === "om-atlas" && zn(h, m, t), f === "om-scalebar" && Dn(h, m, t), f === "om-text" && Gn(h, m, t);
2466
+ f === "om-frame" && jn(h, t), f === "om-legend" && zn(h, m, t), f === "om-atlas" && Dn(h, m, t), f === "om-scalebar" && Gn(h, m, t), f === "om-text" && qn(h, m, t);
2439
2467
  for (const p of ["for", "overview-of"]) {
2440
2468
  const g = h.getAttribute(p);
2441
2469
  g && !u.has(g) && t("error", h, `${p}="${g}" references no frame on this page.`, `Point it at one of: ${[...u].join(", ") || "(no frames)"}.`, p);
@@ -2445,7 +2473,7 @@ function Rn(r, t) {
2445
2473
  for (let h = 0; h < d.length; h++)
2446
2474
  for (let f = h + 1; f < d.length; f++) {
2447
2475
  const p = d[h], g = d[f];
2448
- p.box.w <= 0 || p.box.h <= 0 || g.box.w <= 0 || g.box.h <= 0 || Fn(p.box, g.box) && t(
2476
+ p.box.w <= 0 || p.box.h <= 0 || g.box.w <= 0 || g.box.h <= 0 || In(p.box, g.box) && t(
2449
2477
  "warning",
2450
2478
  p.el,
2451
2479
  `Overlaps ${Ye(g.el)} on the page.`,
@@ -2453,7 +2481,7 @@ function Rn(r, t) {
2453
2481
  );
2454
2482
  }
2455
2483
  }
2456
- function _n(r, t, e) {
2484
+ function On(r, t, e) {
2457
2485
  const n = new Set(P[t] ?? []);
2458
2486
  for (const i of r.attributes) {
2459
2487
  const s = i.name.toLowerCase();
@@ -2466,7 +2494,7 @@ function _n(r, t, e) {
2466
2494
  e("warning", r, `Unknown attribute "${s}" on <${t}> — likely a typo.`, `Valid attributes: ${[...n].join(", ")}.`, s);
2467
2495
  }
2468
2496
  }
2469
- function On(r, t, e, n, i, s) {
2497
+ function Un(r, t, e, n, i, s) {
2470
2498
  if (t.w <= 0 || t.h <= 0) {
2471
2499
  s("error", r, `Element has no size (w=${t.w}, h=${t.h}).`, "Give w= and h= in millimetres — both greater than zero.", t.w <= 0 ? "w" : "h");
2472
2500
  return;
@@ -2485,7 +2513,7 @@ function On(r, t, e, n, i, s) {
2485
2513
  ["height", t.h]
2486
2514
  ];
2487
2515
  for (const [u, m] of c) {
2488
- const d = In(r, u);
2516
+ const d = Rn(r, u);
2489
2517
  d != null && Math.abs(d - m) > 0.01 && s(
2490
2518
  "error",
2491
2519
  r,
@@ -2495,7 +2523,7 @@ function On(r, t, e, n, i, s) {
2495
2523
  );
2496
2524
  }
2497
2525
  }
2498
- function Un(r, t) {
2526
+ function jn(r, t) {
2499
2527
  if ((r.getAttribute("mode") === "static" ? "static" : "live") === "static") {
2500
2528
  const n = r.getAttribute("corners"), i = mt(n);
2501
2529
  i || t(
@@ -2505,14 +2533,14 @@ function Un(r, t) {
2505
2533
  'Give four lon/lat pairs in tl, tr, br, bl order — corners="[[lng,lat],[lng,lat],[lng,lat],[lng,lat]]".',
2506
2534
  "corners"
2507
2535
  ), r.querySelector(":scope > img") || t("error", r, "Static frame has no <img> child to place.", "Add the georeferenced raster as an <img> child — it is also what renders with JavaScript disabled.");
2508
- const s = C(r), o = K(r.getAttribute("crs"));
2536
+ const s = S(r), o = K(r.getAttribute("crs"));
2509
2537
  if (i && o && s.w > 0 && s.h > 0) {
2510
2538
  const a = ht({ corners: i, widthMm: s.w, heightMm: s.h, crsForward: o });
2511
2539
  if (a.degenerate)
2512
2540
  t("error", r, "Frame corners are degenerate (collinear or coincident) — nothing can be placed on this frame.", "Check the corner order: tl, tr, br, bl.", "corners");
2513
2541
  else {
2514
2542
  const l = Br(a);
2515
- l != null && l > Tn && t(
2543
+ l != null && l > Ln && t(
2516
2544
  "warning",
2517
2545
  r,
2518
2546
  `Ground scale varies ${(l * 100).toFixed(1)}% across this frame, so a single scale bar is only true near its anchor.`,
@@ -2521,7 +2549,7 @@ function Un(r, t) {
2521
2549
  }
2522
2550
  }
2523
2551
  } else {
2524
- lt(r) || t(
2552
+ Q(r) || t(
2525
2553
  "error",
2526
2554
  r,
2527
2555
  "Live frame has no valid camera.",
@@ -2540,12 +2568,12 @@ function Un(r, t) {
2540
2568
  n && n !== "EPSG:3857" && t("error", r, `Live frame declares ${n}, but live frames render EPSG:3857.`, 'Use mode="static" with a georeferenced raster for other projections.', "crs");
2541
2569
  }
2542
2570
  }
2543
- function Rt(r, t) {
2571
+ function _t(r, t) {
2544
2572
  const e = r.getAttribute("for");
2545
2573
  return e ? t.find((n) => n.id === e) : t.length === 1 ? t[0] : void 0;
2546
2574
  }
2547
- function jn(r, t, e) {
2548
- const n = r.getAttribute("derived") !== "false", i = Rt(r, t);
2575
+ function zn(r, t, e) {
2576
+ const n = r.getAttribute("derived") !== "false", i = _t(r, t);
2549
2577
  n && i?.getAttribute("mode") === "static" && e(
2550
2578
  "warning",
2551
2579
  r,
@@ -2566,10 +2594,10 @@ function jn(r, t, e) {
2566
2594
  );
2567
2595
  }
2568
2596
  }
2569
- function zn(r, t, e) {
2597
+ function Dn(r, t, e) {
2570
2598
  const n = r.getAttribute("layer");
2571
2599
  n || e("error", r, "Atlas has no layer= to iterate.", 'Name a layer inside the frame, e.g. layer="parcels".', "layer");
2572
- const i = r.getAttribute("for"), s = Rt(r, t);
2600
+ const i = r.getAttribute("for"), s = _t(r, t);
2573
2601
  if (!s) {
2574
2602
  !i && t.length !== 1 && e("error", r, `Atlas does not say which frame drives it, and the page has ${t.length} frames.`, 'Add for="<frame id>".', "for");
2575
2603
  return;
@@ -2601,17 +2629,17 @@ function zn(r, t, e) {
2601
2629
  );
2602
2630
  }
2603
2631
  }
2604
- function Dn(r, t, e) {
2605
- const n = V(r, "segment-length");
2632
+ function Gn(r, t, e) {
2633
+ const n = H(r, "segment-length");
2606
2634
  if (n == null) return;
2607
- const i = Rt(r, t);
2635
+ const i = _t(r, t);
2608
2636
  if (!i) return;
2609
- const s = mt(i.getAttribute("corners")), o = K(i.getAttribute("crs")), a = C(i);
2637
+ const s = mt(i.getAttribute("corners")), o = K(i.getAttribute("crs")), a = S(i);
2610
2638
  if (!s || !o || a.w <= 0 || a.h <= 0) return;
2611
- const l = ht({ corners: s, widthMm: a.w, heightMm: a.h, crsForward: o }), c = C(r), u = ke({
2639
+ const l = ht({ corners: s, widthMm: a.w, heightMm: a.h, crsForward: o }), c = S(r), u = $e({
2612
2640
  groundMetersPerMm: l.groundMetersPerMm(),
2613
2641
  maxWidthMm: c.w,
2614
- segments: V(r, "segments") ?? void 0,
2642
+ segments: H(r, "segments") ?? void 0,
2615
2643
  segmentLengthMeters: n
2616
2644
  });
2617
2645
  u && u.totalMm > c.w + 1e-6 && e(
@@ -2622,9 +2650,9 @@ function Dn(r, t, e) {
2622
2650
  "segment-length"
2623
2651
  );
2624
2652
  }
2625
- function Gn(r, t, e) {
2653
+ function qn(r, t, e) {
2626
2654
  const n = r.textContent ?? "", i = /* @__PURE__ */ new Set(["title", "attribution", "date", "notes", "scale", "crs"]), s = new Set(t.map((o) => o.id).filter(Boolean));
2627
- for (const o of $r(n))
2655
+ for (const o of kr(n))
2628
2656
  if (!o.startsWith("atlas.")) {
2629
2657
  if (o.startsWith("frame.")) {
2630
2658
  const a = o.slice(6), l = a.lastIndexOf("."), c = l > 0 ? a.slice(0, l) : "", u = l > 0 ? a.slice(l + 1) : "";
@@ -2643,10 +2671,10 @@ function Gn(r, t, e) {
2643
2671
  i.has(o) || e("warning", r, `Unknown token {{${o}}} — it will render literally.`, `Known tokens: ${[...i].join(", ")}, frame.<id>.scale, frame.<id>.crs, atlas.<field>.`);
2644
2672
  }
2645
2673
  }
2646
- function Hn(r) {
2674
+ function Yn(r) {
2647
2675
  return Ke(pr(r));
2648
2676
  }
2649
- async function Yn(r) {
2677
+ async function Kn(r) {
2650
2678
  const t = Ke(r), e = [...r.querySelectorAll("om-frame")].filter((a) => a.querySelector(":scope > om-map"));
2651
2679
  if (e.length === 0) return t;
2652
2680
  const { loadCore: n } = await Promise.resolve().then(() => Je), i = await n(), s = [...t.errors], o = [...t.warnings];
@@ -2657,7 +2685,7 @@ async function Yn(r) {
2657
2685
  }
2658
2686
  return { valid: s.length === 0, errors: s, warnings: o };
2659
2687
  }
2660
- function Kn() {
2688
+ function Xn() {
2661
2689
  x("om-cartograph", Fe), x("om-text", Ie), x("om-frame", Ue), x("om-scalebar", je), x("om-north", ze), x("om-shape", De), x("om-image", Ge), x("om-legend", We), x("om-graticule", Ve), x("om-atlas", He);
2662
2690
  }
2663
2691
  ye(() => import("@nika-js/onlymap"));
@@ -2666,9 +2694,9 @@ export {
2666
2694
  P as CARTOGRAPH_ELEMENT_ATTRS,
2667
2695
  pt as CARTOGRAPH_FORMAT,
2668
2696
  gt as CARTOGRAPH_TAG_NAMES,
2669
- qn as CARTOGRAPH_THEMES,
2697
+ Wn as CARTOGRAPH_THEMES,
2670
2698
  ir as COLLAPSE_THRESHOLD,
2671
- Ft as CVD_MATRICES,
2699
+ It as CVD_MATRICES,
2672
2700
  dt as CVD_TYPES,
2673
2701
  rr as CVD_VALUES,
2674
2702
  Be as GEOGRAPHIC_PLANE,
@@ -2686,39 +2714,39 @@ export {
2686
2714
  je as OmScalebarElement,
2687
2715
  De as OmShapeElement,
2688
2716
  Ie as OmTextElement,
2689
- Ot as PAGE_PRESETS,
2690
- Bt as PAGE_SIZE_NAMES,
2691
- j as PLACED_ATTR_NAMES,
2692
- W as PX_PER_MM,
2717
+ Ut as PAGE_PRESETS,
2718
+ Vt as PAGE_SIZE_NAMES,
2719
+ z as PLACED_ATTR_NAMES,
2720
+ j as PX_PER_MM,
2693
2721
  Sr as SCALE_GROUP_SEPARATOR,
2694
2722
  hr as URL_ACTION_TIMEOUT_MS,
2695
2723
  Fr as alignOffset,
2696
2724
  Le as allFrames,
2697
2725
  sr as applyCvdToCanvas,
2698
- kr as applyTokens,
2726
+ $r as applyTokens,
2699
2727
  mr as applyUrlActions,
2700
- Tt as atlasFields,
2701
- Vn as boundsArea,
2702
- C as boxMm,
2703
- un as buildGraticule,
2704
- Mn as buildPages,
2705
- ke as buildScalebar,
2728
+ Lt as atlasFields,
2729
+ Hn as boundsArea,
2730
+ S as boxMm,
2731
+ hn as buildGraticule,
2732
+ vn as buildPages,
2733
+ $e as buildScalebar,
2706
2734
  Ar as buildScalebarDrawing,
2707
2735
  K as builtinCrsForward,
2708
- Wn as canvasMeasurer,
2736
+ Bn as canvasMeasurer,
2709
2737
  Pr as clearUnlinked,
2710
- Bn as cornersFromBounds,
2711
- se as cornersFromCamera,
2738
+ Vn as cornersFromBounds,
2739
+ Pt as cornersFromCamera,
2712
2740
  ht as createFrameGeoref,
2713
2741
  er as createZip,
2714
- Kn as defineCartographElements,
2715
- Dt as deltaE00,
2716
- sn as deriveLegendRows,
2742
+ Xn as defineCartographElements,
2743
+ Gt as deltaE00,
2744
+ an as deriveLegendRows,
2717
2745
  ar as ensureCvdFilters,
2718
- yn as featureBounds,
2746
+ wn as featureBounds,
2719
2747
  I as fieldOf,
2720
2748
  Te as findFrame,
2721
- dn as formatDms,
2749
+ fn as formatDms,
2722
2750
  Cr as formatScaleDenominator,
2723
2751
  dr as installUrlActions,
2724
2752
  Ze as isCoreLoaded,
@@ -2726,43 +2754,44 @@ export {
2726
2754
  Lr as layoutText,
2727
2755
  or as lintLegendColours,
2728
2756
  we as loadCore,
2757
+ Kr as maxGeoreferenceablePitch,
2729
2758
  _r as mercatorForward,
2730
2759
  Or as mercatorInverse,
2731
2760
  de as niceInterval,
2732
- $e as niceNumberBelow,
2761
+ ke as niceNumberBelow,
2733
2762
  Y as normalizeCrs,
2734
2763
  Wr as northBearingDegrees,
2735
2764
  Pe as ownerCartograph,
2736
- wn as padBounds,
2737
- _t as paintEnvForDpi,
2765
+ Mn as padBounds,
2766
+ Ot as paintEnvForDpi,
2738
2767
  nr as parseColor,
2739
2768
  mt as parseCorners,
2740
- An as parseSort,
2741
- H as peekCore,
2742
- lt as readCamera,
2769
+ Sn as parseSort,
2770
+ G as peekCore,
2771
+ Q as readCamera,
2743
2772
  qe as readLiteralRows,
2744
- cn as readOverrides,
2773
+ un as readOverrides,
2745
2774
  O as referencedFrame,
2746
- bn as rejectionFor,
2747
- It as renderCartograph,
2775
+ yn as rejectionFor,
2776
+ Rt as renderCartograph,
2748
2777
  Ce as renderCartographAtlas,
2749
2778
  Oe as resolveCrsForward,
2750
- Lt as resolveCvdType,
2751
- xn as resolveFilenames,
2779
+ Ft as resolveCvdType,
2780
+ kn as resolveFilenames,
2752
2781
  ct as resolvePageSize,
2753
2782
  xr as resolveToken,
2754
2783
  Ne as resolveTokens,
2755
- on as rowColorFor,
2784
+ sn as rowColorFor,
2756
2785
  Hr as sanitizeAdoptedMap,
2757
- Cn as sanitizeFilename,
2786
+ xn as sanitizeFilename,
2758
2787
  Br as scaleVariation,
2759
2788
  ye as setCoreLoader,
2760
- jt as simulate,
2761
- nn as swatchShapeFor,
2762
- $r as tokensIn,
2763
- ne as utmDef,
2789
+ zt as simulate,
2790
+ on as swatchShapeFor,
2791
+ kr as tokensIn,
2792
+ ie as utmDef,
2764
2793
  Ke as validateCartograph,
2765
- Yn as validateCartographDeep,
2766
- Hn as validateCartographString,
2767
- Wt as whenPageReady
2794
+ Kn as validateCartographDeep,
2795
+ Yn as validateCartographString,
2796
+ Bt as whenPageReady
2768
2797
  };