@nika-js/onlymap 0.10.8 → 0.10.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +1 -1
  3. package/dist/{basemap-BVnjFQjy.js → basemap-BH76eQA0.js} +2 -2
  4. package/dist/cartograph/element-base.d.ts +9 -0
  5. package/dist/cartograph/elements/om-atlas.d.ts +24 -0
  6. package/dist/cartograph/elements/om-legend.d.ts +4 -0
  7. package/dist/cartograph/render.d.ts +12 -0
  8. package/dist/cartograph.js +866 -726
  9. package/dist/cartograph.standalone.js +1768 -1628
  10. package/dist/{geoparquet-B9T6_4zS.js → geoparquet-DzKLe-0r.js} +1 -1
  11. package/dist/{globe-view-H-M5WaEA.js → globe-view-B-prUQFh.js} +1 -1
  12. package/dist/{hillshade-CIVdviss.js → hillshade-CDng2Jsi.js} +1 -1
  13. package/dist/{index-C2dp0xNz.js → index-8Fj-yh7f.js} +2 -2
  14. package/dist/{index-DZAIpBqJ.js → index-CIo8LgRZ.js} +3 -3
  15. package/dist/{index-BmEcYwOm.js → index-CpLydTmE.js} +1 -1
  16. package/dist/{index-D_sOimHC.js → index-D86S8KJ1.js} +1 -1
  17. package/dist/{index-D2PbSGEg.js → index-DOfIeNux.js} +1 -1
  18. package/dist/{index-8Pn7CrwJ.js → index-DvEcTZ4i.js} +18 -18
  19. package/dist/{index-DZYIEPWK.js → index-Rvd-zFrS.js} +1 -1
  20. package/dist/{index-BnOXGh3D.js → index-cwieLGSg.js} +1 -1
  21. package/dist/{index-DlDUl8ad.js → index-laD2SEAB.js} +3 -3
  22. package/dist/{lerc-By_uKoCw.js → lerc-BJB4-X6n.js} +1 -1
  23. package/dist/onlymap.standalone.js +1 -1
  24. package/dist/onlymapjs.js +1 -1
  25. package/dist/{post-process-effect-nmzWxY7I.js → post-process-effect-Bd5plkno.js} +1 -1
  26. package/dist/{raster-2v19l86Q.js → raster-DJ6vvro6.js} +3 -3
  27. package/dist/{raster-pipeline-BvnoZO-T.js → raster-pipeline-BQhNhrPq.js} +1 -1
  28. package/dist/{text-on-path-huXjU_aC.js → text-on-path-CrqchF3O.js} +1 -1
  29. package/dist/version.d.ts +1 -1
  30. package/dist/{zarr-BTXLI2Nu.js → zarr-oAkG7ZLM.js} +2 -2
  31. package/docs/cartograph.md +33 -8
  32. package/llms.txt +1 -1
  33. package/onlymapjs.html-data.json +57 -1
  34. package/package.json +1 -1
  35. package/skills/onlymapjs/SKILL.md +1 -1
  36. package/skills/onlymapjs/references/syntax.md +4 -3
@@ -1,29 +1,29 @@
1
- let $t = null, J = null;
2
- function Ne(r) {
3
- $t = r;
1
+ let xt = null, Z = null;
2
+ function Pe(r) {
3
+ xt = r;
4
4
  }
5
- function cr() {
6
- return B !== null;
5
+ function dr() {
6
+ return V !== null;
7
7
  }
8
- let B = null;
9
- function Y() {
10
- return B;
8
+ let V = null;
9
+ function J() {
10
+ return V;
11
11
  }
12
- function Pe() {
13
- return B ? Promise.resolve(B) : J || ($t ? (J = Promise.resolve($t()).then((r) => (B = r, B)).catch((r) => {
14
- throw J = null, r;
15
- }), J) : Promise.reject(
12
+ function Te() {
13
+ return V ? Promise.resolve(V) : Z || (xt ? (Z = Promise.resolve(xt()).then((r) => (V = r, V)).catch((r) => {
14
+ throw Z = null, r;
15
+ }), Z) : Promise.reject(
16
16
  new Error(
17
17
  '[onlymapjs/cartograph] No map runtime loader is configured. Import the cartograph entry ("@nika-js/onlymap/cartograph" or its standalone build) rather than a submodule — the entry installs it.'
18
18
  )
19
19
  ));
20
20
  }
21
- const ur = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
21
+ const fr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
22
22
  __proto__: null,
23
- isCoreLoaded: cr,
24
- loadCore: Pe,
25
- peekCore: Y,
26
- setCoreLoader: Ne
23
+ isCoreLoaded: dr,
24
+ loadCore: Te,
25
+ peekCore: J,
26
+ setCoreLoader: Pe
27
27
  }, Symbol.toStringTag, { value: "Module" }));
28
28
  function Bt(r) {
29
29
  return { scale: r / 96, pxPerMm: r / 25.4 };
@@ -31,33 +31,33 @@ function Bt(r) {
31
31
  function ft(r) {
32
32
  return typeof r?.paintCartograph == "function";
33
33
  }
34
- const W = (r, t) => {
34
+ const K = (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: W(r, "x") ?? 0,
43
- y: W(r, "y") ?? 0,
44
- w: W(r, "w") ?? 0,
45
- h: W(r, "h") ?? 0,
46
- rotation: W(r, "rotation") ?? 0,
47
- z: W(r, "z")
42
+ x: K(r, "x") ?? 0,
43
+ y: K(r, "y") ?? 0,
44
+ w: K(r, "w") ?? 0,
45
+ h: K(r, "h") ?? 0,
46
+ rotation: K(r, "rotation") ?? 0,
47
+ z: K(r, "z")
48
48
  };
49
49
  }
50
- function xt(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;
54
54
  }
55
- function R(r) {
55
+ function F(r) {
56
56
  if (!r) return null;
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 D = 96 / 25.4, Vt = {
60
+ const D = 96 / 25.4, Kt = {
61
61
  A0: { widthMm: 841, heightMm: 1189 },
62
62
  A1: { widthMm: 594, heightMm: 841 },
63
63
  A2: { widthMm: 420, heightMm: 594 },
@@ -66,15 +66,15 @@ const D = 96 / 25.4, Vt = {
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
- }, Kt = "A4";
69
+ }, Vt = "A4";
70
70
  function ht(r, t, e, n) {
71
71
  const i = t != null ? Number(t) : NaN, o = e != null ? Number(e) : NaN;
72
72
  if (Number.isFinite(i) && i > 0 && Number.isFinite(o) && o > 0) return { widthMm: i, heightMm: o };
73
- const s = Vt[r ?? Kt] ?? Vt[Kt];
73
+ const s = Kt[r ?? Vt] ?? Kt[Vt];
74
74
  return n === "landscape" ? { widthMm: s.heightMm, heightMm: s.widthMm } : { ...s };
75
75
  }
76
76
  let rt = null;
77
- function hr(r) {
77
+ function pr(r) {
78
78
  if (!rt) {
79
79
  rt = new Uint32Array(256);
80
80
  for (let e = 0; e < 256; e++) {
@@ -87,29 +87,29 @@ function hr(r) {
87
87
  for (let e = 0; e < r.length; e++) t = rt[(t ^ r[e]) & 255] ^ t >>> 8;
88
88
  return (t ^ 4294967295) >>> 0;
89
89
  }
90
- function mr(r) {
90
+ function gr(r) {
91
91
  const t = Math.max(1980, r.getFullYear());
92
92
  return {
93
93
  time: r.getHours() << 11 | r.getMinutes() << 5 | Math.floor(r.getSeconds() / 2),
94
94
  date: t - 1980 << 9 | r.getMonth() + 1 << 5 | r.getDate()
95
95
  };
96
96
  }
97
- async function dr(r, t = /* @__PURE__ */ new Date()) {
98
- const e = new TextEncoder(), { time: n, date: i } = mr(t), o = [], s = [];
97
+ async function br(r, t = /* @__PURE__ */ new Date()) {
98
+ const e = new TextEncoder(), { time: n, date: i } = gr(t), o = [], s = [];
99
99
  let a = 0;
100
100
  for (const u of r) {
101
- const h = u.data instanceof Blob ? new Uint8Array(await u.data.arrayBuffer()) : u.data, d = e.encode(u.name), m = hr(h), f = new DataView(new ArrayBuffer(30));
102
- f.setUint32(0, 67324752, !0), f.setUint16(4, 20, !0), f.setUint16(6, 2048, !0), f.setUint16(8, 0, !0), f.setUint16(10, n, !0), f.setUint16(12, i, !0), f.setUint32(14, m, !0), f.setUint32(18, h.length, !0), f.setUint32(22, h.length, !0), f.setUint16(26, d.length, !0), f.setUint16(28, 0, !0), o.push(new Uint8Array(f.buffer), d, h), s.push({ name: u.name, bytes: h, crc: m, offset: a }), a += 30 + d.length + h.length;
101
+ const m = u.data instanceof Blob ? new Uint8Array(await u.data.arrayBuffer()) : u.data, d = e.encode(u.name), h = pr(m), f = new DataView(new ArrayBuffer(30));
102
+ f.setUint32(0, 67324752, !0), f.setUint16(4, 20, !0), f.setUint16(6, 2048, !0), f.setUint16(8, 0, !0), f.setUint16(10, n, !0), f.setUint16(12, i, !0), f.setUint32(14, h, !0), f.setUint32(18, m.length, !0), f.setUint32(22, m.length, !0), f.setUint16(26, d.length, !0), f.setUint16(28, 0, !0), o.push(new Uint8Array(f.buffer), d, m), s.push({ name: u.name, bytes: m, crc: h, offset: a }), a += 30 + d.length + m.length;
103
103
  }
104
104
  const l = a;
105
105
  for (const u of s) {
106
- const h = e.encode(u.name), d = new DataView(new ArrayBuffer(46));
107
- d.setUint32(0, 33639248, !0), d.setUint16(4, 20, !0), d.setUint16(6, 20, !0), d.setUint16(8, 2048, !0), d.setUint16(10, 0, !0), d.setUint16(12, n, !0), d.setUint16(14, i, !0), d.setUint32(16, u.crc, !0), d.setUint32(20, u.bytes.length, !0), d.setUint32(24, u.bytes.length, !0), d.setUint16(28, h.length, !0), d.setUint16(30, 0, !0), d.setUint16(32, 0, !0), d.setUint16(34, 0, !0), d.setUint16(36, 0, !0), d.setUint32(38, 0, !0), d.setUint32(42, u.offset, !0), o.push(new Uint8Array(d.buffer), h), a += 46 + h.length;
106
+ const m = e.encode(u.name), d = new DataView(new ArrayBuffer(46));
107
+ d.setUint32(0, 33639248, !0), d.setUint16(4, 20, !0), d.setUint16(6, 20, !0), d.setUint16(8, 2048, !0), d.setUint16(10, 0, !0), d.setUint16(12, n, !0), d.setUint16(14, i, !0), d.setUint32(16, u.crc, !0), d.setUint32(20, u.bytes.length, !0), d.setUint32(24, u.bytes.length, !0), d.setUint16(28, m.length, !0), d.setUint16(30, 0, !0), d.setUint16(32, 0, !0), d.setUint16(34, 0, !0), d.setUint16(36, 0, !0), d.setUint32(38, 0, !0), d.setUint32(42, u.offset, !0), o.push(new Uint8Array(d.buffer), m), a += 46 + m.length;
108
108
  }
109
109
  const c = new DataView(new ArrayBuffer(22));
110
110
  return c.setUint32(0, 101010256, !0), c.setUint16(4, 0, !0), c.setUint16(6, 0, !0), c.setUint16(8, s.length, !0), c.setUint16(10, s.length, !0), c.setUint32(12, a - l, !0), c.setUint32(16, l, !0), c.setUint16(20, 0, !0), o.push(new Uint8Array(c.buffer)), new Blob(o, { type: "application/zip" });
111
111
  }
112
- const mt = ["protanopia", "deuteranopia", "tritanopia", "achromatopsia"], Te = {
112
+ const mt = ["protanopia", "deuteranopia", "tritanopia", "achromatopsia"], Le = {
113
113
  protan: "protanopia",
114
114
  deutan: "deuteranopia",
115
115
  tritan: "tritanopia",
@@ -117,21 +117,21 @@ const mt = ["protanopia", "deuteranopia", "tritanopia", "achromatopsia"], Te = {
117
117
  };
118
118
  function Dt(r) {
119
119
  const t = r?.trim().toLowerCase();
120
- return !t || t === "none" ? null : mt.includes(t) ? t : Te[t] ?? null;
120
+ return !t || t === "none" ? null : mt.includes(t) ? t : Le[t] ?? null;
121
121
  }
122
- const fr = ["none", ...mt, ...Object.keys(Te)], jt = {
122
+ const yr = ["none", ...mt, ...Object.keys(Le)], zt = {
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
- }, G = (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
130
  }, ct = (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
  };
134
- function gr(r) {
134
+ function wr(r) {
135
135
  const t = r.trim().toLowerCase(), e = /^#([0-9a-f]{3}|[0-9a-f]{6})$/.exec(t);
136
136
  if (e) {
137
137
  const i = e[1], o = (s) => parseInt(s.length === 1 ? s + s : s, 16);
@@ -141,7 +141,7 @@ function gr(r) {
141
141
  return n ? { r: Number(n[1]), g: Number(n[2]), b: Number(n[3]) } : null;
142
142
  }
143
143
  function Ht(r, t) {
144
- const e = jt[t], [n, i, o] = [G(r.r), G(r.g), G(r.b)];
144
+ const e = zt[t], [n, i, o] = [q(r.r), q(r.g), q(r.b)];
145
145
  return {
146
146
  r: ct(e[0] * n + e[1] * i + e[2] * o),
147
147
  g: ct(e[3] * n + e[4] * i + e[5] * o),
@@ -149,28 +149,28 @@ function Ht(r, t) {
149
149
  };
150
150
  }
151
151
  function Yt({ r, g: t, b: e }) {
152
- const [n, i, o] = [G(r), G(t), G(e)], s = (n * 0.4124564 + i * 0.3575761 + o * 0.1804375) / 0.95047, a = n * 0.2126729 + i * 0.7151522 + o * 0.072175, l = (n * 0.0193339 + i * 0.119192 + o * 0.9503041) / 1.08883, c = (m) => m > 216 / 24389 ? Math.cbrt(m) : 841 / 108 * m + 4 / 29, [u, h, d] = [c(s), c(a), c(l)];
153
- return [116 * h - 16, 500 * (u - h), 200 * (h - d)];
152
+ const [n, i, o] = [q(r), q(t), q(e)], s = (n * 0.4124564 + i * 0.3575761 + o * 0.1804375) / 0.95047, a = n * 0.2126729 + i * 0.7151522 + o * 0.072175, l = (n * 0.0193339 + i * 0.119192 + o * 0.9503041) / 1.08883, c = (h) => h > 216 / 24389 ? Math.cbrt(h) : 841 / 108 * h + 4 / 29, [u, m, d] = [c(s), c(a), c(l)];
153
+ return [116 * m - 16, 500 * (u - m), 200 * (m - d)];
154
154
  }
155
155
  function Xt(r, t) {
156
- const [e, n, i] = Yt(r), [o, s, a] = Yt(t), l = Math.PI / 180, c = 180 / Math.PI, u = (Math.hypot(n, i) + Math.hypot(s, a)) / 2, h = 0.5 * (1 - Math.sqrt(u ** 7 / (u ** 7 + 25 ** 7))), [d, m] = [n * (1 + h), s * (1 + h)], [f, g] = [Math.hypot(d, i), Math.hypot(m, a)], p = (U, et) => {
157
- if (U === 0 && et === 0) return 0;
158
- const X = Math.atan2(et, U) * c;
159
- return X >= 0 ? X : X + 360;
160
- }, [b, w] = [p(d, i), p(m, a)], y = o - e, M = g - f;
156
+ const [e, n, i] = Yt(r), [o, s, a] = Yt(t), l = Math.PI / 180, c = 180 / Math.PI, u = (Math.hypot(n, i) + Math.hypot(s, a)) / 2, m = 0.5 * (1 - Math.sqrt(u ** 7 / (u ** 7 + 25 ** 7))), [d, h] = [n * (1 + m), s * (1 + m)], [f, g] = [Math.hypot(d, i), Math.hypot(h, a)], p = (L, R) => {
157
+ if (L === 0 && R === 0) return 0;
158
+ const B = Math.atan2(R, L) * c;
159
+ return B >= 0 ? B : B + 360;
160
+ }, [b, w] = [p(d, i), p(h, a)], y = o - e, A = g - f;
161
161
  let v = 0;
162
162
  f * g !== 0 && (v = w - b, v > 180 ? v -= 360 : v < -180 && (v += 360));
163
- const N = 2 * Math.sqrt(f * g) * Math.sin(v * l / 2), _ = (e + o) / 2, $ = (f + g) / 2;
164
- let P = b + w;
165
- f * g !== 0 && (Math.abs(b - w) > 180 && (P += b + w < 360 ? 360 : -360), P /= 2);
166
- const L = 1 - 0.17 * Math.cos((P - 30) * l) + 0.24 * Math.cos(2 * P * l) + 0.32 * Math.cos((3 * P + 6) * l) - 0.2 * Math.cos((4 * P - 63) * l), A = 1 + 0.015 * (_ - 50) ** 2 / Math.sqrt(20 + (_ - 50) ** 2), S = 1 + 0.045 * $, x = 1 + 0.015 * $ * L, E = -2 * Math.sqrt($ ** 7 / ($ ** 7 + 25 ** 7)) * Math.sin(60 * Math.exp(-(((P - 275) / 25) ** 2)) * l);
167
- return Math.sqrt((y / A) ** 2 + (M / S) ** 2 + (N / x) ** 2 + E * (M / S) * (N / x));
168
- }
169
- const pr = 10;
170
- function br(r, t = pr) {
163
+ const $ = 2 * Math.sqrt(f * g) * Math.sin(v * l / 2), G = (e + o) / 2, _ = (f + g) / 2;
164
+ let E = b + w;
165
+ f * g !== 0 && (Math.abs(b - w) > 180 && (E += b + w < 360 ? 360 : -360), E /= 2);
166
+ const N = 1 - 0.17 * Math.cos((E - 30) * l) + 0.24 * Math.cos(2 * E * l) + 0.32 * Math.cos((3 * E + 6) * l) - 0.2 * Math.cos((4 * E - 63) * l), M = 1 + 0.015 * (G - 50) ** 2 / Math.sqrt(20 + (G - 50) ** 2), C = 1 + 0.045 * _, P = 1 + 0.015 * _ * N, x = -2 * Math.sqrt(_ ** 7 / (_ ** 7 + 25 ** 7)) * Math.sin(60 * Math.exp(-(((E - 275) / 25) ** 2)) * l);
167
+ return Math.sqrt((y / M) ** 2 + (A / C) ** 2 + ($ / P) ** 2 + x * (A / C) * ($ / P));
168
+ }
169
+ const vr = 10;
170
+ function Ar(r, t = vr) {
171
171
  const e = /* @__PURE__ */ new Map();
172
172
  for (const a of r) {
173
- const l = gr(a.color);
173
+ const l = wr(a.color);
174
174
  if (!l) continue;
175
175
  const c = a.layer ?? "", u = e.get(c);
176
176
  u ? u.push({ entry: a, rgb: l }) : e.set(c, [{ entry: a, rgb: l }]);
@@ -189,7 +189,7 @@ function br(r, t = pr) {
189
189
  l > s && (s = l, o = a);
190
190
  return { collapses: n, worstType: o };
191
191
  }
192
- function yr(r, t, e, n) {
192
+ function Mr(r, t, e, n) {
193
193
  if (t <= 0 || e <= 0) return !0;
194
194
  let i;
195
195
  try {
@@ -198,36 +198,36 @@ function yr(r, t, e, n) {
198
198
  return !1;
199
199
  }
200
200
  const o = new Float64Array(256);
201
- for (let h = 0; h < 256; h++) o[h] = G(h);
201
+ for (let m = 0; m < 256; m++) o[m] = q(m);
202
202
  const s = 1024, a = new Float64Array(s + 1);
203
- for (let h = 0; h <= s; h++) a[h] = ct(h / s);
204
- const l = (h) => {
205
- const d = Math.min(1, Math.max(0, h)) * s, m = Math.floor(d);
206
- return m >= s ? a[s] : a[m] + (a[m + 1] - a[m]) * (d - m);
207
- }, c = jt[n], u = i.data;
208
- for (let h = 0; h < u.length; h += 4) {
209
- const d = o[u[h]], m = o[u[h + 1]], f = o[u[h + 2]];
210
- u[h] = l(c[0] * d + c[1] * m + c[2] * f), u[h + 1] = l(c[3] * d + c[4] * m + c[5] * f), u[h + 2] = l(c[6] * d + c[7] * m + c[8] * f);
203
+ for (let m = 0; m <= s; m++) a[m] = ct(m / s);
204
+ const l = (m) => {
205
+ const d = Math.min(1, Math.max(0, m)) * s, h = Math.floor(d);
206
+ return h >= s ? a[s] : a[h] + (a[h + 1] - a[h]) * (d - h);
207
+ }, c = zt[n], u = i.data;
208
+ for (let m = 0; m < u.length; m += 4) {
209
+ const d = o[u[m]], h = o[u[m + 1]], f = o[u[m + 2]];
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);
211
211
  }
212
212
  return r.putImageData(i, 0, 0), !0;
213
213
  }
214
- const Le = (r) => `om-carto-cvd-${r}`;
215
- function wr(r) {
214
+ const Re = (r) => `om-carto-cvd-${r}`;
215
+ function Sr(r) {
216
216
  if (r.getElementById("om-carto-cvd-filters")) return;
217
217
  const t = r.createElementNS("http://www.w3.org/2000/svg", "svg");
218
218
  t.id = "om-carto-cvd-filters", t.setAttribute("aria-hidden", "true"), t.setAttribute("width", "0"), t.setAttribute("height", "0"), t.style.cssText = "position:absolute;width:0;height:0;overflow:hidden;";
219
219
  for (const e of mt) {
220
220
  const n = r.createElementNS("http://www.w3.org/2000/svg", "filter");
221
- n.id = Le(e), n.setAttribute("color-interpolation-filters", "linearRGB");
221
+ n.id = Re(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 o = jt[e];
224
+ const o = zt[e];
225
225
  i.setAttribute("values", [o[0], o[1], o[2], 0, 0, o[3], o[4], o[5], 0, 0, o[6], o[7], o[8], 0, 0, 0, 0, 0, 1, 0].join(" ")), n.appendChild(i), t.appendChild(n);
226
226
  }
227
227
  r.body.appendChild(t);
228
228
  }
229
- const Re = 16384, Fe = 134217728;
230
- async function vr(r) {
229
+ const Fe = 16384, Ie = 134217728;
230
+ async function Cr(r) {
231
231
  const t = [], e = [...r.querySelectorAll("img")];
232
232
  return await Promise.all(
233
233
  e.map(async (n) => {
@@ -240,12 +240,13 @@ async function vr(r) {
240
240
  })
241
241
  ), t;
242
242
  }
243
- function Mr(r) {
244
- return [...r.children].filter(
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);
243
+ function Oe(r) {
244
+ return !r.hasAttribute("hidden") && !r.hasAttribute("data-om-carto-screen-only") && !r.hasAttribute("data-om-carto-marks") && !r.hasAttribute("data-om-carto-flattened") && r.tagName.toLowerCase() !== "style" && r.tagName.toLowerCase() !== "script";
245
+ }
246
+ function kr(r) {
247
+ return [...r.children].filter(Oe).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
248
  }
248
- async function zt(r, t = {}) {
249
+ async function jt(r, t = {}) {
249
250
  const e = r ?? document.querySelector("om-cartograph");
250
251
  if (!e) throw new Error("[onlymapjs/cartograph] renderCartograph: no <om-cartograph> to render.");
251
252
  const n = [], i = t.dpi ?? (Number(e.getAttribute("dpi")) || 300);
@@ -255,53 +256,53 @@ async function zt(r, t = {}) {
255
256
  e.getAttribute("width"),
256
257
  e.getAttribute("height"),
257
258
  e.getAttribute("orientation")
258
- ), a = Math.max(0, Number(e.getAttribute("bleed")) || 0), l = o + a * 2, c = s + a * 2, u = t.maxDimension ?? Re, h = t.maxArea ?? Fe;
259
+ ), a = Math.max(0, Number(e.getAttribute("bleed")) || 0), l = o + a * 2, c = s + a * 2, u = t.maxDimension ?? Fe, m = t.maxArea ?? Ie;
259
260
  let d = i;
260
- const m = Math.min(u / (l / 25.4), u / (c / 25.4)), f = Math.sqrt(h / (l / 25.4 * (c / 25.4))), g = Math.min(m, f);
261
- d > g && (d = Math.floor(g), 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 vr(e)), typeof document < "u" && document.fonts?.ready && await document.fonts.ready;
262
- const p = Bt(d), b = Math.max(1, Math.round(l * p.pxPerMm)), w = Math.max(1, Math.round(c * p.pxPerMm)), y = Mr(e);
263
- for (const A of y)
264
- if (!(!ft(A) || !A.prepareCartograph))
261
+ const h = Math.min(u / (l / 25.4), u / (c / 25.4)), f = Math.sqrt(m / (l / 25.4 * (c / 25.4))), g = Math.min(h, f);
262
+ d > g && (d = Math.floor(g), 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 Cr(e)), typeof document < "u" && document.fonts?.ready && await document.fonts.ready;
263
+ const p = Bt(d), b = Math.max(1, Math.round(l * p.pxPerMm)), w = Math.max(1, Math.round(c * p.pxPerMm)), y = kr(e);
264
+ for (const M of y)
265
+ if (!(!ft(M) || !M.prepareCartograph))
265
266
  try {
266
- await A.prepareCartograph(Bt(d));
267
- } catch (S) {
268
- A.discardCartograph?.(), n.push(`${A.tagName.toLowerCase()}${A.id ? `#${A.id}` : ""} could not be captured: ${S.message}`);
267
+ await M.prepareCartograph(Bt(d));
268
+ } catch (C) {
269
+ M.discardCartograph?.(), n.push(`${M.tagName.toLowerCase()}${M.id ? `#${M.id}` : ""} could not be captured: ${C.message}`);
269
270
  }
270
- const M = document.createElement("canvas");
271
- M.width = b, M.height = w;
272
- const v = M.getContext("2d");
271
+ const A = document.createElement("canvas");
272
+ A.width = b, A.height = w;
273
+ const v = A.getContext("2d");
273
274
  if (!v) throw new Error("[onlymapjs/cartograph] renderCartograph: could not get a 2D canvas context.");
274
- const N = typeof getComputedStyle == "function" ? getComputedStyle(e) : null;
275
- v.fillStyle = R(N?.backgroundColor) ?? "#ffffff", v.fillRect(0, 0, b, w);
276
- for (const A of y) {
277
- if (!ft(A)) continue;
278
- const S = C(A);
279
- if (v.save(), v.translate((S.x + a) * p.pxPerMm, (S.y + a) * p.pxPerMm), S.rotation) {
280
- const x = S.w / 2 * p.pxPerMm, E = S.h / 2 * p.pxPerMm;
281
- v.translate(x, E), v.rotate(S.rotation * Math.PI / 180), v.translate(-x, -E);
275
+ const $ = typeof getComputedStyle == "function" ? getComputedStyle(e) : null;
276
+ v.fillStyle = F($?.backgroundColor) ?? "#ffffff", v.fillRect(0, 0, b, w);
277
+ for (const M of y) {
278
+ if (!ft(M)) continue;
279
+ const C = S(M);
280
+ if (v.save(), v.translate((C.x + a) * p.pxPerMm, (C.y + a) * p.pxPerMm), C.rotation) {
281
+ const P = C.w / 2 * p.pxPerMm, x = C.h / 2 * p.pxPerMm;
282
+ v.translate(P, x), v.rotate(C.rotation * Math.PI / 180), v.translate(-P, -x);
282
283
  }
283
284
  try {
284
- A.paintCartograph(v, p);
285
- } catch (x) {
286
- n.push(`${A.tagName.toLowerCase()}${A.id ? `#${A.id}` : ""} failed to render: ${x.message}`);
285
+ M.paintCartograph(v, p);
286
+ } catch (P) {
287
+ n.push(`${M.tagName.toLowerCase()}${M.id ? `#${M.id}` : ""} failed to render: ${P.message}`);
287
288
  }
288
289
  v.restore();
289
290
  }
290
- const _ = e.querySelector(":scope > [data-om-carto-marks]");
291
- for (const A of _?.querySelectorAll("line") ?? []) {
292
- const S = Number(A.getAttribute("x1")), x = Number(A.getAttribute("y1")), E = Number(A.getAttribute("x2")), U = Number(A.getAttribute("y2"));
293
- [S, x, E, U].every(Number.isFinite) && (v.save(), v.strokeStyle = A.getAttribute("stroke") || "#000000", v.lineWidth = (Number(A.getAttribute("stroke-width")) || 0.2) * p.pxPerMm, v.beginPath(), v.moveTo((S + a) * p.pxPerMm, (x + a) * p.pxPerMm), v.lineTo((E + a) * p.pxPerMm, (U + a) * p.pxPerMm), v.stroke(), v.restore());
294
- }
295
- const $ = Dt(t.cvd === "page" ? e.getAttribute("cvd") : t.cvd);
296
- $ && !yr(v, b, w, $) && n.push("Colour-vision simulation was skipped: a cross-origin image on the page makes the export canvas unreadable.");
297
- for (const A of y) ft(A) && A.discardCartograph?.();
298
- const P = t.format === "jpeg" ? "image/jpeg" : "image/png";
299
- P === "image/jpeg" && e.querySelector("om-text") && n.push("JPEG compresses text edges — prefer PNG for a page carrying labels.");
300
- const L = await new Promise((A) => M.toBlob(A, P, t.quality));
301
- if (!L) throw new Error("[onlymapjs/cartograph] renderCartograph: the canvas produced no image (it may have exceeded a browser limit).");
302
- return { blob: L, widthPx: b, heightPx: w, dpi: d, warnings: n };
303
- }
304
- async function Ie(r, t = {}) {
291
+ const G = e.querySelector(":scope > [data-om-carto-marks]");
292
+ for (const M of G?.querySelectorAll("line") ?? []) {
293
+ const C = Number(M.getAttribute("x1")), P = Number(M.getAttribute("y1")), x = Number(M.getAttribute("x2")), L = Number(M.getAttribute("y2"));
294
+ [C, P, x, L].every(Number.isFinite) && (v.save(), v.strokeStyle = M.getAttribute("stroke") || "#000000", v.lineWidth = (Number(M.getAttribute("stroke-width")) || 0.2) * p.pxPerMm, v.beginPath(), v.moveTo((C + a) * p.pxPerMm, (P + a) * p.pxPerMm), v.lineTo((x + a) * p.pxPerMm, (L + a) * p.pxPerMm), v.stroke(), v.restore());
295
+ }
296
+ const _ = Dt(t.cvd === "page" ? e.getAttribute("cvd") : t.cvd);
297
+ _ && !Mr(v, b, w, _) && n.push("Colour-vision simulation was skipped: a cross-origin image on the page makes the export canvas unreadable.");
298
+ for (const M of y) ft(M) && M.discardCartograph?.();
299
+ const E = t.format === "jpeg" ? "image/jpeg" : "image/png";
300
+ E === "image/jpeg" && e.querySelector("om-text") && n.push("JPEG compresses text edges — prefer PNG for a page carrying labels.");
301
+ const N = await new Promise((M) => A.toBlob(M, E, t.quality));
302
+ if (!N) throw new Error("[onlymapjs/cartograph] renderCartograph: the canvas produced no image (it may have exceeded a browser limit).");
303
+ return { blob: N, widthPx: b, heightPx: w, dpi: d, warnings: n };
304
+ }
305
+ async function _e(r, t = {}) {
305
306
  const e = r ?? document.querySelector("om-cartograph");
306
307
  if (!e) throw new Error("[onlymapjs/cartograph] renderCartographAtlas: no <om-cartograph> to render.");
307
308
  const n = e.querySelector("om-atlas") ?? null;
@@ -313,21 +314,21 @@ async function Ie(r, t = {}) {
313
314
  const o = t.format === "jpeg" ? "jpg" : "png", s = n.filenames(o), a = [], l = n.index;
314
315
  try {
315
316
  if (t.page != null) {
316
- const h = Math.trunc(t.page);
317
- if (!Number.isInteger(h) || h < 0 || h >= i)
317
+ const m = Math.trunc(t.page);
318
+ if (!Number.isInteger(m) || m < 0 || m >= i)
318
319
  throw new Error(`[onlymapjs/cartograph] renderCartographAtlas: page ${t.page} is out of range (this atlas has ${i}).`);
319
- n.seek(h);
320
+ n.seek(m);
320
321
  const d = await Jt(e, t, a);
321
- return { blob: d.blob, filenames: [s[h]], pages: 1, dpi: d.dpi, warnings: a };
322
+ return { blob: d.blob, filenames: [s[m]], pages: 1, dpi: d.dpi, warnings: a };
322
323
  }
323
324
  const c = [];
324
325
  let u = t.dpi ?? 300;
325
- for (let h = 0; h < i; h++) {
326
- n.seek(h);
326
+ for (let m = 0; m < i; m++) {
327
+ n.seek(m);
327
328
  const d = await Jt(e, t, a);
328
- u = d.dpi, c.push({ name: s[h], data: d.blob }), t.onPage?.(h + 1, i);
329
+ u = d.dpi, c.push({ name: s[m], data: d.blob }), t.onPage?.(m + 1, i);
329
330
  }
330
- return { blob: await dr(c), filenames: s, pages: i, dpi: u, warnings: a };
331
+ return { blob: await br(c), filenames: s, pages: i, dpi: u, warnings: a };
331
332
  } finally {
332
333
  n.seek(l);
333
334
  }
@@ -335,15 +336,16 @@ async function Ie(r, t = {}) {
335
336
  async function Jt(r, t, e) {
336
337
  for (const i of r.querySelectorAll("om-frame"))
337
338
  await i.mapElement?.whenSettled?.({ timeout: 2e4 });
338
- const n = await zt(r, t);
339
+ const n = await jt(r, t);
339
340
  return e.push(...n.warnings), n;
340
341
  }
341
- const Ar = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
342
+ const xr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
342
343
  __proto__: null,
343
- MAX_CANVAS_AREA: Fe,
344
- MAX_CANVAS_DIMENSION: Re,
345
- renderCartograph: zt,
346
- renderCartographAtlas: Ie
344
+ MAX_CANVAS_AREA: Ie,
345
+ MAX_CANVAS_DIMENSION: Fe,
346
+ paintsInExport: Oe,
347
+ renderCartograph: jt,
348
+ renderCartographAtlas: _e
347
349
  }, Symbol.toStringTag, { value: "Module" }));
348
350
  function Zt(r, t, e = {}) {
349
351
  const n = URL.createObjectURL(r), i = document.createElement("a");
@@ -351,8 +353,8 @@ function Zt(r, t, e = {}) {
351
353
  const o = e.revokeAfterMs ?? 0;
352
354
  o > 0 ? setTimeout(() => URL.revokeObjectURL(n), o) : URL.revokeObjectURL(n);
353
355
  }
354
- const Sr = 3e4;
355
- async function Qt(r, t = Sr) {
356
+ const $r = 3e4;
357
+ async function Qt(r, t = $r) {
356
358
  let e = !1;
357
359
  const n = new Promise(
358
360
  (o) => setTimeout(() => {
@@ -372,7 +374,7 @@ async function Qt(r, t = Sr) {
372
374
  })();
373
375
  return await Promise.race([i, n]), { timedOut: e };
374
376
  }
375
- async function Cr(r, t = {}) {
377
+ async function Er(r, t = {}) {
376
378
  if (!r.hasAttribute("allow-url-actions") || typeof document < "u" && document.documentElement?.dataset?.omHost === "editor") return null;
377
379
  const e = t.search ?? (typeof location < "u" ? location.search : "");
378
380
  if (!e) return null;
@@ -383,42 +385,42 @@ async function Cr(r, t = {}) {
383
385
  await Qt(r, t.timeoutMs);
384
386
  const s = o === "jpeg" ? "jpeg" : "png", a = Number(n.get("dpi")) || void 0, l = r.getAttribute("cartograph-id") || "cartograph", c = n.get("page");
385
387
  if (c != null) {
386
- const h = r.querySelector("om-atlas");
387
- if (!h) throw new Error(`?page=${c} needs an <om-atlas>; this cartograph is a single sheet.`);
388
+ const m = r.querySelector("om-atlas");
389
+ if (!m) throw new Error(`?page=${c} needs an <om-atlas>; this cartograph is a single sheet.`);
388
390
  const d = Number(c);
389
391
  if (!Number.isInteger(d) || d < 1) throw new Error(`?page=${c} is not a page number (they start at 1).`);
390
- h.refresh?.();
391
- const m = await Ie(r, { dpi: a, format: s, page: d - 1 });
392
- for (const f of m.warnings) console.warn(`[onlymapjs/cartograph] ${f}`);
393
- return Zt(m.blob, m.filenames[0] ?? `${l}.${s === "jpeg" ? "jpg" : "png"}`, { revokeAfterMs: 1e4 }), "export";
392
+ m.refresh?.();
393
+ const h = await _e(r, { dpi: a, format: s, page: d - 1 });
394
+ for (const f of h.warnings) console.warn(`[onlymapjs/cartograph] ${f}`);
395
+ return Zt(h.blob, h.filenames[0] ?? `${l}.${s === "jpeg" ? "jpg" : "png"}`, { revokeAfterMs: 1e4 }), "export";
394
396
  }
395
- const u = await zt(r, { dpi: a, format: s });
396
- for (const h of u.warnings) console.warn(`[onlymapjs/cartograph] ${h}`);
397
+ const u = await jt(r, { dpi: a, format: s });
398
+ for (const m of u.warnings) console.warn(`[onlymapjs/cartograph] ${m}`);
397
399
  return Zt(u.blob, `${l}.${s === "jpeg" ? "jpg" : "png"}`, { revokeAfterMs: 1e4 }), "export";
398
400
  }
399
401
  return n.get("print") === "1" ? (await Qt(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
402
  }
401
- function kr() {
403
+ function Nr() {
402
404
  if (typeof document > "u") return;
403
405
  const r = () => {
404
406
  for (const t of document.querySelectorAll("om-cartograph[allow-url-actions]"))
405
- Cr(t).catch((e) => console.warn(`[onlymapjs/cartograph] URL action failed: ${e.message}`));
407
+ Er(t).catch((e) => console.warn(`[onlymapjs/cartograph] URL action failed: ${e.message}`));
406
408
  };
407
409
  document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", r, { once: !0 }) : r();
408
410
  }
409
- const _e = typeof window < "u" && typeof document < "u" && typeof customElements < "u", Oe = _e ? HTMLElement : class {
411
+ const Ue = typeof window < "u" && typeof document < "u" && typeof customElements < "u", De = Ue ? HTMLElement : class {
410
412
  };
411
413
  function k(r, t) {
412
- _e && (customElements.get(r) || customElements.define(r, t));
414
+ Ue && (customElements.get(r) || customElements.define(r, t));
413
415
  }
414
- function $r(r) {
416
+ function Pr(r) {
415
417
  if (typeof DOMParser > "u")
416
418
  throw new Error(
417
419
  "[onlymapjs] Parsing a manifest string needs a DOM implementation (DOMParser). In node, run under a DOM test environment — e.g. vitest with `environment: 'happy-dom'` (or jsdom) — or pass an already-parsed Element instead of a string."
418
420
  );
419
421
  return new DOMParser().parseFromString(r, "text/html");
420
422
  }
421
- class I extends Oe {
423
+ class O extends De {
422
424
  renderQueued = !1;
423
425
  connectedCallback() {
424
426
  this.scheduleRender();
@@ -435,6 +437,18 @@ class I extends Oe {
435
437
  this.renderQueued = !1, this.isConnected && this.renderNow();
436
438
  }));
437
439
  }
440
+ /**
441
+ * Apply an authored colour or font override to the theme property the
442
+ * element's styling reads. Written as the custom property itself — on this
443
+ * element, so it scopes to it — which is what lets one attribute reach the
444
+ * SVG the element draws, its computed style, and so the canvas exporter,
445
+ * which reads computed colour and keeps no second theme table. `alsoColor`
446
+ * writes the element's own `color` too, for painters that read that.
447
+ */
448
+ applyThemeOverride(t, e, n = !1) {
449
+ const i = this.getAttribute(t)?.trim();
450
+ i ? (this.style.setProperty(e, i), n && (this.style.color = i)) : (this.style.removeProperty(e), n && this.style.removeProperty("color"));
451
+ }
438
452
  /** Write the placed-element inline styles from the mm placement attributes. */
439
453
  applyPlacement() {
440
454
  const t = (l) => {
@@ -450,35 +464,35 @@ class I extends Oe {
450
464
  a != null && Number.isInteger(a) ? this.style.zIndex = String(a) : this.style.removeProperty("z-index");
451
465
  }
452
466
  }
453
- const gt = "cartograph/2", fi = ["default", "dark", "sepia", "blueprint", "minimal"], te = ["A0", "A1", "A2", "A3", "A4", "A5", "Letter", "Legal"], xr = /* @__PURE__ */ new Map([
467
+ const pt = "cartograph/2", Ai = ["default", "dark", "sepia", "blueprint", "minimal"], te = ["A0", "A1", "A2", "A3", "A4", "A5", "Letter", "Legal"], Tr = /* @__PURE__ */ new Map([
454
468
  ["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"], T = {
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", "keep-badge"],
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"],
469
+ ]), z = ["id", "x", "y", "w", "h", "rotation", "z", "locked", "hidden"], T = {
470
+ "om-cartograph": ["cartograph-id", "format", "size", "width", "height", "orientation", "theme", "bg", "color", "font", "title", "attribution", "notes", "cvd", "bleed", "crop-marks", "safe-zone", "dpi", "flatten", "color-profile", "allow-url-actions", "keep-badge"],
471
+ "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"],
472
+ "om-legend": [...z, "for", "title", "columns", "derived", "bg", "color", "stroke", "font-size", "padding"],
459
473
  "om-legend-row": ["layer", "match", "label", "hide", "order", "color", "shape"],
460
474
  // NOTE: the discriminator on furniture is `kind`, never `style` — `style` is
461
475
  // the global HTML attribute the runtime itself writes for mm placement, so
462
476
  // `style="double"` would be erased on the first render. `kind` also matches
463
477
  // 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"],
478
+ "om-scalebar": [...z, "for", "units", "segments", "segment-length", "kind", "color"],
479
+ "om-north": [...z, "for", "kind", "color"],
480
+ "om-graticule": [...z, "for", "crs", "crs-def", "interval", "interval-x", "interval-y", "kind", "labels", "format", "color"],
481
+ "om-text": [...z, "kind", "font-size", "weight", "align", "font", "color", "bg"],
482
+ "om-shape": [...z, "kind", "fill", "fill-opacity", "stroke", "stroke-width", "radius"],
483
+ "om-image": [...z, "src", "fit"],
470
484
  // NOT placed: a source is a child of <om-frame> that says where the frame's
471
485
  // picture may come from. Its corners/crs describe THAT source — a capture
472
486
  // carries the georeference that was true when it was taken, which is the
473
487
  // only way furniture can be right when the live map never loaded and its
474
488
  // CRS is therefore unknowable.
475
489
  "om-source": ["src", "corners", "crs", "crs-def"],
476
- "om-atlas": ["id", "for", "layer", "filter", "sort", "filename", "page-name"]
477
- }, pt = Object.keys(T), Et = "data-om-carto-vector", Er = ["metric", "imperial", "nautical"], Nr = 0.3048, Pr = 1609.344, Tr = 1852;
478
- function Lr(r) {
479
- return r != null && Er.includes(r) ? r : null;
490
+ "om-atlas": ["id", "for", "layer", "filter", "sort", "filename", "page-name", "pager"]
491
+ }, gt = Object.keys(T), Et = "data-om-carto-vector", Lr = ["metric", "imperial", "nautical"], Rr = 0.3048, Fr = 1609.344, Ir = 1852;
492
+ function Or(r) {
493
+ return r != null && Lr.includes(r) ? r : null;
480
494
  }
481
- function Ue(r) {
495
+ function ze(r) {
482
496
  if (!isFinite(r) || r <= 0) return 0;
483
497
  const t = Math.pow(10, Math.floor(Math.log10(r))), e = r / t;
484
498
  return (e >= 5 ? 5 : e >= 2 ? 2 : 1) * t;
@@ -490,12 +504,12 @@ const ee = {
490
504
  { metersPerUnit: 1e3, label: "km" }
491
505
  ],
492
506
  imperial: [
493
- { metersPerUnit: Nr, label: "ft" },
494
- { metersPerUnit: Pr, label: "mi" }
507
+ { metersPerUnit: Rr, label: "ft" },
508
+ { metersPerUnit: Fr, label: "mi" }
495
509
  ],
496
- nautical: [{ metersPerUnit: Tr, label: "nmi" }]
510
+ nautical: [{ metersPerUnit: Ir, label: "nmi" }]
497
511
  };
498
- function De({ groundMetersPerMm: r, maxWidthMm: t, segments: e = 4, units: n = "metric", segmentLengthMeters: i }) {
512
+ function je({ groundMetersPerMm: r, maxWidthMm: t, segments: e = 4, units: n = "metric", segmentLengthMeters: i }) {
499
513
  if (!Number.isFinite(r) || r <= 0 || !Number.isFinite(t) || t <= 0) return null;
500
514
  const o = Number.isInteger(e) && e > 0 ? e : 4, s = ee[n] ?? ee.metric, a = t / o * r;
501
515
  let l, c;
@@ -503,26 +517,26 @@ function De({ groundMetersPerMm: r, maxWidthMm: t, segments: e = 4, units: n = "
503
517
  l = i, c = re(s, l);
504
518
  else {
505
519
  c = re(s, a);
506
- const f = Ue(a / c.metersPerUnit);
520
+ const f = ze(a / c.metersPerUnit);
507
521
  if (f <= 0) return null;
508
522
  l = f * c.metersPerUnit;
509
523
  }
510
524
  const u = l / r;
511
525
  if (!Number.isFinite(u) || u <= 0) return null;
512
- const h = l / c.metersPerUnit, d = h < 1 ? 2 : h < 10 && !Number.isInteger(h) ? 1 : 0, m = Array.from({ length: o + 1 }, (f, g) => (g * h).toFixed(d));
526
+ const m = l / c.metersPerUnit, d = m < 1 ? 2 : m < 10 && !Number.isInteger(m) ? 1 : 0, h = Array.from({ length: o + 1 }, (f, g) => (g * m).toFixed(d));
513
527
  return {
514
528
  segmentMeters: l,
515
529
  segmentMm: u,
516
530
  segments: o,
517
531
  totalMm: u * o,
518
- labels: m,
532
+ labels: h,
519
533
  unitLabel: c.label,
520
534
  // 1 mm on the page is groundMetersPerMm metres on the ground; the RF is
521
535
  // that ratio in consistent units (mm : mm).
522
536
  scaleDenominator: r * 1e3
523
537
  };
524
538
  }
525
- function Rr(r, t, e) {
539
+ function _r(r, t, e) {
526
540
  const n = Math.min(2.6, Math.max(1.6, e * 0.34)), i = 0.2, o = n * 1.25, s = Math.max(0.6, Math.min(2.2, e - o - 0.4)), a = 0, l = r.segmentMm, c = [], u = [];
527
541
  if (t === "single" || t === "double") {
528
542
  const p = t === "double" ? 2 : 1, b = s / p;
@@ -544,21 +558,21 @@ function Rr(r, t, e) {
544
558
  u.push({ x1: w, y1: a, x2: w, y2: a + s });
545
559
  }
546
560
  }
547
- const h = r.labels.length - 1, d = r.labels.map((p, b) => ({
561
+ const m = r.labels.length - 1, d = r.labels.map((p, b) => ({
548
562
  // The end label carries the unit so the bar reads "0 2 4 6 8 km".
549
- text: b === h ? `${p} ${r.unitLabel}` : p,
563
+ text: b === m ? `${p} ${r.unitLabel}` : p,
550
564
  // Keep the end label inside the drawn width rather than hanging off it.
551
- x: b === h ? r.totalMm : b * l,
565
+ x: b === m ? r.totalMm : b * l,
552
566
  y: a + s + n,
553
- anchor: b === 0 ? "start" : b === h ? "end" : "middle",
567
+ anchor: b === 0 ? "start" : b === m ? "end" : "middle",
554
568
  index: b
555
- })), m = (p) => p.length * n * 0.62, f = [];
569
+ })), h = (p) => p.length * n * 0.62, f = [];
556
570
  let g = -1 / 0;
557
571
  for (const p of d) {
558
- const b = m(p.text) / 2, w = p.anchor === "start" ? p.x : p.anchor === "end" ? p.x - b * 2 : p.x - b, y = w + m(p.text);
559
- if (!(!(p.index === 0 || p.index === h) && w < g + n * 0.4)) {
560
- if (p.index === h && w < g + n * 0.4)
561
- for (; f.length > 1 && f[f.length - 1].x + m(f[f.length - 1].text) / 2 > w - n * 0.4; ) f.pop();
572
+ const b = h(p.text) / 2, w = p.anchor === "start" ? p.x : p.anchor === "end" ? p.x - b * 2 : p.x - b, y = w + h(p.text);
573
+ if (!(!(p.index === 0 || p.index === m) && w < g + n * 0.4)) {
574
+ if (p.index === m && w < g + n * 0.4)
575
+ for (; f.length > 1 && f[f.length - 1].x + h(f[f.length - 1].text) / 2 > w - n * 0.4; ) f.pop();
562
576
  f.push({ text: p.text, x: p.x, y: p.y, anchor: p.anchor }), g = y;
563
577
  }
564
578
  }
@@ -570,12 +584,12 @@ function re(r, t) {
570
584
  t / n.metersPerUnit >= 1 && (e = n);
571
585
  return e;
572
586
  }
573
- const Fr = " ";
574
- function Ir(r) {
575
- return !Number.isFinite(r) || r <= 0 ? "" : Math.round(r).toString().replace(/\B(?=(\d{3})+(?!\d))/g, Fr);
587
+ const Ur = " ";
588
+ function Dr(r) {
589
+ return !Number.isFinite(r) || r <= 0 ? "" : Math.round(r).toString().replace(/\B(?=(\d{3})+(?!\d))/g, Ur);
576
590
  }
577
- const je = /\{\{\s*([\w.]+)\s*\}\}/g;
578
- function _r(r, t) {
591
+ const Ge = /\{\{\s*([\w.]+)\s*\}\}/g;
592
+ function zr(r, t) {
579
593
  if (r.startsWith("atlas.")) return t.atlas?.[r.slice(6)];
580
594
  if (r.startsWith("frame.")) {
581
595
  const e = r.slice(6), n = e.lastIndexOf(".");
@@ -587,18 +601,18 @@ function _r(r, t) {
587
601
  }
588
602
  return t.page[r];
589
603
  }
590
- function ze(r, t) {
604
+ function qe(r, t) {
591
605
  const e = [];
592
- return { text: r.replace(je, (i, o) => {
593
- const s = _r(o, t);
606
+ return { text: r.replace(Ge, (i, o) => {
607
+ const s = zr(o, t);
594
608
  return s === void 0 ? (e.push(o), i) : s;
595
609
  }), unresolved: e };
596
610
  }
597
- function Or(r) {
598
- return [...r.matchAll(je)].map((t) => t[1]);
611
+ function jr(r) {
612
+ return [...r.matchAll(Ge)].map((t) => t[1]);
599
613
  }
600
614
  const ne = /* @__PURE__ */ new WeakMap();
601
- function Ur(r, t) {
615
+ function Gr(r, t) {
602
616
  const e = [], n = r.ownerDocument ?? (typeof document < "u" ? document : null);
603
617
  if (!n) return e;
604
618
  const i = n.createTreeWalker(
@@ -613,39 +627,39 @@ function Ur(r, t) {
613
627
  if (a = s.data, !a.includes("{{")) continue;
614
628
  ne.set(s, a);
615
629
  }
616
- const l = ze(a, t);
630
+ const l = qe(a, t);
617
631
  s.data !== l.text && (s.data = l.text), e.push(...l.unresolved);
618
632
  }
619
633
  return e;
620
634
  }
621
- function Dr(r = /* @__PURE__ */ new Date()) {
635
+ function qr(r = /* @__PURE__ */ new Date()) {
622
636
  return `${r.getFullYear()}-${String(r.getMonth() + 1).padStart(2, "0")}-${String(r.getDate()).padStart(2, "0")}`;
623
637
  }
624
638
  const Nt = "data-om-carto-unlinked";
625
- function Ge(r) {
639
+ function We(r) {
626
640
  return r.closest("om-cartograph");
627
641
  }
628
- function qe(r, t) {
629
- const e = Ge(r);
642
+ function Be(r, t) {
643
+ const e = We(r);
630
644
  if (!e || !t) return null;
631
645
  for (const n of e.querySelectorAll("om-frame"))
632
646
  if (n.id === t) return n;
633
647
  return null;
634
648
  }
635
- function We(r) {
649
+ function Ke(r) {
636
650
  return [...r.querySelectorAll("om-frame")];
637
651
  }
638
- function jr(r) {
639
- const t = Ge(r);
652
+ function Wr(r) {
653
+ const t = We(r);
640
654
  if (!t) return null;
641
- const e = We(t);
655
+ const e = Ke(t);
642
656
  return e.length === 1 ? e[0] : null;
643
657
  }
644
- function O(r) {
658
+ function U(r) {
645
659
  const t = r.getAttribute("for");
646
- return t ? qe(r, t) : jr(r);
660
+ return t ? Be(r, t) : Wr(r);
647
661
  }
648
- function q(r, t) {
662
+ function W(r, t) {
649
663
  let e = r.querySelector(`:scope > [${Nt}]`);
650
664
  if (!e) {
651
665
  for (const n of [...r.children])
@@ -654,11 +668,11 @@ function q(r, t) {
654
668
  }
655
669
  e.textContent !== t && (e.textContent = t);
656
670
  }
657
- function zr(r) {
671
+ function Br(r) {
658
672
  r.querySelector(`:scope > [${Nt}]`)?.remove();
659
673
  }
660
- const ie = "data-om-carto-page", se = "data-om-carto-marks", bt = "data-om-carto-credit", Be = "Built with OnlyMap by NIKA", Gr = `${Be} · free for non-commercial use`, nt = 2, oe = 1.2, yt = 2.4, ae = 1.5, wt = 1.2, le = 0.3, ce = 0.8, vt = "http://www.w3.org/2000/svg", qr = 6e4;
661
- class Ve extends I {
674
+ const ie = "data-om-carto-page", se = "data-om-carto-marks", bt = "data-om-carto-credit", Ve = "Built with OnlyMap by NIKA", Kr = `${Ve} · free for non-commercial use`, nt = 2, oe = 1.2, yt = 2.4, ae = 1.5, wt = 1.2, le = 0.3, ce = 0.8, vt = "http://www.w3.org/2000/svg", Vr = 6e4;
675
+ class He extends O {
662
676
  static observedAttributes = [...T["om-cartograph"]];
663
677
  frameListenerBound = !1;
664
678
  /** Fields of the atlas page currently displayed, for {{atlas.<field>}}. */
@@ -697,14 +711,14 @@ class Ve extends I {
697
711
  * runtime's job (issue #41 §9: the om-map carries the key).
698
712
  */
699
713
  renderCredit() {
700
- const t = Y();
714
+ const t = J();
701
715
  t && !this.unsubscribeLicense && typeof t.subscribeLicense == "function" && (this.unsubscribeLicense = t.subscribeLicense(() => this.renderCredit()));
702
716
  const e = this.creditMode(t, this.hasAttribute("keep-badge")), n = [...this.querySelectorAll("om-text")].some((a) => /onlymap/i.test(a.textContent ?? "")), i = this.querySelector(`:scope > [${bt}]`);
703
717
  if (e === "hidden" || n) {
704
718
  i?.remove();
705
719
  return;
706
720
  }
707
- const o = e === "voluntary" ? Be : Gr;
721
+ const o = e === "voluntary" ? Ve : Kr;
708
722
  if (i) {
709
723
  i.textContent !== o && (i.textContent = o), this.armCreditPainter(i);
710
724
  return;
@@ -759,12 +773,12 @@ class Ve extends I {
759
773
  try {
760
774
  window.print();
761
775
  } finally {
762
- o || setTimeout(s, qr);
776
+ o || setTimeout(s, Vr);
763
777
  }
764
778
  }
765
779
  /** Render the whole page to one image, for `flatten`. */
766
780
  async buildFlattenedImage(t) {
767
- const { renderCartograph: e } = await Promise.resolve().then(() => Ar), { blob: n } = await e(this, { dpi: t }), i = this.ownerDocument.createElement("img");
781
+ const { renderCartograph: e } = await Promise.resolve().then(() => xr), { blob: n } = await e(this, { dpi: t }), i = this.ownerDocument.createElement("img");
768
782
  i.src = URL.createObjectURL(n), i.setAttribute("data-om-carto-flattened", "");
769
783
  const o = this.bleedMm;
770
784
  return i.style.cssText = `position:absolute;left:${-o}mm;top:${-o}mm;width:calc(100% + ${o * 2}mm);height:calc(100% + ${o * 2}mm);z-index:2147483645;`, await i.decode().catch(() => {
@@ -785,20 +799,20 @@ class Ve extends I {
785
799
  }
786
800
  /** Values every `{{token}}` on this page resolves against. */
787
801
  tokenContext() {
788
- const t = /* @__PURE__ */ new Map(), e = We(this);
802
+ const t = /* @__PURE__ */ new Map(), e = Ke(this);
789
803
  for (const o of e) {
790
804
  const s = o.georef, a = s?.groundMetersPerMm() ?? 0;
791
805
  t.set(o.id, {
792
- scale: a > 0 ? Ir(a * 1e3) : void 0,
806
+ scale: a > 0 ? Dr(a * 1e3) : void 0,
793
807
  crs: s?.crs
794
808
  });
795
809
  }
796
- const n = { page: {}, frames: t, soleFrameId: e.length === 1 ? e[0].id : null, atlas: this.atlasFields }, i = (o) => ze(this.getAttribute(o) ?? "", n).text;
810
+ const n = { page: {}, frames: t, soleFrameId: e.length === 1 ? e[0].id : null, atlas: this.atlasFields }, i = (o) => qe(this.getAttribute(o) ?? "", n).text;
797
811
  return {
798
812
  page: {
799
813
  title: i("title"),
800
814
  attribution: i("attribution"),
801
- date: Dr(),
815
+ date: qr(),
802
816
  notes: i("notes")
803
817
  },
804
818
  frames: t,
@@ -815,7 +829,7 @@ class Ve extends I {
815
829
  }
816
830
  renderNow() {
817
831
  const { widthMm: t, heightMm: e } = this.pageSize, n = this.bleedMm;
818
- 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";
832
+ 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", this.applyThemeOverride("bg", "--om-carto-bg"), this.applyThemeOverride("color", "--om-carto-ink"), this.applyThemeOverride("font", "--om-carto-font");
819
833
  let i = this.querySelector(`style[${ie}]`);
820
834
  i || (i = document.createElement("style"), i.setAttribute(ie, ""), this.prepend(i));
821
835
  const o = t + n * 2, s = e + n * 2;
@@ -839,15 +853,15 @@ class Ve extends I {
839
853
  }
840
854
  const l = this.ownerDocument, c = a ?? l.createElementNS(vt, "svg");
841
855
  if (c.setAttribute(se, ""), 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) {
842
- const u = Math.min(n, 4), h = Math.min(n * 0.35, 1.5), d = [];
843
- for (const m of [0, t])
856
+ const u = Math.min(n, 4), m = Math.min(n * 0.35, 1.5), d = [];
857
+ for (const h of [0, t])
844
858
  for (const f of [0, e]) {
845
- const g = m === 0 ? -1 : 1, p = f === 0 ? -1 : 1;
846
- d.push([m + g * h, f, m + g * (h + u), f]), d.push([m, f + p * h, m, f + p * (h + u)]);
859
+ const g = h === 0 ? -1 : 1, p = f === 0 ? -1 : 1;
860
+ d.push([h + g * m, f, h + g * (m + u), f]), d.push([h, f + p * m, h, f + p * (m + u)]);
847
861
  }
848
- for (const [m, f, g, p] of d) {
862
+ for (const [h, f, g, p] of d) {
849
863
  const b = l.createElementNS(vt, "line");
850
- b.setAttribute("x1", String(m)), b.setAttribute("y1", String(f)), b.setAttribute("x2", String(g)), b.setAttribute("y2", String(p)), b.setAttribute("stroke", "#000"), b.setAttribute("stroke-width", "0.15"), c.appendChild(b);
864
+ b.setAttribute("x1", String(h)), b.setAttribute("y1", String(f)), b.setAttribute("x2", String(g)), b.setAttribute("y2", String(p)), b.setAttribute("stroke", "#000"), b.setAttribute("stroke-width", "0.15"), c.appendChild(b);
851
865
  }
852
866
  }
853
867
  if (s) {
@@ -870,20 +884,20 @@ class Ve extends I {
870
884
  this.style.removeProperty("filter");
871
885
  return;
872
886
  }
873
- wr(this.ownerDocument), this.style.filter = `url(#${Le(t)})`;
887
+ Sr(this.ownerDocument), this.style.filter = `url(#${Re(t)})`;
874
888
  }
875
889
  }
876
- k("om-cartograph", Ve);
877
- function Wr({ text: r, maxWidth: t, fontSizePx: e, lineHeightPx: n, measure: i }) {
890
+ k("om-cartograph", He);
891
+ function Hr({ text: r, maxWidth: t, fontSizePx: e, lineHeightPx: n, measure: i }) {
878
892
  const o = n > 0 ? n : e * 1.2, s = [];
879
893
  for (const c of r.split(/\r?\n/)) {
880
- const u = c.split(/\s+/).filter((m) => m !== "");
894
+ const u = c.split(/\s+/).filter((h) => h !== "");
881
895
  if (u.length === 0) {
882
896
  s.push({ text: "", baselineY: 0, width: 0 });
883
897
  continue;
884
898
  }
885
- const h = (m) => {
886
- let f = m;
899
+ const m = (h) => {
900
+ let f = h;
887
901
  for (; i(f) > t && f.length > 1; ) {
888
902
  let g = f.length - 1;
889
903
  for (; g > 1 && i(f.slice(0, g)) > t; ) g--;
@@ -892,9 +906,9 @@ function Wr({ text: r, maxWidth: t, fontSizePx: e, lineHeightPx: n, measure: i }
892
906
  return f;
893
907
  };
894
908
  let d = "";
895
- for (const m of u) {
896
- const f = d === "" ? m : `${d} ${m}`;
897
- d === "" ? d = h(m) : i(f) > t ? (s.push({ text: d, baselineY: 0, width: i(d) }), d = h(m)) : d = f;
909
+ for (const h of u) {
910
+ const f = d === "" ? h : `${d} ${h}`;
911
+ d === "" ? d = m(h) : i(f) > t ? (s.push({ text: d, baselineY: 0, width: i(d) }), d = m(h)) : d = f;
898
912
  }
899
913
  s.push({ text: d, baselineY: 0, width: i(d) });
900
914
  }
@@ -904,15 +918,15 @@ function Wr({ text: r, maxWidth: t, fontSizePx: e, lineHeightPx: n, measure: i }
904
918
  c.baselineY = a + u * o, c.width > l && (l = c.width);
905
919
  }), { lines: s, lineHeight: o, maxWidth: l };
906
920
  }
907
- function gi(r) {
921
+ function Mi(r) {
908
922
  if (typeof document > "u") return null;
909
923
  const e = document.createElement("canvas").getContext("2d");
910
924
  return e ? (e.font = r, (n) => e.measureText(n).width) : null;
911
925
  }
912
- function Br(r, t, e) {
926
+ function Yr(r, t, e) {
913
927
  return r === "center" ? (t - e) / 2 : r === "end" || r === "right" ? t - e : 0;
914
928
  }
915
- class Ke extends I {
929
+ class Ye extends O {
916
930
  static observedAttributes = [...T["om-text"]];
917
931
  renderNow() {
918
932
  this.applyPlacement(), this.style.display = "block", this.style.boxSizing = "border-box", this.style.overflow = "hidden";
@@ -932,18 +946,18 @@ class Ke extends I {
932
946
  /** Re-run token substitution from the authored templates. */
933
947
  resolveTokens() {
934
948
  const t = this.closest("om-cartograph");
935
- t && typeof t.tokenContext == "function" && Ur(this, t.tokenContext());
949
+ t && typeof t.tokenContext == "function" && Gr(this, t.tokenContext());
936
950
  }
937
951
  paintCartograph(t, e) {
938
- const { w: n, h: i } = C(this), o = n * e.pxPerMm, s = i * e.pxPerMm;
952
+ const { w: n, h: i } = S(this), o = n * e.pxPerMm, s = i * e.pxPerMm;
939
953
  if (o <= 0 || s <= 0) return;
940
- const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = R(a?.backgroundColor);
954
+ const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = F(a?.backgroundColor);
941
955
  l && (t.fillStyle = l, t.fillRect(0, 0, o, s));
942
956
  const c = (this.textContent ?? "").trim();
943
957
  if (c === "") return;
944
- const u = xt(a?.fontSize, 12), h = a?.lineHeight === "normal" ? u * 1.4 : xt(a?.lineHeight, u * 1.4), d = a?.fontFamily || "system-ui, sans-serif", m = a?.fontWeight || "400", f = u * e.scale, g = h * e.scale, p = `${m} ${f}px ${d}`;
945
- t.save(), t.font = p, t.fillStyle = R(a?.color) ?? "#000", t.textBaseline = "alphabetic", t.textAlign = "left";
946
- const b = Wr({
958
+ 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, g = m * e.scale, p = `${h} ${f}px ${d}`;
959
+ t.save(), t.font = p, t.fillStyle = F(a?.color) ?? "#000", t.textBaseline = "alphabetic", t.textAlign = "left";
960
+ const b = Hr({
947
961
  text: c,
948
962
  maxWidth: o,
949
963
  fontSizePx: f,
@@ -952,34 +966,34 @@ class Ke extends I {
952
966
  }), w = a?.textAlign || "start";
953
967
  for (const y of b.lines) {
954
968
  if (y.baselineY > s + g) break;
955
- t.fillText(y.text, Br(w, o, y.width), y.baselineY);
969
+ t.fillText(y.text, Yr(w, o, y.width), y.baselineY);
956
970
  }
957
971
  t.restore();
958
972
  }
959
973
  }
960
- k("om-text", Ke);
961
- const Vr = 63710087714e-4;
962
- let Kr = Vr;
974
+ k("om-text", Ye);
975
+ const Xr = 63710087714e-4;
976
+ let Jr = Xr;
963
977
  const it = Math.PI / 180;
964
- function Hr(r, t, e = Kr) {
978
+ function Zr(r, t, e = Jr) {
965
979
  const n = (t[1] - r[1]) * it, i = (t[0] - r[0]) * it, o = r[1] * it, s = t[1] * it, a = Math.sin(n / 2) ** 2 + Math.cos(o) * Math.cos(s) * Math.sin(i / 2) ** 2;
966
980
  return 2 * e * Math.asin(Math.min(1, Math.sqrt(a)));
967
981
  }
968
- const tt = 6378137, ue = Math.PI / 180, he = 180 / Math.PI, me = 85.0511287798066, Pt = 2 * Math.PI * tt / 360;
982
+ const et = 6378137, ue = Math.PI / 180, he = 180 / Math.PI, me = 85.0511287798066, Pt = 2 * Math.PI * et / 360;
969
983
  function Gt([r, t]) {
970
984
  const e = Math.max(-me, Math.min(me, t));
971
- return [tt * r * ue, tt * Math.log(Math.tan(Math.PI / 4 + e * ue / 2))];
985
+ return [et * r * ue, et * Math.log(Math.tan(Math.PI / 4 + e * ue / 2))];
972
986
  }
973
987
  function dt([r, t]) {
974
- return [r / tt * he, (2 * Math.atan(Math.exp(t / tt)) - Math.PI / 2) * he];
988
+ return [r / et * he, (2 * Math.atan(Math.exp(t / et)) - Math.PI / 2) * he];
975
989
  }
976
- const Yr = {
990
+ const Qr = {
977
991
  code: "EPSG:3857",
978
992
  units: "linear",
979
993
  metresPerUnit: 1,
980
994
  forward: Gt,
981
995
  inverse: dt
982
- }, Xr = {
996
+ }, tn = {
983
997
  code: "EPSG:4326",
984
998
  units: "degree",
985
999
  metresPerUnit: Pt,
@@ -993,16 +1007,16 @@ function qt(r) {
993
1007
  const e = /^(?:epsg:{1,2})?(\d{4,6})$/i.exec(t);
994
1008
  return e ? `EPSG:${e[1]}` : t.toUpperCase();
995
1009
  }
996
- function He(r) {
1010
+ function Xe(r) {
997
1011
  const t = qt(r) ?? "EPSG:3857";
998
- return t === "EPSG:3857" || t === "EPSG:900913" ? Yr : t === "EPSG:4326" || t === "CRS:84" || t === "OGC:CRS84" ? Xr : null;
1012
+ return t === "EPSG:3857" || t === "EPSG:900913" ? Qr : t === "EPSG:4326" || t === "CRS:84" || t === "OGC:CRS84" ? tn : null;
999
1013
  }
1000
- const Ye = /* @__PURE__ */ new Map();
1014
+ const Je = /* @__PURE__ */ new Map();
1001
1015
  function Tt(r, t) {
1002
1016
  return !Number.isInteger(r) || r < 1 || r > 60 ? null : `+proj=utm +zone=${r}${t === "S" ? " +south" : ""} +datum=WGS84 +units=m +no_defs`;
1003
1017
  }
1004
- async function Jr(r) {
1005
- const t = Ye.get(r);
1018
+ async function en(r) {
1019
+ const t = Je.get(r);
1006
1020
  if (typeof t == "string") return t;
1007
1021
  const e = Number(/^EPSG:(\d+)$/.exec(r)?.[1]);
1008
1022
  if (!Number.isFinite(e)) return null;
@@ -1011,22 +1025,22 @@ async function Jr(r) {
1011
1025
  const { CRS_DEFS: n } = await import("./crs-BzE_KP4M.js");
1012
1026
  return n[e]?.def ?? null;
1013
1027
  }
1014
- function Zr(r) {
1028
+ function rn(r) {
1015
1029
  if (r.projName === "longlat") return { units: "degree", metresPerUnit: Pt };
1016
1030
  if (typeof r.to_meter == "number" && r.to_meter > 0) return { units: "linear", metresPerUnit: r.to_meter };
1017
1031
  const t = (r.units ?? "m").toLowerCase();
1018
1032
  return t.startsWith("deg") ? { units: "degree", metresPerUnit: Pt } : t.includes("ft") || t.includes("foot") ? { units: "linear", metresPerUnit: 0.3048 } : { units: "linear", metresPerUnit: 1 };
1019
1033
  }
1020
- async function Qr(r, t) {
1021
- const e = qt(r) ?? "EPSG:3857", n = Ye.get(e);
1034
+ async function nn(r, t) {
1035
+ const e = qt(r) ?? "EPSG:3857", n = Je.get(e);
1022
1036
  if (n && typeof n != "string") return n;
1023
1037
  if (!t) {
1024
- const u = He(e);
1038
+ const u = Xe(e);
1025
1039
  if (u) return u;
1026
1040
  }
1027
- const i = t?.trim() || await Jr(e);
1041
+ const i = t?.trim() || await en(e);
1028
1042
  if (!i) return null;
1029
- const o = (await import("./index-CcLC9jE5.js")).default, a = o(i, "+proj=longlat +datum=WGS84 +no_defs"), { units: l, metresPerUnit: c } = Zr(new o.Proj(i));
1043
+ const o = (await import("./index-CcLC9jE5.js")).default, a = o(i, "+proj=longlat +datum=WGS84 +no_defs"), { units: l, metresPerUnit: c } = rn(new o.Proj(i));
1030
1044
  return {
1031
1045
  code: e,
1032
1046
  units: l,
@@ -1035,20 +1049,20 @@ async function Qr(r, t) {
1035
1049
  inverse: (u) => a.forward(u)
1036
1050
  };
1037
1051
  }
1038
- const de = Math.PI / 180, tn = 180 / Math.PI, en = { code: "EPSG:3857", forward: Gt, inverse: dt }, pi = Gt, bi = dt, fe = 6378137, ge = 89.9;
1039
- function rn([r, t]) {
1040
- const e = Math.max(-ge, Math.min(ge, t));
1052
+ const de = Math.PI / 180, sn = 180 / Math.PI, on = { code: "EPSG:3857", forward: Gt, inverse: dt }, Si = Gt, Ci = dt, fe = 6378137, pe = 89.9;
1053
+ function an([r, t]) {
1054
+ const e = Math.max(-pe, Math.min(pe, t));
1041
1055
  return [fe * r * de, fe * Math.log(Math.tan(Math.PI / 4 + e * de / 2))];
1042
1056
  }
1043
- const nn = { code: "EPSG:3857", forward: rn, inverse: dt }, Lt = qt;
1044
- function K(r) {
1045
- return He(r);
1057
+ const ln = { code: "EPSG:3857", forward: an, inverse: dt }, Lt = qt;
1058
+ function Y(r) {
1059
+ return Xe(r);
1046
1060
  }
1047
1061
  async function Rt(r, t) {
1048
- return Qr(r, t);
1062
+ return nn(r, t);
1049
1063
  }
1050
- const yi = Tt;
1051
- function sn(r, t) {
1064
+ const ki = Tt;
1065
+ function cn(r, t) {
1052
1066
  const e = t.length, n = r.map((i, o) => [...i, t[o]]);
1053
1067
  for (let i = 0; i < e; i++) {
1054
1068
  let o = i;
@@ -1064,23 +1078,23 @@ function sn(r, t) {
1064
1078
  }
1065
1079
  return n.map((i, o) => i[e] / i[o]);
1066
1080
  }
1067
- function on(r, t) {
1081
+ function un(r, t) {
1068
1082
  if (r.length !== 4 || t.length !== 4) return null;
1069
- const e = r.reduce((h, d) => h + d[0], 0) / 4, n = r.reduce((h, d) => h + d[1], 0) / 4, i = r.reduce((h, d) => h + Math.hypot(d[0] - e, d[1] - n), 0) / 4, o = i > 1e-12 ? Math.SQRT2 / i : 1, s = (h) => [(h[0] - e) * o, (h[1] - n) * o], a = [], l = [];
1070
- for (let h = 0; h < 4; h++) {
1071
- const [d, m] = s(r[h]), [f, g] = t[h];
1072
- a.push([d, m, 1, 0, 0, 0, -d * f, -m * f]), l.push(f), a.push([0, 0, 0, d, m, 1, -d * g, -m * g]), l.push(g);
1073
- }
1074
- const c = sn(a, l);
1075
- if (!c || c.some((h) => !Number.isFinite(h))) return null;
1076
- const u = (h) => [h[0] / o + e, h[1] / o + n];
1083
+ const e = r.reduce((m, d) => m + d[0], 0) / 4, n = r.reduce((m, d) => m + d[1], 0) / 4, i = r.reduce((m, d) => m + Math.hypot(d[0] - e, d[1] - n), 0) / 4, o = i > 1e-12 ? Math.SQRT2 / i : 1, s = (m) => [(m[0] - e) * o, (m[1] - n) * o], a = [], l = [];
1084
+ for (let m = 0; m < 4; m++) {
1085
+ const [d, h] = s(r[m]), [f, g] = t[m];
1086
+ a.push([d, h, 1, 0, 0, 0, -d * f, -h * f]), l.push(f), a.push([0, 0, 0, d, h, 1, -d * g, -h * g]), l.push(g);
1087
+ }
1088
+ const c = cn(a, l);
1089
+ if (!c || c.some((m) => !Number.isFinite(m))) return null;
1090
+ const u = (m) => [m[0] / o + e, m[1] / o + n];
1077
1091
  return { matrix: [c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], 1], normalize: s, denormalize: u };
1078
1092
  }
1079
- function pe(r, [t, e]) {
1093
+ function ge(r, [t, e]) {
1080
1094
  const n = r[6] * t + r[7] * e + r[8];
1081
1095
  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];
1082
1096
  }
1083
- function an(r) {
1097
+ function hn(r) {
1084
1098
  const [t, e, n, i, o, s, a, l, c] = r, u = t * (o * c - s * l) - e * (i * c - s * a) + n * (i * l - o * a);
1085
1099
  return !Number.isFinite(u) || Math.abs(u) < 1e-15 ? null : [
1086
1100
  (o * c - s * l) / u,
@@ -1094,29 +1108,29 @@ function an(r) {
1094
1108
  (t * o - e * i) / u
1095
1109
  ];
1096
1110
  }
1097
- function ln(r, t) {
1111
+ function mn(r, t) {
1098
1112
  let e = r;
1099
1113
  for (; e - t > 180; ) e -= 360;
1100
1114
  for (; t - e > 180; ) e += 360;
1101
1115
  return e;
1102
1116
  }
1103
- const Xe = (r) => {
1117
+ const Ze = (r) => {
1104
1118
  let t = ((r + 180) % 360 + 360) % 360 - 180;
1105
1119
  return t === -180 && (t = 180), t;
1106
1120
  };
1107
- function Q({ corners: r, widthMm: t, heightMm: e, crsForward: n, continuous: i = !1 }) {
1108
- const o = n ?? (i ? nn : en), s = r[0][0], a = (b) => i ? b : ln(b, s), l = (b) => i ? b : Xe(b), c = r.map(([b, w]) => [a(b), w]), u = c.map((b) => o.forward(b)), h = [
1121
+ function tt({ corners: r, widthMm: t, heightMm: e, crsForward: n, continuous: i = !1 }) {
1122
+ const o = n ?? (i ? ln : on), s = r[0][0], a = (b) => i ? b : mn(b, s), l = (b) => i ? b : Ze(b), c = r.map(([b, w]) => [a(b), w]), u = c.map((b) => o.forward(b)), m = [
1109
1123
  [0, 0],
1110
1124
  [t, 0],
1111
1125
  [t, e],
1112
1126
  [0, e]
1113
- ], d = t > 0 && e > 0 ? on(u, h) : null, m = d ? an(d.matrix) : null, f = !d || !m, g = (b, w = i ? 16 : 1) => {
1114
- let y = 0, M = p.unproject(0, b);
1115
- if (!M) return null;
1127
+ ], d = t > 0 && e > 0 ? un(u, m) : null, h = d ? hn(d.matrix) : null, f = !d || !h, g = (b, w = i ? 16 : 1) => {
1128
+ let y = 0, A = p.unproject(0, b);
1129
+ if (!A) return null;
1116
1130
  for (let v = 1; v <= w; v++) {
1117
- const N = p.unproject(t * v / w, b);
1118
- if (!N) return null;
1119
- y += Hr(M, N), M = N;
1131
+ const $ = p.unproject(t * v / w, b);
1132
+ if (!$) return null;
1133
+ y += Zr(A, $), A = $;
1120
1134
  }
1121
1135
  return y;
1122
1136
  }, p = {
@@ -1128,15 +1142,15 @@ function Q({ corners: r, widthMm: t, heightMm: e, crsForward: n, continuous: i =
1128
1142
  continuous: i,
1129
1143
  project(b) {
1130
1144
  if (!d) return null;
1131
- const w = o.forward([a(b[0]), b[1]]), y = pe(d.matrix, d.normalize(w));
1145
+ const w = o.forward([a(b[0]), b[1]]), y = ge(d.matrix, d.normalize(w));
1132
1146
  return y && Number.isFinite(y[0]) && Number.isFinite(y[1]) ? { xMm: y[0], yMm: y[1] } : null;
1133
1147
  },
1134
1148
  unproject(b, w) {
1135
- if (!d || !m) return null;
1136
- const y = pe(m, [b, w]);
1149
+ if (!d || !h) return null;
1150
+ const y = ge(h, [b, w]);
1137
1151
  if (!y) return null;
1138
- const M = o.inverse(d.denormalize(y));
1139
- return Number.isFinite(M[0]) && Number.isFinite(M[1]) ? [l(M[0]), M[1]] : null;
1152
+ const A = o.inverse(d.denormalize(y));
1153
+ return Number.isFinite(A[0]) && Number.isFinite(A[1]) ? [l(A[0]), A[1]] : null;
1140
1154
  },
1141
1155
  groundMetersPerMm() {
1142
1156
  if (f || t <= 0) return 0;
@@ -1147,7 +1161,7 @@ function Q({ corners: r, widthMm: t, heightMm: e, crsForward: n, continuous: i =
1147
1161
  };
1148
1162
  return p;
1149
1163
  }
1150
- function H(r) {
1164
+ function X(r) {
1151
1165
  if (r == null || r.trim() === "") return null;
1152
1166
  let t;
1153
1167
  try {
@@ -1182,16 +1196,16 @@ function H(r) {
1182
1196
  }
1183
1197
  return e;
1184
1198
  }
1185
- function cn(r) {
1199
+ function dn(r) {
1186
1200
  if (r.degenerate) return null;
1187
1201
  const t = r.unproject(r.widthMm / 2, r.heightMm / 2);
1188
1202
  if (!t) return null;
1189
1203
  const n = [t[0], Math.min(89.9, Math.max(-89.9, t[1] + 0.01))], i = r.project(t), o = r.project(n);
1190
1204
  if (!i || !o) return null;
1191
1205
  const s = o.xMm - i.xMm, a = o.yMm - i.yMm;
1192
- return Math.abs(s) < 1e-12 && Math.abs(a) < 1e-12 ? null : (Math.atan2(s, -a) * tn % 360 + 360) % 360;
1206
+ return Math.abs(s) < 1e-12 && Math.abs(a) < 1e-12 ? null : (Math.atan2(s, -a) * sn % 360 + 360) % 360;
1193
1207
  }
1194
- function un(r) {
1208
+ function fn(r) {
1195
1209
  if (r.degenerate) return null;
1196
1210
  const { widthMm: t, heightMm: e } = r, n = [];
1197
1211
  for (const s of [0.02, 0.5, 0.98]) {
@@ -1202,7 +1216,7 @@ function un(r) {
1202
1216
  const i = Math.min(...n), o = Math.max(...n);
1203
1217
  return i > 0 ? (o - i) / i : null;
1204
1218
  }
1205
- function wi(r, t, e, n) {
1219
+ function xi(r, t, e, n) {
1206
1220
  return [
1207
1221
  [r, n],
1208
1222
  [e, n],
@@ -1210,8 +1224,8 @@ function wi(r, t, e, n) {
1210
1224
  [r, t]
1211
1225
  ];
1212
1226
  }
1213
- const hn = (r) => r.toLowerCase().startsWith("on");
1214
- function mn(r, t) {
1227
+ const pn = (r) => r.toLowerCase().startsWith("on");
1228
+ function gn(r, t) {
1215
1229
  const e = (n) => {
1216
1230
  const i = n.tagName.toLowerCase();
1217
1231
  if (i === "script") {
@@ -1222,7 +1236,7 @@ function mn(r, t) {
1222
1236
  if (i === "style" || i === "link" || i === "iframe" || i === "object" || i === "embed") return null;
1223
1237
  const o = t.createElement(i);
1224
1238
  for (const s of n.attributes)
1225
- hn(s.name) || /^\s*javascript:/i.test(s.value) || o.setAttribute(s.name, s.value);
1239
+ pn(s.name) || /^\s*javascript:/i.test(s.value) || o.setAttribute(s.name, s.value);
1226
1240
  for (const s of n.childNodes)
1227
1241
  if (s.nodeType === 3) o.appendChild(t.createTextNode(s.textContent ?? ""));
1228
1242
  else if (s.nodeType === 1) {
@@ -1233,12 +1247,12 @@ function mn(r, t) {
1233
1247
  };
1234
1248
  return e(r);
1235
1249
  }
1236
- async function dn(r, t = document) {
1250
+ async function bn(r, t = document) {
1237
1251
  const e = await fetch(r, { credentials: "same-origin", cache: "no-store" });
1238
1252
  if (!e.ok) throw new Error(`fetching ${r} failed with HTTP ${e.status}`);
1239
1253
  const n = await e.text(), o = new DOMParser().parseFromString(n, "text/html").querySelector("om-map");
1240
1254
  if (!o) throw new Error(`${r} contains no <om-map>`);
1241
- const s = mn(o, t);
1255
+ const s = gn(o, t);
1242
1256
  if (!s) throw new Error(`${r} could not be adopted`);
1243
1257
  return s;
1244
1258
  }
@@ -1263,7 +1277,7 @@ function ut(r) {
1263
1277
  pitch: Number(r.getAttribute("pitch")) || 0
1264
1278
  };
1265
1279
  }
1266
- function vi(r, t, e, n, i = 60) {
1280
+ function $i(r, t, e, n, i = 60) {
1267
1281
  const o = (l) => Ft(r, { ...t, pitch: l }, e, n) !== null;
1268
1282
  if (o(i)) return i;
1269
1283
  if (!o(0)) return 0;
@@ -1297,26 +1311,26 @@ function Ft(r, t, e, n) {
1297
1311
  }
1298
1312
  return s;
1299
1313
  }
1300
- async function fn(r, t) {
1301
- const e = await Pe();
1314
+ async function yn(r, t) {
1315
+ const e = await Te();
1302
1316
  if (t && typeof t != "string") return { core: e, map: t };
1303
1317
  if (!t) throw new Error("a live frame needs src= or an inline <om-map> child");
1304
- const n = await dn(t, r.ownerDocument);
1318
+ const n = await bn(t, r.ownerDocument);
1305
1319
  return { core: e, map: n };
1306
1320
  }
1307
- function Mt(r, t) {
1308
- 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)), gn(r, t);
1321
+ function At(r, t) {
1322
+ 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)), wn(r, t);
1309
1323
  }
1310
- function gn(r, t) {
1324
+ function wn(r, t) {
1311
1325
  const e = r;
1312
1326
  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 });
1313
1327
  }
1314
- const pn = [".png", ".jpg", ".jpeg", ".webp", ".avif", ".gif", ".svg"], bn = [".html", ".htm"];
1328
+ const vn = [".png", ".jpg", ".jpeg", ".webp", ".avif", ".gif", ".svg"], An = [".html", ".htm"];
1315
1329
  function It(r) {
1316
1330
  const t = r.trim().split(/[?#]/, 1)[0]?.toLowerCase() ?? "";
1317
- return bn.some((e) => t.endsWith(e)) ? "map" : pn.some((e) => t.endsWith(e)) ? "raster" : null;
1331
+ return An.some((e) => t.endsWith(e)) ? "map" : vn.some((e) => t.endsWith(e)) ? "raster" : null;
1318
1332
  }
1319
- function yn(r, t) {
1333
+ function Mn(r, t) {
1320
1334
  const e = [], n = [...r.children].find(
1321
1335
  (s) => s.tagName.toLowerCase() === "om-map" && s !== t
1322
1336
  );
@@ -1331,10 +1345,10 @@ function yn(r, t) {
1331
1345
  }
1332
1346
  return e;
1333
1347
  }
1334
- function wn(r) {
1348
+ function Sn(r) {
1335
1349
  return r.map((t) => t.key).join("|");
1336
1350
  }
1337
- async function vn(r, t, e) {
1351
+ async function Cn(r, t, e) {
1338
1352
  const n = Math.max(1, Math.round(t.w * e)), i = Math.max(1, Math.round(t.h * e)), o = r.cloneNode(!0);
1339
1353
  o.removeAttribute("style"), o.setAttribute("width", String(n)), o.setAttribute("height", String(i)), o.setAttribute("preserveAspectRatio", "none");
1340
1354
  const s = new XMLSerializer().serializeToString(o), a = new Image();
@@ -1346,8 +1360,8 @@ async function vn(r, t, e) {
1346
1360
  }
1347
1361
  return a;
1348
1362
  }
1349
- const At = "data-om-carto-placeholder", be = "data-om-carto-source", St = "data-om-carto-capture", Ct = "data-om-carto-overview", ye = "http://www.w3.org/2000/svg", we = 24, ve = 0.25;
1350
- class Je extends I {
1363
+ const Mt = "data-om-carto-placeholder", be = "data-om-carto-source", St = "data-om-carto-capture", Ct = "data-om-carto-overview", ye = "http://www.w3.org/2000/svg", we = 24, ve = 0.25;
1364
+ class Qe extends O {
1351
1365
  static observedAttributes = [...T["om-frame"]];
1352
1366
  /** Resolved non-builtin CRS planes, so a re-render does not re-await proj4. */
1353
1367
  resolvedForward = null;
@@ -1424,22 +1438,22 @@ class Je extends I {
1424
1438
  * than caching it correctly.
1425
1439
  */
1426
1440
  get georef() {
1427
- const { w: t, h: e } = C(this);
1441
+ const { w: t, h: e } = S(this);
1428
1442
  if (t <= 0 || e <= 0) return null;
1429
1443
  if (this.mode === "live" && !this.showingRaster) {
1430
1444
  if (!this.liveCorners) return null;
1431
1445
  const l = this.liveMap?.projectedCrs?.() ?? null;
1432
1446
  if (l) {
1433
- const c = this.resolvedForwardKey === `${l}|` ? this.resolvedForward : K(l);
1434
- return c ? Q({ corners: this.liveCorners, widthMm: t, heightMm: e, crsForward: c }) : (this.ensureLiveCrsForward(l), null);
1447
+ const c = this.resolvedForwardKey === `${l}|` ? this.resolvedForward : Y(l);
1448
+ return c ? tt({ corners: this.liveCorners, widthMm: t, heightMm: e, crsForward: c }) : (this.ensureLiveCrsForward(l), null);
1435
1449
  }
1436
- return Q({ corners: this.liveCorners, widthMm: t, heightMm: e, continuous: !0 });
1450
+ return tt({ corners: this.liveCorners, widthMm: t, heightMm: e, continuous: !0 });
1437
1451
  }
1438
- const n = this.georefHost, i = H(n.getAttribute("corners"));
1452
+ const n = this.georefHost, i = X(n.getAttribute("corners"));
1439
1453
  if (!i) return null;
1440
1454
  const o = Lt(n.getAttribute("crs")) ?? "EPSG:3857", s = n.getAttribute("crs-def");
1441
- let a = s ? null : K(o);
1442
- return !a && this.resolvedForwardKey === `${o}|${s ?? ""}` && (a = this.resolvedForward), a ? Q({ corners: i, widthMm: t, heightMm: e, crsForward: a }) : null;
1455
+ let a = s ? null : Y(o);
1456
+ return !a && this.resolvedForwardKey === `${o}|${s ?? ""}` && (a = this.resolvedForward), a ? tt({ corners: i, widthMm: t, heightMm: e, crsForward: a }) : null;
1443
1457
  }
1444
1458
  /**
1445
1459
  * Resolve a live map's CRS through the core's lazy proj4, into the same
@@ -1515,7 +1529,7 @@ class Je extends I {
1515
1529
  const e = t.style;
1516
1530
  e.position = "absolute", e.inset = "0", e.width = "100%", e.height = "100%", e.display = "block", t instanceof SVGSVGElement ? t.setAttribute("preserveAspectRatio", "none") : e.objectFit = "fill";
1517
1531
  const n = Lt(this.getAttribute("crs")) ?? "EPSG:3857", i = this.getAttribute("crs-def"), o = `${n}|${i ?? ""}`;
1518
- if ((i != null || K(n) == null) && this.resolvedForwardKey !== o) {
1532
+ if ((i != null || Y(n) == null) && this.resolvedForwardKey !== o) {
1519
1533
  const a = ++this.resolveToken;
1520
1534
  this.resolvedForward = null, this.resolvedForwardKey = null, Rt(n, i).then((l) => {
1521
1535
  if (a === this.resolveToken) {
@@ -1530,7 +1544,7 @@ class Je extends I {
1530
1544
  });
1531
1545
  return;
1532
1546
  }
1533
- if (!H(this.getAttribute("corners"))) {
1547
+ if (!X(this.getAttribute("corners"))) {
1534
1548
  this.showPlaceholder("bad-corners", 'Static frame needs corners="[[lng,lat] × 4]" (tl, tr, br, bl).');
1535
1549
  return;
1536
1550
  }
@@ -1556,7 +1570,7 @@ class Je extends I {
1556
1570
  this.showPlaceholder("no-source", "Live frame needs src=, an <om-source> child, or an inline <om-map>.");
1557
1571
  return;
1558
1572
  }
1559
- const s = wn(o);
1573
+ const s = Sn(o);
1560
1574
  s !== this.knownSourceList && (this.knownSourceList = s, this.sourceCursor = 0, this.settledSource = null, this.removeAttribute(be));
1561
1575
  const a = Math.min(this.sourceCursor, o.length - 1), l = o[a];
1562
1576
  if (l.kind === "raster") {
@@ -1567,7 +1581,7 @@ class Je extends I {
1567
1581
  if (this.mountedSource !== l.key)
1568
1582
  this.releaseLiveMap();
1569
1583
  else {
1570
- Mt(this.liveMap, e), this.sizeLiveMap();
1584
+ At(this.liveMap, e), this.sizeLiveMap();
1571
1585
  return;
1572
1586
  }
1573
1587
  if (this.mounting) {
@@ -1585,7 +1599,7 @@ class Je extends I {
1585
1599
  renderCaptureSource(t, e) {
1586
1600
  const n = t.src ?? "";
1587
1601
  let i = this.querySelector(`:scope > img[${St}]`);
1588
- if (i || (i = document.createElement("img"), i.setAttribute(St, ""), i.alt = "", this.appendChild(i)), i.getAttribute("src") !== n && i.setAttribute("src", n), i.style.cssText = "position:absolute;inset:0;width:100%;height:100%;display:block;object-fit:fill;", this.captureImage = i, !H(this.georefHostFor(t).getAttribute("corners"))) {
1602
+ if (i || (i = document.createElement("img"), i.setAttribute(St, ""), i.alt = "", this.appendChild(i)), i.getAttribute("src") !== n && i.setAttribute("src", n), i.style.cssText = "position:absolute;inset:0;width:100%;height:100%;display:block;object-fit:fill;", this.captureImage = i, !X(this.georefHostFor(t).getAttribute("corners"))) {
1589
1603
  this.showPlaceholder("bad-corners", 'A capture <om-source> needs corners="[[lng,lat] × 4]" (tl, tr, br, bl).');
1590
1604
  return;
1591
1605
  }
@@ -1606,7 +1620,7 @@ class Je extends I {
1606
1620
  * inline source on the next render.
1607
1621
  */
1608
1622
  sources() {
1609
- return yn(this, this.liveMapOwned ? this.liveMap : null);
1623
+ return Mn(this, this.liveMapOwned ? this.liveMap : null);
1610
1624
  }
1611
1625
  /**
1612
1626
  * Move to the next source, or report that there is none.
@@ -1675,9 +1689,9 @@ class Je extends I {
1675
1689
  }
1676
1690
  updateLiveCorners(t = ut(this)) {
1677
1691
  if (!t) return;
1678
- const e = Y();
1692
+ const e = J();
1679
1693
  if (!e) return;
1680
- const { w: n, h: i } = C(this), s = this.liveMap?.groundCorners?.(n * D, i * D) ?? Ft(e, t, n * D, i * D), a = JSON.stringify(s) !== JSON.stringify(this.liveCorners);
1694
+ const { w: n, h: i } = S(this), s = this.liveMap?.groundCorners?.(n * D, i * D) ?? Ft(e, t, n * D, i * D), a = JSON.stringify(s) !== JSON.stringify(this.liveCorners);
1681
1695
  this.liveCorners = s, a && this.liveMap && this.dispatchEvent(new CustomEvent("om-frame-view", { bubbles: !0, detail: { id: this.id } })), this.applyReferenceScale(), s ? this.lastError === "degenerate-view" && this.clearPlaceholder() : this.showPlaceholder("degenerate-view", "This frame's box cannot be georeferenced — give it a positive width and height.");
1682
1696
  }
1683
1697
  async mountLive(t, e, n) {
@@ -1685,15 +1699,15 @@ class Je extends I {
1685
1699
  this.mounting = !0, this.mountingSource = t.key;
1686
1700
  let o = !1;
1687
1701
  try {
1688
- const { core: s, map: a } = await fn(this, t.map ?? t.src);
1702
+ const { core: s, map: a } = await yn(this, t.map ?? t.src);
1689
1703
  if (i !== this.mountToken || !this.isConnected || this.mode !== "live") return;
1690
1704
  const l = ut(this);
1691
1705
  if (!l) return;
1692
- this.appliedCameraKey = JSON.stringify(l), Mt(a, l);
1706
+ this.appliedCameraKey = JSON.stringify(l), At(a, l);
1693
1707
  const c = a;
1694
1708
  c.style.position = "absolute", c.style.inset = "0", c.style.display = "block", a.setAttribute("data-om-carto-frame", ""), this.liveMapOwned = a.parentElement !== this, this.liveMapOwned && this.appendChild(a), this.liveMap = c, c.addEventListener("om-view-changed", this.onLiveViewSettled), this.mountedSource = t.key, this.sizeLiveMap(), this.clearPlaceholder();
1695
- const { w: u, h } = C(this);
1696
- if (this.liveCorners = Ft(s, l, u * D, h * D), this.applyReferenceScale(), await c.ready, i !== this.mountToken || (Mt(a, l), await c.whenSettled?.({ timeout: 2e4 }), i !== this.mountToken)) return;
1709
+ const { w: u, h: m } = S(this);
1710
+ if (this.liveCorners = Ft(s, l, u * D, m * D), this.applyReferenceScale(), await c.ready, i !== this.mountToken || (At(a, l), await c.whenSettled?.({ timeout: 2e4 }), i !== this.mountToken)) return;
1697
1711
  if (c.hasDrawableContent?.() === !1) {
1698
1712
  if (this.advanceSource(n)) return;
1699
1713
  console.warn(
@@ -1741,21 +1755,21 @@ class Je extends I {
1741
1755
  e?.remove();
1742
1756
  return;
1743
1757
  }
1744
- const n = qe(this, t), i = this.georef, o = n?.georef;
1758
+ const n = Be(this, t), i = this.georef, o = n?.georef;
1745
1759
  if (!n || !i || !o) {
1746
1760
  e?.remove();
1747
1761
  return;
1748
1762
  }
1749
- const { w: s, h: a } = C(this), l = [], [c, u, h, d] = o.corners, m = [
1763
+ const { w: s, h: a } = S(this), l = [], [c, u, m, d] = o.corners, h = [
1750
1764
  [c, u],
1751
- [u, h],
1752
- [h, d],
1765
+ [u, m],
1766
+ [m, d],
1753
1767
  [d, c]
1754
1768
  ];
1755
- for (const [b, w] of m)
1769
+ for (const [b, w] of h)
1756
1770
  for (let y = 0; y < we; y++) {
1757
- const M = y / we, v = [b[0] + (w[0] - b[0]) * M, b[1] + (w[1] - b[1]) * M], N = i.project(v);
1758
- N && l.push(`${N.xMm.toFixed(3)},${N.yMm.toFixed(3)}`);
1771
+ const A = y / we, v = [b[0] + (w[0] - b[0]) * A, b[1] + (w[1] - b[1]) * A], $ = i.project(v);
1772
+ $ && l.push(`${$.xMm.toFixed(3)},${$.yMm.toFixed(3)}`);
1759
1773
  }
1760
1774
  if (l.length < 3) {
1761
1775
  e?.remove();
@@ -1787,11 +1801,11 @@ class Je extends I {
1787
1801
  * the worst outcome — it looks like a design choice.
1788
1802
  */
1789
1803
  showPlaceholder(t, e) {
1790
- let n = this.querySelector(`:scope > [${At}]`);
1791
- n || (n = document.createElement("div"), n.setAttribute(At, ""), n.style.cssText = "position:absolute;inset:0;display:grid;place-content:center;padding:4mm;text-align:center;font:italic 3mm/1.4 system-ui,sans-serif;color:var(--om-carto-ink);opacity:.75;", this.appendChild(n)), n.textContent !== e && (n.textContent = e), this.lastError !== t && (this.lastError = t, this.settleReady(), this.dispatchEvent(new CustomEvent("om-frame-error", { bubbles: !0, detail: { id: this.id, reason: t, message: e } })));
1804
+ let n = this.querySelector(`:scope > [${Mt}]`);
1805
+ n || (n = document.createElement("div"), n.setAttribute(Mt, ""), n.style.cssText = "position:absolute;inset:0;display:grid;place-content:center;padding:4mm;text-align:center;font:italic 3mm/1.4 system-ui,sans-serif;color:var(--om-carto-ink);opacity:.75;", this.appendChild(n)), n.textContent !== e && (n.textContent = e), this.lastError !== t && (this.lastError = t, this.settleReady(), this.dispatchEvent(new CustomEvent("om-frame-error", { bubbles: !0, detail: { id: this.id, reason: t, message: e } })));
1792
1806
  }
1793
1807
  clearPlaceholder() {
1794
- this.querySelector(`:scope > [${At}]`)?.remove(), this.lastError = null;
1808
+ this.querySelector(`:scope > [${Mt}]`)?.remove(), this.lastError = null;
1795
1809
  }
1796
1810
  // -------------------------------------------------------------------------
1797
1811
  // Capture, export and print
@@ -1853,9 +1867,9 @@ class Je extends I {
1853
1867
  * follows from the same source as any authored camera.
1854
1868
  */
1855
1869
  fitBounds(t) {
1856
- const [e, n, i, o] = t, { w: s, h: a } = C(this);
1870
+ const [e, n, i, o] = t, { w: s, h: a } = S(this);
1857
1871
  if (s <= 0 || a <= 0) return;
1858
- const l = Y();
1872
+ const l = J();
1859
1873
  if (!l) return;
1860
1874
  const c = new l.WebMercatorViewport({ width: s * D, height: a * D, longitude: 0, latitude: 0, zoom: 0 }).fitBounds([
1861
1875
  [e, n],
@@ -1880,7 +1894,7 @@ class Je extends I {
1880
1894
  return;
1881
1895
  }
1882
1896
  const e = this.vector;
1883
- e && (this.captureImage = await vn(e, C(this), t.pxPerMm));
1897
+ e && (this.captureImage = await Cn(e, S(this), t.pxPerMm));
1884
1898
  }
1885
1899
  /** Export hook: forget the capture, so a failed pre-pass never reuses it. */
1886
1900
  discardCartograph() {
@@ -1901,14 +1915,14 @@ class Je extends I {
1901
1915
  this.printing = !1, this.querySelector(":scope > img[data-om-carto-print]")?.remove(), this.liveMap && (this.liveMap.hidden = !1);
1902
1916
  }
1903
1917
  paintCartograph(t, e) {
1904
- const { w: n, h: i } = C(this), o = n * e.pxPerMm, s = i * e.pxPerMm;
1918
+ const { w: n, h: i } = S(this), o = n * e.pxPerMm, s = i * e.pxPerMm;
1905
1919
  if (o <= 0 || s <= 0) return;
1906
- const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = R(a?.backgroundColor);
1920
+ const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = F(a?.backgroundColor);
1907
1921
  l && (t.fillStyle = l, t.fillRect(0, 0, o, s));
1908
1922
  const c = this.mode === "static" ? this.vector ? this.captureImage : this.raster : this.captureImage;
1909
1923
  c && c.complete && c.naturalWidth > 0 && t.drawImage(c, 0, 0, o, s), this.paintOverview(t, e);
1910
- const u = this.getAttribute("frame-stroke") || R(a?.getPropertyValue("--om-carto-frame-stroke")?.trim()) || "#333333", h = ve * e.pxPerMm;
1911
- h > 0 && (t.strokeStyle = u, t.lineWidth = h, t.strokeRect(h / 2, h / 2, o - h, s - h));
1924
+ const u = this.getAttribute("frame-stroke") || F(a?.getPropertyValue("--om-carto-frame-stroke")?.trim()) || "#333333", m = ve * e.pxPerMm;
1925
+ m > 0 && (t.strokeStyle = u, t.lineWidth = m, t.strokeRect(m / 2, m / 2, o - m, s - m));
1912
1926
  }
1913
1927
  paintOverview(t, e) {
1914
1928
  const n = this.querySelector(`:scope > [${Ct}] polygon`), i = n?.getAttribute("points");
@@ -1918,45 +1932,45 @@ class Je extends I {
1918
1932
  }), t.closePath(), t.stroke(), t.restore());
1919
1933
  }
1920
1934
  }
1921
- k("om-frame", Je);
1922
- const st = "http://www.w3.org/2000/svg", Mn = ["single", "double", "line", "ticks"];
1923
- class Ze extends I {
1935
+ k("om-frame", Qe);
1936
+ const st = "http://www.w3.org/2000/svg", kn = ["single", "double", "line", "ticks"];
1937
+ class tr extends O {
1924
1938
  static observedAttributes = [...T["om-scalebar"]];
1925
1939
  /** The geometry currently drawn — reused by the canvas exporter. */
1926
1940
  get drawing() {
1927
- const e = O(this)?.georef;
1941
+ const e = U(this)?.georef;
1928
1942
  if (!e) return null;
1929
- const { w: n, h: i } = C(this), o = De({
1943
+ const { w: n, h: i } = S(this), o = je({
1930
1944
  groundMetersPerMm: e.groundMetersPerMm(),
1931
1945
  maxWidthMm: n,
1932
1946
  segments: Number(this.getAttribute("segments")) || void 0,
1933
1947
  units: this.unitSystem,
1934
1948
  segmentLengthMeters: this.getAttribute("segment-length") ? Number(this.getAttribute("segment-length")) : null
1935
1949
  });
1936
- return o ? Rr(o, this.barStyle, i) : null;
1950
+ return o ? _r(o, this.barStyle, i) : null;
1937
1951
  }
1938
1952
  get barStyle() {
1939
1953
  const t = this.getAttribute("kind");
1940
- return Mn.includes(t) ? t : "single";
1954
+ return kn.includes(t) ? t : "single";
1941
1955
  }
1942
1956
  get unitSystem() {
1943
- return Lr(this.getAttribute("units")) ?? "metric";
1957
+ return Or(this.getAttribute("units")) ?? "metric";
1944
1958
  }
1945
1959
  renderNow() {
1946
- if (this.applyPlacement(), this.style.display = "block", !O(this)) {
1960
+ if (this.applyPlacement(), this.applyThemeOverride("color", "--om-carto-scalebar-ink", !0), this.style.display = "block", !U(this)) {
1947
1961
  const n = this.getAttribute("for");
1948
- q(this, n ? `Scale bar references no frame with id "${n}".` : "Scale bar has no frame to measure (set for=).");
1962
+ W(this, n ? `Scale bar references no frame with id "${n}".` : "Scale bar has no frame to measure (set for=).");
1949
1963
  return;
1950
1964
  }
1951
1965
  const e = this.drawing;
1952
1966
  if (!e) {
1953
- q(this, "Scale bar cannot derive a scale from this frame yet.");
1967
+ W(this, "Scale bar cannot derive a scale from this frame yet.");
1954
1968
  return;
1955
1969
  }
1956
1970
  this.renderSvg(e);
1957
1971
  }
1958
1972
  renderSvg(t) {
1959
- const { w: e, h: n } = C(this), i = this.ownerDocument, o = i.createElementNS(st, "svg");
1973
+ const { w: e, h: n } = S(this), i = this.ownerDocument, o = i.createElementNS(st, "svg");
1960
1974
  o.setAttribute("width", `${e}mm`), o.setAttribute("height", `${n}mm`), o.setAttribute("viewBox", `0 0 ${e} ${n}`), o.setAttribute("part", "scalebar"), o.style.display = "block", o.style.overflow = "visible";
1961
1975
  const s = "var(--om-carto-scalebar-ink)";
1962
1976
  for (const a of t.bars) {
@@ -1976,7 +1990,7 @@ class Ze extends I {
1976
1990
  paintCartograph(t, e) {
1977
1991
  const n = this.drawing;
1978
1992
  if (!n) return;
1979
- const i = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, o = R(i?.color) ?? "#000", s = (l) => l * e.pxPerMm;
1993
+ const i = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, o = F(i?.color) ?? "#000", s = (l) => l * e.pxPerMm;
1980
1994
  t.strokeStyle = o, t.fillStyle = o, t.lineWidth = s(n.strokeMm);
1981
1995
  for (const l of n.bars)
1982
1996
  l.filled && t.fillRect(s(l.x), s(l.y), s(l.w), s(l.h)), t.strokeRect(s(l.x), s(l.y), s(l.w), s(l.h));
@@ -1990,32 +2004,32 @@ class Ze extends I {
1990
2004
  t.textAlign = l.anchor === "middle" ? "center" : l.anchor === "end" ? "right" : "left", t.fillText(l.text, s(l.x), s(l.y));
1991
2005
  }
1992
2006
  }
1993
- k("om-scalebar", Ze);
1994
- const Z = "http://www.w3.org/2000/svg";
1995
- class Qe extends I {
2007
+ k("om-scalebar", tr);
2008
+ const Q = "http://www.w3.org/2000/svg";
2009
+ class er extends O {
1996
2010
  static observedAttributes = [...T["om-north"]];
1997
2011
  /** Degrees clockwise from the page's "up", or null when unknowable. */
1998
2012
  get bearing() {
1999
- const t = O(this)?.georef;
2000
- return t ? cn(t) : null;
2013
+ const t = U(this)?.georef;
2014
+ return t ? dn(t) : null;
2001
2015
  }
2002
2016
  get indicatorKind() {
2003
2017
  return this.getAttribute("kind") === "rose" ? "rose" : "arrow";
2004
2018
  }
2005
2019
  renderNow() {
2006
- if (this.applyPlacement(), this.style.display = "block", !O(this)) {
2020
+ if (this.applyPlacement(), this.applyThemeOverride("color", "--om-carto-compass-ink", !0), this.style.display = "block", !U(this)) {
2007
2021
  const l = this.getAttribute("for");
2008
- q(this, l ? `North indicator references no frame with id "${l}".` : "North indicator has no frame (set for=).");
2022
+ W(this, l ? `North indicator references no frame with id "${l}".` : "North indicator has no frame (set for=).");
2009
2023
  return;
2010
2024
  }
2011
2025
  const e = this.bearing;
2012
2026
  if (e == null) {
2013
- q(this, "North indicator cannot derive a direction from this frame yet.");
2027
+ W(this, "North indicator cannot derive a direction from this frame yet.");
2014
2028
  return;
2015
2029
  }
2016
- const { w: n, h: i } = C(this), o = this.ownerDocument, s = o.createElementNS(Z, "svg");
2030
+ const { w: n, h: i } = S(this), o = this.ownerDocument, s = o.createElementNS(Q, "svg");
2017
2031
  s.setAttribute("width", `${n}mm`), s.setAttribute("height", `${i}mm`), s.setAttribute("viewBox", `0 0 ${n} ${i}`), s.style.display = "block";
2018
- const a = o.createElementNS(Z, "g");
2032
+ const a = o.createElementNS(Q, "g");
2019
2033
  a.setAttribute("transform", `rotate(${e.toFixed(3)} ${n / 2} ${i / 2})`);
2020
2034
  for (const l of this.buildGeometry(o, n, i)) a.appendChild(l);
2021
2035
  s.appendChild(a), this.replaceChildren(s);
@@ -2023,28 +2037,28 @@ class Qe extends I {
2023
2037
  buildGeometry(t, e, n) {
2024
2038
  const i = "var(--om-carto-compass-ink)", o = [], s = e / 2, a = Math.min(3, n * 0.24), l = n - a * 1.2;
2025
2039
  if (this.indicatorKind === "rose") {
2026
- const f = Math.min(e, l) / 2, g = t.createElementNS(Z, "circle");
2040
+ const f = Math.min(e, l) / 2, g = t.createElementNS(Q, "circle");
2027
2041
  g.setAttribute("cx", String(s)), g.setAttribute("cy", String(l / 2)), g.setAttribute("r", String(f)), g.setAttribute("fill", "none"), g.setAttribute("stroke", i), g.setAttribute("stroke-width", "0.2"), o.push(g);
2028
2042
  }
2029
- const c = 0, u = l, h = Math.min(e * 0.3, 4), d = t.createElementNS(Z, "path");
2030
- d.setAttribute("d", `M ${s} ${c} L ${s + h} ${u} L ${s} ${u - h * 0.55} L ${s - h} ${u} Z`), d.setAttribute("fill", i), o.push(d);
2031
- const m = t.createElementNS(Z, "text");
2032
- return m.setAttribute("x", String(s)), m.setAttribute("y", String(n)), m.setAttribute("font-size", String(a)), m.setAttribute("text-anchor", "middle"), m.setAttribute("fill", i), m.setAttribute("font-family", "var(--om-carto-font)"), m.textContent = "N", o.push(m), o;
2043
+ const c = 0, u = l, m = Math.min(e * 0.3, 4), d = t.createElementNS(Q, "path");
2044
+ d.setAttribute("d", `M ${s} ${c} L ${s + m} ${u} L ${s} ${u - m * 0.55} L ${s - m} ${u} Z`), d.setAttribute("fill", i), o.push(d);
2045
+ const h = t.createElementNS(Q, "text");
2046
+ return h.setAttribute("x", String(s)), h.setAttribute("y", String(n)), h.setAttribute("font-size", String(a)), h.setAttribute("text-anchor", "middle"), h.setAttribute("fill", i), h.setAttribute("font-family", "var(--om-carto-font)"), h.textContent = "N", o.push(h), o;
2033
2047
  }
2034
2048
  paintCartograph(t, e) {
2035
2049
  const n = this.bearing;
2036
2050
  if (n == null) return;
2037
- const { w: i, h: o } = C(this), s = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, a = R(s?.color) ?? "#000", l = (m) => m * e.pxPerMm, c = Math.min(3, o * 0.24), u = o - c * 1.2, h = i / 2, d = Math.min(i * 0.3, 4);
2038
- t.save(), t.translate(l(h), l(o / 2)), t.rotate(n * Math.PI / 180), t.translate(-l(h), -l(o / 2)), t.fillStyle = a, t.strokeStyle = a, this.indicatorKind === "rose" && (t.lineWidth = l(0.2), t.beginPath(), t.arc(l(h), l(u / 2), l(Math.min(i, u) / 2), 0, Math.PI * 2), t.stroke()), t.beginPath(), t.moveTo(l(h), 0), t.lineTo(l(h + d), l(u)), t.lineTo(l(h), l(u - d * 0.55)), t.lineTo(l(h - d), l(u)), t.closePath(), t.fill(), t.font = `${l(c)}px ${s?.fontFamily || "system-ui, sans-serif"}`, t.textAlign = "center", t.textBaseline = "alphabetic", t.fillText("N", l(h), l(o)), t.restore();
2051
+ const { w: i, h: o } = S(this), s = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, a = F(s?.color) ?? "#000", l = (h) => h * e.pxPerMm, c = Math.min(3, o * 0.24), u = o - c * 1.2, m = i / 2, d = Math.min(i * 0.3, 4);
2052
+ t.save(), t.translate(l(m), l(o / 2)), t.rotate(n * Math.PI / 180), t.translate(-l(m), -l(o / 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 ${s?.fontFamily || "system-ui, sans-serif"}`, t.textAlign = "center", t.textBaseline = "alphabetic", t.fillText("N", l(m), l(o)), t.restore();
2039
2053
  }
2040
2054
  }
2041
- k("om-north", Qe);
2042
- const ot = "http://www.w3.org/2000/svg", An = ["rect", "ellipse", "line", "arrow"];
2043
- class tr extends I {
2055
+ k("om-north", er);
2056
+ const ot = "http://www.w3.org/2000/svg", xn = ["rect", "ellipse", "line", "arrow"];
2057
+ class rr extends O {
2044
2058
  static observedAttributes = [...T["om-shape"]];
2045
2059
  get kind() {
2046
2060
  const t = this.getAttribute("kind");
2047
- return An.includes(t) ? t : "rect";
2061
+ return xn.includes(t) ? t : "rect";
2048
2062
  }
2049
2063
  get fill() {
2050
2064
  return this.getAttribute("fill") || "var(--om-carto-shape-fill)";
@@ -2070,7 +2084,7 @@ class tr extends I {
2070
2084
  }
2071
2085
  renderNow() {
2072
2086
  this.applyPlacement(), this.style.display = "block";
2073
- const { w: t, h: e } = C(this), n = this.ownerDocument, i = n.createElementNS(ot, "svg");
2087
+ const { w: t, h: e } = S(this), n = this.ownerDocument, i = n.createElementNS(ot, "svg");
2074
2088
  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";
2075
2089
  const o = this.strokeWidthMm / 2, s = this.kind;
2076
2090
  let a;
@@ -2084,15 +2098,15 @@ class tr extends I {
2084
2098
  return `M 0 0 L ${o} ${s} M ${o} ${s} L ${a.x} ${a.y} L ${l.x} ${l.y} Z`;
2085
2099
  }
2086
2100
  paintCartograph(t, e) {
2087
- const { w: n, h: i } = C(this);
2101
+ const { w: n, h: i } = S(this);
2088
2102
  if (n <= 0 || i <= 0) return;
2089
- const o = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, s = (d) => d * e.pxPerMm, a = this.getAttribute("fill") || o?.getPropertyValue("--om-carto-shape-fill")?.trim() || "#cccccc", l = this.getAttribute("stroke") || o?.getPropertyValue("--om-carto-shape-stroke")?.trim() || "#333333", c = s(this.strokeWidthMm), u = c / 2, h = this.kind;
2090
- if (t.save(), t.globalAlpha = this.fillOpacity, t.fillStyle = a, t.strokeStyle = l, t.lineWidth = c, h === "ellipse")
2103
+ const o = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, s = (d) => d * e.pxPerMm, a = this.getAttribute("fill") || o?.getPropertyValue("--om-carto-shape-fill")?.trim() || "#cccccc", l = this.getAttribute("stroke") || o?.getPropertyValue("--om-carto-shape-stroke")?.trim() || "#333333", c = s(this.strokeWidthMm), u = c / 2, m = this.kind;
2104
+ if (t.save(), t.globalAlpha = this.fillOpacity, t.fillStyle = a, t.strokeStyle = l, t.lineWidth = c, m === "ellipse")
2091
2105
  t.beginPath(), t.ellipse(s(n / 2), s(i / 2), Math.max(0, s(n / 2) - u), Math.max(0, s(i / 2) - u), 0, 0, Math.PI * 2), t.fill(), t.globalAlpha = 1, c > 0 && t.stroke();
2092
- else if (h === "line" || h === "arrow") {
2093
- if (t.globalAlpha = 1, t.beginPath(), t.moveTo(0, 0), t.lineTo(s(n), s(i)), c > 0 && t.stroke(), h === "arrow") {
2094
- const d = Math.min(s(n), s(i)) * 0.28, m = Math.atan2(s(i), s(n));
2095
- t.beginPath(), t.moveTo(s(n), s(i)), t.lineTo(s(n) - d * Math.cos(m - 0.4), s(i) - d * Math.sin(m - 0.4)), t.lineTo(s(n) - d * Math.cos(m + 0.4), s(i) - d * Math.sin(m + 0.4)), t.closePath(), t.fillStyle = l, t.fill();
2106
+ else if (m === "line" || m === "arrow") {
2107
+ if (t.globalAlpha = 1, t.beginPath(), t.moveTo(0, 0), t.lineTo(s(n), s(i)), c > 0 && t.stroke(), m === "arrow") {
2108
+ const d = Math.min(s(n), s(i)) * 0.28, h = Math.atan2(s(i), s(n));
2109
+ t.beginPath(), t.moveTo(s(n), s(i)), t.lineTo(s(n) - d * Math.cos(h - 0.4), s(i) - d * Math.sin(h - 0.4)), t.lineTo(s(n) - d * Math.cos(h + 0.4), s(i) - d * Math.sin(h + 0.4)), t.closePath(), t.fillStyle = l, t.fill();
2096
2110
  }
2097
2111
  } else {
2098
2112
  const d = s(this.radiusMm);
@@ -2101,13 +2115,13 @@ class tr extends I {
2101
2115
  t.restore();
2102
2116
  }
2103
2117
  }
2104
- k("om-shape", tr);
2105
- const Me = "data-om-carto-owned", Sn = ["contain", "cover", "fill"];
2106
- class er extends I {
2118
+ k("om-shape", rr);
2119
+ const Ae = "data-om-carto-owned", $n = ["contain", "cover", "fill"];
2120
+ class nr extends O {
2107
2121
  static observedAttributes = [...T["om-image"]];
2108
2122
  get fit() {
2109
2123
  const t = this.getAttribute("fit");
2110
- return Sn.includes(t ?? "") ? t : "contain";
2124
+ return $n.includes(t ?? "") ? t : "contain";
2111
2125
  }
2112
2126
  get image() {
2113
2127
  return this.querySelector(":scope > img");
@@ -2116,29 +2130,29 @@ class er extends I {
2116
2130
  this.applyPlacement(), this.style.display = "block", this.style.overflow = "hidden";
2117
2131
  const t = this.getAttribute("src");
2118
2132
  let e = this.image;
2119
- !e && t && (e = this.ownerDocument.createElement("img"), e.setAttribute(Me, ""), e.alt = "", e.crossOrigin = "anonymous", this.appendChild(e)), e && (t && e.hasAttribute(Me) && e.getAttribute("src") !== t && e.setAttribute("src", t), e.style.width = "100%", e.style.height = "100%", e.style.objectFit = this.fit, e.style.display = "block");
2133
+ !e && t && (e = this.ownerDocument.createElement("img"), e.setAttribute(Ae, ""), e.alt = "", e.crossOrigin = "anonymous", this.appendChild(e)), e && (t && e.hasAttribute(Ae) && e.getAttribute("src") !== t && e.setAttribute("src", t), e.style.width = "100%", e.style.height = "100%", e.style.objectFit = this.fit, e.style.display = "block");
2120
2134
  }
2121
2135
  paintCartograph(t, e) {
2122
2136
  const n = this.image;
2123
2137
  if (!n || !n.complete || n.naturalWidth === 0) return;
2124
- const { w: i, h: o } = C(this), s = i * e.pxPerMm, a = o * e.pxPerMm;
2138
+ const { w: i, h: o } = S(this), s = i * e.pxPerMm, a = o * e.pxPerMm;
2125
2139
  if (s <= 0 || a <= 0) return;
2126
2140
  const l = this.fit;
2127
2141
  if (l === "fill") {
2128
2142
  t.drawImage(n, 0, 0, s, a);
2129
2143
  return;
2130
2144
  }
2131
- const c = n.naturalWidth / n.naturalHeight, u = s / a, h = l === "contain" ? c > u : c < u, d = h ? s : a * c, m = h ? s / c : a;
2132
- l === "cover" && (t.save(), t.beginPath(), t.rect(0, 0, s, a), t.clip()), t.drawImage(n, (s - d) / 2, (a - m) / 2, d, m), l === "cover" && t.restore();
2145
+ const c = n.naturalWidth / n.naturalHeight, u = s / a, m = l === "contain" ? c > u : c < u, d = m ? s : a * c, h = m ? s / c : a;
2146
+ l === "cover" && (t.save(), t.beginPath(), t.rect(0, 0, s, a), t.clip()), t.drawImage(n, (s - d) / 2, (a - h) / 2, d, h), l === "cover" && t.restore();
2133
2147
  }
2134
2148
  }
2135
- k("om-image", er);
2136
- const Cn = /* @__PURE__ */ new Set(["PathLayer", "LineLayer", "ArcLayer", "TripsLayer", "GreatCircleLayer", "PathStyleLayer"]), kn = /* @__PURE__ */ new Set(["ScatterplotLayer", "IconLayer", "TextLayer", "PointCloudLayer", "HeatmapLayer", "ScreenGridLayer"]), $n = /* @__PURE__ */ new Set(["COGLayer", "ZarrLayer", "BitmapLayer", "TerrainLayer", "ImageOverlay"]);
2137
- function xn(r) {
2149
+ k("om-image", nr);
2150
+ const En = /* @__PURE__ */ new Set(["PathLayer", "LineLayer", "ArcLayer", "TripsLayer", "GreatCircleLayer", "PathStyleLayer"]), Nn = /* @__PURE__ */ new Set(["ScatterplotLayer", "IconLayer", "TextLayer", "PointCloudLayer", "HeatmapLayer", "ScreenGridLayer"]), Pn = /* @__PURE__ */ new Set(["COGLayer", "ZarrLayer", "BitmapLayer", "TerrainLayer", "ImageOverlay"]);
2151
+ function Tn(r) {
2138
2152
  const t = r.type ?? "";
2139
- if ($n.has(t)) return "ramp";
2140
- if (Cn.has(t)) return "line";
2141
- if (kn.has(t)) return "point";
2153
+ if (Pn.has(t)) return "ramp";
2154
+ if (En.has(t)) return "line";
2155
+ if (Nn.has(t)) return "point";
2142
2156
  if (t === "GeoJsonLayer") {
2143
2157
  const e = r.props ?? {}, n = e.getFillColor !== void 0, i = e.getLineColor !== void 0;
2144
2158
  if (n && !i) return "polygon";
@@ -2146,24 +2160,24 @@ function xn(r) {
2146
2160
  }
2147
2161
  return "polygon";
2148
2162
  }
2149
- function En(r) {
2163
+ function Ln(r) {
2150
2164
  const t = r.meta?.legend;
2151
2165
  return r.meta?.color ?? (t?.kind === "ramp" ? t.colors[0] : t?.entries[0]?.color) ?? "#999";
2152
2166
  }
2153
2167
  const kt = 12;
2154
- function Nn(r, t = []) {
2168
+ function Rn(r, t = []) {
2155
2169
  const e = [];
2156
2170
  for (const n of r) {
2157
2171
  if (n.props?.visible === !1) continue;
2158
2172
  const i = t.filter((a) => a.layer === n.id), o = i.find((a) => a.match == null);
2159
2173
  if (o?.hide) continue;
2160
- const s = Pn(n.meta?.legend);
2174
+ const s = Fn(n.meta?.legend);
2161
2175
  e.push({
2162
2176
  layerId: n.id,
2163
2177
  label: o?.label ?? n.meta?.label ?? n.id,
2164
- color: o?.color ?? En(n),
2165
- shape: o?.shape ?? xn(n),
2166
- legend: Tn(s, i),
2178
+ color: o?.color ?? Ln(n),
2179
+ shape: o?.shape ?? Tn(n),
2180
+ legend: In(s, i),
2167
2181
  order: o?.order
2168
2182
  });
2169
2183
  }
@@ -2172,7 +2186,7 @@ function Nn(r, t = []) {
2172
2186
  return o - s || n.index - i.index;
2173
2187
  }).map((n) => n.row);
2174
2188
  }
2175
- function Pn(r) {
2189
+ function Fn(r) {
2176
2190
  if (!r || r.kind !== "categories" || r.entries.length <= kt) return r;
2177
2191
  const t = r.entries.slice(0, kt), e = r.entries.length - kt;
2178
2192
  return {
@@ -2180,7 +2194,7 @@ function Pn(r) {
2180
2194
  entries: [...t, { color: r.defaultColor ?? "#999", label: `+${e} more` }]
2181
2195
  };
2182
2196
  }
2183
- function Tn(r, t) {
2197
+ function In(r, t) {
2184
2198
  const e = t.filter((i) => i.match != null);
2185
2199
  if (!r || r.kind === "ramp" || e.length === 0) return r;
2186
2200
  const n = [];
@@ -2190,7 +2204,7 @@ function Tn(r, t) {
2190
2204
  }
2191
2205
  return { ...r, entries: n };
2192
2206
  }
2193
- function Ln(r) {
2207
+ function On(r) {
2194
2208
  const t = [];
2195
2209
  for (const e of r.querySelectorAll(":scope > om-legend-row")) {
2196
2210
  const n = e.getAttribute("layer");
@@ -2208,7 +2222,7 @@ function Ln(r) {
2208
2222
  }
2209
2223
  return t;
2210
2224
  }
2211
- function rr(r) {
2225
+ function ir(r) {
2212
2226
  const t = [];
2213
2227
  for (const e of r.querySelectorAll(":scope > om-legend-row")) {
2214
2228
  if (e.hasAttribute("hide")) continue;
@@ -2223,36 +2237,46 @@ function rr(r) {
2223
2237
  }
2224
2238
  return t.sort((e, n) => (e.order ?? Number.POSITIVE_INFINITY) - (n.order ?? Number.POSITIVE_INFINITY));
2225
2239
  }
2226
- const Ae = "data-om-carto-legend-rows";
2227
- class nr extends I {
2240
+ const Me = "data-om-carto-legend-rows";
2241
+ class sr extends O {
2228
2242
  static observedAttributes = [...T["om-legend"]];
2229
2243
  get derived() {
2230
2244
  return this.getAttribute("derived") !== "false";
2231
2245
  }
2232
2246
  /** The rows this legend currently shows — recomputed on demand, never stored. */
2233
2247
  get rows() {
2234
- if (!this.derived) return rr(this);
2235
- const n = O(this)?.mapElement?.getLayers?.();
2236
- return n ? Nn(n, Ln(this)) : [];
2248
+ if (!this.derived) return ir(this);
2249
+ const n = U(this)?.mapElement?.getLayers?.();
2250
+ return n ? Rn(n, On(this)) : [];
2251
+ }
2252
+ /** Inner padding in mm — authored, else the 2 mm the theme always used. */
2253
+ get paddingMm() {
2254
+ const t = Number(this.getAttribute("padding"));
2255
+ return Number.isFinite(t) && t >= 0 && this.getAttribute("padding") !== null ? t : 2;
2256
+ }
2257
+ /** Row text size in mm — `font-size` is authored in points, like <om-text>. */
2258
+ get fontMm() {
2259
+ const t = Number(this.getAttribute("font-size"));
2260
+ return Number.isFinite(t) && t > 0 ? t * 25.4 / 72 : 2.6;
2237
2261
  }
2238
2262
  renderNow() {
2239
- if (this.applyPlacement(), this.style.display = "block", this.style.boxSizing = "border-box", this.style.overflow = "hidden", this.derived && !O(this)) {
2263
+ if (this.applyPlacement(), this.style.display = "block", this.style.boxSizing = "border-box", this.style.overflow = "hidden", this.applyThemeOverride("bg", "--om-carto-legend-bg"), this.applyThemeOverride("stroke", "--om-carto-legend-border"), this.applyThemeOverride("color", "--om-carto-legend-title-ink", !0), this.derived && !U(this)) {
2240
2264
  const e = this.getAttribute("for");
2241
- q(this, e ? `Legend references no frame with id "${e}".` : "Legend has no frame to derive from (set for=).");
2265
+ W(this, e ? `Legend references no frame with id "${e}".` : "Legend has no frame to derive from (set for=).");
2242
2266
  return;
2243
2267
  }
2244
2268
  const t = this.rows;
2245
2269
  if (t.length === 0 && this.derived) {
2246
- q(this, "Legend is waiting for its frame's layers.");
2270
+ W(this, "Legend is waiting for its frame's layers.");
2247
2271
  return;
2248
2272
  }
2249
2273
  this.renderRows(t);
2250
2274
  }
2251
2275
  renderRows(t) {
2252
2276
  const e = this.ownerDocument;
2253
- this.querySelector(`:scope > [${Ae}]`)?.remove(), zr(this);
2277
+ this.querySelector(`:scope > [${Me}]`)?.remove(), Br(this);
2254
2278
  const n = e.createElement("div");
2255
- n.setAttribute(Ae, ""), n.style.cssText = "padding:2mm;font-size:2.6mm;line-height:1.35;";
2279
+ n.setAttribute(Me, ""), n.style.cssText = `padding:${this.paddingMm}mm;font-size:${this.fontMm}mm;line-height:1.35;`;
2256
2280
  const i = this.getAttribute("title");
2257
2281
  if (i) {
2258
2282
  const s = e.createElement("div");
@@ -2296,38 +2320,38 @@ class nr extends I {
2296
2320
  return n;
2297
2321
  }
2298
2322
  paintCartograph(t, e) {
2299
- const { w: n, h: i } = C(this), o = n * e.pxPerMm, s = i * e.pxPerMm;
2323
+ const { w: n, h: i } = S(this), o = n * e.pxPerMm, s = i * e.pxPerMm;
2300
2324
  if (o <= 0 || s <= 0) return;
2301
- const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = R(a?.backgroundColor);
2325
+ const a = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, l = F(a?.backgroundColor);
2302
2326
  l && (t.fillStyle = l, t.fillRect(0, 0, o, s));
2303
- const c = R(a?.borderTopColor), u = xt(a?.borderTopWidth) * e.scale;
2327
+ const c = F(a?.borderTopColor), u = $t(a?.borderTopWidth) * e.scale;
2304
2328
  c && u > 0 && (t.strokeStyle = c, t.lineWidth = u, t.strokeRect(u / 2, u / 2, o - u, s - u));
2305
- const h = R(a?.color) ?? "#111", d = a?.fontFamily || "system-ui, sans-serif", m = (P) => P * e.pxPerMm;
2306
- let f = m(2);
2307
- const g = this.getAttribute("title");
2308
- g && (t.fillStyle = h, t.font = `600 ${m(2.6)}px ${d}`, t.textBaseline = "top", t.fillText(g, m(2), f), f += m(4));
2309
- const p = this.rows, b = Number(this.getAttribute("columns")), w = Math.min(p.length || 1, Number.isFinite(b) && b > 1 ? Math.floor(b) : 1), y = Math.max(1, Math.ceil(p.length / w)), M = 3, v = Math.max(1, (n - 4 - M * (w - 1)) / w), N = f;
2310
- let _ = -1, $ = 2;
2311
- t.font = `${m(2.6)}px ${d}`;
2312
- for (const [P, L] of p.entries()) {
2313
- const A = Math.min(w - 1, Math.floor(P / y));
2314
- if (A !== _ && (_ = A, $ = 2 + _ * (v + M), f = _ === 0 ? N : m(2)), f > s || (t.fillStyle = L.color, L.shape === "line" ? t.fillRect(m($), f + m(1.2), m(3.2), m(0.9)) : L.shape === "point" ? (t.beginPath(), t.arc(m($ + 1.6), f + m(1.6), m(1.6), 0, Math.PI * 2), t.fill()) : t.fillRect(m($), f, m(3.2), m(3.2)), t.fillStyle = h, t.textBaseline = "top", t.fillText(L.label, m($ + 4.7), f + m(0.3)), f += m(4.2), !L.legend)) continue;
2315
- const S = L.legend;
2316
- if (t.save(), t.font = `${m(2.1)}px ${d}`, t.globalAlpha = 0.7, t.fillText(S.field, m($ + 2.7), f), t.globalAlpha = 1, f += m(2.8), S.kind === "ramp") {
2317
- const x = Math.min(24, Math.max(1, v - 2.7)), E = $ + 2.7, U = t.createLinearGradient(m(E), 0, m(E + x), 0);
2318
- S.colors.forEach((X, lr) => U.addColorStop(S.colors.length === 1 ? 0 : lr / (S.colors.length - 1), X)), t.fillStyle = U, t.fillRect(m(E), f, m(x), m(2.4)), f += m(3.4), t.fillStyle = h, t.font = `${m(2.1)}px ${d}`, t.fillText(S.domain[0].toLocaleString("en-US"), m(E), f);
2319
- const et = S.domain[1].toLocaleString("en-US");
2320
- t.textAlign = "right", t.fillText(et, m(E + x), f), t.textAlign = "left", f += m(3.2);
2329
+ const m = F(a?.color) ?? "#111", d = a?.fontFamily || "system-ui, sans-serif", h = (M) => M * e.pxPerMm, f = this.paddingMm, g = this.fontMm;
2330
+ let p = h(f);
2331
+ const b = this.getAttribute("title");
2332
+ b && (t.fillStyle = m, t.font = `600 ${h(g)}px ${d}`, t.textBaseline = "top", t.fillText(b, h(f), p), p += h(g * 1.55));
2333
+ const w = this.rows, y = Number(this.getAttribute("columns")), A = Math.min(w.length || 1, Number.isFinite(y) && y > 1 ? Math.floor(y) : 1), v = Math.max(1, Math.ceil(w.length / A)), $ = 3, G = Math.max(1, (n - f * 2 - $ * (A - 1)) / A), _ = p;
2334
+ let E = -1, N = f;
2335
+ t.font = `${h(g)}px ${d}`;
2336
+ for (const [M, C] of w.entries()) {
2337
+ const P = Math.min(A - 1, Math.floor(M / v));
2338
+ if (P !== E && (E = P, N = f + E * (G + $), p = E === 0 ? _ : h(f)), p > s || (t.fillStyle = C.color, C.shape === "line" ? t.fillRect(h(N), p + h(1.2), h(3.2), h(0.9)) : C.shape === "point" ? (t.beginPath(), t.arc(h(N + 1.6), p + h(1.6), h(1.6), 0, Math.PI * 2), t.fill()) : t.fillRect(h(N), p, h(3.2), h(3.2)), t.fillStyle = m, t.textBaseline = "top", t.fillText(C.label, h(N + 4.7), p + h(0.3)), p += h(g * 1.6), !C.legend)) continue;
2339
+ const x = C.legend;
2340
+ if (t.save(), t.font = `${h(2.1)}px ${d}`, t.globalAlpha = 0.7, t.fillText(x.field, h(N + 2.7), p), t.globalAlpha = 1, p += h(2.8), x.kind === "ramp") {
2341
+ const L = Math.min(24, Math.max(1, G - 2.7)), R = N + 2.7, B = t.createLinearGradient(h(R), 0, h(R + L), 0);
2342
+ x.colors.forEach((hr, mr) => B.addColorStop(x.colors.length === 1 ? 0 : mr / (x.colors.length - 1), hr)), t.fillStyle = B, t.fillRect(h(R), p, h(L), h(2.4)), p += h(3.4), t.fillStyle = m, t.font = `${h(2.1)}px ${d}`, t.fillText(x.domain[0].toLocaleString("en-US"), h(R), p);
2343
+ const ur = x.domain[1].toLocaleString("en-US");
2344
+ t.textAlign = "right", t.fillText(ur, h(R + L), p), t.textAlign = "left", p += h(3.2);
2321
2345
  } else {
2322
- const x = [...S.entries];
2323
- S.kind === "categories" && S.defaultColor && x.push({ color: S.defaultColor, label: "other" }), t.font = `${m(2.3)}px ${d}`;
2324
- for (const E of x) {
2325
- if (f > s) break;
2326
- t.fillStyle = E.color, t.fillRect(m($ + 2.7), f, m(2.6), m(2.6)), t.fillStyle = h, t.fillText(E.label, m($ + 6.3), f + m(0.2)), f += m(3.2);
2346
+ const L = [...x.entries];
2347
+ x.kind === "categories" && x.defaultColor && L.push({ color: x.defaultColor, label: "other" }), t.font = `${h(2.3)}px ${d}`;
2348
+ for (const R of L) {
2349
+ if (p > s) break;
2350
+ t.fillStyle = R.color, t.fillRect(h(N + 2.7), p, h(2.6), h(2.6)), t.fillStyle = m, t.fillText(R.label, h(N + 6.3), p + h(0.2)), p += h(3.2);
2327
2351
  }
2328
- f += m(1);
2352
+ p += h(1);
2329
2353
  }
2330
- t.restore(), t.font = `${m(2.6)}px ${d}`;
2354
+ t.restore(), t.font = `${h(2.6)}px ${d}`;
2331
2355
  }
2332
2356
  }
2333
2357
  }
@@ -2335,55 +2359,55 @@ const at = (r, t) => {
2335
2359
  const e = r.createElement("span");
2336
2360
  return e.textContent = t, e;
2337
2361
  };
2338
- k("om-legend", nr);
2339
- const Se = 48, _t = {
2362
+ k("om-legend", sr);
2363
+ const Se = 48, Ot = {
2340
2364
  toLngLat: (r, t) => [r, t],
2341
2365
  fromLngLat: (r) => [r[0], r[1]]
2342
2366
  };
2343
2367
  function Ce(r, t = 5) {
2344
- return !Number.isFinite(r) || r <= 0 ? 0 : Ue(r / Math.max(1, t));
2368
+ return !Number.isFinite(r) || r <= 0 ? 0 : ze(r / Math.max(1, t));
2345
2369
  }
2346
- function Rn({ georef: r, plane: t = _t, interval: e, intervalX: n, intervalY: i, labels: o = "outside", format: s }) {
2370
+ function _n({ georef: r, plane: t = Ot, interval: e, intervalX: n, intervalY: i, labels: o = "outside", format: s }) {
2347
2371
  if (r.degenerate) return null;
2348
2372
  const a = r.corners.map((y) => t.fromLngLat(y)), l = a.map((y) => y[0]), c = a.map((y) => y[1]);
2349
2373
  if (l.some((y) => !Number.isFinite(y)) || c.some((y) => !Number.isFinite(y))) return null;
2350
- const u = Math.min(...l), h = Math.max(...l), d = Math.min(...c), m = Math.max(...c), f = ke(n ?? e, Ce(h - u)), g = ke(i ?? e, Ce(m - d));
2351
- if (f <= 0 || g <= 0 || (h - u) / f > 500 || (m - d) / g > 500) return null;
2352
- const p = [], b = [], w = s ?? In;
2353
- for (let y = Math.ceil(u / f) * f; y <= h + 1e-9; y += f) {
2354
- const M = $e(r, t, y, d, m, "x");
2355
- if (M) {
2356
- p.push(M);
2357
- const v = t === _t ? Xe(y) : y;
2358
- o !== "none" && Ee(b, M, r, w(v, "x"), "x", o);
2374
+ const u = Math.min(...l), m = Math.max(...l), d = Math.min(...c), h = Math.max(...c), f = ke(n ?? e, Ce(m - u)), g = ke(i ?? e, Ce(h - d));
2375
+ if (f <= 0 || g <= 0 || (m - u) / f > 500 || (h - d) / g > 500) return null;
2376
+ const p = [], b = [], w = s ?? Dn;
2377
+ for (let y = Math.ceil(u / f) * f; y <= m + 1e-9; y += f) {
2378
+ const A = xe(r, t, y, d, h, "x");
2379
+ if (A) {
2380
+ p.push(A);
2381
+ const v = t === Ot ? Ze(y) : y;
2382
+ o !== "none" && Ee(b, A, r, w(v, "x"), "x", o);
2359
2383
  }
2360
2384
  }
2361
- for (let y = Math.ceil(d / g) * g; y <= m + 1e-9; y += g) {
2362
- const M = $e(r, t, y, u, h, "y");
2363
- M && (p.push(M), o !== "none" && Ee(b, M, r, w(y, "y"), "y", o));
2385
+ for (let y = Math.ceil(d / g) * g; y <= h + 1e-9; y += g) {
2386
+ const A = xe(r, t, y, u, m, "y");
2387
+ A && (p.push(A), o !== "none" && Ee(b, A, r, w(y, "y"), "y", o));
2364
2388
  }
2365
2389
  return { lines: p, labels: b, intervalX: f, intervalY: g };
2366
2390
  }
2367
2391
  const ke = (r, t) => r != null && Number.isFinite(r) && r > 0 ? r : t;
2368
- function $e(r, t, e, n, i, o) {
2392
+ function xe(r, t, e, n, i, o) {
2369
2393
  const s = [];
2370
2394
  for (let l = 0; l <= Se; l++) {
2371
2395
  const c = n + (i - n) * l / Se, u = o === "x" ? t.toLngLat(e, c) : t.toLngLat(c, e);
2372
2396
  if (!Number.isFinite(u[0]) || !Number.isFinite(u[1])) continue;
2373
- const h = r.project(u);
2374
- h && s.push(h);
2397
+ const m = r.project(u);
2398
+ m && s.push(m);
2375
2399
  }
2376
- const a = Fn(s, r.widthMm, r.heightMm);
2400
+ const a = Un(s, r.widthMm, r.heightMm);
2377
2401
  return a.length >= 2 ? { points: a, value: e, axis: o } : null;
2378
2402
  }
2379
- function Fn(r, t, e) {
2403
+ function Un(r, t, e) {
2380
2404
  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);
2381
2405
  if (i === -1) return [];
2382
2406
  let o = r.length - 1;
2383
2407
  for (; o > i && !n(r[o]); ) o--;
2384
- return r.slice(Math.max(0, i - 1), Math.min(r.length, o + 2)).map((a) => ({ xMm: xe(a.xMm, 0, t), yMm: xe(a.yMm, 0, e) }));
2408
+ return r.slice(Math.max(0, i - 1), Math.min(r.length, o + 2)).map((a) => ({ xMm: $e(a.xMm, 0, t), yMm: $e(a.yMm, 0, e) }));
2385
2409
  }
2386
- const xe = (r, t, e) => Math.min(e, Math.max(t, r));
2410
+ const $e = (r, t, e) => Math.min(e, Math.max(t, r));
2387
2411
  function Ee(r, t, e, n, i, o) {
2388
2412
  if (i === "x") {
2389
2413
  const s = t.points.reduce((a, l) => l.yMm > a.yMm ? l : a);
@@ -2395,24 +2419,24 @@ function Ee(r, t, e, n, i, o) {
2395
2419
  r.push({ text: n, xMm: o === "outside" ? -1.2 : 1.2, yMm: s.yMm, edge: "left", axis: i });
2396
2420
  }
2397
2421
  }
2398
- function In(r, t) {
2422
+ function Dn(r, t) {
2399
2423
  if (Math.abs(r) >= 1e3) return Math.round(r).toLocaleString("en-US");
2400
2424
  const e = Math.abs(r) < 1 ? 3 : Math.abs(r) < 10 ? 2 : 1;
2401
2425
  return `${Number(r.toFixed(e))}°`;
2402
2426
  }
2403
- function _n(r, t) {
2404
- const e = t === "x" ? r < 0 ? "W" : "E" : r < 0 ? "S" : "N", n = Math.abs(r), i = Math.floor(n), o = (n - i) * 60, s = Math.floor(o), a = Math.round((o - s) * 60), l = a === 60 ? s + 1 : s, c = l === 60 ? i + 1 : i, u = l === 60 ? 0 : l, h = a === 60 ? 0 : a;
2405
- return `${c}°${String(u).padStart(2, "0")}′${String(h).padStart(2, "0")}″${e}`;
2427
+ function zn(r, t) {
2428
+ const e = t === "x" ? r < 0 ? "W" : "E" : r < 0 ? "S" : "N", n = Math.abs(r), i = Math.floor(n), o = (n - i) * 60, s = Math.floor(o), a = Math.round((o - s) * 60), l = a === 60 ? s + 1 : s, c = l === 60 ? i + 1 : i, u = l === 60 ? 0 : l, m = a === 60 ? 0 : a;
2429
+ return `${c}°${String(u).padStart(2, "0")}′${String(m).padStart(2, "0")}″${e}`;
2406
2430
  }
2407
- const lt = "http://www.w3.org/2000/svg", On = ["solid", "cross", "markers"], z = 1.4;
2408
- class ir extends I {
2431
+ const lt = "http://www.w3.org/2000/svg", jn = ["solid", "cross", "markers"], j = 1.4;
2432
+ class or extends O {
2409
2433
  static observedAttributes = [...T["om-graticule"]];
2410
2434
  resolvedPlane = null;
2411
2435
  resolvedPlaneKey = null;
2412
2436
  resolveToken = 0;
2413
2437
  get kind() {
2414
2438
  const t = this.getAttribute("kind");
2415
- return On.includes(t) ? t : "solid";
2439
+ return jn.includes(t) ? t : "solid";
2416
2440
  }
2417
2441
  get labelPlacement() {
2418
2442
  const t = this.getAttribute("labels");
@@ -2420,7 +2444,7 @@ class ir extends I {
2420
2444
  }
2421
2445
  /** The grid this element currently draws, or null when it cannot yet. */
2422
2446
  get graticule() {
2423
- const t = O(this)?.georef;
2447
+ const t = U(this)?.georef;
2424
2448
  if (!t) return null;
2425
2449
  const e = this.gridPlane();
2426
2450
  if (!e) return null;
@@ -2428,14 +2452,14 @@ class ir extends I {
2428
2452
  const o = Number(this.getAttribute(i));
2429
2453
  return Number.isFinite(o) && o > 0 ? o : null;
2430
2454
  };
2431
- return Rn({
2455
+ return _n({
2432
2456
  georef: t,
2433
2457
  plane: e,
2434
2458
  interval: n("interval"),
2435
2459
  intervalX: n("interval-x"),
2436
2460
  intervalY: n("interval-y"),
2437
2461
  labels: this.labelPlacement,
2438
- format: this.getAttribute("format") === "dms" ? _n : void 0
2462
+ format: this.getAttribute("format") === "dms" ? zn : void 0
2439
2463
  });
2440
2464
  }
2441
2465
  /**
@@ -2445,10 +2469,10 @@ class ir extends I {
2445
2469
  */
2446
2470
  gridPlane() {
2447
2471
  const t = Lt(this.getAttribute("crs"));
2448
- if (!t || t === "EPSG:4326" || t === "CRS:84" || t === "OGC:CRS84") return _t;
2472
+ if (!t || t === "EPSG:4326" || t === "CRS:84" || t === "OGC:CRS84") return Ot;
2449
2473
  const e = `${t}|${this.getAttribute("crs-def") ?? ""}`;
2450
2474
  if (this.resolvedPlaneKey === e) return this.resolvedPlane;
2451
- const n = K(t);
2475
+ const n = Y(t);
2452
2476
  if (n) {
2453
2477
  const o = { toLngLat: (s, a) => n.inverse([s, a]), fromLngLat: (s) => n.forward(s) };
2454
2478
  return this.resolvedPlane = o, this.resolvedPlaneKey = e, o;
@@ -2460,9 +2484,9 @@ class ir extends I {
2460
2484
  }), null;
2461
2485
  }
2462
2486
  renderNow() {
2463
- if (this.applyPlacement(), this.style.display = "block", this.style.pointerEvents = "none", !O(this)) {
2487
+ if (this.applyPlacement(), this.applyThemeOverride("color", "--om-carto-graticule-ink", !0), this.style.display = "block", this.style.pointerEvents = "none", !U(this)) {
2464
2488
  const n = this.getAttribute("for");
2465
- q(this, n ? `Graticule references no frame with id "${n}".` : "Graticule has no frame to cover (set for=).");
2489
+ W(this, n ? `Graticule references no frame with id "${n}".` : "Graticule has no frame to cover (set for=).");
2466
2490
  return;
2467
2491
  }
2468
2492
  const e = this.graticule;
@@ -2473,7 +2497,7 @@ class ir extends I {
2473
2497
  this.renderSvg(e);
2474
2498
  }
2475
2499
  renderSvg(t) {
2476
- const { w: e, h: n } = C(this), i = this.ownerDocument, o = i.createElementNS(lt, "svg");
2500
+ const { w: e, h: n } = S(this), i = this.ownerDocument, o = i.createElementNS(lt, "svg");
2477
2501
  o.setAttribute("width", `${e}mm`), o.setAttribute("height", `${n}mm`), o.setAttribute("viewBox", `0 0 ${e} ${n}`), o.style.cssText = "display:block;overflow:visible;";
2478
2502
  const s = "var(--om-carto-graticule-ink)", a = this.kind;
2479
2503
  for (const l of t.lines)
@@ -2483,7 +2507,7 @@ class ir extends I {
2483
2507
  } else
2484
2508
  for (const c of this.tickPoints(l, a, t)) {
2485
2509
  const u = i.createElementNS(lt, "path");
2486
- 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", s), u.setAttribute("stroke-width", "0.15"), o.appendChild(u);
2510
+ u.setAttribute("d", `M ${c.xMm - j} ${c.yMm} H ${c.xMm + j} M ${c.xMm} ${c.yMm - j} V ${c.yMm + j}`), u.setAttribute("stroke", s), u.setAttribute("stroke-width", "0.15"), o.appendChild(u);
2487
2511
  }
2488
2512
  for (const l of t.labels) {
2489
2513
  const c = i.createElementNS(lt, "text");
@@ -2496,7 +2520,7 @@ class ir extends I {
2496
2520
  if (e === "markers") return [t.points[0], t.points[t.points.length - 1]];
2497
2521
  const i = n.lines.filter((s) => s.axis !== t.axis), o = [];
2498
2522
  for (const s of i) {
2499
- const a = Un(t.points, s.points);
2523
+ const a = Gn(t.points, s.points);
2500
2524
  a && o.push(a);
2501
2525
  }
2502
2526
  return o;
@@ -2504,21 +2528,21 @@ class ir extends I {
2504
2528
  paintCartograph(t, e) {
2505
2529
  const n = this.graticule;
2506
2530
  if (!n) return;
2507
- const i = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, o = R(i?.color) ?? "#ffffff", s = (l) => l * e.pxPerMm, a = this.kind;
2531
+ const i = typeof getComputedStyle == "function" ? getComputedStyle(this) : null, o = F(i?.color) ?? "#ffffff", s = (l) => l * e.pxPerMm, a = this.kind;
2508
2532
  t.save(), t.strokeStyle = o, t.fillStyle = o, t.lineWidth = s(0.15);
2509
2533
  for (const l of n.lines)
2510
2534
  if (a === "solid")
2511
2535
  t.beginPath(), l.points.forEach((c, u) => u === 0 ? t.moveTo(s(c.xMm), s(c.yMm)) : t.lineTo(s(c.xMm), s(c.yMm))), t.stroke();
2512
2536
  else
2513
2537
  for (const c of this.tickPoints(l, a, n))
2514
- t.beginPath(), t.moveTo(s(c.xMm - z), s(c.yMm)), t.lineTo(s(c.xMm + z), s(c.yMm)), t.moveTo(s(c.xMm), s(c.yMm - z)), t.lineTo(s(c.xMm), s(c.yMm + z)), t.stroke();
2538
+ t.beginPath(), t.moveTo(s(c.xMm - j), s(c.yMm)), t.lineTo(s(c.xMm + j), s(c.yMm)), t.moveTo(s(c.xMm), s(c.yMm - j)), t.lineTo(s(c.xMm), s(c.yMm + j)), t.stroke();
2515
2539
  t.font = `${s(2.2)}px ${i?.fontFamily || "system-ui, sans-serif"}`, t.textBaseline = "alphabetic";
2516
2540
  for (const l of n.labels)
2517
2541
  t.textAlign = l.edge === "left" ? "right" : "center", t.fillText(l.text, s(l.xMm), s(l.yMm));
2518
2542
  t.restore();
2519
2543
  }
2520
2544
  }
2521
- function Un(r, t) {
2545
+ function Gn(r, t) {
2522
2546
  let e = null, n = Number.POSITIVE_INFINITY;
2523
2547
  for (const i of r)
2524
2548
  for (const o of t) {
@@ -2527,26 +2551,26 @@ function Un(r, t) {
2527
2551
  }
2528
2552
  return n <= 1 ? e : null;
2529
2553
  }
2530
- k("om-graticule", ir);
2531
- function Dn(r, t) {
2554
+ k("om-graticule", or);
2555
+ function qn(r, t) {
2532
2556
  if (r == null || typeof r != "object") return;
2533
2557
  const e = r.properties;
2534
2558
  return e && t in e ? e[t] : r[t];
2535
2559
  }
2536
- function Ot(r, t) {
2560
+ function _t(r, t) {
2537
2561
  if (Array.isArray(r)) {
2538
2562
  if (typeof r[0] == "number") {
2539
2563
  t.push([r[0], r[1]]);
2540
2564
  return;
2541
2565
  }
2542
- for (const e of r) Ot(e, t);
2566
+ for (const e of r) _t(e, t);
2543
2567
  }
2544
2568
  }
2545
- function jn(r) {
2569
+ function Wn(r) {
2546
2570
  return r ? r.tileData != null ? "tiled" : r.asset != null ? "asset" : null : "empty";
2547
2571
  }
2548
- function F(r, t) {
2549
- return Dn(r, t);
2572
+ function I(r, t) {
2573
+ return qn(r, t);
2550
2574
  }
2551
2575
  function Ut(r) {
2552
2576
  const t = {}, e = (i) => {
@@ -2557,64 +2581,65 @@ function Ut(r) {
2557
2581
  const n = r.properties;
2558
2582
  return n && typeof n == "object" && e(n), t;
2559
2583
  }
2560
- function zn(r) {
2584
+ function Bn(r) {
2561
2585
  let t = 1 / 0, e = 1 / 0, n = -1 / 0, i = -1 / 0;
2562
2586
  const o = [], s = r.geometry;
2563
- if (s?.coordinates != null) Ot(s.coordinates, o);
2564
- else if (Array.isArray(r.coordinates)) Ot(r.coordinates, o);
2587
+ if (s?.coordinates != null) _t(s.coordinates, o);
2588
+ else if (Array.isArray(r.coordinates)) _t(r.coordinates, o);
2565
2589
  else {
2566
- const a = Number(F(r, "lng") ?? F(r, "longitude") ?? F(r, "lon") ?? F(r, "x")), l = Number(F(r, "lat") ?? F(r, "latitude") ?? F(r, "y"));
2590
+ 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"));
2567
2591
  Number.isFinite(a) && Number.isFinite(l) && o.push([a, l]);
2568
2592
  }
2569
2593
  for (const [a, l] of o)
2570
2594
  !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));
2571
2595
  return !Number.isFinite(t) || !Number.isFinite(e) ? null : [t, e, n, i];
2572
2596
  }
2573
- function Gn(r, t) {
2597
+ function Kn(r, t) {
2574
2598
  const [e, n, i, o] = r, s = Math.max(i - e, 1e-4), a = Math.max(o - n, 1e-4), l = s * t, c = a * t;
2575
2599
  return [e - l, n - c, i + l, o + c];
2576
2600
  }
2577
- const Mi = ([r, t, e, n]) => Math.max(0, e - r) * Math.max(0, n - t);
2578
- function qn({ features: r, filter: t, sort: e }) {
2579
- let n = t ? r.filter((o) => Wn(t, o)) : [...r];
2580
- const i = Bn(e);
2601
+ const Ei = ([r, t, e, n]) => Math.max(0, e - r) * Math.max(0, n - t);
2602
+ function Vn({ features: r, filter: t, sort: e }) {
2603
+ let n = t ? r.filter((o) => Hn(t, o)) : [...r];
2604
+ const i = Yn(e);
2581
2605
  return i.length > 0 && (n = [...n].sort((o, s) => {
2582
2606
  for (const { field: a, descending: l } of i) {
2583
- const c = F(o, a), u = F(s, a);
2607
+ const c = I(o, a), u = I(s, a);
2584
2608
  if (c == null && u == null) continue;
2585
2609
  if (c == null) return 1;
2586
2610
  if (u == null) return -1;
2587
- const h = Vn(c, u);
2588
- if (h !== 0) return l ? -h : h;
2611
+ const m = Xn(c, u);
2612
+ if (m !== 0) return l ? -m : m;
2589
2613
  }
2590
2614
  return 0;
2591
2615
  })), n;
2592
2616
  }
2593
- function Wn(r, t) {
2617
+ function Hn(r, t) {
2594
2618
  try {
2595
2619
  return !!r(t);
2596
2620
  } catch {
2597
2621
  return !1;
2598
2622
  }
2599
2623
  }
2600
- function Bn(r) {
2624
+ function Yn(r) {
2601
2625
  return r ? r.split(",").map((t) => t.trim()).filter(Boolean).map((t) => t.startsWith("-") ? { field: t.slice(1), descending: !0 } : { field: t, descending: !1 }) : [];
2602
2626
  }
2603
- function Vn(r, t) {
2627
+ function Xn(r, t) {
2604
2628
  return typeof r == "number" && typeof t == "number" ? r - t : String(r).localeCompare(String(t), void 0, { numeric: !0, sensitivity: "base" });
2605
2629
  }
2606
- function Kn(r) {
2630
+ function Jn(r) {
2607
2631
  const t = r.replace(/[\x00-\x1f<>:"/\\|?*]+/g, "-").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^[-.]+|[-.]+$/g, "").slice(0, 100);
2608
2632
  return t === "" ? "page" : t;
2609
2633
  }
2610
- function Hn(r, t, e) {
2634
+ function Zn(r, t, e) {
2611
2635
  const n = /* @__PURE__ */ new Map();
2612
2636
  return t.map((i, o) => {
2613
- const s = Ut(i), a = (r ?? "page-{{atlas.index}}").replace(/\{\{\s*atlas\.([\w]+)\s*\}\}/g, (u, h) => h === "index" ? String(o + 1) : h === "count" ? String(t.length) : s[h] ?? u), l = Kn(a), c = n.get(l) ?? 0;
2637
+ const s = Ut(i), a = (r ?? "page-{{atlas.index}}").replace(/\{\{\s*atlas\.([\w]+)\s*\}\}/g, (u, m) => m === "index" ? String(o + 1) : m === "count" ? String(t.length) : s[m] ?? u), l = Jn(a), c = n.get(l) ?? 0;
2614
2638
  return n.set(l, c + 1), `${c === 0 ? l : `${l}-${c + 1}`}.${e}`;
2615
2639
  });
2616
2640
  }
2617
- class sr extends I {
2641
+ const Ne = "data-om-carto-pager", Qn = "data-om-carto-screen-only", ti = "onlymap-cartograph", ei = "onlymap-cartograph-host";
2642
+ class ar extends O {
2618
2643
  static observedAttributes = [...T["om-atlas"]];
2619
2644
  /**
2620
2645
  * Pages are SNAPSHOTTED when iteration first starts. A streaming or polling
@@ -2624,9 +2649,51 @@ class sr extends I {
2624
2649
  pages = null;
2625
2650
  currentIndex = 0;
2626
2651
  rejection = null;
2652
+ pager = null;
2653
+ /**
2654
+ * Arrow keys page the atlas. This element had `seek()`, `next()` and an
2655
+ * event, and no way for a READER to use any of them: a 49-page atlas opened
2656
+ * in a preview, a browser or an exported file showed page one and could not
2657
+ * be moved off it. Bound as fields so the exact function is removed again.
2658
+ */
2659
+ onKeyDown = (t) => {
2660
+ if (t.defaultPrevented || t.metaKey || t.ctrlKey || t.altKey || !this.isConnected || this.count === 0) return;
2661
+ const e = t.target, n = e?.tagName?.toLowerCase();
2662
+ if (n === "input" || n === "textarea" || n === "select" || e?.isContentEditable) return;
2663
+ let i = null;
2664
+ switch (t.key) {
2665
+ case "ArrowRight":
2666
+ case "PageDown":
2667
+ i = this.currentIndex + 1;
2668
+ break;
2669
+ case "ArrowLeft":
2670
+ case "PageUp":
2671
+ i = this.currentIndex - 1;
2672
+ break;
2673
+ case "Home":
2674
+ i = 0;
2675
+ break;
2676
+ case "End":
2677
+ i = this.count - 1;
2678
+ break;
2679
+ default:
2680
+ return;
2681
+ }
2682
+ t.preventDefault(), this.seek(i);
2683
+ };
2684
+ /**
2685
+ * A parent window may drive the atlas: `{ source: "onlymap-cartograph-host",
2686
+ * type: "atlas-seek", index }`. This is what lets a host that shows the
2687
+ * sheet in a CROSS-ORIGIN iframe — where it cannot reach `seek()` — page it
2688
+ * anyway. Any window can post this; the worst it can do is turn a page.
2689
+ */
2690
+ onHostMessage = (t) => {
2691
+ const e = t.data;
2692
+ !e || e.source !== ei || e.type !== "atlas-seek" || typeof e.index == "number" && Number.isInteger(e.index) && this.seek(e.index);
2693
+ };
2627
2694
  /** The frame whose layer drives the iteration — the same `for=` rule every furniture element follows. */
2628
2695
  get frame() {
2629
- return O(this);
2696
+ return U(this);
2630
2697
  }
2631
2698
  get count() {
2632
2699
  return this.ensurePages().length;
@@ -2643,7 +2710,7 @@ class sr extends I {
2643
2710
  }
2644
2711
  /** Export filenames, one per page, already de-duplicated. */
2645
2712
  filenames(t = "png") {
2646
- return Hn(this.getAttribute("filename"), this.ensurePages(), t);
2713
+ return Zn(this.getAttribute("filename"), this.ensurePages(), t);
2647
2714
  }
2648
2715
  /** Human page labels, for an editor's stepper and PDF bookmarks. */
2649
2716
  pageName(t) {
@@ -2663,15 +2730,15 @@ class sr extends I {
2663
2730
  * the authored camera, until something else happened to seek.
2664
2731
  */
2665
2732
  refresh() {
2666
- this.pages = null, this.rejection = null, this.ensurePages().length > 0 && this.applyPage();
2733
+ this.pages = null, this.rejection = null, this.ensurePages().length > 0 ? this.applyPage() : this.renderPager();
2667
2734
  }
2668
2735
  ensurePages() {
2669
2736
  if (this.pages) return this.pages;
2670
- const e = this.frame?.mapElement?.getLayers?.(), n = this.getAttribute("layer"), i = e?.find((a) => a.id === n), o = e ? jn(i) : null;
2737
+ const e = this.frame?.mapElement?.getLayers?.(), n = this.getAttribute("layer"), i = e?.find((a) => a.id === n), o = e ? Wn(i) : null;
2671
2738
  if (!e || o)
2672
2739
  return this.rejection = e ? o : null, this.pages = [];
2673
2740
  const s = this.materialize(i);
2674
- return this.pages = qn({ features: s, filter: this.compileFilter(), sort: this.getAttribute("sort") }), this.currentIndex = Math.min(this.currentIndex, Math.max(0, this.pages.length - 1)), this.pages;
2741
+ return this.pages = Vn({ features: s, filter: this.compileFilter(), sort: this.getAttribute("sort") }), this.currentIndex = Math.min(this.currentIndex, Math.max(0, this.pages.length - 1)), this.pages;
2675
2742
  }
2676
2743
  /**
2677
2744
  * Rows from the layer, with the layer's OWN declarative filters applied —
@@ -2679,13 +2746,13 @@ class sr extends I {
2679
2746
  * sheets for features the map itself is hiding.
2680
2747
  */
2681
2748
  materialize(t) {
2682
- const e = Y(), n = t.data;
2749
+ const e = J(), n = t.data;
2683
2750
  if (!n) return [];
2684
2751
  const i = e?.asRows ? e.asRows(n) : Array.isArray(n) ? n : [], o = [t.filter, t.categoryFilter].filter(Boolean);
2685
2752
  return o.length === 0 ? i : i.filter(
2686
2753
  (s) => o.every((a) => {
2687
2754
  if (!a.field) return !0;
2688
- const l = F(s, a.field);
2755
+ const l = I(s, a.field);
2689
2756
  if (a.range) {
2690
2757
  const c = Number(l);
2691
2758
  return Number.isFinite(c) && c >= a.range[0] && c <= a.range[1];
@@ -2698,7 +2765,7 @@ class sr extends I {
2698
2765
  compileFilter() {
2699
2766
  const t = this.getAttribute("filter");
2700
2767
  if (!t) return;
2701
- const e = Y();
2768
+ const e = J();
2702
2769
  if (e?.compileExpression)
2703
2770
  try {
2704
2771
  const n = e.compileExpression(t, { shape: "geojson", paramName: "d" });
@@ -2720,26 +2787,74 @@ class sr extends I {
2720
2787
  const t = this.current;
2721
2788
  if (!t) return;
2722
2789
  const e = this.closest("om-cartograph");
2723
- for (const n of e?.querySelectorAll("om-frame") ?? []) {
2724
- if (n.getAttribute("atlas-fit") !== "feature") continue;
2725
- const i = zn(t);
2726
- if (!i) continue;
2727
- const o = Number(n.getAttribute("atlas-margin")), s = Gn(i, Number.isFinite(o) && o > 0 ? o : 0.15);
2728
- n.fitBounds?.(s);
2729
- }
2730
- e?.setAtlasFields({ ...Ut(t), index: String(this.currentIndex + 1), count: String(this.count) }), e?.refreshFurniture(), this.dispatchEvent(
2790
+ for (const o of e?.querySelectorAll("om-frame") ?? []) {
2791
+ if (o.getAttribute("atlas-fit") !== "feature") continue;
2792
+ const s = Bn(t);
2793
+ if (!s) continue;
2794
+ const a = Number(o.getAttribute("atlas-margin")), l = Kn(s, Number.isFinite(a) && a > 0 ? a : 0.15);
2795
+ o.fitBounds?.(l);
2796
+ }
2797
+ e?.setAtlasFields({ ...Ut(t), index: String(this.currentIndex + 1), count: String(this.count) }), e?.refreshFurniture();
2798
+ const n = this.pageName(this.currentIndex);
2799
+ this.dispatchEvent(
2731
2800
  new CustomEvent("om-atlas-page", {
2732
2801
  bubbles: !0,
2733
- detail: { index: this.currentIndex, count: this.count, name: this.pageName(this.currentIndex), feature: t }
2802
+ detail: { index: this.currentIndex, count: this.count, name: n, feature: t }
2734
2803
  })
2735
- );
2804
+ ), this.renderPager();
2805
+ const i = typeof window < "u" ? window.parent : null;
2806
+ i && i !== window && i.postMessage({ source: ti, type: "atlas-page", index: this.currentIndex, count: this.count, name: n }, "*");
2807
+ }
2808
+ /**
2809
+ * Draw (or update) the reader's page control on the owning sheet:
2810
+ * `‹ 3 / 49 · Alabama ›`. Find-or-create, like the page's own overlays, so
2811
+ * paging updates one element rather than stacking them. `pager="none"`
2812
+ * removes it for a host that draws its own.
2813
+ */
2814
+ renderPager() {
2815
+ const t = this.closest("om-cartograph");
2816
+ if (!t) return;
2817
+ const e = t.querySelector(`:scope > [${Ne}]`), n = this.count;
2818
+ if (this.getAttribute("pager") === "none" || n === 0) {
2819
+ e?.remove(), this.pager = null;
2820
+ return;
2821
+ }
2822
+ const i = this.ownerDocument, o = e ?? i.createElement("div");
2823
+ if (!e) {
2824
+ o.setAttribute(Ne, ""), o.setAttribute(Qn, ""), o.setAttribute("role", "navigation"), o.setAttribute("aria-label", "Atlas pages"), o.style.cssText = "position:absolute;left:50%;bottom:4mm;transform:translateX(-50%);z-index:2147483000;display:flex;align-items:center;gap:8px;padding:4px 10px;border-radius:999px;background:rgba(20,20,24,.82);color:#fff;font:12px/1.2 system-ui,sans-serif;box-shadow:0 2px 10px rgba(0,0,0,.35);user-select:none;pointer-events:auto;";
2825
+ for (const [u, m, d] of [
2826
+ [-1, "‹", "Previous page"],
2827
+ [1, "›", "Next page"]
2828
+ ]) {
2829
+ const h = i.createElement("button");
2830
+ h.type = "button", h.setAttribute("data-om-carto-pager-step", String(u)), h.setAttribute("aria-label", d), h.textContent = m, h.style.cssText = "all:unset;cursor:pointer;padding:0 6px;font-size:16px;line-height:1;color:inherit;", h.addEventListener("click", () => this.seek(this.currentIndex + u)), o.appendChild(h);
2831
+ }
2832
+ const c = i.createElement("span");
2833
+ c.setAttribute("data-om-carto-pager-label", ""), o.insertBefore(c, o.lastElementChild), t.appendChild(o);
2834
+ }
2835
+ const s = o.querySelector("[data-om-carto-pager-label]");
2836
+ s.textContent = `${this.currentIndex + 1} / ${n} · ${this.pageName(this.currentIndex)}`;
2837
+ const [a, l] = o.querySelectorAll("button");
2838
+ a && (a.disabled = this.currentIndex === 0), l && (l.disabled = this.currentIndex >= n - 1);
2839
+ for (const c of [a, l]) c && (c.style.opacity = c.disabled ? ".35" : "1");
2840
+ this.pager = o;
2841
+ }
2842
+ connectedCallback() {
2843
+ super.connectedCallback(), this.ownerDocument.addEventListener("keydown", this.onKeyDown), typeof window < "u" && window.addEventListener("message", this.onHostMessage);
2844
+ }
2845
+ disconnectedCallback() {
2846
+ this.ownerDocument.removeEventListener("keydown", this.onKeyDown), typeof window < "u" && window.removeEventListener("message", this.onHostMessage);
2847
+ const t = this.pager;
2848
+ this.pager = null, t && queueMicrotask(() => {
2849
+ t.isConnected && !this.isConnected && t.remove();
2850
+ });
2736
2851
  }
2737
2852
  renderNow() {
2738
2853
  this.style.display = "none", this.refresh();
2739
2854
  }
2740
2855
  }
2741
- k("om-atlas", sr);
2742
- class Yn extends Oe {
2856
+ k("om-atlas", ar);
2857
+ class ri extends De {
2743
2858
  static observedAttributes = [...T["om-source"]];
2744
2859
  connectedCallback() {
2745
2860
  this.style.display = "none";
@@ -2753,38 +2868,38 @@ class Yn extends Oe {
2753
2868
  this.closest("om-frame")?.scheduleRender?.();
2754
2869
  }
2755
2870
  }
2756
- const Xn = /* @__PURE__ */ new Set(["class", "style", "id", "hidden", "title", "lang", "dir", "slot", "part", "role", "tabindex"]), Jn = /* @__PURE__ */ new Set(["style", "script", "img", "template", "om-map"]), Zn = ["data-om-carto-credit", "data-om-carto-marks", "data-om-carto-flattened"], Qn = /* @__PURE__ */ new Set(["om-text", "om-legend", "om-scalebar", "om-north", "om-shape", "om-image"]), ti = /* @__PURE__ */ new Set(["om-frame", "om-legend", "om-scalebar", "om-north", "om-graticule", "om-text", "om-shape", "om-image"]), ei = 0.02, ri = (r) => Math.max(0, Number(r.getAttribute("bleed")) || 0);
2757
- function or(r) {
2871
+ const ni = /* @__PURE__ */ new Set(["class", "style", "id", "hidden", "title", "lang", "dir", "slot", "part", "role", "tabindex"]), ii = /* @__PURE__ */ new Set(["style", "script", "img", "template", "om-map"]), si = ["data-om-carto-credit", "data-om-carto-marks", "data-om-carto-flattened"], oi = /* @__PURE__ */ new Set(["om-text", "om-legend", "om-scalebar", "om-north", "om-shape", "om-image"]), ai = /* @__PURE__ */ new Set(["om-frame", "om-legend", "om-scalebar", "om-north", "om-graticule", "om-text", "om-shape", "om-image"]), li = 0.02, ci = (r) => Math.max(0, Number(r.getAttribute("bleed")) || 0);
2872
+ function lr(r) {
2758
2873
  const t = r.tagName.toLowerCase();
2759
2874
  return r.id ? `${t}#${r.id}` : t;
2760
2875
  }
2761
- function V(r, t) {
2876
+ function H(r, t) {
2762
2877
  const e = r.getAttribute(t);
2763
2878
  if (e == null || e.trim() === "") return null;
2764
2879
  const n = Number(e);
2765
2880
  return Number.isFinite(n) ? n : null;
2766
2881
  }
2767
- function ni(r, t) {
2882
+ function ui(r, t) {
2768
2883
  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;
2769
2884
  }
2770
- function ii(r, t) {
2885
+ function hi(r, t) {
2771
2886
  const e = r.getAttribute("style");
2772
2887
  if (!e) return null;
2773
2888
  const n = new RegExp(`(?:^|;)\\s*${t}\\s*:\\s*(-?[\\d.]+)mm`, "i").exec(e);
2774
2889
  return n ? Number(n[1]) : null;
2775
2890
  }
2776
- function ar(r) {
2891
+ function cr(r) {
2777
2892
  const t = [], e = (s, a, l, c, u) => {
2778
- t.push({ severity: s, element: or(a), ...u ? { attribute: u } : {}, message: l, fix: c });
2893
+ t.push({ severity: s, element: lr(a), ...u ? { attribute: u } : {}, message: l, fix: c });
2779
2894
  }, n = [...r.querySelectorAll("om-cartograph")];
2780
2895
  if (n.length === 0 && r.tagName?.toLowerCase() === "om-cartograph" && n.push(r), n.length === 0)
2781
2896
  return { valid: !0, errors: [], warnings: [] };
2782
- for (const s of n) si(s, e);
2897
+ for (const s of n) mi(s, e);
2783
2898
  const i = t.filter((s) => s.severity === "error"), o = t.filter((s) => s.severity === "warning");
2784
2899
  return { valid: i.length === 0, errors: i, warnings: o };
2785
2900
  }
2786
- function si(r, t) {
2787
- const e = r.getAttribute("size"), n = V(r, "width") != null && V(r, "height") != null;
2901
+ function mi(r, t) {
2902
+ const e = r.getAttribute("size"), n = H(r, "width") != null && H(r, "height") != null;
2788
2903
  e && !te.includes(e) && !n && t(
2789
2904
  "error",
2790
2905
  r,
@@ -2793,54 +2908,54 @@ function si(r, t) {
2793
2908
  "size"
2794
2909
  );
2795
2910
  const i = r.getAttribute("cvd");
2796
- i && i.trim().toLowerCase() !== "none" && !Dt(i) && t("warning", r, `Unknown cvd="${i}" — no simulation applied.`, `Use one of ${fr.join(", ")}.`, "cvd"), r.hasAttribute("crop-marks") && ri(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");
2797
- const o = V(r, "safe-zone");
2911
+ i && i.trim().toLowerCase() !== "none" && !Dt(i) && t("warning", r, `Unknown cvd="${i}" — no simulation applied.`, `Use one of ${yr.join(", ")}.`, "cvd"), r.hasAttribute("crop-marks") && ci(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");
2912
+ const o = H(r, "safe-zone");
2798
2913
  if (o != null && o > 0) {
2799
- const m = ht(r.getAttribute("size"), r.getAttribute("width"), r.getAttribute("height"), r.getAttribute("orientation"));
2800
- o * 2 >= Math.min(m.widthMm, m.heightMm) && t("warning", r, `safe-zone=${o}mm leaves no usable area on a ${m.widthMm} × ${m.heightMm} mm page.`, "Use a smaller inset — 5–10mm is typical.", "safe-zone");
2914
+ const h = ht(r.getAttribute("size"), r.getAttribute("width"), r.getAttribute("height"), r.getAttribute("orientation"));
2915
+ o * 2 >= Math.min(h.widthMm, h.heightMm) && t("warning", r, `safe-zone=${o}mm leaves no usable area on a ${h.widthMm} × ${h.heightMm} mm page.`, "Use a smaller inset — 5–10mm is typical.", "safe-zone");
2801
2916
  }
2802
2917
  const s = r.getAttribute("format");
2803
- s == null ? t("warning", r, "No format= on the cartograph root.", `Add format="${gt}" so future runtimes can migrate this document.`, "format") : s !== gt && t("warning", r, `Unrecognised document format "${s}".`, `This build understands "${gt}".`, "format");
2804
- const { widthMm: a, heightMm: l } = ht(e, r.getAttribute("width"), r.getAttribute("height"), r.getAttribute("orientation")), c = Math.max(0, V(r, "bleed") ?? 0), u = /* @__PURE__ */ new Set(), h = [...r.querySelectorAll("om-frame")];
2805
- for (const m of h)
2806
- m.id ? u.add(m.id) : t("error", m, "Frame has no id.", "Give every frame an id so furniture can reference it with for=.", "id");
2807
- for (const m of r.children) {
2808
- if (Zn.some((g) => m.hasAttribute(g))) continue;
2809
- const f = m.tagName.toLowerCase();
2810
- !pt.includes(f) && !Jn.has(f) && t("error", m, `<${f}> is not a cartograph element.`, `Use one of ${pt.join(", ")}, or move this content inside an <om-text>.`);
2918
+ s == null ? t("warning", r, "No format= on the cartograph root.", `Add format="${pt}" so future runtimes can migrate this document.`, "format") : s !== pt && t("warning", r, `Unrecognised document format "${s}".`, `This build understands "${pt}".`, "format");
2919
+ const { widthMm: a, heightMm: l } = ht(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")];
2920
+ for (const h of m)
2921
+ 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");
2922
+ for (const h of r.children) {
2923
+ if (si.some((g) => h.hasAttribute(g))) continue;
2924
+ const f = h.tagName.toLowerCase();
2925
+ !gt.includes(f) && !ii.has(f) && t("error", h, `<${f}> is not a cartograph element.`, `Use one of ${gt.join(", ")}, or move this content inside an <om-text>.`);
2811
2926
  }
2812
2927
  const d = [];
2813
- for (const m of [r, ...r.querySelectorAll("*")]) {
2814
- const f = m.tagName.toLowerCase();
2815
- if (pt.includes(f) && !m.closest("om-map")) {
2816
- if (oi(m, f, t), ti.has(f)) {
2817
- const g = C(m);
2818
- ai(m, g, a, l, c, t), Qn.has(f) && !m.hasAttribute("hidden") && d.push({ el: m, box: g });
2928
+ for (const h of [r, ...r.querySelectorAll("*")]) {
2929
+ const f = h.tagName.toLowerCase();
2930
+ if (gt.includes(f) && !h.closest("om-map")) {
2931
+ if (di(h, f, t), ai.has(f)) {
2932
+ const g = S(h);
2933
+ fi(h, g, a, l, c, t), oi.has(f) && !h.hasAttribute("hidden") && d.push({ el: h, box: g });
2819
2934
  }
2820
- f === "om-frame" && li(m, t), f === "om-source" && ci(m, t), f === "om-legend" && ui(m, h, t), f === "om-atlas" && hi(m, h, t), f === "om-scalebar" && mi(m, h, t), f === "om-text" && di(m, h, t);
2935
+ f === "om-frame" && pi(h, t), f === "om-source" && gi(h, t), f === "om-legend" && bi(h, m, t), f === "om-atlas" && yi(h, m, t), f === "om-scalebar" && wi(h, m, t), f === "om-text" && vi(h, m, t);
2821
2936
  for (const g of ["for", "overview-of"]) {
2822
- const p = m.getAttribute(g);
2823
- p && !u.has(p) && t("error", m, `${g}="${p}" references no frame on this page.`, `Point it at one of: ${[...u].join(", ") || "(no frames)"}.`, g);
2937
+ const p = h.getAttribute(g);
2938
+ p && !u.has(p) && t("error", h, `${g}="${p}" references no frame on this page.`, `Point it at one of: ${[...u].join(", ") || "(no frames)"}.`, g);
2824
2939
  }
2825
2940
  }
2826
2941
  }
2827
- for (let m = 0; m < d.length; m++)
2828
- for (let f = m + 1; f < d.length; f++) {
2829
- const g = d[m], p = d[f];
2830
- g.box.w <= 0 || g.box.h <= 0 || p.box.w <= 0 || p.box.h <= 0 || ni(g.box, p.box) && t(
2942
+ for (let h = 0; h < d.length; h++)
2943
+ for (let f = h + 1; f < d.length; f++) {
2944
+ const g = d[h], p = d[f];
2945
+ g.box.w <= 0 || g.box.h <= 0 || p.box.w <= 0 || p.box.h <= 0 || ui(g.box, p.box) && t(
2831
2946
  "warning",
2832
2947
  g.el,
2833
- `Overlaps ${or(p.el)} on the page.`,
2948
+ `Overlaps ${lr(p.el)} on the page.`,
2834
2949
  "Move one of them — furniture overlapping furniture usually means a stale layout (frames may sit under anything)."
2835
2950
  );
2836
2951
  }
2837
2952
  }
2838
- function oi(r, t, e) {
2953
+ function di(r, t, e) {
2839
2954
  const n = new Set(T[t] ?? []);
2840
2955
  for (const i of r.attributes) {
2841
2956
  const o = i.name.toLowerCase();
2842
- if (n.has(o) || Xn.has(o) || o.startsWith("data-") || o.startsWith("aria-")) continue;
2843
- const s = xr.get(o);
2957
+ if (n.has(o) || ni.has(o) || o.startsWith("data-") || o.startsWith("aria-")) continue;
2958
+ const s = Tr.get(o);
2844
2959
  if (s) {
2845
2960
  e("warning", r, `Attribute "${o}" has no effect: ${s}`, "Remove it, or use the documented alternative.", o);
2846
2961
  continue;
@@ -2848,7 +2963,7 @@ function oi(r, t, e) {
2848
2963
  e("warning", r, `Unknown attribute "${o}" on <${t}> — likely a typo.`, `Valid attributes: ${[...n].join(", ")}.`, o);
2849
2964
  }
2850
2965
  }
2851
- function ai(r, t, e, n, i, o) {
2966
+ function fi(r, t, e, n, i, o) {
2852
2967
  if (t.w <= 0 || t.h <= 0) {
2853
2968
  o("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");
2854
2969
  return;
@@ -2866,20 +2981,20 @@ function ai(r, t, e, n, i, o) {
2866
2981
  ["width", t.w],
2867
2982
  ["height", t.h]
2868
2983
  ];
2869
- for (const [u, h] of c) {
2870
- const d = ii(r, u);
2871
- d != null && Math.abs(d - h) > 0.01 && o(
2984
+ for (const [u, m] of c) {
2985
+ const d = hi(r, u);
2986
+ d != null && Math.abs(d - m) > 0.01 && o(
2872
2987
  "error",
2873
2988
  r,
2874
- `Inline style ${u}:${d}mm disagrees with the placement attribute (${h}mm).`,
2989
+ `Inline style ${u}:${d}mm disagrees with the placement attribute (${m}mm).`,
2875
2990
  "The attributes are authoritative — make the inline style match, or drop it and let the runtime write it.",
2876
2991
  "style"
2877
2992
  );
2878
2993
  }
2879
2994
  }
2880
- function li(r, t) {
2995
+ function pi(r, t) {
2881
2996
  if ((r.getAttribute("mode") === "static" ? "static" : "live") === "static") {
2882
- const n = r.getAttribute("corners"), i = H(n);
2997
+ const n = r.getAttribute("corners"), i = X(n);
2883
2998
  i || t(
2884
2999
  "error",
2885
3000
  r,
@@ -2892,14 +3007,14 @@ function li(r, t) {
2892
3007
  "Static frame has no <img> or inline <svg> child to place.",
2893
3008
  'Add the georeferenced picture as a child — an <img> raster, or the inline <svg> that snapshot({format: "svg"}) produces.'
2894
3009
  );
2895
- const o = C(r), s = K(r.getAttribute("crs"));
3010
+ const o = S(r), s = Y(r.getAttribute("crs"));
2896
3011
  if (i && s && o.w > 0 && o.h > 0) {
2897
- const a = Q({ corners: i, widthMm: o.w, heightMm: o.h, crsForward: s });
3012
+ const a = tt({ corners: i, widthMm: o.w, heightMm: o.h, crsForward: s });
2898
3013
  if (a.degenerate)
2899
3014
  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");
2900
3015
  else {
2901
- const l = un(a);
2902
- l != null && l > ei && t(
3016
+ const l = fn(a);
3017
+ l != null && l > li && t(
2903
3018
  "warning",
2904
3019
  r,
2905
3020
  `Ground scale varies ${(l * 100).toFixed(1)}% across this frame, so a single scale bar is only true near its anchor.`,
@@ -2921,17 +3036,40 @@ function li(r, t) {
2921
3036
  "Give it src=, add an <om-source src=> child, or add an inline <om-map> child.",
2922
3037
  "src"
2923
3038
  );
2924
- for (const n of ["crs", "corners"])
2925
- r.hasAttribute(n) && t(
3039
+ const n = r.getAttribute("atlas-margin");
3040
+ if (n != null) {
3041
+ const i = Number(n);
3042
+ !Number.isFinite(i) || i < 0 ? t(
3043
+ "warning",
3044
+ r,
3045
+ `atlas-margin="${n}" is not a number, so the default (0.15) is used.`,
3046
+ `Give a fraction of the feature's extent, e.g. atlas-margin="0.15".`,
3047
+ "atlas-margin"
3048
+ ) : i > 2 && t(
3049
+ "warning",
3050
+ r,
3051
+ `atlas-margin="${n}" pads each side by ${i}× the feature's extent — it is a FRACTION (default 0.15), not millimetres.`,
3052
+ 'Use 0.1–0.3. "A 10 mm margin" is atlas-margin="0.1", not "10".',
3053
+ "atlas-margin"
3054
+ ), r.getAttribute("atlas-fit") !== "feature" && t(
3055
+ "warning",
3056
+ r,
3057
+ 'atlas-margin= has no effect without atlas-fit="feature" — the frame is not refit per page.',
3058
+ 'Add atlas-fit="feature" to this frame, or remove atlas-margin.',
3059
+ "atlas-margin"
3060
+ );
3061
+ }
3062
+ for (const i of ["crs", "corners"])
3063
+ r.hasAttribute(i) && t(
2926
3064
  "warning",
2927
3065
  r,
2928
- `${n}= is ignored on a live frame — a live frame takes its projection from the <om-map> it mounts and its corners from that map's camera.`,
2929
- n === "crs" ? `Put crs= on the frame's <om-map> instead, on an <om-source> if it describes a capture, or set mode="static" for a georeferenced picture placed by corners.` : 'Remove it, put it on the <om-source> whose capture it describes, or set mode="static" if this frame is a georeferenced picture.',
2930
- n
3066
+ `${i}= is ignored on a live frame — a live frame takes its projection from the <om-map> it mounts and its corners from that map's camera.`,
3067
+ i === "crs" ? `Put crs= on the frame's <om-map> instead, on an <om-source> if it describes a capture, or set mode="static" for a georeferenced picture placed by corners.` : 'Remove it, put it on the <om-source> whose capture it describes, or set mode="static" if this frame is a georeferenced picture.',
3068
+ i
2931
3069
  );
2932
3070
  }
2933
3071
  }
2934
- function ci(r, t) {
3072
+ function gi(r, t) {
2935
3073
  const e = r.parentElement;
2936
3074
  if (e?.tagName.toLowerCase() !== "om-frame") {
2937
3075
  t(
@@ -2960,7 +3098,7 @@ function ci(r, t) {
2960
3098
  }
2961
3099
  if (i === "raster") {
2962
3100
  const o = r.getAttribute("corners");
2963
- H(o) || t(
3101
+ X(o) || t(
2964
3102
  "error",
2965
3103
  r,
2966
3104
  o == null ? "A capture <om-source> has no corners=, so nothing on the sheet could be placed against it." : `A capture <om-source> has malformed corners= ("${o}").`,
@@ -2987,7 +3125,7 @@ function Wt(r, t) {
2987
3125
  const e = r.getAttribute("for");
2988
3126
  return e ? t.find((n) => n.id === e) : t.length === 1 ? t[0] : void 0;
2989
3127
  }
2990
- function ui(r, t, e) {
3128
+ function bi(r, t, e) {
2991
3129
  const n = r.getAttribute("derived") !== "false", i = Wt(r, t);
2992
3130
  n && i?.getAttribute("mode") === "static" && e(
2993
3131
  "warning",
@@ -2996,9 +3134,9 @@ function ui(r, t, e) {
2996
3134
  'Write the rows as <om-legend-row color= label= shape=> children and set derived="false".',
2997
3135
  "derived"
2998
3136
  );
2999
- const o = rr(r);
3137
+ const o = ir(r);
3000
3138
  if (o.length < 2) return;
3001
- const s = br(o.map((a) => ({ label: a.label, color: a.color, layer: a.layerId })));
3139
+ const s = Ar(o.map((a) => ({ label: a.label, color: a.color, layer: a.layerId })));
3002
3140
  if (s.collapses.length > 0 && s.worstType) {
3003
3141
  const a = s.collapses.filter((c) => c.type === s.worstType), l = a.slice(0, 3).map((c) => `"${c.a.label}"/"${c.b.label}"`).join(", ");
3004
3142
  e(
@@ -3009,15 +3147,17 @@ function ui(r, t, e) {
3009
3147
  );
3010
3148
  }
3011
3149
  }
3012
- function hi(r, t, e) {
3013
- const n = r.getAttribute("layer");
3014
- n || e("error", r, "Atlas has no layer= to iterate.", 'Name a layer inside the frame, e.g. layer="parcels".', "layer");
3015
- const i = r.getAttribute("for"), o = Wt(r, t);
3016
- if (!o) {
3017
- !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");
3150
+ function yi(r, t, e) {
3151
+ const n = r.getAttribute("pager");
3152
+ n != null && n !== "auto" && n !== "none" && e("warning", r, `pager="${n}" is not a value; the control is drawn as if "auto".`, 'Use pager="none" to remove the on-screen page control, or omit the attribute.', "pager");
3153
+ const i = r.getAttribute("layer");
3154
+ i || e("error", r, "Atlas has no layer= to iterate.", 'Name a layer inside the frame, e.g. layer="parcels".', "layer");
3155
+ const o = r.getAttribute("for"), s = Wt(r, t);
3156
+ if (!s) {
3157
+ !o && 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");
3018
3158
  return;
3019
3159
  }
3020
- if (o.getAttribute("mode") === "static") {
3160
+ if (s.getAttribute("mode") === "static") {
3021
3161
  e(
3022
3162
  "error",
3023
3163
  r,
@@ -3027,34 +3167,34 @@ function hi(r, t, e) {
3027
3167
  );
3028
3168
  return;
3029
3169
  }
3030
- const s = o.querySelector(":scope > om-map");
3031
- if (s && n) {
3032
- const a = [...s.querySelectorAll("om-layer")].find((c) => c.id === n);
3033
- if (!a) {
3034
- e("error", r, `Atlas layer "${n}" is not in frame #${o.id}'s map.`, "Check the layer id, or point the atlas at the frame that has it.", "layer");
3170
+ const a = s.querySelector(":scope > om-map");
3171
+ if (a && i) {
3172
+ const l = [...a.querySelectorAll("om-layer")].find((u) => u.id === i);
3173
+ if (!l) {
3174
+ e("error", r, `Atlas layer "${i}" is not in frame #${s.id}'s map.`, "Check the layer id, or point the atlas at the frame that has it.", "layer");
3035
3175
  return;
3036
3176
  }
3037
- const l = a.getAttribute("data") ?? "";
3038
- /\{z\}|\{x\}|\{y\}/.test(l) && e(
3177
+ const c = l.getAttribute("data") ?? "";
3178
+ /\{z\}|\{x\}|\{y\}/.test(c) && e(
3039
3179
  "error",
3040
3180
  r,
3041
- `Atlas layer "${n}" is tiled, so its features live on a server rather than in this document.`,
3181
+ `Atlas layer "${i}" is tiled, so its features live on a server rather than in this document.`,
3042
3182
  "Iterate a layer whose data is loaded locally (GeoJSON, CSV, inline JSON).",
3043
3183
  "layer"
3044
3184
  );
3045
3185
  }
3046
3186
  }
3047
- function mi(r, t, e) {
3048
- const n = V(r, "segment-length");
3187
+ function wi(r, t, e) {
3188
+ const n = H(r, "segment-length");
3049
3189
  if (n == null) return;
3050
3190
  const i = Wt(r, t);
3051
3191
  if (!i) return;
3052
- const o = H(i.getAttribute("corners")), s = K(i.getAttribute("crs")), a = C(i);
3192
+ const o = X(i.getAttribute("corners")), s = Y(i.getAttribute("crs")), a = S(i);
3053
3193
  if (!o || !s || a.w <= 0 || a.h <= 0) return;
3054
- const l = Q({ corners: o, widthMm: a.w, heightMm: a.h, crsForward: s }), c = C(r), u = De({
3194
+ const l = tt({ corners: o, widthMm: a.w, heightMm: a.h, crsForward: s }), c = S(r), u = je({
3055
3195
  groundMetersPerMm: l.groundMetersPerMm(),
3056
3196
  maxWidthMm: c.w,
3057
- segments: V(r, "segments") ?? void 0,
3197
+ segments: H(r, "segments") ?? void 0,
3058
3198
  segmentLengthMeters: n
3059
3199
  });
3060
3200
  u && u.totalMm > c.w + 1e-6 && e(
@@ -3065,9 +3205,9 @@ function mi(r, t, e) {
3065
3205
  "segment-length"
3066
3206
  );
3067
3207
  }
3068
- function di(r, t, e) {
3208
+ function vi(r, t, e) {
3069
3209
  const n = r.textContent ?? "", i = /* @__PURE__ */ new Set(["title", "attribution", "date", "notes", "scale", "crs"]), o = new Set(t.map((s) => s.id).filter(Boolean));
3070
- for (const s of Or(n))
3210
+ for (const s of jr(n))
3071
3211
  if (!s.startsWith("atlas.")) {
3072
3212
  if (s.startsWith("frame.")) {
3073
3213
  const a = s.slice(6), l = a.lastIndexOf("."), c = l > 0 ? a.slice(0, l) : "", u = l > 0 ? a.slice(l + 1) : "";
@@ -3086,13 +3226,13 @@ function di(r, t, e) {
3086
3226
  i.has(s) || e("warning", r, `Unknown token {{${s}}} — it will render literally.`, `Known tokens: ${[...i].join(", ")}, frame.<id>.scale, frame.<id>.crs, atlas.<field>.`);
3087
3227
  }
3088
3228
  }
3089
- function Ai(r) {
3090
- return ar($r(r));
3229
+ function Ni(r) {
3230
+ return cr(Pr(r));
3091
3231
  }
3092
- async function Si(r) {
3093
- const t = ar(r), e = [...r.querySelectorAll("om-frame")].filter((a) => a.querySelector(":scope > om-map"));
3232
+ async function Pi(r) {
3233
+ const t = cr(r), e = [...r.querySelectorAll("om-frame")].filter((a) => a.querySelector(":scope > om-map"));
3094
3234
  if (e.length === 0) return t;
3095
- const { loadCore: n } = await Promise.resolve().then(() => ur), i = await n(), o = [...t.errors], s = [...t.warnings];
3235
+ const { loadCore: n } = await Promise.resolve().then(() => fr), i = await n(), o = [...t.errors], s = [...t.warnings];
3096
3236
  for (const a of e) {
3097
3237
  const l = a.id ? `om-frame#${a.id}` : "om-frame", c = i.validateManifest(a);
3098
3238
  for (const u of c.errors) o.push({ ...u, element: `${l} > ${u.element}` });
@@ -3100,113 +3240,113 @@ async function Si(r) {
3100
3240
  }
3101
3241
  return { valid: o.length === 0, errors: o, warnings: s };
3102
3242
  }
3103
- function Ci() {
3104
- k("om-cartograph", Ve), k("om-text", Ke), k("om-frame", Je), k("om-scalebar", Ze), k("om-north", Qe), k("om-shape", tr), k("om-image", er), k("om-legend", nr), k("om-graticule", ir), k("om-atlas", sr), k("om-source", Yn);
3243
+ function Ti() {
3244
+ k("om-cartograph", He), k("om-text", Ye), k("om-frame", Qe), k("om-scalebar", tr), k("om-north", er), k("om-shape", rr), k("om-image", nr), k("om-legend", sr), k("om-graticule", or), k("om-atlas", ar), k("om-source", ri);
3105
3245
  }
3106
- Ne(() => import("@nika-js/onlymap"));
3107
- kr();
3246
+ Pe(() => import("@nika-js/onlymap"));
3247
+ Nr();
3108
3248
  export {
3109
3249
  T as CARTOGRAPH_ELEMENT_ATTRS,
3110
- gt as CARTOGRAPH_FORMAT,
3111
- pt as CARTOGRAPH_TAG_NAMES,
3112
- fi as CARTOGRAPH_THEMES,
3113
- pr as COLLAPSE_THRESHOLD,
3114
- jt as CVD_MATRICES,
3250
+ pt as CARTOGRAPH_FORMAT,
3251
+ gt as CARTOGRAPH_TAG_NAMES,
3252
+ Ai as CARTOGRAPH_THEMES,
3253
+ vr as COLLAPSE_THRESHOLD,
3254
+ zt as CVD_MATRICES,
3115
3255
  mt as CVD_TYPES,
3116
- fr as CVD_VALUES,
3117
- _t as GEOGRAPHIC_PLANE,
3118
- xr as INERT_RESERVED_CARTOGRAPH_ATTRS,
3119
- Fe as MAX_CANVAS_AREA,
3120
- Re as MAX_CANVAS_DIMENSION,
3256
+ yr as CVD_VALUES,
3257
+ Ot as GEOGRAPHIC_PLANE,
3258
+ Tr as INERT_RESERVED_CARTOGRAPH_ATTRS,
3259
+ Ie as MAX_CANVAS_AREA,
3260
+ Fe as MAX_CANVAS_DIMENSION,
3121
3261
  kt as MAX_CATEGORY_ENTRIES,
3122
- sr as OmAtlasElement,
3123
- Ve as OmCartographElement,
3124
- Je as OmFrameElement,
3125
- ir as OmGraticuleElement,
3126
- er as OmImageElement,
3127
- nr as OmLegendElement,
3128
- Qe as OmNorthElement,
3129
- Ze as OmScalebarElement,
3130
- tr as OmShapeElement,
3131
- Ke as OmTextElement,
3132
- Vt as PAGE_PRESETS,
3262
+ ar as OmAtlasElement,
3263
+ He as OmCartographElement,
3264
+ Qe as OmFrameElement,
3265
+ or as OmGraticuleElement,
3266
+ nr as OmImageElement,
3267
+ sr as OmLegendElement,
3268
+ er as OmNorthElement,
3269
+ tr as OmScalebarElement,
3270
+ rr as OmShapeElement,
3271
+ Ye as OmTextElement,
3272
+ Kt as PAGE_PRESETS,
3133
3273
  te as PAGE_SIZE_NAMES,
3134
- j as PLACED_ATTR_NAMES,
3274
+ z as PLACED_ATTR_NAMES,
3135
3275
  D as PX_PER_MM,
3136
- Fr as SCALE_GROUP_SEPARATOR,
3137
- Sr as URL_ACTION_TIMEOUT_MS,
3138
- Br as alignOffset,
3139
- We as allFrames,
3140
- yr as applyCvdToCanvas,
3141
- Ur as applyTokens,
3142
- Cr as applyUrlActions,
3276
+ Ur as SCALE_GROUP_SEPARATOR,
3277
+ $r as URL_ACTION_TIMEOUT_MS,
3278
+ Yr as alignOffset,
3279
+ Ke as allFrames,
3280
+ Mr as applyCvdToCanvas,
3281
+ Gr as applyTokens,
3282
+ Er as applyUrlActions,
3143
3283
  Ut as atlasFields,
3144
- Mi as boundsArea,
3145
- C as boxMm,
3146
- Rn as buildGraticule,
3147
- qn as buildPages,
3148
- De as buildScalebar,
3149
- Rr as buildScalebarDrawing,
3150
- K as builtinCrsForward,
3151
- gi as canvasMeasurer,
3152
- zr as clearUnlinked,
3153
- wi as cornersFromBounds,
3284
+ Ei as boundsArea,
3285
+ S as boxMm,
3286
+ _n as buildGraticule,
3287
+ Vn as buildPages,
3288
+ je as buildScalebar,
3289
+ _r as buildScalebarDrawing,
3290
+ Y as builtinCrsForward,
3291
+ Mi as canvasMeasurer,
3292
+ Br as clearUnlinked,
3293
+ xi as cornersFromBounds,
3154
3294
  Ft as cornersFromCamera,
3155
- Q as createFrameGeoref,
3156
- dr as createZip,
3157
- Ci as defineCartographElements,
3295
+ tt as createFrameGeoref,
3296
+ br as createZip,
3297
+ Ti as defineCartographElements,
3158
3298
  Xt as deltaE00,
3159
- Nn as deriveLegendRows,
3160
- wr as ensureCvdFilters,
3161
- zn as featureBounds,
3162
- F as fieldOf,
3163
- qe as findFrame,
3164
- _n as formatDms,
3165
- Ir as formatScaleDenominator,
3166
- kr as installUrlActions,
3167
- cr as isCoreLoaded,
3168
- Dr as isoDate,
3169
- Wr as layoutText,
3170
- br as lintLegendColours,
3171
- Pe as loadCore,
3172
- vi as maxGeoreferenceablePitch,
3173
- pi as mercatorForward,
3174
- bi as mercatorInverse,
3299
+ Rn as deriveLegendRows,
3300
+ Sr as ensureCvdFilters,
3301
+ Bn as featureBounds,
3302
+ I as fieldOf,
3303
+ Be as findFrame,
3304
+ zn as formatDms,
3305
+ Dr as formatScaleDenominator,
3306
+ Nr as installUrlActions,
3307
+ dr as isCoreLoaded,
3308
+ qr as isoDate,
3309
+ Hr as layoutText,
3310
+ Ar as lintLegendColours,
3311
+ Te as loadCore,
3312
+ $i as maxGeoreferenceablePitch,
3313
+ Si as mercatorForward,
3314
+ Ci as mercatorInverse,
3175
3315
  Ce as niceInterval,
3176
- Ue as niceNumberBelow,
3316
+ ze as niceNumberBelow,
3177
3317
  Lt as normalizeCrs,
3178
- cn as northBearingDegrees,
3179
- Ge as ownerCartograph,
3180
- Gn as padBounds,
3318
+ dn as northBearingDegrees,
3319
+ We as ownerCartograph,
3320
+ Kn as padBounds,
3181
3321
  Bt as paintEnvForDpi,
3182
- gr as parseColor,
3183
- H as parseCorners,
3184
- Bn as parseSort,
3185
- Y as peekCore,
3322
+ wr as parseColor,
3323
+ X as parseCorners,
3324
+ Yn as parseSort,
3325
+ J as peekCore,
3186
3326
  ut as readCamera,
3187
- rr as readLiteralRows,
3188
- Ln as readOverrides,
3189
- O as referencedFrame,
3190
- jn as rejectionFor,
3191
- zt as renderCartograph,
3192
- Ie as renderCartographAtlas,
3327
+ ir as readLiteralRows,
3328
+ On as readOverrides,
3329
+ U as referencedFrame,
3330
+ Wn as rejectionFor,
3331
+ jt as renderCartograph,
3332
+ _e as renderCartographAtlas,
3193
3333
  Rt as resolveCrsForward,
3194
3334
  Dt as resolveCvdType,
3195
- Hn as resolveFilenames,
3335
+ Zn as resolveFilenames,
3196
3336
  ht as resolvePageSize,
3197
- _r as resolveToken,
3198
- ze as resolveTokens,
3199
- En as rowColorFor,
3200
- mn as sanitizeAdoptedMap,
3201
- Kn as sanitizeFilename,
3202
- un as scaleVariation,
3203
- Ne as setCoreLoader,
3337
+ zr as resolveToken,
3338
+ qe as resolveTokens,
3339
+ Ln as rowColorFor,
3340
+ gn as sanitizeAdoptedMap,
3341
+ Jn as sanitizeFilename,
3342
+ fn as scaleVariation,
3343
+ Pe as setCoreLoader,
3204
3344
  Ht as simulate,
3205
- xn as swatchShapeFor,
3206
- Or as tokensIn,
3207
- yi as utmDef,
3208
- ar as validateCartograph,
3209
- Si as validateCartographDeep,
3210
- Ai as validateCartographString,
3345
+ Tn as swatchShapeFor,
3346
+ jr as tokensIn,
3347
+ ki as utmDef,
3348
+ cr as validateCartograph,
3349
+ Pi as validateCartographDeep,
3350
+ Ni as validateCartographString,
3211
3351
  Qt as whenPageReady
3212
3352
  };