@graphty/graphty-element 2.6.2 → 3.0.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.
Files changed (163) hide show
  1. package/dist/ai.js +3 -3
  2. package/dist/catalog.js +53 -54
  3. package/dist/chunks/{AiManager-4iQpsJW1.js → AiManager-Bhh0rR_p.js} +706 -655
  4. package/dist/chunks/GraphSession-DPoTaT3b.js +21175 -0
  5. package/dist/chunks/{GraphtyLogger-B_O67a6c.js → GraphtyLogger-BtcBJQPL.js} +1 -1
  6. package/dist/chunks/{VoiceInputAdapter-Cc6mHXTI.js → VoiceInputAdapter-CdLsJ_nG.js} +1 -1
  7. package/dist/chunks/{XRPivotCameraController-BLa89LXn.js → XRPivotCameraController-CiLJ9Gz6.js} +2 -2
  8. package/dist/chunks/algorithms-qij74zEN.js +6811 -0
  9. package/dist/chunks/{capability-check-Am2zliFj.js → capability-check-BbgTejS3.js} +1 -1
  10. package/dist/chunks/definePalette-BYt2Llxs.js +1333 -0
  11. package/dist/chunks/fields-5uVC1Pll.js +4999 -0
  12. package/dist/chunks/{format-detection-BHwrAVzW.js → format-detection-FKaDMshR.js} +1 -1
  13. package/dist/chunks/{index-BkBLbvui.js → index-Cc_6D9hV.js} +6034 -7127
  14. package/dist/chunks/interpolation-Dk206AhZ.js +105 -0
  15. package/dist/chunks/paletteRegistry-De3CGdst.js +357 -0
  16. package/dist/chunks/parse-SVp77JbE.js +669 -0
  17. package/dist/chunks/{pluginRegistry-Bs8bEkz9.js → pluginRegistry-Ddfl6Mv2.js} +27 -24
  18. package/dist/chunks/{registry-BdGvyZou.js → registry-CgMqldp4.js} +1 -1
  19. package/dist/chunks/{DataSource-BL2UzPff.js → sources-BbAJCDIH.js} +279 -108
  20. package/dist/commands.d.ts +128 -19
  21. package/dist/commands.js +49 -1
  22. package/dist/custom-elements.json +1 -1
  23. package/dist/extend.d.ts +10 -2
  24. package/dist/extend.js +64 -57
  25. package/dist/graphty-catalog.json +6 -3
  26. package/dist/graphty.bundle.js +267177 -240648
  27. package/dist/graphty.js +84 -78
  28. package/dist/index.d.ts +4 -0
  29. package/dist/logging.js +2 -2
  30. package/dist/schema.js +70 -71
  31. package/dist/session.d.ts +5 -6
  32. package/dist/session.js +40 -86
  33. package/dist/src/Edge.d.ts +31 -67
  34. package/dist/src/Graph.d.ts +335 -77
  35. package/dist/src/Node.d.ts +36 -3
  36. package/dist/src/NodeBehavior.d.ts +28 -0
  37. package/dist/src/Styles.d.ts +15 -4
  38. package/dist/src/acceleration/AccelerationController.d.ts +8 -0
  39. package/dist/src/acceleration/narrow.d.ts +9 -1
  40. package/dist/src/acceleration/types.d.ts +10 -0
  41. package/dist/src/ai/AiController.d.ts +12 -0
  42. package/dist/src/ai/AiManager.d.ts +7 -0
  43. package/dist/src/ai/commands/AlgorithmCommands.d.ts +1 -1
  44. package/dist/src/ai/commands/LayoutCommands.d.ts +1 -1
  45. package/dist/src/ai/commands/StyleCommands.d.ts +1 -1
  46. package/dist/src/ai/commands/types.d.ts +20 -1
  47. package/dist/src/algorithms/Algorithm.d.ts +21 -4
  48. package/dist/src/algorithms/BFSAlgorithm.d.ts +0 -9
  49. package/dist/src/algorithms/BellmanFordAlgorithm.d.ts +0 -14
  50. package/dist/src/algorithms/DFSAlgorithm.d.ts +1 -1
  51. package/dist/src/algorithms/FloydWarshallAlgorithm.d.ts +5 -0
  52. package/dist/src/algorithms/GirvanNewmanAlgorithm.d.ts +5 -0
  53. package/dist/src/algorithms/LeidenAlgorithm.d.ts +5 -0
  54. package/dist/src/algorithms/PageRankAlgorithm.d.ts +1 -1
  55. package/dist/src/algorithms/StronglyConnectedComponentsAlgorithm.d.ts +1 -1
  56. package/dist/src/algorithms/metrics/fields.d.ts +23 -1
  57. package/dist/src/algorithms/utils/graphUtils.d.ts +13 -1
  58. package/dist/src/catalog/paletteRegistry.d.ts +4 -4
  59. package/dist/src/catalog/registry.d.ts +3 -2
  60. package/dist/src/catalog/types.d.ts +18 -1
  61. package/dist/src/config/GraphStyle.d.ts +1 -1
  62. package/dist/src/config/StyleTemplate.d.ts +2 -2
  63. package/dist/src/config/xr-config-schema.d.ts +4 -4
  64. package/dist/src/data/CSVDataSource.d.ts +77 -22
  65. package/dist/src/data/ErrorAggregator.d.ts +5 -0
  66. package/dist/src/data/GEXFDataSource.d.ts +12 -61
  67. package/dist/src/data/GraphMLDataSource.d.ts +3 -44
  68. package/dist/src/data/GraphStore.d.ts +322 -15
  69. package/dist/src/data/JsonDataSource.d.ts +43 -1
  70. package/dist/src/data/graph-io-import.d.ts +89 -0
  71. package/dist/src/data/graph-io-records.d.ts +64 -0
  72. package/dist/src/data/lane.d.ts +23 -0
  73. package/dist/src/data/positions.d.ts +13 -0
  74. package/dist/src/data/seedPosition.d.ts +16 -0
  75. package/dist/src/errors/GraphtyError.d.ts +3 -1
  76. package/dist/src/errors/codes.d.ts +23 -0
  77. package/dist/src/events.d.ts +12 -0
  78. package/dist/src/graphty-element.d.ts +149 -54
  79. package/dist/src/input/types.d.ts +2 -0
  80. package/dist/src/layout/D3GraphLayoutEngine.d.ts +17 -3
  81. package/dist/src/layout/FixedLayoutEngine.d.ts +20 -4
  82. package/dist/src/layout/KamadaKawaiLayoutEngine.d.ts +6 -0
  83. package/dist/src/layout/LayoutEngine.d.ts +214 -116
  84. package/dist/src/layout/NGraphLayoutEngine.d.ts +10 -3
  85. package/dist/src/layout/SimulationLayoutEngine.d.ts +8 -3
  86. package/dist/src/managers/AlgorithmManager.d.ts +24 -5
  87. package/dist/src/managers/DataManager.d.ts +258 -181
  88. package/dist/src/managers/EventManager.d.ts +5 -2
  89. package/dist/src/managers/GraphContext.d.ts +7 -0
  90. package/dist/src/managers/InputManager.d.ts +11 -0
  91. package/dist/src/managers/LayoutManager.d.ts +129 -50
  92. package/dist/src/managers/RenderManager.d.ts +14 -1
  93. package/dist/src/managers/UpdateManager.d.ts +20 -0
  94. package/dist/src/screenshot/ScreenshotCapture.d.ts +1 -1
  95. package/dist/src/session/GraphSession.d.ts +83 -6
  96. package/dist/src/session/commands/algo.d.ts +169 -0
  97. package/dist/src/session/commands/config.d.ts +45 -0
  98. package/dist/src/session/commands/data.d.ts +178 -0
  99. package/dist/src/session/commands/doors.d.ts +93 -0
  100. package/dist/src/session/commands/index.d.ts +20 -0
  101. package/dist/src/session/commands/layout.d.ts +104 -0
  102. package/dist/src/session/commands/positions.d.ts +30 -0
  103. package/dist/src/session/commands/sets.d.ts +113 -0
  104. package/dist/src/session/commands/style.d.ts +92 -0
  105. package/dist/src/session/commands/view.d.ts +57 -0
  106. package/dist/src/session/commands/visibility.d.ts +41 -0
  107. package/dist/src/session/data.d.ts +131 -4
  108. package/dist/src/session/index.d.ts +1 -1
  109. package/dist/src/session/planning.d.ts +25 -8
  110. package/dist/src/session/project/Dispatcher.d.ts +905 -0
  111. package/dist/src/session/project/History.d.ts +382 -0
  112. package/dist/src/session/project/arrangement.d.ts +247 -0
  113. package/dist/src/session/project/derive.d.ts +132 -0
  114. package/dist/src/session/project/digest.d.ts +33 -0
  115. package/dist/src/session/project/draft.d.ts +194 -0
  116. package/dist/src/session/project/graphOps.d.ts +304 -0
  117. package/dist/src/session/project/ingest.d.ts +364 -0
  118. package/dist/src/session/project/state.d.ts +145 -0
  119. package/dist/src/session/project/strict.d.ts +68 -0
  120. package/dist/src/session/results/RunResult.d.ts +48 -0
  121. package/dist/src/session/results/statistics.d.ts +20 -0
  122. package/dist/src/session/runs/Run.d.ts +80 -4
  123. package/dist/src/session/runs/RunsApi.d.ts +23 -6
  124. package/dist/src/session/runs/types.d.ts +25 -6
  125. package/dist/src/session/scope/ElementMask.d.ts +14 -0
  126. package/dist/src/session/scope/ScopeApi.d.ts +3 -22
  127. package/dist/src/session/scope/spaces.d.ts +29 -0
  128. package/dist/src/session/sealed.d.ts +22 -0
  129. package/dist/src/session/selection/SelectionApi.d.ts +14 -4
  130. package/dist/src/session/sets/SetsApi.d.ts +13 -5
  131. package/dist/src/session/sets/store.d.ts +54 -53
  132. package/dist/src/session/sets/types.d.ts +5 -2
  133. package/dist/src/session/styles/Layer.d.ts +5 -0
  134. package/dist/src/session/styles/StylesApi.d.ts +68 -17
  135. package/dist/src/session/styles/autoApply.d.ts +64 -53
  136. package/dist/src/session/styles/index.d.ts +3 -3
  137. package/dist/src/session/styles/predicate.d.ts +7 -0
  138. package/dist/src/session/styles/repaint.d.ts +16 -1
  139. package/dist/src/session/styles/sources.d.ts +1 -1
  140. package/dist/src/session/types.d.ts +625 -54
  141. package/dist/src/session/visibility/VisibilityApi.d.ts +38 -18
  142. package/dist/src/session/visibility/filter.d.ts +10 -0
  143. package/dist/src/simple/defineAlgorithm.d.ts +28 -0
  144. package/dist/src/simple/defineLayout.d.ts +35 -0
  145. package/dist/src/simple/defineLogDestination.d.ts +31 -0
  146. package/dist/src/simple/definePalette.d.ts +26 -0
  147. package/dist/src/simple/definition.d.ts +106 -0
  148. package/dist/src/simple/options.d.ts +33 -0
  149. package/dist/src/simple/source.d.ts +49 -0
  150. package/dist/src/simple/types.d.ts +366 -0
  151. package/dist/src/simple/view.d.ts +107 -0
  152. package/dist/webgpu.js +2 -2
  153. package/package.json +10 -12
  154. package/dist/chunks/GraphSession-BhuHSXIo.js +0 -12819
  155. package/dist/chunks/GraphStyle-Cwr55SAE.js +0 -65
  156. package/dist/chunks/algorithms-BJ6DQMOe.js +0 -3777
  157. package/dist/chunks/detect-fyuVnlCT.js +0 -88
  158. package/dist/chunks/interpolation-DY-PNpqX.js +0 -43
  159. package/dist/chunks/optionsFromZod-CKMYSwTz.js +0 -3636
  160. package/dist/chunks/paletteRegistry-BCFSwJGK.js +0 -1196
  161. package/dist/chunks/parse-BMTqt4SS.js +0 -3658
  162. package/dist/src/data/csv-variant-detection.d.ts +0 -29
  163. package/dist/src/data/ingest.d.ts +0 -104
@@ -0,0 +1,669 @@
1
+ import { V as z, Y as W, g as J, I as Q, B as X, G as Z, d as v, O as N, i as R, T as I, P as C, C as L, h as ee, b as ie, R as te, a as _, c as D, e as T } from "./sequential-Zym81qm7.js";
2
+ import { i as ne, f as K } from "./paletteRegistry-De3CGdst.js";
3
+ import { G as oe } from "./pluginRegistry-Ddfl6Mv2.js";
4
+ import { I as w, J as q, K as y, M as re } from "./fields-5uVC1Pll.js";
5
+ const a = ["deuteranopia", "protanopia", "tritanopia"], S = Object.freeze([
6
+ {
7
+ id: "viridis",
8
+ plainName: "Purple to Yellow",
9
+ kind: "sequential",
10
+ colors: z,
11
+ capacity: null,
12
+ colorblindSafe: a
13
+ },
14
+ // Paul Tol, "Colour Schemes" (2021): YlOrBr, trimmed to the steps that stand off a light
15
+ // background. The default for a measurement.
16
+ {
17
+ id: "ylorbr",
18
+ plainName: "Orange to Brown",
19
+ kind: "sequential",
20
+ colors: W,
21
+ capacity: null,
22
+ colorblindSafe: a
23
+ },
24
+ {
25
+ id: "plasma",
26
+ plainName: "Blue to Yellow",
27
+ kind: "sequential",
28
+ colors: J,
29
+ capacity: null,
30
+ colorblindSafe: a
31
+ },
32
+ {
33
+ id: "inferno",
34
+ plainName: "Black to Yellow",
35
+ kind: "sequential",
36
+ colors: Q,
37
+ capacity: null,
38
+ colorblindSafe: a
39
+ },
40
+ {
41
+ id: "blues",
42
+ plainName: "Shades of Blue",
43
+ kind: "sequential",
44
+ colors: X,
45
+ capacity: null,
46
+ colorblindSafe: a
47
+ },
48
+ {
49
+ id: "greens",
50
+ plainName: "Shades of Green",
51
+ kind: "sequential",
52
+ colors: Z,
53
+ capacity: null,
54
+ colorblindSafe: []
55
+ },
56
+ {
57
+ id: "oranges",
58
+ plainName: "Shades of Orange",
59
+ kind: "sequential",
60
+ colors: v,
61
+ capacity: null,
62
+ colorblindSafe: []
63
+ },
64
+ {
65
+ id: "okabe-ito",
66
+ plainName: "Eight Distinct Colours",
67
+ kind: "categorical",
68
+ colors: N,
69
+ capacity: N.length,
70
+ colorblindSafe: a
71
+ },
72
+ {
73
+ id: "tol-vibrant",
74
+ plainName: "Seven Bright Colours",
75
+ kind: "categorical",
76
+ colors: R,
77
+ capacity: R.length,
78
+ colorblindSafe: a
79
+ },
80
+ {
81
+ id: "tol-muted",
82
+ plainName: "Nine Soft Colours",
83
+ kind: "categorical",
84
+ colors: I,
85
+ capacity: I.length,
86
+ colorblindSafe: a
87
+ },
88
+ {
89
+ id: "pastel",
90
+ plainName: "Eight Pale Colours",
91
+ kind: "categorical",
92
+ colors: C,
93
+ capacity: C.length,
94
+ colorblindSafe: a
95
+ },
96
+ {
97
+ id: "carbon",
98
+ plainName: "Five Enterprise Colours",
99
+ kind: "categorical",
100
+ colors: L,
101
+ capacity: L.length,
102
+ colorblindSafe: []
103
+ },
104
+ {
105
+ id: "purple-green",
106
+ plainName: "Purple to Green",
107
+ kind: "diverging",
108
+ colors: ee,
109
+ capacity: null,
110
+ colorblindSafe: a
111
+ },
112
+ {
113
+ id: "blue-orange",
114
+ plainName: "Blue to Orange",
115
+ kind: "diverging",
116
+ colors: ie,
117
+ capacity: null,
118
+ colorblindSafe: a
119
+ },
120
+ {
121
+ id: "red-blue",
122
+ plainName: "Red to Blue",
123
+ kind: "diverging",
124
+ colors: te,
125
+ capacity: null,
126
+ colorblindSafe: []
127
+ },
128
+ {
129
+ id: "blue-highlight",
130
+ plainName: "Blue Highlight",
131
+ kind: "categorical",
132
+ colors: [_.highlighted, _.muted],
133
+ capacity: 2,
134
+ colorblindSafe: a
135
+ },
136
+ {
137
+ id: "green-highlight",
138
+ plainName: "Green Highlight",
139
+ kind: "categorical",
140
+ colors: [D.highlighted, D.muted],
141
+ capacity: 2,
142
+ colorblindSafe: a
143
+ },
144
+ {
145
+ id: "orange-highlight",
146
+ plainName: "Orange Highlight",
147
+ kind: "categorical",
148
+ colors: [T.highlighted, T.muted],
149
+ capacity: 2,
150
+ colorblindSafe: a
151
+ }
152
+ ]);
153
+ function Se(e) {
154
+ return S.find((i) => i.id === e) ?? ne(e);
155
+ }
156
+ function ke(e) {
157
+ const i = S.filter((t) => t.kind === e), n = K().filter((t) => t.kind === e);
158
+ return n.length === 0 ? i : [...i, ...n];
159
+ }
160
+ function Oe() {
161
+ return [...S, ...K()].map((e) => String(e.id));
162
+ }
163
+ const f = {
164
+ name: "reverse",
165
+ plainName: "Reverse",
166
+ technicalName: "reverse",
167
+ type: "boolean",
168
+ default: !1,
169
+ description: "Send the smallest value to the far end of the range instead of the near end."
170
+ }, l = {
171
+ name: "midpoint",
172
+ plainName: "Midpoint",
173
+ technicalName: "midpoint",
174
+ type: "number",
175
+ description: "The value that lands on the middle colour of a diverging palette."
176
+ };
177
+ function x(e, i, n) {
178
+ return {
179
+ name: "bins",
180
+ plainName: e,
181
+ technicalName: "bins",
182
+ type: "integer",
183
+ default: n,
184
+ min: 2,
185
+ max: 20,
186
+ step: 1,
187
+ description: i
188
+ };
189
+ }
190
+ const M = [
191
+ {
192
+ name: "linear",
193
+ plainName: "Even Steps",
194
+ domainKind: "numeric",
195
+ options: [f, l]
196
+ },
197
+ {
198
+ name: "log",
199
+ plainName: "By Order of Magnitude",
200
+ domainKind: "numeric",
201
+ options: [f, l]
202
+ },
203
+ {
204
+ name: "neglog10",
205
+ plainName: "By Significance",
206
+ domainKind: "numeric",
207
+ options: [f, l]
208
+ },
209
+ {
210
+ name: "sqrt",
211
+ plainName: "By Area",
212
+ domainKind: "numeric",
213
+ options: [f, l]
214
+ },
215
+ {
216
+ name: "pow",
217
+ plainName: "Curved",
218
+ domainKind: "numeric",
219
+ options: [
220
+ {
221
+ name: "exponent",
222
+ plainName: "Exponent",
223
+ technicalName: "exponent",
224
+ type: "number",
225
+ default: 1,
226
+ min: 0.1,
227
+ max: 10,
228
+ step: 0.1,
229
+ description: "How hard the curve bends. Below one spreads the small values out; above one spreads the large ones out."
230
+ },
231
+ f,
232
+ l
233
+ ]
234
+ },
235
+ {
236
+ name: "bins",
237
+ plainName: "Equal Ranges",
238
+ domainKind: "numeric",
239
+ options: [
240
+ x("Groups", "How many equally wide ranges to cut the values into.", 5),
241
+ f
242
+ ]
243
+ },
244
+ {
245
+ name: "quantile",
246
+ plainName: "Equal Counts",
247
+ domainKind: "numeric",
248
+ options: [
249
+ x("Groups", "How many groups of equal size to sort the values into.", 4),
250
+ f
251
+ ]
252
+ },
253
+ {
254
+ name: "ordinal",
255
+ plainName: "One Colour per Value",
256
+ domainKind: "categorical",
257
+ options: [f]
258
+ },
259
+ {
260
+ name: "passthrough",
261
+ plainName: "Use the Value As It Is",
262
+ domainKind: "categorical",
263
+ options: []
264
+ }
265
+ ];
266
+ function Ee(e) {
267
+ return M.find((i) => i.name === e);
268
+ }
269
+ function Ne(e) {
270
+ return M.filter((i) => i.domainKind === e);
271
+ }
272
+ const se = /* @__PURE__ */ new Set([
273
+ "fixed.weights",
274
+ "rule.scope",
275
+ "edgeMember.key",
276
+ "edgeMember.dataSource",
277
+ "set.graph",
278
+ "search",
279
+ "threshold.percentile",
280
+ "threshold.z",
281
+ "threshold.population",
282
+ "itemKey.op",
283
+ "itemKey.smallestNode",
284
+ "itemKey.edges",
285
+ "itemKey.binds"
286
+ ]), de = ["visible", "graph", "selection", "largest-component"], ae = ["induced", "listed", "clipped"], ce = ["in", "out", "all"];
287
+ function o(e, i = {}) {
288
+ return new oe({ code: "E_BAD_COMMAND", message: e, source: "data", details: i });
289
+ }
290
+ function c(e) {
291
+ return typeof e == "object" && e !== null && !Array.isArray(e);
292
+ }
293
+ function b(e) {
294
+ return typeof e == "number" && Number.isFinite(e);
295
+ }
296
+ function h(e) {
297
+ return typeof e == "string" || b(e);
298
+ }
299
+ class k {
300
+ constructor(i) {
301
+ this.mode = i;
302
+ }
303
+ /**
304
+ * Meet a kind or field this element does not define: refused at a door, remembered on load.
305
+ * @param name - The kind, or `<node>.<field>`.
306
+ * @param what - How to say it in a refusal.
307
+ */
308
+ unknown(i, n) {
309
+ if (this.mode === "door") {
310
+ const t = se.has(i);
311
+ throw o(
312
+ t ? `"${i}" is reserved for a later release of graphty-element and cannot be used yet.` : `${n} "${i}" is not one graphty-element knows.`,
313
+ t ? { field: i, reserved: !0 } : { name: i }
314
+ );
315
+ }
316
+ this.first ??= i;
317
+ }
318
+ /**
319
+ * Meet every field of a node outside its known list, in code-unit order.
320
+ * @param value - The node.
321
+ * @param node - Its name, for `<node>.<field>`.
322
+ * @param known - The fields it defines.
323
+ */
324
+ fields(i, n, t) {
325
+ for (const r of Object.keys(i).sort())
326
+ i[r] !== void 0 && !t.includes(r) && this.unknown(`${n}.${r}`, "The field");
327
+ }
328
+ }
329
+ function p(e, i) {
330
+ if (!Array.isArray(e))
331
+ throw o(`${i} is a list of node ids.`, { value: e });
332
+ for (const n of e)
333
+ if (!h(n))
334
+ throw o(`${i} holds ${String(n)}, which is not a node id: an id is a string or a finite number.`, {
335
+ id: n
336
+ });
337
+ }
338
+ function B(e, i) {
339
+ if (!c(e))
340
+ throw o(
341
+ "An edge member is an object with a source, a target and one of id, key or ordinal with among. A session edge id is accepted only at a write door, which stores its stable form.",
342
+ { member: e }
343
+ );
344
+ if (i.fields(e, "edgeMember", re), !h(e.source) || !h(e.target))
345
+ throw o("An edge member's source and target are node ids.", { member: e });
346
+ const n = e.ordinal !== void 0;
347
+ if (n !== (e.among !== void 0))
348
+ throw o("An edge member's ordinal and among come together or not at all.", { member: e });
349
+ if ([e.id, e.key, e.ordinal].filter((r) => r !== void 0).length !== 1)
350
+ throw o("An edge member names its edge by exactly one of id, key or ordinal with among.", { member: e });
351
+ if (e.id !== void 0 && !h(e.id))
352
+ throw o("An edge member's id is a string or a finite number.", { member: e });
353
+ if (e.key !== void 0) {
354
+ if (!h(e.key))
355
+ throw o("An edge member's key is a string or a finite number.", { member: e });
356
+ i.unknown("edgeMember.key", "The field");
357
+ }
358
+ if (n) {
359
+ const { ordinal: r, among: d } = e;
360
+ if (!Number.isInteger(d) || d < 1 || !Number.isInteger(r) || r < 0 || r >= d)
361
+ throw o("An edge member's ordinal counts from 0 and is below among, a whole number from 1.", {
362
+ member: e
363
+ });
364
+ }
365
+ }
366
+ function m(e, i) {
367
+ if (typeof e != "string" || e.trim() === "")
368
+ throw o(`${i} needs a query. An empty one matches every element rather than none.`, { where: e });
369
+ }
370
+ function $(e) {
371
+ for (const i of ["min", "max"])
372
+ if (e[i] !== void 0 && !b(e[i]))
373
+ throw o(`A "${String(e.kind)}" leaf's ${i} must be a finite number.`, { [i]: e[i] });
374
+ if (e.min !== void 0 && e.max !== void 0 && e.min > e.max)
375
+ throw o(`A "${String(e.kind)}" leaf's min is above its max.`, { min: e.min, max: e.max });
376
+ }
377
+ function fe(e, i) {
378
+ if (!c(e))
379
+ throw o("An item leaf's item is an object with a result and a key.", { item: e });
380
+ i.fields(e, "resultItem", ["result", "run", "key"]);
381
+ const n = i.mode === "door" ? q(e.result) : e.result;
382
+ if (typeof n != "string" || n === "")
383
+ throw o("An item names its result by the result's id.", { result: e.result });
384
+ if (e.run !== void 0 && (typeof e.run != "string" || e.run === ""))
385
+ throw o("An item's run is the token of the run it holds.", { run: e.run });
386
+ const { key: t } = e;
387
+ if (!c(t))
388
+ throw o(`An item's key is an object, such as { field: "group", value: 3 }.`, { key: t });
389
+ if (t.field === void 0) {
390
+ i.unknown(`itemKey.${Object.keys(t).sort()[0] ?? "{}"}`, "The item key form");
391
+ return;
392
+ }
393
+ if (i.fields(t, "itemKey", ["field", "value"]), typeof t.field != "string" || t.field === "")
394
+ throw o("An item key's field names a field of the result.", { key: t });
395
+ const { value: r } = t;
396
+ if (typeof r != "string" && typeof r != "boolean" && !b(r))
397
+ throw o("An item key's value is a string, a finite number or a boolean.", { key: t });
398
+ }
399
+ function le(e) {
400
+ if (typeof e != "string")
401
+ return !1;
402
+ if (e.startsWith("data."))
403
+ return e.length > 5;
404
+ const i = e.startsWith("results.") ? e.slice(8) : "", n = i.indexOf(".");
405
+ return n > 0 && n < i.length - 1;
406
+ }
407
+ function he(e, i) {
408
+ if (i.fields(e, "threshold", ["kind", "path", "top", "above"]), j(e.path), !le(e.path))
409
+ throw o(`A "threshold" leaf's path is "data.<field>" or "results.<run>.<field>".`, { path: e.path });
410
+ const n = i.mode === "load" && (e.percentile !== void 0 || e.z !== void 0), t = [e.top, e.above].filter((r) => r !== void 0).length;
411
+ if (t !== 1 && !(n && t === 0))
412
+ throw o('A "threshold" leaf has exactly one cut: top or above.', { top: e.top, above: e.above });
413
+ if (e.top !== void 0 && (!Number.isInteger(e.top) || e.top < 0))
414
+ throw o(`A "threshold" leaf's top is a whole number of elements.`, { top: e.top });
415
+ if (e.above !== void 0 && !b(e.above))
416
+ throw o(`A "threshold" leaf's above is a finite number.`, { above: e.above });
417
+ }
418
+ const me = ["data", "results"];
419
+ function j(e) {
420
+ if (typeof e != "string" || e === "")
421
+ return;
422
+ const i = e.split(".")[0];
423
+ if (!me.includes(i))
424
+ throw o(
425
+ `A field path starts with "data." or "results.", so "${e}" is refused: the root "${i}" is reserved.`,
426
+ {
427
+ path: e,
428
+ root: i,
429
+ reason: "reserved-root"
430
+ }
431
+ );
432
+ }
433
+ function G(e, i) {
434
+ i.mode === "door" && j(e);
435
+ }
436
+ function u(e, i) {
437
+ if (!c(e) || typeof e.kind != "string")
438
+ throw o("A rule tree node is an object with a kind.", { node: e });
439
+ const { kind: n } = e, t = (r) => {
440
+ i.fields(e, n, ["kind", ...r]);
441
+ };
442
+ switch (n) {
443
+ case "expression":
444
+ case "edges":
445
+ t(["where"]), m(e.where, `An "${n}" leaf`);
446
+ return;
447
+ case "range":
448
+ t(["attribute", "min", "max"]), m(e.attribute, `A "range" leaf's attribute`), G(e.attribute, i), $(e);
449
+ return;
450
+ case "categories":
451
+ if (t(["attribute", "values"]), m(e.attribute, `A "categories" leaf's attribute`), G(e.attribute, i), !Array.isArray(e.values) || !e.values.every((r) => typeof r == "string"))
452
+ throw o(`A "categories" leaf's values are a list of strings.`, { values: e.values });
453
+ return;
454
+ case "degree":
455
+ if (t(["min", "max", "direction"]), $(e), e.direction !== void 0 && !ce.includes(e.direction))
456
+ throw o(`A "degree" leaf's direction is "in", "out" or "all".`, { direction: e.direction });
457
+ return;
458
+ case "component":
459
+ if (t(["id"]), !Number.isInteger(e.id) || e.id < 0)
460
+ throw o(`A "component" leaf's id is a component number, counting from 0.`, { id: e.id });
461
+ return;
462
+ case "neighborhood":
463
+ if (t(["seeds", "depth"]), p(e.seeds, `A "neighborhood" leaf's seeds`), !Number.isInteger(e.depth) || e.depth < 0)
464
+ throw o(`A "neighborhood" leaf's depth is a whole number of hops, from 0.`, { depth: e.depth });
465
+ return;
466
+ case "member":
467
+ t(["of"]), F(e.of, i);
468
+ return;
469
+ case "item":
470
+ t(["item"]), fe(e.item, i);
471
+ return;
472
+ case "threshold":
473
+ he(e, i);
474
+ return;
475
+ case "all":
476
+ case "any":
477
+ if (t(["of"]), !Array.isArray(e.of))
478
+ throw o(`An "${n}" node's operands are a list.`, { of: e.of });
479
+ for (const r of e.of)
480
+ u(r, i);
481
+ return;
482
+ case "not":
483
+ t(["of"]), u(e.of, i);
484
+ return;
485
+ default:
486
+ i.unknown(n, "The rule leaf kind");
487
+ }
488
+ }
489
+ function ge(e, i) {
490
+ return e === "visible" ? "clipped" : c(e) ? c(e.define) ? e.define.kind === "path" ? "listed" : typeof e.define.reading == "string" ? e.define.reading : "induced" : typeof e.set == "string" ? i?.(e.set) ?? "induced" : "induced" : "induced";
491
+ }
492
+ function A(e, i, n) {
493
+ if (!c(e))
494
+ return !1;
495
+ switch (e.kind) {
496
+ case "edges":
497
+ return !0;
498
+ case "member":
499
+ return ge(e.of, i) !== "induced";
500
+ case "item": {
501
+ const t = c(e.item) ? e.item : {}, r = c(t.key) ? t.key : {}, d = q(t.result);
502
+ return typeof d == "string" && typeof r.field == "string" && n?.(`results.${d}.${r.field}`).includes("edge") === !0;
503
+ }
504
+ case "threshold":
505
+ return typeof e.path == "string" && n?.(e.path).includes("edge") === !0;
506
+ case "all":
507
+ case "any":
508
+ return Array.isArray(e.of) && e.of.some((t) => A(t, i, n));
509
+ case "not":
510
+ return A(e.of, i, n);
511
+ default:
512
+ return !1;
513
+ }
514
+ }
515
+ function pe() {
516
+ return o(
517
+ `An induced set derives its edges from its nodes, so this rule's edge-speaking leaf would be ignored. Read it "clipped" or "listed" instead.`,
518
+ { reason: "induced-edge-leaf" }
519
+ );
520
+ }
521
+ function F(e, i) {
522
+ if (typeof e == "string") {
523
+ de.includes(e) || i.unknown(e, "The scope keyword");
524
+ return;
525
+ }
526
+ if (!c(e))
527
+ throw o(
528
+ 'A scope is "visible", "graph", "selection", "largest-component", { set }, { where }, { nodes } or { define }.',
529
+ {
530
+ scope: e
531
+ }
532
+ );
533
+ if (e.set !== void 0) {
534
+ if (i.fields(e, "set", ["set"]), typeof e.set != "string" || e.set === "")
535
+ throw o("A { set } scope names a set by its id.", { scope: e });
536
+ } else e.where !== void 0 ? (i.fields(e, "where", ["where"]), m(e.where, "A { where } scope")) : e.nodes !== void 0 ? (i.fields(e, "nodes", ["nodes"]), p(e.nodes, "A { nodes } scope")) : e.define !== void 0 ? (i.fields(e, "define", ["define"]), U(e.define, i)) : i.unknown(Object.keys(e).sort()[0] ?? "{}", "The scope form");
537
+ }
538
+ function P(e) {
539
+ if (!ae.includes(e))
540
+ throw o(`A set's reading is "induced", "listed" or "clipped".`, { reading: e });
541
+ }
542
+ function H(e, i) {
543
+ const n = new k(i);
544
+ return U(e, n), n;
545
+ }
546
+ function U(e, i) {
547
+ if (!c(e) || typeof e.kind != "string")
548
+ throw o('A set definition is an object whose kind is "fixed", "rule" or "path".', { definition: e });
549
+ switch (e.kind) {
550
+ case "fixed":
551
+ if (i.fields(e, "fixed", y.fixed), p(e.nodes, "A fixed set's nodes"), P(e.reading), e.edges !== void 0) {
552
+ if (!Array.isArray(e.edges))
553
+ throw o("A fixed set's edges are a list of edge members.", { edges: e.edges });
554
+ for (const n of e.edges)
555
+ B(n, i);
556
+ }
557
+ break;
558
+ case "rule":
559
+ if (i.fields(e, "rule", y.rule), P(e.reading), typeof e.where == "string" ? m(e.where, "A rule") : u(e.where, i), i.mode === "door" && e.reading === "induced" && A(e.where))
560
+ throw pe();
561
+ break;
562
+ case "path": {
563
+ i.fields(e, "path", y.path), p(e.nodes, "A path's nodes");
564
+ const n = e.nodes;
565
+ if (n.length === 0)
566
+ throw o("A path has at least one node; one node is a path of length zero.");
567
+ if (e.directed !== void 0 && typeof e.directed != "boolean")
568
+ throw o("A path's directed is true or false.", { directed: e.directed });
569
+ if (e.edges !== void 0) {
570
+ if (!Array.isArray(e.edges) || e.edges.length !== n.length - 1)
571
+ throw o(`A path of ${n.length} nodes names ${n.length - 1} steps' edges, one per step.`, {
572
+ edges: e.edges
573
+ });
574
+ e.edges.forEach((t, r) => {
575
+ if (t !== null) {
576
+ if (Array.isArray(t) && t.length === 0)
577
+ throw o(
578
+ "A path step's edge group names at least one edge; null means every edge of the pair."
579
+ );
580
+ for (const d of Array.isArray(t) ? t : [t])
581
+ B(d, i), ue(d, n[r], n[r + 1], r, i);
582
+ }
583
+ });
584
+ }
585
+ break;
586
+ }
587
+ default:
588
+ i.unknown(e.kind, "The set definition kind");
589
+ }
590
+ }
591
+ function ue(e, i, n, t, r) {
592
+ const d = e.source === i && e.target === n || e.source === n && e.target === i;
593
+ if (r.mode === "door" && !d)
594
+ throw o(
595
+ `A path's step ${t} names an edge from "${String(e.source)}" to "${String(e.target)}", which does not join its nodes.`,
596
+ {
597
+ step: t,
598
+ edge: e,
599
+ nodes: [i, n]
600
+ }
601
+ );
602
+ }
603
+ function Re(e) {
604
+ return H(e, "door"), w(e);
605
+ }
606
+ function Ie(e) {
607
+ const { first: i } = H(e, "load"), n = w(e);
608
+ return i === void 0 ? { definition: n } : { definition: n, opaque: { first: i } };
609
+ }
610
+ function Ce(e) {
611
+ u(e, new k("door"));
612
+ }
613
+ function Le(e) {
614
+ return F(e, new k("door")), c(e) && e.define !== void 0 ? Object.freeze({ define: w(e.define) }) : e;
615
+ }
616
+ function _e(e, i) {
617
+ const n = (t) => {
618
+ if (!c(t))
619
+ return t;
620
+ const r = (s, g) => g === t[s] ? t : { ...t, [s]: g }, d = (s, g) => {
621
+ if (!Array.isArray(s))
622
+ return s;
623
+ const E = s.map(g);
624
+ return E.every((V, Y) => V === s[Y]) ? s : E;
625
+ }, O = (s) => typeof s == "string" || c(s) ? i(s) : s;
626
+ if (t.define !== void 0)
627
+ return r("define", n(t.define));
628
+ if (t.match === "member")
629
+ return r("of", n(t.of));
630
+ switch (t.kind) {
631
+ case "fixed":
632
+ case "path":
633
+ return r(
634
+ "edges",
635
+ d(t.edges, (s) => Array.isArray(s) ? d(s, O) : O(s))
636
+ );
637
+ case "rule":
638
+ return r("where", n(t.where));
639
+ case "member":
640
+ return r("of", n(t.of));
641
+ case "all":
642
+ case "any":
643
+ return r("of", d(t.of, n));
644
+ case "not":
645
+ return r("of", n(t.of));
646
+ default:
647
+ return t;
648
+ }
649
+ };
650
+ return n(e);
651
+ }
652
+ export {
653
+ ae as E,
654
+ S as P,
655
+ M as S,
656
+ Re as a,
657
+ Se as b,
658
+ ke as c,
659
+ Ne as d,
660
+ A as e,
661
+ _e as f,
662
+ Ce as g,
663
+ pe as i,
664
+ Oe as k,
665
+ Ie as l,
666
+ Le as p,
667
+ ge as r,
668
+ Ee as s
669
+ };