@urban-toolkit/autk-grammar 5.1.0 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,601 +1,831 @@
1
- import { DEFAULT_WORKSPACE_NAME as j, isVectorTable as Nt, AutkDb as Tt, isRenderableTable as dt, DEFAULT_WORKSPACE_COORDINATE_FORMAT as $t } from "@urban-toolkit/autk-db";
2
- import { AutkMap as Ot, MapEvent as Q } from "@urban-toolkit/autk-map";
3
- import { AutkPlot as kt, PlotEvent as k } from "@urban-toolkit/autk-plot";
4
- import { ColorMapInterpolator as Ft, ColorMapDomainStrategy as P, ColorMap as B } from "@urban-toolkit/autk-core";
5
- import { AutkComputeEngine as Z } from "@urban-toolkit/autk-compute";
6
- function Bt(t) {
7
- const { spec: e, adapters: r } = t;
8
- let o;
1
+ import { DEFAULT_WORKSPACE_NAME as U, isVectorTable as Ht, AutkDb as Jt, isRenderableTable as Et, DEFAULT_WORKSPACE_COORDINATE_FORMAT as qt } from "@urban-toolkit/autk-db";
2
+ import { AutkMap as nt, MapEvent as J } from "@urban-toolkit/autk-map";
3
+ import { AutkPlot as Kt, PlotStyle as F, PlotEvent as B } from "@urban-toolkit/autk-plot";
4
+ import { ColorMapDomainStrategy as A, ColorMapInterpolator as _t, ColorMap as P, valueAtPath as zt } from "@urban-toolkit/autk-core";
5
+ import { AutkComputeEngine as at } from "@urban-toolkit/autk-compute";
6
+ function Xt(t) {
7
+ const { spec: e, adapters: o } = t;
8
+ let r;
9
9
  async function n() {
10
- let i;
11
- if (e.workspaces?.length && r.db.resolveWorkspaces && (i = await r.db.resolveWorkspaces(i, e.workspaces)), e.data)
12
- for (const l of e.data)
13
- i = await r.db.resolveSource(i, l);
10
+ let l;
11
+ if (e.workspaces?.length && o.db.resolveWorkspaces && (l = await o.db.resolveWorkspaces(l, e.workspaces)), e.data)
12
+ for (const s of e.data)
13
+ l = await o.db.resolveSource(l, s);
14
14
  if (e.compute)
15
- for (const l of e.compute)
16
- i = await r.compute.resolveCompute(i, l);
15
+ for (const s of e.compute)
16
+ l = await o.compute.resolveCompute(l, s);
17
17
  if (e.map)
18
18
  if (Array.isArray(e.map))
19
- for (let l = 0; l < e.map.length; l++) {
20
- let u = e.map[l];
21
- await r.map.resolveMap(i, u, l);
19
+ for (let s = 0; s < e.map.length; s++) {
20
+ let u = e.map[s];
21
+ await o.map.resolveMap(l, u, s);
22
22
  }
23
23
  else
24
- await r.map.resolveMap(i, e.map);
24
+ await o.map.resolveMap(l, e.map);
25
25
  if (e.plot)
26
26
  if (Array.isArray(e.plot))
27
- for (let l = 0; l < e.plot.length; l++)
28
- await r.plot.resolvePlot(i, e.plot[l], l);
27
+ for (let s = 0; s < e.plot.length; s++)
28
+ await o.plot.resolvePlot(l, e.plot[s], s);
29
29
  else
30
- await r.plot.resolvePlot(i, e.plot);
31
- o = i;
30
+ await o.plot.resolvePlot(l, e.plot);
31
+ r = l;
32
32
  }
33
- function s(i) {
34
- return console.log("Spec to update", i), new Promise((l) => {
35
- l();
33
+ function i(l) {
34
+ return console.log("Spec to update", l), new Promise((s) => {
35
+ s();
36
36
  });
37
37
  }
38
38
  function a() {
39
39
  console.log("Function not implemented yet");
40
40
  }
41
- return { run: n, updatedSpec: s, destroy: a, get context() {
42
- return o;
41
+ return { run: n, updatedSpec: i, destroy: a, get context() {
42
+ return r;
43
43
  } };
44
44
  }
45
- function tt(t) {
45
+ function it(t) {
46
46
  return t === void 0 ? [] : Array.isArray(t) ? t : [t];
47
47
  }
48
- function Te(t) {
49
- const e = t.layout ?? {}, r = e.type ?? "vertical";
50
- if (r !== "vertical" && r !== "horizontal" && r !== "grid")
51
- throw new Error(`Layout type must be vertical, horizontal or grid, not ${JSON.stringify(r)}.`);
52
- const o = e.gap ?? 0;
53
- if (typeof o != "number" || !Number.isFinite(o) || o < 0)
54
- throw new Error(`Layout gap must be a number of pixels, 0 or more, not ${JSON.stringify(o)}.`);
48
+ function go(t) {
49
+ const e = t.layout ?? {}, o = e.type ?? "vertical";
50
+ if (o !== "vertical" && o !== "horizontal" && o !== "grid")
51
+ throw new Error(`Layout type must be vertical, horizontal or grid, not ${JSON.stringify(o)}.`);
52
+ const r = e.gap ?? 0;
53
+ if (typeof r != "number" || !Number.isFinite(r) || r < 0)
54
+ throw new Error(`Layout gap must be a number of pixels, 0 or more, not ${JSON.stringify(r)}.`);
55
55
  const n = e.columns ?? 2;
56
56
  if (!Number.isInteger(n) || n < 1)
57
57
  throw new Error(`Layout columns must be a whole number, 1 or more, not ${JSON.stringify(n)}.`);
58
- const s = [
59
- ...tt(t.map).map((l, u) => ({ kind: "map", index: u, id: l.id, key: l.id ?? u })),
60
- ...tt(t.plot).map((l, u) => ({ kind: "plot", index: u, id: l.id, key: l.id ?? l.dataRef }))
61
- ], a = r === "vertical" ? 1 : r === "horizontal" ? Math.max(s.length, 1) : n, i = s.map(({ kind: l, index: u, id: d, key: c }, f) => ({
62
- kind: l,
58
+ const i = [
59
+ ...it(t.map).map((s, u) => ({ kind: "map", index: u, id: s.id, key: s.id ?? u })),
60
+ ...it(t.plot).map((s, u) => ({ kind: "plot", index: u, id: s.id, key: s.id ?? s.dataRef }))
61
+ ], a = o === "vertical" ? 1 : o === "horizontal" ? Math.max(i.length, 1) : n, l = i.map(({ kind: s, index: u, id: d, key: f }, c) => ({
62
+ kind: s,
63
63
  index: u,
64
64
  ...d !== void 0 && { id: d },
65
- key: c,
66
- row: Math.floor(f / a),
67
- column: f % a
65
+ key: f,
66
+ row: Math.floor(c / a),
67
+ column: c % a
68
68
  }));
69
- return { type: r, rows: Math.ceil(s.length / a), columns: a, gap: o, panes: i };
69
+ return { type: o, rows: Math.ceil(i.length / a), columns: a, gap: r, panes: l };
70
70
  }
71
- var xt = /* @__PURE__ */ ((t) => (t.CAT_ACCENT = "schemeAccent", t.CAT_DARK2 = "schemeDark2", t.CAT_CATEGORY10 = "schemeCategory10", t.CAT_OBSERVABLE10 = "schemeObservable10", t.CAT_PAIRED = "schemePaired", t.CAT_PASTEL1 = "schemePastel1", t.CAT_PASTEL2 = "schemePastel2", t.CAT_SET1 = "schemeSet1", t.CAT_SET2 = "schemeSet2", t.CAT_SET3 = "schemeSet3", t.CAT_TABLEAU10 = "schemeTableau10", t.SEQ_REDS = "interpolateReds", t.SEQ_BLUES = "interpolateBlues", t.SEQ_GREENS = "interpolateGreens", t.SEQ_GREYS = "interpolateGreys", t.SEQ_ORANGES = "interpolateOranges", t.SEQ_PURPLES = "interpolatePurples", t.SEQ_TURBO = "interpolateTurbo", t.SEQ_VIRIDIS = "interpolateViridis", t.SEQ_INFERNO = "interpolateInferno", t.SEQ_MAGMA = "interpolateMagma", t.SEQ_PLASMA = "interpolatePlasma", t.SEQ_CIVIDIS = "interpolateCividis", t.SEQ_WARM = "interpolateWarm", t.SEQ_COOL = "interpolateCool", t.SEQ_CUBEHELIX_DEFAULT = "interpolateCubehelixDefault", t.SEQ_BU_GN = "interpolateBuGn", t.SEQ_BU_PU = "interpolateBuPu", t.SEQ_GN_BU = "interpolateGnBu", t.SEQ_OR_RD = "interpolateOrRd", t.SEQ_PU_BU_GN = "interpolatePuBuGn", t.SEQ_PU_BU = "interpolatePuBu", t.SEQ_PU_RD = "interpolatePuRd", t.SEQ_RD_PU = "interpolateRdPu", t.SEQ_YL_GN_BU = "interpolateYlGnBu", t.SEQ_YL_GN = "interpolateYlGn", t.SEQ_YL_OR_BR = "interpolateYlOrBr", t.SEQ_YL_OR_RD = "interpolateYlOrRd", t.DIV_BR_BG = "interpolateBrBG", t.DIV_PR_GN = "interpolatePRGn", t.DIV_PI_YG = "interpolatePiYG", t.DIV_PU_OR = "interpolatePuOr", t.DIV_RED_BLUE = "interpolateRdBu", t.DIV_RED_GREY = "interpolateRdGy", t.DIV_RED_YELLOW_BLUE = "interpolateRdYlBu", t.DIV_RED_YELLOW_GREEN = "interpolateRdYlGn", t.DIV_SPECTRAL = "interpolateSpectral", t))(xt || {}), pt = /* @__PURE__ */ ((t) => (t.MIN_MAX = "minMax", t.PERCENTILE = "percentile", t))(pt || {});
71
+ var Zt = /* @__PURE__ */ ((t) => (t.CAT_ACCENT = "schemeAccent", t.CAT_DARK2 = "schemeDark2", t.CAT_CATEGORY10 = "schemeCategory10", t.CAT_OBSERVABLE10 = "schemeObservable10", t.CAT_PAIRED = "schemePaired", t.CAT_PASTEL1 = "schemePastel1", t.CAT_PASTEL2 = "schemePastel2", t.CAT_SET1 = "schemeSet1", t.CAT_SET2 = "schemeSet2", t.CAT_SET3 = "schemeSet3", t.CAT_TABLEAU10 = "schemeTableau10", t.SEQ_REDS = "interpolateReds", t.SEQ_BLUES = "interpolateBlues", t.SEQ_GREENS = "interpolateGreens", t.SEQ_GREYS = "interpolateGreys", t.SEQ_ORANGES = "interpolateOranges", t.SEQ_PURPLES = "interpolatePurples", t.SEQ_TURBO = "interpolateTurbo", t.SEQ_VIRIDIS = "interpolateViridis", t.SEQ_INFERNO = "interpolateInferno", t.SEQ_MAGMA = "interpolateMagma", t.SEQ_PLASMA = "interpolatePlasma", t.SEQ_CIVIDIS = "interpolateCividis", t.SEQ_WARM = "interpolateWarm", t.SEQ_COOL = "interpolateCool", t.SEQ_CUBEHELIX_DEFAULT = "interpolateCubehelixDefault", t.SEQ_BU_GN = "interpolateBuGn", t.SEQ_BU_PU = "interpolateBuPu", t.SEQ_GN_BU = "interpolateGnBu", t.SEQ_OR_RD = "interpolateOrRd", t.SEQ_PU_BU_GN = "interpolatePuBuGn", t.SEQ_PU_BU = "interpolatePuBu", t.SEQ_PU_RD = "interpolatePuRd", t.SEQ_RD_PU = "interpolateRdPu", t.SEQ_YL_GN_BU = "interpolateYlGnBu", t.SEQ_YL_GN = "interpolateYlGn", t.SEQ_YL_OR_BR = "interpolateYlOrBr", t.SEQ_YL_OR_RD = "interpolateYlOrRd", t.DIV_BR_BG = "interpolateBrBG", t.DIV_PR_GN = "interpolatePRGn", t.DIV_PI_YG = "interpolatePiYG", t.DIV_PU_OR = "interpolatePuOr", t.DIV_RED_BLUE = "interpolateRdBu", t.DIV_RED_GREY = "interpolateRdGy", t.DIV_RED_YELLOW_BLUE = "interpolateRdYlBu", t.DIV_RED_YELLOW_GREEN = "interpolateRdYlGn", t.DIV_SPECTRAL = "interpolateSpectral", t))(Zt || {}), Ct = /* @__PURE__ */ ((t) => (t.MIN_MAX = "minMax", t.PERCENTILE = "percentile", t))(Ct || {});
72
72
  async function I(t, e) {
73
- const r = e ?? j;
74
- t.getCurrentWorkspace() !== r && await t.setWorkspace(r);
73
+ const o = e ?? U;
74
+ t.getCurrentWorkspace() !== o && await t.setWorkspace(o);
75
+ }
76
+ function E(t, e) {
77
+ return t === void 0 || t === U ? e : `${t}/${e}`;
78
+ }
79
+ const te = /* @__PURE__ */ Symbol.for("@urban-toolkit/autk-grammar:source-crs"), ee = globalThis, $t = ee[te] ??= /* @__PURE__ */ new WeakMap();
80
+ function oe(t, e) {
81
+ $t.set(t, e);
75
82
  }
76
- function b(t, e) {
77
- return t === void 0 || t === j ? e : `${t}/${e}`;
83
+ function re(t, e) {
84
+ const o = t && $t.get(t);
85
+ return o !== void 0 && o.toUpperCase() === e.toUpperCase() ? t : void 0;
78
86
  }
79
- function mt(t) {
87
+ function Mt(t) {
80
88
  const e = /* @__PURE__ */ new Set();
81
- for (const o of t)
82
- o?.id != null && e.add(JSON.stringify(o.id));
83
- const r = /* @__PURE__ */ new Set();
84
- return t.map((o, n) => {
85
- if (o?.id != null) return o.id;
86
- let s = `autk-feature-${n}`;
87
- for (; e.has(JSON.stringify(s)) || r.has(JSON.stringify(s)); ) s = `${s}-generated`;
88
- return r.add(JSON.stringify(s)), s;
89
+ for (const r of t)
90
+ r?.id != null && e.add(JSON.stringify(r.id));
91
+ const o = /* @__PURE__ */ new Set();
92
+ return t.map((r, n) => {
93
+ if (r?.id != null) return r.id;
94
+ let i = `autk-feature-${n}`;
95
+ for (; e.has(JSON.stringify(i)) || o.has(JSON.stringify(i)); ) i = `${i}-generated`;
96
+ return o.add(JSON.stringify(i)), i;
89
97
  });
90
98
  }
91
- function ht(t) {
99
+ function kt(t) {
92
100
  const e = /* @__PURE__ */ new Map();
93
- return mt(t).map((r) => {
94
- const o = JSON.stringify(r), n = e.get(o) ?? 0;
95
- return e.set(o, n + 1), n === 0 ? o : `${o} ${n}`;
101
+ return Mt(t).map((o) => {
102
+ const r = JSON.stringify(o), n = e.get(r) ?? 0;
103
+ return e.set(r, n + 1), n === 0 ? r : `${r} ${n}`;
96
104
  });
97
105
  }
98
- const et = /* @__PURE__ */ new WeakMap();
99
- function jt(t) {
100
- let e = et.get(t);
101
- return e || (e = /* @__PURE__ */ new Map(), t.forEach((r, o) => {
102
- const n = e.get(r);
103
- n ? n.push(o) : e.set(r, [o]);
104
- }), et.set(t, e), e);
105
- }
106
- function x(t, e, r) {
107
- const o = jt(r), n = /* @__PURE__ */ new Set();
108
- for (const s of t) {
109
- const a = e[s];
106
+ const st = /* @__PURE__ */ new WeakMap();
107
+ function ne(t) {
108
+ let e = st.get(t);
109
+ return e || (e = /* @__PURE__ */ new Map(), t.forEach((o, r) => {
110
+ const n = e.get(o);
111
+ n ? n.push(r) : e.set(o, [r]);
112
+ }), st.set(t, e), e);
113
+ }
114
+ function D(t, e, o) {
115
+ const r = ne(o), n = /* @__PURE__ */ new Set();
116
+ for (const i of t) {
117
+ const a = e[i];
110
118
  if (a !== void 0)
111
- for (const i of o.get(a) ?? []) n.add(i);
119
+ for (const l of r.get(a) ?? []) n.add(l);
112
120
  }
113
121
  return [...n];
114
122
  }
115
- const Gt = { type: "GeometryCollection", geometries: [] };
116
- function Dt(t) {
117
- const e = t.features ?? [], r = mt(e);
118
- let o = !1;
119
- const n = e.map((a, i) => a == null || a.id != null && a.geometry != null ? a : (o = !0, { ...a, id: r[i], geometry: a.geometry ?? Gt })), s = e.findIndex((a) => a?.geometry != null);
120
- return s > 0 && e[0] != null && e[0].geometry == null && ([n[0], n[s]] = [n[s], n[0]], o = !0), o ? { ...t, features: n } : t;
123
+ const ae = { type: "GeometryCollection", geometries: [] };
124
+ function ie(t) {
125
+ const e = t.features ?? [], o = Mt(e);
126
+ let r = !1;
127
+ const n = e.map((a, l) => a == null || a.id != null && a.geometry != null ? a : (r = !0, { ...a, id: o[l], geometry: a.geometry ?? ae })), i = e.findIndex((a) => a?.geometry != null);
128
+ return i > 0 && e[0] != null && e[0].geometry == null && ([n[0], n[i]] = [n[i], n[0]], r = !0), r ? { ...t, features: n } : t;
121
129
  }
122
- function Ut(t) {
130
+ function se(t) {
123
131
  const { queryArea: e } = t;
124
132
  if (e.bbox === void 0) return { geocodeArea: e.geocodeArea, areas: e.areas };
125
- const r = (l) => new Error(`OSM source "${t.outputTableName}": ${l}`);
133
+ const o = (s) => new Error(`OSM source "${t.outputTableName}": ${s}`);
126
134
  if (e.geocodeArea !== void 0 || e.areas !== void 0)
127
- throw r("queryArea takes either bbox or geocodeArea with areas, not both.");
128
- const o = e.bbox;
129
- if (!Array.isArray(o) || o.length !== 4 || !o.every((l) => typeof l == "number" && Number.isFinite(l)))
130
- throw r("queryArea.bbox must hold four numbers, [west, south, east, north] in degrees.");
131
- const [n, s, a, i] = e.bbox;
135
+ throw o("queryArea takes either bbox or geocodeArea with areas, not both.");
136
+ const r = e.bbox;
137
+ if (!Array.isArray(r) || r.length !== 4 || !r.every((s) => typeof s == "number" && Number.isFinite(s)))
138
+ throw o("queryArea.bbox must hold four numbers, [west, south, east, north] in degrees.");
139
+ const [n, i, a, l] = e.bbox;
132
140
  if (Math.abs(n) > 180 || Math.abs(a) > 180)
133
- throw r("queryArea.bbox west and east must be longitudes from -180 to 180.");
134
- if (Math.abs(s) > 90 || Math.abs(i) > 90)
135
- throw r("queryArea.bbox south and north must be latitudes from -90 to 90.");
141
+ throw o("queryArea.bbox west and east must be longitudes from -180 to 180.");
142
+ if (Math.abs(i) > 90 || Math.abs(l) > 90)
143
+ throw o("queryArea.bbox south and north must be latitudes from -90 to 90.");
136
144
  if (n >= a)
137
- throw r(`queryArea.bbox west (${n}) must be less than east (${a}); a box across the antimeridian is not supported.`);
138
- if (s >= i)
139
- throw r(`queryArea.bbox south (${s}) must be less than north (${i}).`);
140
- return { bbox: [n, s, a, i] };
145
+ throw o(`queryArea.bbox west (${n}) must be less than east (${a}); a box across the antimeridian is not supported.`);
146
+ if (i >= l)
147
+ throw o(`queryArea.bbox south (${i}) must be less than north (${l}).`);
148
+ return { bbox: [n, i, a, l] };
141
149
  }
142
- function Qt(t) {
143
- const { autoLoadLayers: e, ...r } = t;
150
+ function le(t) {
151
+ const { autoLoadLayers: e, ...o } = t;
144
152
  if (t.pbfFileUrl !== void 0 && (t.tagSets?.length ?? 0) > 0)
145
153
  throw new Error(`OSM source "${t.outputTableName}": tagSets are read from the Overpass API only, so a source with pbfFileUrl cannot take them.`);
146
154
  return {
147
- ...r,
148
- queryArea: Ut(t),
155
+ ...o,
156
+ queryArea: se(t),
149
157
  autoLoadLayers: {
150
158
  layers: e?.layers ?? [],
151
159
  ...e?.coordinateFormat !== void 0 && { coordinateFormat: e.coordinateFormat }
152
160
  }
153
161
  };
154
162
  }
155
- function rt(t) {
163
+ function lt(t) {
156
164
  return `${t ? `coordinateFormat is set to "${t}"` : "no coordinateFormat was specified, so it defaults to EPSG:4326 (WGS84 per RFC 7946)"}. Verify that coordinateFormat matches the actual CRS of the input data.`;
157
165
  }
158
- function D(t) {
159
- return t === void 0 || t === j ? "the default workspace" : `the workspace "${t}"`;
166
+ function V(t) {
167
+ return t === void 0 || t === U ? "the default workspace" : `the workspace "${t}"`;
160
168
  }
161
- function ot(t) {
169
+ function ut(t) {
162
170
  if (t != null)
163
171
  return typeof t == "string" ? t : JSON.stringify(t);
164
172
  }
165
- async function Yt(t, e, r, o) {
173
+ async function ue(t, e, o, r) {
166
174
  const n = /* @__PURE__ */ new Map();
167
- for (const i of (await t.getLayer(e.name)).features) {
168
- const l = ot(i.properties?.[o]);
169
- if (l !== void 0) {
170
- if (i.id === void 0 || i.id === null)
175
+ for (const l of (await t.getLayer(e.name)).features) {
176
+ const s = ut(l.properties?.[r]);
177
+ if (s !== void 0) {
178
+ if (l.id === void 0 || l.id === null)
171
179
  throw new Error("its rows have no feature id to update them by.");
172
- n.set(l, [...n.get(l) ?? [], i.id]);
180
+ n.set(s, [...n.get(s) ?? [], l.id]);
173
181
  }
174
182
  }
175
- const s = r.features.flatMap((i) => {
176
- const l = ot(i.properties?.[o]);
177
- return l === void 0 ? [] : (n.get(l) ?? []).map((u) => ({ ...i, id: u }));
178
- }), a = e.columns.some((i) => i.name === "geojson_id") ? "geojson_id" : "id";
179
- return { data: { ...r, features: s }, idColumn: a };
183
+ const i = o.features.flatMap((l) => {
184
+ const s = ut(l.properties?.[r]);
185
+ return s === void 0 ? [] : (n.get(s) ?? []).map((u) => ({ ...l, id: u }));
186
+ }), a = e.columns.some((l) => l.name === "geojson_id") ? "geojson_id" : "id";
187
+ return { data: { ...o, features: i }, idColumn: a };
180
188
  }
181
- async function nt(t) {
189
+ async function ft(t) {
182
190
  if (t) return t;
183
- const e = new Tt();
191
+ const e = new Jt();
184
192
  return await e.init(), e;
185
193
  }
186
- function yt(t) {
187
- let e = 1 / 0, r = 1 / 0, o = -1 / 0, n = -1 / 0;
188
- const s = (i) => {
189
- if (Array.isArray(i)) {
190
- if (typeof i[0] == "number") {
191
- const [l, u] = i;
192
- l < e && (e = l), l > o && (o = l), u < r && (r = u), u > n && (n = u);
194
+ function Rt(t) {
195
+ let e = 1 / 0, o = 1 / 0, r = -1 / 0, n = -1 / 0;
196
+ const i = (l) => {
197
+ if (Array.isArray(l)) {
198
+ if (typeof l[0] == "number") {
199
+ const [s, u] = l;
200
+ s < e && (e = s), s > r && (r = s), u < o && (o = u), u > n && (n = u);
193
201
  return;
194
202
  }
195
- for (const l of i) s(l);
203
+ for (const s of l) i(s);
196
204
  }
197
- }, a = (i) => {
198
- i && (i.type === "GeometryCollection" ? i.geometries.forEach(a) : s(i.coordinates));
205
+ }, a = (l) => {
206
+ l && (l.type === "GeometryCollection" ? l.geometries.forEach(a) : i(l.coordinates));
199
207
  };
200
- for (const i of t.features ?? []) a(i?.geometry);
201
- return e <= o ? [e, r, o, n] : void 0;
208
+ for (const l of t.features ?? []) a(l?.geometry);
209
+ return e <= r ? [e, o, r, n] : void 0;
202
210
  }
203
- function Vt(t, e) {
204
- function r(n, s) {
205
- if (!s || !s.db)
211
+ function fe(t, e) {
212
+ function o(n, i) {
213
+ if (!i || !i.db)
206
214
  return;
207
- const a = document.getElementById(s.db);
215
+ const a = document.getElementById(i.db);
208
216
  if (a) {
209
- const i = n.getTablesMetadata();
217
+ const l = n.getTablesMetadata();
210
218
  a.innerHTML += "<ul>";
211
- for (const l of i)
212
- a.innerHTML += `<li>${l.name}: (${l.source}, ${l.type}) </li>`;
213
- a.innerHTML += "</ul>", a.innerHTML += `<p>Number of tables: ${i.length}</p>`;
219
+ for (const s of l)
220
+ a.innerHTML += `<li>${s.name}: (${s.source}, ${s.type}) </li>`;
221
+ a.innerHTML += "</ul>", a.innerHTML += `<p>Number of tables: ${l.length}</p>`;
214
222
  }
215
223
  }
216
- async function o(n, s, a) {
224
+ async function r(n, i, a) {
217
225
  if (!e) return;
218
- const i = b(s, a), l = n.getTablesMetadata().find((u) => u.name === a);
219
- l && dt(l) ? e.set(i, await n.getLayer(a)) : e.delete(i);
226
+ const l = E(i, a), s = n.getTablesMetadata().find((u) => u.name === a);
227
+ s && Et(s) ? e.set(l, await n.getLayer(a)) : e.delete(l);
220
228
  }
221
229
  return {
222
- async resolveWorkspaces(n, s) {
223
- const a = await nt(n), i = /* @__PURE__ */ new Set();
224
- for (const { name: l, coordinateFormat: u, precisionGrid: d } of s) {
225
- const c = l ?? j;
226
- if (i.has(c))
227
- throw new Error(`workspaces sets ${D(l)} twice; give each workspace one entry.`);
228
- i.add(c);
230
+ async resolveWorkspaces(n, i) {
231
+ const a = await ft(n), l = /* @__PURE__ */ new Set();
232
+ for (const { name: s, coordinateFormat: u, precisionGrid: d } of i) {
233
+ const f = s ?? U;
234
+ if (l.has(f))
235
+ throw new Error(`workspaces sets ${V(s)} twice; give each workspace one entry.`);
236
+ l.add(f);
229
237
  try {
230
- await a.setWorkspace(c, { coordinateFormat: u, precisionGrid: d });
231
- } catch (f) {
232
- throw new Error(`workspaces, ${D(l)}: ${f instanceof Error ? f.message : String(f)}`);
238
+ await a.setWorkspace(f, { coordinateFormat: u, precisionGrid: d });
239
+ } catch (c) {
240
+ throw new Error(`workspaces, ${V(s)}: ${c instanceof Error ? c.message : String(c)}`);
233
241
  }
234
242
  }
235
243
  return await I(a), a;
236
244
  },
237
- async resolveSource(n, s) {
238
- const a = await nt(n), { workspace: i } = s;
239
- await I(a, i);
240
- let { type: l, workspace: u, ...d } = s;
241
- switch (l) {
245
+ async resolveSource(n, i) {
246
+ const a = await ft(n), { workspace: l } = i;
247
+ await I(a, l);
248
+ let { type: s, workspace: u, ...d } = i;
249
+ switch (s) {
242
250
  case "osm":
243
- return await a.loadOsm(Qt(d)), r(a, t), a;
251
+ return await a.loadOsm(le(d)), o(a, t), a;
244
252
  case "csv":
245
- return await a.loadCsv(d), r(a, t), a;
253
+ return await a.loadCsv(d), o(a, t), a;
246
254
  case "json":
247
- return await a.loadJson(d), r(a, t), a;
255
+ return await a.loadJson(d), o(a, t), a;
248
256
  case "geojson": {
249
- const c = d;
250
- let f;
251
- c.geojsonFileUrl ? f = await (await fetch(c.geojsonFileUrl)).json() : f = c.geojsonObject, e && f && e.set(b(i, c.outputTableName), f);
252
- const y = f ? (() => {
253
- const p = { ...c, geojsonObject: Dt(f) };
257
+ const f = d;
258
+ let c;
259
+ f.geojsonFileUrl ? c = await (await fetch(f.geojsonFileUrl)).json() : c = f.geojsonObject, e && c && (e.set(E(l, f.outputTableName), c), oe(c, f.coordinateFormat ?? "EPSG:4326"));
260
+ const h = c ? (() => {
261
+ const p = { ...f, geojsonObject: ie(c) };
254
262
  return delete p.geojsonFileUrl, p;
255
- })() : c, m = /^EPSG:4326$/i.test(y.coordinateFormat ?? "EPSG:4326"), h = f && m ? yt(f) : void 0;
256
- if (h && (h[1] < -90 || h[3] > 90))
263
+ })() : f, m = /^EPSG:4326$/i.test(h.coordinateFormat ?? "EPSG:4326"), y = c && m ? Rt(c) : void 0;
264
+ if (y && (y[1] < -90 || y[3] > 90))
257
265
  throw new Error(
258
- `GeoJSON layer "${y.outputTableName}" has y coordinates outside -90 to 90 (bbox: [${h.join(", ")}]), so they cannot be EPSG:4326 degrees. ${rt(y.coordinateFormat)}`
266
+ `GeoJSON layer "${h.outputTableName}" has y coordinates outside -90 to 90 (bbox: [${y.join(", ")}]), so they cannot be EPSG:4326 degrees. ${lt(h.coordinateFormat)}`
259
267
  );
260
268
  try {
261
- await a.loadGeojson(y);
269
+ await a.loadGeojson(h);
262
270
  } catch (p) {
263
- throw new Error(`Failed to load GeoJSON layer "${y.outputTableName}": ${p instanceof Error ? p.message : String(p)}`);
271
+ throw new Error(`Failed to load GeoJSON layer "${h.outputTableName}": ${p instanceof Error ? p.message : String(p)}`);
264
272
  }
265
273
  try {
266
- const p = await a.getBoundingBoxFromLayer(y.outputTableName), w = 25e6;
267
- if (!isFinite(p.minLon) || !isFinite(p.minLat) || !isFinite(p.maxLon) || !isFinite(p.maxLat) || Math.abs(p.minLon) > w || Math.abs(p.maxLon) > w || Math.abs(p.minLat) > w || Math.abs(p.maxLat) > w)
274
+ const p = await a.getBoundingBoxFromLayer(h.outputTableName), g = 25e6;
275
+ if (!isFinite(p.minLon) || !isFinite(p.minLat) || !isFinite(p.maxLon) || !isFinite(p.maxLat) || Math.abs(p.minLon) > g || Math.abs(p.maxLon) > g || Math.abs(p.minLat) > g || Math.abs(p.maxLat) > g)
268
276
  throw new Error(
269
- `Geometry bounding box after transform is invalid for layer "${y.outputTableName}" (bbox: [${p.minLon}, ${p.minLat}, ${p.maxLon}, ${p.maxLat}]). ${rt(y.coordinateFormat)} The workspace uses ${a.getWorkspaceConfiguration().coordinateFormat}; input is expected in EPSG:4326 by default.`
277
+ `Geometry bounding box after transform is invalid for layer "${h.outputTableName}" (bbox: [${p.minLon}, ${p.minLat}, ${p.maxLon}, ${p.maxLat}]). ${lt(h.coordinateFormat)} The workspace uses ${a.getWorkspaceConfiguration().coordinateFormat}; input is expected in EPSG:4326 by default.`
270
278
  );
271
279
  } catch (p) {
272
280
  if (p instanceof Error && p.message.includes("bounding box after transform")) throw p;
273
281
  }
274
- return r(a, t), a;
282
+ return o(a, t), a;
275
283
  }
276
284
  case "geotiff":
277
- return await a.loadGeoTiff(d), r(a, t), a;
285
+ return await a.loadGeoTiff(d), o(a, t), a;
278
286
  case "heatmap": {
279
- const c = d;
280
- if (c.groupBy?.some((f) => f.aggregateFn === "collect"))
281
- throw new Error(`Heatmap "${c.outputTableName}": aggregateFn "collect" lists the rows near a cell, and a cell holds one value; use sum, avg, count, min, max or weighted.`);
287
+ const f = d;
288
+ if (f.groupBy?.some((c) => c.aggregateFn === "collect"))
289
+ throw new Error(`Heatmap "${f.outputTableName}": aggregateFn "collect" lists the rows near a cell, and a cell holds one value; use sum, avg, count, min, max or weighted.`);
282
290
  return await a.buildHeatmap({
283
- tableJoinName: c.joinDataRef,
284
- near: c.near,
285
- outputTableName: c.outputTableName,
286
- grid: c.grid,
287
- ...c.groupBy && { groupBy: c.groupBy }
288
- }), r(a, t), a;
291
+ tableJoinName: f.joinDataRef,
292
+ near: f.near,
293
+ outputTableName: f.outputTableName,
294
+ grid: f.grid,
295
+ ...f.groupBy && { groupBy: f.groupBy }
296
+ }), o(a, t), a;
289
297
  }
290
298
  case "join": {
291
- const c = d;
299
+ const f = d;
292
300
  if (await a.spatialQuery({
293
- tableRootName: c.dataRef,
294
- tableJoinName: c.joinDataRef,
295
- ...c.near && { near: c.near },
296
- ...c.groupBy && { groupBy: c.groupBy }
301
+ tableRootName: f.dataRef,
302
+ tableJoinName: f.joinDataRef,
303
+ ...f.near && { near: f.near },
304
+ ...f.groupBy && { groupBy: f.groupBy }
297
305
  }), e) {
298
- const f = await a.getLayer(c.dataRef);
299
- e.set(b(i, c.dataRef), f);
306
+ const c = await a.getLayer(f.dataRef);
307
+ e.set(E(l, f.dataRef), c);
300
308
  }
301
- return r(a, t), a;
309
+ return o(a, t), a;
302
310
  }
303
311
  case "sql": {
304
- const c = d;
312
+ const f = d;
305
313
  try {
306
314
  await a.rawQuery({
307
- query: c.query,
315
+ query: f.query,
308
316
  output: {
309
317
  type: "CREATE_TABLE",
310
- tableName: c.outputTableName,
318
+ tableName: f.outputTableName,
311
319
  source: "user",
312
- ...c.layerType !== void 0 && { tableType: c.layerType }
320
+ ...f.layerType !== void 0 && { tableType: f.layerType }
313
321
  }
314
322
  });
315
- } catch (f) {
316
- throw new Error(`SQL source "${c.outputTableName}": ${f instanceof Error ? f.message : String(f)}`);
323
+ } catch (c) {
324
+ throw new Error(`SQL source "${f.outputTableName}": ${c instanceof Error ? c.message : String(c)}`);
317
325
  }
318
- return e?.delete(b(i, c.outputTableName)), r(a, t), a;
326
+ return e?.delete(E(l, f.outputTableName)), o(a, t), a;
319
327
  }
320
328
  case "update": {
321
- const c = d, f = (h) => new Error(`Update of "${c.dataRef}": ${h}`);
322
- if (c.geojsonObject === void 0 == (c.jsonObject === void 0))
323
- throw f("give its rows in geojsonObject or in jsonObject, one of the two.");
324
- if (c.strategy === "update" && !c.idColumn)
325
- throw f("the update strategy needs an idColumn, the column that matches a given row to the table's rows.");
326
- let y = c.geojsonObject ?? c.jsonObject, m = c.idColumn;
329
+ const f = d, c = (y) => new Error(`Update of "${f.dataRef}": ${y}`);
330
+ if (f.geojsonObject === void 0 == (f.jsonObject === void 0))
331
+ throw c("give its rows in geojsonObject or in jsonObject, one of the two.");
332
+ if (f.strategy === "update" && !f.idColumn)
333
+ throw c("the update strategy needs an idColumn, the column that matches a given row to the table's rows.");
334
+ let h = f.geojsonObject ?? f.jsonObject, m = f.idColumn;
327
335
  try {
328
- const h = a.getTablesMetadata().find((p) => p.name === c.dataRef);
329
- if (c.strategy === "update" && c.geojsonObject && m?.startsWith("properties.") && h && Nt(h) && ({ data: y, idColumn: m } = await Yt(a, h, c.geojsonObject, m.slice(11)), y.features.length === 0))
330
- return r(a, t), a;
336
+ const y = a.getTablesMetadata().find((p) => p.name === f.dataRef);
337
+ if (f.strategy === "update" && f.geojsonObject && m?.startsWith("properties.") && y && Ht(y) && ({ data: h, idColumn: m } = await ue(a, y, f.geojsonObject, m.slice(11)), h.features.length === 0))
338
+ return o(a, t), a;
331
339
  await a.updateTable({
332
- tableName: c.dataRef,
333
- data: y,
334
- strategy: c.strategy,
340
+ tableName: f.dataRef,
341
+ data: h,
342
+ strategy: f.strategy,
335
343
  ...m !== void 0 && { idColumn: m }
336
344
  });
337
- } catch (h) {
338
- throw f(h instanceof Error ? h.message : String(h));
345
+ } catch (y) {
346
+ throw c(y instanceof Error ? y.message : String(y));
339
347
  }
340
- return await o(a, i, c.dataRef), r(a, t), a;
348
+ return await r(a, l, f.dataRef), o(a, t), a;
341
349
  }
342
350
  case "drop": {
343
- const c = d;
344
- if (!a.getTablesMetadata().some((f) => f.name === c.dataRef))
345
- throw new Error(`Drop of "${c.dataRef}": ${D(i)} holds no table of that name.`);
346
- return await a.removeLayer(c.dataRef), e?.delete(b(i, c.dataRef)), r(a, t), a;
351
+ const f = d;
352
+ if (!a.getTablesMetadata().some((c) => c.name === f.dataRef))
353
+ throw new Error(`Drop of "${f.dataRef}": ${V(l)} holds no table of that name.`);
354
+ return await a.removeLayer(f.dataRef), e?.delete(E(l, f.dataRef)), o(a, t), a;
347
355
  }
348
356
  default:
349
- throw new Error(`Unknown data source type "${String(l)}".`);
357
+ throw new Error(`Unknown data source type "${String(s)}".`);
350
358
  }
351
359
  }
352
360
  };
353
361
  }
354
- function wt(t, e) {
362
+ function St(t, e) {
355
363
  return e === !0 ? `${t} osm-elements` : t;
356
364
  }
357
- function gt(t) {
365
+ function At(t) {
358
366
  return t === !0 ? { osmElements: !0 } : void 0;
359
367
  }
360
- function bt(t, e, r) {
361
- if (!t) return r();
362
- let o = t.get(e);
363
- return o || (o = r(), t.set(e, o)), o;
368
+ function It(t, e, o) {
369
+ if (!t) return o();
370
+ let r = t.get(e);
371
+ return r || (r = o(), t.set(e, r)), r;
364
372
  }
365
- function _t(t, e) {
373
+ function Lt(t, e) {
366
374
  return t?.id ?? e;
367
375
  }
368
- function U(t, e) {
376
+ function Y(t, e) {
369
377
  return e === void 0 ? !0 : typeof e == "number" ? t.mapIndex === e : t.mapId === e;
370
378
  }
371
- function Et(t, e, r) {
372
- const o = t?.get(e) ?? [];
373
- o.includes(r) || t?.set(e, [...o, r]);
379
+ function Pt(t, e, o) {
380
+ const r = t?.get(e) ?? [];
381
+ r.includes(o) || t?.set(e, [...r, o]);
374
382
  }
375
- const Mt = 6378137, Y = 0.0818191908426215;
376
- function Wt(t, e) {
383
+ const Nt = 6378137, q = 0.0818191908426215;
384
+ function ce(t, e) {
377
385
  if (t === void 0 || typeof t == "number" && Number.isFinite(t) && t > 0) return;
378
- const r = typeof t == "number" ? String(t) : JSON.stringify(t);
379
- throw new Error(`Layer "${e}": pointSize must be a number of meters greater than 0, not ${r}.`);
380
- }
381
- function Ht(t) {
382
- const e = Math.exp(-t / Mt);
383
- let r = Math.PI / 2 - 2 * Math.atan(e);
384
- for (let o = 0; o < 10; o++) {
385
- const n = Y * Math.sin(r), s = Math.PI / 2 - 2 * Math.atan(e * ((1 - n) / (1 + n)) ** (Y / 2));
386
- if (Math.abs(s - r) < 1e-12) return s;
387
- r = s;
386
+ const o = typeof t == "number" ? String(t) : JSON.stringify(t);
387
+ throw new Error(`Layer "${e}": pointSize must be a number of meters greater than 0, not ${o}.`);
388
+ }
389
+ function de(t) {
390
+ const e = Math.exp(-t / Nt);
391
+ let o = Math.PI / 2 - 2 * Math.atan(e);
392
+ for (let r = 0; r < 10; r++) {
393
+ const n = q * Math.sin(o), i = Math.PI / 2 - 2 * Math.atan(e * ((1 - n) / (1 + n)) ** (q / 2));
394
+ if (Math.abs(i - o) < 1e-12) return i;
395
+ o = i;
388
396
  }
389
- return r;
397
+ return o;
390
398
  }
391
- function qt(t, e) {
399
+ function pe(t, e) {
392
400
  if (/^EPSG:3395$/i.test(t)) {
393
- const r = Ht(e), o = Y * Math.sin(r);
394
- return Math.sqrt(1 - o * o) / Math.cos(r);
401
+ const o = de(e), r = q * Math.sin(o);
402
+ return Math.sqrt(1 - r * r) / Math.cos(o);
395
403
  }
396
- return /^EPSG:3857$/i.test(t) ? Math.cosh(e / Mt) : 1;
404
+ return /^EPSG:3857$/i.test(t) ? Math.cosh(e / Nt) : 1;
397
405
  }
398
- function Jt(t, e, r, o) {
406
+ function he(t, e, o, r) {
399
407
  if (t === void 0 || e !== "points") return;
400
- const n = o();
408
+ const n = r();
401
409
  if (n)
402
- return t * qt(r, (n[1] + n[3]) / 2);
410
+ return t * pe(o, (n[1] + n[3]) / 2);
411
+ }
412
+ const G = /^#[0-9a-fA-F]{6}$/;
413
+ function Tt(t, e) {
414
+ if (t === void 0) return;
415
+ if (!Array.isArray(t) || t.length !== 2 || !t.every((n) => typeof n == "number" && Number.isFinite(n)))
416
+ return "colorMapRange must hold two numbers, [low, high].";
417
+ const [o, r] = t;
418
+ if (o >= r)
419
+ return `colorMapRange low (${o}) must be less than high (${r}).`;
420
+ if (e !== void 0)
421
+ return "set colorMapRange or colorMapDomain, not both.";
422
+ }
423
+ function Ot(t, e) {
424
+ return e && e.length > 0 ? { type: A.USER, params: e } : t?.mode === Ct.PERCENTILE ? t.lowerPercentile !== void 0 || t.upperPercentile !== void 0 ? {
425
+ type: A.PERCENTILE,
426
+ params: [t.lowerPercentile ?? 0, t.upperPercentile ?? 100]
427
+ } : { type: A.PERCENTILE } : { type: A.MIN_MAX };
403
428
  }
404
- function R(t) {
429
+ function b(t) {
405
430
  return typeof t.title == "string" && t.title !== "" ? t.title : t.dataRef;
406
431
  }
407
- function Kt(t, e) {
408
- const r = /* @__PURE__ */ new Set();
409
- for (const o of t.layerRefs) {
410
- const n = R(o);
411
- if (r.has(n))
432
+ function me(t, e) {
433
+ const o = /* @__PURE__ */ new Set();
434
+ for (const r of t.layerRefs) {
435
+ const n = b(r);
436
+ if (o.has(n))
412
437
  throw new Error(`Map ${e} draws two layers with the id "${n}". A layer's id is its title, else its dataRef: give each layer of a map its own title.`);
413
- r.add(n);
438
+ o.add(n);
414
439
  }
415
440
  }
416
- const Xt = /^#[0-9a-fA-F]{6}$/;
417
- function at(t, e, r) {
418
- if (!Xt.test(t))
419
- throw new Error(`Layer "${r}": ${e} must be a color written #rrggbb, not "${t}".`);
420
- return B.hexToRgb(t);
441
+ function ct(t, e, o) {
442
+ if (!G.test(t))
443
+ throw new Error(`Layer "${o}": ${e} must be a color written #rrggbb, not "${t}".`);
444
+ return P.hexToRgb(t);
421
445
  }
422
- function zt(t, e) {
423
- const r = {};
424
- return t.color != null && (r.color = at(t.color, "color", e)), t.stroke === !1 ? r.showBorders = !1 : t.stroke != null && (r.strokeColor = at(t.stroke, "stroke", e)), t.width != null && (r.polylinesWidth = t.width), r;
446
+ function ye(t, e) {
447
+ const o = {};
448
+ return t.color != null && (o.color = ct(t.color, "color", e)), t.stroke === !1 ? o.showBorders = !1 : t.stroke != null && (o.strokeColor = ct(t.stroke, "stroke", e)), t.width != null && (o.polylinesWidth = t.width), o;
425
449
  }
426
- function Zt(t, e) {
427
- return t.isColorMap != null ? t.isColorMap : e === "raster" ? t.colorMapInterpolator != null || t.colorMapRange != null || t.colorMapCenter != null || t.colorMapReverse === !0 : t.color != null ? !1 : t.colorMapInterpolator != null || t.getFnv != null;
450
+ function ge(t, e) {
451
+ return t.isColorMap != null ? t.isColorMap : e === "raster" ? t.colorMapInterpolator != null || t.colorMapRange != null || t.colorMapCenter != null || t.colorMapReverse === !0 || t.legend === !0 : t.color != null ? !1 : t.colorMapInterpolator != null || t.getFnv != null;
428
452
  }
429
- function te(t, e) {
430
- const r = t.features?.[0]?.properties?.[e];
431
- return r instanceof Float32Array ? r : ArrayBuffer.isView(r) && !(r instanceof DataView) || Array.isArray(r) ? Float32Array.from(r, (o) => Number.isFinite(Number(o)) ? Number(o) : NaN) : null;
453
+ function we(t, e) {
454
+ const o = t.features?.[0]?.properties?.[e];
455
+ return o instanceof Float32Array ? o : ArrayBuffer.isView(o) && !(o instanceof DataView) || Array.isArray(o) ? Float32Array.from(o, (r) => Number.isFinite(Number(r)) ? Number(r) : NaN) : null;
432
456
  }
433
- function ee(t, e, r, o, n) {
434
- if (B.isCategorical(e.interpolator)) return;
457
+ function be(t, e, o, r, n) {
458
+ if (P.isCategorical(e.interpolator)) return;
435
459
  if (n != null) {
436
- const u = r != null ? [n[0], r, n[1]] : [n[0], n[1]];
437
- return o === !0 ? u.reverse() : u;
460
+ const u = o != null ? [n[0], o, n[1]] : [n[0], n[1]];
461
+ return r === !0 ? u.reverse() : u;
438
462
  }
439
463
  if (!t) return;
440
- let s = 0, a = 0;
464
+ let i = 0, a = 0;
441
465
  for (let u = 0; u < t.length; u++) {
442
466
  const d = t[u];
443
- Number.isFinite(d) && (a++, r != null && (s = Math.max(s, Math.abs(d - r))));
467
+ Number.isFinite(d) && (a++, o != null && (i = Math.max(i, Math.abs(d - o))));
444
468
  }
445
- const i = r != null && s > 0;
446
- if (a === 0 || !i && o !== !0) return;
447
- const l = i && r != null ? [r - s, r, r + s] : B.resolveDomainFromData(t, e);
448
- return o === !0 ? [...l].reverse() : l;
469
+ const l = o != null && i > 0;
470
+ if (a === 0 || !l && r !== !0) return;
471
+ const s = l && o != null ? [o - i, o, o + i] : P.resolveDomainFromData(t, e);
472
+ return r === !0 ? [...s].reverse() : s;
449
473
  }
450
- function re(t, e) {
451
- if (!(e == null || B.isCategorical(t.interpolator)))
474
+ function ve(t, e) {
475
+ if (!(e == null || P.isCategorical(t.interpolator)))
452
476
  return [e[0], e[1]];
453
477
  }
454
- function oe(t) {
478
+ function Ee(t) {
455
479
  const e = t.colorMapRange;
456
480
  if (e === void 0) return;
457
- const r = (a) => new Error(`Layer "${R(t)}": ${a}`);
458
- if (!Array.isArray(e) || e.length !== 2 || !e.every((a) => typeof a == "number" && Number.isFinite(a)))
459
- throw r("colorMapRange must hold two numbers, [low, high].");
460
- const [o, n] = e;
461
- if (o >= n)
462
- throw r(`colorMapRange low (${o}) must be less than high (${n}).`);
463
- if (t.colorMapDomain !== void 0)
464
- throw r("set colorMapRange or colorMapDomain, not both.");
465
- const s = t.colorMapCenter;
466
- if (s != null && (s < o || s > n))
467
- throw r(`colorMapCenter (${s}) must lie within colorMapRange [${o}, ${n}].`);
468
- }
469
- function ne(t, e) {
470
- return e && e.length > 0 ? { type: P.USER, params: e } : t?.mode === pt.PERCENTILE ? t.lowerPercentile !== void 0 || t.upperPercentile !== void 0 ? {
471
- type: P.PERCENTILE,
472
- params: [t.lowerPercentile ?? 0, t.upperPercentile ?? 100]
473
- } : { type: P.PERCENTILE } : { type: P.MIN_MAX };
481
+ const o = (l) => new Error(`Layer "${b(t)}": ${l}`), r = Tt(e, t.colorMapDomain);
482
+ if (r)
483
+ throw o(r);
484
+ const [n, i] = e, a = t.colorMapCenter;
485
+ if (a != null && (a < n || a > i))
486
+ throw o(`colorMapCenter (${a}) must lie within colorMapRange [${n}, ${i}].`);
487
+ }
488
+ const H = ["background", "surface", "parks", "water", "roads", "buildings", "points", "polylines", "polygons"];
489
+ function _e(t, e) {
490
+ const o = (n) => new Error(`Map ${e}: ${n}`), r = t.style;
491
+ if (r !== void 0 && typeof r != "string") {
492
+ if (r === null || typeof r != "object" || Array.isArray(r))
493
+ throw o(`style must be the name of one of autk-map's styles or the colors of a style, not ${JSON.stringify(r)}.`);
494
+ const n = H.filter((i) => !(i in r));
495
+ if (n.length > 0)
496
+ throw o(`style gives no color for ${n.join(", ")}: a style of the spec's own gives each of ${H.join(", ")}.`);
497
+ for (const i of H) {
498
+ const a = r[i];
499
+ if (typeof a != "string" || !G.test(a))
500
+ throw o(`style.${i} must be a color written #rrggbb, not ${JSON.stringify(a)}.`);
501
+ }
502
+ }
503
+ for (const n of ["highlightColor", "invalidValueColor"]) {
504
+ const i = t[n];
505
+ if (i !== void 0 && (typeof i != "string" || !G.test(i)))
506
+ throw o(`${n} must be a color written #rrggbb, not ${JSON.stringify(i)}.`);
507
+ }
474
508
  }
475
- function ae(t, e) {
476
- return e.split(".").reduce((r, o) => {
477
- if (!(r == null || typeof r != "object"))
478
- return r[o];
479
- }, t);
509
+ function Ce(t, e) {
510
+ typeof e.style == "string" ? t.style.setPredefinedStyle(e.style) : e.style && t.style.setCustomStyle(e.style), e.highlightColor !== void 0 && t.style.setHighlightColor(e.highlightColor), e.invalidValueColor !== void 0 && t.style.setInvalidValueColor(e.invalidValueColor);
480
511
  }
481
- function ie(t, e, r) {
482
- const o = e.split("."), n = { ...t };
483
- let s = n;
484
- for (let a = 0; a < o.length - 1; a++)
485
- s[o[a]] = { ...s[o[a]] ?? {} }, s = s[o[a]];
486
- return s[o[o.length - 1]] = r, n;
512
+ function $e(t, e) {
513
+ const o = t.widthBy;
514
+ if (o !== void 0) {
515
+ if (typeof o != "string" || o === "")
516
+ throw new Error(`Layer "${e}": widthBy must be the dot path to each line's width, not ${JSON.stringify(o)}.`);
517
+ if (t.width !== void 0)
518
+ throw new Error(`Layer "${e}": set width or widthBy, not both: width gives every line one width.`);
519
+ }
487
520
  }
488
- function se(t, e) {
489
- const o = t.features?.[0]?.properties?.bands ?? [];
490
- return o.find((s) => s.id === e || s.label === e?.replace(/\./g, "_"))?.id ?? o[0]?.id ?? e ?? "";
521
+ function Me(t, e, o, r, n) {
522
+ if (r !== "roads")
523
+ throw new Error(`Layer "${e}": widthBy sets the width of each line of a roads layer, and the layer is drawn as ${r}: draw a table of lines as roads with layerType: 'roads'.`);
524
+ const i = t.layerManager.searchByLayerId(e), a = i?.components ?? [], l = new Float32Array(a.length);
525
+ l.set(i?.layerRenderInfo.polylinesWidthByComponent?.subarray(0, a.length) ?? []);
526
+ const s = o.startsWith("properties.") ? o.slice(11) : o;
527
+ let u = 0;
528
+ if (a.forEach((d, f) => {
529
+ const c = n.features[d.featureIndex ?? f], h = Number(Bt(c?.properties, s));
530
+ Number.isFinite(h) && h > 0 && (l[f] = h, u++);
531
+ }), u === 0)
532
+ throw new Error(`Layer "${e}": widthBy "${o}" gives no line of the layer a width: none has a positive number there.`);
533
+ t.updateRenderInfo(e, { polylinesWidthByComponent: l });
534
+ }
535
+ function ke(t, e) {
536
+ const o = t.layerRefs.filter((r) => r.legend === !0).map(b);
537
+ if (o.length > 1)
538
+ throw new Error(`Map ${e}: layers ${o.map((r) => `"${r}"`).join(" and ")} each set legend: a map shows one legend.`);
539
+ if (o.length === 1 && t.showUi === !1)
540
+ throw new Error(`Layer "${o[0]}": legend shows the layer in the map's legend, and the map's showUi is false, which hides the legend.`);
541
+ }
542
+ function Re(t, e) {
543
+ const o = e.layerRefs.find((i) => i.legend === !0);
544
+ if (!o) return;
545
+ const r = b(o), n = t.layerManager.searchByLayerId(r);
546
+ if (!n?.layerRenderInfo.isColorMap)
547
+ throw new Error(`Layer "${r}": legend shows the color scale of a layer colored by value, and the layer is drawn in one color.`);
548
+ t.ui.activeLayer = n, t.ui.refreshLegend(null);
549
+ }
550
+ const Se = [
551
+ { types: ["points"], drawn: "a table of points is drawn as points" },
552
+ { types: ["polylines", "roads"], drawn: "a table of lines is drawn as polylines or roads" },
553
+ { types: ["polygons", "surface", "parks", "water", "buildings"], drawn: "a table of polygons is drawn as polygons, surface, parks, water or buildings" },
554
+ { types: ["raster"], drawn: "a raster table is drawn as raster" }
555
+ ];
556
+ function Ae(t, e, o) {
557
+ const r = t.layerType;
558
+ if (r === void 0 || e === void 0) return r ?? e;
559
+ const n = Se.find((i) => i.types.includes(e));
560
+ if (!n || n.types.includes(r)) return r;
561
+ throw new Error(`Layer "${o}": layerType "${r}" cannot draw the table "${t.dataRef}", a ${e} table: ${n.drawn}.`);
562
+ }
563
+ function Ft(t, e, o) {
564
+ if (!Array.isArray(t) || !t.every((r) => Number.isInteger(r) && r >= 0))
565
+ throw new Error(`Layer "${o}": ${e} must list the positions of features the layer draws, whole numbers from 0, not ${JSON.stringify(t)}.`);
566
+ }
567
+ function dt(t, e, o, r, n) {
568
+ if (r === "raster")
569
+ throw new Error(`Layer "${o}": ${e} names features, and a raster layer has none.`);
570
+ const i = t.find((a) => a >= n);
571
+ if (i !== void 0)
572
+ throw new Error(`Layer "${o}": ${e} names position ${i}, past the ${n} features the layer draws.`);
573
+ }
574
+ function Ie(t) {
575
+ t.layerRefs.forEach((e, o) => {
576
+ if (e.pickedComps === void 0) return;
577
+ const r = b(e);
578
+ if (Ft(e.pickedComps, "pickedComps", r), e.isPick !== !0)
579
+ throw new Error(`Layer "${r}": pickedComps draws features as picked, which autk-map does only on the layer that picks: set isPick: true.`);
580
+ const n = t.layerRefs.slice(o + 1).find((i) => i.isPick === !0);
581
+ if (n)
582
+ throw new Error(`Layer "${r}": pickedComps draws features as picked on the layer that picks, but layer "${b(n)}", after it, picks too: autk-map lets one layer of a map pick, the last.`);
583
+ });
491
584
  }
492
- function At(t) {
585
+ function Bt(t, e) {
586
+ return e.split(".").reduce((o, r) => {
587
+ if (!(o == null || typeof o != "object"))
588
+ return o[r];
589
+ }, t);
590
+ }
591
+ function Le(t, e, o) {
592
+ const r = e.split("."), n = { ...t };
593
+ let i = n;
594
+ for (let a = 0; a < r.length - 1; a++)
595
+ i[r[a]] = { ...i[r[a]] ?? {} }, i = i[r[a]];
596
+ return i[r[r.length - 1]] = o, n;
597
+ }
598
+ function jt(t, e, o) {
599
+ const n = t.features?.[0]?.properties?.bands ?? [];
600
+ if (e === void 0) return n[0]?.id ?? "";
601
+ const i = n.find((a) => a.id === e || a.label === e.replace(/\./g, "_"));
602
+ if (i) return i.id;
603
+ if (n.length > 1) {
604
+ const a = n.map((l) => l.label && l.label !== l.id ? `${l.id} (${l.label})` : l.id);
605
+ throw o(`"${e}" names none of its ${n.length} bands: ${a.join(", ")}.`);
606
+ }
607
+ return n[0]?.id ?? e;
608
+ }
609
+ function xt(t) {
493
610
  const { pitch: e } = t;
494
611
  return e === void 0 || typeof e == "number" && e >= 0 && e < 90 ? void 0 : `camera.pitch must be at least 0 and less than 90 degrees, not ${typeof e == "number" ? String(e) : JSON.stringify(e)}: at 90 the eye would sit on the ground, edge-on to the map's flat layers, and the map could not pan.`;
495
612
  }
496
- function le(t, e) {
497
- const r = At(e);
498
- if (r) throw new Error(r);
613
+ function Pe(t, e) {
614
+ const o = xt(e);
615
+ if (o) throw new Error(o);
499
616
  if (e.zoom === void 0 && !e.pitch && !e.bearing) return;
500
- const o = t.camera, [n, s] = o.getLookAt(), a = e.zoom !== void 0 ? 1e4 / Math.pow(2, e.zoom - 10) : Math.abs(o.getEye()[2]), i = (e.pitch ?? 0) * Math.PI / 180, l = (e.bearing ?? 0) * Math.PI / 180, u = [
501
- n - a * Math.sin(i) * Math.sin(l),
502
- s - a * Math.sin(i) * Math.cos(l),
503
- a * Math.cos(i)
504
- ], d = [Math.cos(i) * Math.sin(l), Math.cos(i) * Math.cos(l), Math.sin(i)];
505
- o.resetCamera(d, [n, s, 0], u);
506
- }
507
- function ue(t, e, r, o) {
508
- const s = t.layerManager.searchByLayerId(e)?.components;
509
- return Array.isArray(s) ? s.map((a, i) => {
510
- const l = Number.isInteger(a?.featureIndex) ? a.featureIndex : i;
511
- return r[o[l]] ?? "";
512
- }) : o.map((a) => r[a] ?? "");
513
- }
514
- function ce(t, e, r, o, n, s) {
515
- async function a(i, l, u) {
617
+ const r = t.camera, [n, i] = r.getLookAt(), a = e.zoom !== void 0 ? 1e4 / Math.pow(2, e.zoom - 10) : Math.abs(r.getEye()[2]), l = (e.pitch ?? 0) * Math.PI / 180, s = (e.bearing ?? 0) * Math.PI / 180, u = [
618
+ n - a * Math.sin(l) * Math.sin(s),
619
+ i - a * Math.sin(l) * Math.cos(s),
620
+ a * Math.cos(l)
621
+ ], d = [Math.cos(l) * Math.sin(s), Math.cos(l) * Math.cos(s), Math.sin(l)];
622
+ r.resetCamera(d, [n, i, 0], u);
623
+ }
624
+ async function Ne(t, e, o, r) {
625
+ const n = (s) => new Error(`Map ${r}: terrain ${s}`), i = e.getTablesMetadata().find((s) => s.name === o.dataRef);
626
+ if (!i)
627
+ throw n(`dataRef "${o.dataRef}" names no table of the map's workspace.`);
628
+ if (i.type !== "raster")
629
+ throw n(`dataRef "${o.dataRef}" names a ${i.type ?? "plain"} table, and a terrain takes its heights from a raster table, such as a geotiff source's.`);
630
+ const a = await e.getRaster(o.dataRef), l = jt(a, o.band, (s) => n(`band ${s}`));
631
+ try {
632
+ t.enableTerrainMode(a, l);
633
+ } catch (s) {
634
+ throw n(`"${o.dataRef}": ${s instanceof Error ? s.message : String(s)}`);
635
+ }
636
+ }
637
+ function Te(t, e, o, r) {
638
+ const i = t.layerManager.searchByLayerId(e)?.components;
639
+ return Array.isArray(i) ? i.map((a, l) => {
640
+ const s = Number.isInteger(a?.featureIndex) ? a.featureIndex : l;
641
+ return o[r[s]] ?? "";
642
+ }) : r.map((a) => o[a] ?? "");
643
+ }
644
+ function Oe(t, e, o, r, n, i) {
645
+ async function a(l, s, u) {
516
646
  let d = {};
517
- for (const f of l.getTablesMetadata())
518
- f.type !== void 0 && (d[f.name] = f.type);
519
- const c = [];
520
- for (const f of u.layerRefs) {
521
- const y = f.dataRef, m = R(f), h = b(u.workspace, y), p = n?.get(h) ?? d[y], w = f.getFnv, _ = r?.get(h) ?? (p === "raster" ? await l.getRaster(y) : await bt(s, wt(h, f.osmElements), () => l.getLayer(y, gt(f.osmElements)))), E = _.features ?? [], S = p === "raster" ? [] : E.flatMap((g, M) => g?.geometry != null ? [M] : []), A = p === "raster" ? _ : { ..._, features: S.map((g) => E[g]) }, V = p === "raster" ? se(A, w) : "";
522
- p === "raster" ? i.loadCollection(m, { collection: A, type: "raster", property: V }) : i.loadCollection(m, { collection: A, type: p }), f.opacity != null && i.updateRenderInfo(m, { opacity: f.opacity });
523
- const W = zt(f, m);
524
- Object.keys(W).length > 0 && i.updateRenderInfo(m, W);
525
- const Pt = l.getWorkspaceConfiguration().coordinateFormat, H = Jt(f.pointSize, p, Pt, () => yt(A));
526
- H !== void 0 && i.updateRenderInfo(m, { pointSize: H }), Zt(f, p) && i.updateRenderInfo(m, { isColorMap: !0 }), f.isPick && i.updateRenderInfo(m, { isPick: !0 }), f.isSkip && i.updateRenderInfo(m, { isSkip: !0 });
527
- const { catchAllCategory: $, colorMapDomain: L } = f;
528
- let q = A, J = L;
529
- if (w && $ && L?.length) {
530
- const g = new Set(L);
531
- q = {
532
- ...A,
533
- features: A.features.map((M) => {
534
- const z = M.properties, G = ae(z, w);
535
- return G == null || !g.has(String(G)) ? { ...M, properties: ie(z, w, $) } : M;
647
+ for (const c of s.getTablesMetadata())
648
+ c.type !== void 0 && (d[c.name] = c.type);
649
+ const f = [];
650
+ for (const c of u.layerRefs) {
651
+ const h = c.dataRef, m = b(c), y = E(u.workspace, h), p = Ae(c, n?.get(y) ?? d[h], m), g = c.getFnv, _ = o?.get(y) ?? (p === "raster" ? await s.getRaster(h) : await It(i, St(y, c.osmElements), () => s.getLayer(h, At(c.osmElements)))), $ = _.features ?? [], S = p === "raster" ? [] : $.flatMap((w, M) => w?.geometry != null ? [M] : []), k = p === "raster" ? _ : { ..._, features: S.map((w) => $[w]) }, K = p === "raster" ? jt(k, g, (w) => new Error(`Layer "${m}": getFnv ${w}`)) : "";
652
+ if (p === "raster")
653
+ l.loadCollection(m, { collection: k, type: "raster", property: K });
654
+ else {
655
+ const w = p === "buildings" && c.buildingsZeroHeight === !0;
656
+ l.loadCollection(m, { collection: k, type: p, ...w ? { loadConfig: { buildingsZeroHeight: !0 } } : {} });
657
+ }
658
+ c.opacity != null && l.updateRenderInfo(m, { opacity: c.opacity });
659
+ const z = ye(c, m);
660
+ Object.keys(z).length > 0 && l.updateRenderInfo(m, z), c.widthBy !== void 0 && Me(l, m, c.widthBy, p, k);
661
+ const Yt = s.getWorkspaceConfiguration().coordinateFormat, X = he(c.pointSize, p, Yt, () => Rt(k));
662
+ X !== void 0 && l.updateRenderInfo(m, { pointSize: X }), ge(c, p) && l.updateRenderInfo(m, { isColorMap: !0 }), c.isPick && l.updateRenderInfo(m, { isPick: !0 }), c.isSkip && l.updateRenderInfo(m, { isSkip: !0 });
663
+ const { catchAllCategory: T, colorMapDomain: L } = c;
664
+ let Z = k, tt = L;
665
+ if (g && T && L?.length) {
666
+ const w = new Set(L);
667
+ Z = {
668
+ ...k,
669
+ features: k.features.map((M) => {
670
+ const rt = M.properties, Q = Bt(rt, g);
671
+ return Q == null || !w.has(String(Q)) ? { ...M, properties: Le(rt, g, T) } : M;
536
672
  })
537
- }, J = g.has($) ? L : [...L, $];
673
+ }, tt = w.has(T) ? L : [...L, T];
538
674
  }
539
- const K = p === "raster" && f.transferFunction != null;
540
- K && i.layerManager.searchByLayerId(m)?.setTransferFunction?.(f.transferFunction);
541
- const O = f.colorMapRange, X = p === "raster" && (O != null || f.colorMapCenter != null || f.colorMapReverse === !0);
542
- if (f.colorMapInterpolator || X || O) {
543
- const g = {
675
+ const et = p === "raster" && c.transferFunction != null;
676
+ et && l.layerManager.searchByLayerId(m)?.setTransferFunction?.(c.transferFunction);
677
+ const O = c.colorMapRange, ot = p === "raster" && (O != null || c.colorMapCenter != null || c.colorMapReverse === !0);
678
+ if (c.colorMapInterpolator || ot || O) {
679
+ const w = {
544
680
  // urban-grammar ColorMapInterpolator values are string-compatible
545
681
  // with autk-core ColorMapInterpolator at runtime
546
- interpolator: f.colorMapInterpolator ?? i.layerManager.searchByLayerId(m)?.layerRenderInfo.colormap.config.interpolator ?? Ft.SEQ_REDS,
547
- domainSpec: ne(f.normalization, J)
682
+ interpolator: c.colorMapInterpolator ?? l.layerManager.searchByLayerId(m)?.layerRenderInfo.colormap.config.interpolator ?? _t.SEQ_REDS,
683
+ domainSpec: Ot(c.normalization, tt)
548
684
  };
549
685
  let M;
550
- X ? M = ee(te(A, V), g, f.colorMapCenter, f.colorMapReverse, O) : p !== "raster" && (M = re(g, O)), M && (g.domainSpec = { type: P.USER, params: M }), i.updateColorMap(m, { colorMap: g });
551
- } else K && i.updateColorMap(m, { colorMap: {} });
552
- if (w && p !== "raster") {
553
- const g = w.startsWith("properties.") ? w : `properties.${w}`;
554
- i.updateThematic(m, { collection: q, property: g });
686
+ ot ? M = be(we(k, K), w, c.colorMapCenter, c.colorMapReverse, O) : p !== "raster" && (M = ve(w, O)), M && (w.domainSpec = { type: A.USER, params: M }), l.updateColorMap(m, { colorMap: w });
687
+ } else et && l.updateColorMap(m, { colorMap: {} });
688
+ if (g && p !== "raster") {
689
+ const w = g.startsWith("properties.") ? g : `properties.${g}`;
690
+ l.updateThematic(m, { collection: Z, property: w });
555
691
  }
556
- c.push(p === "raster" ? [] : ue(i, m, ht(E), S));
692
+ const W = p === "raster" ? [] : Te(l, m, kt($), S);
693
+ c.pickedComps && dt(c.pickedComps, "pickedComps", m, p, W.length), c.skippedComps && (dt(c.skippedComps, "skippedComps", m, p, W.length), l.layerManager.searchByLayerId(m)?.setSkippedIds(c.skippedComps)), f.push(W);
557
694
  }
558
- return c;
695
+ return f;
559
696
  }
560
697
  return {
561
- async resolveMap(i, l, u = 0) {
562
- if (t && t.map && i) {
563
- Kt(l, u);
564
- for (const h of l.layerRefs)
565
- oe(h), Wt(h.pointSize, R(h));
566
- const d = l.camera && At(l.camera);
698
+ async resolveMap(l, s, u = 0) {
699
+ if (t && t.map && l) {
700
+ me(s, u);
701
+ for (const y of s.layerRefs)
702
+ Ee(y), ce(y.pointSize, b(y)), y.skippedComps !== void 0 && Ft(y.skippedComps, "skippedComps", b(y)), $e(y, b(y));
703
+ Ie(s), _e(s, u), ke(s, u);
704
+ const d = s.camera && xt(s.camera);
567
705
  if (d)
568
706
  throw new Error(`Map ${u}: ${d}`);
569
- let c;
570
- if (Array.isArray(t.map) ? c = document.getElementById(t.map[u]) : c = document.getElementById(t.map), !c)
707
+ let f;
708
+ if (Array.isArray(t.map) ? f = document.getElementById(t.map[u]) : f = document.getElementById(t.map), !f)
571
709
  throw new Error("Could not find rendering target for map: " + t.map);
572
- if (!(c instanceof HTMLCanvasElement))
710
+ if (!(f instanceof HTMLCanvasElement))
573
711
  throw new Error("Target for map is not a canvas: " + t.map);
574
- const f = new Ot(c);
575
- let y;
712
+ const c = s.showUi === !1 ? new nt(f, !1) : new nt(f);
713
+ let h;
576
714
  try {
577
- l.style && f.style.setPredefinedStyle(l.style), await f.init(), await I(i, l.workspace), y = await a(f, i, l);
578
- } catch (h) {
715
+ Ce(c, s), await c.init(), await I(l, s.workspace), h = await a(c, l, s), s.terrain && await Ne(c, l, s.terrain, u), Re(c, s);
716
+ } catch (y) {
579
717
  try {
580
- f.destroy();
718
+ c.destroy();
581
719
  } catch {
582
720
  }
583
- throw h;
721
+ throw y;
584
722
  }
585
- const m = _t(l, u);
586
- l.layerRefs.forEach((h, p) => e?.push({
587
- map: f,
723
+ const m = Lt(s, u);
724
+ s.layerRefs.forEach((y, p) => e?.push({
725
+ map: c,
588
726
  mapIndex: u,
589
727
  mapId: m,
590
- layerId: R(h),
591
- dataRef: h.dataRef,
592
- rows: y[p]
593
- })), o && (o[u] = f), l.camera && le(f, l.camera), f.draw();
728
+ layerId: b(y),
729
+ dataRef: y.dataRef,
730
+ rows: h[p]
731
+ })), r && (r[u] = c), s.camera && Pe(c, s.camera), c.draw();
732
+ }
733
+ }
734
+ };
735
+ }
736
+ function C(t) {
737
+ return t.id ?? t.dataRef;
738
+ }
739
+ const Fe = new Set(Object.values(_t));
740
+ function pt(t, e, o) {
741
+ if (e !== void 0) {
742
+ if (typeof e != "string" || !Fe.has(e)) return `${t} ${JSON.stringify(e)} is not a color scheme.`;
743
+ if (P.isCategorical(e) !== o)
744
+ return o ? `${t} "${e}" is not a categorical scheme: categories take a scheme* scheme, such as schemeTableau10.` : `${t} "${e}" is a categorical scheme: numbers take an interpolate* scheme, and categories take categoricalColorMapInterpolator.`;
745
+ }
746
+ }
747
+ const Be = /^(?:.?[<>=^])?[-+( ]?[$#]?0?\d*,?(?:\.\d+)?~?[a-zA-Z%]?$/;
748
+ function je(t) {
749
+ if (t === void 0) return;
750
+ if (!Array.isArray(t) || t.length !== 2)
751
+ return "tickFormats must hold two d3-format specifiers, [x, y].";
752
+ const e = t.findIndex((o) => typeof o != "string" || !Be.test(o));
753
+ if (e >= 0)
754
+ return `tickFormats[${e}] ${JSON.stringify(t[e])} is not a d3-format specifier, such as "~s", ",d" or ".0%".`;
755
+ }
756
+ function xe(t, e) {
757
+ if (t === void 0) return;
758
+ if (!Array.isArray(t) || !t.every((r) => typeof r == "string"))
759
+ return "axisLabels must be a list of titles, one for each column of axis.";
760
+ if (t.length > e.length)
761
+ return `axisLabels has ${t.length} titles for the ${e.length} columns of axis.`;
762
+ const o = t.find((r, n) => t.indexOf(r) !== n);
763
+ if (o !== void 0)
764
+ return `axisLabels gives two axes the title ${JSON.stringify(o)}.`;
765
+ }
766
+ function ht(t, e) {
767
+ if (!(e === void 0 || typeof e == "string" && G.test(e)))
768
+ return `${t} must be a color written #rrggbb, not ${JSON.stringify(e)}.`;
769
+ }
770
+ function De(t) {
771
+ if (t !== void 0 && (!Array.isArray(t) || !t.every((e) => Number.isInteger(e) && e >= 0)))
772
+ return "selection must list the positions of rows, whole numbers from 0.";
773
+ }
774
+ function Ge(t) {
775
+ const e = pt("colorMapInterpolator", t.colorMapInterpolator, !1) ?? pt("categoricalColorMapInterpolator", t.categoricalColorMapInterpolator, !0) ?? Tt(t.colorMapRange, t.colorMapDomain) ?? je(t.tickFormats) ?? xe(t.axisLabels, t.axis) ?? De(t.selection) ?? ht("markColor", t.markColor) ?? ht("highlightColor", t.highlightColor);
776
+ if (e) throw new Error(`Plot "${C(t)}": ${e}`);
777
+ }
778
+ function Ue(t) {
779
+ const e = {};
780
+ for (const [o, r] of [["markColor", "mark"], ["highlightColor", "highlight"]]) {
781
+ let n;
782
+ for (const i of t) {
783
+ const a = i[o];
784
+ if (a !== void 0) {
785
+ if (n && n[o].toLowerCase() !== a.toLowerCase())
786
+ throw new Error(`Plots "${C(n)}" and "${C(i)}" set different ${o} values, "${n[o]}" and "${a}": autk-plot draws every plot of a page in one ${r} color.`);
787
+ n ??= i;
594
788
  }
595
789
  }
790
+ n && (e[o] = n[o]);
791
+ }
792
+ return e;
793
+ }
794
+ function We(t, e) {
795
+ const o = t.selection?.find((r) => r >= e);
796
+ if (o !== void 0)
797
+ throw new Error(`Plot "${C(t)}": selection names row ${o}, but the plot draws ${e === 1 ? "1 row" : `${e} rows`}.`);
798
+ }
799
+ function Qe(t, e) {
800
+ return t === void 0 || t === "@transform" ? !1 : e.some((o) => {
801
+ const r = zt(o?.properties ?? {}, t);
802
+ return typeof r == "string" && isNaN(Number(r));
803
+ });
804
+ }
805
+ function Ve(t, e) {
806
+ const o = t.colorMapRange;
807
+ if (o !== void 0 && !Qe(t.color, e))
808
+ return { type: A.USER, params: [o[0], o[1]] };
809
+ if (!(t.normalization === void 0 && t.colorMapDomain === void 0))
810
+ return Ot(t.normalization, t.colorMapDomain);
811
+ }
812
+ function Ye(t) {
813
+ return t.axis.map((e, o) => t.axisLabels?.[o] ?? (e === "@transform" ? "value" : e));
814
+ }
815
+ function He(t, e) {
816
+ const o = Ve(t, e);
817
+ return {
818
+ labels: { axis: Ye(t), title: t.title },
819
+ // The grammar's scheme names are autk-core's, as strings.
820
+ ...t.colorMapInterpolator !== void 0 && { colorMapInterpolator: t.colorMapInterpolator },
821
+ ...t.categoricalColorMapInterpolator !== void 0 && {
822
+ categoricalColorMapInterpolator: t.categoricalColorMapInterpolator
823
+ },
824
+ ...o && { domainSpec: o },
825
+ ...t.tickFormats !== void 0 && { tickFormats: [...t.tickFormats] }
596
826
  };
597
827
  }
598
- function fe(t) {
828
+ function Je(t) {
599
829
  return {
600
830
  scatter: "scatterplot",
601
831
  bar: "barchart",
@@ -606,311 +836,314 @@ function fe(t) {
606
836
  heatmatrix: "heatmatrix"
607
837
  }[t];
608
838
  }
609
- function N(t) {
610
- return t.id ?? t.dataRef;
839
+ let j;
840
+ function qe(t) {
841
+ t.markColor === void 0 && t.highlightColor === void 0 && !j || (j ??= { markColor: F.default, highlightColor: F.highlight }, F.setDefaultColor(t.markColor ?? j.markColor), F.setHighlightColor(t.highlightColor ?? j.highlightColor));
611
842
  }
612
- function vt(t, e, r, o) {
613
- const { map: n, layerId: s } = o;
614
- n.updateRenderInfo(s, { isPick: !0 }), n.events.on(Q.PICKING, ({ layerId: a, selection: i }) => {
615
- a === s && t.setSelection(x(i, o.rows, e));
843
+ function Dt(t, e, o, r) {
844
+ const { map: n, layerId: i } = r;
845
+ n.updateRenderInfo(i, { isPick: !0 }), n.events.on(J.PICKING, ({ layerId: a, selection: l }) => {
846
+ a === i && t.setSelection(D(l, r.rows, e));
616
847
  });
617
- for (const a of r)
618
- t.events.on(a, ({ selection: i }) => {
619
- n.setHighlightedIds(s, x(i, e, o.rows));
848
+ for (const a of o)
849
+ t.events.on(a, ({ selection: l }) => {
850
+ n.setHighlightedIds(i, D(l, e, r.rows));
620
851
  });
621
852
  }
622
- async function de(t, e, r, o, n) {
623
- const s = t.getTablesMetadata().find((a) => a.name === e);
624
- return s && !dt(s) ? { type: "FeatureCollection", features: (await t.getTable(e)).map((i) => ({ type: "Feature", geometry: null, properties: i })) } : bt(o, wt(r, n), () => t.getLayer(e, gt(n)));
853
+ async function Ke(t, e, o, r, n) {
854
+ const i = t.getTablesMetadata().find((a) => a.name === e);
855
+ return i && !Et(i) ? { type: "FeatureCollection", features: (await t.getTable(e)).map((l) => ({ type: "Feature", geometry: null, properties: l })) } : It(r, St(o, n), () => t.getLayer(e, At(n)));
625
856
  }
626
- function pe(t, e, r, o, n, s, a, i) {
857
+ function ze(t, e, o, r, n, i, a, l) {
627
858
  return {
628
- async resolvePlot(l, u, d = 0) {
859
+ async resolvePlot(s, u, d = 0) {
629
860
  if (!t || !t.plot) return;
630
- const c = Array.isArray(t.plot) ? t.plot[d] : t.plot;
631
- if (c === void 0) throw new Error(`Plot ${d} has no target: the plot targets name ${t.plot.length} elements.`);
632
- const f = document.getElementById(c);
633
- if (!f) throw new Error(`Could not find plot target: ${c}`);
634
- const y = l;
635
- if (!y) throw new Error("No data context available for plot.");
636
- await I(y, u.workspace);
637
- const m = b(u.workspace, u.dataRef), h = u.osmElements === !0 ? void 0 : n?.get(m), p = s?.get(m) ?? h ?? await de(y, u.dataRef, m, i, u.osmElements), w = u.events ?? [], _ = new kt(f, {
638
- type: fe(u.mark),
861
+ const f = Array.isArray(t.plot) ? t.plot[d] : t.plot;
862
+ if (f === void 0) throw new Error(`Plot ${d} has no target: the plot targets name ${t.plot.length} elements.`);
863
+ const c = document.getElementById(f);
864
+ if (!c) throw new Error(`Could not find plot target: ${f}`);
865
+ const h = s;
866
+ if (!h) throw new Error("No data context available for plot.");
867
+ await I(h, u.workspace);
868
+ const m = E(u.workspace, u.dataRef), y = u.osmElements === !0 ? void 0 : n?.get(m), p = i?.get(m) ?? y ?? await Ke(h, u.dataRef, m, l, u.osmElements);
869
+ We(u, p.features?.length ?? 0);
870
+ const g = u.events ?? [], _ = new Kt(c, {
871
+ type: Je(u.mark),
639
872
  collection: p,
640
873
  attributes: { axis: u.axis, ...u.color && { color: u.color } },
641
- labels: { axis: u.axis, title: u.title },
642
- events: w,
874
+ events: g,
875
+ ...He(u, p.features ?? []),
643
876
  ...u.width && { width: u.width },
644
877
  ...u.height && { height: u.height },
645
878
  ...u.margins && { margins: u.margins },
646
879
  ...u.transform && { transform: u.transform }
647
880
  });
648
- r?.set(N(u), _);
649
- const E = ht(p.features ?? []);
650
- a?.set(N(u), E);
881
+ u.mark === "scatter" && u.color !== void 0 && _.setSelection([]), o?.set(C(u), _);
882
+ const $ = kt(p.features ?? []);
883
+ a?.set(C(u), $);
651
884
  for (const S of e ?? [])
652
- !u.mapRef || S.dataRef !== u.mapRef || (vt(_, E, w, S), Et(o, N(u), S));
885
+ !u.mapRef || S.dataRef !== u.mapRef || (Dt(_, $, g, S), Pt(r, C(u), S));
653
886
  }
654
887
  };
655
888
  }
656
- const Rt = 134217728, me = 4, he = 32;
657
- function ye(t) {
889
+ const Gt = 134217728, Xe = 4, Ze = 32;
890
+ function to(t) {
658
891
  return Array.isArray(t) ? t.join(`
659
892
  `) : t;
660
893
  }
661
- function v(t) {
894
+ function R(t) {
662
895
  return !!t && typeof t == "object" && !Array.isArray(t) && typeof t.fromFeature == "object" && t.fromFeature !== null;
663
896
  }
664
- function T(t, e) {
897
+ function N(t, e) {
665
898
  return t instanceof Map ? t.get(e) : t[e];
666
899
  }
667
- function F(t, e) {
668
- return e.split(".").reduce((r, o) => {
669
- if (!(r == null || typeof r != "object"))
670
- return r[o];
900
+ function x(t, e) {
901
+ return e.split(".").reduce((o, r) => {
902
+ if (!(o == null || typeof o != "object"))
903
+ return o[r];
671
904
  }, t);
672
905
  }
673
- function St(t) {
906
+ function Ut(t) {
674
907
  const e = [];
675
- for (const r of [t.uniforms, t.uniformMatrices])
676
- for (const o of Object.values(r ?? {}))
677
- v(o) && e.push(o);
908
+ for (const o of [t.uniforms, t.uniformMatrices])
909
+ for (const r of Object.values(o ?? {}))
910
+ R(r) && e.push(r);
678
911
  return e;
679
912
  }
680
- function we(t) {
681
- return [.../* @__PURE__ */ new Set([t.dataRef, ...St(t).map((e) => e.fromFeature.layer)])];
913
+ function eo(t) {
914
+ return [.../* @__PURE__ */ new Set([t.dataRef, ...Ut(t).map((e) => e.fromFeature.layer)])];
682
915
  }
683
- function Ct(t) {
684
- for (const e of St(t)) {
685
- const { iterate: r, layer: o } = e.fromFeature;
686
- if (r === "all" || r === "batched") return { mode: r, layer: o };
916
+ function Wt(t) {
917
+ for (const e of Ut(t)) {
918
+ const { iterate: o, layer: r } = e.fromFeature;
919
+ if (o === "all" || o === "batched") return { mode: o, layer: r };
687
920
  }
688
921
  return null;
689
922
  }
690
- function It(t, e, r) {
691
- const o = t.fromFeature, n = r !== void 0 && o.iterate === "all" ? r : o.index ?? 0, s = T(e, o.layer)?.features?.[n];
692
- return s ? F(s, o.path) : void 0;
923
+ function Qt(t, e, o) {
924
+ const r = t.fromFeature, n = o !== void 0 && r.iterate === "all" ? o : r.index ?? 0, i = N(e, r.layer)?.features?.[n];
925
+ return i ? x(i, r.path) : void 0;
693
926
  }
694
- function it(t, e, r) {
927
+ function mt(t, e, o) {
695
928
  if (!t) return;
696
- const o = {};
697
- for (const [n, s] of Object.entries(t)) {
698
- if (!v(s)) {
699
- o[n] = s;
929
+ const r = {};
930
+ for (const [n, i] of Object.entries(t)) {
931
+ if (!R(i)) {
932
+ r[n] = i;
700
933
  continue;
701
934
  }
702
- const a = Number(It(s, e, r) ?? NaN);
703
- Number.isFinite(a) ? o[n] = a : typeof s.default == "number" && (o[n] = s.default);
935
+ const a = Number(Qt(i, e, o) ?? NaN);
936
+ Number.isFinite(a) ? r[n] = a : typeof i.default == "number" && (r[n] = i.default);
704
937
  }
705
- return o;
938
+ return r;
706
939
  }
707
- function st(t, e, r) {
940
+ function yt(t, e, o) {
708
941
  if (!t) return;
709
- const o = {};
710
- for (const [n, s] of Object.entries(t)) {
711
- if (!v(s)) {
712
- o[n] = s;
942
+ const r = {};
943
+ for (const [n, i] of Object.entries(t)) {
944
+ if (!R(i)) {
945
+ r[n] = i;
713
946
  continue;
714
947
  }
715
- const a = It(s, e, r), i = Array.isArray(a) ? a : Array.isArray(s.default) ? s.default : void 0;
716
- if (!i) continue;
717
- const l = s.cols ?? (Array.isArray(i[0]) ? i[0].length : 0);
718
- l > 0 ? o[n] = { data: i, cols: l } : console.warn(`[autk-grammar] uniform matrix "${n}" has no column count; entry dropped`);
948
+ const a = Qt(i, e, o), l = Array.isArray(a) ? a : Array.isArray(i.default) ? i.default : void 0;
949
+ if (!l) continue;
950
+ const s = i.cols ?? (Array.isArray(l[0]) ? l[0].length : 0);
951
+ s > 0 ? r[n] = { data: l, cols: s } : console.warn(`[autk-grammar] uniform matrix "${n}" has no column count; entry dropped`);
719
952
  }
720
- return o;
953
+ return r;
721
954
  }
722
- function ge(t) {
955
+ function oo(t) {
723
956
  return t != null && !(typeof t == "number" && !Number.isFinite(t));
724
957
  }
725
- function lt(t) {
726
- return v(t) && t.fromFeature.iterate === "batched";
958
+ function gt(t) {
959
+ return R(t) && t.fromFeature.iterate === "batched";
727
960
  }
728
- function Lt(t, e) {
729
- return Object.values(e ?? {}).some(lt) ? he : Object.values(t ?? {}).some(lt) ? me : 0;
961
+ function Vt(t, e) {
962
+ return Object.values(e ?? {}).some(gt) ? Ze : Object.values(t ?? {}).some(gt) ? Xe : 0;
730
963
  }
731
- function be(t, e, r = Rt) {
732
- const o = Lt(t, e);
733
- return o > 0 ? Math.floor(r / o) : Number.POSITIVE_INFINITY;
964
+ function ro(t, e, o = Gt) {
965
+ const r = Vt(t, e);
966
+ return r > 0 ? Math.floor(o / r) : Number.POSITIVE_INFINITY;
734
967
  }
735
- function _e(t, e, r, o = Rt) {
736
- const n = {}, s = {}, a = [];
737
- for (const l of [t, e])
738
- for (const u of Object.values(l ?? {}))
739
- v(u) && u.fromFeature.iterate === "batched" && u.fromFeature.required && a.push(u.fromFeature.path);
968
+ function no(t, e, o, r = Gt) {
969
+ const n = {}, i = {}, a = [];
970
+ for (const s of [t, e])
971
+ for (const u of Object.values(s ?? {}))
972
+ R(u) && u.fromFeature.iterate === "batched" && u.fromFeature.required && a.push(u.fromFeature.path);
740
973
  if (a.length > 0) {
741
- const l = r.length;
742
- r = r.filter((u) => a.every((d) => ge(F(u, d)))), r.length < l && console.info(`[autk-grammar] batched compute dropped ${l - r.length} feature(s) missing ${a.join(", ")}`);
974
+ const s = o.length;
975
+ o = o.filter((u) => a.every((d) => oo(x(u, d)))), o.length < s && console.info(`[autk-grammar] batched compute dropped ${s - o.length} feature(s) missing ${a.join(", ")}`);
743
976
  }
744
- const i = be(t, e, o);
745
- r.length > i && (console.warn(
746
- `[autk-grammar] batched compute capped at ${i} features (got ${r.length}): its largest packed array takes ${Lt(t, e)} B per feature, and a storage buffer binding holds ${o} B`
747
- ), r = r.slice(0, i));
748
- for (const [l, u] of Object.entries(t ?? {}))
749
- if (v(u) && u.fromFeature.iterate === "batched") {
977
+ const l = ro(t, e, r);
978
+ o.length > l && (console.warn(
979
+ `[autk-grammar] batched compute capped at ${l} features (got ${o.length}): its largest packed array takes ${Vt(t, e)} B per feature, and a storage buffer binding holds ${r} B`
980
+ ), o = o.slice(0, l));
981
+ for (const [s, u] of Object.entries(t ?? {}))
982
+ if (R(u) && u.fromFeature.iterate === "batched") {
750
983
  const d = typeof u.default == "number" ? u.default : void 0;
751
- s[l] = r.map((c) => {
752
- const f = Number(F(c, u.fromFeature.path) ?? d);
753
- return Number.isFinite(f) ? f : 0;
984
+ i[s] = o.map((f) => {
985
+ const c = Number(x(f, u.fromFeature.path) ?? d);
986
+ return Number.isFinite(c) ? c : 0;
754
987
  });
755
- } else typeof u == "number" && (n[l] = u);
756
- for (const [l, u] of Object.entries(e ?? {})) {
757
- if (!v(u) || u.fromFeature.iterate !== "batched") continue;
988
+ } else typeof u == "number" && (n[s] = u);
989
+ for (const [s, u] of Object.entries(e ?? {})) {
990
+ if (!R(u) || u.fromFeature.iterate !== "batched") continue;
758
991
  const d = [];
759
- for (const c of r) {
760
- const f = F(c, u.fromFeature.path);
761
- let y = 1 / 0, m = 1 / 0, h = -1 / 0, p = -1 / 0;
762
- if (Array.isArray(f))
763
- for (const w of f) {
764
- if (!Array.isArray(w) || w.length < 2) continue;
765
- const _ = Number(w[0]), E = Number(w[1]);
766
- !Number.isFinite(_) || !Number.isFinite(E) || (y = Math.min(y, _), m = Math.min(m, E), h = Math.max(h, _), p = Math.max(p, E));
992
+ for (const f of o) {
993
+ const c = x(f, u.fromFeature.path);
994
+ let h = 1 / 0, m = 1 / 0, y = -1 / 0, p = -1 / 0;
995
+ if (Array.isArray(c))
996
+ for (const g of c) {
997
+ if (!Array.isArray(g) || g.length < 2) continue;
998
+ const _ = Number(g[0]), $ = Number(g[1]);
999
+ !Number.isFinite(_) || !Number.isFinite($) || (h = Math.min(h, _), m = Math.min(m, $), y = Math.max(y, _), p = Math.max(p, $));
767
1000
  }
768
- Number.isFinite(y) || (y = 0, m = 0, h = 0, p = 0), d.push(y, m, h, m, h, p, y, p);
1001
+ Number.isFinite(h) || (h = 0, m = 0, y = 0, p = 0), d.push(h, m, y, m, y, p, h, p);
769
1002
  }
770
- s[l] = d;
1003
+ i[s] = d;
771
1004
  }
772
- return n.num_features = r.length, { uniforms: n, uniformArrays: s };
1005
+ return n.num_features = o.length, { uniforms: n, uniformArrays: i };
773
1006
  }
774
- function ut(t, e, r) {
775
- const o = T(e, t.dataRef);
776
- if (!o) throw new Error(`compute: table "${t.dataRef}" is not loaded`);
1007
+ function wt(t, e, o) {
1008
+ const r = N(e, t.dataRef);
1009
+ if (!r) throw new Error(`compute: table "${t.dataRef}" is not loaded`);
777
1010
  const n = {
778
- collection: o,
1011
+ collection: r,
779
1012
  variableMapping: t.attributes,
780
- wgslBody: ye(t.wgslFunction)
1013
+ wgslBody: to(t.wgslFunction)
781
1014
  };
782
1015
  t.attributeArrays && (n.attributeArrays = t.attributeArrays), t.attributeMatrices && (n.attributeMatrices = t.attributeMatrices), t.uniformArrays && (n.uniformArrays = t.uniformArrays), t.outputColumnName && (n.resultField = t.outputColumnName), t.outputColumns && (n.outputColumns = t.outputColumns);
783
- const s = Ct(t);
784
- if (s?.mode === "batched") {
785
- const u = T(e, s.layer)?.features ?? [], d = _e(t.uniforms, t.uniformMatrices, u), c = it(ct(t.uniforms), e) ?? {}, f = st(ct(t.uniformMatrices), e);
786
- return n.uniforms = { ...c, ...d.uniforms }, n.uniformArrays = { ...n.uniformArrays ?? {}, ...d.uniformArrays }, f && Object.keys(f).length > 0 && (n.uniformMatrices = f), n;
1016
+ const i = Wt(t);
1017
+ if (i?.mode === "batched") {
1018
+ const u = N(e, i.layer)?.features ?? [], d = no(t.uniforms, t.uniformMatrices, u), f = mt(bt(t.uniforms), e) ?? {}, c = yt(bt(t.uniformMatrices), e);
1019
+ return n.uniforms = { ...f, ...d.uniforms }, n.uniformArrays = { ...n.uniformArrays ?? {}, ...d.uniformArrays }, c && Object.keys(c).length > 0 && (n.uniformMatrices = c), n;
787
1020
  }
788
- const a = s?.mode === "all" ? r : void 0, i = it(t.uniforms, e, a), l = st(t.uniformMatrices, e, a);
789
- return i && (n.uniforms = i), l && (n.uniformMatrices = l), n;
1021
+ const a = i?.mode === "all" ? o : void 0, l = mt(t.uniforms, e, a), s = yt(t.uniformMatrices, e, a);
1022
+ return l && (n.uniforms = l), s && (n.uniformMatrices = s), n;
790
1023
  }
791
- function ct(t) {
1024
+ function bt(t) {
792
1025
  if (t)
793
- return Object.fromEntries(Object.entries(t).filter(([, e]) => !(v(e) && e.fromFeature.iterate === "batched")));
1026
+ return Object.fromEntries(Object.entries(t).filter(([, e]) => !(R(e) && e.fromFeature.iterate === "batched")));
794
1027
  }
795
- function Ee(t) {
1028
+ function ao(t) {
796
1029
  return t.outputColumns ?? (t.outputColumnName ? [t.outputColumnName] : []);
797
1030
  }
798
- async function Me(t, e, r) {
799
- const o = Ct(t);
800
- if (o?.mode !== "all") return r(ut(t, e));
801
- const n = T(e, t.dataRef);
1031
+ async function io(t, e, o) {
1032
+ const r = Wt(t);
1033
+ if (r?.mode !== "all") return o(wt(t, e));
1034
+ const n = N(e, t.dataRef);
802
1035
  if (!n) throw new Error(`compute: table "${t.dataRef}" is not loaded`);
803
- const s = Ee(t), a = structuredClone(n);
804
- for (const l of a.features) {
805
- const u = l.properties ??= {}, d = u.compute ??= {};
806
- for (const c of s) d[c] = 0;
1036
+ const i = ao(t), a = structuredClone(n);
1037
+ for (const s of a.features) {
1038
+ const u = s.properties ??= {}, d = u.compute ??= {};
1039
+ for (const f of i) d[f] = 0;
807
1040
  }
808
- const i = T(e, o.layer)?.features?.length ?? 0;
809
- for (let l = 0; l < i; l++) {
810
- const u = await r({ ...ut(t, e, l), collection: a });
811
- a.features.forEach((d, c) => {
812
- const f = d.properties?.compute, y = u.features[c]?.properties?.compute;
813
- if (!(!f || !y))
814
- for (const m of s) {
815
- const h = Number(y[m]);
816
- Number.isFinite(h) && (f[m] += h);
1041
+ const l = N(e, r.layer)?.features?.length ?? 0;
1042
+ for (let s = 0; s < l; s++) {
1043
+ const u = await o({ ...wt(t, e, s), collection: a });
1044
+ a.features.forEach((d, f) => {
1045
+ const c = d.properties?.compute, h = u.features[f]?.properties?.compute;
1046
+ if (!(!c || !h))
1047
+ for (const m of i) {
1048
+ const y = Number(h[m]);
1049
+ Number.isFinite(y) && (c[m] += y);
817
1050
  }
818
1051
  });
819
1052
  }
820
1053
  return a;
821
1054
  }
822
- const ft = ["surface", "parks", "water", "roads", "buildings", "polygons", "polylines"];
823
- function Ae(t, e, r, o) {
824
- return o?.get(b(r, e)) ?? t.getTablesMetadata().find((n) => n.name === e)?.type;
1055
+ const vt = ["surface", "parks", "water", "roads", "buildings", "polygons", "polylines"];
1056
+ function so(t, e, o, r) {
1057
+ return r?.get(E(o, e)) ?? t.getTablesMetadata().find((n) => n.name === e)?.type;
825
1058
  }
826
- function ve(t, e) {
827
- async function r(a, i, l) {
828
- return t?.get(b(l, i)) ?? await a.getLayer(i);
1059
+ function lo(t, e, o) {
1060
+ async function r(l, s, u) {
1061
+ return t?.get(E(u, s)) ?? await l.getLayer(s);
829
1062
  }
830
- function o(a, i, l, u, d) {
1063
+ function n(l, s, u, d, f) {
831
1064
  if (!t) return;
832
- const c = u.outputTableName ?? l;
833
- t.set(b(u.workspace, c), i);
834
- const f = u.layerType ?? d ?? Ae(a, l, u.workspace, e);
835
- u.outputTableName && f && e?.set(b(u.workspace, c), f);
1065
+ const c = d.outputTableName ?? u;
1066
+ t.set(E(d.workspace, c), s);
1067
+ const h = d.layerType ?? f ?? so(l, u, d.workspace, e);
1068
+ d.outputTableName && h && e?.set(E(d.workspace, c), h);
836
1069
  }
837
- async function n(a, i) {
838
- for (const d of i.layers)
839
- if (!ft.includes(d.type))
840
- throw new Error(`Render pass "${i.outputTableName}": layer "${d.id}" has the type "${d.type}", which a render pass cannot draw. A layer's type is one of ${ft.join(", ")}.`);
841
- const l = await Promise.all(i.layers.map(async (d) => ({
842
- id: d.id,
843
- collection: await r(a, d.dataRef, i.workspace),
844
- type: d.type,
845
- objectIdProperty: d.objectIdProperty
846
- }))), u = await new Z().renderPipeline({
847
- layers: l,
1070
+ async function i(l, s) {
1071
+ for (const f of s.layers)
1072
+ if (!vt.includes(f.type))
1073
+ throw new Error(`Render pass "${s.outputTableName}": layer "${f.id}" has the type "${f.type}", which a render pass cannot draw. A layer's type is one of ${vt.join(", ")}.`);
1074
+ const u = await Promise.all(s.layers.map(async (f) => ({
1075
+ id: f.id,
1076
+ collection: await r(l, f.dataRef, s.workspace),
1077
+ type: f.type,
1078
+ objectIdProperty: f.objectIdProperty
1079
+ }))), d = await new at().renderPipeline({
1080
+ layers: u,
848
1081
  viewpoints: {
849
- collection: await r(a, i.viewpoints.dataRef, i.workspace),
850
- strategy: i.viewpoints.strategy,
851
- sampling: i.viewpoints.sampling
1082
+ collection: await r(l, s.viewpoints.dataRef, s.workspace),
1083
+ strategy: s.viewpoints.strategy,
1084
+ sampling: s.viewpoints.sampling
852
1085
  },
853
- aggregation: i.aggregation,
854
- camera: i.camera,
855
- tileSize: i.tileSize
1086
+ aggregation: s.aggregation,
1087
+ camera: s.camera,
1088
+ tileSize: s.tileSize
856
1089
  });
857
- o(a, u, i.viewpoints.dataRef, i, i.viewpoints.strategy?.type === "building-windows" ? "points" : void 0);
1090
+ n(l, d, s.viewpoints.dataRef, s, s.viewpoints.strategy?.type === "building-windows" ? "points" : void 0);
858
1091
  }
859
- async function s(a, i) {
860
- const l = {};
861
- for (const c of we(i)) {
862
- const f = t?.get(b(i.workspace, c));
863
- if (f) l[c] = f;
864
- else if (c === i.dataRef) l[c] = await a.getLayer(c);
1092
+ async function a(l, s) {
1093
+ const u = {}, d = l.getWorkspaceConfiguration().coordinateFormat;
1094
+ for (const h of eo(s)) {
1095
+ const m = E(s.workspace, h), y = t?.get(m) ?? (h === s.dataRef ? void 0 : re(o?.get(m), d));
1096
+ if (y) u[h] = y;
1097
+ else if (h === s.dataRef) u[h] = await l.getLayer(h);
865
1098
  else
866
1099
  try {
867
- l[c] = await a.getLayer(c);
1100
+ u[h] = await l.getLayer(h);
868
1101
  } catch {
869
- l[c] = void 0;
1102
+ u[h] = void 0;
870
1103
  }
871
1104
  }
872
- const u = new Z(), d = await Me(i, l, (c) => u.gpgpuPipeline(c));
873
- o(a, d, i.dataRef, i);
1105
+ const f = new at(), c = await io(s, u, (h) => f.gpgpuPipeline(h));
1106
+ n(l, c, s.dataRef, s);
874
1107
  }
875
1108
  return {
876
- async resolveCompute(a, i) {
877
- if (a)
878
- return await I(a, i.workspace), i.type === "render" ? await n(a, i) : await s(a, i), a;
1109
+ async resolveCompute(l, s) {
1110
+ if (l)
1111
+ return await I(l, s.workspace), s.type === "render" ? await i(l, s) : await a(l, s), l;
879
1112
  }
880
1113
  };
881
1114
  }
882
- class Re {
1115
+ class uo {
883
1116
  _listeners = /* @__PURE__ */ new Map();
884
- on(e, r) {
1117
+ on(e, o) {
885
1118
  this._listeners.has(e) || this._listeners.set(e, /* @__PURE__ */ new Set());
886
- const o = this._listeners.get(e);
887
- return o.add(r), () => o.delete(r);
1119
+ const r = this._listeners.get(e);
1120
+ return r.add(o), () => r.delete(o);
888
1121
  }
889
1122
  /** @internal */
890
- emit(e, r) {
891
- this._listeners.get(e)?.forEach((o) => o(r));
1123
+ emit(e, o) {
1124
+ this._listeners.get(e)?.forEach((r) => r(o));
892
1125
  }
893
1126
  }
894
- function C(t) {
1127
+ function v(t) {
895
1128
  return t === void 0 ? [] : Array.isArray(t) ? t : [t];
896
1129
  }
897
- function Se(t) {
1130
+ function fo(t) {
898
1131
  const e = /* @__PURE__ */ new Set();
899
- for (const o of [...C(t.map), ...C(t.plot)])
900
- if (o.id !== void 0) {
901
- if (o.id === "") throw new Error("A map or plot has an empty id.");
902
- if (e.has(o.id)) throw new Error(`Two maps or plots have the id "${o.id}"; an id names one view.`);
903
- e.add(o.id);
1132
+ for (const r of [...v(t.map), ...v(t.plot)])
1133
+ if (r.id !== void 0) {
1134
+ if (r.id === "") throw new Error("A map or plot has an empty id.");
1135
+ if (e.has(r.id)) throw new Error(`Two maps or plots have the id "${r.id}"; an id names one view.`);
1136
+ e.add(r.id);
904
1137
  }
905
- const r = /* @__PURE__ */ new Map();
906
- for (const o of C(t.plot)) {
907
- const n = N(o), s = r.get(n);
908
- if (s)
909
- throw new Error(s.id === void 0 && o.id === void 0 ? `Two plots of the table "${n}" have no id; give each plot an id.` : `A plot's id "${n}" is the dataRef of a plot without an id; give each plot an id.`);
910
- r.set(n, o);
1138
+ const o = /* @__PURE__ */ new Map();
1139
+ for (const r of v(t.plot)) {
1140
+ const n = C(r), i = o.get(n);
1141
+ if (i)
1142
+ throw new Error(i.id === void 0 && r.id === void 0 ? `Two plots of the table "${n}" have no id; give each plot an id.` : `A plot's id "${n}" is the dataRef of a plot without an id; give each plot an id.`);
1143
+ o.set(n, r);
911
1144
  }
912
1145
  }
913
- class $e {
1146
+ class wo {
914
1147
  dataAdapter;
915
1148
  mapAdapter;
916
1149
  plotAdapter;
@@ -928,9 +1161,9 @@ class $e {
928
1161
  _exports = /* @__PURE__ */ new Map();
929
1162
  /** Each GeoJSON table a run loaded and each table a join wrote, which its plots read before the database. */
930
1163
  _geojsonCache = /* @__PURE__ */ new Map();
931
- interactions = new Re();
1164
+ interactions = new uo();
932
1165
  constructor(e) {
933
- this.dataAdapter = Vt(e, this._geojsonCache), this.mapAdapter = ce(e, this._layers, this._computeCache, this._maps, this._computeTypes, this._exports), this.plotAdapter = pe(e, this._layers, this._plotRegistry, this._plotLinks, this._geojsonCache, this._computeCache, this._plotRows, this._exports), this.computeAdapter = ve(this._computeCache, this._computeTypes);
1166
+ this.dataAdapter = fe(e, this._geojsonCache), this.mapAdapter = Oe(e, this._layers, this._computeCache, this._maps, this._computeTypes, this._exports), this.plotAdapter = ze(e, this._layers, this._plotRegistry, this._plotLinks, this._geojsonCache, this._computeCache, this._plotRows, this._exports), this.computeAdapter = lo(this._computeCache, this._computeTypes, this._geojsonCache);
934
1167
  }
935
1168
  /**
936
1169
  * The coordinate reference system autk-db stores a workspace's tables in, unless the spec's `workspaces` sets
@@ -942,7 +1175,7 @@ class $e {
942
1175
  * instead of hard-coding a CRS string.
943
1176
  */
944
1177
  get workspaceCrs() {
945
- return $t;
1178
+ return qt;
946
1179
  }
947
1180
  get data() {
948
1181
  return this._data;
@@ -967,8 +1200,8 @@ class $e {
967
1200
  * @param mapId The map to look in, by its {@link MapId}: a string names a map by its `id`, a number by its index in
968
1201
  * the spec's `map` list. Without it, every map.
969
1202
  */
970
- mapLayers(e, r) {
971
- return this._layersOf(e, r).map(({ map: o, layerId: n }) => ({ map: o, layerId: n }));
1203
+ mapLayers(e, o) {
1204
+ return this._layersOf(e, o).map(({ map: r, layerId: n }) => ({ map: r, layerId: n }));
972
1205
  }
973
1206
  /**
974
1207
  * The layer a map of the last {@link run} draws for a table, found by the table's name (a layer's `dataRef`):
@@ -984,12 +1217,12 @@ class $e {
984
1217
  * const layer = grammar.mapLayer('buildings');
985
1218
  * layer?.map.updateRenderInfo(layer.layerId, { opacity: 0.5 });
986
1219
  */
987
- mapLayer(e, r) {
988
- return this.mapLayers(e, r).pop();
1220
+ mapLayer(e, o) {
1221
+ return this.mapLayers(e, o).pop();
989
1222
  }
990
1223
  /** The drawn layers of a table, on every map or on the one `mapId` names. */
991
- _layersOf(e, r) {
992
- return this._layers.filter((o) => o.dataRef === e && U(o, r));
1224
+ _layersOf(e, o) {
1225
+ return this._layers.filter((r) => r.dataRef === e && Y(r, o));
993
1226
  }
994
1227
  /**
995
1228
  * Releases what the last run created: every map (its layers' GPU buffers, its textures, its canvas context, the
@@ -1013,7 +1246,10 @@ class $e {
1013
1246
  throw new Error("Plot adapter not initialized. Please call the constructor first.");
1014
1247
  if (!this.computeAdapter)
1015
1248
  throw new Error("Compute adapter not initialized. Please call the constructor first.");
1016
- Se(e), this.destroy(), this.grammarEngine = Bt({
1249
+ fo(e);
1250
+ for (const i of v(e.plot)) Ge(i);
1251
+ const o = Ue(v(e.plot));
1252
+ this.destroy(), v(e.plot).length > 0 && qe(o), this.grammarEngine = Xt({
1017
1253
  spec: e,
1018
1254
  adapters: {
1019
1255
  db: this.dataAdapter,
@@ -1023,27 +1259,27 @@ class $e {
1023
1259
  }
1024
1260
  }), await this.grammarEngine.run();
1025
1261
  const r = this.grammarEngine.context;
1026
- if (r && await I(r), this._wireLinks(e), this._rewireInteractions(e), !r) {
1262
+ if (r && await I(r), this._wireLinks(e), this._pickFromTheStart(e), this._selectFromTheStart(e), this._rewireInteractions(e), !r) {
1027
1263
  console.warn("Grammar engine produced no data context."), this._data = {};
1028
1264
  return;
1029
1265
  }
1030
- const o = {};
1031
- for (const n of r.getLayersMetadata())
1032
- Object.defineProperty(o, n.name, {
1266
+ const n = {};
1267
+ for (const i of r.getLayersMetadata())
1268
+ Object.defineProperty(n, i.name, {
1033
1269
  get: () => {
1034
- const s = this._computeCache.get(n.name);
1035
- return s ? Promise.resolve(s) : r.getLayer(n.name);
1270
+ const a = this._computeCache.get(i.name);
1271
+ return a ? Promise.resolve(a) : r.getLayer(i.name);
1036
1272
  },
1037
1273
  enumerable: !0,
1038
1274
  configurable: !0
1039
1275
  });
1040
- for (const n of this._computeCache.keys())
1041
- n in o || Object.defineProperty(o, n, {
1042
- get: () => Promise.resolve(this._computeCache.get(n)),
1276
+ for (const i of this._computeCache.keys())
1277
+ i in n || Object.defineProperty(n, i, {
1278
+ get: () => Promise.resolve(this._computeCache.get(i)),
1043
1279
  enumerable: !0,
1044
1280
  configurable: !0
1045
1281
  });
1046
- this._data = o;
1282
+ this._data = n;
1047
1283
  }
1048
1284
  /**
1049
1285
  * Highlights features on every layer that draws the table `dataRef`, in every map (see {@link mapLayers}), or only
@@ -1056,10 +1292,10 @@ class $e {
1056
1292
  * @param mapId The map to highlight on, by its {@link MapId}: a string names a map by its `id`, a number by its
1057
1293
  * index in the spec's `map` list. Without it, every map that draws the table.
1058
1294
  */
1059
- highlightOnMap(e, r, o) {
1060
- const n = this._layersOf(e, o);
1061
- for (const { map: s, layerId: a } of n) s.setHighlightedIds(a, r);
1062
- this._selectInLinkedPlots(n, r);
1295
+ highlightOnMap(e, o, r) {
1296
+ const n = this._layersOf(e, r);
1297
+ for (const { map: i, layerId: a } of n) i.setHighlightedIds(a, o);
1298
+ this._selectInLinkedPlots(n, o);
1063
1299
  }
1064
1300
  /**
1065
1301
  * Clears highlighted features on every layer that draws the table `dataRef`, in every map (see {@link mapLayers}),
@@ -1070,10 +1306,10 @@ class $e {
1070
1306
  * @param mapId The map to clear, by its {@link MapId}: a string names a map by its `id`, a number by its index in
1071
1307
  * the spec's `map` list. Without it, every map that draws the table.
1072
1308
  */
1073
- clearHighlightOnMap(e, r) {
1074
- const o = this._layersOf(e, r);
1075
- for (const { map: n, layerId: s } of o) n.clearHighlightedIds(s);
1076
- this._selectInLinkedPlots(o, []);
1309
+ clearHighlightOnMap(e, o) {
1310
+ const r = this._layersOf(e, o);
1311
+ for (const { map: n, layerId: i } of r) n.clearHighlightedIds(i);
1312
+ this._selectInLinkedPlots(r, []);
1077
1313
  }
1078
1314
  /**
1079
1315
  * Clears the selection on the plot `plotId` names: its `id`, else its `dataRef`.
@@ -1084,10 +1320,10 @@ class $e {
1084
1320
  * @param mapId The map whose linked layers to clear, by its {@link MapId}: a string names a map by its `id`, a
1085
1321
  * number by its index in the spec's `map` list. Without it, every linked layer.
1086
1322
  */
1087
- clearHighlightOnPlot(e, r) {
1323
+ clearHighlightOnPlot(e, o) {
1088
1324
  this._plotRegistry.get(e)?.setSelection([]);
1089
- for (const o of this._plotLinks.get(e) ?? [])
1090
- U(o, r) && o.map.clearHighlightedIds(o.layerId);
1325
+ for (const r of this._plotLinks.get(e) ?? [])
1326
+ Y(r, o) && r.map.clearHighlightedIds(r.layerId);
1091
1327
  }
1092
1328
  /**
1093
1329
  * Applies a selection to the plot `plotId` names: its `id`, else its `dataRef`.
@@ -1099,86 +1335,121 @@ class $e {
1099
1335
  * @param mapId The map whose linked layers to highlight, by its {@link MapId}: a string names a map by its `id`, a
1100
1336
  * number by its index in the spec's `map` list. Without it, every linked layer.
1101
1337
  */
1102
- setPlotSelection(e, r, o) {
1103
- this._plotRegistry.get(e)?.setSelection(r);
1338
+ setPlotSelection(e, o, r) {
1339
+ this._plotRegistry.get(e)?.setSelection(o);
1104
1340
  const n = this._plotRows.get(e) ?? [];
1105
- for (const s of this._plotLinks.get(e) ?? [])
1106
- U(s, o) && s.map.setHighlightedIds(s.layerId, x(r, n, s.rows));
1341
+ for (const i of this._plotLinks.get(e) ?? [])
1342
+ Y(i, r) && i.map.setHighlightedIds(i.layerId, D(o, n, i.rows));
1107
1343
  }
1108
1344
  /**
1109
1345
  * Applies a selection made on `layers`, by their positions `featureIds`, to every plot linked to one of them, at the
1110
1346
  * plot's own positions of the selected rows.
1111
1347
  */
1112
- _selectInLinkedPlots(e, r) {
1113
- for (const [o, n] of this._plotLinks) {
1114
- const s = n.filter((l) => e.includes(l));
1115
- if (s.length === 0) continue;
1116
- const a = this._plotRows.get(o) ?? [], i = new Set(s.flatMap((l) => x(r, l.rows, a)));
1117
- this._plotRegistry.get(o)?.setSelection([...i]);
1348
+ _selectInLinkedPlots(e, o) {
1349
+ for (const [r, n] of this._plotLinks) {
1350
+ const i = n.filter((s) => e.includes(s));
1351
+ if (i.length === 0) continue;
1352
+ const a = this._plotRows.get(r) ?? [], l = new Set(i.flatMap((s) => D(o, s.rows, a)));
1353
+ this._plotRegistry.get(r)?.setSelection([...l]);
1118
1354
  }
1119
1355
  }
1120
1356
  /** Wires each entry of `links` between a plot and a layer of a map, both now drawn. */
1121
1357
  _wireLinks(e) {
1122
- const r = C(e.map), o = C(e.plot);
1358
+ const o = v(e.map), r = v(e.plot);
1123
1359
  for (const n of e.links ?? []) {
1124
- const s = o.find((c) => N(c) === n.source), a = this._plotRegistry.get(n.source);
1125
- if (!s || !a)
1360
+ const i = r.find((f) => C(f) === n.source), a = this._plotRegistry.get(n.source);
1361
+ if (!i || !a)
1126
1362
  throw new Error(`Link source "${n.source}" is not the id (or the dataRef) of a plot of this specification.`);
1127
- const i = r.findIndex((c) => c.id === n.target), l = this._maps[i];
1128
- if (i < 0 || !l)
1363
+ const l = o.findIndex((f) => f.id === n.target), s = this._maps[l];
1364
+ if (l < 0 || !s)
1129
1365
  throw new Error(`Link target "${n.target}" is not the id of a map of this specification.`);
1130
- const u = r[i].layerRefs.find((c) => n.layer !== void 0 ? R(c) === n.layer : c.dataRef === s.dataRef);
1366
+ const u = o[l].layerRefs.find((f) => n.layer !== void 0 ? b(f) === n.layer : f.dataRef === i.dataRef);
1131
1367
  if (!u)
1132
- throw new Error(n.layer !== void 0 ? `Link from "${n.source}": map "${n.target}" has no layer "${n.layer}".` : `Link from "${n.source}": map "${n.target}" draws no layer of the table "${s.dataRef}"; name the layer.`);
1133
- const d = this._layers.find((c) => c.mapIndex === i && c.layerId === R(u));
1134
- d && (vt(a, this._plotRows.get(n.source) ?? [], s.events ?? [], d), Et(this._plotLinks, n.source, d));
1368
+ throw new Error(n.layer !== void 0 ? `Link from "${n.source}": map "${n.target}" has no layer "${n.layer}".` : `Link from "${n.source}": map "${n.target}" draws no layer of the table "${i.dataRef}"; name the layer.`);
1369
+ const d = this._layers.find((f) => f.mapIndex === l && f.layerId === b(u));
1370
+ d && (Dt(a, this._plotRows.get(n.source) ?? [], i.events ?? [], d), Pt(this._plotLinks, n.source, d));
1135
1371
  }
1136
1372
  }
1373
+ /**
1374
+ * Draws each layer's `pickedComps` as picked once the maps, the plots and their links exist, as `highlightOnMap` does
1375
+ * for that one layer: the layer highlights the features, and the plots linked to it select the same rows. autk-map
1376
+ * draws picked features only on the layer of a map that picks, and lets one layer of a map pick, so a layer that no
1377
+ * longer picks, since a link or a plot's `mapRef` made another layer of its map pick, is refused. So is one linked to a
1378
+ * plot that sets `selection`, which sets what both show too.
1379
+ */
1380
+ _pickFromTheStart(e) {
1381
+ const o = v(e.plot);
1382
+ v(e.map).forEach((r, n) => {
1383
+ for (const i of r.layerRefs) {
1384
+ if (!i.pickedComps) continue;
1385
+ const a = b(i), l = this._layers.find((u) => u.mapIndex === n && u.layerId === a);
1386
+ if (!l) continue;
1387
+ const s = l.map.activePickingLayer?.layerInfo.id;
1388
+ if (s !== a)
1389
+ throw new Error(`Layer "${a}": pickedComps draws features as picked on the layer that picks, but ${s === void 0 ? "no layer of its map picks" : `a link or a plot's mapRef made layer "${s}" of its map pick`}: autk-map lets one layer of a map pick.`);
1390
+ for (const [u, d] of this._plotLinks) {
1391
+ const f = o.find((c) => C(c) === u);
1392
+ if (d.includes(l) && (f?.selection?.length ?? 0) > 0)
1393
+ throw new Error(`Layer "${a}": pickedComps and the selection of plot "${u}", which is linked to it, both set what the two show: set one of them.`);
1394
+ }
1395
+ l.map.setHighlightedIds(a, i.pickedComps), this._selectInLinkedPlots([l], i.pickedComps);
1396
+ }
1397
+ });
1398
+ }
1399
+ /**
1400
+ * Applies each plot's `selection` once the plots and their links exist, as `setPlotSelection` does: the plot selects
1401
+ * the rows, and the layers it is linked to, by `mapRef` or `links`, highlight them. autk-plot's `setSelection` emits
1402
+ * no event, so no `plot:selection` reports it.
1403
+ */
1404
+ _selectFromTheStart(e) {
1405
+ for (const o of v(e.plot))
1406
+ o.selection && o.selection.length > 0 && this.setPlotSelection(C(o), o.selection);
1407
+ }
1137
1408
  _rewireInteractions(e) {
1138
- for (const o of this._fwdCleanups) o();
1409
+ for (const r of this._fwdCleanups) r();
1139
1410
  this._fwdCleanups = [];
1140
- const r = C(e.map);
1141
- this._maps.forEach((o, n) => {
1142
- const s = _t(r[n], n), a = ({ layerId: i, selection: l }) => {
1143
- this.interactions.emit("map:picking", { mapId: s, layerId: i, selection: l });
1411
+ const o = v(e.map);
1412
+ this._maps.forEach((r, n) => {
1413
+ const i = Lt(o[n], n), a = ({ layerId: l, selection: s }) => {
1414
+ this.interactions.emit("map:picking", { mapId: i, layerId: l, selection: s });
1144
1415
  };
1145
- o.events.on(Q.PICKING, a), this._fwdCleanups.push(() => o.events.off(Q.PICKING, a));
1416
+ r.events.on(J.PICKING, a), this._fwdCleanups.push(() => r.events.off(J.PICKING, a));
1146
1417
  });
1147
- for (const [o, n] of this._plotRegistry)
1148
- for (const s of [k.CLICK, k.BRUSH, k.BRUSH_X, k.BRUSH_Y]) {
1149
- const a = ({ selection: i }) => {
1418
+ for (const [r, n] of this._plotRegistry)
1419
+ for (const i of [B.CLICK, B.BRUSH, B.BRUSH_X, B.BRUSH_Y]) {
1420
+ const a = ({ selection: l }) => {
1150
1421
  this.interactions.emit("plot:selection", {
1151
- plotId: o,
1152
- event: s,
1153
- selection: i
1422
+ plotId: r,
1423
+ event: i,
1424
+ selection: l
1154
1425
  });
1155
1426
  };
1156
- n.events.on(s, a), this._fwdCleanups.push(() => n.events.off(s, a));
1427
+ n.events.on(i, a), this._fwdCleanups.push(() => n.events.off(i, a));
1157
1428
  }
1158
1429
  }
1159
1430
  }
1160
1431
  export {
1161
- $e as AutkGrammar,
1162
- xt as ColorMapInterpolator,
1163
- Re as GrammarEventEmitter,
1164
- pt as NormalizationMode,
1165
- Rt as STORAGE_BUFFER_BINDING_SIZE,
1166
- le as applyCamera,
1167
- Te as arrangeViews,
1168
- _e as buildBatchedUniforms,
1169
- we as computeLayerNames,
1170
- ve as createComputeAdapter,
1171
- Vt as createDataAdapter,
1172
- Bt as createEngine,
1432
+ wo as AutkGrammar,
1433
+ Zt as ColorMapInterpolator,
1434
+ uo as GrammarEventEmitter,
1435
+ Ct as NormalizationMode,
1436
+ Gt as STORAGE_BUFFER_BINDING_SIZE,
1437
+ Pe as applyCamera,
1438
+ go as arrangeViews,
1439
+ no as buildBatchedUniforms,
1440
+ eo as computeLayerNames,
1441
+ lo as createComputeAdapter,
1442
+ fe as createDataAdapter,
1443
+ Xt as createEngine,
1173
1444
  I as enterWorkspace,
1174
- Ct as findIterateSource,
1175
- v as isFromFeature,
1176
- ye as joinWgsl,
1177
- be as maxBatchedFeatures,
1178
- ut as resolveComputeParams,
1179
- st as resolveUniformMatrices,
1180
- it as resolveUniforms,
1181
- Me as runCompute,
1182
- b as tableKey
1445
+ Wt as findIterateSource,
1446
+ R as isFromFeature,
1447
+ to as joinWgsl,
1448
+ ro as maxBatchedFeatures,
1449
+ wt as resolveComputeParams,
1450
+ yt as resolveUniformMatrices,
1451
+ mt as resolveUniforms,
1452
+ io as runCompute,
1453
+ E as tableKey
1183
1454
  };
1184
1455
  //# sourceMappingURL=autk-grammar.js.map