@urban-toolkit/autk-grammar 4.3.0 → 4.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,49 +1,49 @@
1
- import { AutkDb as J, DEFAULT_WORKSPACE_COORDINATE_FORMAT as V } from "@urban-toolkit/autk-db";
2
- import { AutkMap as K, MapEvent as N } from "@urban-toolkit/autk-map";
3
- import { AutkPlot as z, PlotEvent as I } from "@urban-toolkit/autk-plot";
4
- import { ColorMapInterpolator as Z, ColorMapDomainStrategy as S, ColorMap as P } from "@urban-toolkit/autk-core";
5
- import { AutkComputeEngine as tt } from "@urban-toolkit/autk-compute";
6
- function et(t) {
1
+ import { AutkDb as z, DEFAULT_WORKSPACE_COORDINATE_FORMAT as k } from "@urban-toolkit/autk-db";
2
+ import { AutkMap as Z, MapEvent as B } from "@urban-toolkit/autk-map";
3
+ import { AutkPlot as tt, PlotEvent as I } from "@urban-toolkit/autk-plot";
4
+ import { ColorMapInterpolator as et, ColorMapDomainStrategy as M, ColorMap as v } from "@urban-toolkit/autk-core";
5
+ import { AutkComputeEngine as rt } from "@urban-toolkit/autk-compute";
6
+ function ot(t) {
7
7
  const { spec: e, adapters: r } = t;
8
8
  let o;
9
9
  async function i() {
10
- let n;
10
+ let a;
11
11
  if (e.data)
12
12
  for (const s of e.data)
13
- n = await r.db.resolveSource(n, s);
13
+ a = await r.db.resolveSource(a, s);
14
14
  if (e.compute)
15
15
  for (const s of e.compute)
16
- n = await r.compute.resolveCompute(n, s);
16
+ a = await r.compute.resolveCompute(a, s);
17
17
  if (e.map)
18
18
  if (Array.isArray(e.map))
19
19
  for (let s = 0; s < e.map.length; s++) {
20
- let c = e.map[s];
21
- await r.map.resolveMap(n, c, s);
20
+ let u = e.map[s];
21
+ await r.map.resolveMap(a, u, s);
22
22
  }
23
23
  else
24
- await r.map.resolveMap(n, e.map);
24
+ await r.map.resolveMap(a, e.map);
25
25
  if (e.plot)
26
26
  if (Array.isArray(e.plot))
27
27
  for (const s of e.plot)
28
- await r.plot.resolvePlot(n, s);
28
+ await r.plot.resolvePlot(a, s);
29
29
  else
30
- await r.plot.resolvePlot(n, e.plot);
31
- o = n;
30
+ await r.plot.resolvePlot(a, e.plot);
31
+ o = a;
32
32
  }
33
- function a(n) {
34
- return console.log("Spec to update", n), new Promise((s) => {
33
+ function n(a) {
34
+ return console.log("Spec to update", a), new Promise((s) => {
35
35
  s();
36
36
  });
37
37
  }
38
38
  function l() {
39
39
  console.log("Function not implemented yet");
40
40
  }
41
- return { run: i, updatedSpec: a, destroy: l, get context() {
41
+ return { run: i, updatedSpec: n, destroy: l, get context() {
42
42
  return o;
43
43
  } };
44
44
  }
45
- var rt = /* @__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))(rt || {}), Y = /* @__PURE__ */ ((t) => (t.MIN_MAX = "minMax", t.PERCENTILE = "percentile", t))(Y || {});
46
- function ot(t) {
45
+ var nt = /* @__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))(nt || {}), H = /* @__PURE__ */ ((t) => (t.MIN_MAX = "minMax", t.PERCENTILE = "percentile", t))(H || {});
46
+ function at(t) {
47
47
  const { queryArea: e } = t;
48
48
  if (e.bbox === void 0) return { geocodeArea: e.geocodeArea, areas: e.areas };
49
49
  const r = (s) => new Error(`OSM source "${t.outputTableName}": ${s}`);
@@ -52,95 +52,116 @@ function ot(t) {
52
52
  const o = e.bbox;
53
53
  if (!Array.isArray(o) || o.length !== 4 || !o.every((s) => typeof s == "number" && Number.isFinite(s)))
54
54
  throw r("queryArea.bbox must hold four numbers, [west, south, east, north] in degrees.");
55
- const [i, a, l, n] = e.bbox;
55
+ const [i, n, l, a] = e.bbox;
56
56
  if (Math.abs(i) > 180 || Math.abs(l) > 180)
57
57
  throw r("queryArea.bbox west and east must be longitudes from -180 to 180.");
58
- if (Math.abs(a) > 90 || Math.abs(n) > 90)
58
+ if (Math.abs(n) > 90 || Math.abs(a) > 90)
59
59
  throw r("queryArea.bbox south and north must be latitudes from -90 to 90.");
60
60
  if (i >= l)
61
61
  throw r(`queryArea.bbox west (${i}) must be less than east (${l}); a box across the antimeridian is not supported.`);
62
- if (a >= n)
63
- throw r(`queryArea.bbox south (${a}) must be less than north (${n}).`);
64
- return { bbox: [i, a, l, n] };
62
+ if (n >= a)
63
+ throw r(`queryArea.bbox south (${n}) must be less than north (${a}).`);
64
+ return { bbox: [i, n, l, a] };
65
65
  }
66
- function at(t) {
66
+ function it(t) {
67
67
  const { autoLoadLayers: e, ...r } = t;
68
- return { ...r, queryArea: ot(t), autoLoadLayers: { layers: e?.layers ?? [] } };
68
+ return { ...r, queryArea: at(t), autoLoadLayers: { layers: e?.layers ?? [] } };
69
+ }
70
+ function D(t) {
71
+ 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.`;
72
+ }
73
+ function st(t) {
74
+ let e = 1 / 0, r = 1 / 0, o = -1 / 0, i = -1 / 0;
75
+ const n = (a) => {
76
+ if (Array.isArray(a)) {
77
+ if (typeof a[0] == "number") {
78
+ const [s, u] = a;
79
+ s < e && (e = s), s > o && (o = s), u < r && (r = u), u > i && (i = u);
80
+ return;
81
+ }
82
+ for (const s of a) n(s);
83
+ }
84
+ }, l = (a) => {
85
+ a && (a.type === "GeometryCollection" ? a.geometries.forEach(l) : n(a.coordinates));
86
+ };
87
+ for (const a of t.features ?? []) l(a?.geometry);
88
+ return e <= o ? [e, r, o, i] : void 0;
69
89
  }
70
- function nt(t, e) {
90
+ function lt(t, e) {
71
91
  function r(o, i) {
72
92
  if (!i || !i.db)
73
93
  return;
74
- const a = document.getElementById(i.db);
75
- if (a) {
94
+ const n = document.getElementById(i.db);
95
+ if (n) {
76
96
  const l = o.getTablesMetadata();
77
- a.innerHTML += "<ul>";
78
- for (const n of l)
79
- a.innerHTML += `<li>${n.name}: (${n.source}, ${n.type}) </li>`;
80
- a.innerHTML += "</ul>", a.innerHTML += `<p>Number of tables: ${l.length}</p>`;
97
+ n.innerHTML += "<ul>";
98
+ for (const a of l)
99
+ n.innerHTML += `<li>${a.name}: (${a.source}, ${a.type}) </li>`;
100
+ n.innerHTML += "</ul>", n.innerHTML += `<p>Number of tables: ${l.length}</p>`;
81
101
  }
82
102
  }
83
103
  return {
84
104
  async resolveSource(o, i) {
85
- let a = o;
86
- a || (a = new J(), await a.init());
87
- let { type: l, ...n } = i;
105
+ let n = o;
106
+ n || (n = new z(), await n.init());
107
+ let { type: l, ...a } = i;
88
108
  switch (l) {
89
109
  case "osm":
90
- return await a.loadOsm(at(n)), r(a, t), a;
110
+ return await n.loadOsm(it(a)), r(n, t), n;
91
111
  case "csv":
92
- return await a.loadCsv(n), r(a, t), a;
112
+ return await n.loadCsv(a), r(n, t), n;
93
113
  case "json":
94
- return await a.loadJson(n), r(a, t), a;
114
+ return await n.loadJson(a), r(n, t), n;
95
115
  case "geojson": {
96
- const s = n;
97
- let c;
98
- s.geojsonFileUrl ? c = await (await fetch(s.geojsonFileUrl)).json() : c = s.geojsonObject, e && c && e.set(s.outputTableName, c);
99
- const u = c ? (() => {
100
- const f = { ...s, geojsonObject: c };
116
+ const s = a;
117
+ let u;
118
+ s.geojsonFileUrl ? u = await (await fetch(s.geojsonFileUrl)).json() : u = s.geojsonObject, e && u && e.set(s.outputTableName, u);
119
+ const c = u ? (() => {
120
+ const f = { ...s, geojsonObject: u };
101
121
  return delete f.geojsonFileUrl, f;
102
- })() : s;
103
- try {
104
- await a.loadGeojson(u);
105
- } catch (f) {
106
- const p = u.coordinateFormat ? `coordinateFormat is set to "${u.coordinateFormat}"` : "no coordinateFormat was specified — defaulting to EPSG:4326 (WGS84 per RFC 7946)";
122
+ })() : s, d = /^EPSG:4326$/i.test(c.coordinateFormat ?? "EPSG:4326"), p = u && d ? st(u) : void 0;
123
+ if (p && (p[1] < -90 || p[3] > 90))
107
124
  throw new Error(
108
- `Failed to load GeoJSON layer "${u.outputTableName}": ${f instanceof Error ? f.message : String(f)}. ${p}. Verify that coordinateFormat matches the actual CRS of the input data.`
125
+ `GeoJSON layer "${c.outputTableName}" has y coordinates outside -90 to 90 (bbox: [${p.join(", ")}]), so they cannot be EPSG:4326 degrees. ${D(c.coordinateFormat)}`
109
126
  );
127
+ try {
128
+ await n.loadGeojson(c);
129
+ } catch (f) {
130
+ throw new Error(`Failed to load GeoJSON layer "${c.outputTableName}": ${f instanceof Error ? f.message : String(f)}`);
110
131
  }
111
132
  try {
112
- const f = await a.getBoundingBoxFromLayer(u.outputTableName), p = 25e6;
113
- if (!isFinite(f.minLon) || !isFinite(f.minLat) || !isFinite(f.maxLon) || !isFinite(f.maxLat) || Math.abs(f.minLon) > p || Math.abs(f.maxLon) > p || Math.abs(f.minLat) > p || Math.abs(f.maxLat) > p)
133
+ const f = await n.getBoundingBoxFromLayer(c.outputTableName), m = 25e6;
134
+ if (!isFinite(f.minLon) || !isFinite(f.minLat) || !isFinite(f.maxLon) || !isFinite(f.maxLat) || Math.abs(f.minLon) > m || Math.abs(f.maxLon) > m || Math.abs(f.minLat) > m || Math.abs(f.maxLat) > m)
114
135
  throw new Error(
115
- `Geometry bounding box after transform is invalid for layer "${u.outputTableName}" (bbox: [${f.minLon}, ${f.minLat}, ${f.maxLon}, ${f.maxLat}]). Verify that coordinateFormat matches the actual CRS of the input data. The workspace uses ${V}; input is expected in EPSG:4326 by default.`
136
+ `Geometry bounding box after transform is invalid for layer "${c.outputTableName}" (bbox: [${f.minLon}, ${f.minLat}, ${f.maxLon}, ${f.maxLat}]). ${D(c.coordinateFormat)} The workspace uses ${k}; input is expected in EPSG:4326 by default.`
116
137
  );
117
138
  } catch (f) {
118
139
  if (f instanceof Error && f.message.includes("bounding box after transform")) throw f;
119
140
  }
120
- return r(a, t), a;
141
+ return r(n, t), n;
121
142
  }
122
143
  case "heatmap": {
123
- const s = n;
124
- return await a.buildHeatmap({
144
+ const s = a;
145
+ return await n.buildHeatmap({
125
146
  tableJoinName: s.tableJoinName,
126
147
  near: { distance: s.near.distance },
127
148
  outputTableName: s.outputTableName,
128
149
  grid: s.grid,
129
150
  ...s.groupBy && { groupBy: s.groupBy }
130
- }), r(a, t), a;
151
+ }), r(n, t), n;
131
152
  }
132
153
  case "join": {
133
- const s = n;
134
- if (await a.spatialQuery({
154
+ const s = a;
155
+ if (await n.spatialQuery({
135
156
  tableRootName: s.tableRootName,
136
157
  tableJoinName: s.tableJoinName,
137
158
  ...s.near && { near: s.near },
138
159
  ...s.groupBy && { groupBy: s.groupBy }
139
160
  }), e) {
140
- const c = await a.getLayer(s.tableRootName);
141
- e.set(s.tableRootName, c);
161
+ const u = await n.getLayer(s.tableRootName);
162
+ e.set(s.tableRootName, u);
142
163
  }
143
- return r(a, t), a;
164
+ return r(n, t), n;
144
165
  }
145
166
  default:
146
167
  return;
@@ -148,132 +169,159 @@ function nt(t, e) {
148
169
  }
149
170
  };
150
171
  }
151
- function B(t) {
172
+ function N(t) {
152
173
  return typeof t.title == "string" && t.title !== "" ? t.title : t.dataRef;
153
174
  }
154
- function it(t, e) {
175
+ function ut(t, e) {
155
176
  const r = /* @__PURE__ */ new Set();
156
177
  for (const o of t.layerRefs) {
157
- const i = B(o);
178
+ const i = N(o);
158
179
  if (r.has(i))
159
180
  throw new Error(`Map ${e} draws two layers with the id "${i}". A layer's id is its title, else its dataRef: give each layer of a map its own title.`);
160
181
  r.add(i);
161
182
  }
162
183
  }
163
- const st = /^#[0-9a-fA-F]{6}$/;
164
- function D(t, e, r) {
165
- if (!st.test(t))
184
+ const ct = /^#[0-9a-fA-F]{6}$/;
185
+ function G(t, e, r) {
186
+ if (!ct.test(t))
166
187
  throw new Error(`Layer "${r}": ${e} must be a color written #rrggbb, not "${t}".`);
167
- return P.hexToRgb(t);
188
+ return v.hexToRgb(t);
168
189
  }
169
- function lt(t, e) {
190
+ function ft(t, e) {
170
191
  const r = {};
171
- return t.color != null && (r.color = D(t.color, "color", e)), t.stroke === !1 ? r.showBorders = !1 : t.stroke != null && (r.strokeColor = D(t.stroke, "stroke", e)), t.width != null && (r.polylinesWidth = t.width), r;
192
+ return t.color != null && (r.color = G(t.color, "color", e)), t.stroke === !1 ? r.showBorders = !1 : t.stroke != null && (r.strokeColor = G(t.stroke, "stroke", e)), t.width != null && (r.polylinesWidth = t.width), r;
172
193
  }
173
- function ut(t, e) {
174
- return t.isColorMap != null ? t.isColorMap : e === "raster" ? t.colorMapInterpolator != null || t.colorMapCenter != null || t.colorMapReverse === !0 : t.color != null ? !1 : t.colorMapInterpolator != null || t.getFnv != null;
194
+ function pt(t, e) {
195
+ 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;
175
196
  }
176
- function ct(t, e) {
197
+ function mt(t, e) {
177
198
  const r = t.features?.[0]?.properties?.[e];
178
199
  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;
179
200
  }
180
- function ft(t, e, r, o) {
181
- if (P.isCategorical(e.interpolator)) return;
182
- let i = 0, a = 0;
183
- for (let s = 0; s < t.length; s++) {
184
- const c = t[s];
185
- Number.isFinite(c) && (a++, r != null && (i = Math.max(i, Math.abs(c - r))));
201
+ function dt(t, e, r, o, i) {
202
+ if (v.isCategorical(e.interpolator)) return;
203
+ if (i != null) {
204
+ const u = r != null ? [i[0], r, i[1]] : [i[0], i[1]];
205
+ return o === !0 ? u.reverse() : u;
186
206
  }
187
- const l = r != null && i > 0;
188
- if (a === 0 || !l && o !== !0) return;
189
- const n = l && r != null ? [r - i, r, r + i] : P.resolveDomainFromData(t, e);
190
- return o === !0 ? [...n].reverse() : n;
207
+ if (!t) return;
208
+ let n = 0, l = 0;
209
+ for (let u = 0; u < t.length; u++) {
210
+ const c = t[u];
211
+ Number.isFinite(c) && (l++, r != null && (n = Math.max(n, Math.abs(c - r))));
212
+ }
213
+ const a = r != null && n > 0;
214
+ if (l === 0 || !a && o !== !0) return;
215
+ const s = a && r != null ? [r - n, r, r + n] : v.resolveDomainFromData(t, e);
216
+ return o === !0 ? [...s].reverse() : s;
191
217
  }
192
- function pt(t, e) {
193
- return e && e.length > 0 ? { type: S.USER, params: e } : t?.mode === Y.PERCENTILE ? t.lowerPercentile !== void 0 || t.upperPercentile !== void 0 ? {
194
- type: S.PERCENTILE,
218
+ function ht(t, e) {
219
+ if (!(e == null || v.isCategorical(t.interpolator)))
220
+ return [e[0], e[1]];
221
+ }
222
+ function yt(t) {
223
+ const e = t.colorMapRange;
224
+ if (e === void 0) return;
225
+ const r = (l) => new Error(`Layer "${N(t)}": ${l}`);
226
+ if (!Array.isArray(e) || e.length !== 2 || !e.every((l) => typeof l == "number" && Number.isFinite(l)))
227
+ throw r("colorMapRange must hold two numbers, [low, high].");
228
+ const [o, i] = e;
229
+ if (o >= i)
230
+ throw r(`colorMapRange low (${o}) must be less than high (${i}).`);
231
+ if (t.colorMapDomain !== void 0)
232
+ throw r("set colorMapRange or colorMapDomain, not both.");
233
+ const n = t.colorMapCenter;
234
+ if (n != null && (n < o || n > i))
235
+ throw r(`colorMapCenter (${n}) must lie within colorMapRange [${o}, ${i}].`);
236
+ }
237
+ function gt(t, e) {
238
+ return e && e.length > 0 ? { type: M.USER, params: e } : t?.mode === H.PERCENTILE ? t.lowerPercentile !== void 0 || t.upperPercentile !== void 0 ? {
239
+ type: M.PERCENTILE,
195
240
  params: [t.lowerPercentile ?? 0, t.upperPercentile ?? 100]
196
- } : { type: S.PERCENTILE } : { type: S.MIN_MAX };
241
+ } : { type: M.PERCENTILE } : { type: M.MIN_MAX };
197
242
  }
198
- function mt(t, e) {
243
+ function bt(t, e) {
199
244
  return e.split(".").reduce((r, o) => {
200
245
  if (!(r == null || typeof r != "object"))
201
246
  return r[o];
202
247
  }, t);
203
248
  }
204
- function dt(t, e, r) {
249
+ function _t(t, e, r) {
205
250
  const o = e.split("."), i = { ...t };
206
- let a = i;
251
+ let n = i;
207
252
  for (let l = 0; l < o.length - 1; l++)
208
- a[o[l]] = { ...a[o[l]] ?? {} }, a = a[o[l]];
209
- return a[o[o.length - 1]] = r, i;
253
+ n[o[l]] = { ...n[o[l]] ?? {} }, n = n[o[l]];
254
+ return n[o[o.length - 1]] = r, i;
210
255
  }
211
- function ht(t, e) {
256
+ function Et(t, e) {
212
257
  const o = t.features?.[0]?.properties?.bands ?? [];
213
- return o.find((a) => a.id === e || a.label === e?.replace(/\./g, "_"))?.id ?? o[0]?.id ?? e ?? "";
214
- }
215
- function yt(t, e, r, o, i) {
216
- async function a(l, n, s) {
217
- let c = {};
218
- for (const u of n.getTablesMetadata())
219
- u.type !== void 0 && (c[u.name] = u.type);
220
- for (const u of s.layerRefs) {
221
- const f = u.dataRef, p = B(u), m = c[f], d = u.getFnv, h = r?.get(f) ?? await n.getLayer(f), y = m === "raster" ? h : {
258
+ return o.find((n) => n.id === e || n.label === e?.replace(/\./g, "_"))?.id ?? o[0]?.id ?? e ?? "";
259
+ }
260
+ function wt(t, e, r, o, i) {
261
+ async function n(l, a, s) {
262
+ let u = {};
263
+ for (const c of a.getTablesMetadata())
264
+ c.type !== void 0 && (u[c.name] = c.type);
265
+ for (const c of s.layerRefs) {
266
+ const d = c.dataRef, p = N(c), f = u[d], m = c.getFnv, h = r?.get(d) ?? await a.getLayer(d), y = f === "raster" ? h : {
222
267
  ...h,
223
268
  features: (h.features ?? []).filter((g) => g.geometry != null)
224
- }, E = m === "raster" ? ht(y, d) : "";
225
- m === "raster" ? l.loadCollection(p, { collection: y, type: "raster", property: E }) : l.loadCollection(p, { collection: y, type: m }), u.opacity != null && l.updateRenderInfo(p, { opacity: u.opacity });
226
- const A = lt(u, p);
227
- Object.keys(A).length > 0 && l.updateRenderInfo(p, A), ut(u, m) && l.updateRenderInfo(p, { isColorMap: !0 }), u.isPick && l.updateRenderInfo(p, { isPick: !0 }), u.isSkip && l.updateRenderInfo(p, { isSkip: !0 });
228
- const { catchAllCategory: b, colorMapDomain: R } = u;
269
+ }, w = f === "raster" ? Et(y, m) : "";
270
+ f === "raster" ? l.loadCollection(p, { collection: y, type: "raster", property: w }) : l.loadCollection(p, { collection: y, type: f }), c.opacity != null && l.updateRenderInfo(p, { opacity: c.opacity });
271
+ const A = ft(c, p);
272
+ Object.keys(A).length > 0 && l.updateRenderInfo(p, A), pt(c, f) && l.updateRenderInfo(p, { isColorMap: !0 }), c.isPick && l.updateRenderInfo(p, { isPick: !0 }), c.isSkip && l.updateRenderInfo(p, { isSkip: !0 });
273
+ const { catchAllCategory: b, colorMapDomain: R } = c;
229
274
  let F = y, T = R;
230
- if (d && b && R?.length) {
275
+ if (m && b && R?.length) {
231
276
  const g = new Set(R);
232
277
  F = {
233
278
  ...y,
234
- features: y.features.map((w) => {
235
- const M = w.properties, v = mt(M, d);
236
- return v == null || !g.has(String(v)) ? { ...w, properties: dt(M, d, b) } : w;
279
+ features: y.features.map((_) => {
280
+ const $ = _.properties, P = bt($, m);
281
+ return P == null || !g.has(String(P)) ? { ..._, properties: _t($, m, b) } : _;
237
282
  })
238
283
  }, T = g.has(b) ? R : [...R, b];
239
284
  }
240
- const O = m === "raster" && u.transferFunction != null;
241
- O && l.layerManager.searchByLayerId(p)?.setTransferFunction?.(u.transferFunction);
242
- const x = m === "raster" && (u.colorMapCenter != null || u.colorMapReverse === !0);
243
- if (u.colorMapInterpolator || x) {
285
+ const O = f === "raster" && c.transferFunction != null;
286
+ O && l.layerManager.searchByLayerId(p)?.setTransferFunction?.(c.transferFunction);
287
+ const C = c.colorMapRange, x = f === "raster" && (C != null || c.colorMapCenter != null || c.colorMapReverse === !0);
288
+ if (c.colorMapInterpolator || x || C) {
244
289
  const g = {
245
290
  // urban-grammar ColorMapInterpolator values are string-compatible
246
291
  // with autk-core ColorMapInterpolator at runtime
247
- interpolator: u.colorMapInterpolator ?? l.layerManager.searchByLayerId(p)?.layerRenderInfo.colormap.config.interpolator ?? Z.SEQ_REDS,
248
- domainSpec: pt(u.normalization, T)
249
- }, w = x ? ct(y, E) : null, M = w ? ft(w, g, u.colorMapCenter, u.colorMapReverse) : void 0;
250
- M && (g.domainSpec = { type: S.USER, params: M }), l.updateColorMap(p, { colorMap: g });
292
+ interpolator: c.colorMapInterpolator ?? l.layerManager.searchByLayerId(p)?.layerRenderInfo.colormap.config.interpolator ?? et.SEQ_REDS,
293
+ domainSpec: gt(c.normalization, T)
294
+ };
295
+ let _;
296
+ x ? _ = dt(mt(y, w), g, c.colorMapCenter, c.colorMapReverse, C) : f !== "raster" && (_ = ht(g, C)), _ && (g.domainSpec = { type: M.USER, params: _ }), l.updateColorMap(p, { colorMap: g });
251
297
  } else O && l.updateColorMap(p, { colorMap: {} });
252
- if (d && m !== "raster") {
253
- const g = d.startsWith("properties.") ? d : `properties.${d}`;
298
+ if (m && f !== "raster") {
299
+ const g = m.startsWith("properties.") ? m : `properties.${m}`;
254
300
  l.updateThematic(p, { collection: F, property: g });
255
301
  }
256
302
  }
257
303
  }
258
304
  return {
259
- async resolveMap(l, n, s = 0) {
305
+ async resolveMap(l, a, s = 0) {
260
306
  if (t && t.map && l) {
261
- it(n, s);
262
- let c;
263
- if (Array.isArray(t.map) ? c = document.getElementById(t.map[s]) : c = document.getElementById(t.map), !c)
307
+ ut(a, s);
308
+ for (const d of a.layerRefs)
309
+ yt(d);
310
+ let u;
311
+ if (Array.isArray(t.map) ? u = document.getElementById(t.map[s]) : u = document.getElementById(t.map), !u)
264
312
  throw new Error("Could not find rendering target for map: " + t.map);
265
- if (!(c instanceof HTMLCanvasElement))
313
+ if (!(u instanceof HTMLCanvasElement))
266
314
  throw new Error("Target for map is not a canvas: " + t.map);
267
- const u = new K(c);
268
- n.style && u.style.setPredefinedStyle(n.style), await u.init(), await a(u, l, n);
269
- for (const f of n.layerRefs)
270
- e?.set(f.dataRef, u), i?.set(f.dataRef, B(f));
271
- o && (o[s] = u), u.draw();
315
+ const c = new Z(u);
316
+ a.style && c.style.setPredefinedStyle(a.style), await c.init(), await n(c, l, a);
317
+ for (const d of a.layerRefs)
318
+ e?.set(d.dataRef, c), i?.set(d.dataRef, N(d));
319
+ o && (o[s] = c), c.draw();
272
320
  }
273
321
  }
274
322
  };
275
323
  }
276
- function gt(t) {
324
+ function At(t) {
277
325
  return {
278
326
  scatter: "scatterplot",
279
327
  bar: "barchart",
@@ -284,49 +332,49 @@ function gt(t) {
284
332
  heatmatrix: "heatmatrix"
285
333
  }[t];
286
334
  }
287
- function bt(t, e, r, o, i, a) {
335
+ function Rt(t, e, r, o, i, n) {
288
336
  return {
289
- async resolvePlot(l, n) {
337
+ async resolvePlot(l, a) {
290
338
  if (!t || !t.plot) return;
291
339
  const s = document.getElementById(t.plot);
292
340
  if (!s) throw new Error(`Could not find plot target: ${t.plot}`);
293
- const c = l;
294
- if (!c) throw new Error("No data context available for plot.");
295
- const u = i?.get(n.dataRef) ?? await c.getLayer(n.dataRef), f = n.events ?? [], p = new z(s, {
296
- type: gt(n.mark),
297
- collection: u,
298
- attributes: { axis: n.axis, ...n.color && { color: n.color } },
299
- labels: { axis: n.axis, title: n.title },
300
- events: f,
301
- ...n.width && { width: n.width },
302
- ...n.height && { height: n.height },
303
- ...n.margins && { margins: n.margins },
304
- ...n.transform && { transform: n.transform }
341
+ const u = l;
342
+ if (!u) throw new Error("No data context available for plot.");
343
+ const c = i?.get(a.dataRef) ?? await u.getLayer(a.dataRef), d = a.events ?? [], p = new tt(s, {
344
+ type: At(a.mark),
345
+ collection: c,
346
+ attributes: { axis: a.axis, ...a.color && { color: a.color } },
347
+ labels: { axis: a.axis, title: a.title },
348
+ events: d,
349
+ ...a.width && { width: a.width },
350
+ ...a.height && { height: a.height },
351
+ ...a.margins && { margins: a.margins },
352
+ ...a.transform && { transform: a.transform }
305
353
  });
306
- if (r?.set(n.dataRef, p), n.mapRef && o?.set(n.dataRef, n.mapRef), n.mapRef && e) {
307
- const m = e.get(n.mapRef), d = a?.get(n.mapRef) ?? n.mapRef;
308
- if (m) {
309
- m.updateRenderInfo(d, { isPick: !0 }), m.events.on(N.PICKING, ({ selection: h }) => {
354
+ if (r?.set(a.dataRef, p), a.mapRef && o?.set(a.dataRef, a.mapRef), a.mapRef && e) {
355
+ const f = e.get(a.mapRef), m = n?.get(a.mapRef) ?? a.mapRef;
356
+ if (f) {
357
+ f.updateRenderInfo(m, { isPick: !0 }), f.events.on(B.PICKING, ({ selection: h }) => {
310
358
  p.setSelection(h);
311
359
  });
312
- for (const h of f)
360
+ for (const h of d)
313
361
  p.events.on(h, ({ selection: y }) => {
314
- m.setHighlightedIds(d, y);
362
+ f.setHighlightedIds(m, y);
315
363
  });
316
364
  }
317
365
  }
318
366
  }
319
367
  };
320
368
  }
321
- const H = 134217728, _t = 4, Et = 32;
322
- function At(t) {
369
+ const q = 134217728, Mt = 4, St = 32;
370
+ function Ct(t) {
323
371
  return Array.isArray(t) ? t.join(`
324
372
  `) : t;
325
373
  }
326
- function _(t) {
374
+ function E(t) {
327
375
  return !!t && typeof t == "object" && !Array.isArray(t) && typeof t.fromFeature == "object" && t.fromFeature !== null;
328
376
  }
329
- function C(t, e) {
377
+ function S(t, e) {
330
378
  return t instanceof Map ? t.get(e) : t[e];
331
379
  }
332
380
  function L(t, e) {
@@ -335,163 +383,163 @@ function L(t, e) {
335
383
  return r[o];
336
384
  }, t);
337
385
  }
338
- function k(t) {
386
+ function W(t) {
339
387
  const e = [];
340
388
  for (const r of [t.uniforms, t.uniformMatrices])
341
389
  for (const o of Object.values(r ?? {}))
342
- _(o) && e.push(o);
390
+ E(o) && e.push(o);
343
391
  return e;
344
392
  }
345
- function wt(t) {
346
- return [.../* @__PURE__ */ new Set([t.dataRef, ...k(t).map((e) => e.fromFeature.layer)])];
393
+ function It(t) {
394
+ return [.../* @__PURE__ */ new Set([t.dataRef, ...W(t).map((e) => e.fromFeature.layer)])];
347
395
  }
348
- function q(t) {
349
- for (const e of k(t)) {
396
+ function X(t) {
397
+ for (const e of W(t)) {
350
398
  const { iterate: r, layer: o } = e.fromFeature;
351
399
  if (r === "all" || r === "batched") return { mode: r, layer: o };
352
400
  }
353
401
  return null;
354
402
  }
355
- function W(t, e, r) {
356
- const o = t.fromFeature, i = r !== void 0 && o.iterate === "all" ? r : o.index ?? 0, a = C(e, o.layer)?.features?.[i];
357
- return a ? L(a, o.path) : void 0;
403
+ function J(t, e, r) {
404
+ const o = t.fromFeature, i = r !== void 0 && o.iterate === "all" ? r : o.index ?? 0, n = S(e, o.layer)?.features?.[i];
405
+ return n ? L(n, o.path) : void 0;
358
406
  }
359
- function G(t, e, r) {
407
+ function j(t, e, r) {
360
408
  if (!t) return;
361
409
  const o = {};
362
- for (const [i, a] of Object.entries(t)) {
363
- if (!_(a)) {
364
- o[i] = a;
410
+ for (const [i, n] of Object.entries(t)) {
411
+ if (!E(n)) {
412
+ o[i] = n;
365
413
  continue;
366
414
  }
367
- const l = Number(W(a, e, r) ?? NaN);
368
- Number.isFinite(l) ? o[i] = l : typeof a.default == "number" && (o[i] = a.default);
415
+ const l = Number(J(n, e, r) ?? NaN);
416
+ Number.isFinite(l) ? o[i] = l : typeof n.default == "number" && (o[i] = n.default);
369
417
  }
370
418
  return o;
371
419
  }
372
- function $(t, e, r) {
420
+ function U(t, e, r) {
373
421
  if (!t) return;
374
422
  const o = {};
375
- for (const [i, a] of Object.entries(t)) {
376
- if (!_(a)) {
377
- o[i] = a;
423
+ for (const [i, n] of Object.entries(t)) {
424
+ if (!E(n)) {
425
+ o[i] = n;
378
426
  continue;
379
427
  }
380
- const l = W(a, e, r), n = Array.isArray(l) ? l : Array.isArray(a.default) ? a.default : void 0;
381
- if (!n) continue;
382
- const s = a.cols ?? (Array.isArray(n[0]) ? n[0].length : 0);
383
- s > 0 ? o[i] = { data: n, cols: s } : console.warn(`[autk-grammar] uniform matrix "${i}" has no column count; entry dropped`);
428
+ const l = J(n, e, r), a = Array.isArray(l) ? l : Array.isArray(n.default) ? n.default : void 0;
429
+ if (!a) continue;
430
+ const s = n.cols ?? (Array.isArray(a[0]) ? a[0].length : 0);
431
+ s > 0 ? o[i] = { data: a, cols: s } : console.warn(`[autk-grammar] uniform matrix "${i}" has no column count; entry dropped`);
384
432
  }
385
433
  return o;
386
434
  }
387
- function Rt(t) {
435
+ function Lt(t) {
388
436
  return t != null && !(typeof t == "number" && !Number.isFinite(t));
389
437
  }
390
- function j(t) {
391
- return _(t) && t.fromFeature.iterate === "batched";
438
+ function Q(t) {
439
+ return E(t) && t.fromFeature.iterate === "batched";
392
440
  }
393
- function X(t, e) {
394
- return Object.values(e ?? {}).some(j) ? Et : Object.values(t ?? {}).some(j) ? _t : 0;
441
+ function K(t, e) {
442
+ return Object.values(e ?? {}).some(Q) ? St : Object.values(t ?? {}).some(Q) ? Mt : 0;
395
443
  }
396
- function Mt(t, e, r = H) {
397
- const o = X(t, e);
444
+ function vt(t, e, r = q) {
445
+ const o = K(t, e);
398
446
  return o > 0 ? Math.floor(r / o) : Number.POSITIVE_INFINITY;
399
447
  }
400
- function St(t, e, r, o = H) {
401
- const i = {}, a = {}, l = [];
448
+ function Nt(t, e, r, o = q) {
449
+ const i = {}, n = {}, l = [];
402
450
  for (const s of [t, e])
403
- for (const c of Object.values(s ?? {}))
404
- _(c) && c.fromFeature.iterate === "batched" && c.fromFeature.required && l.push(c.fromFeature.path);
451
+ for (const u of Object.values(s ?? {}))
452
+ E(u) && u.fromFeature.iterate === "batched" && u.fromFeature.required && l.push(u.fromFeature.path);
405
453
  if (l.length > 0) {
406
454
  const s = r.length;
407
- r = r.filter((c) => l.every((u) => Rt(L(c, u)))), r.length < s && console.info(`[autk-grammar] batched compute dropped ${s - r.length} feature(s) missing ${l.join(", ")}`);
455
+ r = r.filter((u) => l.every((c) => Lt(L(u, c)))), r.length < s && console.info(`[autk-grammar] batched compute dropped ${s - r.length} feature(s) missing ${l.join(", ")}`);
408
456
  }
409
- const n = Mt(t, e, o);
410
- r.length > n && (console.warn(
411
- `[autk-grammar] batched compute capped at ${n} features (got ${r.length}): its largest packed array takes ${X(t, e)} B per feature, and a storage buffer binding holds ${o} B`
412
- ), r = r.slice(0, n));
413
- for (const [s, c] of Object.entries(t ?? {}))
414
- if (_(c) && c.fromFeature.iterate === "batched") {
415
- const u = typeof c.default == "number" ? c.default : void 0;
416
- a[s] = r.map((f) => {
417
- const p = Number(L(f, c.fromFeature.path) ?? u);
457
+ const a = vt(t, e, o);
458
+ r.length > a && (console.warn(
459
+ `[autk-grammar] batched compute capped at ${a} features (got ${r.length}): its largest packed array takes ${K(t, e)} B per feature, and a storage buffer binding holds ${o} B`
460
+ ), r = r.slice(0, a));
461
+ for (const [s, u] of Object.entries(t ?? {}))
462
+ if (E(u) && u.fromFeature.iterate === "batched") {
463
+ const c = typeof u.default == "number" ? u.default : void 0;
464
+ n[s] = r.map((d) => {
465
+ const p = Number(L(d, u.fromFeature.path) ?? c);
418
466
  return Number.isFinite(p) ? p : 0;
419
467
  });
420
- } else typeof c == "number" && (i[s] = c);
421
- for (const [s, c] of Object.entries(e ?? {})) {
422
- if (!_(c) || c.fromFeature.iterate !== "batched") continue;
423
- const u = [];
424
- for (const f of r) {
425
- const p = L(f, c.fromFeature.path);
426
- let m = 1 / 0, d = 1 / 0, h = -1 / 0, y = -1 / 0;
468
+ } else typeof u == "number" && (i[s] = u);
469
+ for (const [s, u] of Object.entries(e ?? {})) {
470
+ if (!E(u) || u.fromFeature.iterate !== "batched") continue;
471
+ const c = [];
472
+ for (const d of r) {
473
+ const p = L(d, u.fromFeature.path);
474
+ let f = 1 / 0, m = 1 / 0, h = -1 / 0, y = -1 / 0;
427
475
  if (Array.isArray(p))
428
- for (const E of p) {
429
- if (!Array.isArray(E) || E.length < 2) continue;
430
- const A = Number(E[0]), b = Number(E[1]);
431
- !Number.isFinite(A) || !Number.isFinite(b) || (m = Math.min(m, A), d = Math.min(d, b), h = Math.max(h, A), y = Math.max(y, b));
476
+ for (const w of p) {
477
+ if (!Array.isArray(w) || w.length < 2) continue;
478
+ const A = Number(w[0]), b = Number(w[1]);
479
+ !Number.isFinite(A) || !Number.isFinite(b) || (f = Math.min(f, A), m = Math.min(m, b), h = Math.max(h, A), y = Math.max(y, b));
432
480
  }
433
- Number.isFinite(m) || (m = 0, d = 0, h = 0, y = 0), u.push(m, d, h, d, h, y, m, y);
481
+ Number.isFinite(f) || (f = 0, m = 0, h = 0, y = 0), c.push(f, m, h, m, h, y, f, y);
434
482
  }
435
- a[s] = u;
483
+ n[s] = c;
436
484
  }
437
- return i.num_features = r.length, { uniforms: i, uniformArrays: a };
485
+ return i.num_features = r.length, { uniforms: i, uniformArrays: n };
438
486
  }
439
- function U(t, e, r) {
440
- const o = C(e, t.dataRef);
487
+ function Y(t, e, r) {
488
+ const o = S(e, t.dataRef);
441
489
  if (!o) throw new Error(`compute: table "${t.dataRef}" is not loaded`);
442
490
  const i = {
443
491
  collection: o,
444
492
  variableMapping: t.attributes,
445
- wgslBody: At(t.wglsFunction)
493
+ wgslBody: Ct(t.wglsFunction)
446
494
  };
447
495
  t.attributeArrays && (i.attributeArrays = t.attributeArrays), t.attributeMatrices && (i.attributeMatrices = t.attributeMatrices), t.uniformArrays && (i.uniformArrays = t.uniformArrays), t.outputColumnName && (i.resultField = t.outputColumnName), t.outputColumns && (i.outputColumns = t.outputColumns);
448
- const a = q(t);
449
- if (a?.mode === "batched") {
450
- const c = C(e, a.layer)?.features ?? [], u = St(t.uniforms, t.uniformMatrices, c), f = G(Q(t.uniforms), e) ?? {}, p = $(Q(t.uniformMatrices), e);
451
- return i.uniforms = { ...f, ...u.uniforms }, i.uniformArrays = { ...i.uniformArrays ?? {}, ...u.uniformArrays }, p && Object.keys(p).length > 0 && (i.uniformMatrices = p), i;
496
+ const n = X(t);
497
+ if (n?.mode === "batched") {
498
+ const u = S(e, n.layer)?.features ?? [], c = Nt(t.uniforms, t.uniformMatrices, u), d = j(V(t.uniforms), e) ?? {}, p = U(V(t.uniformMatrices), e);
499
+ return i.uniforms = { ...d, ...c.uniforms }, i.uniformArrays = { ...i.uniformArrays ?? {}, ...c.uniformArrays }, p && Object.keys(p).length > 0 && (i.uniformMatrices = p), i;
452
500
  }
453
- const l = a?.mode === "all" ? r : void 0, n = G(t.uniforms, e, l), s = $(t.uniformMatrices, e, l);
454
- return n && (i.uniforms = n), s && (i.uniformMatrices = s), i;
501
+ const l = n?.mode === "all" ? r : void 0, a = j(t.uniforms, e, l), s = U(t.uniformMatrices, e, l);
502
+ return a && (i.uniforms = a), s && (i.uniformMatrices = s), i;
455
503
  }
456
- function Q(t) {
504
+ function V(t) {
457
505
  if (t)
458
- return Object.fromEntries(Object.entries(t).filter(([, e]) => !(_(e) && e.fromFeature.iterate === "batched")));
506
+ return Object.fromEntries(Object.entries(t).filter(([, e]) => !(E(e) && e.fromFeature.iterate === "batched")));
459
507
  }
460
- function Ct(t) {
508
+ function Pt(t) {
461
509
  return t.outputColumns ?? (t.outputColumnName ? [t.outputColumnName] : []);
462
510
  }
463
- async function It(t, e, r) {
464
- const o = q(t);
465
- if (o?.mode !== "all") return r(U(t, e));
466
- const i = C(e, t.dataRef);
511
+ async function Bt(t, e, r) {
512
+ const o = X(t);
513
+ if (o?.mode !== "all") return r(Y(t, e));
514
+ const i = S(e, t.dataRef);
467
515
  if (!i) throw new Error(`compute: table "${t.dataRef}" is not loaded`);
468
- const a = Ct(t), l = structuredClone(i);
516
+ const n = Pt(t), l = structuredClone(i);
469
517
  for (const s of l.features) {
470
- const c = s.properties ??= {}, u = c.compute ??= {};
471
- for (const f of a) u[f] = 0;
518
+ const u = s.properties ??= {}, c = u.compute ??= {};
519
+ for (const d of n) c[d] = 0;
472
520
  }
473
- const n = C(e, o.layer)?.features?.length ?? 0;
474
- for (let s = 0; s < n; s++) {
475
- const c = await r({ ...U(t, e, s), collection: l });
476
- l.features.forEach((u, f) => {
477
- const p = u.properties?.compute, m = c.features[f]?.properties?.compute;
478
- if (!(!p || !m))
479
- for (const d of a) {
480
- const h = Number(m[d]);
481
- Number.isFinite(h) && (p[d] += h);
521
+ const a = S(e, o.layer)?.features?.length ?? 0;
522
+ for (let s = 0; s < a; s++) {
523
+ const u = await r({ ...Y(t, e, s), collection: l });
524
+ l.features.forEach((c, d) => {
525
+ const p = c.properties?.compute, f = u.features[d]?.properties?.compute;
526
+ if (!(!p || !f))
527
+ for (const m of n) {
528
+ const h = Number(f[m]);
529
+ Number.isFinite(h) && (p[m] += h);
482
530
  }
483
531
  });
484
532
  }
485
533
  return l;
486
534
  }
487
- function Lt(t) {
535
+ function Ft(t) {
488
536
  return {
489
537
  async resolveCompute(e, r) {
490
538
  if (e) {
491
539
  const o = {};
492
- for (const l of wt(r)) {
493
- const n = t?.get(l);
494
- if (n) o[l] = n;
540
+ for (const l of It(r)) {
541
+ const a = t?.get(l);
542
+ if (a) o[l] = a;
495
543
  else if (l === r.dataRef) o[l] = await e.getLayer(l);
496
544
  else
497
545
  try {
@@ -500,13 +548,13 @@ function Lt(t) {
500
548
  o[l] = void 0;
501
549
  }
502
550
  }
503
- const i = new tt(), a = await It(r, o, (l) => i.gpgpuPipeline(l));
504
- return t && t.set(r.dataRef, a), e;
551
+ const i = new rt(), n = await Bt(r, o, (l) => i.gpgpuPipeline(l));
552
+ return t && t.set(r.dataRef, n), e;
505
553
  }
506
554
  }
507
555
  };
508
556
  }
509
- class vt {
557
+ class Tt {
510
558
  _listeners = /* @__PURE__ */ new Map();
511
559
  on(e, r) {
512
560
  this._listeners.has(e) || this._listeners.set(e, /* @__PURE__ */ new Set());
@@ -518,7 +566,7 @@ class vt {
518
566
  this._listeners.get(e)?.forEach((o) => o(r));
519
567
  }
520
568
  }
521
- class Ot {
569
+ class jt {
522
570
  dataAdapter;
523
571
  mapAdapter;
524
572
  plotAdapter;
@@ -532,10 +580,10 @@ class Ot {
532
580
  _plotRegistry = /* @__PURE__ */ new Map();
533
581
  _fwdCleanups = [];
534
582
  _plotMapLinks = /* @__PURE__ */ new Map();
535
- interactions = new vt();
583
+ interactions = new Tt();
536
584
  constructor(e) {
537
585
  const r = /* @__PURE__ */ new Map();
538
- this.dataAdapter = nt(e, r), this.mapAdapter = yt(e, this._mapRegistry, this._computeCache, this._maps, this._mapLayerIds), this.plotAdapter = bt(e, this._mapRegistry, this._plotRegistry, this._plotMapLinks, r, this._mapLayerIds), this.computeAdapter = Lt(this._computeCache);
586
+ this.dataAdapter = lt(e, r), this.mapAdapter = wt(e, this._mapRegistry, this._computeCache, this._maps, this._mapLayerIds), this.plotAdapter = Rt(e, this._mapRegistry, this._plotRegistry, this._plotMapLinks, r, this._mapLayerIds), this.computeAdapter = Ft(this._computeCache);
539
587
  }
540
588
  /**
541
589
  * The coordinate reference system used internally by the autk workspace.
@@ -546,7 +594,7 @@ class Ot {
546
594
  * instead of hard-coding a CRS string.
547
595
  */
548
596
  get workspaceCrs() {
549
- return V;
597
+ return k;
550
598
  }
551
599
  get data() {
552
600
  return this._data;
@@ -584,7 +632,7 @@ class Ot {
584
632
  throw new Error("Plot adapter not initialized. Please call the constructor first.");
585
633
  if (!this.computeAdapter)
586
634
  throw new Error("Compute adapter not initialized. Please call the constructor first.");
587
- this._mapRegistry.clear(), this._mapLayerIds.clear(), this._maps.length = 0, this._plotRegistry.clear(), this._plotMapLinks.clear(), this._computeCache.clear(), this.grammarEngine = et({
635
+ this._mapRegistry.clear(), this._mapLayerIds.clear(), this._maps.length = 0, this._plotRegistry.clear(), this._plotMapLinks.clear(), this._computeCache.clear(), this.grammarEngine = ot({
588
636
  spec: e,
589
637
  adapters: {
590
638
  db: this.dataAdapter,
@@ -602,8 +650,8 @@ class Ot {
602
650
  for (const i of r.getLayersMetadata())
603
651
  Object.defineProperty(o, i.name, {
604
652
  get: () => {
605
- const a = this._computeCache.get(i.name);
606
- return a ? Promise.resolve(a) : r.getLayer(i.name);
653
+ const n = this._computeCache.get(i.name);
654
+ return n ? Promise.resolve(n) : r.getLayer(i.name);
607
655
  },
608
656
  enumerable: !0,
609
657
  configurable: !0
@@ -617,8 +665,8 @@ class Ot {
617
665
  highlightOnMap(e, r) {
618
666
  const o = this.mapLayer(e);
619
667
  o?.map.setHighlightedIds(o.layerId, r);
620
- for (const [i, a] of this._plotMapLinks)
621
- a === e && this._plotRegistry.get(i)?.setSelection(r);
668
+ for (const [i, n] of this._plotMapLinks)
669
+ n === e && this._plotRegistry.get(i)?.setSelection(r);
622
670
  }
623
671
  /**
624
672
  * Clears highlighted features on the map layer that draws the table `dataRef` (see {@link mapLayer}).
@@ -655,40 +703,40 @@ class Ot {
655
703
  for (const [r, o] of this._mapRegistry) {
656
704
  if (e.has(o)) continue;
657
705
  e.add(o);
658
- const i = ({ selection: a }) => {
659
- this.interactions.emit("map:picking", { layerId: r, selection: a });
706
+ const i = ({ selection: n }) => {
707
+ this.interactions.emit("map:picking", { layerId: r, selection: n });
660
708
  };
661
- o.events.on(N.PICKING, i), this._fwdCleanups.push(() => o.events.off(N.PICKING, i));
709
+ o.events.on(B.PICKING, i), this._fwdCleanups.push(() => o.events.off(B.PICKING, i));
662
710
  }
663
711
  for (const [r, o] of this._plotRegistry)
664
712
  for (const i of [I.CLICK, I.BRUSH, I.BRUSH_X, I.BRUSH_Y]) {
665
- const a = ({ selection: l }) => {
713
+ const n = ({ selection: l }) => {
666
714
  this.interactions.emit("plot:selection", {
667
715
  plotId: r,
668
716
  event: i,
669
717
  selection: l
670
718
  });
671
719
  };
672
- o.events.on(i, a), this._fwdCleanups.push(() => o.events.off(i, a));
720
+ o.events.on(i, n), this._fwdCleanups.push(() => o.events.off(i, n));
673
721
  }
674
722
  }
675
723
  }
676
724
  export {
677
- Ot as AutkGrammar,
678
- rt as ColorMapInterpolator,
679
- vt as GrammarEventEmitter,
680
- Y as NormalizationMode,
681
- H as STORAGE_BUFFER_BINDING_SIZE,
682
- St as buildBatchedUniforms,
683
- wt as computeLayerNames,
684
- et as createEngine,
685
- q as findIterateSource,
686
- _ as isFromFeature,
687
- At as joinWgsl,
688
- Mt as maxBatchedFeatures,
689
- U as resolveComputeParams,
690
- $ as resolveUniformMatrices,
691
- G as resolveUniforms,
692
- It as runCompute
725
+ jt as AutkGrammar,
726
+ nt as ColorMapInterpolator,
727
+ Tt as GrammarEventEmitter,
728
+ H as NormalizationMode,
729
+ q as STORAGE_BUFFER_BINDING_SIZE,
730
+ Nt as buildBatchedUniforms,
731
+ It as computeLayerNames,
732
+ ot as createEngine,
733
+ X as findIterateSource,
734
+ E as isFromFeature,
735
+ Ct as joinWgsl,
736
+ vt as maxBatchedFeatures,
737
+ Y as resolveComputeParams,
738
+ U as resolveUniformMatrices,
739
+ j as resolveUniforms,
740
+ Bt as runCompute
693
741
  };
694
742
  //# sourceMappingURL=autk-grammar.js.map