@nakafa/aksara-contracts 8.16.0 → 8.17.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.
@@ -30,8 +30,9 @@ export declare function spaceFormulaFields(object: SpaceMathObject): readonly Fo
30
30
  /** Reports one formula that reads a name it may not, at its root path. */
31
31
  export declare function strayIssues(field: FormulaField, declared: readonly string[], root: readonly (string | number)[]): Schema.FilterIssue[];
32
32
  /**
33
- * Reports every formula that reads a name its object does not offer, and every
34
- * slider whose name repeats an earlier one.
33
+ * Reports every formula that reads a name its object does not offer, every
34
+ * slider whose name repeats an earlier one, and every slider that drives no
35
+ * object in the visual scene.
35
36
  */
36
37
  export declare function formulaScopeIssues<Object>(objects: readonly Object[], fields: (object: Object) => readonly FormulaField[], parameters: readonly FormulaParameter[]): readonly Schema.FilterIssue[];
37
38
  /** Each slider's starting value by its name, the scope a scene first draws with. */
@@ -104,8 +104,9 @@ export function strayIssues(field, declared, root) {
104
104
  ];
105
105
  }
106
106
  /**
107
- * Reports every formula that reads a name its object does not offer, and every
108
- * slider whose name repeats an earlier one.
107
+ * Reports every formula that reads a name its object does not offer, every
108
+ * slider whose name repeats an earlier one, and every slider that drives no
109
+ * object in the visual scene.
109
110
  */
110
111
  export function formulaScopeIssues(objects, fields, parameters) {
111
112
  const names = Arr.map(parameters, ({ name }) => name);
@@ -118,8 +119,18 @@ export function formulaScopeIssues(objects, fields, parameters) {
118
119
  },
119
120
  ]
120
121
  : []);
122
+ const usedInObjects = Arr.reduce(Arr.flatMap(objects, fields), HashSet.empty(), (acc, field) => HashSet.union(acc, namesOf(field)));
123
+ const unused = Arr.flatMap(parameters, ({ name }, index) => Arr.contains(Arr.take(names, index), name) ||
124
+ HashSet.has(usedInObjects, name)
125
+ ? []
126
+ : [
127
+ {
128
+ issue: `Expected slider "${name}" to drive at least one object in the visual scene.`,
129
+ path: ["parameters", index, "name"],
130
+ },
131
+ ]);
121
132
  const unknown = Arr.flatMap(objects, (object, index) => Arr.flatMap(fields(object), (field) => strayIssues(field, declared, ["objects", index])));
122
- return [...repeated, ...unknown];
133
+ return [...repeated, ...unused, ...unknown];
123
134
  }
124
135
  /** Each slider's starting value by its name, the scope a scene first draws with. */
125
136
  export function parameterScope(parameters) {
@@ -0,0 +1,425 @@
1
+ import { Schema } from "effect";
2
+ import type { RichSlot } from "#contracts/visual/card";
3
+ /**
4
+ * Ecosystem biology labs covering trophic pyramids, quadrat field sampling,
5
+ * and ecological succession.
6
+ */
7
+ export declare function ecosystemVisuals<E>(rich: RichSlot<E>): {
8
+ EcologicalSuccessionLab: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
9
+ readonly description: RichSlot<E>;
10
+ readonly footer: Schema.optionalKey<Schema.Codec<readonly [{
11
+ readonly marks?: readonly [{
12
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
13
+ } | {
14
+ readonly attrs: {
15
+ readonly href: string;
16
+ };
17
+ readonly type: "link";
18
+ } | {
19
+ readonly attrs: {
20
+ readonly variant: "success" | "warning" | null;
21
+ };
22
+ readonly type: "highlight";
23
+ }, ...({
24
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
25
+ } | {
26
+ readonly attrs: {
27
+ readonly href: string;
28
+ };
29
+ readonly type: "link";
30
+ } | {
31
+ readonly attrs: {
32
+ readonly variant: "success" | "warning" | null;
33
+ };
34
+ readonly type: "highlight";
35
+ })[]];
36
+ readonly text: string;
37
+ readonly type: "text";
38
+ } | {
39
+ readonly attrs: {
40
+ readonly latex: string;
41
+ };
42
+ readonly marks?: readonly [{
43
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
44
+ } | {
45
+ readonly attrs: {
46
+ readonly href: string;
47
+ };
48
+ readonly type: "link";
49
+ } | {
50
+ readonly attrs: {
51
+ readonly variant: "success" | "warning" | null;
52
+ };
53
+ readonly type: "highlight";
54
+ }, ...({
55
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
56
+ } | {
57
+ readonly attrs: {
58
+ readonly href: string;
59
+ };
60
+ readonly type: "link";
61
+ } | {
62
+ readonly attrs: {
63
+ readonly variant: "success" | "warning" | null;
64
+ };
65
+ readonly type: "highlight";
66
+ })[]];
67
+ readonly type: "mathInline";
68
+ }, ...({
69
+ readonly marks?: readonly [{
70
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
71
+ } | {
72
+ readonly attrs: {
73
+ readonly href: string;
74
+ };
75
+ readonly type: "link";
76
+ } | {
77
+ readonly attrs: {
78
+ readonly variant: "success" | "warning" | null;
79
+ };
80
+ readonly type: "highlight";
81
+ }, ...({
82
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
83
+ } | {
84
+ readonly attrs: {
85
+ readonly href: string;
86
+ };
87
+ readonly type: "link";
88
+ } | {
89
+ readonly attrs: {
90
+ readonly variant: "success" | "warning" | null;
91
+ };
92
+ readonly type: "highlight";
93
+ })[]];
94
+ readonly text: string;
95
+ readonly type: "text";
96
+ } | {
97
+ readonly attrs: {
98
+ readonly latex: string;
99
+ };
100
+ readonly marks?: readonly [{
101
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
102
+ } | {
103
+ readonly attrs: {
104
+ readonly href: string;
105
+ };
106
+ readonly type: "link";
107
+ } | {
108
+ readonly attrs: {
109
+ readonly variant: "success" | "warning" | null;
110
+ };
111
+ readonly type: "highlight";
112
+ }, ...({
113
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
114
+ } | {
115
+ readonly attrs: {
116
+ readonly href: string;
117
+ };
118
+ readonly type: "link";
119
+ } | {
120
+ readonly attrs: {
121
+ readonly variant: "success" | "warning" | null;
122
+ };
123
+ readonly type: "highlight";
124
+ })[]];
125
+ readonly type: "mathInline";
126
+ })[]], E, never, never>>;
127
+ readonly title: RichSlot<E>;
128
+ readonly labels: Schema.Struct<{
129
+ readonly biodiversity: Schema.optionalKey<RichSlot<E>>;
130
+ readonly parts: Schema.$Record<Schema.Literals<readonly ["bedrock", "topsoil", "pioneerPlant", "shrubLayer", "canopyTree"]>, Schema.Trimmed>;
131
+ readonly pathway: Schema.Trimmed;
132
+ readonly pathways: Schema.$Record<Schema.Literals<readonly ["primary", "secondary"]>, Schema.optionalKey<Schema.Trimmed>>;
133
+ readonly soilDepth: Schema.optionalKey<RichSlot<E>>;
134
+ readonly stage: Schema.Trimmed;
135
+ readonly stages: Schema.$Record<Schema.Literals<readonly ["bareRock", "lichenMoss", "grassShrub", "youngWoodland", "climaxForest"]>, Schema.optionalKey<Schema.Struct<{
136
+ readonly name: Schema.Trimmed;
137
+ readonly summary: RichSlot<E>;
138
+ }>>>;
139
+ readonly view: Schema.Trimmed;
140
+ }>;
141
+ readonly pathways: Schema.NonEmptyArray<Schema.Literals<readonly ["primary", "secondary"]>>;
142
+ readonly stages: Schema.NonEmptyArray<Schema.Literals<readonly ["bareRock", "lichenMoss", "grassShrub", "youngWoodland", "climaxForest"]>>;
143
+ }>, "figure">;
144
+ FoodWebTrophicLab: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
145
+ readonly description: RichSlot<E>;
146
+ readonly footer: Schema.optionalKey<Schema.Codec<readonly [{
147
+ readonly marks?: readonly [{
148
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
149
+ } | {
150
+ readonly attrs: {
151
+ readonly href: string;
152
+ };
153
+ readonly type: "link";
154
+ } | {
155
+ readonly attrs: {
156
+ readonly variant: "success" | "warning" | null;
157
+ };
158
+ readonly type: "highlight";
159
+ }, ...({
160
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
161
+ } | {
162
+ readonly attrs: {
163
+ readonly href: string;
164
+ };
165
+ readonly type: "link";
166
+ } | {
167
+ readonly attrs: {
168
+ readonly variant: "success" | "warning" | null;
169
+ };
170
+ readonly type: "highlight";
171
+ })[]];
172
+ readonly text: string;
173
+ readonly type: "text";
174
+ } | {
175
+ readonly attrs: {
176
+ readonly latex: string;
177
+ };
178
+ readonly marks?: readonly [{
179
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
180
+ } | {
181
+ readonly attrs: {
182
+ readonly href: string;
183
+ };
184
+ readonly type: "link";
185
+ } | {
186
+ readonly attrs: {
187
+ readonly variant: "success" | "warning" | null;
188
+ };
189
+ readonly type: "highlight";
190
+ }, ...({
191
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
192
+ } | {
193
+ readonly attrs: {
194
+ readonly href: string;
195
+ };
196
+ readonly type: "link";
197
+ } | {
198
+ readonly attrs: {
199
+ readonly variant: "success" | "warning" | null;
200
+ };
201
+ readonly type: "highlight";
202
+ })[]];
203
+ readonly type: "mathInline";
204
+ }, ...({
205
+ readonly marks?: readonly [{
206
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
207
+ } | {
208
+ readonly attrs: {
209
+ readonly href: string;
210
+ };
211
+ readonly type: "link";
212
+ } | {
213
+ readonly attrs: {
214
+ readonly variant: "success" | "warning" | null;
215
+ };
216
+ readonly type: "highlight";
217
+ }, ...({
218
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
219
+ } | {
220
+ readonly attrs: {
221
+ readonly href: string;
222
+ };
223
+ readonly type: "link";
224
+ } | {
225
+ readonly attrs: {
226
+ readonly variant: "success" | "warning" | null;
227
+ };
228
+ readonly type: "highlight";
229
+ })[]];
230
+ readonly text: string;
231
+ readonly type: "text";
232
+ } | {
233
+ readonly attrs: {
234
+ readonly latex: string;
235
+ };
236
+ readonly marks?: readonly [{
237
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
238
+ } | {
239
+ readonly attrs: {
240
+ readonly href: string;
241
+ };
242
+ readonly type: "link";
243
+ } | {
244
+ readonly attrs: {
245
+ readonly variant: "success" | "warning" | null;
246
+ };
247
+ readonly type: "highlight";
248
+ }, ...({
249
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
250
+ } | {
251
+ readonly attrs: {
252
+ readonly href: string;
253
+ };
254
+ readonly type: "link";
255
+ } | {
256
+ readonly attrs: {
257
+ readonly variant: "success" | "warning" | null;
258
+ };
259
+ readonly type: "highlight";
260
+ })[]];
261
+ readonly type: "mathInline";
262
+ })[]], E, never, never>>;
263
+ readonly title: RichSlot<E>;
264
+ readonly energyInput: Schema.Struct<{
265
+ readonly max: Schema.Finite;
266
+ readonly min: Schema.Finite;
267
+ readonly value: Schema.Finite;
268
+ }>;
269
+ readonly labels: Schema.Struct<{
270
+ readonly energyCascade: Schema.optionalKey<RichSlot<E>>;
271
+ readonly energyInput: Schema.Trimmed;
272
+ readonly outcome: Schema.optionalKey<RichSlot<E>>;
273
+ readonly parts: Schema.$Record<Schema.Literals<readonly ["producer", "primaryConsumer", "secondaryConsumer", "tertiaryConsumer", "decomposer", "heatLoss"]>, Schema.Trimmed>;
274
+ readonly scenario: Schema.Trimmed;
275
+ readonly scenarios: Schema.$Record<Schema.Literals<readonly ["balanced", "removePredator", "algalBloom", "overharvest"]>, Schema.optionalKey<Schema.Struct<{
276
+ readonly effect: RichSlot<E>;
277
+ readonly name: Schema.Trimmed;
278
+ }>>>;
279
+ readonly view: Schema.Trimmed;
280
+ }>;
281
+ readonly scenarios: Schema.NonEmptyArray<Schema.Literals<readonly ["balanced", "removePredator", "algalBloom", "overharvest"]>>;
282
+ }>, "figure">;
283
+ QuadratSamplingLab: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
284
+ readonly description: RichSlot<E>;
285
+ readonly footer: Schema.optionalKey<Schema.Codec<readonly [{
286
+ readonly marks?: readonly [{
287
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
288
+ } | {
289
+ readonly attrs: {
290
+ readonly href: string;
291
+ };
292
+ readonly type: "link";
293
+ } | {
294
+ readonly attrs: {
295
+ readonly variant: "success" | "warning" | null;
296
+ };
297
+ readonly type: "highlight";
298
+ }, ...({
299
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
300
+ } | {
301
+ readonly attrs: {
302
+ readonly href: string;
303
+ };
304
+ readonly type: "link";
305
+ } | {
306
+ readonly attrs: {
307
+ readonly variant: "success" | "warning" | null;
308
+ };
309
+ readonly type: "highlight";
310
+ })[]];
311
+ readonly text: string;
312
+ readonly type: "text";
313
+ } | {
314
+ readonly attrs: {
315
+ readonly latex: string;
316
+ };
317
+ readonly marks?: readonly [{
318
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
319
+ } | {
320
+ readonly attrs: {
321
+ readonly href: string;
322
+ };
323
+ readonly type: "link";
324
+ } | {
325
+ readonly attrs: {
326
+ readonly variant: "success" | "warning" | null;
327
+ };
328
+ readonly type: "highlight";
329
+ }, ...({
330
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
331
+ } | {
332
+ readonly attrs: {
333
+ readonly href: string;
334
+ };
335
+ readonly type: "link";
336
+ } | {
337
+ readonly attrs: {
338
+ readonly variant: "success" | "warning" | null;
339
+ };
340
+ readonly type: "highlight";
341
+ })[]];
342
+ readonly type: "mathInline";
343
+ }, ...({
344
+ readonly marks?: readonly [{
345
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
346
+ } | {
347
+ readonly attrs: {
348
+ readonly href: string;
349
+ };
350
+ readonly type: "link";
351
+ } | {
352
+ readonly attrs: {
353
+ readonly variant: "success" | "warning" | null;
354
+ };
355
+ readonly type: "highlight";
356
+ }, ...({
357
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
358
+ } | {
359
+ readonly attrs: {
360
+ readonly href: string;
361
+ };
362
+ readonly type: "link";
363
+ } | {
364
+ readonly attrs: {
365
+ readonly variant: "success" | "warning" | null;
366
+ };
367
+ readonly type: "highlight";
368
+ })[]];
369
+ readonly text: string;
370
+ readonly type: "text";
371
+ } | {
372
+ readonly attrs: {
373
+ readonly latex: string;
374
+ };
375
+ readonly marks?: readonly [{
376
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
377
+ } | {
378
+ readonly attrs: {
379
+ readonly href: string;
380
+ };
381
+ readonly type: "link";
382
+ } | {
383
+ readonly attrs: {
384
+ readonly variant: "success" | "warning" | null;
385
+ };
386
+ readonly type: "highlight";
387
+ }, ...({
388
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
389
+ } | {
390
+ readonly attrs: {
391
+ readonly href: string;
392
+ };
393
+ readonly type: "link";
394
+ } | {
395
+ readonly attrs: {
396
+ readonly variant: "success" | "warning" | null;
397
+ };
398
+ readonly type: "highlight";
399
+ })[]];
400
+ readonly type: "mathInline";
401
+ })[]], E, never, never>>;
402
+ readonly title: RichSlot<E>;
403
+ readonly labels: Schema.Struct<{
404
+ readonly coverage: Schema.optionalKey<RichSlot<E>>;
405
+ readonly density: Schema.optionalKey<RichSlot<E>>;
406
+ readonly method: Schema.Trimmed;
407
+ readonly methods: Schema.$Record<Schema.Literals<readonly ["random", "beltTransect"]>, Schema.optionalKey<Schema.Trimmed>>;
408
+ readonly organism: Schema.Trimmed;
409
+ readonly organisms: Schema.$Record<Schema.Literals<readonly ["clover", "fern", "moss"]>, Schema.optionalKey<Schema.Struct<{
410
+ readonly habit: RichSlot<E>;
411
+ readonly name: Schema.Trimmed;
412
+ }>>>;
413
+ readonly parts: Schema.$Record<Schema.Literals<readonly ["quadratFrame", "transectLine", "gridPlot", "canopy", "markerFlag"]>, Schema.Trimmed>;
414
+ readonly quadrats: Schema.Trimmed;
415
+ readonly view: Schema.Trimmed;
416
+ }>;
417
+ readonly methods: Schema.NonEmptyArray<Schema.Literals<readonly ["random", "beltTransect"]>>;
418
+ readonly organisms: Schema.NonEmptyArray<Schema.Literals<readonly ["clover", "fern", "moss"]>>;
419
+ readonly quadrats: Schema.Struct<{
420
+ readonly max: Schema.Int;
421
+ readonly min: Schema.Int;
422
+ readonly value: Schema.Int;
423
+ }>;
424
+ }>, "figure">;
425
+ };
@@ -0,0 +1,140 @@
1
+ import { Schema } from "effect";
2
+ import { byIds, byPickedIds, cardFields, namesEach, TextSchema, } from "#contracts/visual/card";
3
+ import { answerAt, figure } from "#contracts/visual/entry";
4
+ /** A strictly positive finite bound for ecological sliders. */
5
+ const PositiveSchema = Schema.Finite.check(Schema.isGreaterThan(0));
6
+ /** A positive slider whose minimum sits below its maximum. */
7
+ const PositiveSliderSchema = Schema.Struct({
8
+ max: PositiveSchema,
9
+ min: PositiveSchema,
10
+ value: PositiveSchema,
11
+ }).check(Schema.makeFilter(({ max, min, value }) => min < max && min <= value && value <= max, {
12
+ message: "Expected a positive slider range whose minimum is below its maximum, with the starting value between them.",
13
+ }));
14
+ /** A positive integer count slider for quadrat sampling. */
15
+ const CountSliderSchema = Schema.Struct({
16
+ max: Schema.Int.check(Schema.isGreaterThan(1)),
17
+ min: Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)),
18
+ value: Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)),
19
+ }).check(Schema.makeFilter(({ max, min, value }) => min < max && min <= value && value <= max, {
20
+ message: "Expected a quadrat count range whose minimum is below its maximum, with the starting value between them.",
21
+ }));
22
+ const TROPHIC_SCENARIOS = [
23
+ "balanced",
24
+ "removePredator",
25
+ "algalBloom",
26
+ "overharvest",
27
+ ];
28
+ const QUADRAT_ORGANISMS = ["clover", "fern", "moss"];
29
+ const SAMPLING_METHODS = ["random", "beltTransect"];
30
+ const SUCCESSION_PATHWAYS = ["primary", "secondary"];
31
+ const SUCCESSION_STAGES = [
32
+ "bareRock",
33
+ "lichenMoss",
34
+ "grassShrub",
35
+ "youngWoodland",
36
+ "climaxForest",
37
+ ];
38
+ /**
39
+ * Props of `FoodWebTrophicLab`: a 3D trophic energy pyramid and interconnected
40
+ * food web modeling the 10% energy transfer rule and ecosystem disturbances.
41
+ * Energy cascade and ecosystem outcome readouts are optional answer state.
42
+ */
43
+ function foodWebTrophicLab(rich) {
44
+ return figure(Schema.Struct({
45
+ ...cardFields(rich),
46
+ energyInput: PositiveSliderSchema,
47
+ labels: Schema.Struct({
48
+ energyCascade: Schema.optionalKey(rich),
49
+ energyInput: TextSchema,
50
+ outcome: Schema.optionalKey(rich),
51
+ parts: byIds([
52
+ "producer",
53
+ "primaryConsumer",
54
+ "secondaryConsumer",
55
+ "tertiaryConsumer",
56
+ "decomposer",
57
+ "heatLoss",
58
+ ], TextSchema),
59
+ scenario: TextSchema,
60
+ scenarios: byPickedIds(TROPHIC_SCENARIOS, Schema.Struct({
61
+ effect: rich,
62
+ name: TextSchema,
63
+ })),
64
+ view: TextSchema,
65
+ }),
66
+ scenarios: Schema.NonEmptyArray(Schema.Literals(TROPHIC_SCENARIOS)).check(Schema.isUnique()),
67
+ }).check(Schema.makeFilter(({ labels, scenarios }) => namesEach(scenarios, labels.scenarios), {
68
+ message: "Expected a name and ecological effect note for every trophic scenario shown, and no other.",
69
+ })), answerAt(["labels", "energyCascade"], ["labels", "outcome"]));
70
+ }
71
+ /**
72
+ * Props of `QuadratSamplingLab`: a 3D ecological field grid comparing random
73
+ * quadrat throws and belt-transect sampling to estimate population density and
74
+ * percentage ground coverage. Density and coverage readouts are optional answer
75
+ * state.
76
+ */
77
+ function quadratSamplingLab(rich) {
78
+ return figure(Schema.Struct({
79
+ ...cardFields(rich),
80
+ labels: Schema.Struct({
81
+ coverage: Schema.optionalKey(rich),
82
+ density: Schema.optionalKey(rich),
83
+ method: TextSchema,
84
+ methods: byPickedIds(SAMPLING_METHODS, TextSchema),
85
+ organism: TextSchema,
86
+ organisms: byPickedIds(QUADRAT_ORGANISMS, Schema.Struct({
87
+ habit: rich,
88
+ name: TextSchema,
89
+ })),
90
+ parts: byIds(["quadratFrame", "transectLine", "gridPlot", "canopy", "markerFlag"], TextSchema),
91
+ quadrats: TextSchema,
92
+ view: TextSchema,
93
+ }),
94
+ methods: Schema.NonEmptyArray(Schema.Literals(SAMPLING_METHODS)).check(Schema.isUnique()),
95
+ organisms: Schema.NonEmptyArray(Schema.Literals(QUADRAT_ORGANISMS)).check(Schema.isUnique()),
96
+ quadrats: CountSliderSchema,
97
+ }).check(Schema.makeFilter(({ labels, methods, organisms }) => namesEach(methods, labels.methods) &&
98
+ namesEach(organisms, labels.organisms), {
99
+ message: "Expected a name for every sampling method and organism shown, and no other.",
100
+ })), answerAt(["labels", "density"], ["labels", "coverage"]));
101
+ }
102
+ /**
103
+ * Props of `EcologicalSuccessionLab`: a 3D landscape diorama progressing
104
+ * through primary and secondary succession from pioneer colonization to climax
105
+ * forest. Soil depth and biodiversity readouts are optional answer state.
106
+ */
107
+ function ecologicalSuccessionLab(rich) {
108
+ return figure(Schema.Struct({
109
+ ...cardFields(rich),
110
+ labels: Schema.Struct({
111
+ biodiversity: Schema.optionalKey(rich),
112
+ parts: byIds(["bedrock", "topsoil", "pioneerPlant", "shrubLayer", "canopyTree"], TextSchema),
113
+ pathway: TextSchema,
114
+ pathways: byPickedIds(SUCCESSION_PATHWAYS, TextSchema),
115
+ soilDepth: Schema.optionalKey(rich),
116
+ stage: TextSchema,
117
+ stages: byPickedIds(SUCCESSION_STAGES, Schema.Struct({
118
+ name: TextSchema,
119
+ summary: rich,
120
+ })),
121
+ view: TextSchema,
122
+ }),
123
+ pathways: Schema.NonEmptyArray(Schema.Literals(SUCCESSION_PATHWAYS)).check(Schema.isUnique()),
124
+ stages: Schema.NonEmptyArray(Schema.Literals(SUCCESSION_STAGES)).check(Schema.isUnique()),
125
+ }).check(Schema.makeFilter(({ labels, pathways, stages }) => namesEach(pathways, labels.pathways) &&
126
+ namesEach(stages, labels.stages), {
127
+ message: "Expected a name for every succession pathway and stage shown, and no other.",
128
+ })), answerAt(["labels", "soilDepth"], ["labels", "biodiversity"]));
129
+ }
130
+ /**
131
+ * Ecosystem biology labs covering trophic pyramids, quadrat field sampling,
132
+ * and ecological succession.
133
+ */
134
+ export function ecosystemVisuals(rich) {
135
+ return {
136
+ EcologicalSuccessionLab: ecologicalSuccessionLab(rich),
137
+ FoodWebTrophicLab: foodWebTrophicLab(rich),
138
+ QuadratSamplingLab: quadratSamplingLab(rich),
139
+ };
140
+ }