@elaraai/east-plugin 1.0.112 → 1.0.114

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 (2) hide show
  1. package/index.json +376 -43
  2. package/package.json +3 -3
package/index.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "version": 2,
3
3
  "stats": {
4
- "totalEntries": 1385,
5
- "totalFiles": 226,
4
+ "totalEntries": 1394,
5
+ "totalFiles": 228,
6
6
  "packages": {
7
7
  "east": 595,
8
8
  "east-node-std": 55,
9
9
  "east-node-io": 63,
10
10
  "east-py-datascience": 94,
11
11
  "east-ui": 308,
12
- "e3-ui": 220,
12
+ "e3-ui": 229,
13
13
  "e3": 36,
14
14
  "e3-ui-cli": 8,
15
15
  "e3-create": 6
@@ -40399,7 +40399,7 @@
40399
40399
  "languages": [
40400
40400
  "tsx"
40401
40401
  ],
40402
- "source": "// The smallest board over the app's own records: bins with only the board's roles — their bay, time, load, m³, split across kilns and drying time — the bays, the kilns and the day's loads, and the yard's fit on e3. No library, no inspector and no Publish; every gesture is still a draft until Save.\n// inputs: []\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\nexport const minimalBins = e3.record(\"kiln_minimal_bins\", DictType(StringType, MinimalBin), {\n initial: yardMinimalBinRows,\n indexes: (index) => ({\n kiln_minimal_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the smallest board's bin kind reads them. */\nexport const minimalBinRoles = East.function([MinimalBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: none,\n}));\n\n/** A kiln, as the smallest board's kilns read it. */\nexport const minimalKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: none, meta: none, note: none, min: k.min, max: k.max, hold: variant(\"days\", 0.0), jobs: k.charges,\n}));\n\n/** A load, as the smallest board's arrivals read it. */\nexport const minimalLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: none, due: none, window: none, details: [],\n}));\n\n/**\n * The smallest board's verdicts over a day's bins as their roles (#1624): the built-in rules, over every kiln and\n * every load as that board reads them — what each of its fits answers, once it has read its own bins.\n */\nexport const minimalAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest], Allocation.Types.FitResult,\n ($, day, kilnRows, loadRows, request) => {\n const kiln = $.const(minimalKilnOf);\n const load = $.const(minimalLoadOf);\n const context = $.const({\n bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\",\n }, Allocation.Types.FitContext);\n const answer = $.const(Allocation.answer);\n const rule = $.const(Allocation.fit);\n return answer(request, context, rule, \"ranked by load, kind and spare days\");\n });\n\n/** The smallest board's fit, on e3 (§6.5): the built-in rules over its own bins, read through their interval index. */\nexport const minimalFit = e3.function(\"yard_minimal_fit\", {\n inputs: [e3.index(minimalBins.indexes.kiln_minimal_bins_by_time), minimalBins, kilns, arrivals],\n drafts: [minimalBins],\n args: [Allocation.Types.FitRequest],\n output: Allocation.Types.FitResult,\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n const roles = $.const(minimalBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(minimalAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(minimalBins));\n const loads = $.let(Data.bind(arrivals));\n const yard = $.let(Data.bind(kilns));\n const bays = $.let(Data.bind(yardBays));\n const fit = $.let(Func.bind(minimalFit));\n return <Box width=\"100%\" height=\"760px\"><Allocation id=\"allocationMinimal\" fit={fit} view={{ date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\",\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\",\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, min: k => k.min, max: k => k.max, jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), { label: l => l.code, quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays) })} />\n </Box>;\n }}</Reactive>)"
40402
+ "source": "// The smallest board over the app's own records: bins with only the board's roles — their bay, time, load, m³, split across kilns and drying time — the bays, the kilns and the day's loads, and the yard's fit on e3. No library, no inspector and no Publish; every gesture is still a draft until Save.\n// inputs: []\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\nexport const minimalBins = e3.record(\"kiln_minimal_bins\", DictType(StringType, MinimalBin), {\n initial: yardMinimalBinRows,\n indexes: (index) => ({\n kiln_minimal_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the smallest board's bin kind reads them. */\nexport const minimalBinRoles = East.function([MinimalBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: none,\n}));\n\n/** A kiln, as the smallest board's kilns read it. */\nexport const minimalKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: none, meta: none, note: none, min: k.min, max: k.max, hold: variant(\"days\", 0.0), jobs: k.charges,\n}));\n\n/** A load, as the smallest board's arrivals read it. */\nexport const minimalLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: none, due: none, window: none, details: [],\n}));\n\n/**\n * The smallest board's verdicts over a day's bins as their roles (#1624): the built-in rules, over every kiln and\n * every load as that board reads them — what each of its fits answers, once it has read its own bins.\n */\nexport const minimalAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest()], Allocation.Types.FitResult(),\n ($, day, kilnRows, loadRows, request) => {\n const kiln = $.const(minimalKilnOf);\n const load = $.const(minimalLoadOf);\n const context = $.const({\n bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\",\n }, Allocation.Types.FitContext());\n const answer = $.const(Allocation.answer());\n const rule = $.const(Allocation.fit());\n return answer(request, context, rule, \"ranked by load, kind and spare days\");\n });\n\n/** The smallest board's fit, on e3 (§6.5): the built-in rules over its own bins, read through their interval index. */\nexport const minimalFit = e3.function(\"yard_minimal_fit\", {\n inputs: [e3.index(minimalBins.indexes.kiln_minimal_bins_by_time), minimalBins, kilns, arrivals],\n drafts: [minimalBins],\n args: [Allocation.Types.FitRequest()],\n output: Allocation.Types.FitResult(),\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n const roles = $.const(minimalBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(minimalAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(minimalBins));\n const loads = $.let(Data.bind(arrivals));\n const yard = $.let(Data.bind(kilns));\n const bays = $.let(Data.bind(yardBays));\n const fit = $.let(Func.bind(minimalFit));\n return <Box width=\"100%\" height=\"760px\"><Allocation id=\"allocationMinimal\" fit={fit} view={{ date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\",\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\",\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, min: k => k.min, max: k => k.max, jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), { label: l => l.code, quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays) })} />\n </Box>;\n }}</Reactive>)"
40403
40403
  },
40404
40404
  {
40405
40405
  "id": "e3-ui:allocation.examples.tsx:allocationViews",
@@ -40432,7 +40432,7 @@
40432
40432
  "languages": [
40433
40433
  "tsx"
40434
40434
  ],
40435
- "source": "// Which layouts an instance offers, chosen as the page runs: a multi-select wired into `views`, an expression of an array of Allocation.Types.Layout. Choose Table alone and Timeline is gone, its button and all; with one layout left no switch shows, and with none chosen, both. `views={[\"table\"]}` writes the same choice in the code.\n// inputs: []\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\nexport const minimalBins = e3.record(\"kiln_minimal_bins\", DictType(StringType, MinimalBin), {\n initial: yardMinimalBinRows,\n indexes: (index) => ({\n kiln_minimal_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the smallest board's bin kind reads them. */\nexport const minimalBinRoles = East.function([MinimalBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: none,\n}));\n\n/** A kiln, as the smallest board's kilns read it. */\nexport const minimalKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: none, meta: none, note: none, min: k.min, max: k.max, hold: variant(\"days\", 0.0), jobs: k.charges,\n}));\n\n/** A load, as the smallest board's arrivals read it. */\nexport const minimalLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: none, due: none, window: none, details: [],\n}));\n\n/**\n * The smallest board's verdicts over a day's bins as their roles (#1624): the built-in rules, over every kiln and\n * every load as that board reads them — what each of its fits answers, once it has read its own bins.\n */\nexport const minimalAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest], Allocation.Types.FitResult,\n ($, day, kilnRows, loadRows, request) => {\n const kiln = $.const(minimalKilnOf);\n const load = $.const(minimalLoadOf);\n const context = $.const({\n bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\",\n }, Allocation.Types.FitContext);\n const answer = $.const(Allocation.answer);\n const rule = $.const(Allocation.fit);\n return answer(request, context, rule, \"ranked by load, kind and spare days\");\n });\n\n/** The smallest board's fit, on e3 (§6.5): the built-in rules over its own bins, read through their interval index. */\nexport const minimalFit = e3.function(\"yard_minimal_fit\", {\n inputs: [e3.index(minimalBins.indexes.kiln_minimal_bins_by_time), minimalBins, kilns, arrivals],\n drafts: [minimalBins],\n args: [Allocation.Types.FitRequest],\n output: Allocation.Types.FitResult,\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n const roles = $.const(minimalBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(minimalAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(minimalBins));\n const loads = $.let(Data.bind(arrivals));\n const yard = $.let(Data.bind(kilns));\n const bays = $.let(Data.bind(yardBays));\n const fit = $.let(Func.bind(minimalFit));\n // The tags the multi-select holds, and the layouts they name.\n const chosen = $.let(State.bind([ArrayType(StringType)], \"ex.allocationViews.views\", []));\n const tags = $.let(chosen.read());\n const onViews = $.const(East.function([ArrayType(StringType)], NullType, ($, next) => { $(chosen.write(next)); }));\n const every = $.const([variant(\"timeline\", null), variant(\"table\", null)], ArrayType(Allocation.Types.Layout));\n const views = $.let(every.filter(($, view) => tags.toSet().has(view.getTag())));\n return <VStack gap=\"3\" align=\"stretch\" width=\"100%\">\n <HStack gap=\"2\" align=\"center\"><Text>Views</Text><Select value=\"\" placeholder=\"Every view\" multiple={true} onChangeMultiple={onViews}\n items={[Select.Item(\"timeline\", \"Timeline\"), Select.Item(\"table\", \"Table\")]} /></HStack>\n <Box width=\"100%\" height=\"700px\"><Allocation id=\"allocationViews\" views={views} fit={fit} view={{ date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\",\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\",\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, min: k => k.min, max: k => k.max, jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), { label: l => l.code, quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays) })} />\n </Box>\n </VStack>;\n }}</Reactive>)"
40435
+ "source": "// Which layouts an instance offers, chosen as the page runs: a multi-select wired into `views`, an expression of an array of Allocation.Types.Layout. Choose Table alone and Timeline is gone, its button and all; with one layout left no switch shows, and with none chosen, both. `views={[\"table\"]}` writes the same choice in the code.\n// inputs: []\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\nexport const minimalBins = e3.record(\"kiln_minimal_bins\", DictType(StringType, MinimalBin), {\n initial: yardMinimalBinRows,\n indexes: (index) => ({\n kiln_minimal_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the smallest board's bin kind reads them. */\nexport const minimalBinRoles = East.function([MinimalBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: none,\n}));\n\n/** A kiln, as the smallest board's kilns read it. */\nexport const minimalKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: none, meta: none, note: none, min: k.min, max: k.max, hold: variant(\"days\", 0.0), jobs: k.charges,\n}));\n\n/** A load, as the smallest board's arrivals read it. */\nexport const minimalLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: none, due: none, window: none, details: [],\n}));\n\n/**\n * The smallest board's verdicts over a day's bins as their roles (#1624): the built-in rules, over every kiln and\n * every load as that board reads them — what each of its fits answers, once it has read its own bins.\n */\nexport const minimalAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest()], Allocation.Types.FitResult(),\n ($, day, kilnRows, loadRows, request) => {\n const kiln = $.const(minimalKilnOf);\n const load = $.const(minimalLoadOf);\n const context = $.const({\n bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\",\n }, Allocation.Types.FitContext());\n const answer = $.const(Allocation.answer());\n const rule = $.const(Allocation.fit());\n return answer(request, context, rule, \"ranked by load, kind and spare days\");\n });\n\n/** The smallest board's fit, on e3 (§6.5): the built-in rules over its own bins, read through their interval index. */\nexport const minimalFit = e3.function(\"yard_minimal_fit\", {\n inputs: [e3.index(minimalBins.indexes.kiln_minimal_bins_by_time), minimalBins, kilns, arrivals],\n drafts: [minimalBins],\n args: [Allocation.Types.FitRequest()],\n output: Allocation.Types.FitResult(),\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n const roles = $.const(minimalBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(minimalAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(minimalBins));\n const loads = $.let(Data.bind(arrivals));\n const yard = $.let(Data.bind(kilns));\n const bays = $.let(Data.bind(yardBays));\n const fit = $.let(Func.bind(minimalFit));\n // The tags the multi-select holds, and the layouts they name.\n const chosen = $.let(State.bind([ArrayType(StringType)], \"ex.allocationViews.views\", []));\n const tags = $.let(chosen.read());\n const onViews = $.const(East.function([ArrayType(StringType)], NullType, ($, next) => { $(chosen.write(next)); }));\n const every = $.const([variant(\"timeline\", null), variant(\"table\", null)], ArrayType(Allocation.Types.Layout));\n const views = $.let(every.filter(($, view) => tags.toSet().has(view.getTag())));\n return <VStack gap=\"3\" align=\"stretch\" width=\"100%\">\n <HStack gap=\"2\" align=\"center\"><Text>Views</Text><Select value=\"\" placeholder=\"Every view\" multiple={true} onChangeMultiple={onViews}\n items={[Select.Item(\"timeline\", \"Timeline\"), Select.Item(\"table\", \"Table\")]} /></HStack>\n <Box width=\"100%\" height=\"700px\"><Allocation id=\"allocationViews\" views={views} fit={fit} view={{ date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\",\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\",\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, min: k => k.min, max: k => k.max, jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), { label: l => l.code, quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays) })} />\n </Box>\n </VStack>;\n }}</Reactive>)"
40436
40436
  },
40437
40437
  {
40438
40438
  "id": "e3-ui:allocation.examples.tsx:allocationKilnYard",
@@ -40471,7 +40471,7 @@
40471
40471
  "languages": [
40472
40472
  "tsx"
40473
40473
  ],
40474
- "source": "// The kiln yard's board over its own records: its bins, each with the yard's spec and grade beside the board's roles, read a day at a time through the slice; the days it publishes; a check over the bins' own fields; a booked bin's own fields from its load's `values`, a reservation's from the bin kind's; the rail over the bays, the kilns and the loads — each source with its icon, and each narrowing every place its rows appear, the Library's tabs included; the yard's fields as columns; the Arrivals and Resources library; the inspector; and the yard's greedy fit on e3.\n// inputs: []\n/** The bins, every day's, each the yard's own row. */\nexport const kilnBins = e3.record(\"kiln_bins\", DictType(StringType, KilnBin), {\n initial: yardBinRows,\n indexes: (index) => ({\n // The bins by their time: what the board's slice reads a day of them through, its navigation writing the range.\n kiln_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The days of the yard's plan, what the board publishes: Tue 4 May issued, Tue 11 and Wed 12 drafts. */\nexport const yardDays = e3.record(\"yard_days\", DictType(DateTimeType, YardDay), {\n initial: yardDayRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the board's bin kind reads them. */\nexport const yardBinRoles = East.function([KilnBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: b.spec,\n}));\n\n/** A kiln, as the board's kilns read it. */\nexport const yardKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: some(k.group), meta: none, note: k.note, min: k.min, max: k.max, hold: variant(\"days\", k.days), jobs: k.charges,\n}));\n\n/** A load, as the board's arrivals read it. */\nexport const yardLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: some(l.spec),\n due: some(l.due), window: some({ from: l.from, to: l.to }), details: [],\n}));\n\n/**\n * What a yard's fit read (#1624): a day's bins as their roles, and every kiln and every load — every kiln is a\n * candidate, and a look-ahead places every load, so both are read whole, as the board reads them.\n */\nexport const yardRead = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad)], Allocation.Types.FitContext, ($, day, kilnRows, loadRows) => {\n const kiln = $.const(yardKilnOf);\n const load = $.const(yardLoadOf);\n return { bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\" };\n});\n\n/**\n * The yard's verdicts over a day's bins as their roles (#1624): the built-in rules, then a greedy look-ahead over the\n * day's other loads — a fit that leaves more of the day's unbooked loads with nowhere to go ranks lower. What each of\n * the yard's fits answers, once it has read its own bins.\n */\nexport const yardAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest], Allocation.Types.FitResult,\n ($, day, kilnRows, loadRows, request) => {\n const read = $.const(yardRead);\n const context = $.const(read(day, kilnRows, loadRows));\n const answer = $.const(Allocation.answer);\n const rule = $.const(Allocation.fit);\n const ahead = $.const(Allocation.lookahead);\n return answer(request, context, East.function([Allocation.Types.Candidate], Allocation.Types.Fit, (_$2, c) => ahead(context, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n });\n\n/**\n * The yard's fit, on e3 (#1624): the yard's verdicts ({@link yardAnswer}) over the day's bins. It is asked the day and\n * the question, and sent no row: it reads the day's bins through their interval index, the board's unsaved bins among\n * them.\n */\nexport const yardFit = e3.function(\"yard_fit\", {\n inputs: [e3.index(kilnBins.indexes.kiln_bins_by_time), kilnBins, kilns, arrivals],\n // The board's unsaved bins are laid over them, and over their index\n drafts: [kilnBins],\n args: [Allocation.Types.FitRequest],\n output: Allocation.Types.FitResult,\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n // The day's bins, every one: a kiln's load is every bin's part on it. The index carries no row: it gives each\n // bin's key, and the record its row, both at the one drafted state.\n const roles = $.const(yardBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(yardAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n // What the board writes: the bins and the days of the plan, each through its patch door.\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n const days = $.let(Record.bind(yardDays));\n // Every bay, kiln and load is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\", \"yard_bays_by_cover\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group_max\", \"kilns_by_name\"] }));\n const loadIndex = $.let(Data.bindPaged(arrivals, { indexes: [\"arrivals_by_spec\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationKilnYard\", {\n // The day's bins: the board's navigation writes the range; no chip picks the day.\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, icon: { prefix: \"fas\", name: \"warehouse\" },\n fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] }, cover: { label: \"Cover\", hints: [\"Covered\", \"Open\"] } } },\n // A max narrows within a group (one index on group, then max); a name is searched by its start.\n kilns: { source: kilnIndex, icon: { prefix: \"fas\", name: \"fire\" },\n fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] }, max: { label: \"Max m³\" }, name: { label: \"Name\" } } },\n arrivals: { source: loadIndex, icon: { prefix: \"fas\", name: \"truck\" }, fields: { spec: { label: \"Spec\", hints: [\"MC08\", \"MC10\", \"MC12\", \"MC14\", \"MC16\", \"MC18\", \"MC20\", \"MC22\"] } } },\n }, {\n presets: [\n { id: \"halls\", name: \"Halls\", where: { kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n { id: \"small\", name: \"Compact and standard\", where: { kilns: { group: [\"Compact\", \"Standard\"] } } },\n { id: \"large\", name: \"Large and bulk\", where: { kilns: { group: [\"Large\", \"Bulk\"] } } },\n { id: \"north\", name: \"North bays, halls\", where: { bays: { area: [\"North\"] }, kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n ],\n }));\n const fit = $.let(Func.bind(yardFit));\n // The yard's check reads its own fields: a bin measured off its booked spec is flagged, never refused.\n const check = $.const(East.function([Allocation.Types.CheckContext(KilnBin)], ArrayType(Allocation.Types.Issue), ($2, cx) => {\n const issues = $2.let([], ArrayType(Allocation.Types.Issue));\n $2.for(cx.plan.bins, ($3, bin, id) => {\n $3.match(bin.arrival, { some: ($4, code) => {\n $4.if(East.notEqual(bin.row.specBooked, bin.row.specMeasured), ($5) => {\n $5(issues.pushLast({ kind: variant(\"custom\", \"Spec mismatch\"), tone: variant(\"neutral\", null),\n title: East.str`${code} · bin ${id}`,\n detail: East.str`Spec booked ${bin.row.specBooked} · measured ${bin.row.specMeasured} · ${bin.lane} ${bin.at.printFormatted(\"HH:mm\")}`,\n bin: some(id), resource: none, flag: some(\"≠ spec\"), fix: none }));\n });\n } });\n });\n return issues;\n }));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationKilnYard\" title=\"Kiln loading\" fit={fit} check={check} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"timeline\", date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n // A reservation's own fields, the yard's: its kind's spec, booked and measured alike — empty, as a reservation holds\n // no kind until a load comes — no grade yet, and its instruction. A bin booked from a load takes the load's `values` below.\n values: r => ({\n specBooked: r.kind.unwrap(\"some\", () => \"\"), specMeasured: r.kind.unwrap(\"some\", () => \"\"),\n gradeBooked: \"\", gradeMeasured: \"\", instruction: some(\"Hold for the next load\"),\n }),\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n // A booked bin's own fields: the ones no role maps.\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(days, { every: \"day\", status: { field: \"state\", draft: \"draft\", published: \"issued\" } })}\n columns={[\n { key: \"spec\", label: \"Spec\", text: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => b.specMeasured, () => East.str`booked ${b.specBooked} · measured ${b.specMeasured}`),\n tone: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => none, () => some(variant(\"warning\", null))) },\n { key: \"grade\", label: \"Grade\", text: b => b.gradeMeasured.startsWith(b.gradeBooked).ifElse(() => b.gradeMeasured, () => East.str`booked ${b.gradeBooked} · measured ${b.gradeMeasured}`), table: false },\n ]} />\n </Box>;\n }}</Reactive>)"
40474
+ "source": "// The kiln yard's board over its own records: its bins, each with the yard's spec and grade beside the board's roles, read a day at a time through the slice; the days it publishes; a check over the bins' own fields; a booked bin's own fields from its load's `values`, a reservation's from the bin kind's; the rail over the bays, the kilns and the loads — each source with its icon, and each narrowing every place its rows appear, the Library's tabs included; the yard's fields as columns; the Arrivals and Resources library; the inspector; and the yard's greedy fit on e3.\n// inputs: []\n/** The bins, every day's, each the yard's own row. */\nexport const kilnBins = e3.record(\"kiln_bins\", DictType(StringType, KilnBin), {\n initial: yardBinRows,\n indexes: (index) => ({\n // The bins by their time: what the board's slice reads a day of them through, its navigation writing the range.\n kiln_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The days of the yard's plan, what the board publishes: Tue 4 May issued, Tue 11 and Wed 12 drafts. */\nexport const yardDays = e3.record(\"yard_days\", DictType(DateTimeType, YardDay), {\n initial: yardDayRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the board's bin kind reads them. */\nexport const yardBinRoles = East.function([KilnBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: b.spec,\n}));\n\n/** A kiln, as the board's kilns read it. */\nexport const yardKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: some(k.group), meta: none, note: k.note, min: k.min, max: k.max, hold: variant(\"days\", k.days), jobs: k.charges,\n}));\n\n/** A load, as the board's arrivals read it. */\nexport const yardLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: some(l.spec),\n due: some(l.due), window: some({ from: l.from, to: l.to }), details: [],\n}));\n\n/**\n * What a yard's fit read (#1624): a day's bins as their roles, and every kiln and every load — every kiln is a\n * candidate, and a look-ahead places every load, so both are read whole, as the board reads them.\n */\nexport const yardRead = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad)], Allocation.Types.FitContext(), ($, day, kilnRows, loadRows) => {\n const kiln = $.const(yardKilnOf);\n const load = $.const(yardLoadOf);\n return { bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\" };\n});\n\n/**\n * The yard's verdicts over a day's bins as their roles (#1624): the built-in rules, then a greedy look-ahead over the\n * day's other loads — a fit that leaves more of the day's unbooked loads with nowhere to go ranks lower. What each of\n * the yard's fits answers, once it has read its own bins.\n */\nexport const yardAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest()], Allocation.Types.FitResult(),\n ($, day, kilnRows, loadRows, request) => {\n const read = $.const(yardRead);\n const context = $.const(read(day, kilnRows, loadRows));\n const answer = $.const(Allocation.answer());\n const rule = $.const(Allocation.fit());\n const ahead = $.const(Allocation.lookahead());\n return answer(request, context, East.function([Allocation.Types.Candidate()], Allocation.Types.Fit, (_$2, c) => ahead(context, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n });\n\n/**\n * The yard's fit, on e3 (#1624): the yard's verdicts ({@link yardAnswer}) over the day's bins. It is asked the day and\n * the question, and sent no row: it reads the day's bins through their interval index, the board's unsaved bins among\n * them.\n */\nexport const yardFit = e3.function(\"yard_fit\", {\n inputs: [e3.index(kilnBins.indexes.kiln_bins_by_time), kilnBins, kilns, arrivals],\n // The board's unsaved bins are laid over them, and over their index\n drafts: [kilnBins],\n args: [Allocation.Types.FitRequest()],\n output: Allocation.Types.FitResult(),\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n // The day's bins, every one: a kiln's load is every bin's part on it. The index carries no row: it gives each\n // bin's key, and the record its row, both at the one drafted state.\n const roles = $.const(yardBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(yardAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n // What the board writes: the bins and the days of the plan, each through its patch door.\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n const days = $.let(Record.bind(yardDays));\n // Every bay, kiln and load is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\", \"yard_bays_by_cover\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group_max\", \"kilns_by_name\"] }));\n const loadIndex = $.let(Data.bindPaged(arrivals, { indexes: [\"arrivals_by_spec\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationKilnYard\", {\n // The day's bins: the board's navigation writes the range; no chip picks the day.\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, icon: { prefix: \"fas\", name: \"warehouse\" },\n fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] }, cover: { label: \"Cover\", hints: [\"Covered\", \"Open\"] } } },\n // A max narrows within a group (one index on group, then max); a name is searched by its start.\n kilns: { source: kilnIndex, icon: { prefix: \"fas\", name: \"fire\" },\n fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] }, max: { label: \"Max m³\" }, name: { label: \"Name\" } } },\n arrivals: { source: loadIndex, icon: { prefix: \"fas\", name: \"truck\" }, fields: { spec: { label: \"Spec\", hints: [\"MC08\", \"MC10\", \"MC12\", \"MC14\", \"MC16\", \"MC18\", \"MC20\", \"MC22\"] } } },\n }, {\n presets: [\n { id: \"halls\", name: \"Halls\", where: { kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n { id: \"small\", name: \"Compact and standard\", where: { kilns: { group: [\"Compact\", \"Standard\"] } } },\n { id: \"large\", name: \"Large and bulk\", where: { kilns: { group: [\"Large\", \"Bulk\"] } } },\n { id: \"north\", name: \"North bays, halls\", where: { bays: { area: [\"North\"] }, kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n ],\n }));\n const fit = $.let(Func.bind(yardFit));\n // The yard's check reads its own fields: a bin measured off its booked spec is flagged, never refused.\n const check = $.const(East.function([Allocation.Types.CheckContext(KilnBin)], ArrayType(Allocation.Types.Issue), ($2, cx) => {\n const issues = $2.let([], ArrayType(Allocation.Types.Issue));\n $2.for(cx.plan.bins, ($3, bin, id) => {\n $3.match(bin.arrival, { some: ($4, code) => {\n $4.if(East.notEqual(bin.row.specBooked, bin.row.specMeasured), ($5) => {\n $5(issues.pushLast({ kind: variant(\"custom\", \"Spec mismatch\"), tone: variant(\"neutral\", null),\n title: East.str`${code} · bin ${id}`,\n detail: East.str`Spec booked ${bin.row.specBooked} · measured ${bin.row.specMeasured} · ${bin.lane} ${bin.at.printFormatted(\"HH:mm\")}`,\n bin: some(id), resource: none, flag: some(\"≠ spec\"), fix: none }));\n });\n } });\n });\n return issues;\n }));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationKilnYard\" title=\"Kiln loading\" fit={fit} check={check} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"timeline\", date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n // A reservation's own fields, the yard's: its kind's spec, booked and measured alike — empty, as a reservation holds\n // no kind until a load comes — no grade yet, and its instruction. A bin booked from a load takes the load's `values` below.\n values: r => ({\n specBooked: r.kind.unwrap(\"some\", () => \"\"), specMeasured: r.kind.unwrap(\"some\", () => \"\"),\n gradeBooked: \"\", gradeMeasured: \"\", instruction: some(\"Hold for the next load\"),\n }),\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n // A booked bin's own fields: the ones no role maps.\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(days, { every: \"day\", status: { field: \"state\", draft: \"draft\", published: \"issued\" } })}\n columns={[\n { key: \"spec\", label: \"Spec\", text: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => b.specMeasured, () => East.str`booked ${b.specBooked} · measured ${b.specMeasured}`),\n tone: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => none, () => some(variant(\"warning\", null))) },\n { key: \"grade\", label: \"Grade\", text: b => b.gradeMeasured.startsWith(b.gradeBooked).ifElse(() => b.gradeMeasured, () => East.str`booked ${b.gradeBooked} · measured ${b.gradeMeasured}`), table: false },\n ]} />\n </Box>;\n }}</Reactive>)"
40475
40475
  },
40476
40476
  {
40477
40477
  "id": "e3-ui:allocation.examples.tsx:allocationTable",
@@ -40502,7 +40502,7 @@
40502
40502
  "languages": [
40503
40503
  "tsx"
40504
40504
  ],
40505
- "source": "// The kiln yard as a Table: one row per bay slot and one per extra bin of a batch, in four foldable time bands, narrowed by the bays' area or cover, the kilns' group, max or name, and the loads' spec; the same drafts, library and inspector as the Timeline.\n// inputs: []\n/** The bins, every day's, each the yard's own row. */\nexport const kilnBins = e3.record(\"kiln_bins\", DictType(StringType, KilnBin), {\n initial: yardBinRows,\n indexes: (index) => ({\n // The bins by their time: what the board's slice reads a day of them through, its navigation writing the range.\n kiln_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The days of the yard's plan, what the board publishes: Tue 4 May issued, Tue 11 and Wed 12 drafts. */\nexport const yardDays = e3.record(\"yard_days\", DictType(DateTimeType, YardDay), {\n initial: yardDayRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the board's bin kind reads them. */\nexport const yardBinRoles = East.function([KilnBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: b.spec,\n}));\n\n/** A kiln, as the board's kilns read it. */\nexport const yardKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: some(k.group), meta: none, note: k.note, min: k.min, max: k.max, hold: variant(\"days\", k.days), jobs: k.charges,\n}));\n\n/** A load, as the board's arrivals read it. */\nexport const yardLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: some(l.spec),\n due: some(l.due), window: some({ from: l.from, to: l.to }), details: [],\n}));\n\n/**\n * What a yard's fit read (#1624): a day's bins as their roles, and every kiln and every load — every kiln is a\n * candidate, and a look-ahead places every load, so both are read whole, as the board reads them.\n */\nexport const yardRead = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad)], Allocation.Types.FitContext, ($, day, kilnRows, loadRows) => {\n const kiln = $.const(yardKilnOf);\n const load = $.const(yardLoadOf);\n return { bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\" };\n});\n\n/**\n * The yard's verdicts over a day's bins as their roles (#1624): the built-in rules, then a greedy look-ahead over the\n * day's other loads — a fit that leaves more of the day's unbooked loads with nowhere to go ranks lower. What each of\n * the yard's fits answers, once it has read its own bins.\n */\nexport const yardAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest], Allocation.Types.FitResult,\n ($, day, kilnRows, loadRows, request) => {\n const read = $.const(yardRead);\n const context = $.const(read(day, kilnRows, loadRows));\n const answer = $.const(Allocation.answer);\n const rule = $.const(Allocation.fit);\n const ahead = $.const(Allocation.lookahead);\n return answer(request, context, East.function([Allocation.Types.Candidate], Allocation.Types.Fit, (_$2, c) => ahead(context, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n });\n\n/**\n * The yard's fit, on e3 (#1624): the yard's verdicts ({@link yardAnswer}) over the day's bins. It is asked the day and\n * the question, and sent no row: it reads the day's bins through their interval index, the board's unsaved bins among\n * them.\n */\nexport const yardFit = e3.function(\"yard_fit\", {\n inputs: [e3.index(kilnBins.indexes.kiln_bins_by_time), kilnBins, kilns, arrivals],\n // The board's unsaved bins are laid over them, and over their index\n drafts: [kilnBins],\n args: [Allocation.Types.FitRequest],\n output: Allocation.Types.FitResult,\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n // The day's bins, every one: a kiln's load is every bin's part on it. The index carries no row: it gives each\n // bin's key, and the record its row, both at the one drafted state.\n const roles = $.const(yardBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(yardAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n const days = $.let(Record.bind(yardDays));\n // Every bay, kiln and load is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\", \"yard_bays_by_cover\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group_max\", \"kilns_by_name\"] }));\n const loadIndex = $.let(Data.bindPaged(arrivals, { indexes: [\"arrivals_by_spec\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationTable\", {\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, icon: { prefix: \"fas\", name: \"warehouse\" },\n fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] }, cover: { label: \"Cover\", hints: [\"Covered\", \"Open\"] } } },\n // A max narrows within a group (one index on group, then max); a name is searched by its start.\n kilns: { source: kilnIndex, icon: { prefix: \"fas\", name: \"fire\" },\n fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] }, max: { label: \"Max m³\" }, name: { label: \"Name\" } } },\n arrivals: { source: loadIndex, icon: { prefix: \"fas\", name: \"truck\" }, fields: { spec: { label: \"Spec\", hints: [\"MC08\", \"MC10\", \"MC12\", \"MC14\", \"MC16\", \"MC18\", \"MC20\", \"MC22\"] } } },\n }, {\n presets: [\n { id: \"halls\", name: \"Halls\", where: { kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n { id: \"small\", name: \"Compact and standard\", where: { kilns: { group: [\"Compact\", \"Standard\"] } } },\n { id: \"large\", name: \"Large and bulk\", where: { kilns: { group: [\"Large\", \"Bulk\"] } } },\n { id: \"north\", name: \"North bays, halls\", where: { bays: { area: [\"North\"] }, kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n ],\n }));\n const fit = $.let(Func.bind(yardFit));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationTable\" title=\"Kiln loading\" fit={fit} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"table\", date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(days, { every: \"day\", status: { field: \"state\", draft: \"draft\", published: \"issued\" } })}\n columns={[\n { key: \"spec\", label: \"Spec\", text: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => b.specMeasured, () => East.str`booked ${b.specBooked} · measured ${b.specMeasured}`),\n tone: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => none, () => some(variant(\"warning\", null))) },\n { key: \"grade\", label: \"Grade\", text: b => b.gradeMeasured.startsWith(b.gradeBooked).ifElse(() => b.gradeMeasured, () => East.str`booked ${b.gradeBooked} · measured ${b.gradeMeasured}`), table: false },\n ]} />\n </Box>;\n }}</Reactive>)"
40505
+ "source": "// The kiln yard as a Table: one row per bay slot and one per extra bin of a batch, in four foldable time bands, narrowed by the bays' area or cover, the kilns' group, max or name, and the loads' spec; the same drafts, library and inspector as the Timeline.\n// inputs: []\n/** The bins, every day's, each the yard's own row. */\nexport const kilnBins = e3.record(\"kiln_bins\", DictType(StringType, KilnBin), {\n initial: yardBinRows,\n indexes: (index) => ({\n // The bins by their time: what the board's slice reads a day of them through, its navigation writing the range.\n kiln_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The days of the yard's plan, what the board publishes: Tue 4 May issued, Tue 11 and Wed 12 drafts. */\nexport const yardDays = e3.record(\"yard_days\", DictType(DateTimeType, YardDay), {\n initial: yardDayRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the board's bin kind reads them. */\nexport const yardBinRoles = East.function([KilnBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: b.spec,\n}));\n\n/** A kiln, as the board's kilns read it. */\nexport const yardKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: some(k.group), meta: none, note: k.note, min: k.min, max: k.max, hold: variant(\"days\", k.days), jobs: k.charges,\n}));\n\n/** A load, as the board's arrivals read it. */\nexport const yardLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: some(l.spec),\n due: some(l.due), window: some({ from: l.from, to: l.to }), details: [],\n}));\n\n/**\n * What a yard's fit read (#1624): a day's bins as their roles, and every kiln and every load — every kiln is a\n * candidate, and a look-ahead places every load, so both are read whole, as the board reads them.\n */\nexport const yardRead = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad)], Allocation.Types.FitContext(), ($, day, kilnRows, loadRows) => {\n const kiln = $.const(yardKilnOf);\n const load = $.const(yardLoadOf);\n return { bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\" };\n});\n\n/**\n * The yard's verdicts over a day's bins as their roles (#1624): the built-in rules, then a greedy look-ahead over the\n * day's other loads — a fit that leaves more of the day's unbooked loads with nowhere to go ranks lower. What each of\n * the yard's fits answers, once it has read its own bins.\n */\nexport const yardAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest()], Allocation.Types.FitResult(),\n ($, day, kilnRows, loadRows, request) => {\n const read = $.const(yardRead);\n const context = $.const(read(day, kilnRows, loadRows));\n const answer = $.const(Allocation.answer());\n const rule = $.const(Allocation.fit());\n const ahead = $.const(Allocation.lookahead());\n return answer(request, context, East.function([Allocation.Types.Candidate()], Allocation.Types.Fit, (_$2, c) => ahead(context, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n });\n\n/**\n * The yard's fit, on e3 (#1624): the yard's verdicts ({@link yardAnswer}) over the day's bins. It is asked the day and\n * the question, and sent no row: it reads the day's bins through their interval index, the board's unsaved bins among\n * them.\n */\nexport const yardFit = e3.function(\"yard_fit\", {\n inputs: [e3.index(kilnBins.indexes.kiln_bins_by_time), kilnBins, kilns, arrivals],\n // The board's unsaved bins are laid over them, and over their index\n drafts: [kilnBins],\n args: [Allocation.Types.FitRequest()],\n output: Allocation.Types.FitResult(),\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n // The day's bins, every one: a kiln's load is every bin's part on it. The index carries no row: it gives each\n // bin's key, and the record its row, both at the one drafted state.\n const roles = $.const(yardBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(yardAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n const days = $.let(Record.bind(yardDays));\n // Every bay, kiln and load is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\", \"yard_bays_by_cover\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group_max\", \"kilns_by_name\"] }));\n const loadIndex = $.let(Data.bindPaged(arrivals, { indexes: [\"arrivals_by_spec\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationTable\", {\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, icon: { prefix: \"fas\", name: \"warehouse\" },\n fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] }, cover: { label: \"Cover\", hints: [\"Covered\", \"Open\"] } } },\n // A max narrows within a group (one index on group, then max); a name is searched by its start.\n kilns: { source: kilnIndex, icon: { prefix: \"fas\", name: \"fire\" },\n fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] }, max: { label: \"Max m³\" }, name: { label: \"Name\" } } },\n arrivals: { source: loadIndex, icon: { prefix: \"fas\", name: \"truck\" }, fields: { spec: { label: \"Spec\", hints: [\"MC08\", \"MC10\", \"MC12\", \"MC14\", \"MC16\", \"MC18\", \"MC20\", \"MC22\"] } } },\n }, {\n presets: [\n { id: \"halls\", name: \"Halls\", where: { kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n { id: \"small\", name: \"Compact and standard\", where: { kilns: { group: [\"Compact\", \"Standard\"] } } },\n { id: \"large\", name: \"Large and bulk\", where: { kilns: { group: [\"Large\", \"Bulk\"] } } },\n { id: \"north\", name: \"North bays, halls\", where: { bays: { area: [\"North\"] }, kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n ],\n }));\n const fit = $.let(Func.bind(yardFit));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationTable\" title=\"Kiln loading\" fit={fit} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"table\", date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(days, { every: \"day\", status: { field: \"state\", draft: \"draft\", published: \"issued\" } })}\n columns={[\n { key: \"spec\", label: \"Spec\", text: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => b.specMeasured, () => East.str`booked ${b.specBooked} · measured ${b.specMeasured}`),\n tone: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => none, () => some(variant(\"warning\", null))) },\n { key: \"grade\", label: \"Grade\", text: b => b.gradeMeasured.startsWith(b.gradeBooked).ifElse(() => b.gradeMeasured, () => East.str`booked ${b.gradeBooked} · measured ${b.gradeMeasured}`), table: false },\n ]} />\n </Box>;\n }}</Reactive>)"
40506
40506
  },
40507
40507
  {
40508
40508
  "id": "e3-ui:allocation.examples.tsx:allocationLabels",
@@ -40532,7 +40532,7 @@
40532
40532
  "languages": [
40533
40533
  "tsx"
40534
40534
  ],
40535
- "source": "// The kiln yard in its own words: labels={{ lane: \"Bay\", arrival: { one: \"Delivery\", other: \"Deliveries\" }, resource: \"Kiln\", quantity: \"Vol\" }} names the board's lanes, arrivals, resources and quantity everywhere it writes them — the Table's heads, the Chooser, the placeholders, the drag captions, the banners and the narrowing's summary — and table={{ bands }} sets the Table's time bands to the yard's shifts.\n// inputs: []\n/** The bins, every day's, each the yard's own row. */\nexport const kilnBins = e3.record(\"kiln_bins\", DictType(StringType, KilnBin), {\n initial: yardBinRows,\n indexes: (index) => ({\n // The bins by their time: what the board's slice reads a day of them through, its navigation writing the range.\n kiln_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The days of the yard's plan, what the board publishes: Tue 4 May issued, Tue 11 and Wed 12 drafts. */\nexport const yardDays = e3.record(\"yard_days\", DictType(DateTimeType, YardDay), {\n initial: yardDayRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the board's bin kind reads them. */\nexport const yardBinRoles = East.function([KilnBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: b.spec,\n}));\n\n/** A kiln, as the board's kilns read it. */\nexport const yardKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: some(k.group), meta: none, note: k.note, min: k.min, max: k.max, hold: variant(\"days\", k.days), jobs: k.charges,\n}));\n\n/** A load, as the board's arrivals read it. */\nexport const yardLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: some(l.spec),\n due: some(l.due), window: some({ from: l.from, to: l.to }), details: [],\n}));\n\n/**\n * What a yard's fit read (#1624): a day's bins as their roles, and every kiln and every load — every kiln is a\n * candidate, and a look-ahead places every load, so both are read whole, as the board reads them.\n */\nexport const yardRead = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad)], Allocation.Types.FitContext, ($, day, kilnRows, loadRows) => {\n const kiln = $.const(yardKilnOf);\n const load = $.const(yardLoadOf);\n return { bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\" };\n});\n\n/**\n * The yard's verdicts over a day's bins as their roles (#1624): the built-in rules, then a greedy look-ahead over the\n * day's other loads — a fit that leaves more of the day's unbooked loads with nowhere to go ranks lower. What each of\n * the yard's fits answers, once it has read its own bins.\n */\nexport const yardAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest], Allocation.Types.FitResult,\n ($, day, kilnRows, loadRows, request) => {\n const read = $.const(yardRead);\n const context = $.const(read(day, kilnRows, loadRows));\n const answer = $.const(Allocation.answer);\n const rule = $.const(Allocation.fit);\n const ahead = $.const(Allocation.lookahead);\n return answer(request, context, East.function([Allocation.Types.Candidate], Allocation.Types.Fit, (_$2, c) => ahead(context, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n });\n\n/**\n * The yard's fit, on e3 (#1624): the yard's verdicts ({@link yardAnswer}) over the day's bins. It is asked the day and\n * the question, and sent no row: it reads the day's bins through their interval index, the board's unsaved bins among\n * them.\n */\nexport const yardFit = e3.function(\"yard_fit\", {\n inputs: [e3.index(kilnBins.indexes.kiln_bins_by_time), kilnBins, kilns, arrivals],\n // The board's unsaved bins are laid over them, and over their index\n drafts: [kilnBins],\n args: [Allocation.Types.FitRequest],\n output: Allocation.Types.FitResult,\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n // The day's bins, every one: a kiln's load is every bin's part on it. The index carries no row: it gives each\n // bin's key, and the record its row, both at the one drafted state.\n const roles = $.const(yardBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(yardAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n const days = $.let(Record.bind(yardDays));\n // Every bay and kiln is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationLabels\", {\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] } } },\n kilns: { source: kilnIndex, fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] } } },\n }, {\n presets: [\n { id: \"halls\", name: \"Halls\", where: { kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n { id: \"small\", name: \"Compact and standard\", where: { kilns: { group: [\"Compact\", \"Standard\"] } } },\n { id: \"large\", name: \"Large and bulk\", where: { kilns: { group: [\"Large\", \"Bulk\"] } } },\n { id: \"north\", name: \"North bays, halls\", where: { bays: { area: [\"North\"] }, kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n ],\n }));\n const fit = $.let(Func.bind(yardFit));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationLabels\" title=\"Kiln loading\" fit={fit} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"table\", date: yardDay }}\n labels={{ lane: \"Bay\", arrival: { one: \"Delivery\", other: \"Deliveries\" }, resource: \"Kiln\", quantity: \"Vol\" }}\n table={{ bands: [{ from: 0, label: \"Night\" }, { from: 6, label: \"Day shift\" }, { from: 18, label: \"Evening\" }] }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(days, { every: \"day\", status: { field: \"state\", draft: \"draft\", published: \"issued\" } })}\n columns={[\n { key: \"spec\", label: \"Spec\", text: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => b.specMeasured, () => East.str`booked ${b.specBooked} · measured ${b.specMeasured}`),\n tone: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => none, () => some(variant(\"warning\", null))) },\n { key: \"grade\", label: \"Grade\", text: b => b.gradeMeasured.startsWith(b.gradeBooked).ifElse(() => b.gradeMeasured, () => East.str`booked ${b.gradeBooked} · measured ${b.gradeMeasured}`), table: false },\n ]} />\n </Box>;\n }}</Reactive>)"
40535
+ "source": "// The kiln yard in its own words: labels={{ lane: \"Bay\", arrival: { one: \"Delivery\", other: \"Deliveries\" }, resource: \"Kiln\", quantity: \"Vol\" }} names the board's lanes, arrivals, resources and quantity everywhere it writes them — the Table's heads, the Chooser, the placeholders, the drag captions, the banners and the narrowing's summary — and table={{ bands }} sets the Table's time bands to the yard's shifts.\n// inputs: []\n/** The bins, every day's, each the yard's own row. */\nexport const kilnBins = e3.record(\"kiln_bins\", DictType(StringType, KilnBin), {\n initial: yardBinRows,\n indexes: (index) => ({\n // The bins by their time: what the board's slice reads a day of them through, its navigation writing the range.\n kiln_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The days of the yard's plan, what the board publishes: Tue 4 May issued, Tue 11 and Wed 12 drafts. */\nexport const yardDays = e3.record(\"yard_days\", DictType(DateTimeType, YardDay), {\n initial: yardDayRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the board's bin kind reads them. */\nexport const yardBinRoles = East.function([KilnBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: b.spec,\n}));\n\n/** A kiln, as the board's kilns read it. */\nexport const yardKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: some(k.group), meta: none, note: k.note, min: k.min, max: k.max, hold: variant(\"days\", k.days), jobs: k.charges,\n}));\n\n/** A load, as the board's arrivals read it. */\nexport const yardLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: some(l.spec),\n due: some(l.due), window: some({ from: l.from, to: l.to }), details: [],\n}));\n\n/**\n * What a yard's fit read (#1624): a day's bins as their roles, and every kiln and every load — every kiln is a\n * candidate, and a look-ahead places every load, so both are read whole, as the board reads them.\n */\nexport const yardRead = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad)], Allocation.Types.FitContext(), ($, day, kilnRows, loadRows) => {\n const kiln = $.const(yardKilnOf);\n const load = $.const(yardLoadOf);\n return { bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\" };\n});\n\n/**\n * The yard's verdicts over a day's bins as their roles (#1624): the built-in rules, then a greedy look-ahead over the\n * day's other loads — a fit that leaves more of the day's unbooked loads with nowhere to go ranks lower. What each of\n * the yard's fits answers, once it has read its own bins.\n */\nexport const yardAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest()], Allocation.Types.FitResult(),\n ($, day, kilnRows, loadRows, request) => {\n const read = $.const(yardRead);\n const context = $.const(read(day, kilnRows, loadRows));\n const answer = $.const(Allocation.answer());\n const rule = $.const(Allocation.fit());\n const ahead = $.const(Allocation.lookahead());\n return answer(request, context, East.function([Allocation.Types.Candidate()], Allocation.Types.Fit, (_$2, c) => ahead(context, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n });\n\n/**\n * The yard's fit, on e3 (#1624): the yard's verdicts ({@link yardAnswer}) over the day's bins. It is asked the day and\n * the question, and sent no row: it reads the day's bins through their interval index, the board's unsaved bins among\n * them.\n */\nexport const yardFit = e3.function(\"yard_fit\", {\n inputs: [e3.index(kilnBins.indexes.kiln_bins_by_time), kilnBins, kilns, arrivals],\n // The board's unsaved bins are laid over them, and over their index\n drafts: [kilnBins],\n args: [Allocation.Types.FitRequest()],\n output: Allocation.Types.FitResult(),\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n // The day's bins, every one: a kiln's load is every bin's part on it. The index carries no row: it gives each\n // bin's key, and the record its row, both at the one drafted state.\n const roles = $.const(yardBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(yardAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n const days = $.let(Record.bind(yardDays));\n // Every bay and kiln is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationLabels\", {\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] } } },\n kilns: { source: kilnIndex, fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] } } },\n }, {\n presets: [\n { id: \"halls\", name: \"Halls\", where: { kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n { id: \"small\", name: \"Compact and standard\", where: { kilns: { group: [\"Compact\", \"Standard\"] } } },\n { id: \"large\", name: \"Large and bulk\", where: { kilns: { group: [\"Large\", \"Bulk\"] } } },\n { id: \"north\", name: \"North bays, halls\", where: { bays: { area: [\"North\"] }, kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n ],\n }));\n const fit = $.let(Func.bind(yardFit));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationLabels\" title=\"Kiln loading\" fit={fit} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"table\", date: yardDay }}\n labels={{ lane: \"Bay\", arrival: { one: \"Delivery\", other: \"Deliveries\" }, resource: \"Kiln\", quantity: \"Vol\" }}\n table={{ bands: [{ from: 0, label: \"Night\" }, { from: 6, label: \"Day shift\" }, { from: 18, label: \"Evening\" }] }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(days, { every: \"day\", status: { field: \"state\", draft: \"draft\", published: \"issued\" } })}\n columns={[\n { key: \"spec\", label: \"Spec\", text: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => b.specMeasured, () => East.str`booked ${b.specBooked} · measured ${b.specMeasured}`),\n tone: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => none, () => some(variant(\"warning\", null))) },\n { key: \"grade\", label: \"Grade\", text: b => b.gradeMeasured.startsWith(b.gradeBooked).ifElse(() => b.gradeMeasured, () => East.str`booked ${b.gradeBooked} · measured ${b.gradeMeasured}`), table: false },\n ]} />\n </Box>;\n }}</Reactive>)"
40536
40536
  },
40537
40537
  {
40538
40538
  "id": "e3-ui:allocation.examples.tsx:allocationWording",
@@ -40564,7 +40564,7 @@
40564
40564
  "languages": [
40565
40565
  "tsx"
40566
40566
  ],
40567
- "source": "// The kiln yard in all its own words (#1516): beside the nouns, `labels` takes what the board books (`bin`), a slot held with nothing booked in it (`reservation`, `reserved`), the legend's jobs, the hold and the Library's groups, each kept in its place and its look whatever it is called.\n// inputs: []\n/** The bins, every day's, each the yard's own row. */\nexport const kilnBins = e3.record(\"kiln_bins\", DictType(StringType, KilnBin), {\n initial: yardBinRows,\n indexes: (index) => ({\n // The bins by their time: what the board's slice reads a day of them through, its navigation writing the range.\n kiln_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The days of the yard's plan, what the board publishes: Tue 4 May issued, Tue 11 and Wed 12 drafts. */\nexport const yardDays = e3.record(\"yard_days\", DictType(DateTimeType, YardDay), {\n initial: yardDayRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the board's bin kind reads them. */\nexport const yardBinRoles = East.function([KilnBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: b.spec,\n}));\n\n/** A kiln, as the board's kilns read it. */\nexport const yardKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: some(k.group), meta: none, note: k.note, min: k.min, max: k.max, hold: variant(\"days\", k.days), jobs: k.charges,\n}));\n\n/** A load, as the board's arrivals read it. */\nexport const yardLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: some(l.spec),\n due: some(l.due), window: some({ from: l.from, to: l.to }), details: [],\n}));\n\n/**\n * What a yard's fit read (#1624): a day's bins as their roles, and every kiln and every load — every kiln is a\n * candidate, and a look-ahead places every load, so both are read whole, as the board reads them.\n */\nexport const yardRead = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad)], Allocation.Types.FitContext, ($, day, kilnRows, loadRows) => {\n const kiln = $.const(yardKilnOf);\n const load = $.const(yardLoadOf);\n return { bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\" };\n});\n\n/**\n * The yard's verdicts over a day's bins as their roles (#1624): the built-in rules, then a greedy look-ahead over the\n * day's other loads — a fit that leaves more of the day's unbooked loads with nowhere to go ranks lower. What each of\n * the yard's fits answers, once it has read its own bins.\n */\nexport const yardAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest], Allocation.Types.FitResult,\n ($, day, kilnRows, loadRows, request) => {\n const read = $.const(yardRead);\n const context = $.const(read(day, kilnRows, loadRows));\n const answer = $.const(Allocation.answer);\n const rule = $.const(Allocation.fit);\n const ahead = $.const(Allocation.lookahead);\n return answer(request, context, East.function([Allocation.Types.Candidate], Allocation.Types.Fit, (_$2, c) => ahead(context, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n });\n\n/**\n * The yard's fit, on e3 (#1624): the yard's verdicts ({@link yardAnswer}) over the day's bins. It is asked the day and\n * the question, and sent no row: it reads the day's bins through their interval index, the board's unsaved bins among\n * them.\n */\nexport const yardFit = e3.function(\"yard_fit\", {\n inputs: [e3.index(kilnBins.indexes.kiln_bins_by_time), kilnBins, kilns, arrivals],\n // The board's unsaved bins are laid over them, and over their index\n drafts: [kilnBins],\n args: [Allocation.Types.FitRequest],\n output: Allocation.Types.FitResult,\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n // The day's bins, every one: a kiln's load is every bin's part on it. The index carries no row: it gives each\n // bin's key, and the record its row, both at the one drafted state.\n const roles = $.const(yardBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(yardAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n const days = $.let(Record.bind(yardDays));\n // Every bay and kiln is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationWording\", {\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] } } },\n kilns: { source: kilnIndex, fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] } } },\n }, {\n presets: [\n { id: \"halls\", name: \"Halls\", where: { kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n { id: \"small\", name: \"Compact and standard\", where: { kilns: { group: [\"Compact\", \"Standard\"] } } },\n { id: \"large\", name: \"Large and bulk\", where: { kilns: { group: [\"Large\", \"Bulk\"] } } },\n { id: \"north\", name: \"North bays, halls\", where: { bays: { area: [\"North\"] }, kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n ],\n }));\n const fit = $.let(Func.bind(yardFit));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationWording\" title=\"Kiln loading\" fit={fit} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"timeline\", date: yardDay }}\n labels={{\n lane: \"Bay\", arrival: { one: \"Delivery\", other: \"Deliveries\" }, resource: \"Kiln\", quantity: \"Vol\",\n bin: { one: \"Charge\", other: \"Charges\" }, reservation: \"Booking\", reserved: \"Booked\", priorJob: \"Last firing\", nextJob: \"Next firing\", hold: \"Dwell\",\n groups: { overdue: \"Late\", ready: \"Due soon\", removed: \"Taken off\", allocated: \"Charged\", free: \"Idle\", loading: \"Filling\", busy: \"Firing\" },\n }}\n table={{ bands: [{ from: 0, label: \"Night\" }, { from: 6, label: \"Day shift\" }, { from: 18, label: \"Evening\" }] }}\n events={{ bin: Schedule.events(bins, {\n name: \"Charge\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(days, { every: \"day\", status: { field: \"state\", draft: \"draft\", published: \"issued\" } })}\n columns={[\n { key: \"spec\", label: \"Spec\", text: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => b.specMeasured, () => East.str`booked ${b.specBooked} · measured ${b.specMeasured}`),\n tone: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => none, () => some(variant(\"warning\", null))) },\n { key: \"grade\", label: \"Grade\", text: b => b.gradeMeasured.startsWith(b.gradeBooked).ifElse(() => b.gradeMeasured, () => East.str`booked ${b.gradeBooked} · measured ${b.gradeMeasured}`), table: false },\n ]} />\n </Box>;\n }}</Reactive>)"
40567
+ "source": "// The kiln yard in all its own words (#1516): beside the nouns, `labels` takes what the board books (`bin`), a slot held with nothing booked in it (`reservation`, `reserved`), the legend's jobs, the hold and the Library's groups, each kept in its place and its look whatever it is called.\n// inputs: []\n/** The bins, every day's, each the yard's own row. */\nexport const kilnBins = e3.record(\"kiln_bins\", DictType(StringType, KilnBin), {\n initial: yardBinRows,\n indexes: (index) => ({\n // The bins by their time: what the board's slice reads a day of them through, its navigation writing the range.\n kiln_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The days of the yard's plan, what the board publishes: Tue 4 May issued, Tue 11 and Wed 12 drafts. */\nexport const yardDays = e3.record(\"yard_days\", DictType(DateTimeType, YardDay), {\n initial: yardDayRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the board's bin kind reads them. */\nexport const yardBinRoles = East.function([KilnBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: b.spec,\n}));\n\n/** A kiln, as the board's kilns read it. */\nexport const yardKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: some(k.group), meta: none, note: k.note, min: k.min, max: k.max, hold: variant(\"days\", k.days), jobs: k.charges,\n}));\n\n/** A load, as the board's arrivals read it. */\nexport const yardLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: some(l.spec),\n due: some(l.due), window: some({ from: l.from, to: l.to }), details: [],\n}));\n\n/**\n * What a yard's fit read (#1624): a day's bins as their roles, and every kiln and every load — every kiln is a\n * candidate, and a look-ahead places every load, so both are read whole, as the board reads them.\n */\nexport const yardRead = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad)], Allocation.Types.FitContext(), ($, day, kilnRows, loadRows) => {\n const kiln = $.const(yardKilnOf);\n const load = $.const(yardLoadOf);\n return { bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\" };\n});\n\n/**\n * The yard's verdicts over a day's bins as their roles (#1624): the built-in rules, then a greedy look-ahead over the\n * day's other loads — a fit that leaves more of the day's unbooked loads with nowhere to go ranks lower. What each of\n * the yard's fits answers, once it has read its own bins.\n */\nexport const yardAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest()], Allocation.Types.FitResult(),\n ($, day, kilnRows, loadRows, request) => {\n const read = $.const(yardRead);\n const context = $.const(read(day, kilnRows, loadRows));\n const answer = $.const(Allocation.answer());\n const rule = $.const(Allocation.fit());\n const ahead = $.const(Allocation.lookahead());\n return answer(request, context, East.function([Allocation.Types.Candidate()], Allocation.Types.Fit, (_$2, c) => ahead(context, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n });\n\n/**\n * The yard's fit, on e3 (#1624): the yard's verdicts ({@link yardAnswer}) over the day's bins. It is asked the day and\n * the question, and sent no row: it reads the day's bins through their interval index, the board's unsaved bins among\n * them.\n */\nexport const yardFit = e3.function(\"yard_fit\", {\n inputs: [e3.index(kilnBins.indexes.kiln_bins_by_time), kilnBins, kilns, arrivals],\n // The board's unsaved bins are laid over them, and over their index\n drafts: [kilnBins],\n args: [Allocation.Types.FitRequest()],\n output: Allocation.Types.FitResult(),\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n // The day's bins, every one: a kiln's load is every bin's part on it. The index carries no row: it gives each\n // bin's key, and the record its row, both at the one drafted state.\n const roles = $.const(yardBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(yardAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n const days = $.let(Record.bind(yardDays));\n // Every bay and kiln is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationWording\", {\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] } } },\n kilns: { source: kilnIndex, fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] } } },\n }, {\n presets: [\n { id: \"halls\", name: \"Halls\", where: { kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n { id: \"small\", name: \"Compact and standard\", where: { kilns: { group: [\"Compact\", \"Standard\"] } } },\n { id: \"large\", name: \"Large and bulk\", where: { kilns: { group: [\"Large\", \"Bulk\"] } } },\n { id: \"north\", name: \"North bays, halls\", where: { bays: { area: [\"North\"] }, kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n ],\n }));\n const fit = $.let(Func.bind(yardFit));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationWording\" title=\"Kiln loading\" fit={fit} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"timeline\", date: yardDay }}\n labels={{\n lane: \"Bay\", arrival: { one: \"Delivery\", other: \"Deliveries\" }, resource: \"Kiln\", quantity: \"Vol\",\n bin: { one: \"Charge\", other: \"Charges\" }, reservation: \"Booking\", reserved: \"Booked\", priorJob: \"Last firing\", nextJob: \"Next firing\", hold: \"Dwell\",\n groups: { overdue: \"Late\", ready: \"Due soon\", removed: \"Taken off\", allocated: \"Charged\", free: \"Idle\", loading: \"Filling\", busy: \"Firing\" },\n }}\n table={{ bands: [{ from: 0, label: \"Night\" }, { from: 6, label: \"Day shift\" }, { from: 18, label: \"Evening\" }] }}\n events={{ bin: Schedule.events(bins, {\n name: \"Charge\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(days, { every: \"day\", status: { field: \"state\", draft: \"draft\", published: \"issued\" } })}\n columns={[\n { key: \"spec\", label: \"Spec\", text: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => b.specMeasured, () => East.str`booked ${b.specBooked} · measured ${b.specMeasured}`),\n tone: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => none, () => some(variant(\"warning\", null))) },\n { key: \"grade\", label: \"Grade\", text: b => b.gradeMeasured.startsWith(b.gradeBooked).ifElse(() => b.gradeMeasured, () => East.str`booked ${b.gradeBooked} · measured ${b.gradeMeasured}`), table: false },\n ]} />\n </Box>;\n }}</Reactive>)"
40568
40568
  },
40569
40569
  {
40570
40570
  "id": "e3-ui:allocation.examples.tsx:allocationPublished",
@@ -40591,7 +40591,7 @@
40591
40591
  "languages": [
40592
40592
  "tsx"
40593
40593
  ],
40594
- "source": "// A published day, Tue 4 May, its status the yard's own day issued: read-only under its banner; navigation, the narrowing, the focus, links and the inspector still work.\n// inputs: []\n/** The bins, every day's, each the yard's own row. */\nexport const kilnBins = e3.record(\"kiln_bins\", DictType(StringType, KilnBin), {\n initial: yardBinRows,\n indexes: (index) => ({\n // The bins by their time: what the board's slice reads a day of them through, its navigation writing the range.\n kiln_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The days of the yard's plan, what the board publishes: Tue 4 May issued, Tue 11 and Wed 12 drafts. */\nexport const yardDays = e3.record(\"yard_days\", DictType(DateTimeType, YardDay), {\n initial: yardDayRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the board's bin kind reads them. */\nexport const yardBinRoles = East.function([KilnBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: b.spec,\n}));\n\n/** A kiln, as the board's kilns read it. */\nexport const yardKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: some(k.group), meta: none, note: k.note, min: k.min, max: k.max, hold: variant(\"days\", k.days), jobs: k.charges,\n}));\n\n/** A load, as the board's arrivals read it. */\nexport const yardLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: some(l.spec),\n due: some(l.due), window: some({ from: l.from, to: l.to }), details: [],\n}));\n\n/**\n * What a yard's fit read (#1624): a day's bins as their roles, and every kiln and every load — every kiln is a\n * candidate, and a look-ahead places every load, so both are read whole, as the board reads them.\n */\nexport const yardRead = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad)], Allocation.Types.FitContext, ($, day, kilnRows, loadRows) => {\n const kiln = $.const(yardKilnOf);\n const load = $.const(yardLoadOf);\n return { bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\" };\n});\n\n/**\n * The yard's verdicts over a day's bins as their roles (#1624): the built-in rules, then a greedy look-ahead over the\n * day's other loads — a fit that leaves more of the day's unbooked loads with nowhere to go ranks lower. What each of\n * the yard's fits answers, once it has read its own bins.\n */\nexport const yardAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest], Allocation.Types.FitResult,\n ($, day, kilnRows, loadRows, request) => {\n const read = $.const(yardRead);\n const context = $.const(read(day, kilnRows, loadRows));\n const answer = $.const(Allocation.answer);\n const rule = $.const(Allocation.fit);\n const ahead = $.const(Allocation.lookahead);\n return answer(request, context, East.function([Allocation.Types.Candidate], Allocation.Types.Fit, (_$2, c) => ahead(context, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n });\n\n/**\n * The yard's fit, on e3 (#1624): the yard's verdicts ({@link yardAnswer}) over the day's bins. It is asked the day and\n * the question, and sent no row: it reads the day's bins through their interval index, the board's unsaved bins among\n * them.\n */\nexport const yardFit = e3.function(\"yard_fit\", {\n inputs: [e3.index(kilnBins.indexes.kiln_bins_by_time), kilnBins, kilns, arrivals],\n // The board's unsaved bins are laid over them, and over their index\n drafts: [kilnBins],\n args: [Allocation.Types.FitRequest],\n output: Allocation.Types.FitResult,\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n // The day's bins, every one: a kiln's load is every bin's part on it. The index carries no row: it gives each\n // bin's key, and the record its row, both at the one drafted state.\n const roles = $.const(yardBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(yardAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n const days = $.let(Record.bind(yardDays));\n // Every bay and kiln is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationPublished\", {\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] } } },\n kilns: { source: kilnIndex, fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] } } },\n }, {\n presets: [\n { id: \"halls\", name: \"Halls\", where: { kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n { id: \"small\", name: \"Compact and standard\", where: { kilns: { group: [\"Compact\", \"Standard\"] } } },\n { id: \"large\", name: \"Large and bulk\", where: { kilns: { group: [\"Large\", \"Bulk\"] } } },\n { id: \"north\", name: \"North bays, halls\", where: { bays: { area: [\"North\"] }, kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n ],\n }));\n const fit = $.let(Func.bind(yardFit));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationPublished\" title=\"Kiln loading\" fit={fit} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"timeline\", date: yardPublishedDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(days, { every: \"day\", status: { field: \"state\", draft: \"draft\", published: \"issued\" } })}\n columns={[\n { key: \"spec\", label: \"Spec\", text: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => b.specMeasured, () => East.str`booked ${b.specBooked} · measured ${b.specMeasured}`),\n tone: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => none, () => some(variant(\"warning\", null))) },\n { key: \"grade\", label: \"Grade\", text: b => b.gradeMeasured.startsWith(b.gradeBooked).ifElse(() => b.gradeMeasured, () => East.str`booked ${b.gradeBooked} · measured ${b.gradeMeasured}`), table: false },\n ]} />\n </Box>;\n }}</Reactive>)"
40594
+ "source": "// A published day, Tue 4 May, its status the yard's own day issued: read-only under its banner; navigation, the narrowing, the focus, links and the inspector still work.\n// inputs: []\n/** The bins, every day's, each the yard's own row. */\nexport const kilnBins = e3.record(\"kiln_bins\", DictType(StringType, KilnBin), {\n initial: yardBinRows,\n indexes: (index) => ({\n // The bins by their time: what the board's slice reads a day of them through, its navigation writing the range.\n kiln_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The days of the yard's plan, what the board publishes: Tue 4 May issued, Tue 11 and Wed 12 drafts. */\nexport const yardDays = e3.record(\"yard_days\", DictType(DateTimeType, YardDay), {\n initial: yardDayRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the board's bin kind reads them. */\nexport const yardBinRoles = East.function([KilnBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: b.spec,\n}));\n\n/** A kiln, as the board's kilns read it. */\nexport const yardKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: some(k.group), meta: none, note: k.note, min: k.min, max: k.max, hold: variant(\"days\", k.days), jobs: k.charges,\n}));\n\n/** A load, as the board's arrivals read it. */\nexport const yardLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: some(l.spec),\n due: some(l.due), window: some({ from: l.from, to: l.to }), details: [],\n}));\n\n/**\n * What a yard's fit read (#1624): a day's bins as their roles, and every kiln and every load — every kiln is a\n * candidate, and a look-ahead places every load, so both are read whole, as the board reads them.\n */\nexport const yardRead = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad)], Allocation.Types.FitContext(), ($, day, kilnRows, loadRows) => {\n const kiln = $.const(yardKilnOf);\n const load = $.const(yardLoadOf);\n return { bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\" };\n});\n\n/**\n * The yard's verdicts over a day's bins as their roles (#1624): the built-in rules, then a greedy look-ahead over the\n * day's other loads — a fit that leaves more of the day's unbooked loads with nowhere to go ranks lower. What each of\n * the yard's fits answers, once it has read its own bins.\n */\nexport const yardAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest()], Allocation.Types.FitResult(),\n ($, day, kilnRows, loadRows, request) => {\n const read = $.const(yardRead);\n const context = $.const(read(day, kilnRows, loadRows));\n const answer = $.const(Allocation.answer());\n const rule = $.const(Allocation.fit());\n const ahead = $.const(Allocation.lookahead());\n return answer(request, context, East.function([Allocation.Types.Candidate()], Allocation.Types.Fit, (_$2, c) => ahead(context, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n });\n\n/**\n * The yard's fit, on e3 (#1624): the yard's verdicts ({@link yardAnswer}) over the day's bins. It is asked the day and\n * the question, and sent no row: it reads the day's bins through their interval index, the board's unsaved bins among\n * them.\n */\nexport const yardFit = e3.function(\"yard_fit\", {\n inputs: [e3.index(kilnBins.indexes.kiln_bins_by_time), kilnBins, kilns, arrivals],\n // The board's unsaved bins are laid over them, and over their index\n drafts: [kilnBins],\n args: [Allocation.Types.FitRequest()],\n output: Allocation.Types.FitResult(),\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n // The day's bins, every one: a kiln's load is every bin's part on it. The index carries no row: it gives each\n // bin's key, and the record its row, both at the one drafted state.\n const roles = $.const(yardBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(yardAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n const days = $.let(Record.bind(yardDays));\n // Every bay and kiln is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationPublished\", {\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] } } },\n kilns: { source: kilnIndex, fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] } } },\n }, {\n presets: [\n { id: \"halls\", name: \"Halls\", where: { kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n { id: \"small\", name: \"Compact and standard\", where: { kilns: { group: [\"Compact\", \"Standard\"] } } },\n { id: \"large\", name: \"Large and bulk\", where: { kilns: { group: [\"Large\", \"Bulk\"] } } },\n { id: \"north\", name: \"North bays, halls\", where: { bays: { area: [\"North\"] }, kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n ],\n }));\n const fit = $.let(Func.bind(yardFit));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationPublished\" title=\"Kiln loading\" fit={fit} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"timeline\", date: yardPublishedDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(days, { every: \"day\", status: { field: \"state\", draft: \"draft\", published: \"issued\" } })}\n columns={[\n { key: \"spec\", label: \"Spec\", text: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => b.specMeasured, () => East.str`booked ${b.specBooked} · measured ${b.specMeasured}`),\n tone: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => none, () => some(variant(\"warning\", null))) },\n { key: \"grade\", label: \"Grade\", text: b => b.gradeMeasured.startsWith(b.gradeBooked).ifElse(() => b.gradeMeasured, () => East.str`booked ${b.gradeBooked} · measured ${b.gradeMeasured}`), table: false },\n ]} />\n </Box>;\n }}</Reactive>)"
40595
40595
  },
40596
40596
  {
40597
40597
  "id": "e3-ui:allocation.examples.tsx:allocationWeekly",
@@ -40621,7 +40621,7 @@
40621
40621
  "languages": [
40622
40622
  "tsx"
40623
40623
  ],
40624
- "source": "// The kiln yard publishing a week at a time (#1550): `periods` over the yard's weeks, `Schedule.periods(weeks, { every: \"week\", status })`, each row keyed by the first day of its week, which `week={{ start }}` names — Monday here, as by default. Publish writes the week holding the day in view, after Save; every day of a published week is read-only under its banner, and the picker marks each day with its week's status. The week of Mon 3 May is issued, the plan day's week a draft.\n// inputs: []\n/** The bins, every day's, each the yard's own row. */\nexport const kilnBins = e3.record(\"kiln_bins\", DictType(StringType, KilnBin), {\n initial: yardBinRows,\n indexes: (index) => ({\n // The bins by their time: what the board's slice reads a day of them through, its navigation writing the range.\n kiln_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The weeks of the yard's plan, for a board publishing a week at a time (#1550): each keyed by its Monday, the week of 3 May issued, the plan day's a draft. */\nexport const yardWeeks = e3.record(\"yard_weeks\", DictType(DateTimeType, YardWeek), {\n initial: yardWeekRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the board's bin kind reads them. */\nexport const yardBinRoles = East.function([KilnBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: b.spec,\n}));\n\n/** A kiln, as the board's kilns read it. */\nexport const yardKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: some(k.group), meta: none, note: k.note, min: k.min, max: k.max, hold: variant(\"days\", k.days), jobs: k.charges,\n}));\n\n/** A load, as the board's arrivals read it. */\nexport const yardLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: some(l.spec),\n due: some(l.due), window: some({ from: l.from, to: l.to }), details: [],\n}));\n\n/**\n * What a yard's fit read (#1624): a day's bins as their roles, and every kiln and every load — every kiln is a\n * candidate, and a look-ahead places every load, so both are read whole, as the board reads them.\n */\nexport const yardRead = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad)], Allocation.Types.FitContext, ($, day, kilnRows, loadRows) => {\n const kiln = $.const(yardKilnOf);\n const load = $.const(yardLoadOf);\n return { bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\" };\n});\n\n/**\n * The yard's verdicts over a day's bins as their roles (#1624): the built-in rules, then a greedy look-ahead over the\n * day's other loads — a fit that leaves more of the day's unbooked loads with nowhere to go ranks lower. What each of\n * the yard's fits answers, once it has read its own bins.\n */\nexport const yardAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest], Allocation.Types.FitResult,\n ($, day, kilnRows, loadRows, request) => {\n const read = $.const(yardRead);\n const context = $.const(read(day, kilnRows, loadRows));\n const answer = $.const(Allocation.answer);\n const rule = $.const(Allocation.fit);\n const ahead = $.const(Allocation.lookahead);\n return answer(request, context, East.function([Allocation.Types.Candidate], Allocation.Types.Fit, (_$2, c) => ahead(context, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n });\n\n/**\n * The yard's fit, on e3 (#1624): the yard's verdicts ({@link yardAnswer}) over the day's bins. It is asked the day and\n * the question, and sent no row: it reads the day's bins through their interval index, the board's unsaved bins among\n * them.\n */\nexport const yardFit = e3.function(\"yard_fit\", {\n inputs: [e3.index(kilnBins.indexes.kiln_bins_by_time), kilnBins, kilns, arrivals],\n // The board's unsaved bins are laid over them, and over their index\n drafts: [kilnBins],\n args: [Allocation.Types.FitRequest],\n output: Allocation.Types.FitResult,\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n // The day's bins, every one: a kiln's load is every bin's part on it. The index carries no row: it gives each\n // bin's key, and the record its row, both at the one drafted state.\n const roles = $.const(yardBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(yardAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n // What the board publishes: the yard's weeks, each through the record's patch door.\n const weeks = $.let(Record.bind(yardWeeks));\n // Every bay and kiln is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationWeekly\", {\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] } } },\n kilns: { source: kilnIndex, fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] } } },\n }));\n const fit = $.let(Func.bind(yardFit));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationWeekly\" title=\"Kiln loading\" fit={fit} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"timeline\", date: yardDay }} week={{ start: \"monday\" }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(weeks, { every: \"week\", status: { field: \"state\", draft: \"draft\", published: \"issued\" } })} />\n </Box>;\n }}</Reactive>)"
40624
+ "source": "// The kiln yard publishing a week at a time (#1550): `periods` over the yard's weeks, `Schedule.periods(weeks, { every: \"week\", status })`, each row keyed by the first day of its week, which `week={{ start }}` names — Monday here, as by default. Publish writes the week holding the day in view, after Save; every day of a published week is read-only under its banner, and the picker marks each day with its week's status. The week of Mon 3 May is issued, the plan day's week a draft.\n// inputs: []\n/** The bins, every day's, each the yard's own row. */\nexport const kilnBins = e3.record(\"kiln_bins\", DictType(StringType, KilnBin), {\n initial: yardBinRows,\n indexes: (index) => ({\n // The bins by their time: what the board's slice reads a day of them through, its navigation writing the range.\n kiln_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The weeks of the yard's plan, for a board publishing a week at a time (#1550): each keyed by its Monday, the week of 3 May issued, the plan day's a draft. */\nexport const yardWeeks = e3.record(\"yard_weeks\", DictType(DateTimeType, YardWeek), {\n initial: yardWeekRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the board's bin kind reads them. */\nexport const yardBinRoles = East.function([KilnBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: b.spec,\n}));\n\n/** A kiln, as the board's kilns read it. */\nexport const yardKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: some(k.group), meta: none, note: k.note, min: k.min, max: k.max, hold: variant(\"days\", k.days), jobs: k.charges,\n}));\n\n/** A load, as the board's arrivals read it. */\nexport const yardLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: some(l.spec),\n due: some(l.due), window: some({ from: l.from, to: l.to }), details: [],\n}));\n\n/**\n * What a yard's fit read (#1624): a day's bins as their roles, and every kiln and every load — every kiln is a\n * candidate, and a look-ahead places every load, so both are read whole, as the board reads them.\n */\nexport const yardRead = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad)], Allocation.Types.FitContext(), ($, day, kilnRows, loadRows) => {\n const kiln = $.const(yardKilnOf);\n const load = $.const(yardLoadOf);\n return { bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\" };\n});\n\n/**\n * The yard's verdicts over a day's bins as their roles (#1624): the built-in rules, then a greedy look-ahead over the\n * day's other loads — a fit that leaves more of the day's unbooked loads with nowhere to go ranks lower. What each of\n * the yard's fits answers, once it has read its own bins.\n */\nexport const yardAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest()], Allocation.Types.FitResult(),\n ($, day, kilnRows, loadRows, request) => {\n const read = $.const(yardRead);\n const context = $.const(read(day, kilnRows, loadRows));\n const answer = $.const(Allocation.answer());\n const rule = $.const(Allocation.fit());\n const ahead = $.const(Allocation.lookahead());\n return answer(request, context, East.function([Allocation.Types.Candidate()], Allocation.Types.Fit, (_$2, c) => ahead(context, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n });\n\n/**\n * The yard's fit, on e3 (#1624): the yard's verdicts ({@link yardAnswer}) over the day's bins. It is asked the day and\n * the question, and sent no row: it reads the day's bins through their interval index, the board's unsaved bins among\n * them.\n */\nexport const yardFit = e3.function(\"yard_fit\", {\n inputs: [e3.index(kilnBins.indexes.kiln_bins_by_time), kilnBins, kilns, arrivals],\n // The board's unsaved bins are laid over them, and over their index\n drafts: [kilnBins],\n args: [Allocation.Types.FitRequest()],\n output: Allocation.Types.FitResult(),\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n // The day's bins, every one: a kiln's load is every bin's part on it. The index carries no row: it gives each\n // bin's key, and the record its row, both at the one drafted state.\n const roles = $.const(yardBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(yardAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n // What the board publishes: the yard's weeks, each through the record's patch door.\n const weeks = $.let(Record.bind(yardWeeks));\n // Every bay and kiln is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationWeekly\", {\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] } } },\n kilns: { source: kilnIndex, fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] } } },\n }));\n const fit = $.let(Func.bind(yardFit));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationWeekly\" title=\"Kiln loading\" fit={fit} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"timeline\", date: yardDay }} week={{ start: \"monday\" }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(weeks, { every: \"week\", status: { field: \"state\", draft: \"draft\", published: \"issued\" } })} />\n </Box>;\n }}</Reactive>)"
40625
40625
  },
40626
40626
  {
40627
40627
  "id": "e3-ui:allocation.examples.tsx:allocationNoPublish",
@@ -40648,7 +40648,7 @@
40648
40648
  "languages": [
40649
40649
  "tsx"
40650
40650
  ],
40651
- "source": "// The kiln yard with no `periods`: no status chip and no Publish; Save writes the day's bins as drafts.\n// inputs: []\n/** The bins, every day's, each the yard's own row. */\nexport const kilnBins = e3.record(\"kiln_bins\", DictType(StringType, KilnBin), {\n initial: yardBinRows,\n indexes: (index) => ({\n // The bins by their time: what the board's slice reads a day of them through, its navigation writing the range.\n kiln_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the board's bin kind reads them. */\nexport const yardBinRoles = East.function([KilnBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: b.spec,\n}));\n\n/** A kiln, as the board's kilns read it. */\nexport const yardKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: some(k.group), meta: none, note: k.note, min: k.min, max: k.max, hold: variant(\"days\", k.days), jobs: k.charges,\n}));\n\n/** A load, as the board's arrivals read it. */\nexport const yardLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: some(l.spec),\n due: some(l.due), window: some({ from: l.from, to: l.to }), details: [],\n}));\n\n/**\n * What a yard's fit read (#1624): a day's bins as their roles, and every kiln and every load — every kiln is a\n * candidate, and a look-ahead places every load, so both are read whole, as the board reads them.\n */\nexport const yardRead = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad)], Allocation.Types.FitContext, ($, day, kilnRows, loadRows) => {\n const kiln = $.const(yardKilnOf);\n const load = $.const(yardLoadOf);\n return { bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\" };\n});\n\n/**\n * The yard's verdicts over a day's bins as their roles (#1624): the built-in rules, then a greedy look-ahead over the\n * day's other loads — a fit that leaves more of the day's unbooked loads with nowhere to go ranks lower. What each of\n * the yard's fits answers, once it has read its own bins.\n */\nexport const yardAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest], Allocation.Types.FitResult,\n ($, day, kilnRows, loadRows, request) => {\n const read = $.const(yardRead);\n const context = $.const(read(day, kilnRows, loadRows));\n const answer = $.const(Allocation.answer);\n const rule = $.const(Allocation.fit);\n const ahead = $.const(Allocation.lookahead);\n return answer(request, context, East.function([Allocation.Types.Candidate], Allocation.Types.Fit, (_$2, c) => ahead(context, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n });\n\n/**\n * The yard's fit, on e3 (#1624): the yard's verdicts ({@link yardAnswer}) over the day's bins. It is asked the day and\n * the question, and sent no row: it reads the day's bins through their interval index, the board's unsaved bins among\n * them.\n */\nexport const yardFit = e3.function(\"yard_fit\", {\n inputs: [e3.index(kilnBins.indexes.kiln_bins_by_time), kilnBins, kilns, arrivals],\n // The board's unsaved bins are laid over them, and over their index\n drafts: [kilnBins],\n args: [Allocation.Types.FitRequest],\n output: Allocation.Types.FitResult,\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n // The day's bins, every one: a kiln's load is every bin's part on it. The index carries no row: it gives each\n // bin's key, and the record its row, both at the one drafted state.\n const roles = $.const(yardBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(yardAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n // Every bay and kiln is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationNoPublish\", {\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] } } },\n kilns: { source: kilnIndex, fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] } } },\n }, {\n presets: [\n { id: \"halls\", name: \"Halls\", where: { kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n { id: \"small\", name: \"Compact and standard\", where: { kilns: { group: [\"Compact\", \"Standard\"] } } },\n { id: \"large\", name: \"Large and bulk\", where: { kilns: { group: [\"Large\", \"Bulk\"] } } },\n { id: \"north\", name: \"North bays, halls\", where: { bays: { area: [\"North\"] }, kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n ],\n }));\n const fit = $.let(Func.bind(yardFit));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationNoPublish\" title=\"Kiln loading\" fit={fit} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"timeline\", date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n columns={[\n { key: \"spec\", label: \"Spec\", text: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => b.specMeasured, () => East.str`booked ${b.specBooked} · measured ${b.specMeasured}`),\n tone: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => none, () => some(variant(\"warning\", null))) },\n { key: \"grade\", label: \"Grade\", text: b => b.gradeMeasured.startsWith(b.gradeBooked).ifElse(() => b.gradeMeasured, () => East.str`booked ${b.gradeBooked} · measured ${b.gradeMeasured}`), table: false },\n ]} />\n </Box>;\n }}</Reactive>)"
40651
+ "source": "// The kiln yard with no `periods`: no status chip and no Publish; Save writes the day's bins as drafts.\n// inputs: []\n/** The bins, every day's, each the yard's own row. */\nexport const kilnBins = e3.record(\"kiln_bins\", DictType(StringType, KilnBin), {\n initial: yardBinRows,\n indexes: (index) => ({\n // The bins by their time: what the board's slice reads a day of them through, its navigation writing the range.\n kiln_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the board's bin kind reads them. */\nexport const yardBinRoles = East.function([KilnBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: b.spec,\n}));\n\n/** A kiln, as the board's kilns read it. */\nexport const yardKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: some(k.group), meta: none, note: k.note, min: k.min, max: k.max, hold: variant(\"days\", k.days), jobs: k.charges,\n}));\n\n/** A load, as the board's arrivals read it. */\nexport const yardLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: some(l.spec),\n due: some(l.due), window: some({ from: l.from, to: l.to }), details: [],\n}));\n\n/**\n * What a yard's fit read (#1624): a day's bins as their roles, and every kiln and every load — every kiln is a\n * candidate, and a look-ahead places every load, so both are read whole, as the board reads them.\n */\nexport const yardRead = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad)], Allocation.Types.FitContext(), ($, day, kilnRows, loadRows) => {\n const kiln = $.const(yardKilnOf);\n const load = $.const(yardLoadOf);\n return { bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\" };\n});\n\n/**\n * The yard's verdicts over a day's bins as their roles (#1624): the built-in rules, then a greedy look-ahead over the\n * day's other loads — a fit that leaves more of the day's unbooked loads with nowhere to go ranks lower. What each of\n * the yard's fits answers, once it has read its own bins.\n */\nexport const yardAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest()], Allocation.Types.FitResult(),\n ($, day, kilnRows, loadRows, request) => {\n const read = $.const(yardRead);\n const context = $.const(read(day, kilnRows, loadRows));\n const answer = $.const(Allocation.answer());\n const rule = $.const(Allocation.fit());\n const ahead = $.const(Allocation.lookahead());\n return answer(request, context, East.function([Allocation.Types.Candidate()], Allocation.Types.Fit, (_$2, c) => ahead(context, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n });\n\n/**\n * The yard's fit, on e3 (#1624): the yard's verdicts ({@link yardAnswer}) over the day's bins. It is asked the day and\n * the question, and sent no row: it reads the day's bins through their interval index, the board's unsaved bins among\n * them.\n */\nexport const yardFit = e3.function(\"yard_fit\", {\n inputs: [e3.index(kilnBins.indexes.kiln_bins_by_time), kilnBins, kilns, arrivals],\n // The board's unsaved bins are laid over them, and over their index\n drafts: [kilnBins],\n args: [Allocation.Types.FitRequest()],\n output: Allocation.Types.FitResult(),\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n // The day's bins, every one: a kiln's load is every bin's part on it. The index carries no row: it gives each\n // bin's key, and the record its row, both at the one drafted state.\n const roles = $.const(yardBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(yardAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n // Every bay and kiln is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationNoPublish\", {\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] } } },\n kilns: { source: kilnIndex, fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] } } },\n }, {\n presets: [\n { id: \"halls\", name: \"Halls\", where: { kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n { id: \"small\", name: \"Compact and standard\", where: { kilns: { group: [\"Compact\", \"Standard\"] } } },\n { id: \"large\", name: \"Large and bulk\", where: { kilns: { group: [\"Large\", \"Bulk\"] } } },\n { id: \"north\", name: \"North bays, halls\", where: { bays: { area: [\"North\"] }, kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n ],\n }));\n const fit = $.let(Func.bind(yardFit));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationNoPublish\" title=\"Kiln loading\" fit={fit} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"timeline\", date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n columns={[\n { key: \"spec\", label: \"Spec\", text: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => b.specMeasured, () => East.str`booked ${b.specBooked} · measured ${b.specMeasured}`),\n tone: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => none, () => some(variant(\"warning\", null))) },\n { key: \"grade\", label: \"Grade\", text: b => b.gradeMeasured.startsWith(b.gradeBooked).ifElse(() => b.gradeMeasured, () => East.str`booked ${b.gradeBooked} · measured ${b.gradeMeasured}`), table: false },\n ]} />\n </Box>;\n }}</Reactive>)"
40652
40652
  },
40653
40653
  {
40654
40654
  "id": "e3-ui:allocation.examples.tsx:allocationSplit",
@@ -40676,7 +40676,7 @@
40676
40676
  "languages": [
40677
40677
  "tsx"
40678
40678
  ],
40679
- "source": "// Loads split across kilns on Wed 12 May: each bin's parts on their kilns, one load with 4 m³ unallocated and its Partly allocated issue, and a link to each part.\n// inputs: []\n/** The bins, every day's, each the yard's own row. */\nexport const kilnBins = e3.record(\"kiln_bins\", DictType(StringType, KilnBin), {\n initial: yardBinRows,\n indexes: (index) => ({\n // The bins by their time: what the board's slice reads a day of them through, its navigation writing the range.\n kiln_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The days of the yard's plan, what the board publishes: Tue 4 May issued, Tue 11 and Wed 12 drafts. */\nexport const yardDays = e3.record(\"yard_days\", DictType(DateTimeType, YardDay), {\n initial: yardDayRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the board's bin kind reads them. */\nexport const yardBinRoles = East.function([KilnBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: b.spec,\n}));\n\n/** A kiln, as the board's kilns read it. */\nexport const yardKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: some(k.group), meta: none, note: k.note, min: k.min, max: k.max, hold: variant(\"days\", k.days), jobs: k.charges,\n}));\n\n/** A load, as the board's arrivals read it. */\nexport const yardLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: some(l.spec),\n due: some(l.due), window: some({ from: l.from, to: l.to }), details: [],\n}));\n\n/**\n * What a yard's fit read (#1624): a day's bins as their roles, and every kiln and every load — every kiln is a\n * candidate, and a look-ahead places every load, so both are read whole, as the board reads them.\n */\nexport const yardRead = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad)], Allocation.Types.FitContext, ($, day, kilnRows, loadRows) => {\n const kiln = $.const(yardKilnOf);\n const load = $.const(yardLoadOf);\n return { bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\" };\n});\n\n/**\n * The yard's verdicts over a day's bins as their roles (#1624): the built-in rules, then a greedy look-ahead over the\n * day's other loads — a fit that leaves more of the day's unbooked loads with nowhere to go ranks lower. What each of\n * the yard's fits answers, once it has read its own bins.\n */\nexport const yardAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest], Allocation.Types.FitResult,\n ($, day, kilnRows, loadRows, request) => {\n const read = $.const(yardRead);\n const context = $.const(read(day, kilnRows, loadRows));\n const answer = $.const(Allocation.answer);\n const rule = $.const(Allocation.fit);\n const ahead = $.const(Allocation.lookahead);\n return answer(request, context, East.function([Allocation.Types.Candidate], Allocation.Types.Fit, (_$2, c) => ahead(context, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n });\n\n/**\n * The yard's fit, on e3 (#1624): the yard's verdicts ({@link yardAnswer}) over the day's bins. It is asked the day and\n * the question, and sent no row: it reads the day's bins through their interval index, the board's unsaved bins among\n * them.\n */\nexport const yardFit = e3.function(\"yard_fit\", {\n inputs: [e3.index(kilnBins.indexes.kiln_bins_by_time), kilnBins, kilns, arrivals],\n // The board's unsaved bins are laid over them, and over their index\n drafts: [kilnBins],\n args: [Allocation.Types.FitRequest],\n output: Allocation.Types.FitResult,\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n // The day's bins, every one: a kiln's load is every bin's part on it. The index carries no row: it gives each\n // bin's key, and the record its row, both at the one drafted state.\n const roles = $.const(yardBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(yardAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n const days = $.let(Record.bind(yardDays));\n // Every bay and kiln is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationSplit\", {\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] } } },\n kilns: { source: kilnIndex, fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] } } },\n }, {\n presets: [\n { id: \"halls\", name: \"Halls\", where: { kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n { id: \"small\", name: \"Compact and standard\", where: { kilns: { group: [\"Compact\", \"Standard\"] } } },\n { id: \"large\", name: \"Large and bulk\", where: { kilns: { group: [\"Large\", \"Bulk\"] } } },\n { id: \"north\", name: \"North bays, halls\", where: { bays: { area: [\"North\"] }, kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n ],\n }));\n const fit = $.let(Func.bind(yardFit));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationSplit\" title=\"Kiln loading\" fit={fit} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"timeline\", date: yardSplitDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(days, { every: \"day\", status: { field: \"state\", draft: \"draft\", published: \"issued\" } })}\n columns={[\n { key: \"spec\", label: \"Spec\", text: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => b.specMeasured, () => East.str`booked ${b.specBooked} · measured ${b.specMeasured}`),\n tone: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => none, () => some(variant(\"warning\", null))) },\n { key: \"grade\", label: \"Grade\", text: b => b.gradeMeasured.startsWith(b.gradeBooked).ifElse(() => b.gradeMeasured, () => East.str`booked ${b.gradeBooked} · measured ${b.gradeMeasured}`), table: false },\n ]} />\n </Box>;\n }}</Reactive>)"
40679
+ "source": "// Loads split across kilns on Wed 12 May: each bin's parts on their kilns, one load with 4 m³ unallocated and its Partly allocated issue, and a link to each part.\n// inputs: []\n/** The bins, every day's, each the yard's own row. */\nexport const kilnBins = e3.record(\"kiln_bins\", DictType(StringType, KilnBin), {\n initial: yardBinRows,\n indexes: (index) => ({\n // The bins by their time: what the board's slice reads a day of them through, its navigation writing the range.\n kiln_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The days of the yard's plan, what the board publishes: Tue 4 May issued, Tue 11 and Wed 12 drafts. */\nexport const yardDays = e3.record(\"yard_days\", DictType(DateTimeType, YardDay), {\n initial: yardDayRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the board's bin kind reads them. */\nexport const yardBinRoles = East.function([KilnBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: b.spec,\n}));\n\n/** A kiln, as the board's kilns read it. */\nexport const yardKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: some(k.group), meta: none, note: k.note, min: k.min, max: k.max, hold: variant(\"days\", k.days), jobs: k.charges,\n}));\n\n/** A load, as the board's arrivals read it. */\nexport const yardLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: some(l.spec),\n due: some(l.due), window: some({ from: l.from, to: l.to }), details: [],\n}));\n\n/**\n * What a yard's fit read (#1624): a day's bins as their roles, and every kiln and every load — every kiln is a\n * candidate, and a look-ahead places every load, so both are read whole, as the board reads them.\n */\nexport const yardRead = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad)], Allocation.Types.FitContext(), ($, day, kilnRows, loadRows) => {\n const kiln = $.const(yardKilnOf);\n const load = $.const(yardLoadOf);\n return { bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\" };\n});\n\n/**\n * The yard's verdicts over a day's bins as their roles (#1624): the built-in rules, then a greedy look-ahead over the\n * day's other loads — a fit that leaves more of the day's unbooked loads with nowhere to go ranks lower. What each of\n * the yard's fits answers, once it has read its own bins.\n */\nexport const yardAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest()], Allocation.Types.FitResult(),\n ($, day, kilnRows, loadRows, request) => {\n const read = $.const(yardRead);\n const context = $.const(read(day, kilnRows, loadRows));\n const answer = $.const(Allocation.answer());\n const rule = $.const(Allocation.fit());\n const ahead = $.const(Allocation.lookahead());\n return answer(request, context, East.function([Allocation.Types.Candidate()], Allocation.Types.Fit, (_$2, c) => ahead(context, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n });\n\n/**\n * The yard's fit, on e3 (#1624): the yard's verdicts ({@link yardAnswer}) over the day's bins. It is asked the day and\n * the question, and sent no row: it reads the day's bins through their interval index, the board's unsaved bins among\n * them.\n */\nexport const yardFit = e3.function(\"yard_fit\", {\n inputs: [e3.index(kilnBins.indexes.kiln_bins_by_time), kilnBins, kilns, arrivals],\n // The board's unsaved bins are laid over them, and over their index\n drafts: [kilnBins],\n args: [Allocation.Types.FitRequest()],\n output: Allocation.Types.FitResult(),\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n // The day's bins, every one: a kiln's load is every bin's part on it. The index carries no row: it gives each\n // bin's key, and the record its row, both at the one drafted state.\n const roles = $.const(yardBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(yardAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n const days = $.let(Record.bind(yardDays));\n // Every bay and kiln is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationSplit\", {\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] } } },\n kilns: { source: kilnIndex, fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] } } },\n }, {\n presets: [\n { id: \"halls\", name: \"Halls\", where: { kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n { id: \"small\", name: \"Compact and standard\", where: { kilns: { group: [\"Compact\", \"Standard\"] } } },\n { id: \"large\", name: \"Large and bulk\", where: { kilns: { group: [\"Large\", \"Bulk\"] } } },\n { id: \"north\", name: \"North bays, halls\", where: { bays: { area: [\"North\"] }, kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n ],\n }));\n const fit = $.let(Func.bind(yardFit));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationSplit\" title=\"Kiln loading\" fit={fit} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"timeline\", date: yardSplitDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(days, { every: \"day\", status: { field: \"state\", draft: \"draft\", published: \"issued\" } })}\n columns={[\n { key: \"spec\", label: \"Spec\", text: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => b.specMeasured, () => East.str`booked ${b.specBooked} · measured ${b.specMeasured}`),\n tone: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => none, () => some(variant(\"warning\", null))) },\n { key: \"grade\", label: \"Grade\", text: b => b.gradeMeasured.startsWith(b.gradeBooked).ifElse(() => b.gradeMeasured, () => East.str`booked ${b.gradeBooked} · measured ${b.gradeMeasured}`), table: false },\n ]} />\n </Box>;\n }}</Reactive>)"
40680
40680
  },
40681
40681
  {
40682
40682
  "id": "e3-ui:allocation.examples.tsx:allocationWindowed",
@@ -40709,7 +40709,7 @@
40709
40709
  "languages": [
40710
40710
  "tsx"
40711
40711
  ],
40712
- "source": "// Two years of bins read a day at a time through the slice's bin source — an interval index over their times, its range the board's own navigation — and the plan's days by key: only the active day and the open picker's month are requested, never a record whole.\n// inputs: []\n/** Two years of the yard's bins, for the board read a day at a time through its slice. */\nexport const kilnBinHistory = e3.record(\"kiln_bin_history\", DictType(StringType, KilnBin), {\n initial: yardBinHistoryRows,\n indexes: (index) => ({\n kiln_bin_history_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The days of those two years, read by key. */\nexport const yardDayHistory = e3.record(\"yard_day_history\", DictType(DateTimeType, YardDay), {\n initial: yardDayHistoryRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the board's bin kind reads them. */\nexport const yardBinRoles = East.function([KilnBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: b.spec,\n}));\n\n/** A kiln, as the board's kilns read it. */\nexport const yardKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: some(k.group), meta: none, note: k.note, min: k.min, max: k.max, hold: variant(\"days\", k.days), jobs: k.charges,\n}));\n\n/** A load, as the board's arrivals read it. */\nexport const yardLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: some(l.spec),\n due: some(l.due), window: some({ from: l.from, to: l.to }), details: [],\n}));\n\n/**\n * What a yard's fit read (#1624): a day's bins as their roles, and every kiln and every load — every kiln is a\n * candidate, and a look-ahead places every load, so both are read whole, as the board reads them.\n */\nexport const yardRead = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad)], Allocation.Types.FitContext, ($, day, kilnRows, loadRows) => {\n const kiln = $.const(yardKilnOf);\n const load = $.const(yardLoadOf);\n return { bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\" };\n});\n\n/**\n * The yard's verdicts over a day's bins as their roles (#1624): the built-in rules, then a greedy look-ahead over the\n * day's other loads — a fit that leaves more of the day's unbooked loads with nowhere to go ranks lower. What each of\n * the yard's fits answers, once it has read its own bins.\n */\nexport const yardAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest], Allocation.Types.FitResult,\n ($, day, kilnRows, loadRows, request) => {\n const read = $.const(yardRead);\n const context = $.const(read(day, kilnRows, loadRows));\n const answer = $.const(Allocation.answer);\n const rule = $.const(Allocation.fit);\n const ahead = $.const(Allocation.lookahead);\n return answer(request, context, East.function([Allocation.Types.Candidate], Allocation.Types.Fit, (_$2, c) => ahead(context, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n });\n\n/** The yard's fit over the two years of bins: the same rules, its day read through that record's own index. */\nexport const yardHistoryFit = e3.function(\"yard_history_fit\", {\n inputs: [e3.index(kilnBinHistory.indexes.kiln_bin_history_by_time), kilnBinHistory, kilns, arrivals],\n drafts: [kilnBinHistory],\n args: [Allocation.Types.FitRequest],\n output: Allocation.Types.FitResult,\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n const roles = $.const(yardBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(yardAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnBinHistory));\n const entries = $.let(Data.bindPaged(kilnBinHistory));\n const byTime = $.let(Data.bindPaged(kilnBinHistory, { indexes: [\"kiln_bin_history_by_time\"] }));\n // The days of the plan read by key: the day, and the open picker's month.\n const days = $.let(Record.bind(yardDayHistory));\n const dayEntries = $.let(Data.bindPaged(yardDayHistory));\n // Every bay and kiln is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationWindowed\", {\n // The day's bins: the board's navigation writes the range.\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] } } },\n kilns: { source: kilnIndex, fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] } } },\n }, {\n presets: [\n { id: \"halls\", name: \"Halls\", where: { kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n { id: \"small\", name: \"Compact and standard\", where: { kilns: { group: [\"Compact\", \"Standard\"] } } },\n { id: \"large\", name: \"Large and bulk\", where: { kilns: { group: [\"Large\", \"Bulk\"] } } },\n { id: \"north\", name: \"North bays, halls\", where: { bays: { area: [\"North\"] }, kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n ],\n }));\n const fit = $.let(Func.bind(yardHistoryFit));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationWindowed\" title=\"Kiln loading\" fit={fit} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"timeline\", date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(days, { every: \"day\", status: { field: \"state\", draft: \"draft\", published: \"issued\" }, entries: dayEntries })}\n columns={[\n { key: \"spec\", label: \"Spec\", text: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => b.specMeasured, () => East.str`booked ${b.specBooked} · measured ${b.specMeasured}`),\n tone: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => none, () => some(variant(\"warning\", null))) },\n { key: \"grade\", label: \"Grade\", text: b => b.gradeMeasured.startsWith(b.gradeBooked).ifElse(() => b.gradeMeasured, () => East.str`booked ${b.gradeBooked} · measured ${b.gradeMeasured}`), table: false },\n ]} />\n </Box>;\n }}</Reactive>)"
40712
+ "source": "// Two years of bins read a day at a time through the slice's bin source — an interval index over their times, its range the board's own navigation — and the plan's days by key: only the active day and the open picker's month are requested, never a record whole.\n// inputs: []\n/** Two years of the yard's bins, for the board read a day at a time through its slice. */\nexport const kilnBinHistory = e3.record(\"kiln_bin_history\", DictType(StringType, KilnBin), {\n initial: yardBinHistoryRows,\n indexes: (index) => ({\n kiln_bin_history_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The days of those two years, read by key. */\nexport const yardDayHistory = e3.record(\"yard_day_history\", DictType(DateTimeType, YardDay), {\n initial: yardDayHistoryRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the board's bin kind reads them. */\nexport const yardBinRoles = East.function([KilnBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: b.spec,\n}));\n\n/** A kiln, as the board's kilns read it. */\nexport const yardKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: some(k.group), meta: none, note: k.note, min: k.min, max: k.max, hold: variant(\"days\", k.days), jobs: k.charges,\n}));\n\n/** A load, as the board's arrivals read it. */\nexport const yardLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: some(l.spec),\n due: some(l.due), window: some({ from: l.from, to: l.to }), details: [],\n}));\n\n/**\n * What a yard's fit read (#1624): a day's bins as their roles, and every kiln and every load — every kiln is a\n * candidate, and a look-ahead places every load, so both are read whole, as the board reads them.\n */\nexport const yardRead = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad)], Allocation.Types.FitContext(), ($, day, kilnRows, loadRows) => {\n const kiln = $.const(yardKilnOf);\n const load = $.const(yardLoadOf);\n return { bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\" };\n});\n\n/**\n * The yard's verdicts over a day's bins as their roles (#1624): the built-in rules, then a greedy look-ahead over the\n * day's other loads — a fit that leaves more of the day's unbooked loads with nowhere to go ranks lower. What each of\n * the yard's fits answers, once it has read its own bins.\n */\nexport const yardAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest()], Allocation.Types.FitResult(),\n ($, day, kilnRows, loadRows, request) => {\n const read = $.const(yardRead);\n const context = $.const(read(day, kilnRows, loadRows));\n const answer = $.const(Allocation.answer());\n const rule = $.const(Allocation.fit());\n const ahead = $.const(Allocation.lookahead());\n return answer(request, context, East.function([Allocation.Types.Candidate()], Allocation.Types.Fit, (_$2, c) => ahead(context, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n });\n\n/** The yard's fit over the two years of bins: the same rules, its day read through that record's own index. */\nexport const yardHistoryFit = e3.function(\"yard_history_fit\", {\n inputs: [e3.index(kilnBinHistory.indexes.kiln_bin_history_by_time), kilnBinHistory, kilns, arrivals],\n drafts: [kilnBinHistory],\n args: [Allocation.Types.FitRequest()],\n output: Allocation.Types.FitResult(),\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n const roles = $.const(yardBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(yardAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnBinHistory));\n const entries = $.let(Data.bindPaged(kilnBinHistory));\n const byTime = $.let(Data.bindPaged(kilnBinHistory, { indexes: [\"kiln_bin_history_by_time\"] }));\n // The days of the plan read by key: the day, and the open picker's month.\n const days = $.let(Record.bind(yardDayHistory));\n const dayEntries = $.let(Data.bindPaged(yardDayHistory));\n // Every bay and kiln is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationWindowed\", {\n // The day's bins: the board's navigation writes the range.\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] } } },\n kilns: { source: kilnIndex, fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] } } },\n }, {\n presets: [\n { id: \"halls\", name: \"Halls\", where: { kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n { id: \"small\", name: \"Compact and standard\", where: { kilns: { group: [\"Compact\", \"Standard\"] } } },\n { id: \"large\", name: \"Large and bulk\", where: { kilns: { group: [\"Large\", \"Bulk\"] } } },\n { id: \"north\", name: \"North bays, halls\", where: { bays: { area: [\"North\"] }, kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n ],\n }));\n const fit = $.let(Func.bind(yardHistoryFit));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationWindowed\" title=\"Kiln loading\" fit={fit} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"timeline\", date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(days, { every: \"day\", status: { field: \"state\", draft: \"draft\", published: \"issued\" }, entries: dayEntries })}\n columns={[\n { key: \"spec\", label: \"Spec\", text: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => b.specMeasured, () => East.str`booked ${b.specBooked} · measured ${b.specMeasured}`),\n tone: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => none, () => some(variant(\"warning\", null))) },\n { key: \"grade\", label: \"Grade\", text: b => b.gradeMeasured.startsWith(b.gradeBooked).ifElse(() => b.gradeMeasured, () => East.str`booked ${b.gradeBooked} · measured ${b.gradeMeasured}`), table: false },\n ]} />\n </Box>;\n }}</Reactive>)"
40713
40713
  },
40714
40714
  {
40715
40715
  "id": "e3-ui:allocation.examples.tsx:allocationMobile",
@@ -40736,7 +40736,7 @@
40736
40736
  "languages": [
40737
40737
  "tsx"
40738
40738
  ],
40739
- "source": "// The kiln yard in a 390px container: a card per kiln (or per slot in the Table) with Book, Reserve, Allocate, Unlink and Back to Arrivals in the bottom panel over the pane strip; no drag source or target.\n// inputs: []\n/** The bins, every day's, each the yard's own row. */\nexport const kilnBins = e3.record(\"kiln_bins\", DictType(StringType, KilnBin), {\n initial: yardBinRows,\n indexes: (index) => ({\n // The bins by their time: what the board's slice reads a day of them through, its navigation writing the range.\n kiln_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The days of the yard's plan, what the board publishes: Tue 4 May issued, Tue 11 and Wed 12 drafts. */\nexport const yardDays = e3.record(\"yard_days\", DictType(DateTimeType, YardDay), {\n initial: yardDayRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the board's bin kind reads them. */\nexport const yardBinRoles = East.function([KilnBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: b.spec,\n}));\n\n/** A kiln, as the board's kilns read it. */\nexport const yardKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: some(k.group), meta: none, note: k.note, min: k.min, max: k.max, hold: variant(\"days\", k.days), jobs: k.charges,\n}));\n\n/** A load, as the board's arrivals read it. */\nexport const yardLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: some(l.spec),\n due: some(l.due), window: some({ from: l.from, to: l.to }), details: [],\n}));\n\n/**\n * What a yard's fit read (#1624): a day's bins as their roles, and every kiln and every load — every kiln is a\n * candidate, and a look-ahead places every load, so both are read whole, as the board reads them.\n */\nexport const yardRead = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad)], Allocation.Types.FitContext, ($, day, kilnRows, loadRows) => {\n const kiln = $.const(yardKilnOf);\n const load = $.const(yardLoadOf);\n return { bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\" };\n});\n\n/**\n * The yard's verdicts over a day's bins as their roles (#1624): the built-in rules, then a greedy look-ahead over the\n * day's other loads — a fit that leaves more of the day's unbooked loads with nowhere to go ranks lower. What each of\n * the yard's fits answers, once it has read its own bins.\n */\nexport const yardAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest], Allocation.Types.FitResult,\n ($, day, kilnRows, loadRows, request) => {\n const read = $.const(yardRead);\n const context = $.const(read(day, kilnRows, loadRows));\n const answer = $.const(Allocation.answer);\n const rule = $.const(Allocation.fit);\n const ahead = $.const(Allocation.lookahead);\n return answer(request, context, East.function([Allocation.Types.Candidate], Allocation.Types.Fit, (_$2, c) => ahead(context, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n });\n\n/**\n * The yard's fit, on e3 (#1624): the yard's verdicts ({@link yardAnswer}) over the day's bins. It is asked the day and\n * the question, and sent no row: it reads the day's bins through their interval index, the board's unsaved bins among\n * them.\n */\nexport const yardFit = e3.function(\"yard_fit\", {\n inputs: [e3.index(kilnBins.indexes.kiln_bins_by_time), kilnBins, kilns, arrivals],\n // The board's unsaved bins are laid over them, and over their index\n drafts: [kilnBins],\n args: [Allocation.Types.FitRequest],\n output: Allocation.Types.FitResult,\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n // The day's bins, every one: a kiln's load is every bin's part on it. The index carries no row: it gives each\n // bin's key, and the record its row, both at the one drafted state.\n const roles = $.const(yardBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(yardAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n const days = $.let(Record.bind(yardDays));\n // Every bay and kiln is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationMobile\", {\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] } } },\n kilns: { source: kilnIndex, fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] } } },\n }, {\n presets: [\n { id: \"halls\", name: \"Halls\", where: { kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n { id: \"small\", name: \"Compact and standard\", where: { kilns: { group: [\"Compact\", \"Standard\"] } } },\n { id: \"large\", name: \"Large and bulk\", where: { kilns: { group: [\"Large\", \"Bulk\"] } } },\n { id: \"north\", name: \"North bays, halls\", where: { bays: { area: [\"North\"] }, kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n ],\n }));\n const fit = $.let(Func.bind(yardFit));\n return <Box width=\"100%\" maxWidth=\"390px\" height=\"760px\"><Allocation id=\"allocationMobile\" title=\"Kiln loading\" fit={fit} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"timeline\", date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(days, { every: \"day\", status: { field: \"state\", draft: \"draft\", published: \"issued\" } })}\n columns={[\n { key: \"spec\", label: \"Spec\", text: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => b.specMeasured, () => East.str`booked ${b.specBooked} · measured ${b.specMeasured}`),\n tone: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => none, () => some(variant(\"warning\", null))) },\n { key: \"grade\", label: \"Grade\", text: b => b.gradeMeasured.startsWith(b.gradeBooked).ifElse(() => b.gradeMeasured, () => East.str`booked ${b.gradeBooked} · measured ${b.gradeMeasured}`), table: false },\n ]} />\n </Box>;\n }}</Reactive>)"
40739
+ "source": "// The kiln yard in a 390px container: a card per kiln (or per slot in the Table) with Book, Reserve, Allocate, Unlink and Back to Arrivals in the bottom panel over the pane strip; no drag source or target.\n// inputs: []\n/** The bins, every day's, each the yard's own row. */\nexport const kilnBins = e3.record(\"kiln_bins\", DictType(StringType, KilnBin), {\n initial: yardBinRows,\n indexes: (index) => ({\n // The bins by their time: what the board's slice reads a day of them through, its navigation writing the range.\n kiln_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The days of the yard's plan, what the board publishes: Tue 4 May issued, Tue 11 and Wed 12 drafts. */\nexport const yardDays = e3.record(\"yard_days\", DictType(DateTimeType, YardDay), {\n initial: yardDayRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the board's bin kind reads them. */\nexport const yardBinRoles = East.function([KilnBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: b.spec,\n}));\n\n/** A kiln, as the board's kilns read it. */\nexport const yardKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: some(k.group), meta: none, note: k.note, min: k.min, max: k.max, hold: variant(\"days\", k.days), jobs: k.charges,\n}));\n\n/** A load, as the board's arrivals read it. */\nexport const yardLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: some(l.spec),\n due: some(l.due), window: some({ from: l.from, to: l.to }), details: [],\n}));\n\n/**\n * What a yard's fit read (#1624): a day's bins as their roles, and every kiln and every load — every kiln is a\n * candidate, and a look-ahead places every load, so both are read whole, as the board reads them.\n */\nexport const yardRead = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad)], Allocation.Types.FitContext(), ($, day, kilnRows, loadRows) => {\n const kiln = $.const(yardKilnOf);\n const load = $.const(yardLoadOf);\n return { bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\" };\n});\n\n/**\n * The yard's verdicts over a day's bins as their roles (#1624): the built-in rules, then a greedy look-ahead over the\n * day's other loads — a fit that leaves more of the day's unbooked loads with nowhere to go ranks lower. What each of\n * the yard's fits answers, once it has read its own bins.\n */\nexport const yardAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest()], Allocation.Types.FitResult(),\n ($, day, kilnRows, loadRows, request) => {\n const read = $.const(yardRead);\n const context = $.const(read(day, kilnRows, loadRows));\n const answer = $.const(Allocation.answer());\n const rule = $.const(Allocation.fit());\n const ahead = $.const(Allocation.lookahead());\n return answer(request, context, East.function([Allocation.Types.Candidate()], Allocation.Types.Fit, (_$2, c) => ahead(context, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n });\n\n/**\n * The yard's fit, on e3 (#1624): the yard's verdicts ({@link yardAnswer}) over the day's bins. It is asked the day and\n * the question, and sent no row: it reads the day's bins through their interval index, the board's unsaved bins among\n * them.\n */\nexport const yardFit = e3.function(\"yard_fit\", {\n inputs: [e3.index(kilnBins.indexes.kiln_bins_by_time), kilnBins, kilns, arrivals],\n // The board's unsaved bins are laid over them, and over their index\n drafts: [kilnBins],\n args: [Allocation.Types.FitRequest()],\n output: Allocation.Types.FitResult(),\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n // The day's bins, every one: a kiln's load is every bin's part on it. The index carries no row: it gives each\n // bin's key, and the record its row, both at the one drafted state.\n const roles = $.const(yardBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(yardAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n const days = $.let(Record.bind(yardDays));\n // Every bay and kiln is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationMobile\", {\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] } } },\n kilns: { source: kilnIndex, fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] } } },\n }, {\n presets: [\n { id: \"halls\", name: \"Halls\", where: { kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n { id: \"small\", name: \"Compact and standard\", where: { kilns: { group: [\"Compact\", \"Standard\"] } } },\n { id: \"large\", name: \"Large and bulk\", where: { kilns: { group: [\"Large\", \"Bulk\"] } } },\n { id: \"north\", name: \"North bays, halls\", where: { bays: { area: [\"North\"] }, kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n ],\n }));\n const fit = $.let(Func.bind(yardFit));\n return <Box width=\"100%\" maxWidth=\"390px\" height=\"760px\"><Allocation id=\"allocationMobile\" title=\"Kiln loading\" fit={fit} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"timeline\", date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(days, { every: \"day\", status: { field: \"state\", draft: \"draft\", published: \"issued\" } })}\n columns={[\n { key: \"spec\", label: \"Spec\", text: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => b.specMeasured, () => East.str`booked ${b.specBooked} · measured ${b.specMeasured}`),\n tone: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => none, () => some(variant(\"warning\", null))) },\n { key: \"grade\", label: \"Grade\", text: b => b.gradeMeasured.startsWith(b.gradeBooked).ifElse(() => b.gradeMeasured, () => East.str`booked ${b.gradeBooked} · measured ${b.gradeMeasured}`), table: false },\n ]} />\n </Box>;\n }}</Reactive>)"
40740
40740
  },
40741
40741
  {
40742
40742
  "id": "e3-ui:allocation.examples.tsx:allocationCustomBin",
@@ -40763,7 +40763,7 @@
40763
40763
  "languages": [
40764
40764
  "tsx"
40765
40765
  ],
40766
- "source": "// The bin kind's own inspector: the yard's typed bin form — its m³ and its loading instruction, each change the bin written back whole — in place of the built-in quantity field and the row's other fields.\n// inputs: []\n/** The bins, every day's, each the yard's own row. */\nexport const kilnBins = e3.record(\"kiln_bins\", DictType(StringType, KilnBin), {\n initial: yardBinRows,\n indexes: (index) => ({\n // The bins by their time: what the board's slice reads a day of them through, its navigation writing the range.\n kiln_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The days of the yard's plan, what the board publishes: Tue 4 May issued, Tue 11 and Wed 12 drafts. */\nexport const yardDays = e3.record(\"yard_days\", DictType(DateTimeType, YardDay), {\n initial: yardDayRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the board's bin kind reads them. */\nexport const yardBinRoles = East.function([KilnBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: b.spec,\n}));\n\n/** A kiln, as the board's kilns read it. */\nexport const yardKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: some(k.group), meta: none, note: k.note, min: k.min, max: k.max, hold: variant(\"days\", k.days), jobs: k.charges,\n}));\n\n/** A load, as the board's arrivals read it. */\nexport const yardLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: some(l.spec),\n due: some(l.due), window: some({ from: l.from, to: l.to }), details: [],\n}));\n\n/**\n * What a yard's fit read (#1624): a day's bins as their roles, and every kiln and every load — every kiln is a\n * candidate, and a look-ahead places every load, so both are read whole, as the board reads them.\n */\nexport const yardRead = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad)], Allocation.Types.FitContext, ($, day, kilnRows, loadRows) => {\n const kiln = $.const(yardKilnOf);\n const load = $.const(yardLoadOf);\n return { bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\" };\n});\n\n/**\n * The yard's verdicts over a day's bins as their roles (#1624): the built-in rules, then a greedy look-ahead over the\n * day's other loads — a fit that leaves more of the day's unbooked loads with nowhere to go ranks lower. What each of\n * the yard's fits answers, once it has read its own bins.\n */\nexport const yardAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest], Allocation.Types.FitResult,\n ($, day, kilnRows, loadRows, request) => {\n const read = $.const(yardRead);\n const context = $.const(read(day, kilnRows, loadRows));\n const answer = $.const(Allocation.answer);\n const rule = $.const(Allocation.fit);\n const ahead = $.const(Allocation.lookahead);\n return answer(request, context, East.function([Allocation.Types.Candidate], Allocation.Types.Fit, (_$2, c) => ahead(context, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n });\n\n/**\n * The yard's fit, on e3 (#1624): the yard's verdicts ({@link yardAnswer}) over the day's bins. It is asked the day and\n * the question, and sent no row: it reads the day's bins through their interval index, the board's unsaved bins among\n * them.\n */\nexport const yardFit = e3.function(\"yard_fit\", {\n inputs: [e3.index(kilnBins.indexes.kiln_bins_by_time), kilnBins, kilns, arrivals],\n // The board's unsaved bins are laid over them, and over their index\n drafts: [kilnBins],\n args: [Allocation.Types.FitRequest],\n output: Allocation.Types.FitResult,\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n // The day's bins, every one: a kiln's load is every bin's part on it. The index carries no row: it gives each\n // bin's key, and the record its row, both at the one drafted state.\n const roles = $.const(yardBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(yardAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n const days = $.let(Record.bind(yardDays));\n // Every bay and kiln is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationCustomBin\", {\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] } } },\n kilns: { source: kilnIndex, fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] } } },\n }, {\n presets: [\n { id: \"halls\", name: \"Halls\", where: { kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n { id: \"small\", name: \"Compact and standard\", where: { kilns: { group: [\"Compact\", \"Standard\"] } } },\n { id: \"large\", name: \"Large and bulk\", where: { kilns: { group: [\"Large\", \"Bulk\"] } } },\n { id: \"north\", name: \"North bays, halls\", where: { bays: { area: [\"North\"] }, kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n ],\n }));\n const fit = $.let(Func.bind(yardFit));\n // The bin's own form: its m³ and its loading instruction, each change the bin written back whole.\n const binForm = $.const(East.function([KilnBin, FunctionType([KilnBin], NullType)], UIComponentType, (_$2, row, update) =>\n <VStack>\n <Field.FloatInput label=\"Quantity\" value={row.m3} min={0} step={1} onChange={(_$3, m3) => update({ bay: row.bay, at: row.at, load: row.load,\n m3, spec: row.spec, dryFor: row.dryFor, kilns: row.kilns, specBooked: row.specBooked, specMeasured: row.specMeasured,\n gradeBooked: row.gradeBooked, gradeMeasured: row.gradeMeasured, instruction: row.instruction })} />\n <Field.StringInput label=\"Loading instruction\" value={row.instruction.unwrap(\"some\", () => \"\")} onChange={(_$3, text) => update({ bay: row.bay,\n at: row.at, load: row.load, m3: row.m3, spec: row.spec, dryFor: row.dryFor, kilns: row.kilns, specBooked: row.specBooked,\n specMeasured: row.specMeasured, gradeBooked: row.gradeBooked, gradeMeasured: row.gradeMeasured,\n instruction: East.equal(text, \"\").ifElse(() => none, () => some(text)) })} />\n </VStack>));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationCustomBin\" title=\"Kiln loading\" fit={fit} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"timeline\", date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n inspector: binForm,\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(days, { every: \"day\", status: { field: \"state\", draft: \"draft\", published: \"issued\" } })}\n columns={[\n { key: \"spec\", label: \"Spec\", text: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => b.specMeasured, () => East.str`booked ${b.specBooked} · measured ${b.specMeasured}`),\n tone: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => none, () => some(variant(\"warning\", null))) },\n { key: \"grade\", label: \"Grade\", text: b => b.gradeMeasured.startsWith(b.gradeBooked).ifElse(() => b.gradeMeasured, () => East.str`booked ${b.gradeBooked} · measured ${b.gradeMeasured}`), table: false },\n ]} />\n </Box>;\n }}</Reactive>)"
40766
+ "source": "// The bin kind's own inspector: the yard's typed bin form — its m³ and its loading instruction, each change the bin written back whole — in place of the built-in quantity field and the row's other fields.\n// inputs: []\n/** The bins, every day's, each the yard's own row. */\nexport const kilnBins = e3.record(\"kiln_bins\", DictType(StringType, KilnBin), {\n initial: yardBinRows,\n indexes: (index) => ({\n // The bins by their time: what the board's slice reads a day of them through, its navigation writing the range.\n kiln_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The days of the yard's plan, what the board publishes: Tue 4 May issued, Tue 11 and Wed 12 drafts. */\nexport const yardDays = e3.record(\"yard_days\", DictType(DateTimeType, YardDay), {\n initial: yardDayRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the board's bin kind reads them. */\nexport const yardBinRoles = East.function([KilnBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: b.spec,\n}));\n\n/** A kiln, as the board's kilns read it. */\nexport const yardKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: some(k.group), meta: none, note: k.note, min: k.min, max: k.max, hold: variant(\"days\", k.days), jobs: k.charges,\n}));\n\n/** A load, as the board's arrivals read it. */\nexport const yardLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: some(l.spec),\n due: some(l.due), window: some({ from: l.from, to: l.to }), details: [],\n}));\n\n/**\n * What a yard's fit read (#1624): a day's bins as their roles, and every kiln and every load — every kiln is a\n * candidate, and a look-ahead places every load, so both are read whole, as the board reads them.\n */\nexport const yardRead = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad)], Allocation.Types.FitContext(), ($, day, kilnRows, loadRows) => {\n const kiln = $.const(yardKilnOf);\n const load = $.const(yardLoadOf);\n return { bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\" };\n});\n\n/**\n * The yard's verdicts over a day's bins as their roles (#1624): the built-in rules, then a greedy look-ahead over the\n * day's other loads — a fit that leaves more of the day's unbooked loads with nowhere to go ranks lower. What each of\n * the yard's fits answers, once it has read its own bins.\n */\nexport const yardAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest()], Allocation.Types.FitResult(),\n ($, day, kilnRows, loadRows, request) => {\n const read = $.const(yardRead);\n const context = $.const(read(day, kilnRows, loadRows));\n const answer = $.const(Allocation.answer());\n const rule = $.const(Allocation.fit());\n const ahead = $.const(Allocation.lookahead());\n return answer(request, context, East.function([Allocation.Types.Candidate()], Allocation.Types.Fit, (_$2, c) => ahead(context, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n });\n\n/**\n * The yard's fit, on e3 (#1624): the yard's verdicts ({@link yardAnswer}) over the day's bins. It is asked the day and\n * the question, and sent no row: it reads the day's bins through their interval index, the board's unsaved bins among\n * them.\n */\nexport const yardFit = e3.function(\"yard_fit\", {\n inputs: [e3.index(kilnBins.indexes.kiln_bins_by_time), kilnBins, kilns, arrivals],\n // The board's unsaved bins are laid over them, and over their index\n drafts: [kilnBins],\n args: [Allocation.Types.FitRequest()],\n output: Allocation.Types.FitResult(),\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n // The day's bins, every one: a kiln's load is every bin's part on it. The index carries no row: it gives each\n // bin's key, and the record its row, both at the one drafted state.\n const roles = $.const(yardBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(yardAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n const days = $.let(Record.bind(yardDays));\n // Every bay and kiln is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationCustomBin\", {\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] } } },\n kilns: { source: kilnIndex, fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] } } },\n }, {\n presets: [\n { id: \"halls\", name: \"Halls\", where: { kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n { id: \"small\", name: \"Compact and standard\", where: { kilns: { group: [\"Compact\", \"Standard\"] } } },\n { id: \"large\", name: \"Large and bulk\", where: { kilns: { group: [\"Large\", \"Bulk\"] } } },\n { id: \"north\", name: \"North bays, halls\", where: { bays: { area: [\"North\"] }, kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n ],\n }));\n const fit = $.let(Func.bind(yardFit));\n // The bin's own form: its m³ and its loading instruction, each change the bin written back whole.\n const binForm = $.const(East.function([KilnBin, FunctionType([KilnBin], NullType)], UIComponentType, (_$2, row, update) =>\n <VStack>\n <Field.FloatInput label=\"Quantity\" value={row.m3} min={0} step={1} onChange={(_$3, m3) => update({ bay: row.bay, at: row.at, load: row.load,\n m3, spec: row.spec, dryFor: row.dryFor, kilns: row.kilns, specBooked: row.specBooked, specMeasured: row.specMeasured,\n gradeBooked: row.gradeBooked, gradeMeasured: row.gradeMeasured, instruction: row.instruction })} />\n <Field.StringInput label=\"Loading instruction\" value={row.instruction.unwrap(\"some\", () => \"\")} onChange={(_$3, text) => update({ bay: row.bay,\n at: row.at, load: row.load, m3: row.m3, spec: row.spec, dryFor: row.dryFor, kilns: row.kilns, specBooked: row.specBooked,\n specMeasured: row.specMeasured, gradeBooked: row.gradeBooked, gradeMeasured: row.gradeMeasured,\n instruction: East.equal(text, \"\").ifElse(() => none, () => some(text)) })} />\n </VStack>));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationCustomBin\" title=\"Kiln loading\" fit={fit} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"timeline\", date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n inspector: binForm,\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(days, { every: \"day\", status: { field: \"state\", draft: \"draft\", published: \"issued\" } })}\n columns={[\n { key: \"spec\", label: \"Spec\", text: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => b.specMeasured, () => East.str`booked ${b.specBooked} · measured ${b.specMeasured}`),\n tone: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => none, () => some(variant(\"warning\", null))) },\n { key: \"grade\", label: \"Grade\", text: b => b.gradeMeasured.startsWith(b.gradeBooked).ifElse(() => b.gradeMeasured, () => East.str`booked ${b.gradeBooked} · measured ${b.gradeMeasured}`), table: false },\n ]} />\n </Box>;\n }}</Reactive>)"
40767
40767
  },
40768
40768
  {
40769
40769
  "id": "e3-ui:allocation.examples.tsx:allocationFitRule",
@@ -40771,7 +40771,7 @@
40771
40771
  "package": "e3-ui",
40772
40772
  "file": "east-ui/packages/e3-ui/test/allocation/allocation.examples.tsx",
40773
40773
  "suite": "",
40774
- "test": "The ready-made fit with one yard rule over it, as an e3.function (#1624): a bulk kiln takes no load under 20 m³, so LD-2235 (8 m³) fits K-305 alone. The function is asked the day and the question — Allocation.Types.FitRequest, no row — and reads the day's bins through their interval index, the board's unsaved bins laid over them (drafts: [kilnBins]), and the kilns and the loads from the yard's own records, making of them an Allocation.Types.FitContext for Allocation.answer.",
40774
+ "test": "The ready-made fit with one yard rule over it, as an e3.function (#1624): a bulk kiln takes no load under 20 m³, so LD-2235 (8 m³) fits K-305 alone. The function is asked the day and the question — Allocation.Types.FitRequest(), no row — and reads the day's bins through their interval index, the board's unsaved bins laid over them (drafts: [kilnBins]), and the kilns and the loads from the yard's own records, making of them an Allocation.Types.FitContext() for Allocation.answer().",
40775
40775
  "keywords": [
40776
40776
  "Allocation",
40777
40777
  "fit",
@@ -40795,7 +40795,7 @@
40795
40795
  "languages": [
40796
40796
  "tsx"
40797
40797
  ],
40798
- "source": "// The ready-made fit with one yard rule over it, as an e3.function (#1624): a bulk kiln takes no load under 20 m³, so LD-2235 (8 m³) fits K-305 alone. The function is asked the day and the question — Allocation.Types.FitRequest, no row — and reads the day's bins through their interval index, the board's unsaved bins laid over them (drafts: [kilnBins]), and the kilns and the loads from the yard's own records, making of them an Allocation.Types.FitContext for Allocation.answer.\n// inputs: []\n/** The bins, every day's, each the yard's own row. */\nexport const kilnBins = e3.record(\"kiln_bins\", DictType(StringType, KilnBin), {\n initial: yardBinRows,\n indexes: (index) => ({\n // The bins by their time: what the board's slice reads a day of them through, its navigation writing the range.\n kiln_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The days of the yard's plan, what the board publishes: Tue 4 May issued, Tue 11 and Wed 12 drafts. */\nexport const yardDays = e3.record(\"yard_days\", DictType(DateTimeType, YardDay), {\n initial: yardDayRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the board's bin kind reads them. */\nexport const yardBinRoles = East.function([KilnBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: b.spec,\n}));\n\n/** A kiln, as the board's kilns read it. */\nexport const yardKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: some(k.group), meta: none, note: k.note, min: k.min, max: k.max, hold: variant(\"days\", k.days), jobs: k.charges,\n}));\n\n/** A load, as the board's arrivals read it. */\nexport const yardLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: some(l.spec),\n due: some(l.due), window: some({ from: l.from, to: l.to }), details: [],\n}));\n\n/**\n * What a yard's fit read (#1624): a day's bins as their roles, and every kiln and every load — every kiln is a\n * candidate, and a look-ahead places every load, so both are read whole, as the board reads them.\n */\nexport const yardRead = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad)], Allocation.Types.FitContext, ($, day, kilnRows, loadRows) => {\n const kiln = $.const(yardKilnOf);\n const load = $.const(yardLoadOf);\n return { bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\" };\n});\n\n/** A yard rule over the ready-made fit, on e3: a bulk kiln takes no load under 20 m³. */\nexport const bulkFit = e3.function(\"yard_bulk_fit\", {\n inputs: [e3.index(kilnBins.indexes.kiln_bins_by_time), kilnBins, kilns, arrivals],\n drafts: [kilnBins],\n args: [Allocation.Types.FitRequest],\n output: Allocation.Types.FitResult,\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n const roles = $.const(yardBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const read = $.const(yardRead);\n const context = $.const(read(day, kilnRows, loadRows));\n const answer = $.const(Allocation.answer);\n const rule = $.const(Allocation.fit);\n return answer(request, context, East.function([Allocation.Types.Candidate], Allocation.Types.Fit, ($2, c) => {\n $2.if(East.equal(c.resource.group, some(\"Bulk\")).and(() => c.reserve.not()).and(() => East.less(c.quantity, 20.0)), ($3) => {\n $3.return(variant(\"refused\", { group: \"Too small\", reason: East.str`bulk kilns take 20 m³ and more`, measure: variant(\"none\", null) }));\n });\n return rule(c);\n }), \"ranked by load, kind and spare days; bulk kilns take 20 m³ and more\");\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n const days = $.let(Record.bind(yardDays));\n // Every bay and kiln is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationFitRule\", {\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] } } },\n kilns: { source: kilnIndex, fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] } } },\n }, {\n presets: [\n { id: \"halls\", name: \"Halls\", where: { kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n { id: \"small\", name: \"Compact and standard\", where: { kilns: { group: [\"Compact\", \"Standard\"] } } },\n { id: \"large\", name: \"Large and bulk\", where: { kilns: { group: [\"Large\", \"Bulk\"] } } },\n { id: \"north\", name: \"North bays, halls\", where: { bays: { area: [\"North\"] }, kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n ],\n }));\n const fit = $.let(Func.bind(bulkFit));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationFitRule\" title=\"Kiln loading\" fit={fit} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"timeline\", date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(days, { every: \"day\", status: { field: \"state\", draft: \"draft\", published: \"issued\" } })}\n columns={[\n { key: \"spec\", label: \"Spec\", text: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => b.specMeasured, () => East.str`booked ${b.specBooked} · measured ${b.specMeasured}`),\n tone: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => none, () => some(variant(\"warning\", null))) },\n { key: \"grade\", label: \"Grade\", text: b => b.gradeMeasured.startsWith(b.gradeBooked).ifElse(() => b.gradeMeasured, () => East.str`booked ${b.gradeBooked} · measured ${b.gradeMeasured}`), table: false },\n ]} />\n </Box>;\n }}</Reactive>)"
40798
+ "source": "// The ready-made fit with one yard rule over it, as an e3.function (#1624): a bulk kiln takes no load under 20 m³, so LD-2235 (8 m³) fits K-305 alone. The function is asked the day and the question — Allocation.Types.FitRequest(), no row — and reads the day's bins through their interval index, the board's unsaved bins laid over them (drafts: [kilnBins]), and the kilns and the loads from the yard's own records, making of them an Allocation.Types.FitContext() for Allocation.answer().\n// inputs: []\n/** The bins, every day's, each the yard's own row. */\nexport const kilnBins = e3.record(\"kiln_bins\", DictType(StringType, KilnBin), {\n initial: yardBinRows,\n indexes: (index) => ({\n // The bins by their time: what the board's slice reads a day of them through, its navigation writing the range.\n kiln_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The days of the yard's plan, what the board publishes: Tue 4 May issued, Tue 11 and Wed 12 drafts. */\nexport const yardDays = e3.record(\"yard_days\", DictType(DateTimeType, YardDay), {\n initial: yardDayRows,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the board's bin kind reads them. */\nexport const yardBinRoles = East.function([KilnBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: b.spec,\n}));\n\n/** A kiln, as the board's kilns read it. */\nexport const yardKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: some(k.group), meta: none, note: k.note, min: k.min, max: k.max, hold: variant(\"days\", k.days), jobs: k.charges,\n}));\n\n/** A load, as the board's arrivals read it. */\nexport const yardLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: some(l.spec),\n due: some(l.due), window: some({ from: l.from, to: l.to }), details: [],\n}));\n\n/**\n * What a yard's fit read (#1624): a day's bins as their roles, and every kiln and every load — every kiln is a\n * candidate, and a look-ahead places every load, so both are read whole, as the board reads them.\n */\nexport const yardRead = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad)], Allocation.Types.FitContext(), ($, day, kilnRows, loadRows) => {\n const kiln = $.const(yardKilnOf);\n const load = $.const(yardLoadOf);\n return { bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\" };\n});\n\n/** A yard rule over the ready-made fit, on e3: a bulk kiln takes no load under 20 m³. */\nexport const bulkFit = e3.function(\"yard_bulk_fit\", {\n inputs: [e3.index(kilnBins.indexes.kiln_bins_by_time), kilnBins, kilns, arrivals],\n drafts: [kilnBins],\n args: [Allocation.Types.FitRequest()],\n output: Allocation.Types.FitResult(),\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n const roles = $.const(yardBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const read = $.const(yardRead);\n const context = $.const(read(day, kilnRows, loadRows));\n const answer = $.const(Allocation.answer());\n const rule = $.const(Allocation.fit());\n return answer(request, context, East.function([Allocation.Types.Candidate()], Allocation.Types.Fit, ($2, c) => {\n $2.if(East.equal(c.resource.group, some(\"Bulk\")).and(() => c.reserve.not()).and(() => East.less(c.quantity, 20.0)), ($3) => {\n $3.return(variant(\"refused\", { group: \"Too small\", reason: East.str`bulk kilns take 20 m³ and more`, measure: variant(\"none\", null) }));\n });\n return rule(c);\n }), \"ranked by load, kind and spare days; bulk kilns take 20 m³ and more\");\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n const days = $.let(Record.bind(yardDays));\n // Every bay and kiln is the calculation scope; the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationFitRule\", {\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] } } },\n kilns: { source: kilnIndex, fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] } } },\n }, {\n presets: [\n { id: \"halls\", name: \"Halls\", where: { kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n { id: \"small\", name: \"Compact and standard\", where: { kilns: { group: [\"Compact\", \"Standard\"] } } },\n { id: \"large\", name: \"Large and bulk\", where: { kilns: { group: [\"Large\", \"Bulk\"] } } },\n { id: \"north\", name: \"North bays, halls\", where: { bays: { area: [\"North\"] }, kilns: { group: [\"Hall A\", \"Hall B\"] } } },\n ],\n }));\n const fit = $.let(Func.bind(bulkFit));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationFitRule\" title=\"Kiln loading\" fit={fit} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"timeline\", date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(days, { every: \"day\", status: { field: \"state\", draft: \"draft\", published: \"issued\" } })}\n columns={[\n { key: \"spec\", label: \"Spec\", text: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => b.specMeasured, () => East.str`booked ${b.specBooked} · measured ${b.specMeasured}`),\n tone: b => East.equal(b.specBooked, b.specMeasured).ifElse(() => none, () => some(variant(\"warning\", null))) },\n { key: \"grade\", label: \"Grade\", text: b => b.gradeMeasured.startsWith(b.gradeBooked).ifElse(() => b.gradeMeasured, () => East.str`booked ${b.gradeBooked} · measured ${b.gradeMeasured}`), table: false },\n ]} />\n </Box>;\n }}</Reactive>)"
40799
40799
  },
40800
40800
  {
40801
40801
  "id": "e3-ui:allocation.examples.tsx:allocationConflicts",
@@ -40829,7 +40829,7 @@
40829
40829
  "languages": [
40830
40830
  "tsx"
40831
40831
  ],
40832
- "source": "// Your edits meeting someone else's save, in one window — move a bin or change its m³ in the panel, then press Someone else saves, which saves another person's change to the same bins (every bin a quarter hour later, 1 m³ more on each of its kilns), so yours conflict and wait to be chosen, an m³ and its split across kilns one card\n// inputs: []\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the smallest board's bin kind reads them. */\nexport const minimalBinRoles = East.function([MinimalBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: none,\n}));\n\n/** A kiln, as the smallest board's kilns read it. */\nexport const minimalKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: none, meta: none, note: none, min: k.min, max: k.max, hold: variant(\"days\", 0.0), jobs: k.charges,\n}));\n\n/** A load, as the smallest board's arrivals read it. */\nexport const minimalLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: none, due: none, window: none, details: [],\n}));\n\n/**\n * The smallest board's verdicts over a day's bins as their roles (#1624): the built-in rules, over every kiln and\n * every load as that board reads them — what each of its fits answers, once it has read its own bins.\n */\nexport const minimalAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest], Allocation.Types.FitResult,\n ($, day, kilnRows, loadRows, request) => {\n const kiln = $.const(minimalKilnOf);\n const load = $.const(minimalLoadOf);\n const context = $.const({\n bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\",\n }, Allocation.Types.FitContext);\n const answer = $.const(Allocation.answer);\n const rule = $.const(Allocation.fit);\n return answer(request, context, rule, \"ranked by load, kind and spare days\");\n });\n\n/** The bins the conflicts example edits, in a record of their own, so no other example's edits meet them. */\nexport const conflictBins = e3.record(\"kiln_conflict_bins\", DictType(StringType, MinimalBin), {\n initial: yardMinimalBinRows,\n indexes: (index) => ({\n kiln_conflict_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n // Someone else's save: every bin a quarter hour later, and 1 m³ more on each of its kilns, its m³ with them.\n elsewhere: mutation.reduce(East.function([DictType(StringType, MinimalBin)], DictType(StringType, MinimalBin), (_$, bins) =>\n bins.map((_$2, bin) => ({\n bay: bin.bay, at: bin.at.addMinutes(15n), load: bin.load,\n m3: bin.m3.add(bin.kilns.size().toFloat()),\n kilns: bin.kilns.map((_$3, share) => share.add(1.0)),\n dryFor: bin.dryFor,\n })))),\n }),\n});\n\n/** Their fit: the smallest board's rules over these bins, read through their own index. */\nexport const conflictFit = e3.function(\"yard_conflict_fit\", {\n inputs: [e3.index(conflictBins.indexes.kiln_conflict_bins_by_time), conflictBins, kilns, arrivals],\n drafts: [conflictBins],\n args: [Allocation.Types.FitRequest],\n output: Allocation.Types.FitResult,\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n const roles = $.const(minimalBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(minimalAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(conflictBins, [\"patch\"]));\n const others = $.let(Record.bind(conflictBins, [\"elsewhere\"]));\n const theirs = $.const(East.function([], NullType, ($) => { $(others.mutate.elsewhere()); }));\n const loads = $.let(Data.bind(arrivals));\n const yard = $.let(Data.bind(kilns));\n const bays = $.let(Data.bind(yardBays));\n const fit = $.let(Func.bind(conflictFit));\n return <VStack gap=\"3\" align=\"stretch\">\n <HStack gap=\"3\">\n <Button variant=\"outline\" onClick={theirs} loading={others.mutate.pending()}>Someone else saves</Button>\n <Text color=\"fg.muted\">Their change: every bin a quarter hour later, 1 m³ more on each of its kilns</Text>\n </HStack>\n <Box width=\"100%\" height=\"760px\"><Allocation id=\"allocationConflicts\" fit={fit} inspector view={{ date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\",\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\",\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, min: k => k.min, max: k => k.max, jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), { label: l => l.code, quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays) })} />\n </Box>\n </VStack>;\n }}</Reactive>)"
40832
+ "source": "// Your edits meeting someone else's save, in one window — move a bin or change its m³ in the panel, then press Someone else saves, which saves another person's change to the same bins (every bin a quarter hour later, 1 m³ more on each of its kilns), so yours conflict and wait to be chosen, an m³ and its split across kilns one card\n// inputs: []\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the smallest board's bin kind reads them. */\nexport const minimalBinRoles = East.function([MinimalBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: none,\n}));\n\n/** A kiln, as the smallest board's kilns read it. */\nexport const minimalKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: none, meta: none, note: none, min: k.min, max: k.max, hold: variant(\"days\", 0.0), jobs: k.charges,\n}));\n\n/** A load, as the smallest board's arrivals read it. */\nexport const minimalLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: none, due: none, window: none, details: [],\n}));\n\n/**\n * The smallest board's verdicts over a day's bins as their roles (#1624): the built-in rules, over every kiln and\n * every load as that board reads them — what each of its fits answers, once it has read its own bins.\n */\nexport const minimalAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest()], Allocation.Types.FitResult(),\n ($, day, kilnRows, loadRows, request) => {\n const kiln = $.const(minimalKilnOf);\n const load = $.const(minimalLoadOf);\n const context = $.const({\n bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\",\n }, Allocation.Types.FitContext());\n const answer = $.const(Allocation.answer());\n const rule = $.const(Allocation.fit());\n return answer(request, context, rule, \"ranked by load, kind and spare days\");\n });\n\n/** The bins the conflicts example edits, in a record of their own, so no other example's edits meet them. */\nexport const conflictBins = e3.record(\"kiln_conflict_bins\", DictType(StringType, MinimalBin), {\n initial: yardMinimalBinRows,\n indexes: (index) => ({\n kiln_conflict_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n // Someone else's save: every bin a quarter hour later, and 1 m³ more on each of its kilns, its m³ with them.\n elsewhere: mutation.reduce(East.function([DictType(StringType, MinimalBin)], DictType(StringType, MinimalBin), (_$, bins) =>\n bins.map((_$2, bin) => ({\n bay: bin.bay, at: bin.at.addMinutes(15n), load: bin.load,\n m3: bin.m3.add(bin.kilns.size().toFloat()),\n kilns: bin.kilns.map((_$3, share) => share.add(1.0)),\n dryFor: bin.dryFor,\n })))),\n }),\n});\n\n/** Their fit: the smallest board's rules over these bins, read through their own index. */\nexport const conflictFit = e3.function(\"yard_conflict_fit\", {\n inputs: [e3.index(conflictBins.indexes.kiln_conflict_bins_by_time), conflictBins, kilns, arrivals],\n drafts: [conflictBins],\n args: [Allocation.Types.FitRequest()],\n output: Allocation.Types.FitResult(),\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n const roles = $.const(minimalBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(minimalAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(conflictBins, [\"patch\"]));\n const others = $.let(Record.bind(conflictBins, [\"elsewhere\"]));\n const theirs = $.const(East.function([], NullType, ($) => { $(others.mutate.elsewhere()); }));\n const loads = $.let(Data.bind(arrivals));\n const yard = $.let(Data.bind(kilns));\n const bays = $.let(Data.bind(yardBays));\n const fit = $.let(Func.bind(conflictFit));\n return <VStack gap=\"3\" align=\"stretch\">\n <HStack gap=\"3\">\n <Button variant=\"outline\" onClick={theirs} loading={others.mutate.pending()}>Someone else saves</Button>\n <Text color=\"fg.muted\">Their change: every bin a quarter hour later, 1 m³ more on each of its kilns</Text>\n </HStack>\n <Box width=\"100%\" height=\"760px\"><Allocation id=\"allocationConflicts\" fit={fit} inspector view={{ date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\",\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\",\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, min: k => k.min, max: k => k.max, jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), { label: l => l.code, quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays) })} />\n </Box>\n </VStack>;\n }}</Reactive>)"
40833
40833
  },
40834
40834
  {
40835
40835
  "id": "e3-ui:allocation.examples.tsx:allocationDeliveries",
@@ -40863,7 +40863,7 @@
40863
40863
  "languages": [
40864
40864
  "tsx"
40865
40865
  ],
40866
- "source": "// A board over its mills' delivery schedule (#1551): a second record of the yard's, bound as the slice's `reference` source — a paged read through an interval index over each delivery's hour, `range: \"from\"` — which nothing draws and the rail offers no field of. The board writes its day into it as into the bins' source, and the check, from Allocation.Types.CheckContext(MinimalBin, Delivery), is given that day's deliveries by load as `reference`: it flags a bin booked off its load's bay or hour, a bin whose load the day's schedule delivers none of, and a delivery the day books no bin of. Step to Wed 12 May and LD-2214, moved there, is the delivery to book.\n// inputs: []\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the smallest board's bin kind reads them. */\nexport const minimalBinRoles = East.function([MinimalBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: none,\n}));\n\n/** A kiln, as the smallest board's kilns read it. */\nexport const minimalKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: none, meta: none, note: none, min: k.min, max: k.max, hold: variant(\"days\", 0.0), jobs: k.charges,\n}));\n\n/** A load, as the smallest board's arrivals read it. */\nexport const minimalLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: none, due: none, window: none, details: [],\n}));\n\n/**\n * The smallest board's verdicts over a day's bins as their roles (#1624): the built-in rules, over every kiln and\n * every load as that board reads them — what each of its fits answers, once it has read its own bins.\n */\nexport const minimalAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest], Allocation.Types.FitResult,\n ($, day, kilnRows, loadRows, request) => {\n const kiln = $.const(minimalKilnOf);\n const load = $.const(minimalLoadOf);\n const context = $.const({\n bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\",\n }, Allocation.Types.FitContext);\n const answer = $.const(Allocation.answer);\n const rule = $.const(Allocation.fit);\n return answer(request, context, rule, \"ranked by load, kind and spare days\");\n });\n\n/** The smallest board's bins again, read a day at a time through the slice, for the board over its mills' delivery schedule (#1551). */\nexport const kilnScheduledBins = e3.record(\"kiln_scheduled_bins\", DictType(StringType, MinimalBin), {\n initial: yardMinimalBinRows,\n indexes: (index) => ({\n kiln_scheduled_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** Their fit: the smallest board's rules over these bins, read through their own index. */\nexport const scheduledFit = e3.function(\"yard_scheduled_fit\", {\n inputs: [e3.index(kilnScheduledBins.indexes.kiln_scheduled_bins_by_time), kilnScheduledBins, kilns, arrivals],\n drafts: [kilnScheduledBins],\n args: [Allocation.Types.FitRequest],\n output: Allocation.Types.FitResult,\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n const roles = $.const(minimalBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(minimalAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\n/** The mills' delivery schedule (#1551): each load's bay and hour, by load, read through an interval index over the hour — what the board's check reads beside its bins. */\nexport const yardDeliveries = e3.record(\"yard_deliveries\", DictType(StringType, Delivery), {\n initial: yardDeliveryRows,\n indexes: (index) => ({\n yard_deliveries_by_time: index.interval({ from: \"from\", to: \"to\" }),\n }),\n mutations: (mutation) => ({\n // The schedule's patch door: the mills' change, as the renderer's tests on e3 commit it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnScheduledBins));\n const entries = $.let(Data.bindPaged(kilnScheduledBins));\n const byTime = $.let(Data.bindPaged(kilnScheduledBins, { indexes: [\"kiln_scheduled_bins_by_time\"] }));\n // The mills' schedule, read a day at a time through its interval index: the check's reference, never the record whole.\n const schedule = $.let(Data.bindPaged(yardDeliveries, { indexes: [\"yard_deliveries_by_time\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationDeliveries\", {\n bin: { source: byTime, range: \"at\" },\n reference: { source: schedule, range: \"from\" },\n }));\n const loads = $.let(Data.bind(arrivals));\n const yard = $.let(Data.bind(kilns));\n const bays = $.let(Data.bind(yardBays));\n const fit = $.let(Func.bind(scheduledFit));\n // The yard's check over its bins and the day's deliveries: each flagged, never refused.\n const check = $.const(East.function([Allocation.Types.CheckContext(MinimalBin, Delivery)], ArrayType(Allocation.Types.Issue), ($2, cx) => {\n const issues = $2.let([], ArrayType(Allocation.Types.Issue));\n const booked = $2.let(new Set([]), SetType(StringType));\n $2.for(cx.plan.bins, ($3, bin, id) => {\n $3.match(bin.arrival, { some: ($4, code) => {\n $4(booked.tryInsert(code));\n $4.if(cx.reference.has(code).not(), ($5) => {\n $5(issues.pushLast({ kind: variant(\"custom\", \"No delivery on the day\"), tone: variant(\"warning\", null),\n title: East.str`${code} · bin ${id}`, detail: East.str`The mills' schedule delivers ${code} on another day`,\n bin: some(id), resource: none, flag: some(\"no delivery\"), fix: none }));\n }).else(($5) => {\n const delivery = $5.const(cx.reference.get(code));\n $5.if(East.notEqual(delivery.bay, bin.lane).or(() => East.less(bin.at, delivery.from)).or(() => East.greaterEqual(bin.at, delivery.to)), ($6) => {\n $6(issues.pushLast({ kind: variant(\"custom\", \"Delivery moved\"), tone: variant(\"warning\", null),\n title: East.str`${code} · bin ${id}`,\n detail: East.str`Delivered to ${delivery.bay} at ${delivery.from.printFormatted(\"HH:mm\")} now · booked ${bin.lane} ${bin.at.printFormatted(\"HH:mm\")}`,\n bin: some(id), resource: none, flag: some(\"≠ delivery\"), fix: none }));\n });\n });\n } });\n });\n // The day's deliveries no bin books: the reference holds the rows overlapping the day, so a delivery starting the day before is left to it.\n const next = $2.const(cx.day.addDays(1n));\n $2.for(cx.reference, ($3, delivery, code) => {\n $3.if(booked.has(code).not().and(() => East.greaterEqual(delivery.from, cx.day)).and(() => East.less(delivery.from, next)), ($4) => {\n $4(issues.pushLast({ kind: variant(\"custom\", \"Delivery not booked\"), tone: variant(\"warning\", null),\n title: code, detail: East.str`Delivered to ${delivery.bay} at ${delivery.from.printFormatted(\"HH:mm\")}`,\n bin: none, resource: none, flag: none, fix: none }));\n });\n });\n return issues;\n }));\n return <Box width=\"100%\" height=\"760px\"><Allocation id=\"allocationDeliveries\" fit={fit} check={check} slice={{ slice }} inspector view={{ date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\",\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, min: k => k.min, max: k => k.max, jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), { label: l => l.code, quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays) })} />\n </Box>;\n }}</Reactive>)"
40866
+ "source": "// A board over its mills' delivery schedule (#1551): a second record of the yard's, bound as the slice's `reference` source — a paged read through an interval index over each delivery's hour, `range: \"from\"` — which nothing draws and the rail offers no field of. The board writes its day into it as into the bins' source, and the check, from Allocation.Types.CheckContext(MinimalBin, Delivery), is given that day's deliveries by load as `reference`: it flags a bin booked off its load's bay or hour, a bin whose load the day's schedule delivers none of, and a delivery the day books no bin of. Step to Wed 12 May and LD-2214, moved there, is the delivery to book.\n// inputs: []\nexport const kilns = e3.record(\"kilns\", DictType(StringType, Kiln), {\n initial: yardKilns,\n indexes: (index) => ({\n kilns_by_group: index.on([\"group\"]),\n kilns_by_group_max: index.on([\"group\", \"max\"]),\n kilns_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // The kilns' patch door: another session's edit of the yard's kilns, as the renderer's tests on e3 commit it (#1376).\n patch: mutation.patch(),\n }),\n});\n\nexport const arrivals = e3.record(\"arrivals\", DictType(StringType, TimberLoad), {\n initial: yardArrivals,\n indexes: (index) => ({\n arrivals_by_spec: index.on([\"spec\"]),\n }),\n});\n\nexport const yardBays = e3.record(\"yard_bays\", DictType(StringType, Bay), {\n initial: yardBayRows,\n indexes: (index) => ({\n yard_bays_by_area: index.on([\"area\"]),\n yard_bays_by_cover: index.on([\"cover\"]),\n }),\n});\n\n/** The day's bins by key, each its roles: what a fit reads of the plan day. */\nconst DayBins = DictType(StringType, Schedule.Types.AllocationRoles);\n\n/** A bin's roles, as the smallest board's bin kind reads them. */\nexport const minimalBinRoles = East.function([MinimalBin], Schedule.Types.AllocationRoles, (_$, b) => ({\n at: b.at, lane: b.bay, arrival: b.load, quantity: b.m3, parts: b.kilns, hold: b.dryFor, kind: none,\n}));\n\n/** A kiln, as the smallest board's kilns read it. */\nexport const minimalKilnOf = East.function([Kiln, StringType], Allocation.Types.Resource, (_$, k, key) => ({\n key, label: k.name, group: none, meta: none, note: none, min: k.min, max: k.max, hold: variant(\"days\", 0.0), jobs: k.charges,\n}));\n\n/** A load, as the smallest board's arrivals read it. */\nexport const minimalLoadOf = East.function([TimberLoad, StringType], Allocation.Types.Arrival, (_$, l, key) => ({\n key, label: l.code, meta: none, quantity: l.m3, hold: variant(\"days\", l.dryingDays), kind: none, due: none, window: none, details: [],\n}));\n\n/**\n * The smallest board's verdicts over a day's bins as their roles (#1624): the built-in rules, over every kiln and\n * every load as that board reads them — what each of its fits answers, once it has read its own bins.\n */\nexport const minimalAnswer = East.function([DayBins, DictType(StringType, Kiln), DictType(StringType, TimberLoad), Allocation.Types.FitRequest()], Allocation.Types.FitResult(),\n ($, day, kilnRows, loadRows, request) => {\n const kiln = $.const(minimalKilnOf);\n const load = $.const(minimalLoadOf);\n const context = $.const({\n bins: day, arrivals: loadRows.map((_$2, l, key) => load(l, key)), resources: kilnRows.map((_$2, k, key) => kiln(k, key)), rules: { under: true }, unit: \"m³\",\n }, Allocation.Types.FitContext());\n const answer = $.const(Allocation.answer());\n const rule = $.const(Allocation.fit());\n return answer(request, context, rule, \"ranked by load, kind and spare days\");\n });\n\n/** The smallest board's bins again, read a day at a time through the slice, for the board over its mills' delivery schedule (#1551). */\nexport const kilnScheduledBins = e3.record(\"kiln_scheduled_bins\", DictType(StringType, MinimalBin), {\n initial: yardMinimalBinRows,\n indexes: (index) => ({\n kiln_scheduled_bins_by_time: index.interval({ from: \"at\", to: \"at\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** Their fit: the smallest board's rules over these bins, read through their own index. */\nexport const scheduledFit = e3.function(\"yard_scheduled_fit\", {\n inputs: [e3.index(kilnScheduledBins.indexes.kiln_scheduled_bins_by_time), kilnScheduledBins, kilns, arrivals],\n drafts: [kilnScheduledBins],\n args: [Allocation.Types.FitRequest()],\n output: Allocation.Types.FitResult(),\n}, ($, binsByTime, bins, kilnRows, loadRows, request) => {\n const roles = $.const(minimalBinRoles);\n const day = $.let(new Map(), DayBins);\n binsByTime.overlapping({ from: request.day, to: request.day.addDays(1n) }).each($, ($2, _carried, key) => { $2(day.insert(key, roles(bins.get(key)))); });\n const answer = $.const(minimalAnswer);\n return answer(day, kilnRows, loadRows, request);\n});\n\n/** The mills' delivery schedule (#1551): each load's bay and hour, by load, read through an interval index over the hour — what the board's check reads beside its bins. */\nexport const yardDeliveries = e3.record(\"yard_deliveries\", DictType(StringType, Delivery), {\n initial: yardDeliveryRows,\n indexes: (index) => ({\n yard_deliveries_by_time: index.interval({ from: \"from\", to: \"to\" }),\n }),\n mutations: (mutation) => ({\n // The schedule's patch door: the mills' change, as the renderer's tests on e3 commit it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnScheduledBins));\n const entries = $.let(Data.bindPaged(kilnScheduledBins));\n const byTime = $.let(Data.bindPaged(kilnScheduledBins, { indexes: [\"kiln_scheduled_bins_by_time\"] }));\n // The mills' schedule, read a day at a time through its interval index: the check's reference, never the record whole.\n const schedule = $.let(Data.bindPaged(yardDeliveries, { indexes: [\"yard_deliveries_by_time\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationDeliveries\", {\n bin: { source: byTime, range: \"at\" },\n reference: { source: schedule, range: \"from\" },\n }));\n const loads = $.let(Data.bind(arrivals));\n const yard = $.let(Data.bind(kilns));\n const bays = $.let(Data.bind(yardBays));\n const fit = $.let(Func.bind(scheduledFit));\n // The yard's check over its bins and the day's deliveries: each flagged, never refused.\n const check = $.const(East.function([Allocation.Types.CheckContext(MinimalBin, Delivery)], ArrayType(Allocation.Types.Issue), ($2, cx) => {\n const issues = $2.let([], ArrayType(Allocation.Types.Issue));\n const booked = $2.let(new Set([]), SetType(StringType));\n $2.for(cx.plan.bins, ($3, bin, id) => {\n $3.match(bin.arrival, { some: ($4, code) => {\n $4(booked.tryInsert(code));\n $4.if(cx.reference.has(code).not(), ($5) => {\n $5(issues.pushLast({ kind: variant(\"custom\", \"No delivery on the day\"), tone: variant(\"warning\", null),\n title: East.str`${code} · bin ${id}`, detail: East.str`The mills' schedule delivers ${code} on another day`,\n bin: some(id), resource: none, flag: some(\"no delivery\"), fix: none }));\n }).else(($5) => {\n const delivery = $5.const(cx.reference.get(code));\n $5.if(East.notEqual(delivery.bay, bin.lane).or(() => East.less(bin.at, delivery.from)).or(() => East.greaterEqual(bin.at, delivery.to)), ($6) => {\n $6(issues.pushLast({ kind: variant(\"custom\", \"Delivery moved\"), tone: variant(\"warning\", null),\n title: East.str`${code} · bin ${id}`,\n detail: East.str`Delivered to ${delivery.bay} at ${delivery.from.printFormatted(\"HH:mm\")} now · booked ${bin.lane} ${bin.at.printFormatted(\"HH:mm\")}`,\n bin: some(id), resource: none, flag: some(\"≠ delivery\"), fix: none }));\n });\n });\n } });\n });\n // The day's deliveries no bin books: the reference holds the rows overlapping the day, so a delivery starting the day before is left to it.\n const next = $2.const(cx.day.addDays(1n));\n $2.for(cx.reference, ($3, delivery, code) => {\n $3.if(booked.has(code).not().and(() => East.greaterEqual(delivery.from, cx.day)).and(() => East.less(delivery.from, next)), ($4) => {\n $4(issues.pushLast({ kind: variant(\"custom\", \"Delivery not booked\"), tone: variant(\"warning\", null),\n title: code, detail: East.str`Delivered to ${delivery.bay} at ${delivery.from.printFormatted(\"HH:mm\")}`,\n bin: none, resource: none, flag: none, fix: none }));\n });\n });\n return issues;\n }));\n return <Box width=\"100%\" height=\"760px\"><Allocation id=\"allocationDeliveries\" fit={fit} check={check} slice={{ slice }} inspector view={{ date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\",\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, min: k => k.min, max: k => k.max, jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), { label: l => l.code, quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays) })} />\n </Box>;\n }}</Reactive>)"
40867
40867
  },
40868
40868
  {
40869
40869
  "id": "e3-ui:fit.examples.ts:allocationDayLoads",
@@ -40897,7 +40897,7 @@
40897
40897
  "package": "e3-ui",
40898
40898
  "file": "east-ui/packages/e3-ui/test/allocation/fit.examples.ts",
40899
40899
  "suite": "",
40900
- "test": "Allocation.fit, the built-in rules, over the candidates of placing L-2's 30 m³ (Allocation.candidates over what a fit's function read: one per resource, in key order) — K-1 refused over its max, K-2 fits with an open gap, K-3 refused busy",
40900
+ "test": "Allocation.fit(), the built-in rules, over the candidates of placing L-2's 30 m³ (Allocation.candidates() over what a fit's function read: one per resource, in key order) — K-1 refused over its max, K-2 fits with an open gap, K-3 refused busy",
40901
40901
  "keywords": [
40902
40902
  "Allocation",
40903
40903
  "Allocation.fit",
@@ -40918,7 +40918,7 @@
40918
40918
  "languages": [
40919
40919
  "typescript"
40920
40920
  ],
40921
- "source": "// Allocation.fit, the built-in rules, over the candidates of placing L-2's 30 m³ (Allocation.candidates over what a fit's function read: one per resource, in key order) — K-1 refused over its max, K-2 fits with an open gap, K-3 refused busy\n// inputs: [read] returns: [\n variant(\"refused\", { group: \"Over max\", reason: \"over max by 18 m³\", measure: variant(\"amount\", { lead: \"by\", value: 18 }) }),\n variant(\"fits\", { score: 0.6975, why: \"open gap · leaves 30 m³ · takes 20–32\", warn: none }),\n variant(\"refused\", { group: \"Busy\", reason: \"busy until Fri 14\", measure: variant(\"day\", { lead: \"until\", at: new Date(\"2027-05-14T00:00:00Z\") }) }),\n ]\nconst byString = compareFor(StringType);\n\n/** The plan day: Tue 11 May 2027. */\nexport const planDay = new Date(\"2027-05-11T00:00:00Z\");\n\n/** A small yard: two bays, three loads, and three kilns — K-1 with its next charge from Fri 21, K-2 free, K-3 drying until Fri 14. */\nexport const context: ValueTypeOf<typeof Allocation.Types.Context> = {\n lanes: [{ key: \"B-1\", label: \"B-1\", offset: variant(\"minutes\", 15) }, { key: \"B-2\", label: \"B-2\", offset: variant(\"minutes\", 35) }],\n every: variant(\"hours\", 1),\n arrivals: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Arrival>>([\n [\"L-1\", { key: \"L-1\", label: \"L-1\", meta: none, quantity: 12, hold: variant(\"days\", 8), kind: some(\"MC12\"), due: none, window: none, details: [] }],\n [\"L-2\", { key: \"L-2\", label: \"L-2\", meta: none, quantity: 30, hold: variant(\"days\", 6), kind: some(\"MC14\"), due: none, window: none, details: [] }],\n [\"L-3\", { key: \"L-3\", label: \"L-3\", meta: none, quantity: 8, hold: variant(\"days\", 9), kind: some(\"MC12\"), due: none, window: none, details: [] }],\n ], byString),\n resources: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Resource>>([\n [\"K-1\", { key: \"K-1\", label: \"K-1\", group: some(\"Hall A\"), meta: none, note: none, min: 10, max: 24, hold: variant(\"days\", 8),\n jobs: [{ label: \"planned\", start: new Date(\"2027-05-21T00:00:00Z\"), end: new Date(\"2027-05-29T00:00:00Z\") }] }],\n [\"K-2\", { key: \"K-2\", label: \"K-2\", group: some(\"Bulk\"), meta: none, note: none, min: 20, max: 32, hold: variant(\"days\", 8), jobs: [] }],\n [\"K-3\", { key: \"K-3\", label: \"K-3\", group: some(\"Hall A\"), meta: none, note: none, min: 10, max: 24, hold: variant(\"days\", 8),\n jobs: [{ label: \"C-1\", start: new Date(\"2027-05-01T00:00:00Z\"), end: new Date(\"2027-05-14T00:00:00Z\") }] }],\n ], byString),\n rules: { under: true }, unit: \"m³\",\n};\n\n/**\n * What a fit's function read of Tue 11 (#1624): the day's bin as its roles, the yard's loads and kilns, the rules and\n * the unit — what the page holds of them, with no row.\n */\nexport const read: ValueTypeOf<typeof Allocation.Types.FitContext> = {\n bins: new SortedMap<string, ValueTypeOf<typeof Schedule.Types.AllocationRoles>>([\n [\"b1\", { at: new Date(\"2027-05-11T06:15:00Z\"), lane: \"B-1\", arrival: some(\"L-1\"), quantity: 12,\n parts: new SortedMap<string, number>([[\"K-1\", 12]], byString), hold: variant(\"days\", 8), kind: some(\"MC12\") }],\n ], byString),\n arrivals: context.arrivals, resources: context.resources, rules: context.rules, unit: context.unit,\n};\n\nEast.function([Allocation.Types.FitContext], ArrayType(Allocation.Types.Fit), ($, read) => {\n const candidates = $.const(Allocation.candidates);\n const rule = $.const(Allocation.fit);\n // The question carries the plan day and what is asked, and no row: the page holds no scope.\n const request = $.const({ day: planDay, ask: variant(\"place\", { subject: variant(\"arrival\", \"L-2\"), quantity: 30 }), scope: new Map() }, Allocation.Types.FitRequest);\n return candidates(request, read).map(($2, candidate) => rule(candidate));\n })"
40921
+ "source": "// Allocation.fit(), the built-in rules, over the candidates of placing L-2's 30 m³ (Allocation.candidates() over what a fit's function read: one per resource, in key order) — K-1 refused over its max, K-2 fits with an open gap, K-3 refused busy\n// inputs: [read] returns: [\n variant(\"refused\", { group: \"Over max\", reason: \"over max by 18 m³\", measure: variant(\"amount\", { lead: \"by\", value: 18 }) }),\n variant(\"fits\", { score: 0.6975, why: \"open gap · leaves 30 m³ · takes 20–32\", warn: none }),\n variant(\"refused\", { group: \"Busy\", reason: \"busy until Fri 14\", measure: variant(\"day\", { lead: \"until\", at: new Date(\"2027-05-14T00:00:00Z\") }) }),\n ]\n/** What a fit's function read of the yard (#1624), its bins keyed by String; and over bins keyed by number, each part made over their key type. */\nexport const GradeRead = Allocation.Types.FitContext(), GradeReadByNumber = Allocation.Types.FitContext({ key: IntegerType });\n\nconst byString = compareFor(StringType);\n\n/** The plan day: Tue 11 May 2027. */\nexport const planDay = new Date(\"2027-05-11T00:00:00Z\");\n\n/** A small yard: two bays, three loads, and three kilns — K-1 with its next charge from Fri 21, K-2 free, K-3 drying until Fri 14. */\nexport const context: ValueTypeOf<typeof Allocation.Types.Context> = {\n lanes: [{ key: \"B-1\", label: \"B-1\", offset: variant(\"minutes\", 15) }, { key: \"B-2\", label: \"B-2\", offset: variant(\"minutes\", 35) }],\n every: variant(\"hours\", 1),\n arrivals: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Arrival>>([\n [\"L-1\", { key: \"L-1\", label: \"L-1\", meta: none, quantity: 12, hold: variant(\"days\", 8), kind: some(\"MC12\"), due: none, window: none, details: [] }],\n [\"L-2\", { key: \"L-2\", label: \"L-2\", meta: none, quantity: 30, hold: variant(\"days\", 6), kind: some(\"MC14\"), due: none, window: none, details: [] }],\n [\"L-3\", { key: \"L-3\", label: \"L-3\", meta: none, quantity: 8, hold: variant(\"days\", 9), kind: some(\"MC12\"), due: none, window: none, details: [] }],\n ], byString),\n resources: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Resource>>([\n [\"K-1\", { key: \"K-1\", label: \"K-1\", group: some(\"Hall A\"), meta: none, note: none, min: 10, max: 24, hold: variant(\"days\", 8),\n jobs: [{ label: \"planned\", start: new Date(\"2027-05-21T00:00:00Z\"), end: new Date(\"2027-05-29T00:00:00Z\") }] }],\n [\"K-2\", { key: \"K-2\", label: \"K-2\", group: some(\"Bulk\"), meta: none, note: none, min: 20, max: 32, hold: variant(\"days\", 8), jobs: [] }],\n [\"K-3\", { key: \"K-3\", label: \"K-3\", group: some(\"Hall A\"), meta: none, note: none, min: 10, max: 24, hold: variant(\"days\", 8),\n jobs: [{ label: \"C-1\", start: new Date(\"2027-05-01T00:00:00Z\"), end: new Date(\"2027-05-14T00:00:00Z\") }] }],\n ], byString),\n rules: { under: true }, unit: \"m³\",\n};\n\n/**\n * What a fit's function read of Tue 11 (#1624): the day's bin as its roles, the yard's loads and kilns, the rules and\n * the unit — what the page holds of them, with no row.\n */\nexport const read: ValueTypeOf<typeof GradeRead> = {\n bins: new SortedMap<string, ValueTypeOf<typeof Schedule.Types.AllocationRoles>>([\n [\"b1\", { at: new Date(\"2027-05-11T06:15:00Z\"), lane: \"B-1\", arrival: some(\"L-1\"), quantity: 12,\n parts: new SortedMap<string, number>([[\"K-1\", 12]], byString), hold: variant(\"days\", 8), kind: some(\"MC12\") }],\n ], byString),\n arrivals: context.arrivals, resources: context.resources, rules: context.rules, unit: context.unit,\n};\n\nEast.function([Allocation.Types.FitContext()], ArrayType(Allocation.Types.Fit), ($, read) => {\n const candidates = $.const(Allocation.candidates());\n const rule = $.const(Allocation.fit());\n // The question carries the plan day and what is asked, and no row: the page holds no scope.\n const request = $.const({ day: planDay, ask: variant(\"place\", { subject: variant(\"arrival\", \"L-2\"), quantity: 30 }), scope: new Map() }, Allocation.Types.FitRequest());\n return candidates(request, read).map(($2, candidate) => rule(candidate));\n })"
40922
40922
  },
40923
40923
  {
40924
40924
  "id": "e3-ui:fit.examples.ts:allocationAnswerPlace",
@@ -40926,7 +40926,7 @@
40926
40926
  "package": "e3-ui",
40927
40927
  "file": "east-ui/packages/e3-ui/test/allocation/fit.examples.ts",
40928
40928
  "suite": "",
40929
- "test": "Allocation.answer over the built-in rules, placing L-3's 8 m³: a verdict per resource — K-1 fits best, beside a bin of its kind with a day spare before its next charge; K-2 fits under its minimum, a warning; K-3 refused busy",
40929
+ "test": "Allocation.answer() over the built-in rules, placing L-3's 8 m³: a verdict per resource — K-1 fits best, beside a bin of its kind with a day spare before its next charge; K-2 fits under its minimum, a warning; K-3 refused busy",
40930
40930
  "keywords": [
40931
40931
  "Allocation",
40932
40932
  "Allocation.answer",
@@ -40946,7 +40946,7 @@
40946
40946
  "languages": [
40947
40947
  "typescript"
40948
40948
  ],
40949
- "source": "// Allocation.answer over the built-in rules, placing L-3's 8 m³: a verdict per resource — K-1 fits best, beside a bin of its kind with a day spare before its next charge; K-2 fits under its minimum, a warning; K-3 refused busy\n// inputs: [read] returns: {\n ask: variant(\"place\", { subject: variant(\"arrival\", \"L-3\"), quantity: 8 }),\n resources: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Fit>>([\n [\"K-1\", variant(\"fits\", { score: 1.0433333333333334, why: \"1 d spare to Fri 21 · leaves 20 m³ · takes 10–24\", warn: none })],\n [\"K-2\", variant(\"fits\", { score: -0.49, why: \"open gap · leaves 8 m³ · min 20 · 12 short\", warn: some(\"under min\") })],\n [\"K-3\", variant(\"refused\", { group: \"Busy\", reason: \"busy until Fri 14\", measure: variant(\"day\", { lead: \"until\", at: new Date(\"2027-05-14T00:00:00Z\") }) })],\n ], byString),\n bins: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Fit>>([], byString),\n arrivals: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Fit>>([], byString),\n reserve: none, basis: \"ranked by load, kind and spare days\",\n }\nconst byString = compareFor(StringType);\n\n/** The plan day: Tue 11 May 2027. */\nexport const planDay = new Date(\"2027-05-11T00:00:00Z\");\n\n/** A small yard: two bays, three loads, and three kilns — K-1 with its next charge from Fri 21, K-2 free, K-3 drying until Fri 14. */\nexport const context: ValueTypeOf<typeof Allocation.Types.Context> = {\n lanes: [{ key: \"B-1\", label: \"B-1\", offset: variant(\"minutes\", 15) }, { key: \"B-2\", label: \"B-2\", offset: variant(\"minutes\", 35) }],\n every: variant(\"hours\", 1),\n arrivals: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Arrival>>([\n [\"L-1\", { key: \"L-1\", label: \"L-1\", meta: none, quantity: 12, hold: variant(\"days\", 8), kind: some(\"MC12\"), due: none, window: none, details: [] }],\n [\"L-2\", { key: \"L-2\", label: \"L-2\", meta: none, quantity: 30, hold: variant(\"days\", 6), kind: some(\"MC14\"), due: none, window: none, details: [] }],\n [\"L-3\", { key: \"L-3\", label: \"L-3\", meta: none, quantity: 8, hold: variant(\"days\", 9), kind: some(\"MC12\"), due: none, window: none, details: [] }],\n ], byString),\n resources: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Resource>>([\n [\"K-1\", { key: \"K-1\", label: \"K-1\", group: some(\"Hall A\"), meta: none, note: none, min: 10, max: 24, hold: variant(\"days\", 8),\n jobs: [{ label: \"planned\", start: new Date(\"2027-05-21T00:00:00Z\"), end: new Date(\"2027-05-29T00:00:00Z\") }] }],\n [\"K-2\", { key: \"K-2\", label: \"K-2\", group: some(\"Bulk\"), meta: none, note: none, min: 20, max: 32, hold: variant(\"days\", 8), jobs: [] }],\n [\"K-3\", { key: \"K-3\", label: \"K-3\", group: some(\"Hall A\"), meta: none, note: none, min: 10, max: 24, hold: variant(\"days\", 8),\n jobs: [{ label: \"C-1\", start: new Date(\"2027-05-01T00:00:00Z\"), end: new Date(\"2027-05-14T00:00:00Z\") }] }],\n ], byString),\n rules: { under: true }, unit: \"m³\",\n};\n\n/**\n * What a fit's function read of Tue 11 (#1624): the day's bin as its roles, the yard's loads and kilns, the rules and\n * the unit — what the page holds of them, with no row.\n */\nexport const read: ValueTypeOf<typeof Allocation.Types.FitContext> = {\n bins: new SortedMap<string, ValueTypeOf<typeof Schedule.Types.AllocationRoles>>([\n [\"b1\", { at: new Date(\"2027-05-11T06:15:00Z\"), lane: \"B-1\", arrival: some(\"L-1\"), quantity: 12,\n parts: new SortedMap<string, number>([[\"K-1\", 12]], byString), hold: variant(\"days\", 8), kind: some(\"MC12\") }],\n ], byString),\n arrivals: context.arrivals, resources: context.resources, rules: context.rules, unit: context.unit,\n};\n\nEast.function([Allocation.Types.FitContext], Allocation.Types.FitResult, ($, read) => {\n const answer = $.const(Allocation.answer);\n const rule = $.const(Allocation.fit);\n const request = $.const({ day: planDay, ask: variant(\"place\", { subject: variant(\"arrival\", \"L-3\"), quantity: 8 }), scope: new Map() }, Allocation.Types.FitRequest);\n return answer(request, read, rule, \"ranked by load, kind and spare days\");\n })"
40949
+ "source": "// Allocation.answer() over the built-in rules, placing L-3's 8 m³: a verdict per resource — K-1 fits best, beside a bin of its kind with a day spare before its next charge; K-2 fits under its minimum, a warning; K-3 refused busy\n// inputs: [read] returns: {\n ask: variant(\"place\", { subject: variant(\"arrival\", \"L-3\"), quantity: 8 }),\n resources: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Fit>>([\n [\"K-1\", variant(\"fits\", { score: 1.0433333333333334, why: \"1 d spare to Fri 21 · leaves 20 m³ · takes 10–24\", warn: none })],\n [\"K-2\", variant(\"fits\", { score: -0.49, why: \"open gap · leaves 8 m³ · min 20 · 12 short\", warn: some(\"under min\") })],\n [\"K-3\", variant(\"refused\", { group: \"Busy\", reason: \"busy until Fri 14\", measure: variant(\"day\", { lead: \"until\", at: new Date(\"2027-05-14T00:00:00Z\") }) })],\n ], byString),\n bins: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Fit>>([], byString),\n arrivals: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Fit>>([], byString),\n reserve: none, basis: \"ranked by load, kind and spare days\",\n }\n/** What a fit's function read of the yard (#1624), its bins keyed by String; and over bins keyed by number, each part made over their key type. */\nexport const GradeRead = Allocation.Types.FitContext(), GradeReadByNumber = Allocation.Types.FitContext({ key: IntegerType });\n\nconst byString = compareFor(StringType);\n\n/** The plan day: Tue 11 May 2027. */\nexport const planDay = new Date(\"2027-05-11T00:00:00Z\");\n\n/** A small yard: two bays, three loads, and three kilns — K-1 with its next charge from Fri 21, K-2 free, K-3 drying until Fri 14. */\nexport const context: ValueTypeOf<typeof Allocation.Types.Context> = {\n lanes: [{ key: \"B-1\", label: \"B-1\", offset: variant(\"minutes\", 15) }, { key: \"B-2\", label: \"B-2\", offset: variant(\"minutes\", 35) }],\n every: variant(\"hours\", 1),\n arrivals: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Arrival>>([\n [\"L-1\", { key: \"L-1\", label: \"L-1\", meta: none, quantity: 12, hold: variant(\"days\", 8), kind: some(\"MC12\"), due: none, window: none, details: [] }],\n [\"L-2\", { key: \"L-2\", label: \"L-2\", meta: none, quantity: 30, hold: variant(\"days\", 6), kind: some(\"MC14\"), due: none, window: none, details: [] }],\n [\"L-3\", { key: \"L-3\", label: \"L-3\", meta: none, quantity: 8, hold: variant(\"days\", 9), kind: some(\"MC12\"), due: none, window: none, details: [] }],\n ], byString),\n resources: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Resource>>([\n [\"K-1\", { key: \"K-1\", label: \"K-1\", group: some(\"Hall A\"), meta: none, note: none, min: 10, max: 24, hold: variant(\"days\", 8),\n jobs: [{ label: \"planned\", start: new Date(\"2027-05-21T00:00:00Z\"), end: new Date(\"2027-05-29T00:00:00Z\") }] }],\n [\"K-2\", { key: \"K-2\", label: \"K-2\", group: some(\"Bulk\"), meta: none, note: none, min: 20, max: 32, hold: variant(\"days\", 8), jobs: [] }],\n [\"K-3\", { key: \"K-3\", label: \"K-3\", group: some(\"Hall A\"), meta: none, note: none, min: 10, max: 24, hold: variant(\"days\", 8),\n jobs: [{ label: \"C-1\", start: new Date(\"2027-05-01T00:00:00Z\"), end: new Date(\"2027-05-14T00:00:00Z\") }] }],\n ], byString),\n rules: { under: true }, unit: \"m³\",\n};\n\n/**\n * What a fit's function read of Tue 11 (#1624): the day's bin as its roles, the yard's loads and kilns, the rules and\n * the unit — what the page holds of them, with no row.\n */\nexport const read: ValueTypeOf<typeof GradeRead> = {\n bins: new SortedMap<string, ValueTypeOf<typeof Schedule.Types.AllocationRoles>>([\n [\"b1\", { at: new Date(\"2027-05-11T06:15:00Z\"), lane: \"B-1\", arrival: some(\"L-1\"), quantity: 12,\n parts: new SortedMap<string, number>([[\"K-1\", 12]], byString), hold: variant(\"days\", 8), kind: some(\"MC12\") }],\n ], byString),\n arrivals: context.arrivals, resources: context.resources, rules: context.rules, unit: context.unit,\n};\n\nEast.function([Allocation.Types.FitContext()], Allocation.Types.FitResult(), ($, read) => {\n const answer = $.const(Allocation.answer());\n const rule = $.const(Allocation.fit());\n const request = $.const({ day: planDay, ask: variant(\"place\", { subject: variant(\"arrival\", \"L-3\"), quantity: 8 }), scope: new Map() }, Allocation.Types.FitRequest());\n return answer(request, read, rule, \"ranked by load, kind and spare days\");\n })"
40950
40950
  },
40951
40951
  {
40952
40952
  "id": "e3-ui:fit.examples.ts:allocationAnswerTake",
@@ -40954,7 +40954,7 @@
40954
40954
  "package": "e3-ui",
40955
40955
  "file": "east-ui/packages/e3-ui/test/allocation/fit.examples.ts",
40956
40956
  "suite": "",
40957
- "test": "Allocation.answer for a take — what can K-1 take: a verdict for its bin, one for each arrival the plan has not booked (L-2 over its max, L-3 beside a bin of its kind) and one for reserving an empty slot",
40957
+ "test": "Allocation.answer() for a take — what can K-1 take: a verdict for its bin, one for each arrival the plan has not booked (L-2 over its max, L-3 beside a bin of its kind) and one for reserving an empty slot",
40958
40958
  "keywords": [
40959
40959
  "Allocation",
40960
40960
  "Allocation.answer",
@@ -40974,7 +40974,37 @@
40974
40974
  "languages": [
40975
40975
  "typescript"
40976
40976
  ],
40977
- "source": "// Allocation.answer for a take — what can K-1 take: a verdict for its bin, one for each arrival the plan has not booked (L-2 over its max, L-3 beside a bin of its kind) and one for reserving an empty slot\n// inputs: [read] returns: {\n ask: variant(\"take\", { resource: \"K-1\" }),\n resources: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Fit>>([], byString),\n bins: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Fit>>([\n [\"b1\", variant(\"fits\", { score: 0.42, why: \"2 d spare to Fri 21 · leaves 12 m³ · takes 10–24\", warn: none })],\n ], byString),\n arrivals: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Fit>>([\n [\"L-2\", variant(\"refused\", { group: \"Over max\", reason: \"over max by 18 m³\", measure: variant(\"amount\", { lead: \"by\", value: 18 }) })],\n [\"L-3\", variant(\"fits\", { score: 1.0433333333333334, why: \"1 d spare to Fri 21 · leaves 20 m³ · takes 10–24\", warn: none })],\n ], byString),\n reserve: some(variant(\"fits\", { score: 0.32, why: \"2 d spare to Fri 21 · leaves 12 m³ · takes 10–24\", warn: none })),\n basis: \"ranked by load, kind and spare days\",\n }\nconst byString = compareFor(StringType);\n\n/** The plan day: Tue 11 May 2027. */\nexport const planDay = new Date(\"2027-05-11T00:00:00Z\");\n\n/** A small yard: two bays, three loads, and three kilns — K-1 with its next charge from Fri 21, K-2 free, K-3 drying until Fri 14. */\nexport const context: ValueTypeOf<typeof Allocation.Types.Context> = {\n lanes: [{ key: \"B-1\", label: \"B-1\", offset: variant(\"minutes\", 15) }, { key: \"B-2\", label: \"B-2\", offset: variant(\"minutes\", 35) }],\n every: variant(\"hours\", 1),\n arrivals: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Arrival>>([\n [\"L-1\", { key: \"L-1\", label: \"L-1\", meta: none, quantity: 12, hold: variant(\"days\", 8), kind: some(\"MC12\"), due: none, window: none, details: [] }],\n [\"L-2\", { key: \"L-2\", label: \"L-2\", meta: none, quantity: 30, hold: variant(\"days\", 6), kind: some(\"MC14\"), due: none, window: none, details: [] }],\n [\"L-3\", { key: \"L-3\", label: \"L-3\", meta: none, quantity: 8, hold: variant(\"days\", 9), kind: some(\"MC12\"), due: none, window: none, details: [] }],\n ], byString),\n resources: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Resource>>([\n [\"K-1\", { key: \"K-1\", label: \"K-1\", group: some(\"Hall A\"), meta: none, note: none, min: 10, max: 24, hold: variant(\"days\", 8),\n jobs: [{ label: \"planned\", start: new Date(\"2027-05-21T00:00:00Z\"), end: new Date(\"2027-05-29T00:00:00Z\") }] }],\n [\"K-2\", { key: \"K-2\", label: \"K-2\", group: some(\"Bulk\"), meta: none, note: none, min: 20, max: 32, hold: variant(\"days\", 8), jobs: [] }],\n [\"K-3\", { key: \"K-3\", label: \"K-3\", group: some(\"Hall A\"), meta: none, note: none, min: 10, max: 24, hold: variant(\"days\", 8),\n jobs: [{ label: \"C-1\", start: new Date(\"2027-05-01T00:00:00Z\"), end: new Date(\"2027-05-14T00:00:00Z\") }] }],\n ], byString),\n rules: { under: true }, unit: \"m³\",\n};\n\n/**\n * What a fit's function read of Tue 11 (#1624): the day's bin as its roles, the yard's loads and kilns, the rules and\n * the unit — what the page holds of them, with no row.\n */\nexport const read: ValueTypeOf<typeof Allocation.Types.FitContext> = {\n bins: new SortedMap<string, ValueTypeOf<typeof Schedule.Types.AllocationRoles>>([\n [\"b1\", { at: new Date(\"2027-05-11T06:15:00Z\"), lane: \"B-1\", arrival: some(\"L-1\"), quantity: 12,\n parts: new SortedMap<string, number>([[\"K-1\", 12]], byString), hold: variant(\"days\", 8), kind: some(\"MC12\") }],\n ], byString),\n arrivals: context.arrivals, resources: context.resources, rules: context.rules, unit: context.unit,\n};\n\nEast.function([Allocation.Types.FitContext], Allocation.Types.FitResult, ($, read) => {\n const answer = $.const(Allocation.answer);\n const rule = $.const(Allocation.fit);\n const request = $.const({ day: planDay, ask: variant(\"take\", { resource: \"K-1\" }), scope: new Map() }, Allocation.Types.FitRequest);\n return answer(request, read, rule, \"ranked by load, kind and spare days\");\n })"
40977
+ "source": "// Allocation.answer() for a take — what can K-1 take: a verdict for its bin, one for each arrival the plan has not booked (L-2 over its max, L-3 beside a bin of its kind) and one for reserving an empty slot\n// inputs: [read] returns: {\n ask: variant(\"take\", { resource: \"K-1\" }),\n resources: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Fit>>([], byString),\n bins: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Fit>>([\n [\"b1\", variant(\"fits\", { score: 0.42, why: \"2 d spare to Fri 21 · leaves 12 m³ · takes 10–24\", warn: none })],\n ], byString),\n arrivals: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Fit>>([\n [\"L-2\", variant(\"refused\", { group: \"Over max\", reason: \"over max by 18 m³\", measure: variant(\"amount\", { lead: \"by\", value: 18 }) })],\n [\"L-3\", variant(\"fits\", { score: 1.0433333333333334, why: \"1 d spare to Fri 21 · leaves 20 m³ · takes 10–24\", warn: none })],\n ], byString),\n reserve: some(variant(\"fits\", { score: 0.32, why: \"2 d spare to Fri 21 · leaves 12 m³ · takes 10–24\", warn: none })),\n basis: \"ranked by load, kind and spare days\",\n }\n/** What a fit's function read of the yard (#1624), its bins keyed by String; and over bins keyed by number, each part made over their key type. */\nexport const GradeRead = Allocation.Types.FitContext(), GradeReadByNumber = Allocation.Types.FitContext({ key: IntegerType });\n\nconst byString = compareFor(StringType);\n\n/** The plan day: Tue 11 May 2027. */\nexport const planDay = new Date(\"2027-05-11T00:00:00Z\");\n\n/** A small yard: two bays, three loads, and three kilns — K-1 with its next charge from Fri 21, K-2 free, K-3 drying until Fri 14. */\nexport const context: ValueTypeOf<typeof Allocation.Types.Context> = {\n lanes: [{ key: \"B-1\", label: \"B-1\", offset: variant(\"minutes\", 15) }, { key: \"B-2\", label: \"B-2\", offset: variant(\"minutes\", 35) }],\n every: variant(\"hours\", 1),\n arrivals: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Arrival>>([\n [\"L-1\", { key: \"L-1\", label: \"L-1\", meta: none, quantity: 12, hold: variant(\"days\", 8), kind: some(\"MC12\"), due: none, window: none, details: [] }],\n [\"L-2\", { key: \"L-2\", label: \"L-2\", meta: none, quantity: 30, hold: variant(\"days\", 6), kind: some(\"MC14\"), due: none, window: none, details: [] }],\n [\"L-3\", { key: \"L-3\", label: \"L-3\", meta: none, quantity: 8, hold: variant(\"days\", 9), kind: some(\"MC12\"), due: none, window: none, details: [] }],\n ], byString),\n resources: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Resource>>([\n [\"K-1\", { key: \"K-1\", label: \"K-1\", group: some(\"Hall A\"), meta: none, note: none, min: 10, max: 24, hold: variant(\"days\", 8),\n jobs: [{ label: \"planned\", start: new Date(\"2027-05-21T00:00:00Z\"), end: new Date(\"2027-05-29T00:00:00Z\") }] }],\n [\"K-2\", { key: \"K-2\", label: \"K-2\", group: some(\"Bulk\"), meta: none, note: none, min: 20, max: 32, hold: variant(\"days\", 8), jobs: [] }],\n [\"K-3\", { key: \"K-3\", label: \"K-3\", group: some(\"Hall A\"), meta: none, note: none, min: 10, max: 24, hold: variant(\"days\", 8),\n jobs: [{ label: \"C-1\", start: new Date(\"2027-05-01T00:00:00Z\"), end: new Date(\"2027-05-14T00:00:00Z\") }] }],\n ], byString),\n rules: { under: true }, unit: \"m³\",\n};\n\n/**\n * What a fit's function read of Tue 11 (#1624): the day's bin as its roles, the yard's loads and kilns, the rules and\n * the unit — what the page holds of them, with no row.\n */\nexport const read: ValueTypeOf<typeof GradeRead> = {\n bins: new SortedMap<string, ValueTypeOf<typeof Schedule.Types.AllocationRoles>>([\n [\"b1\", { at: new Date(\"2027-05-11T06:15:00Z\"), lane: \"B-1\", arrival: some(\"L-1\"), quantity: 12,\n parts: new SortedMap<string, number>([[\"K-1\", 12]], byString), hold: variant(\"days\", 8), kind: some(\"MC12\") }],\n ], byString),\n arrivals: context.arrivals, resources: context.resources, rules: context.rules, unit: context.unit,\n};\n\nEast.function([Allocation.Types.FitContext()], Allocation.Types.FitResult(), ($, read) => {\n const answer = $.const(Allocation.answer());\n const rule = $.const(Allocation.fit());\n const request = $.const({ day: planDay, ask: variant(\"take\", { resource: \"K-1\" }), scope: new Map() }, Allocation.Types.FitRequest());\n return answer(request, read, rule, \"ranked by load, kind and spare days\");\n })"
40978
+ },
40979
+ {
40980
+ "id": "e3-ui:fit.examples.ts:allocationAnswerByNumber",
40981
+ "skill": "e3-ui",
40982
+ "package": "e3-ui",
40983
+ "file": "east-ui/packages/e3-ui/test/allocation/fit.examples.ts",
40984
+ "suite": "",
40985
+ "test": "Allocation.answer over bins keyed by number: the parts, the question and the answer each made over the bins' key type, { key: IntegerType } — what can K-1 take answers its bin by its number, 1, beside the arrivals it could book and an empty slot reserved",
40986
+ "keywords": [
40987
+ "Allocation",
40988
+ "Allocation.answer",
40989
+ "Allocation.fit",
40990
+ "Allocation.Types.FitRequest",
40991
+ "Allocation.Types.FitContext",
40992
+ "Allocation.Types.FitResult",
40993
+ "key",
40994
+ "IntegerType",
40995
+ "keyed by number",
40996
+ "take",
40997
+ "bins",
40998
+ "e3.function"
40999
+ ],
41000
+ "imports": [
41001
+ "import {",
41002
+ "import { Allocation, Schedule } from \"@elaraai/e3-ui\";"
41003
+ ],
41004
+ "languages": [
41005
+ "typescript"
41006
+ ],
41007
+ "source": "// Allocation.answer over bins keyed by number: the parts, the question and the answer each made over the bins' key type, { key: IntegerType } — what can K-1 take answers its bin by its number, 1, beside the arrivals it could book and an empty slot reserved\n// inputs: [readByNumber] returns: {\n ask: variant(\"take\", { resource: \"K-1\" }),\n resources: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Fit>>([], byString),\n bins: new SortedMap<bigint, ValueTypeOf<typeof Allocation.Types.Fit>>([\n [1n, variant(\"fits\", { score: 0.42, why: \"2 d spare to Fri 21 · leaves 12 m³ · takes 10–24\", warn: none })],\n ], compareFor(IntegerType)),\n arrivals: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Fit>>([\n [\"L-2\", variant(\"refused\", { group: \"Over max\", reason: \"over max by 18 m³\", measure: variant(\"amount\", { lead: \"by\", value: 18 }) })],\n [\"L-3\", variant(\"fits\", { score: 1.0433333333333334, why: \"1 d spare to Fri 21 · leaves 20 m³ · takes 10–24\", warn: none })],\n ], byString),\n reserve: some(variant(\"fits\", { score: 0.32, why: \"2 d spare to Fri 21 · leaves 12 m³ · takes 10–24\", warn: none })),\n basis: \"ranked by load, kind and spare days\",\n }\n/** What a fit's function read of the yard (#1624), its bins keyed by String; and over bins keyed by number, each part made over their key type. */\nexport const GradeRead = Allocation.Types.FitContext(), GradeReadByNumber = Allocation.Types.FitContext({ key: IntegerType });\n\nconst byString = compareFor(StringType);\n\n/** The plan day: Tue 11 May 2027. */\nexport const planDay = new Date(\"2027-05-11T00:00:00Z\");\n\n/** A small yard: two bays, three loads, and three kilns — K-1 with its next charge from Fri 21, K-2 free, K-3 drying until Fri 14. */\nexport const context: ValueTypeOf<typeof Allocation.Types.Context> = {\n lanes: [{ key: \"B-1\", label: \"B-1\", offset: variant(\"minutes\", 15) }, { key: \"B-2\", label: \"B-2\", offset: variant(\"minutes\", 35) }],\n every: variant(\"hours\", 1),\n arrivals: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Arrival>>([\n [\"L-1\", { key: \"L-1\", label: \"L-1\", meta: none, quantity: 12, hold: variant(\"days\", 8), kind: some(\"MC12\"), due: none, window: none, details: [] }],\n [\"L-2\", { key: \"L-2\", label: \"L-2\", meta: none, quantity: 30, hold: variant(\"days\", 6), kind: some(\"MC14\"), due: none, window: none, details: [] }],\n [\"L-3\", { key: \"L-3\", label: \"L-3\", meta: none, quantity: 8, hold: variant(\"days\", 9), kind: some(\"MC12\"), due: none, window: none, details: [] }],\n ], byString),\n resources: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Resource>>([\n [\"K-1\", { key: \"K-1\", label: \"K-1\", group: some(\"Hall A\"), meta: none, note: none, min: 10, max: 24, hold: variant(\"days\", 8),\n jobs: [{ label: \"planned\", start: new Date(\"2027-05-21T00:00:00Z\"), end: new Date(\"2027-05-29T00:00:00Z\") }] }],\n [\"K-2\", { key: \"K-2\", label: \"K-2\", group: some(\"Bulk\"), meta: none, note: none, min: 20, max: 32, hold: variant(\"days\", 8), jobs: [] }],\n [\"K-3\", { key: \"K-3\", label: \"K-3\", group: some(\"Hall A\"), meta: none, note: none, min: 10, max: 24, hold: variant(\"days\", 8),\n jobs: [{ label: \"C-1\", start: new Date(\"2027-05-01T00:00:00Z\"), end: new Date(\"2027-05-14T00:00:00Z\") }] }],\n ], byString),\n rules: { under: true }, unit: \"m³\",\n};\n\n/**\n * What a fit's function read of Tue 11 (#1624): the day's bin as its roles, the yard's loads and kilns, the rules and\n * the unit — what the page holds of them, with no row.\n */\nexport const read: ValueTypeOf<typeof GradeRead> = {\n bins: new SortedMap<string, ValueTypeOf<typeof Schedule.Types.AllocationRoles>>([\n [\"b1\", { at: new Date(\"2027-05-11T06:15:00Z\"), lane: \"B-1\", arrival: some(\"L-1\"), quantity: 12,\n parts: new SortedMap<string, number>([[\"K-1\", 12]], byString), hold: variant(\"days\", 8), kind: some(\"MC12\") }],\n ], byString),\n arrivals: context.arrivals, resources: context.resources, rules: context.rules, unit: context.unit,\n};\n\nEast.function([Allocation.Types.FitContext({ key: IntegerType })], Allocation.Types.FitResult({ key: IntegerType }), ($, read) => {\n // Over bins keyed by number, each part is made over their key type, and so are the question and the answer.\n const answer = $.const(Allocation.answer({ key: IntegerType }));\n const rule = $.const(Allocation.fit({ key: IntegerType }));\n const request = $.const({ day: planDay, ask: variant(\"take\", { resource: \"K-1\" }), scope: new Map() }, Allocation.Types.FitRequest({ key: IntegerType }));\n return answer(request, read, rule, \"ranked by load, kind and spare days\");\n })"
40978
41008
  },
40979
41009
  {
40980
41010
  "id": "e3-ui:fit.examples.ts:allocationLookahead",
@@ -40982,7 +41012,7 @@
40982
41012
  "package": "e3-ui",
40983
41013
  "file": "east-ui/packages/e3-ui/test/allocation/fit.examples.ts",
40984
41014
  "suite": "",
40985
- "test": "Allocation.lookahead over the built-in rules, as a fit's body: placing L-3 on K-2 would leave L-2 with nowhere to go, so that fit drops by one and says so; K-1's leaves room for L-2 on K-2 and stands",
41015
+ "test": "Allocation.lookahead() over the built-in rules, as a fit's body: placing L-3 on K-2 would leave L-2 with nowhere to go, so that fit drops by one and says so; K-1's leaves room for L-2 on K-2 and stands",
40986
41016
  "keywords": [
40987
41017
  "Allocation",
40988
41018
  "Allocation.lookahead",
@@ -41001,7 +41031,7 @@
41001
41031
  "languages": [
41002
41032
  "typescript"
41003
41033
  ],
41004
- "source": "// Allocation.lookahead over the built-in rules, as a fit's body: placing L-3 on K-2 would leave L-2 with nowhere to go, so that fit drops by one and says so; K-1's leaves room for L-2 on K-2 and stands\n// inputs: [read] returns: {\n ask: variant(\"place\", { subject: variant(\"arrival\", \"L-3\"), quantity: 8 }),\n resources: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Fit>>([\n [\"K-1\", variant(\"fits\", { score: 1.0433333333333334, why: \"1 d spare to Fri 21 · leaves 20 m³ · takes 10–24\", warn: none })],\n [\"K-2\", variant(\"fits\", { score: -1.49, why: \"open gap · leaves 8 m³ · min 20 · 12 short · leaves 1 load with no fit\", warn: some(\"under min\") })],\n [\"K-3\", variant(\"refused\", { group: \"Busy\", reason: \"busy until Fri 14\", measure: variant(\"day\", { lead: \"until\", at: new Date(\"2027-05-14T00:00:00Z\") }) })],\n ], byString),\n bins: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Fit>>([], byString),\n arrivals: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Fit>>([], byString),\n reserve: none, basis: \"ranked by load, kind and spare days, and what it leaves for the day's other loads\",\n }\nconst byString = compareFor(StringType);\n\n/** The plan day: Tue 11 May 2027. */\nexport const planDay = new Date(\"2027-05-11T00:00:00Z\");\n\n/** A small yard: two bays, three loads, and three kilns — K-1 with its next charge from Fri 21, K-2 free, K-3 drying until Fri 14. */\nexport const context: ValueTypeOf<typeof Allocation.Types.Context> = {\n lanes: [{ key: \"B-1\", label: \"B-1\", offset: variant(\"minutes\", 15) }, { key: \"B-2\", label: \"B-2\", offset: variant(\"minutes\", 35) }],\n every: variant(\"hours\", 1),\n arrivals: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Arrival>>([\n [\"L-1\", { key: \"L-1\", label: \"L-1\", meta: none, quantity: 12, hold: variant(\"days\", 8), kind: some(\"MC12\"), due: none, window: none, details: [] }],\n [\"L-2\", { key: \"L-2\", label: \"L-2\", meta: none, quantity: 30, hold: variant(\"days\", 6), kind: some(\"MC14\"), due: none, window: none, details: [] }],\n [\"L-3\", { key: \"L-3\", label: \"L-3\", meta: none, quantity: 8, hold: variant(\"days\", 9), kind: some(\"MC12\"), due: none, window: none, details: [] }],\n ], byString),\n resources: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Resource>>([\n [\"K-1\", { key: \"K-1\", label: \"K-1\", group: some(\"Hall A\"), meta: none, note: none, min: 10, max: 24, hold: variant(\"days\", 8),\n jobs: [{ label: \"planned\", start: new Date(\"2027-05-21T00:00:00Z\"), end: new Date(\"2027-05-29T00:00:00Z\") }] }],\n [\"K-2\", { key: \"K-2\", label: \"K-2\", group: some(\"Bulk\"), meta: none, note: none, min: 20, max: 32, hold: variant(\"days\", 8), jobs: [] }],\n [\"K-3\", { key: \"K-3\", label: \"K-3\", group: some(\"Hall A\"), meta: none, note: none, min: 10, max: 24, hold: variant(\"days\", 8),\n jobs: [{ label: \"C-1\", start: new Date(\"2027-05-01T00:00:00Z\"), end: new Date(\"2027-05-14T00:00:00Z\") }] }],\n ], byString),\n rules: { under: true }, unit: \"m³\",\n};\n\n/**\n * What a fit's function read of Tue 11 (#1624): the day's bin as its roles, the yard's loads and kilns, the rules and\n * the unit — what the page holds of them, with no row.\n */\nexport const read: ValueTypeOf<typeof Allocation.Types.FitContext> = {\n bins: new SortedMap<string, ValueTypeOf<typeof Schedule.Types.AllocationRoles>>([\n [\"b1\", { at: new Date(\"2027-05-11T06:15:00Z\"), lane: \"B-1\", arrival: some(\"L-1\"), quantity: 12,\n parts: new SortedMap<string, number>([[\"K-1\", 12]], byString), hold: variant(\"days\", 8), kind: some(\"MC12\") }],\n ], byString),\n arrivals: context.arrivals, resources: context.resources, rules: context.rules, unit: context.unit,\n};\n\nEast.function([Allocation.Types.FitContext], Allocation.Types.FitResult, ($, read) => {\n const answer = $.const(Allocation.answer);\n const rule = $.const(Allocation.fit);\n const ahead = $.const(Allocation.lookahead);\n const request = $.const({ day: planDay, ask: variant(\"place\", { subject: variant(\"arrival\", \"L-3\"), quantity: 8 }), scope: new Map() }, Allocation.Types.FitRequest);\n return answer(request, read, East.function([Allocation.Types.Candidate], Allocation.Types.Fit, (_$2, c) => ahead(read, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n })"
41034
+ "source": "// Allocation.lookahead() over the built-in rules, as a fit's body: placing L-3 on K-2 would leave L-2 with nowhere to go, so that fit drops by one and says so; K-1's leaves room for L-2 on K-2 and stands\n// inputs: [read] returns: {\n ask: variant(\"place\", { subject: variant(\"arrival\", \"L-3\"), quantity: 8 }),\n resources: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Fit>>([\n [\"K-1\", variant(\"fits\", { score: 1.0433333333333334, why: \"1 d spare to Fri 21 · leaves 20 m³ · takes 10–24\", warn: none })],\n [\"K-2\", variant(\"fits\", { score: -1.49, why: \"open gap · leaves 8 m³ · min 20 · 12 short · leaves 1 load with no fit\", warn: some(\"under min\") })],\n [\"K-3\", variant(\"refused\", { group: \"Busy\", reason: \"busy until Fri 14\", measure: variant(\"day\", { lead: \"until\", at: new Date(\"2027-05-14T00:00:00Z\") }) })],\n ], byString),\n bins: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Fit>>([], byString),\n arrivals: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Fit>>([], byString),\n reserve: none, basis: \"ranked by load, kind and spare days, and what it leaves for the day's other loads\",\n }\n/** What a fit's function read of the yard (#1624), its bins keyed by String; and over bins keyed by number, each part made over their key type. */\nexport const GradeRead = Allocation.Types.FitContext(), GradeReadByNumber = Allocation.Types.FitContext({ key: IntegerType });\n\nconst byString = compareFor(StringType);\n\n/** The plan day: Tue 11 May 2027. */\nexport const planDay = new Date(\"2027-05-11T00:00:00Z\");\n\n/** A small yard: two bays, three loads, and three kilns — K-1 with its next charge from Fri 21, K-2 free, K-3 drying until Fri 14. */\nexport const context: ValueTypeOf<typeof Allocation.Types.Context> = {\n lanes: [{ key: \"B-1\", label: \"B-1\", offset: variant(\"minutes\", 15) }, { key: \"B-2\", label: \"B-2\", offset: variant(\"minutes\", 35) }],\n every: variant(\"hours\", 1),\n arrivals: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Arrival>>([\n [\"L-1\", { key: \"L-1\", label: \"L-1\", meta: none, quantity: 12, hold: variant(\"days\", 8), kind: some(\"MC12\"), due: none, window: none, details: [] }],\n [\"L-2\", { key: \"L-2\", label: \"L-2\", meta: none, quantity: 30, hold: variant(\"days\", 6), kind: some(\"MC14\"), due: none, window: none, details: [] }],\n [\"L-3\", { key: \"L-3\", label: \"L-3\", meta: none, quantity: 8, hold: variant(\"days\", 9), kind: some(\"MC12\"), due: none, window: none, details: [] }],\n ], byString),\n resources: new SortedMap<string, ValueTypeOf<typeof Allocation.Types.Resource>>([\n [\"K-1\", { key: \"K-1\", label: \"K-1\", group: some(\"Hall A\"), meta: none, note: none, min: 10, max: 24, hold: variant(\"days\", 8),\n jobs: [{ label: \"planned\", start: new Date(\"2027-05-21T00:00:00Z\"), end: new Date(\"2027-05-29T00:00:00Z\") }] }],\n [\"K-2\", { key: \"K-2\", label: \"K-2\", group: some(\"Bulk\"), meta: none, note: none, min: 20, max: 32, hold: variant(\"days\", 8), jobs: [] }],\n [\"K-3\", { key: \"K-3\", label: \"K-3\", group: some(\"Hall A\"), meta: none, note: none, min: 10, max: 24, hold: variant(\"days\", 8),\n jobs: [{ label: \"C-1\", start: new Date(\"2027-05-01T00:00:00Z\"), end: new Date(\"2027-05-14T00:00:00Z\") }] }],\n ], byString),\n rules: { under: true }, unit: \"m³\",\n};\n\n/**\n * What a fit's function read of Tue 11 (#1624): the day's bin as its roles, the yard's loads and kilns, the rules and\n * the unit — what the page holds of them, with no row.\n */\nexport const read: ValueTypeOf<typeof GradeRead> = {\n bins: new SortedMap<string, ValueTypeOf<typeof Schedule.Types.AllocationRoles>>([\n [\"b1\", { at: new Date(\"2027-05-11T06:15:00Z\"), lane: \"B-1\", arrival: some(\"L-1\"), quantity: 12,\n parts: new SortedMap<string, number>([[\"K-1\", 12]], byString), hold: variant(\"days\", 8), kind: some(\"MC12\") }],\n ], byString),\n arrivals: context.arrivals, resources: context.resources, rules: context.rules, unit: context.unit,\n};\n\nEast.function([Allocation.Types.FitContext()], Allocation.Types.FitResult(), ($, read) => {\n const answer = $.const(Allocation.answer());\n const rule = $.const(Allocation.fit());\n const ahead = $.const(Allocation.lookahead());\n const request = $.const({ day: planDay, ask: variant(\"place\", { subject: variant(\"arrival\", \"L-3\"), quantity: 8 }), scope: new Map() }, Allocation.Types.FitRequest());\n return answer(request, read, East.function([Allocation.Types.Candidate()], Allocation.Types.Fit, (_$2, c) => ahead(read, c, rule)),\n \"ranked by load, kind and spare days, and what it leaves for the day's other loads\");\n })"
41005
41035
  },
41006
41036
  {
41007
41037
  "id": "e3-ui:fit.examples.ts:allocationChecks",
@@ -41099,7 +41129,7 @@
41099
41129
  "languages": [
41100
41130
  "tsx"
41101
41131
  ],
41102
- "source": "// The kiln yard's board with the Elara eye (#1409, #1622): `optimise` is Func.bind of the yard's optimiser on e3 — Allocation.Types.OptimiseRequest in, the day in view, the run number and the rail's narrowing and no row; Allocation.Types.OptimiseResult(KilnBins) out, a patch of the bins' record. The function reads the day's bins through their interval index, the board's unsaved edits laid over them (drafts: [kilnBins]), and the bays, the kilns and the loads from the yard's own records, building the board's context from them (Allocation.context). A joint optimiser: a kiln over its maximum gives the excess to the kilns the fit ranks best, a bin not linked or partly allocated is linked, and every load not yet booked is booked into the day's free bay slots and onto the kilns the fit ranks best — whole on the best fit, split when no one kiln takes it. A click on the eye runs it once over the day; the result lands in the session as one edit — bins added, bins relinked — which one Undo reverts and Save commits with everything else.\n// inputs: []\n/** The bins' record type: the yard's bins by key. */\nexport const KilnBins = DictType(StringType, KilnBin);\n\n/** The day's bins by key, the yard's own rows. */\nconst Bins = KilnBins;\n\n/** A bin's split across kilns: its quantity on each. */\nconst Kilns = DictType(StringType, FloatType);\n\n/** One part a run places: a quantity on a kiln. */\nconst Part = StructType({ kiln: StringType, quantity: FloatType });\n\n/** The day as the board reads it, from the bins as they stand: each bin its roles and its own row. */\nconst dayOf = East.function([Bins], YardPlan, ($, rows) => $.const({\n status: variant(\"draft\", null),\n bins: rows.toDict(($2, _bin, key) => key, ($2, bin) => ({ lane: bin.bay, at: bin.at, arrival: bin.load, quantity: bin.m3, kind: bin.spec, hold: bin.dryFor, parts: bin.kilns, row: bin })),\n}, YardPlan));\n\n/** A bin's row with its kilns replaced, the yard's own fields kept. */\nconst withKilns = East.function([KilnBin, Kilns], KilnBin, (_$, bin, kilns) => ({\n bay: bin.bay, at: bin.at, load: bin.load, m3: bin.m3, spec: bin.spec, dryFor: bin.dryFor, kilns,\n specBooked: bin.specBooked, specMeasured: bin.specMeasured, gradeBooked: bin.gradeBooked, gradeMeasured: bin.gradeMeasured, instruction: bin.instruction,\n}));\n\n/** A bin's kilns with a quantity added to one of them — or taken off it, for a quantity below zero. */\nconst addPart = East.function([Kilns, StringType, FloatType], Kilns, ($, held, kiln, quantity) => {\n const kilns = $.let(new Map(), Kilns);\n $.for(held, ($2, part, key) => { $2(kilns.insert(key, part)); });\n $(kilns.insertOrUpdate(kiln, quantity, (_$2, part, more) => part.add(more)));\n return kilns;\n});\n\n/**\n * Places a quantity of a bin's on the kilns the fit ranks best — whole on the best fit; failing that, split, the kiln\n * with the most room first, until nothing has room — writing each part into the bin's row as it goes. The fit's rules\n * are asked about the bin itself, its own spec and drying time, as a fit's function asks them (#1624): over the bins\n * as their roles, as they stand with the bin once more under a key of its own — a place's candidates leave the\n * subject's parts out of the kilns' loads, and the copy puts them back, so a kiln's room is what the day leaves it,\n * the bin's parts there included — and the kilns and the loads of the board's context.\n *\n * @returns The bins with the parts written, and how much of the quantity found a kiln\n */\nconst settle = East.function([DateTimeType, Allocation.Types.Context, Bins, StringType, FloatType], StructType({ bins: Bins, placed: FloatType }),\n ($, day, context, held, id, quantity) => {\n const candidatesOf = $.const(Allocation.candidates);\n const rule = $.const(Allocation.fit);\n const rolesOf = $.const(yardBinRoles);\n const rowWith = $.const(withKilns);\n const partOn = $.const(addPart);\n const bins = $.let(new Map(), Bins);\n $.for(held, ($2, bin, key) => { $2(bins.insert(key, bin)); });\n const remaining = $.let(quantity, FloatType);\n $.while(East.greater(remaining, 0.0), ($2, loop) => {\n const rows = $2.let(new Map(), Bins);\n $2.for(bins, ($3, bin, key) => { $3(rows.insert(key, bin)); });\n $2(rows.insert(East.str`${id}·`, bins.get(id)));\n const request = $2.const({ day, ask: variant(\"place\", { subject: variant(\"bin\", id), quantity: remaining }), scope: new Map() }, Allocation.Types.FitRequest);\n const read = $2.const({\n bins: rows.map((_$3, bin) => rolesOf(bin)), arrivals: context.arrivals, resources: context.resources, rules: context.rules, unit: context.unit,\n }, Allocation.Types.FitContext);\n const best = $2.let(none, OptionType(StringType)), bestScore = $2.let(0.0, FloatType);\n const roomiest = $2.let(none, OptionType(StringType)), room = $2.let(0.0, FloatType);\n $2.for(candidatesOf(request, read), ($3, candidate) => {\n const kiln = $3.const(candidate.resource.key);\n $3.match(rule(candidate), {\n fits: ($4, fit) => {\n $4.if(best.hasTag(\"none\").or(() => East.greater(fit.score, bestScore)), ($5) => { $5.assign(best, some(kiln)); $5.assign(bestScore, fit.score); });\n },\n refused: ($4, refusal) => {\n // Refused for the quantity alone: a part of it, what the kiln has room for, would fit.\n const spare = $4.const(candidate.resource.max.subtract(candidate.after.subtract(candidate.quantity)));\n $4.if(East.equal(refusal.group, \"Over max\").and(() => East.greater(spare, room)), ($5) => { $5.assign(roomiest, some(kiln)); $5.assign(room, spare); });\n },\n });\n });\n const chosen = $2.let(none, OptionType(Part));\n $2.match(best, {\n some: ($3, kiln) => { $3.assign(chosen, some({ kiln, quantity: remaining })); },\n none: ($3) => { $3.match(roomiest, { some: ($4, kiln) => { $4.assign(chosen, some({ kiln, quantity: room })); } }); },\n });\n $2.match(chosen, {\n none: ($3) => { $3.break(loop); },\n some: ($3, part) => {\n const bin = $3.const(bins.get(id));\n $3(bins.insertOrUpdate(id, rowWith(bin, partOn(bin.kilns, part.kiln, part.quantity)), (_$4, _was, next) => next));\n $3.assign(remaining, remaining.subtract(part.quantity));\n },\n });\n });\n return { bins, placed: quantity.subtract(remaining) };\n });\n\n/**\n * The yard's optimiser, on e3, in three passes over the day as drafted, every bin it held kept in its slot. First the\n * kilns: one over its maximum gives the excess of its latest bin — the check's own fix, Move — to the kilns the fit ranks\n * best. Then the bins: one not linked, or partly allocated, gets what its parts leave of it placed the same way. Then the\n * loads: every one not yet booked, in the loads' order, is booked into the day's first free bay slot — its m³, its spec\n * and its drying time the load's, its spec booked as measured, under a key of the run's own — and placed on the kilns\n * the fit ranks best. A quantity goes whole onto the best fit (`Allocation.fit`: never a busy kiln, never one whose next\n * job its hold runs into, never over a maximum); when no kiln takes it whole it is split, the kiln with the most room\n * first; what no kiln has room for stays unallocated, for the planner. It reads the day's bins through their interval\n * index and each by its key, the board's unsaved edits laid over them, and the bays, the kilns and the loads from the\n * yard's own records, the board's context built from them as the board builds it (`Allocation.context`). The answer is\n * the day's change; a run that finds nothing to do changes nothing.\n */\nexport const yardOptimise = e3.function(\"yard_optimise\", {\n inputs: [e3.index(kilnBins.indexes.kiln_bins_by_time), kilnBins, arrivals, kilns, yardBays],\n // The board's unsaved edits of the bins are laid over them, and over their index\n drafts: [kilnBins],\n args: [Allocation.Types.OptimiseRequest],\n output: Allocation.Types.OptimiseResult(KilnBins),\n}, ($, binsByTime, rows, loads, yard, bays, request) => {\n const loadsOf = $.const(Allocation.loads(KilnBin));\n const checkOf = $.const(Allocation.check(KilnBin));\n const slotsOf = $.const(Allocation.slots(KilnBin));\n const planOf = $.const(dayOf);\n const rowWith = $.const(withKilns);\n const partOn = $.const(addPart);\n const place = $.const(settle);\n const day = $.const(request.day);\n // The board's context, from the yard's own bays, kilns and loads, read as the board reads them.\n const context = $.const(Allocation.context({\n lanes: Schedule.resources(bays, { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n resources: Schedule.resources(yard, { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group, note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n arrivals: Allocation.arrivals(loads, { label: l => l.code, quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }) }),\n unit: \"m³\",\n }));\n // The day's bins, as drafted, through the bins' interval index.\n const held = $.let(new Map(), Bins);\n binsByTime.overlapping({ from: day, to: day.addDays(1n) }).each($, ($2, _carried, key) => { $2(held.insert(key, rows.get(key))); });\n const bins = $.let(held.copy());\n // The kilns: one over its maximum gives the excess of its latest bin — the check's fix, Move — to the kilns the fit\n // ranks best; its part there shrinks by what found room, and what found none stays, over, for the planner.\n $.for(checkOf(day, planOf(bins), context), ($2, issue) => {\n $2.match(issue.kind, { over: ($3) => {\n $3.match(issue.resource, { some: ($4, kiln) => {\n $4.match(issue.fix, { some: ($5, fix) => {\n $5.match(fix, { move: ($6, id) => {\n const bin = $6.const(bins.get(id));\n const over = $6.const(loadsOf(day, planOf(bins), context).get(kiln).fill.subtract(context.resources.get(kiln).max));\n const excess = $6.const(East.min(over, bin.kilns.get(kiln, () => 0.0)));\n $6.if(East.greater(excess, 0.0), ($7) => {\n const settled = $7.const(place(day, context, bins, id, excess));\n $7.assign(bins, settled.bins);\n const moved = $7.const(bins.get(id));\n const kilns = $7.let(partOn(moved.kilns, kiln, settled.placed.negate()));\n $7.if(East.lessEqual(kilns.get(kiln), 0.0), ($8) => { $8(kilns.delete(kiln)); });\n $7(bins.insertOrUpdate(id, rowWith(moved, kilns), (_$8, _was, next) => next));\n });\n } });\n } });\n } });\n } });\n });\n // The bins: one not linked, or partly allocated, gets what its parts leave of it placed; a reservation holds nothing.\n $.for(held, ($2, _held, id) => {\n const bin = $2.const(bins.get(id));\n const allocated = $2.let(0.0, FloatType);\n $2.for(bin.kilns, ($3, part) => { $3.assign(allocated, allocated.add(part)); });\n const left = $2.const(bin.m3.subtract(allocated));\n $2.if(East.greater(left, 0.0), ($3) => { $3.assign(bins, place(day, context, bins, id, left).bins); });\n });\n // The loads: every one not yet booked, in the loads' order, into the day's first free bay slot — its m³, its spec and\n // its drying time the load's, its spec booked as measured, under a key of the run's own — and onto the kilns.\n const booked = $.let(new Set<string>(), SetType(StringType));\n $.for(bins, ($2, bin) => {\n // A load may be booked in two bins, a batch's: once in the set.\n $2.match(bin.load, { some: ($3, load) => { $3(booked.tryInsert(load)); } });\n });\n const free = $.const(slotsOf(day, planOf(bins), context).filter(($2, slot) => slot.status.hasTag(\"free\")));\n const waiting = $.const(context.arrivals.toArray(($2, load) => load).filter(($2, load) => booked.has(load.key).not()));\n $.for(waiting, ($2, load, i) => {\n $2.if(i.less(free.size()), ($3) => {\n const slot = $3.const(free.get(i));\n const spec = $3.const(load.kind.unwrap(\"some\", () => \"\"));\n const id = $3.const(East.str`elara-${request.run}-${load.key}`);\n $3(bins.insert(id, {\n bay: slot.lane, at: slot.at, load: some(load.key), m3: load.quantity, spec: load.kind, dryFor: load.hold, kilns: new Map(),\n specBooked: spec, specMeasured: spec, gradeBooked: \"\", gradeMeasured: \"\", instruction: none,\n }));\n $3.assign(bins, place(day, context, bins, id, load.quantity).bins);\n });\n });\n return { bins: East.diff(held, bins) };\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n const days = $.let(Record.bind(yardDays));\n // Every bay, kiln and load is the calculation scope — and the optimiser's: the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group\"] }));\n const loadIndex = $.let(Data.bindPaged(arrivals, { indexes: [\"arrivals_by_spec\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationOptimise\", {\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] } } },\n kilns: { source: kilnIndex, fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] } } },\n arrivals: { source: loadIndex, fields: { spec: { label: \"Spec\", hints: [\"MC08\", \"MC10\", \"MC12\", \"MC14\", \"MC16\", \"MC18\", \"MC20\", \"MC22\"] } } },\n }));\n const fit = $.let(Func.bind(yardFit));\n // The app's optimiser: the eye calls it once per run over the day in view, with the bins' unsaved edits as drafts.\n const optimise = $.let(Func.bind(yardOptimise));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationOptimise\" title=\"Kiln loading\" fit={fit} optimise={optimise} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"timeline\", date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(days, { every: \"day\", status: { field: \"state\", draft: \"draft\", published: \"issued\" } })} />\n </Box>;\n }}</Reactive>)"
41132
+ "source": "// The kiln yard's board with the Elara eye (#1409, #1622): `optimise` is Func.bind of the yard's optimiser on e3 — Allocation.Types.OptimiseRequest in, the day in view, the run number and the rail's narrowing and no row; Allocation.Types.OptimiseResult(KilnBins) out, a patch of the bins' record. The function reads the day's bins through their interval index, the board's unsaved edits laid over them (drafts: [kilnBins]), and the bays, the kilns and the loads from the yard's own records, building the board's context from them (Allocation.context). A joint optimiser: a kiln over its maximum gives the excess to the kilns the fit ranks best, a bin not linked or partly allocated is linked, and every load not yet booked is booked into the day's free bay slots and onto the kilns the fit ranks best — whole on the best fit, split when no one kiln takes it. A click on the eye runs it once over the day; the result lands in the session as one edit — bins added, bins relinked — which one Undo reverts and Save commits with everything else.\n// inputs: []\n/** The bins' record type: the yard's bins by key. */\nexport const KilnBins = DictType(StringType, KilnBin);\n\n/** The day's bins by key, the yard's own rows. */\nconst Bins = KilnBins;\n\n/** A bin's split across kilns: its quantity on each. */\nconst Kilns = DictType(StringType, FloatType);\n\n/** One part a run places: a quantity on a kiln. */\nconst Part = StructType({ kiln: StringType, quantity: FloatType });\n\n/** The day as the board reads it, from the bins as they stand: each bin its roles and its own row. */\nconst dayOf = East.function([Bins], YardPlan, ($, rows) => $.const({\n status: variant(\"draft\", null),\n bins: rows.toDict(($2, _bin, key) => key, ($2, bin) => ({ lane: bin.bay, at: bin.at, arrival: bin.load, quantity: bin.m3, kind: bin.spec, hold: bin.dryFor, parts: bin.kilns, row: bin })),\n}, YardPlan));\n\n/** A bin's row with its kilns replaced, the yard's own fields kept. */\nconst withKilns = East.function([KilnBin, Kilns], KilnBin, (_$, bin, kilns) => ({\n bay: bin.bay, at: bin.at, load: bin.load, m3: bin.m3, spec: bin.spec, dryFor: bin.dryFor, kilns,\n specBooked: bin.specBooked, specMeasured: bin.specMeasured, gradeBooked: bin.gradeBooked, gradeMeasured: bin.gradeMeasured, instruction: bin.instruction,\n}));\n\n/** A bin's kilns with a quantity added to one of them — or taken off it, for a quantity below zero. */\nconst addPart = East.function([Kilns, StringType, FloatType], Kilns, ($, held, kiln, quantity) => {\n const kilns = $.let(new Map(), Kilns);\n $.for(held, ($2, part, key) => { $2(kilns.insert(key, part)); });\n $(kilns.insertOrUpdate(kiln, quantity, (_$2, part, more) => part.add(more)));\n return kilns;\n});\n\n/**\n * Places a quantity of a bin's on the kilns the fit ranks best — whole on the best fit; failing that, split, the kiln\n * with the most room first, until nothing has room — writing each part into the bin's row as it goes. The fit's rules\n * are asked about the bin itself, its own spec and drying time, as a fit's function asks them (#1624): over the bins\n * as their roles, as they stand with the bin once more under a key of its own — a place's candidates leave the\n * subject's parts out of the kilns' loads, and the copy puts them back, so a kiln's room is what the day leaves it,\n * the bin's parts there included — and the kilns and the loads of the board's context.\n *\n * @returns The bins with the parts written, and how much of the quantity found a kiln\n */\nconst settle = East.function([DateTimeType, Allocation.Types.Context, Bins, StringType, FloatType], StructType({ bins: Bins, placed: FloatType }),\n ($, day, context, held, id, quantity) => {\n const candidatesOf = $.const(Allocation.candidates());\n const rule = $.const(Allocation.fit());\n const rolesOf = $.const(yardBinRoles);\n const rowWith = $.const(withKilns);\n const partOn = $.const(addPart);\n const bins = $.let(new Map(), Bins);\n $.for(held, ($2, bin, key) => { $2(bins.insert(key, bin)); });\n const remaining = $.let(quantity, FloatType);\n $.while(East.greater(remaining, 0.0), ($2, loop) => {\n const rows = $2.let(new Map(), Bins);\n $2.for(bins, ($3, bin, key) => { $3(rows.insert(key, bin)); });\n $2(rows.insert(East.str`${id}·`, bins.get(id)));\n const request = $2.const({ day, ask: variant(\"place\", { subject: variant(\"bin\", id), quantity: remaining }), scope: new Map() }, Allocation.Types.FitRequest());\n const read = $2.const({\n bins: rows.map((_$3, bin) => rolesOf(bin)), arrivals: context.arrivals, resources: context.resources, rules: context.rules, unit: context.unit,\n }, Allocation.Types.FitContext());\n const best = $2.let(none, OptionType(StringType)), bestScore = $2.let(0.0, FloatType);\n const roomiest = $2.let(none, OptionType(StringType)), room = $2.let(0.0, FloatType);\n $2.for(candidatesOf(request, read), ($3, candidate) => {\n const kiln = $3.const(candidate.resource.key);\n $3.match(rule(candidate), {\n fits: ($4, fit) => {\n $4.if(best.hasTag(\"none\").or(() => East.greater(fit.score, bestScore)), ($5) => { $5.assign(best, some(kiln)); $5.assign(bestScore, fit.score); });\n },\n refused: ($4, refusal) => {\n // Refused for the quantity alone: a part of it, what the kiln has room for, would fit.\n const spare = $4.const(candidate.resource.max.subtract(candidate.after.subtract(candidate.quantity)));\n $4.if(East.equal(refusal.group, \"Over max\").and(() => East.greater(spare, room)), ($5) => { $5.assign(roomiest, some(kiln)); $5.assign(room, spare); });\n },\n });\n });\n const chosen = $2.let(none, OptionType(Part));\n $2.match(best, {\n some: ($3, kiln) => { $3.assign(chosen, some({ kiln, quantity: remaining })); },\n none: ($3) => { $3.match(roomiest, { some: ($4, kiln) => { $4.assign(chosen, some({ kiln, quantity: room })); } }); },\n });\n $2.match(chosen, {\n none: ($3) => { $3.break(loop); },\n some: ($3, part) => {\n const bin = $3.const(bins.get(id));\n $3(bins.insertOrUpdate(id, rowWith(bin, partOn(bin.kilns, part.kiln, part.quantity)), (_$4, _was, next) => next));\n $3.assign(remaining, remaining.subtract(part.quantity));\n },\n });\n });\n return { bins, placed: quantity.subtract(remaining) };\n });\n\n/**\n * The yard's optimiser, on e3, in three passes over the day as drafted, every bin it held kept in its slot. First the\n * kilns: one over its maximum gives the excess of its latest bin — the check's own fix, Move — to the kilns the fit ranks\n * best. Then the bins: one not linked, or partly allocated, gets what its parts leave of it placed the same way. Then the\n * loads: every one not yet booked, in the loads' order, is booked into the day's first free bay slot — its m³, its spec\n * and its drying time the load's, its spec booked as measured, under a key of the run's own — and placed on the kilns\n * the fit ranks best. A quantity goes whole onto the best fit (`Allocation.fit()`: never a busy kiln, never one whose next\n * job its hold runs into, never over a maximum); when no kiln takes it whole it is split, the kiln with the most room\n * first; what no kiln has room for stays unallocated, for the planner. It reads the day's bins through their interval\n * index and each by its key, the board's unsaved edits laid over them, and the bays, the kilns and the loads from the\n * yard's own records, the board's context built from them as the board builds it (`Allocation.context`). The answer is\n * the day's change; a run that finds nothing to do changes nothing.\n */\nexport const yardOptimise = e3.function(\"yard_optimise\", {\n inputs: [e3.index(kilnBins.indexes.kiln_bins_by_time), kilnBins, arrivals, kilns, yardBays],\n // The board's unsaved edits of the bins are laid over them, and over their index\n drafts: [kilnBins],\n args: [Allocation.Types.OptimiseRequest],\n output: Allocation.Types.OptimiseResult(KilnBins),\n}, ($, binsByTime, rows, loads, yard, bays, request) => {\n const loadsOf = $.const(Allocation.loads(KilnBin));\n const checkOf = $.const(Allocation.check(KilnBin));\n const slotsOf = $.const(Allocation.slots(KilnBin));\n const planOf = $.const(dayOf);\n const rowWith = $.const(withKilns);\n const partOn = $.const(addPart);\n const place = $.const(settle);\n const day = $.const(request.day);\n // The board's context, from the yard's own bays, kilns and loads, read as the board reads them.\n const context = $.const(Allocation.context({\n lanes: Schedule.resources(bays, { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n resources: Schedule.resources(yard, { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group, note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n arrivals: Allocation.arrivals(loads, { label: l => l.code, quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }) }),\n unit: \"m³\",\n }));\n // The day's bins, as drafted, through the bins' interval index.\n const held = $.let(new Map(), Bins);\n binsByTime.overlapping({ from: day, to: day.addDays(1n) }).each($, ($2, _carried, key) => { $2(held.insert(key, rows.get(key))); });\n const bins = $.let(held.copy());\n // The kilns: one over its maximum gives the excess of its latest bin — the check's fix, Move — to the kilns the fit\n // ranks best; its part there shrinks by what found room, and what found none stays, over, for the planner.\n $.for(checkOf(day, planOf(bins), context), ($2, issue) => {\n $2.match(issue.kind, { over: ($3) => {\n $3.match(issue.resource, { some: ($4, kiln) => {\n $4.match(issue.fix, { some: ($5, fix) => {\n $5.match(fix, { move: ($6, id) => {\n const bin = $6.const(bins.get(id));\n const over = $6.const(loadsOf(day, planOf(bins), context).get(kiln).fill.subtract(context.resources.get(kiln).max));\n const excess = $6.const(East.min(over, bin.kilns.get(kiln, () => 0.0)));\n $6.if(East.greater(excess, 0.0), ($7) => {\n const settled = $7.const(place(day, context, bins, id, excess));\n $7.assign(bins, settled.bins);\n const moved = $7.const(bins.get(id));\n const kilns = $7.let(partOn(moved.kilns, kiln, settled.placed.negate()));\n $7.if(East.lessEqual(kilns.get(kiln), 0.0), ($8) => { $8(kilns.delete(kiln)); });\n $7(bins.insertOrUpdate(id, rowWith(moved, kilns), (_$8, _was, next) => next));\n });\n } });\n } });\n } });\n } });\n });\n // The bins: one not linked, or partly allocated, gets what its parts leave of it placed; a reservation holds nothing.\n $.for(held, ($2, _held, id) => {\n const bin = $2.const(bins.get(id));\n const allocated = $2.let(0.0, FloatType);\n $2.for(bin.kilns, ($3, part) => { $3.assign(allocated, allocated.add(part)); });\n const left = $2.const(bin.m3.subtract(allocated));\n $2.if(East.greater(left, 0.0), ($3) => { $3.assign(bins, place(day, context, bins, id, left).bins); });\n });\n // The loads: every one not yet booked, in the loads' order, into the day's first free bay slot — its m³, its spec and\n // its drying time the load's, its spec booked as measured, under a key of the run's own — and onto the kilns.\n const booked = $.let(new Set<string>(), SetType(StringType));\n $.for(bins, ($2, bin) => {\n // A load may be booked in two bins, a batch's: once in the set.\n $2.match(bin.load, { some: ($3, load) => { $3(booked.tryInsert(load)); } });\n });\n const free = $.const(slotsOf(day, planOf(bins), context).filter(($2, slot) => slot.status.hasTag(\"free\")));\n const waiting = $.const(context.arrivals.toArray(($2, load) => load).filter(($2, load) => booked.has(load.key).not()));\n $.for(waiting, ($2, load, i) => {\n $2.if(i.less(free.size()), ($3) => {\n const slot = $3.const(free.get(i));\n const spec = $3.const(load.kind.unwrap(\"some\", () => \"\"));\n const id = $3.const(East.str`elara-${request.run}-${load.key}`);\n $3(bins.insert(id, {\n bay: slot.lane, at: slot.at, load: some(load.key), m3: load.quantity, spec: load.kind, dryFor: load.hold, kilns: new Map(),\n specBooked: spec, specMeasured: spec, gradeBooked: \"\", gradeMeasured: \"\", instruction: none,\n }));\n $3.assign(bins, place(day, context, bins, id, load.quantity).bins);\n });\n });\n return { bins: East.diff(held, bins) };\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const bins = $.let(Record.bind(kilnBins));\n const entries = $.let(Data.bindPaged(kilnBins));\n const byTime = $.let(Data.bindPaged(kilnBins, { indexes: [\"kiln_bins_by_time\"] }));\n const days = $.let(Record.bind(yardDays));\n // Every bay, kiln and load is the calculation scope — and the optimiser's: the narrowing only chooses which show.\n const yard = $.let(Data.bind(kilns));\n const loads = $.let(Data.bind(arrivals));\n const bays = $.let(Data.bind(yardBays));\n const bayIndex = $.let(Data.bindPaged(yardBays, { indexes: [\"yard_bays_by_area\"] }));\n const kilnIndex = $.let(Data.bindPaged(kilns, { indexes: [\"kilns_by_group\"] }));\n const loadIndex = $.let(Data.bindPaged(arrivals, { indexes: [\"arrivals_by_spec\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.allocationOptimise\", {\n bin: { source: byTime, range: \"at\" },\n bays: { source: bayIndex, fields: { area: { label: \"Area\", hints: [\"North\", \"South\"] } } },\n kilns: { source: kilnIndex, fields: { group: { label: \"Kiln group\", hints: [\"Hall A\", \"Hall B\", \"Compact\", \"Standard\", \"Large\", \"Bulk\"] } } },\n arrivals: { source: loadIndex, fields: { spec: { label: \"Spec\", hints: [\"MC08\", \"MC10\", \"MC12\", \"MC14\", \"MC16\", \"MC18\", \"MC20\", \"MC22\"] } } },\n }));\n const fit = $.let(Func.bind(yardFit));\n // The app's optimiser: the eye calls it once per run over the day in view, with the bins' unsaved edits as drafts.\n const optimise = $.let(Func.bind(yardOptimise));\n return <Box width=\"100%\" height=\"900px\"><Allocation id=\"allocationOptimise\" title=\"Kiln loading\" fit={fit} optimise={optimise} slice={{ slice }} inspector\n library={[Allocation.library.arrivals(), Allocation.library.resources()]} view={{ layout: \"timeline\", date: yardDay }}\n events={{ bin: Schedule.events(bins, {\n name: \"Bin\", icon: \"box\", entries,\n at: \"at\", resource: { field: \"bay\", of: \"bays\" }, arrival: \"load\",\n quantity: { field: \"m3\", unit: \"m³\" }, parts: { field: \"kilns\", of: \"kilns\" }, hold: \"dryFor\", kind: \"spec\",\n fields: { specMeasured: Schedule.field.text({ label: \"Spec measured\" }), instruction: Schedule.field.text({ label: \"Loading instruction\" }) },\n }) }}\n resources={{\n bays: Schedule.resources(bays.read(), { name: \"Bays\", icon: \"warehouse\", label: b => b.name, offset: b => b.offset }),\n kilns: Schedule.resources(yard.read(), { name: \"Kilns\", icon: \"fire\", label: k => k.name, group: k => k.group,\n meta: k => some(East.str`${k.group} · ${East.Float.roundHalf(k.max)} m³`), note: k => k.note,\n min: k => k.min, max: k => k.max, hold: k => variant(\"days\", k.days), jobs: k => k.charges }),\n }}\n arrivals={Allocation.arrivals(loads.read(), {\n label: l => l.code, meta: l => some(East.str`${l.mill} · ${l.grade} · spec ${l.spec}`),\n quantity: l => l.m3, hold: l => variant(\"days\", l.dryingDays), kind: l => some(l.spec),\n due: l => some(l.due), window: l => some({ from: l.from, to: l.to }),\n details: l => [{ label: \"Settings\", value: l.schedule }],\n values: l => ({ specBooked: l.spec, specMeasured: l.spec, gradeBooked: l.grade.substring(0n, 1n), gradeMeasured: l.grade, instruction: l.instruction }),\n })}\n periods={Schedule.periods(days, { every: \"day\", status: { field: \"state\", draft: \"draft\", published: \"issued\" } })} />\n </Box>;\n }}</Reactive>)"
41103
41133
  },
41104
41134
  {
41105
41135
  "id": "e3-ui:data.examples.tsx:dataBindFloat",
@@ -41740,7 +41770,7 @@
41740
41770
  "not committed"
41741
41771
  ],
41742
41772
  "imports": [
41743
- "import { DictType, East, IntegerType, OptionType, StringType, StructType, example, none, some, variant } from \"@elaraai/east\";",
41773
+ "import { DictType, East, IntegerType, OptionType, PatchType, StringType, StructType, example, none, some, variant } from \"@elaraai/east\";",
41744
41774
  "import { Editing } from \"@elaraai/east-ui\";",
41745
41775
  "import { Record } from \"@elaraai/e3-ui\";",
41746
41776
  "import e3 from \"@elaraai/e3\";"
@@ -41773,7 +41803,7 @@
41773
41803
  "not committed"
41774
41804
  ],
41775
41805
  "imports": [
41776
- "import { DictType, East, IntegerType, OptionType, StringType, StructType, example, none, some, variant } from \"@elaraai/east\";",
41806
+ "import { DictType, East, IntegerType, OptionType, PatchType, StringType, StructType, example, none, some, variant } from \"@elaraai/east\";",
41777
41807
  "import { Editing } from \"@elaraai/east-ui\";",
41778
41808
  "import { Record } from \"@elaraai/e3-ui\";",
41779
41809
  "import e3 from \"@elaraai/e3\";"
@@ -41783,6 +41813,38 @@
41783
41813
  ],
41784
41814
  "source": "// What Record.onApply answers is the Save with its draft form, one struct: apply commits a batch, and toDraft answers the same batch as a draft of that commit, with nothing committed. A copy bound in a block keeps both, and a Sheet or a Plan handed it as its onApply takes both\n// inputs: [] returns: \"a draft of bindery_jobs.patch, of 1 argument\"\nexport const BinderyJobType = StructType({ task: StringType, qty: IntegerType });\n\nexport const binderyJobs = e3.record(\"bindery_jobs\", DictType(StringType, BinderyJobType), {\n initial: new Map(),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], StringType, ($) => {\n const board = $.let(Record.bind(binderyJobs));\n // One value, held in a block: a Sheet or a Plan takes it as its onApply.\n const save = $.const(Record.onApply(board, { keyed: true }));\n const folded = $.const(some({ task: \"Fold\", qty: 200n }), OptionType(BinderyJobType));\n const refolded = $.const(some({ task: \"Fold\", qty: 250n }), OptionType(BinderyJobType));\n const pending = $.const({\n requestId: \"\", base: variant(\"revision\", \"a41c09d2\"), label: \"Fold 250\",\n changes: [{ id: \"b1\", patch: East.diff(folded, refolded), place: none }],\n }, Editing.Types.ChangeSet(BinderyJobType, StringType));\n // `save.apply(pending)` would commit the batch; `save.toDraft(pending)` answers it as a draft of that commit.\n return save.toDraft(pending).match({\n draft: (_$, draft) => East.str`a draft of ${draft.record}.${draft.mutation}, of ${East.print(draft.args.size())} argument`,\n unchanged: _$ => East.str`nothing to send`,\n rejected: (_$, issues) => East.str`refused: ${issues.map((_$, issue) => issue.message).stringJoin(\"; \")}`,\n conflict: (_$, issues) => East.str`changed since the edit began: ${issues.map((_$, issue) => issue.message).stringJoin(\"; \")}`,\n });\n })"
41785
41815
  },
41816
+ {
41817
+ "id": "e3-ui:record-draft.examples.ts:recordKeyField",
41818
+ "skill": "e3-ui",
41819
+ "package": "e3-ui",
41820
+ "file": "east-ui/packages/e3-ui/test/bind/record/record-draft.examples.ts",
41821
+ "suite": "",
41822
+ "test": "A record whose rows hold their own key in a field: keyField names the field, and the Save writes a new row's key into it, whatever the batch drafted there. A new row's key is its editing session's to make, and to make again where another Save took it first, so only the Save knows the key the row is saved under",
41823
+ "keywords": [
41824
+ "Record",
41825
+ "onApply",
41826
+ "toDraft",
41827
+ "keyField",
41828
+ "key field",
41829
+ "rows hold their key",
41830
+ "new row",
41831
+ "newKey",
41832
+ "identity field",
41833
+ "insert",
41834
+ "add a row",
41835
+ "ChangeSet"
41836
+ ],
41837
+ "imports": [
41838
+ "import { DictType, East, IntegerType, OptionType, PatchType, StringType, StructType, example, none, some, variant } from \"@elaraai/east\";",
41839
+ "import { Editing } from \"@elaraai/east-ui\";",
41840
+ "import { Record } from \"@elaraai/e3-ui\";",
41841
+ "import e3 from \"@elaraai/e3\";"
41842
+ ],
41843
+ "languages": [
41844
+ "typescript"
41845
+ ],
41846
+ "source": "// A record whose rows hold their own key in a field: keyField names the field, and the Save writes a new row's key into it, whatever the batch drafted there. A new row's key is its editing session's to make, and to make again where another Save took it first, so only the Save knows the key the row is saved under\n// inputs: [] returns: \"Ada is saved under S-1 with staff S-1\"\nexport const CrewMemberType = StructType({ staff: StringType, name: StringType });\n\nexport const crew = e3.record(\"crew\", DictType(StringType, CrewMemberType), {\n initial: new Map(),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], StringType, ($) => {\n const members = $.let(Record.bind(crew));\n // `staff` holds a member's key: `Record.onApply(members, { keyed: true, keyField: \"staff\" })` saves the same way.\n const toDraft = $.const(Record.toDraft(members, { keyed: true, keyField: \"staff\" }));\n const absent = $.const(none, OptionType(CrewMemberType));\n // A member added under the key S-1, their `staff` as the editing surface drafted it.\n const added = $.const(some({ staff: \"\", name: \"Ada\" }), OptionType(CrewMemberType));\n const pending = $.const({\n requestId: \"\", base: variant(\"revision\", \"a41c09d2\"), label: \"Add a member\",\n changes: [{ id: \"S-1\", patch: East.diff(absent, added), place: some(variant(\"keyOrder\", null)) }],\n }, Editing.Types.ChangeSet(CrewMemberType, StringType));\n return toDraft(pending).match({\n draft: ($, draft) => {\n // The patch that Save commits, laid over a crew of nobody.\n const patch = $.const(draft.args.get(0n).decodeBeast(PatchType(crew.type), \"v2\"));\n const saved = $.const(East.applyPatch(East.value(new Map(), crew.type), patch));\n return East.str`${saved.get(\"S-1\").name} is saved under S-1 with staff ${saved.get(\"S-1\").staff}`;\n },\n unchanged: _$ => East.str`nothing to send`,\n rejected: (_$, issues) => East.str`refused: ${issues.map((_$, issue) => issue.message).stringJoin(\"; \")}`,\n conflict: (_$, issues) => East.str`changed since the edit began: ${issues.map((_$, issue) => issue.message).stringJoin(\"; \")}`,\n });\n })"
41847
+ },
41786
41848
  {
41787
41849
  "id": "e3-ui:record.examples.tsx:recordBindMutate",
41788
41850
  "skill": "e3-ui",
@@ -41925,6 +41987,50 @@
41925
41987
  ],
41926
41988
  "source": "// Read the record's commit history (the audit trail) alongside its current value\n// inputs: []\nexport const counter = e3.record(\"counter\", IntegerType, {\n initial: 0n,\n mutations: (mutation) => ({\n increment: mutation.reduce(East.function([IntegerType, IntegerType], IntegerType, ($, state, by) => state.add(by))),\n reset: mutation.reduce(East.function([IntegerType], IntegerType, (_$, _state) => 0n)),\n // What the record runtime's specs write beside them (#1378): a take off the\n // counter that refuses to leave it below zero, so a mutation fails as a\n // reducer's program does.\n take: mutation.reduce(East.function([IntegerType, IntegerType], IntegerType, (_$, state, n) =>\n East.less(state, n).ifElse(() => East.error(\"the counter holds fewer than that\"), () => state.subtract(n)))),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const r = $.let(Record.bind(counter, [\"increment\"]));\n const count = $.let(r.history().match({\n some: (_$, commits) => commits.size(),\n none: _$ => 0n,\n }));\n return (\n <VStack gap=\"3\" align=\"stretch\">\n <Stat label=\"Counter\" value={East.print(r.read())} />\n <Text.MonoLabel>{East.str`${count} COMMITS`}</Text.MonoLabel>\n </VStack>\n );\n }}</Reactive>\n ))"
41927
41989
  },
41990
+ {
41991
+ "id": "e3-ui:calendar-keys.examples.tsx:calendarBuiltKeysSliced",
41992
+ "skill": "e3-ui",
41993
+ "package": "e3-ui",
41994
+ "file": "east-ui/packages/e3-ui/test/calendar/calendar-keys.examples.tsx",
41995
+ "suite": "",
41996
+ "test": "calendarBuiltKeys under the rail, over a key that is no text: machine reservations keyed by a struct of their machine and their start, which `rowKey` on the event kind builds from the row, read a period at a time through their record's interval indexes and narrowed by machine, crew and dates. A record keyed by any type a Dict takes is a source of the rail. A reservation moved to another start or another machine moves under the struct it then builds and is saved there; one that would build a key another reservation holds is refused, the Calendar naming the key; and one moved out of what the rail keeps leaves the view once saved, which the footer says",
41997
+ "keywords": [
41998
+ "Calendar",
41999
+ "Calendar.events",
42000
+ "Schedule.events",
42001
+ "rowKey",
42002
+ "built key",
42003
+ "key from the row",
42004
+ "struct key",
42005
+ "composite key",
42006
+ "keyType",
42007
+ "typed key",
42008
+ "StructType",
42009
+ "Slice",
42010
+ "Slice.bindRecords",
42011
+ "Data.bindPaged",
42012
+ "indexes",
42013
+ "interval",
42014
+ "index.interval",
42015
+ "narrowing",
42016
+ "double booking",
42017
+ "key taken",
42018
+ "refused",
42019
+ "move",
42020
+ "Record.bind",
42021
+ "#1696"
42022
+ ],
42023
+ "imports": [
42024
+ "import { DateTimeType, DictType, East, SortedMap, StringType, StructType, compareFor, example, type ValueTypeOf } from \"@elaraai/east\";",
42025
+ "import { Box, Reactive, Slice, UIComponentType } from \"@elaraai/east-ui\";",
42026
+ "import { Calendar, Data, Record } from \"@elaraai/e3-ui\";",
42027
+ "import e3 from \"@elaraai/e3\";"
42028
+ ],
42029
+ "languages": [
42030
+ "tsx"
42031
+ ],
42032
+ "source": "// calendarBuiltKeys under the rail, over a key that is no text: machine reservations keyed by a struct of their machine and their start, which `rowKey` on the event kind builds from the row, read a period at a time through their record's interval indexes and narrowed by machine, crew and dates. A record keyed by any type a Dict takes is a source of the rail. A reservation moved to another start or another machine moves under the struct it then builds and is saved there; one that would build a key another reservation holds is refused, the Calendar naming the key; and one moved out of what the rail keeps leaves the view once saved, which the footer says\n// inputs: []\n/** A machine's reservation: the machine and the start its key is built from, what it is for, when it ends, and the crew it is for. */\nexport const KeyedReservation = StructType({ machine: StringType, title: StringType, start: DateTimeType, end: DateTimeType, crew: StringType });\n\n/** A reservation's key: its machine and its start. */\nexport const KeyedReservationKey = StructType({ machine: StringType, start: DateTimeType });\n\n/** The machines reserved. */\nexport const keyedMachines = e3.record(\"calendar_keyed_machines\", DictType(StringType, StructType({ name: StringType })), {\n initial: new Map([[\"press1\", { name: \"Press 1\" }], [\"lathe1\", { name: \"Lathe 1\" }], [\"mill1\", { name: \"Mill 1\" }]]),\n});\n\n/** What a machine is reserved for through a day, each with the hour it starts at, how many hours it takes, and its crew. */\nconst BOOKED = [\n [\"Tool trial\", 7, 2, \"Day\"], [\"Operator training\", 11, 1, \"Day\"], [\"First-article run\", 14, 3, \"Day\"], [\"Night batch\", 20, 3, \"Night\"],\n] as const;\n\n/** Three days of reservations on each machine, an hour later on each machine after the first: 36 in all. */\nfunction reservations(): [ValueTypeOf<typeof KeyedReservationKey>, ValueTypeOf<typeof KeyedReservation>][] {\n return [\"press1\", \"lathe1\", \"mill1\"].flatMap((machine, at) => [0, 1, 2].flatMap((day) => BOOKED.map(([title, hour, hours, crew]): [ValueTypeOf<typeof KeyedReservationKey>, ValueTypeOf<typeof KeyedReservation>] => {\n const start = new Date(Date.UTC(2026, 9, 1 + day, hour + at));\n return [{ machine, start }, { machine, title, start, end: new Date(start.getTime() + hours * 3_600_000), crew }];\n })));\n}\n\n/** The reservations, each keyed by the struct its machine and its start build. A Dict over struct keys is a SortedMap, in East's order. */\nexport const keyedReservations = e3.record(\"calendar_keyed_reservations\", DictType(KeyedReservationKey, KeyedReservation), {\n initial: new SortedMap<ValueTypeOf<typeof KeyedReservationKey>, ValueTypeOf<typeof KeyedReservation>>(reservations(), compareFor(KeyedReservationKey)),\n indexes: (index) => ({\n // What the rail reads a period's reservations through, and narrows them by.\n calendar_keyed_reservations_by_time: index.interval({ from: \"start\", to: \"end\" }),\n calendar_keyed_reservations_by_machine_time: index.interval({ on: [\"machine\"], from: \"start\", to: \"end\" }),\n calendar_keyed_reservations_by_crew_time: index.interval({ on: [\"crew\"], from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n // The reservations' patch door — every Save commits through it, each reservation by its struct key.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const machines = $.let(Record.bind(keyedMachines, []));\n const held = $.let(Record.bind(keyedReservations));\n const entries = $.let(Data.bindPaged(keyedReservations));\n const indexed = $.let(Data.bindPaged(keyedReservations, {\n indexes: [\"calendar_keyed_reservations_by_time\", \"calendar_keyed_reservations_by_machine_time\", \"calendar_keyed_reservations_by_crew_time\"],\n }));\n // The rail's one source, named after the kind it narrows: its interval indexes keep every reservation the period overlaps.\n const slice = $.let(Slice.bindRecords(\"ex.calendarBuiltKeysSliced\", {\n reservation: { source: indexed, icon: { prefix: \"fas\", name: \"calendar\" },\n fields: { machine: { label: \"Machine\", hints: [\"press1\", \"lathe1\", \"mill1\"] }, crew: { label: \"Crew\", hints: [\"Day\", \"Night\"] }, start: { label: \"Dates\" } },\n range: \"start\", search: [\"machine\"],\n initial: { start: { from: new Date(\"2026-10-01T00:00:00Z\"), to: new Date(\"2026-10-02T00:00:00Z\") } } },\n }));\n return <Box height=\"680px\" width=\"100%\"><Calendar id=\"builtKeysSliced\" inspector\n view={{ layout: \"resources\", period: \"day\", date: new Date(\"2026-10-01T00:00:00Z\") }} now={new Date(\"2026-10-01T10:15:00Z\")}\n resources={{ machines: Calendar.resources(machines.read(), { name: \"Machines\", icon: \"gears\", label: row => row.name }) }}\n events={{ reservation: Calendar.events(held, { name: \"Reservation\", icon: \"calendar\", title: \"title\", start: \"start\", end: \"end\", resource: { field: \"machine\", of: \"machines\" }, entries,\n // A reservation's key, built from its row at the record's key type: a struct of its machine and its start.\n rowKey: row => ({ machine: row.machine, start: row.start }),\n }) }}\n slice={{ slice, affordances: [\"fields\", \"summary\"] }} />\n </Box>;\n }}</Reactive>)"
42033
+ },
41928
42034
  {
41929
42035
  "id": "e3-ui:calendar-records.examples.tsx:calendarRecordIndexes",
41930
42036
  "skill": "e3-ui",
@@ -42536,6 +42642,44 @@
42536
42642
  ],
42537
42643
  "source": "// Your edits meeting someone else's save, in one window — move or resize a job, then press Someone else saves, which saves another person's change to the same jobs (every job an hour later), so yours conflict, its dates one card to choose; a customer or hours you change in the panel combines with theirs\n// inputs: []\n/** The resources of a small metal fabrication shop. */\nexport const CalendarMachine = StructType({ name: StringType, area: StringType });\n\n/** A job's lifecycle. */\nexport const CalendarJobState = VariantType({ planned: NullType, active: NullType, done: NullType });\n\n/** A job may wait in the backlog; its own record holds its unscheduled rows. */\nexport const CalendarJob = StructType({ title: StringType, start: OptionType(DateTimeType), end: OptionType(DateTimeType), machine: OptionType(StringType),\n status: CalendarJobState, hours: FloatType, customer: StringType, due: OptionType(DateTimeType) });\n\nexport const calendarMachines = e3.record(\"calendar_machines\", DictType(StringType, CalendarMachine), {\n initial: new Map([\n [\"press1\", { name: \"Press 1\", area: \"Press shop\" }], [\"press2\", { name: \"Press 2\", area: \"Press shop\" }],\n [\"lathe1\", { name: \"Lathe 1\", area: \"Machine shop\" }], [\"lathe2\", { name: \"Lathe 2\", area: \"Machine shop\" }],\n ]),\n indexes: (index) => ({\n calendar_machines_by_area: index.on([\"area\"]),\n }),\n mutations: (mutation) => ({\n // The shop edits its machines and job templates elsewhere, each through its patch door; the Calendar reads them live.\n patch: mutation.patch(),\n }),\n});\n\n/** The jobs the conflicts example edits, in a record of their own, so no other example's edits meet them. */\nexport const calendarConflictJobs = e3.record(\"calendar_conflict_jobs\", DictType(StringType, CalendarJob), {\n initial: new Map([\n [\"job1\", { title: \"Mounting brackets\", start: some(new Date(\"2026-10-01T06:00:00Z\")), end: some(new Date(\"2026-10-01T10:00:00Z\")), machine: some(\"press1\"), status: variant(\"active\", null), hours: 4.0, customer: \"Alder Works\", due: none }],\n [\"job2\", { title: \"Pump housings\", start: some(new Date(\"2026-10-01T08:00:00Z\")), end: some(new Date(\"2026-10-01T13:00:00Z\")), machine: some(\"lathe1\"), status: variant(\"planned\", null), hours: 5.0, customer: \"Birch Engineering\", due: none }],\n [\"job3\", { title: \"Mounting plates\", start: some(new Date(\"2026-10-01T11:00:00Z\")), end: some(new Date(\"2026-10-01T12:30:00Z\")), machine: some(\"press2\"), status: variant(\"planned\", null), hours: 1.5, customer: \"Cedar Fabrication\", due: none }],\n [\"job4\", { title: \"Bearing collars\", start: some(new Date(\"2026-10-01T09:00:00Z\")), end: some(new Date(\"2026-10-01T12:00:00Z\")), machine: some(\"lathe2\"), status: variant(\"planned\", null), hours: 3.0, customer: \"Alder Works\", due: none }],\n ]),\n mutations: (mutation) => ({\n // The jobs' patch door — every Save commits through it.\n patch: mutation.patch(),\n // Someone else's save: every job an hour later, its length and its other fields as they were.\n elsewhere: mutation.reduce(East.function([DictType(StringType, CalendarJob)], DictType(StringType, CalendarJob), (_$, jobs) =>\n jobs.map((_$2, job) => ({\n title: job.title,\n start: job.start.match({\n some: (_$3, at) => East.value(some(at.addHours(1n)), OptionType(DateTimeType)),\n none: (_$3) => East.value(none, OptionType(DateTimeType)),\n }),\n end: job.end.match({\n some: (_$3, at) => East.value(some(at.addHours(1n)), OptionType(DateTimeType)),\n none: (_$3) => East.value(none, OptionType(DateTimeType)),\n }),\n machine: job.machine, status: job.status, hours: job.hours, customer: job.customer, due: job.due,\n })))),\n }),\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const machines = $.let(Record.bind(calendarMachines, []));\n const jobs = $.let(Record.bind(calendarConflictJobs, [\"patch\"]));\n const others = $.let(Record.bind(calendarConflictJobs, [\"elsewhere\"]));\n const theirs = $.const(East.function([], NullType, ($) => { $(others.mutate.elsewhere()); }));\n return <VStack gap=\"3\" align=\"stretch\">\n <HStack gap=\"3\">\n <Button variant=\"outline\" onClick={theirs} loading={others.mutate.pending()}>Someone else saves</Button>\n <Text color=\"fg.muted\">Their change: every job an hour later</Text>\n </HStack>\n <Box height=\"680px\"><Calendar id=\"conflicts\" inspector view={{ period: \"week\", date: new Date(\"2026-10-01T00:00:00Z\") }} now={new Date(\"2026-10-01T10:15:00Z\")}\n resources={{ machines: Calendar.resources(machines.read(), { name: \"Machines\", icon: \"gears\", label: row => row.name }) }}\n events={{ job: Calendar.events(jobs, { name: \"Production\", icon: \"industry\", title: \"title\", start: \"start\", end: \"end\", resource: { field: \"machine\", of: \"machines\" } }) }} />\n </Box>\n </VStack>;\n }}</Reactive>)"
42538
42644
  },
42645
+ {
42646
+ "id": "e3-ui:calendar.examples.tsx:calendarBuiltKeys",
42647
+ "skill": "e3-ui",
42648
+ "package": "e3-ui",
42649
+ "file": "east-ui/packages/e3-ui/test/calendar/calendar.examples.tsx",
42650
+ "suite": "",
42651
+ "test": "Events keyed by the key their row builds: machine reservations keyed by their machine and their start, with `rowKey` on the event kind — a function of the row, held to the record's key type. A reservation moved to another start or another machine moves under the key it then builds, and one that would build a key another reservation holds is refused, the Calendar naming the key — so no machine is reserved twice for one start. A copy stands under the key its own row builds. Give `rowKey` or `newKey`, never both; `keyField` names a field of the row that holds its key.",
42652
+ "keywords": [
42653
+ "Calendar",
42654
+ "Calendar.events",
42655
+ "Schedule.events",
42656
+ "rowKey",
42657
+ "built key",
42658
+ "key from the row",
42659
+ "row key",
42660
+ "composite key",
42661
+ "natural key",
42662
+ "East.str",
42663
+ "double booking",
42664
+ "key taken",
42665
+ "refused",
42666
+ "move",
42667
+ "Duplicate",
42668
+ "newKey",
42669
+ "keyField",
42670
+ "Record.bind"
42671
+ ],
42672
+ "imports": [
42673
+ "import { ArrayType, BooleanType, DateTimeType, DictType, East, FloatType, FunctionType, IntegerType, NullType, OptionType, SetType, StringType, StructType, VariantType, example, none, some, variant } from \"@elaraai/east\";",
42674
+ "import { Box, Button, HStack, Input, Reactive, Select, Slice, State, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
42675
+ "import { Calendar, Data, Record } from \"@elaraai/e3-ui\";",
42676
+ "import e3 from \"@elaraai/e3\";"
42677
+ ],
42678
+ "languages": [
42679
+ "tsx"
42680
+ ],
42681
+ "source": "// Events keyed by the key their row builds: machine reservations keyed by their machine and their start, with `rowKey` on the event kind — a function of the row, held to the record's key type. A reservation moved to another start or another machine moves under the key it then builds, and one that would build a key another reservation holds is refused, the Calendar naming the key — so no machine is reserved twice for one start. A copy stands under the key its own row builds. Give `rowKey` or `newKey`, never both; `keyField` names a field of the row that holds its key.\n// inputs: []\n/** The resources of a small metal fabrication shop. */\nexport const CalendarMachine = StructType({ name: StringType, area: StringType });\n\nexport const calendarMachines = e3.record(\"calendar_machines\", DictType(StringType, CalendarMachine), {\n initial: new Map([\n [\"press1\", { name: \"Press 1\", area: \"Press shop\" }], [\"press2\", { name: \"Press 2\", area: \"Press shop\" }],\n [\"lathe1\", { name: \"Lathe 1\", area: \"Machine shop\" }], [\"lathe2\", { name: \"Lathe 2\", area: \"Machine shop\" }],\n ]),\n indexes: (index) => ({\n calendar_machines_by_area: index.on([\"area\"]),\n }),\n mutations: (mutation) => ({\n // The shop edits its machines and job templates elsewhere, each through its patch door; the Calendar reads them live.\n patch: mutation.patch(),\n }),\n});\n\n/** A machine's reservation: the machine and the start its key is built from, what it is for, and when it ends. */\nexport const CalendarReservation = StructType({ machine: StringType, title: StringType, start: DateTimeType, end: DateTimeType });\n\n/** The reservations the built-keys example edits, each keyed as its machine and its start build it, in a record of their own. */\nexport const calendarReservations = e3.record(\"calendar_reservations\", DictType(StringType, CalendarReservation), {\n initial: new Map([\n [\"press1@2026-10-01T07:00:00.000\", { machine: \"press1\", title: \"Tool trial\", start: new Date(\"2026-10-01T07:00:00Z\"), end: new Date(\"2026-10-01T09:00:00Z\") }],\n [\"press1@2026-10-01T11:00:00.000\", { machine: \"press1\", title: \"Operator training\", start: new Date(\"2026-10-01T11:00:00Z\"), end: new Date(\"2026-10-01T12:30:00Z\") }],\n [\"lathe1@2026-10-01T07:00:00.000\", { machine: \"lathe1\", title: \"First-article run\", start: new Date(\"2026-10-01T07:00:00Z\"), end: new Date(\"2026-10-01T10:00:00Z\") }],\n ]),\n mutations: (mutation) => ({\n // The reservations' patch door — every Save commits through it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const machines = $.let(Record.bind(calendarMachines, []));\n const reservations = $.let(Record.bind(calendarReservations));\n return <Box height=\"640px\"><Calendar id=\"builtKeys\" inspector view={{ layout: \"resources\", period: \"day\", date: new Date(\"2026-10-01T00:00:00Z\") }} now={new Date(\"2026-10-01T10:15:00Z\")}\n resources={{ machines: Calendar.resources(machines.read(), { name: \"Machines\", icon: \"gears\", label: row => row.name }) }}\n events={{ reservation: Calendar.events(reservations, { name: \"Reservation\", icon: \"calendar\", title: \"title\", start: \"start\", end: \"end\", resource: { field: \"machine\", of: \"machines\" },\n // A reservation's key, built from its row: its machine and its start.\n rowKey: row => East.str`${row.machine}@${row.start}`,\n }) }} />\n </Box>;\n }}</Reactive>)"
42682
+ },
42539
42683
  {
42540
42684
  "id": "e3-ui:optimise.examples.tsx:calendarOptimise",
42541
42685
  "skill": "e3-ui",
@@ -43230,7 +43374,7 @@
43230
43374
  "IntegerType",
43231
43375
  "Integer keys",
43232
43376
  "struct keys",
43233
- "key",
43377
+ "rowKey",
43234
43378
  "Flowchart.transitions",
43235
43379
  "Connect",
43236
43380
  "Fields.select",
@@ -43251,7 +43395,7 @@
43251
43395
  "languages": [
43252
43396
  "tsx"
43253
43397
  ],
43254
- "source": "// A bakery's line over records keyed as the bakery keys them: its steps and its stations by number, a new one numbered one past the largest, and each move by the two steps it joins — Connect makes the move, then its key from its ends, and a second move between the same two steps is refused; each step's portioning a variant whose cases hold data, edited in the inspector as a choice with the chosen case's fields in a block under it, a new step's a whole loaf from the states' `values`\n// inputs: []\nexport const BakeryPortion = VariantType({ whole: NullType, sliced: IntegerType, weighed: StructType({ grams: FloatType, tolerance: FloatType }) });\n\nexport const BakeryStep = StructType({ name: StringType, station: IntegerType, seq: FloatType, portion: BakeryPortion });\n\nexport const BakeryStation = StructType({ label: StringType, seq: FloatType });\n\nexport const BakeryMoveKey = StructType({ from: IntegerType, to: IntegerType });\n\nexport const BakeryMove = StructType({ from: IntegerType, to: IntegerType, note: OptionType(StringType) });\n\nexport const bakerySteps = e3.record(\"flowchart_bakery_steps\", DictType(IntegerType, BakeryStep), {\n initial: new Map([\n [10n, { name: \"Mix\", station: 1n, seq: 1, portion: variant(\"whole\", null) }],\n [20n, { name: \"Proof\", station: 1n, seq: 2, portion: variant(\"whole\", null) }],\n [30n, { name: \"Bake\", station: 2n, seq: 1, portion: variant(\"whole\", null) }],\n [40n, { name: \"Cool\", station: 3n, seq: 1, portion: variant(\"sliced\", 12n) }],\n ]),\n mutations: (mutation) => ({ patch: mutation.patch() }),\n});\n\nexport const bakeryStations = e3.record(\"flowchart_bakery_stations\", DictType(IntegerType, BakeryStation), {\n initial: new Map([[1n, { label: \"Bench\", seq: 1 }], [2n, { label: \"Oven\", seq: 2 }], [3n, { label: \"Cooling\", seq: 3 }]]),\n mutations: (mutation) => ({ patch: mutation.patch() }),\n});\n\nexport const bakeryMoves = e3.record(\"flowchart_bakery_moves\", DictType(BakeryMoveKey, BakeryMove), {\n initial: new SortedMap([\n [{ from: 10n, to: 20n }, { from: 10n, to: 20n, note: none }],\n [{ from: 20n, to: 30n }, { from: 20n, to: 30n, note: none }],\n [{ from: 30n, to: 40n }, { from: 30n, to: 40n, note: none }],\n ], compareFor(BakeryMoveKey)),\n mutations: (mutation) => ({ patch: mutation.patch() }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const steps = $.let(Record.bind(bakerySteps));\n const moves = $.let(Record.bind(bakeryMoves));\n const stations = $.let(Record.bind(bakeryStations));\n return (\n <Box height=\"560px\">\n <Flowchart\n states={Flowchart.states(steps, {\n label: \"name\", lane: \"station\", order: \"seq\",\n // A new step starts as a whole loaf. Its portion's type default, Sliced at 0, is under the\n // least its Slices field allows: the form holds what it makes to that least, never a value given it.\n values: () => ({ portion: variant(\"whole\", null) }),\n fields: {\n // A variant whose cases hold data: a choice, and the chosen case's fields in a block under it.\n portion: Fields.select({\n labels: { whole: \"Whole loaf\", sliced: \"Sliced\", weighed: \"By weight\" },\n cases: { sliced: Fields.number({ label: \"Slices\", unit: \"slices\", min: 1n }), weighed: { grams: Fields.number({ unit: \"g\", min: 0 }) } },\n }),\n },\n })}\n transitions={Flowchart.transitions(moves, {\n from: \"from\", to: \"to\",\n // Connect makes the row, then its key from it: a move is keyed by its two ends.\n key: (move) => ({ from: move.from, to: move.to }),\n })}\n lanes={Flowchart.lanes(stations, { label: \"label\", order: \"seq\" })}\n name=\"bakery\"\n />\n </Box>\n );\n }}</Reactive>\n ))"
43398
+ "source": "// A bakery's line over records keyed as the bakery keys them: its steps and its stations by number, a new one numbered one past the largest, and each move by the two steps it joins — Connect makes the move, then its key from its ends, and a second move between the same two steps is refused; each step's portioning a variant whose cases hold data, edited in the inspector as a choice with the chosen case's fields in a block under it, a new step's a whole loaf from the states' `values`\n// inputs: []\nexport const BakeryPortion = VariantType({ whole: NullType, sliced: IntegerType, weighed: StructType({ grams: FloatType, tolerance: FloatType }) });\n\nexport const BakeryStep = StructType({ name: StringType, station: IntegerType, seq: FloatType, portion: BakeryPortion });\n\nexport const BakeryStation = StructType({ label: StringType, seq: FloatType });\n\nexport const BakeryMoveKey = StructType({ from: IntegerType, to: IntegerType });\n\nexport const BakeryMove = StructType({ from: IntegerType, to: IntegerType, note: OptionType(StringType) });\n\nexport const bakerySteps = e3.record(\"flowchart_bakery_steps\", DictType(IntegerType, BakeryStep), {\n initial: new Map([\n [10n, { name: \"Mix\", station: 1n, seq: 1, portion: variant(\"whole\", null) }],\n [20n, { name: \"Proof\", station: 1n, seq: 2, portion: variant(\"whole\", null) }],\n [30n, { name: \"Bake\", station: 2n, seq: 1, portion: variant(\"whole\", null) }],\n [40n, { name: \"Cool\", station: 3n, seq: 1, portion: variant(\"sliced\", 12n) }],\n ]),\n mutations: (mutation) => ({ patch: mutation.patch() }),\n});\n\nexport const bakeryStations = e3.record(\"flowchart_bakery_stations\", DictType(IntegerType, BakeryStation), {\n initial: new Map([[1n, { label: \"Bench\", seq: 1 }], [2n, { label: \"Oven\", seq: 2 }], [3n, { label: \"Cooling\", seq: 3 }]]),\n mutations: (mutation) => ({ patch: mutation.patch() }),\n});\n\nexport const bakeryMoves = e3.record(\"flowchart_bakery_moves\", DictType(BakeryMoveKey, BakeryMove), {\n initial: new SortedMap([\n [{ from: 10n, to: 20n }, { from: 10n, to: 20n, note: none }],\n [{ from: 20n, to: 30n }, { from: 20n, to: 30n, note: none }],\n [{ from: 30n, to: 40n }, { from: 30n, to: 40n, note: none }],\n ], compareFor(BakeryMoveKey)),\n mutations: (mutation) => ({ patch: mutation.patch() }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const steps = $.let(Record.bind(bakerySteps));\n const moves = $.let(Record.bind(bakeryMoves));\n const stations = $.let(Record.bind(bakeryStations));\n return (\n <Box height=\"560px\">\n <Flowchart\n states={Flowchart.states(steps, {\n label: \"name\", lane: \"station\", order: \"seq\",\n // A new step starts as a whole loaf. Its portion's type default, Sliced at 0, is under the\n // least its Slices field allows: the form holds what it makes to that least, never a value given it.\n values: () => ({ portion: variant(\"whole\", null) }),\n fields: {\n // A variant whose cases hold data: a choice, and the chosen case's fields in a block under it.\n portion: Fields.select({\n labels: { whole: \"Whole loaf\", sliced: \"Sliced\", weighed: \"By weight\" },\n cases: { sliced: Fields.number({ label: \"Slices\", unit: \"slices\", min: 1n }), weighed: { grams: Fields.number({ unit: \"g\", min: 0 }) } },\n }),\n },\n })}\n transitions={Flowchart.transitions(moves, {\n from: \"from\", to: \"to\",\n // Connect makes the row, then its key from it: a move is keyed by its two ends.\n rowKey: (move) => ({ from: move.from, to: move.to }),\n })}\n lanes={Flowchart.lanes(stations, { label: \"label\", order: \"seq\" })}\n name=\"bakery\"\n />\n </Box>\n );\n }}</Reactive>\n ))"
43255
43399
  },
43256
43400
  {
43257
43401
  "id": "e3-ui:ontology.examples.tsx:supplyChainOntology",
@@ -44349,7 +44493,7 @@
44349
44493
  "import { Reactive, Slice, UIComponentType } from \"@elaraai/east-ui\";",
44350
44494
  "import { Data, Plan, Record, Schedule } from \"@elaraai/e3-ui\";",
44351
44495
  "import e3 from \"@elaraai/e3\";",
44352
- "import { PrintJob, PrintPress } from \"./plan-events.examples.js\";"
44496
+ "import { PrintJob, PrintJobKey, PrintKeyedJobs, PrintPress } from \"./plan-events.examples.js\";"
44353
44497
  ],
44354
44498
  "languages": [
44355
44499
  "tsx"
@@ -44396,13 +44540,51 @@
44396
44540
  "import { Reactive, Slice, UIComponentType } from \"@elaraai/east-ui\";",
44397
44541
  "import { Data, Plan, Record, Schedule } from \"@elaraai/e3-ui\";",
44398
44542
  "import e3 from \"@elaraai/e3\";",
44399
- "import { PrintJob, PrintPress } from \"./plan-events.examples.js\";"
44543
+ "import { PrintJob, PrintJobKey, PrintKeyedJobs, PrintPress } from \"./plan-events.examples.js\";"
44400
44544
  ],
44401
44545
  "languages": [
44402
44546
  "tsx"
44403
44547
  ],
44404
44548
  "source": "// The Plan of planWindows, its 2,000 presses a record narrowed by hall through the rail — its `rows` source, `Data.bindPaged(record, { indexes })` over the presses' hall index, laid out by a `Plan.series.resources` — the canvas paging the narrowing's presses themselves in the index's order, counting the hall's, and reading the jobs' cells for the presses of the hall in view alone; a choice keeps the last view standing until its presses land, and drafts Save whatever the halls chosen\n// inputs: []\n/** A press's key: `P-` and its number plus 1,000 — fixed width, so key order is number order. */\nconst pressKey = East.function([IntegerType], StringType, (_$, n) => East.str`P-${n.add(1_001n)}`);\n\n/**\n * The presses, generated from their count, by key: each named by its number,\n * in one of eight halls, printing 6,000 to 15,000 sheets an hour.\n */\nexport const generateWindowPresses = East.function([IntegerType], DictType(StringType, PrintPress), (_$, count) =>\n East.Array.range(0n, count).toDict(\n (_$2, n) => pressKey(n),\n (_$2, n) => ({\n name: East.str`Press ${n.add(1_001n)}`,\n hall: East.str`Hall ${n.remainder(8n).add(1n)}`,\n sheets_per_hour: n.remainder(10n).multiply(1_000n).add(6_000n).toFloat(),\n }),\n ));\n\n/**\n * The works' 2,000 presses as a record of their own (#1344): the presses\n * `generateWindowPresses` makes, stored, so the rail narrows them — the rail's\n * `rows` source is an index of the record its rows are read from.\n */\nexport const planSeriesPresses = e3.record(\"plan_series_presses\", DictType(StringType, PrintPress), {\n initial: () => East.compile(generateWindowPresses, [])(2_000n),\n indexes: (index) => ({\n // The presses by hall (#1344): each hall's presses, in their key order — what\n // the rail's `presses` source narrows them through, and the order a Plan pages\n // the presses of the halls chosen in.\n plan_series_presses_by_hall: index.on([\"hall\"]),\n }),\n});\n\n/**\n * The print jobs on the presses, from Monday 5 October 2026: a night run into\n * the next day, a run over three days, jobs on presses in each window of 200,\n * jobs in the weeks after the first two, and four waiting in the backlog.\n *\n * @returns The jobs, by their keys\n */\nfunction windowJobs(): ValueTypeOf<DictType<StringType, typeof PrintJob>> {\n return new Map([\n [\"W-0001\", { title: \"Brochure run\", start: some(new Date(\"2026-10-05T06:00:00Z\")), end: some(new Date(\"2026-10-05T14:00:00Z\")), press: some(\"P-1001\"), state: variant(\"actual\", null), sheets: 40000.0, customer: \"Alder & Finch\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-07T00:00:00Z\")) }],\n [\"W-0002\", { title: \"Night catalogue\", start: some(new Date(\"2026-10-05T22:00:00Z\")), end: some(new Date(\"2026-10-06T06:00:00Z\")), press: some(\"P-1001\"), state: variant(\"actual\", null), sheets: 96000.0, customer: \"Larkspur Home\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-08T00:00:00Z\")) }],\n [\"W-0003\", { title: \"Museum guide\", start: some(new Date(\"2026-10-06T06:00:00Z\")), end: some(new Date(\"2026-10-06T12:00:00Z\")), press: some(\"P-1002\"), state: variant(\"actual\", null), sheets: 72000.0, customer: \"Driftwood Museum\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-09T00:00:00Z\")) }],\n [\"W-0004\", { title: \"Course handbooks\", start: some(new Date(\"2026-10-07T06:00:00Z\")), end: some(new Date(\"2026-10-09T18:00:00Z\")), press: some(\"P-1003\"), state: variant(\"confirmed\", null), sheets: 144000.0, customer: \"Elmway College\", stock: variant(\"uncoated\", null), due: some(new Date(\"2026-10-12T00:00:00Z\")) }],\n [\"W-0005\", { title: \"Event posters\", start: some(new Date(\"2026-10-12T07:00:00Z\")), end: some(new Date(\"2026-10-12T12:00:00Z\")), press: some(\"P-1004\"), state: variant(\"confirmed\", null), sheets: 60000.0, customer: \"Granite Hall\", stock: variant(\"uncoated\", null), due: some(new Date(\"2026-10-13T00:00:00Z\")) }],\n [\"W-0006\", { title: \"Menu cards\", start: some(new Date(\"2026-10-14T06:00:00Z\")), end: some(new Date(\"2026-10-14T08:00:00Z\")), press: some(\"P-1010\"), state: variant(\"in-progress\", null), sheets: 24000.0, customer: \"Copperleaf Cafe\", stock: variant(\"board\", null), due: some(new Date(\"2026-10-15T00:00:00Z\")) }],\n [\"W-0007\", { title: \"Seed catalogue\", start: some(new Date(\"2026-10-15T06:00:00Z\")), end: some(new Date(\"2026-10-15T16:00:00Z\")), press: some(\"P-1150\"), state: variant(\"proposed\", variant(\"added\", null)), sheets: 100000.0, customer: \"Foxglove Gardens\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-17T00:00:00Z\")) }],\n [\"W-0008\", { title: \"Tour brochure\", start: some(new Date(\"2026-10-16T06:00:00Z\")), end: some(new Date(\"2026-10-16T14:00:00Z\")), press: some(\"P-1200\"), state: variant(\"proposed\", variant(\"recommended\", null)), sheets: 80000.0, customer: \"Bluewater Tours\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-19T00:00:00Z\")) }],\n [\"W-0009\", { title: \"Timetables\", start: some(new Date(\"2026-10-08T06:00:00Z\")), end: some(new Date(\"2026-10-08T10:00:00Z\")), press: some(\"P-1201\"), state: variant(\"actual\", null), sheets: 48000.0, customer: \"Bluewater Tours\", stock: variant(\"uncoated\", null), due: some(new Date(\"2026-10-09T00:00:00Z\")) }],\n [\"W-0010\", { title: \"Annual report\", start: some(new Date(\"2026-10-13T06:00:00Z\")), end: some(new Date(\"2026-10-13T12:00:00Z\")), press: some(\"P-1250\"), state: variant(\"confirmed\", null), sheets: 60000.0, customer: \"Harbour Arts Society\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-16T00:00:00Z\")) }],\n [\"W-0011\", { title: \"Gift boxes\", start: some(new Date(\"2026-10-09T06:00:00Z\")), end: some(new Date(\"2026-10-09T12:00:00Z\")), press: some(\"P-1333\"), state: variant(\"confirmed\", null), sheets: 48000.0, customer: \"Juniper Toys\", stock: variant(\"board\", null), due: some(new Date(\"2026-10-12T00:00:00Z\")) }],\n [\"W-0012\", { title: \"Store flyers\", start: some(new Date(\"2026-10-14T06:00:00Z\")), end: some(new Date(\"2026-10-14T16:00:00Z\")), press: some(\"P-1401\"), state: variant(\"in-progress\", null), sheets: 150000.0, customer: \"Northwind Outfitters\", stock: variant(\"uncoated\", null), due: some(new Date(\"2026-10-16T00:00:00Z\")) }],\n [\"W-0013\", { title: \"Magazine run\", start: some(new Date(\"2026-10-15T06:00:00Z\")), end: some(new Date(\"2026-10-16T18:00:00Z\")), press: some(\"P-1460\"), state: variant(\"proposed\", variant(\"added\", null)), sheets: 180000.0, customer: \"Meridian Monthly\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-19T00:00:00Z\")) }],\n [\"W-0014\", { title: \"Ticket books\", start: some(new Date(\"2026-10-22T06:00:00Z\")), end: some(new Date(\"2026-10-22T08:00:00Z\")), press: some(\"P-1001\"), state: variant(\"estimated\", null), sheets: 24000.0, customer: \"Heathfield Theatre\", stock: variant(\"uncoated\", null), due: some(new Date(\"2026-10-26T00:00:00Z\")) }],\n [\"W-0015\", { title: \"Wall calendars\", start: some(new Date(\"2026-10-26T06:00:00Z\")), end: some(new Date(\"2026-10-26T18:00:00Z\")), press: some(\"P-1002\"), state: variant(\"estimated\", null), sheets: 50000.0, customer: \"Foxglove Gardens\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-30T00:00:00Z\")) }],\n [\"W-0016\", { title: \"Exhibition book\", start: some(new Date(\"2026-10-28T06:00:00Z\")), end: some(new Date(\"2026-10-28T12:00:00Z\")), press: some(\"P-1470\"), state: variant(\"estimated\", null), sheets: 54000.0, customer: \"Driftwood Museum\", stock: variant(\"coated\", null), due: some(new Date(\"2026-11-02T00:00:00Z\")) }],\n [\"W-0017\", { title: \"Order forms\", start: none, end: none, press: none, state: variant(\"estimated\", null), sheets: 40000.0, customer: \"Larkspur Home\", stock: variant(\"uncoated\", null), due: some(new Date(\"2026-10-16T00:00:00Z\")) }],\n [\"W-0018\", { title: \"Winter brochure\", start: none, end: none, press: none, state: variant(\"estimated\", null), sheets: 64000.0, customer: \"Bluewater Tours\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-21T00:00:00Z\")) }],\n [\"W-0019\", { title: \"Prospectus\", start: none, end: none, press: none, state: variant(\"estimated\", null), sheets: 100000.0, customer: \"Elmway College\", stock: variant(\"coated\", null), due: some(new Date(\"2026-10-30T00:00:00Z\")) }],\n [\"W-0020\", { title: \"Proof sheets\", start: none, end: none, press: none, state: variant(\"estimated\", null), sheets: 2000.0, customer: \"Alder & Finch\", stock: variant(\"uncoated\", null), due: none }],\n ]);\n}\n\n/** The print jobs on the presses ({@link windowJobs}), read through their indexes. */\nexport const planWindowJobs = e3.record(\"plan_window_jobs\", DictType(StringType, PrintJob), {\n initial: windowJobs(),\n indexes: (index) => ({\n // The jobs over their interval index (#1344): a job is filed by the interval\n // it runs over, so a window reads each job overlapping it once, however many\n // days it runs, and a job in the backlog under its Unset start — what the\n // rail's `job` source narrows them through.\n plan_window_jobs_by_time: index.interval({ from: \"start\", to: \"end\" }),\n // The jobs by the press each is on and by time (#1039): a job is filed once,\n // at the level its length fits from the week up, carrying its row (#1433), so\n // a press's jobs at a level over any span are one contiguous range of the\n // index — fifty presses' ranges a cell — and `planWindows` reads only the\n // cells around the rows in view.\n plan_window_jobs_by_press_week: index.series({\n key: \"press\", from: \"start\", to: \"end\", tile: \"week\",\n }),\n // How busy each press is, a month at a time (#1039): under each press and\n // month, how many jobs touch it and the milliseconds of it they cover — what\n // `planWindows` shades where the jobs in view are too many to draw.\n plan_window_jobs_by_press_month: index.summary({\n key: \"press\", from: \"start\", to: \"end\", tile: \"month\",\n }),\n // The jobs' monthly summary declared again (#1039): no example lists it — a\n // Plan refuses two summaries of one tile over the same fields, naming both,\n // and the series spec lists it beside `planWindowJobsByPressMonth` to see it\n // refused.\n plan_window_jobs_by_press_month_again: index.summary({\n key: \"press\", from: \"start\", to: \"end\", tile: \"month\",\n }),\n // The jobs by the days each touches (`Schedule.days`): a scheduled job is\n // filed under every day it runs into, and a job in the backlog under none —\n // the index a kind with no rail reads the days in view through (`window`), on\n // a Calendar's resources read whole: over paged rows, a Plan refuses it.\n plan_window_jobs_by_day: index.keys(East.function([StringType, PrintJob], SetType(DateTimeType), ($, _id, job) => {\n const days = $.const(Schedule.days);\n const filed = $.let(new Set<Date>(), SetType(DateTimeType));\n $.match(job.start, {\n some: ($2, start) => {\n $2.match(job.end, { some: ($3, end) => { $3.assign(filed, days(start, end)); } });\n },\n });\n return filed;\n })),\n // The jobs with no start, by when they are due (`Schedule.unscheduled`): the\n // index a kind with no rail reads its backlog through (`backlogWindow`), and\n // nothing scheduled in it.\n plan_window_jobs_unscheduled: index.keys(East.function([StringType, PrintJob], SetType(OptionType(DateTimeType)), ($, _id, job) => {\n const unscheduled = $.const(Schedule.unscheduled);\n return unscheduled(job.start, job.due);\n })),\n }),\n mutations: (mutation) => ({\n // The jobs' patch door: every Save commits through it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => {\n return (<Reactive>{$ => {\n const jobs = $.let(Record.bind(planWindowJobs));\n const jobEntries = $.let(Data.bindPaged(planWindowJobs));\n // The `rows` source narrows the presses by hall, through their hall index: the canvas pages the narrowing's\n // presses. The `job` source reads the jobs a cell at a time, as in planWindows.\n const slice = $.let(Slice.bindRecords(\"ex.plan.series.halls\", {\n rows: { source: Data.bindPaged(planSeriesPresses, { indexes: [\"plan_series_presses_by_hall\"] }), label: \"Presses\",\n icon: { prefix: \"fas\", name: \"print\" },\n fields: { hall: { label: \"Hall\", hints: [\"Hall 1\", \"Hall 2\", \"Hall 3\", \"Hall 4\", \"Hall 5\", \"Hall 6\", \"Hall 7\", \"Hall 8\"] } } },\n job: { source: Data.bindPaged(planWindowJobs, { indexes: [\"plan_window_jobs_by_time\", \"plan_window_jobs_by_press_week\", \"plan_window_jobs_by_press_month\"] }),\n label: \"Print jobs\", fields: { start: { label: \"Dates\" } }, range: \"start\" },\n }));\n const axis = $.let(Plan.axis({\n window: { min: new Date(\"2026-10-05T00:00:00Z\"), max: new Date(\"2026-10-19T00:00:00Z\") },\n resolution: \"day\", resolutions: [\"day\", \"week\", \"month\", \"quarter\"], now: new Date(\"2026-10-14T09:00:00Z\"),\n }));\n return (\n <Plan\n id=\"series-halls\"\n axis={axis}\n slice={{ slice }}\n // Its rows are presses: the rail counts them so, and the footer's line names them so.\n vocabulary={{ rows: { one: \"Press\", other: \"Presses\" } }}\n series={[Plan.series.resources(PrintPress, {\n key: \"presses\", title: \"Presses\", icon: \"print\", label: p => p.name,\n sub: (p, key) => some(East.str`${key} · ${p.hall}`),\n })]}\n events={{\n job: Schedule.events(jobs, {\n name: \"Print job\", icon: \"file-lines\",\n title: \"title\", start: \"start\", end: \"end\",\n resource: { field: \"press\", of: \"presses\" },\n state: \"state\", quantity: { field: \"sheets\", unit: \"sheets\" },\n backlog: { duration: j => variant(\"hours\", j.sheets.divide(8000.0)), due: j => j.due },\n entries: jobEntries,\n }),\n }}\n library={[Plan.library.backlog()]}\n style={{ height: \"480px\" }}\n />\n );\n }}</Reactive>);\n })"
44405
44549
  },
44550
+ {
44551
+ "id": "e3-ui:plan-windows.examples.tsx:planTypedKeysPaged",
44552
+ "skill": "e3-ui",
44553
+ "package": "e3-ui",
44554
+ "file": "east-ui/packages/e3-ui/test/plan/plan-windows.examples.tsx",
44555
+ "suite": "",
44556
+ "test": "planTypedKeys over rows read a page at a time: its jobs keyed by a variant — an order's number or a sample's, as a composite record keys its rows by their source — on the 2,000 presses of planSeriesByHall, the rail's `rows` source paging them by hall, and the jobs read a cell at a time through their own source of the rail (interval, series and summary indexes): a record keyed by any type a Dict takes is a source of the rail in every builder, and each job is drawn, selected, dragged and saved under its own typed key",
44557
+ "keywords": [
44558
+ "Plan",
44559
+ "keyType",
44560
+ "variant key",
44561
+ "typed key",
44562
+ "composite",
44563
+ "Slice",
44564
+ "Slice.bindRecords",
44565
+ "rows source",
44566
+ "source",
44567
+ "interval index",
44568
+ "series index",
44569
+ "summary index",
44570
+ "paged",
44571
+ "Data.bindPaged",
44572
+ "Schedule.events",
44573
+ "entries",
44574
+ "#1696"
44575
+ ],
44576
+ "imports": [
44577
+ "import {",
44578
+ "import { Reactive, Slice, UIComponentType } from \"@elaraai/east-ui\";",
44579
+ "import { Data, Plan, Record, Schedule } from \"@elaraai/e3-ui\";",
44580
+ "import e3 from \"@elaraai/e3\";",
44581
+ "import { PrintJob, PrintJobKey, PrintKeyedJobs, PrintPress } from \"./plan-events.examples.js\";"
44582
+ ],
44583
+ "languages": [
44584
+ "tsx"
44585
+ ],
44586
+ "source": "// planTypedKeys over rows read a page at a time: its jobs keyed by a variant — an order's number or a sample's, as a composite record keys its rows by their source — on the 2,000 presses of planSeriesByHall, the rail's `rows` source paging them by hall, and the jobs read a cell at a time through their own source of the rail (interval, series and summary indexes): a record keyed by any type a Dict takes is a source of the rail in every builder, and each job is drawn, selected, dragged and saved under its own typed key\n// inputs: []\n/** A press's key: `P-` and its number plus 1,000 — fixed width, so key order is number order. */\nconst pressKey = East.function([IntegerType], StringType, (_$, n) => East.str`P-${n.add(1_001n)}`);\n\n/**\n * The presses, generated from their count, by key: each named by its number,\n * in one of eight halls, printing 6,000 to 15,000 sheets an hour.\n */\nexport const generateWindowPresses = East.function([IntegerType], DictType(StringType, PrintPress), (_$, count) =>\n East.Array.range(0n, count).toDict(\n (_$2, n) => pressKey(n),\n (_$2, n) => ({\n name: East.str`Press ${n.add(1_001n)}`,\n hall: East.str`Hall ${n.remainder(8n).add(1n)}`,\n sheets_per_hour: n.remainder(10n).multiply(1_000n).add(6_000n).toFloat(),\n }),\n ));\n\n/**\n * The works' 2,000 presses as a record of their own (#1344): the presses\n * `generateWindowPresses` makes, stored, so the rail narrows them — the rail's\n * `rows` source is an index of the record its rows are read from.\n */\nexport const planSeriesPresses = e3.record(\"plan_series_presses\", DictType(StringType, PrintPress), {\n initial: () => East.compile(generateWindowPresses, [])(2_000n),\n indexes: (index) => ({\n // The presses by hall (#1344): each hall's presses, in their key order — what\n // the rail's `presses` source narrows them through, and the order a Plan pages\n // the presses of the halls chosen in.\n plan_series_presses_by_hall: index.on([\"hall\"]),\n }),\n});\n\n/**\n * The jobs of `planTypedKeys` again — each keyed by which it is, an order by its number or a sample by its own, as a\n * composite record keys its rows by the source each came from — on the first presses of `planSeriesByHall`'s 2,000,\n * filed as the windows' jobs are: by their times, by press and week, and each press's busy share by month.\n */\nexport const planKeyedWindowJobs = e3.record(\"plan_keyed_window_jobs\", PrintKeyedJobs, {\n initial: new SortedMap<ValueTypeOf<typeof PrintJobKey>, ValueTypeOf<typeof PrintJob>>([\n [variant(\"order\", \"J-8001\"), { title: \"Trade catalogue\", start: some(new Date(\"2026-10-06T06:00:00Z\")), end: some(new Date(\"2026-10-06T18:00:00Z\")), press: some(\"P-1001\"), state: variant(\"confirmed\", null), sheets: 96000.0, customer: \"\", stock: variant(\"coated\", null), due: none }],\n [variant(\"order\", \"J-8002\"), { title: \"Trade price list\", start: some(new Date(\"2026-10-07T06:00:00Z\")), end: some(new Date(\"2026-10-07T14:00:00Z\")), press: some(\"P-1002\"), state: variant(\"confirmed\", null), sheets: 24000.0, customer: \"\", stock: variant(\"coated\", null), due: none }],\n [variant(\"sample\", 1n), { title: \"Catalogue proof\", start: some(new Date(\"2026-10-05T09:00:00Z\")), end: some(new Date(\"2026-10-05T11:00:00Z\")), press: some(\"P-1001\"), state: variant(\"confirmed\", null), sheets: 200.0, customer: \"\", stock: variant(\"coated\", null), due: none }],\n [variant(\"sample\", 2n), { title: \"Price list proof\", start: some(new Date(\"2026-10-06T13:00:00Z\")), end: some(new Date(\"2026-10-06T15:00:00Z\")), press: some(\"P-1002\"), state: variant(\"confirmed\", null), sheets: 100.0, customer: \"\", stock: variant(\"coated\", null), due: none }],\n ], compareFor(PrintJobKey)),\n indexes: (index) => ({\n // What the rail's `job` source narrows them through: the window, its count, and the backlog.\n plan_keyed_window_jobs_by_time: index.interval({ from: \"start\", to: \"end\" }),\n // The cells the canvas reads them by: the presses around the rows in view, over the weeks the window touches.\n plan_keyed_window_jobs_by_press_week: index.series({\n key: \"press\", from: \"start\", to: \"end\", tile: \"week\",\n }),\n // What the canvas shades zoomed out past what it draws.\n plan_keyed_window_jobs_by_press_month: index.summary({\n key: \"press\", from: \"start\", to: \"end\", tile: \"month\",\n }),\n }),\n mutations: (mutation) => ({\n // Their patch door: every Save commits through it, each job by its typed key.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => {\n return (<Reactive>{$ => {\n const jobs = $.let(Record.bind(planKeyedWindowJobs));\n const jobEntries = $.let(Data.bindPaged(planKeyedWindowJobs));\n // The presses paged by hall through the `rows` source; the jobs, keyed by a variant, a cell at a time through theirs.\n const slice = $.let(Slice.bindRecords(\"ex.plan.typedKeysPaged\", {\n rows: { source: Data.bindPaged(planSeriesPresses, { indexes: [\"plan_series_presses_by_hall\"] }), label: \"Presses\",\n icon: { prefix: \"fas\", name: \"print\" },\n fields: { hall: { label: \"Hall\", hints: [\"Hall 1\", \"Hall 2\", \"Hall 3\", \"Hall 4\", \"Hall 5\", \"Hall 6\", \"Hall 7\", \"Hall 8\"] } } },\n job: { source: Data.bindPaged(planKeyedWindowJobs, { indexes: [\"plan_keyed_window_jobs_by_time\", \"plan_keyed_window_jobs_by_press_week\", \"plan_keyed_window_jobs_by_press_month\"] }),\n label: \"Print jobs\", fields: { start: { label: \"Dates\" } }, range: \"start\" },\n }));\n const axis = $.let(Plan.axis({\n window: { min: new Date(\"2026-10-05T00:00:00Z\"), max: new Date(\"2026-10-19T00:00:00Z\") },\n resolution: \"day\", resolutions: [\"day\", \"week\", \"month\", \"quarter\"], now: new Date(\"2026-10-14T09:00:00Z\"),\n }));\n return (\n <Plan\n id=\"typed-keys-paged\"\n axis={axis}\n slice={{ slice }}\n vocabulary={{ rows: { one: \"Press\", other: \"Presses\" } }}\n series={[Plan.series.resources(PrintPress, {\n key: \"presses\", title: \"Presses\", icon: \"print\", label: p => p.name,\n sub: (p, key) => some(East.str`${key} · ${p.hall}`),\n })]}\n events={{\n job: Schedule.events(jobs, {\n name: \"Print job\", icon: \"file-lines\",\n title: \"title\", start: \"start\", end: \"end\",\n resource: { field: \"press\", of: \"presses\" },\n state: \"state\", quantity: { field: \"sheets\", unit: \"sheets\" },\n entries: jobEntries,\n }),\n }}\n inspector\n style={{ height: \"480px\" }}\n />\n );\n }}</Reactive>);\n })"
44587
+ },
44406
44588
  {
44407
44589
  "id": "e3-ui:plan.examples.tsx:planTargetState",
44408
44590
  "skill": "e3-ui",
@@ -45438,6 +45620,89 @@
45438
45620
  ],
45439
45621
  "source": "// The query library over the same record and data sources: one toolbar — the search, Sort, Grid · List and \"+ New query on orders\" — beside the data sources with their counts of saved queries and this viewer's recent runs; the seven saved queries as a gallery, each card a wireframe of its steps with its name, its description and what it gives, and \"Open in builder →\", which opens the query in the builder that shares its id\n// inputs: []\n/** One line of an order: a SKU, its unit price and the quantity ordered. */\nconst Line = StructType({ price: FloatType, qty: IntegerType, sku: StringType });\n\n/** Where an order stands: cancelled for a reason, pending, or shipped on a date. */\nconst Status = VariantType({ cancelled: StructType({ reason: StringType }), pending: NullType, shipped: StructType({ date: DateTimeType }) });\n\n/** An order: `discount` is the fraction taken off, when there is one, and `total` the lines' gross less it, to the cent. */\nconst Order = StructType({\n customer_id: StringType, discount: OptionType(FloatType), id: IntegerType, lines: ArrayType(Line), status: Status, total: FloatType,\n});\n\n/** A customer's tier. */\nconst Tier = VariantType({ gold: NullType, standard: NullType });\n\n/** A customer, and their tier. */\nconst Customer = StructType({ name: StringType, region: StringType, tier: Tier });\n\n/** Weekly demand by region: eight weeks, the first at index 0. */\nconst Forecast = StructType({ regions: DictType(StringType, StructType({ weekly: ArrayType(FloatType) })) });\n\n/** A part and the parts it is built from: a bill of materials. */\nconst Part = RecursiveType(self => StructType({ children: ArrayType(self), cost: FloatType, sku: StringType }));\n\n/** The demand model: units sold at a unit price in a region. */\nconst ModelInput = StructType({ price: FloatType, region: StringType });\n\nconst Model = FunctionType([ModelInput], FloatType);\n\n/** The orders, ids 1001–1040, in id order: the mock's forty, drawn from seed 875 (`Query Editor Spec.md` §6). */\nexport const orders = e3.input(\"orders\", ArrayType(Order), variant(\"value\", [\n { id: 1001n, customer_id: \"C01\", discount: some(0.1), total: 80.1, status: variant(\"shipped\", { date: new Date(\"2026-04-27T09:00:00.000Z\") }),\n lines: [{ price: 8.9, qty: 10n, sku: \"HNG-220\" }] },\n { id: 1002n, customer_id: \"C07\", discount: none, total: 1171.58, status: variant(\"shipped\", { date: new Date(\"2026-01-15T16:00:00.000Z\") }),\n lines: [{ price: 0.85, qty: 38n, sku: \"BLT-045\" }, { price: 46.0, qty: 24n, sku: \"PLT-310\" }, { price: 0.18, qty: 196n, sku: \"WSH-008\" }] },\n { id: 1003n, customer_id: \"C02\", discount: none, total: 453.0, status: variant(\"shipped\", { date: new Date(\"2026-04-06T16:00:00.000Z\") }),\n lines: [{ price: 12.4, qty: 15n, sku: \"BRK-100\" }, { price: 8.9, qty: 30n, sku: \"HNG-220\" }] },\n { id: 1004n, customer_id: \"C05\", discount: some(0.15), total: 128.61, status: variant(\"pending\", null),\n lines: [{ price: 8.9, qty: 17n, sku: \"HNG-220\" }] },\n { id: 1005n, customer_id: \"C02\", discount: none, total: 520.24, status: variant(\"pending\", null),\n lines: [{ price: 46.0, qty: 6n, sku: \"PLT-310\" }, { price: 12.4, qty: 19n, sku: \"BRK-100\" }, { price: 0.18, qty: 48n, sku: \"WSH-008\" }] },\n { id: 1006n, customer_id: \"C06\", discount: none, total: 210.8, status: variant(\"shipped\", { date: new Date(\"2026-06-03T14:00:00.000Z\") }),\n lines: [{ price: 12.4, qty: 17n, sku: \"BRK-100\" }] },\n { id: 1007n, customer_id: \"C05\", discount: some(0.1), total: 1162.92, status: variant(\"shipped\", { date: new Date(\"2026-04-06T09:00:00.000Z\") }),\n lines: [{ price: 0.32, qty: 184n, sku: \"SCR-012\" }, { price: 64.5, qty: 5n, sku: \"RAL-900\" }, { price: 46.0, qty: 7n, sku: \"PLT-310\" }, { price: 3.75, qty: 157n, sku: \"CLP-150\" }] },\n { id: 1008n, customer_id: \"C05\", discount: none, total: 1280.3, status: variant(\"pending\", null),\n lines: [{ price: 0.85, qty: 143n, sku: \"BLT-045\" }, { price: 64.5, qty: 10n, sku: \"RAL-900\" }, { price: 3.75, qty: 137n, sku: \"CLP-150\" }] },\n { id: 1009n, customer_id: \"C04\", discount: some(0.05), total: 409.51, status: variant(\"shipped\", { date: new Date(\"2025-11-18T09:00:00.000Z\") }),\n lines: [{ price: 64.5, qty: 6n, sku: \"RAL-900\" }, { price: 0.18, qty: 211n, sku: \"WSH-008\" }, { price: 0.32, qty: 19n, sku: \"SCR-012\" }] },\n { id: 1010n, customer_id: \"C05\", discount: some(0.05), total: 142.23, status: variant(\"shipped\", { date: new Date(\"2025-10-14T12:00:00.000Z\") }),\n lines: [{ price: 0.18, qty: 189n, sku: \"WSH-008\" }, { price: 8.9, qty: 13n, sku: \"HNG-220\" }] },\n { id: 1011n, customer_id: \"C08\", discount: none, total: 1027.4, status: variant(\"pending\", null),\n lines: [{ price: 8.9, qty: 29n, sku: \"HNG-220\" }, { price: 64.5, qty: 8n, sku: \"RAL-900\" }, { price: 0.85, qty: 298n, sku: \"BLT-045\" }] },\n { id: 1012n, customer_id: \"C02\", discount: none, total: 1109.6, status: variant(\"shipped\", { date: new Date(\"2026-04-01T08:00:00.000Z\") }),\n lines: [{ price: 12.4, qty: 19n, sku: \"BRK-100\" }, { price: 46.0, qty: 19n, sku: \"PLT-310\" }] },\n { id: 1013n, customer_id: \"C08\", discount: some(0.05), total: 311.37, status: variant(\"shipped\", { date: new Date(\"2026-04-27T10:00:00.000Z\") }),\n lines: [{ price: 64.5, qty: 4n, sku: \"RAL-900\" }, { price: 0.32, qty: 218n, sku: \"SCR-012\" }] },\n { id: 1014n, customer_id: \"C07\", discount: none, total: 1765.97, status: variant(\"shipped\", { date: new Date(\"2026-03-09T08:00:00.000Z\") }),\n lines: [{ price: 46.0, qty: 30n, sku: \"PLT-310\" }, { price: 0.18, qty: 254n, sku: \"WSH-008\" }, { price: 0.85, qty: 269n, sku: \"BLT-045\" }, { price: 12.4, qty: 9n, sku: \"BRK-100\" }] },\n { id: 1015n, customer_id: \"C03\", discount: none, total: 3646.84, status: variant(\"pending\", null),\n lines: [{ price: 46.0, qty: 19n, sku: \"PLT-310\" }, { price: 64.5, qty: 26n, sku: \"RAL-900\" }, { price: 3.75, qty: 276n, sku: \"CLP-150\" }, { price: 0.18, qty: 338n, sku: \"WSH-008\" }] },\n { id: 1016n, customer_id: \"C02\", discount: none, total: 1882.9, status: variant(\"pending\", null),\n lines: [{ price: 12.4, qty: 1n, sku: \"BRK-100\" }, { price: 64.5, qty: 29n, sku: \"RAL-900\" }] },\n { id: 1017n, customer_id: \"C02\", discount: some(0.05), total: 2005.59, status: variant(\"pending\", null),\n lines: [{ price: 0.85, qty: 89n, sku: \"BLT-045\" }, { price: 46.0, qty: 12n, sku: \"PLT-310\" }, { price: 64.5, qty: 23n, sku: \"RAL-900\" }] },\n { id: 1018n, customer_id: \"C03\", discount: none, total: 1372.99, status: variant(\"pending\", null),\n lines: [{ price: 46.0, qty: 26n, sku: \"PLT-310\" }, { price: 0.18, qty: 138n, sku: \"WSH-008\" }, { price: 0.85, qty: 179n, sku: \"BLT-045\" }] },\n { id: 1019n, customer_id: \"C05\", discount: none, total: 684.65, status: variant(\"pending\", null),\n lines: [{ price: 0.85, qty: 301n, sku: \"BLT-045\" }, { price: 12.4, qty: 26n, sku: \"BRK-100\" }, { price: 8.9, qty: 8n, sku: \"HNG-220\" }, { price: 0.32, qty: 110n, sku: \"SCR-012\" }] },\n { id: 1020n, customer_id: \"C01\", discount: some(0.05), total: 297.01, status: variant(\"shipped\", { date: new Date(\"2026-02-06T11:00:00.000Z\") }),\n lines: [{ price: 0.32, qty: 75n, sku: \"SCR-012\" }, { price: 0.18, qty: 88n, sku: \"WSH-008\" }, { price: 12.4, qty: 22n, sku: \"BRK-100\" }] },\n { id: 1021n, customer_id: \"C07\", discount: none, total: 1225.5, status: variant(\"shipped\", { date: new Date(\"2026-05-18T14:00:00.000Z\") }),\n lines: [{ price: 64.5, qty: 19n, sku: \"RAL-900\" }] },\n { id: 1022n, customer_id: \"C07\", discount: some(0.15), total: 36.26, status: variant(\"shipped\", { date: new Date(\"2026-01-03T10:00:00.000Z\") }),\n lines: [{ price: 0.18, qty: 237n, sku: \"WSH-008\" }] },\n { id: 1023n, customer_id: \"C01\", discount: some(0.1), total: 1352.32, status: variant(\"shipped\", { date: new Date(\"2026-01-08T12:00:00.000Z\") }),\n lines: [{ price: 0.32, qty: 32n, sku: \"SCR-012\" }, { price: 8.9, qty: 13n, sku: \"HNG-220\" }, { price: 0.18, qty: 123n, sku: \"WSH-008\" }, { price: 64.5, qty: 21n, sku: \"RAL-900\" }] },\n { id: 1024n, customer_id: \"C05\", discount: some(0.05), total: 623.52, status: variant(\"cancelled\", { reason: \"Customer request\" }),\n lines: [{ price: 46.0, qty: 4n, sku: \"PLT-310\" }, { price: 0.18, qty: 209n, sku: \"WSH-008\" }, { price: 0.32, qty: 351n, sku: \"SCR-012\" }, { price: 12.4, qty: 26n, sku: \"BRK-100\" }] },\n { id: 1025n, customer_id: \"C01\", discount: some(0.1), total: 2577.23, status: variant(\"cancelled\", { reason: \"Payment failed\" }),\n lines: [{ price: 0.18, qty: 213n, sku: \"WSH-008\" }, { price: 64.5, qty: 27n, sku: \"RAL-900\" }, { price: 3.75, qty: 289n, sku: \"CLP-150\" }] },\n { id: 1026n, customer_id: \"C03\", discount: none, total: 1913.4, status: variant(\"shipped\", { date: new Date(\"2026-03-07T08:00:00.000Z\") }),\n lines: [{ price: 0.85, qty: 354n, sku: \"BLT-045\" }, { price: 64.5, qty: 25n, sku: \"RAL-900\" }] },\n { id: 1027n, customer_id: \"C08\", discount: none, total: 808.19, status: variant(\"shipped\", { date: new Date(\"2026-06-26T10:00:00.000Z\") }),\n lines: [{ price: 0.85, qty: 3n, sku: \"BLT-045\" }, { price: 8.9, qty: 25n, sku: \"HNG-220\" }, { price: 64.5, qty: 8n, sku: \"RAL-900\" }, { price: 0.18, qty: 373n, sku: \"WSH-008\" }] },\n { id: 1028n, customer_id: \"C06\", discount: none, total: 173.45, status: variant(\"pending\", null),\n lines: [{ price: 0.85, qty: 47n, sku: \"BLT-045\" }, { price: 8.9, qty: 15n, sku: \"HNG-220\" }] },\n { id: 1029n, customer_id: \"C05\", discount: none, total: 64.96, status: variant(\"shipped\", { date: new Date(\"2026-03-19T16:00:00.000Z\") }),\n lines: [{ price: 0.32, qty: 203n, sku: \"SCR-012\" }] },\n { id: 1030n, customer_id: \"C03\", discount: none, total: 913.36, status: variant(\"pending\", null),\n lines: [{ price: 0.85, qty: 380n, sku: \"BLT-045\" }, { price: 3.75, qty: 4n, sku: \"CLP-150\" }, { price: 46.0, qty: 12n, sku: \"PLT-310\" }, { price: 0.32, qty: 73n, sku: \"SCR-012\" }] },\n { id: 1031n, customer_id: \"C06\", discount: none, total: 1537.52, status: variant(\"shipped\", { date: new Date(\"2026-05-31T13:00:00.000Z\") }),\n lines: [{ price: 0.18, qty: 264n, sku: \"WSH-008\" }, { price: 12.4, qty: 20n, sku: \"BRK-100\" }, { price: 46.0, qty: 27n, sku: \"PLT-310\" }] },\n { id: 1032n, customer_id: \"C02\", discount: none, total: 1892.81, status: variant(\"cancelled\", { reason: \"Out of stock\" }),\n lines: [{ price: 46.0, qty: 26n, sku: \"PLT-310\" }, { price: 3.75, qty: 183n, sku: \"CLP-150\" }, { price: 0.32, qty: 33n, sku: \"SCR-012\" }] },\n { id: 1033n, customer_id: \"C01\", discount: none, total: 1834.15, status: variant(\"pending\", null),\n lines: [{ price: 64.5, qty: 27n, sku: \"RAL-900\" }, { price: 0.85, qty: 109n, sku: \"BLT-045\" }] },\n { id: 1034n, customer_id: \"C03\", discount: none, total: 323.06, status: variant(\"pending\", null),\n lines: [{ price: 0.32, qty: 140n, sku: \"SCR-012\" }, { price: 12.4, qty: 19n, sku: \"BRK-100\" }, { price: 0.18, qty: 237n, sku: \"WSH-008\" }] },\n { id: 1035n, customer_id: \"C06\", discount: none, total: 2381.61, status: variant(\"shipped\", { date: new Date(\"2026-06-01T14:00:00.000Z\") }),\n lines: [{ price: 0.18, qty: 292n, sku: \"WSH-008\" }, { price: 3.75, qty: 279n, sku: \"CLP-150\" }, { price: 0.85, qty: 48n, sku: \"BLT-045\" }, { price: 46.0, qty: 27n, sku: \"PLT-310\" }] },\n { id: 1036n, customer_id: \"C01\", discount: some(0.05), total: 1041.68, status: variant(\"shipped\", { date: new Date(\"2026-05-26T13:00:00.000Z\") }),\n lines: [{ price: 64.5, qty: 17n, sku: \"RAL-900\" }] },\n { id: 1037n, customer_id: \"C08\", discount: none, total: 774.5, status: variant(\"pending\", null),\n lines: [{ price: 46.0, qty: 12n, sku: \"PLT-310\" }, { price: 8.9, qty: 25n, sku: \"HNG-220\" }] },\n { id: 1038n, customer_id: \"C01\", discount: none, total: 1758.0, status: variant(\"shipped\", { date: new Date(\"2025-10-28T08:00:00.000Z\") }),\n lines: [{ price: 64.5, qty: 8n, sku: \"RAL-900\" }, { price: 46.0, qty: 27n, sku: \"PLT-310\" }] },\n { id: 1039n, customer_id: \"C06\", discount: none, total: 471.06, status: variant(\"shipped\", { date: new Date(\"2026-04-04T13:00:00.000Z\") }),\n lines: [{ price: 8.9, qty: 15n, sku: \"HNG-220\" }, { price: 0.18, qty: 222n, sku: \"WSH-008\" }, { price: 12.4, qty: 24n, sku: \"BRK-100\" }] },\n { id: 1040n, customer_id: \"C02\", discount: none, total: 884.1, status: variant(\"shipped\", { date: new Date(\"2025-12-08T14:00:00.000Z\") }),\n lines: [{ price: 46.0, qty: 14n, sku: \"PLT-310\" }, { price: 8.9, qty: 18n, sku: \"HNG-220\" }, { price: 0.85, qty: 94n, sku: \"BLT-045\" }] },\n]));\n\n/** The customers, by id. */\nexport const customers = e3.input(\"customers\", DictType(StringType, Customer), variant(\"value\", new SortedMap([\n [\"C01\", { name: \"Harbour Foods\", region: \"NSW\", tier: variant(\"gold\", null) }],\n [\"C02\", { name: \"Coastline Retail\", region: \"NSW\", tier: variant(\"standard\", null) }],\n [\"C03\", { name: \"Ridge Grocers\", region: \"VIC\", tier: variant(\"gold\", null) }],\n [\"C04\", { name: \"Southbank Market\", region: \"VIC\", tier: variant(\"standard\", null) }],\n [\"C05\", { name: \"Sunfield Traders\", region: \"QLD\", tier: variant(\"standard\", null) }],\n [\"C06\", { name: \"Northgate Supply\", region: \"QLD\", tier: variant(\"gold\", null) }],\n [\"C07\", { name: \"Westend Provisions\", region: \"WA\", tier: variant(\"standard\", null) }],\n [\"C08\", { name: \"Ironbark Stores\", region: \"SA\", tier: variant(\"standard\", null) }],\n], compareFor(StringType))));\n\n/** Weekly demand by region: eight weeks of `base × (0.9 + 0.03w + 0.01i)`, to one place, for the region at index i of NSW, VIC, QLD, WA, SA. */\nexport const forecast = e3.input(\"forecast\", Forecast, variant(\"value\", {\n regions: new SortedMap([\n [\"NSW\", { weekly: [1080.0, 1116.0, 1152.0, 1188.0, 1224.0, 1260.0, 1296.0, 1332.0] }],\n [\"QLD\", { weekly: [791.2, 817.0, 842.8, 868.6, 894.4, 920.2, 946.0, 971.8] }],\n [\"SA\", { weekly: [385.4, 397.7, 410.0, 422.3, 434.6, 446.9, 459.2, 471.5] }],\n [\"VIC\", { weekly: [955.5, 987.0, 1018.5, 1050.0, 1081.5, 1113.0, 1144.5, 1176.0] }],\n [\"WA\", { weekly: [502.2, 518.4, 534.6, 550.8, 567.0, 583.2, 599.4, 615.6] }],\n ], compareFor(StringType)),\n}));\n\n/** The demand model, `round₂(base[region] × (price / 10)^−1.4)`: the units sold at a unit price in a region. */\nconst demandModel = East.function([ModelInput], FloatType, ($, input) => {\n const base = $.const(new SortedMap([[\"NSW\", 1200.0], [\"QLD\", 860.0], [\"SA\", 410.0], [\"VIC\", 1050.0], [\"WA\", 540.0]], compareFor(StringType)), DictType(StringType, FloatType));\n // A region the model does not know has a base of 300.\n const demand = base.get(input.region, () => 300.0).multiply(input.price.divide(10.0).pow(-1.4));\n const cents = $.const(demand.multiply(100.0).add(0.5));\n return cents.subtract(cents.remainder(1.0)).divide(100.0);\n});\n\n/** The demand model as data: an East function every runtime can call, which a query tries over a range. */\nexport const model = e3.input(\"model\", Model, variant(\"value\", East.compile(demandModel, [])));\n\n/** The bill of materials for PUMP-A. */\nexport const bom = e3.input(\"bom\", Part, variant(\"value\", {\n sku: \"PUMP-A\", cost: 42.0, children: [\n { sku: \"MOTOR-1\", cost: 120.0, children: [\n { sku: \"ROTOR-1\", cost: 18.5, children: [] }, { sku: \"STATOR-1\", cost: 22.0, children: [] }, { sku: \"BRG-6203\", cost: 3.2, children: [] },\n ] },\n { sku: \"HOUSING-2\", cost: 35.0, children: [{ sku: \"GASKET-9\", cost: 1.1, children: [] }, { sku: \"BOLT-M8\", cost: 0.4, children: [] }] },\n { sku: \"IMPELLER-3\", cost: 27.5, children: [] },\n { sku: \"SEAL-KIT\", cost: 6.8, children: [{ sku: \"ORING-12\", cost: 0.3, children: [] }, { sku: \"ORING-18\", cost: 0.35, children: [] }] },\n ],\n}));\n\n/**\n * The saved queries record: the mock's seven (`Query Editor Spec.md` §6),\n * each its canonical jq — what the builder's steps print — checked against the\n * data sources the builders bind when the package builds, and described where\n * the mock describes it; the rest describe themselves.\n */\nexport const queries = e3.record(\"queries\", Query.Types.Saved, {\n initial: Query.value({ orders, customers, forecast, model, bom }, [\n {\n name: \"Top shipped orders, 2026\",\n jq: `.customers as $customers\n | .orders\n | map(select(.status.type == \"shipped\") | select(.total >= 100 and (.status.value.date | year) == 2026))\n | map(. + {name: $customers[.customer_id].name, region: $customers[.customer_id].region})\n | map({order: .id, customer: .name, region, total, shipped: .status.value.date})\n | sort_by(-.total)\n | .[:10]`,\n savedAt: new Date(\"2026-10-01T09:00:00Z\"),\n },\n {\n name: \"Revenue by region\",\n jq: `.customers as $customers\n | .orders\n | map(select(.status.type == \"shipped\") | select(.total >= 100 and (.status.value.date | year) == 2026))\n | map(. + {region: $customers[.customer_id].region})\n | group_by(.region)\n | map({region: .[0].region, revenue: map(.total) | add, orders: length})\n | sort_by(-.revenue)\n | .[:3]`,\n description: \"Top 3 regions by shipped revenue in 2026, from orders of $100 or more.\",\n savedAt: new Date(\"2026-09-29T09:00:00Z\"),\n },\n {\n name: \"Shipped revenue by month\",\n jq: `.orders\n | map(select(.status.type == \"shipped\"))\n | map(. + {ship_month: .status.value.date | strftime(\"%Y-%m\")})\n | group_by(.ship_month)\n | map({ship_month: .[0].ship_month, revenue: map(.total) | add, orders: length})\n | sort_by(.ship_month)`,\n savedAt: new Date(\"2026-09-12T09:00:00Z\"),\n },\n {\n name: \"Large orders with no discount\",\n jq: `.orders\n | map(select(.total >= 1000 and .discount == null))\n | map({id, customer_id, total, status})\n | sort_by(-.total)`,\n savedAt: new Date(\"2026-09-03T09:00:00Z\"),\n },\n {\n name: \"Units by SKU\",\n jq: `.orders\n | [.[] | . as $order | .lines[] | . + {order_id: $order.id}]\n | group_by(.sku)\n | map({sku: .[0].sku, units: map(.qty) | add, orders: map(.order_id) | unique | length})\n | sort_by(-.units)`,\n savedAt: new Date(\"2026-08-28T09:00:00Z\"),\n },\n {\n name: \"Pump parts cost\",\n jq: `.bom\n | [recurse(.children[]) | {cost, sku}]\n | {total_cost: map(.cost) | add, parts: length, dearest: map(.cost) | max}`,\n description: \"Total cost, part count and dearest part in the PUMP-A bill of materials.\",\n savedAt: new Date(\"2026-08-20T09:00:00Z\"),\n },\n {\n name: \"Demand at $10–$12, NSW\",\n jq: `.model\n | [range(10.0; 12.0 + 0.5 / 2; 0.5) as $price | {price: $price, demand: call(.; {price: $price, region: \"NSW\"})}]`,\n description: \"Modelled demand in NSW at prices from $10 to $12, in $0.50 steps.\",\n savedAt: new Date(\"2026-08-14T09:00:00Z\"),\n },\n ]),\n mutations: (mutation) => ({\n // The record's one write.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const saved = $.let(Record.bind(queries));\n const orderRows = $.let(Data.bind(orders));\n const customerRows = $.let(Data.bind(customers));\n const weekly = $.let(Data.bind(forecast));\n const demand = $.let(Data.bind(model));\n const parts = $.let(Data.bind(bom));\n return (\n <Box height=\"720px\">\n <Query.Library queries={saved} id=\"top\"\n datasets={{ orders: orderRows, customers: customerRows, forecast: weekly, model: demand, bom: parts }} />\n </Box>\n );\n }}</Reactive>\n ))"
45440
45622
  },
45623
+ {
45624
+ "id": "e3-ui:record-keys.examples.tsx:recordBuiltKeysSliced",
45625
+ "skill": "e3-ui",
45626
+ "package": "e3-ui",
45627
+ "file": "east-ui/packages/e3-ui/test/record/record-keys.examples.tsx",
45628
+ "suite": "",
45629
+ "test": "A record whose rows' keys the app builds from the row, paged and narrowed by the rail: stock locations keyed by a text their aisle and their bin build, read a page at a time through the indexes the rail filters by zone and by aisle and searches by what they hold. A bin typed over moves its location under the key it then builds, and a Save writes it there — its row leaving the narrowing where its new aisle is one the rail filters out, which the footer says; a bin another location has is refused, in the danger tone, the row marked where it stands",
45630
+ "keywords": [
45631
+ "Record",
45632
+ "rowKey",
45633
+ "built key",
45634
+ "key from the row",
45635
+ "row key",
45636
+ "natural key",
45637
+ "East.str",
45638
+ "Slice",
45639
+ "Slice.bindRecords",
45640
+ "rows",
45641
+ "Data.bindPaged",
45642
+ "indexes",
45643
+ "index.on",
45644
+ "filter",
45645
+ "search",
45646
+ "narrowing",
45647
+ "paging",
45648
+ "newRow",
45649
+ "key taken",
45650
+ "refused"
45651
+ ],
45652
+ "imports": [
45653
+ "import {",
45654
+ "import { Box, Reactive, Slice, UIComponentType } from \"@elaraai/east-ui\";",
45655
+ "import { Data, Record } from \"@elaraai/e3-ui\";",
45656
+ "import e3 from \"@elaraai/e3\";"
45657
+ ],
45658
+ "languages": [
45659
+ "tsx"
45660
+ ],
45661
+ "source": "// A record whose rows' keys the app builds from the row, paged and narrowed by the rail: stock locations keyed by a text their aisle and their bin build, read a page at a time through the indexes the rail filters by zone and by aisle and searches by what they hold. A bin typed over moves its location under the key it then builds, and a Save writes it there — its row leaving the narrowing where its new aisle is one the rail filters out, which the footer says; a bin another location has is refused, in the danger tone, the row marked where it stands\n// inputs: []\n/** A stock location: what it holds, the aisle and the bin its key is built from, and the zone its aisle is in. */\nexport const StockSlot = StructType({ item: StringType, aisle: StringType, bin: IntegerType, zone: StringType });\n\n/** What the bins of an aisle hold, bin by bin. */\nconst HELD = [\"Pallet wrap\", \"Strapping\", \"Corner boards\", \"Labels\", \"Tape\", \"Void fill\", \"Cartons\", \"Dividers\"] as const;\n\n/** The aisles, each with the zone it is in. */\nconst AISLES = [[\"A\", \"Dry\"], [\"B\", \"Dry\"], [\"C\", \"Chilled\"], [\"D\", \"Chilled\"]] as const;\n\n/** Four aisles of eight bins: aisles A and B in the dry zone, C and D in the chilled one. */\nfunction stockSlots(): ValueTypeOf<typeof StockSlot>[] {\n return AISLES.flatMap(([aisle, zone]) => HELD.map((item, at) => ({ item: `${item} ${aisle}${at + 1}`, aisle, bin: BigInt(at + 1), zone })));\n}\n\n/** The locations keyed by a text: `A-1`. */\nexport const recordSlotsByText = e3.record(\"record_slots_by_text\", DictType(StringType, StockSlot), {\n initial: new Map(stockSlots().map((slot) => [`${slot.aisle}-${slot.bin}`, slot] as const)),\n indexes: (index) => ({\n // What the rail filters and searches by.\n record_slots_by_text_zone: index.on([\"zone\"]),\n record_slots_by_text_aisle: index.on([\"aisle\"]),\n record_slots_by_text_item: index.on([\"item\"]),\n }),\n mutations: (mutation) => ({\n // The locations' patch door — every Save commits through it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const locations = $.let(Record.bind(recordSlotsByText));\n // The rail's `rows` source: the locations, a page at a time, through the indexes it filters and searches by.\n const slice = $.let(Slice.bindRecords(\"record.slots.text\", {\n rows: {\n source: Data.bindPaged(recordSlotsByText, { indexes: [\"record_slots_by_text_zone\", \"record_slots_by_text_aisle\", \"record_slots_by_text_item\"] }),\n label: \"Locations\",\n fields: { zone: { label: \"Zone\", hints: [\"Dry\", \"Chilled\"] }, aisle: { label: \"Aisle\", hints: [\"A\", \"B\", \"C\", \"D\"] }, item: { label: \"Holds\" } },\n search: [\"item\"],\n },\n }));\n // A new location as it is added: in aisle A's zone, its aisle, its bin and what it holds left to type.\n const newRow = $.const(East.function([Record.Types.NewRow], Record.Types.Patch(StockSlot), (_$) => Record.patch(StockSlot, { zone: \"Dry\" })));\n return (\n <Box height=\"520px\">\n <Record\n slice={{ slice }}\n record={locations}\n // A location's key, built from its row: its aisle and its bin, as one text.\n rowKey={(location) => East.str`${location.aisle}-${location.bin}`}\n title=\"Stock locations\"\n noun={{ singular: \"location\", plural: \"locations\" }}\n columns={{\n item: Record.column.title(StockSlot, { header: \"Holds\", width: \"200px\" }),\n aisle: Record.column.text(StockSlot, { header: \"Aisle\", width: \"96px\" }),\n bin: Record.column.integer(StockSlot, { header: \"Bin\", width: \"96px\" }),\n zone: Record.column.text(StockSlot, { header: \"Zone\", width: \"120px\" }),\n }}\n newRow={newRow}\n name=\"recordBuiltKeysSliced\"\n />\n </Box>\n );\n }}</Reactive>\n ))"
45662
+ },
45663
+ {
45664
+ "id": "e3-ui:record-keys.examples.tsx:recordStructKeysSliced",
45665
+ "skill": "e3-ui",
45666
+ "package": "e3-ui",
45667
+ "file": "east-ui/packages/e3-ui/test/record/record-keys.examples.tsx",
45668
+ "suite": "",
45669
+ "test": "recordBuiltKeysSliced over a key that is no text: the same stock locations, under the same rail, keyed by a struct of their aisle and their bin, which `rowKey` builds from the row as a struct. A record keyed by any type a Dict takes is a source of the rail: it pages through its indexes, filters by zone and by aisle and searches by what its rows hold as a text-keyed one does; a bin typed over moves its location under the struct it then builds, a Save writes it there, and a bin another location has is refused. The grid holds a key as East prints it, and reads it back at its own type",
45670
+ "keywords": [
45671
+ "Record",
45672
+ "rowKey",
45673
+ "built key",
45674
+ "key from the row",
45675
+ "struct key",
45676
+ "composite key",
45677
+ "keyType",
45678
+ "typed key",
45679
+ "StructType",
45680
+ "Slice",
45681
+ "Slice.bindRecords",
45682
+ "rows",
45683
+ "Data.bindPaged",
45684
+ "indexes",
45685
+ "index.on",
45686
+ "filter",
45687
+ "search",
45688
+ "narrowing",
45689
+ "paging",
45690
+ "newRow",
45691
+ "key taken",
45692
+ "refused",
45693
+ "#1696"
45694
+ ],
45695
+ "imports": [
45696
+ "import {",
45697
+ "import { Box, Reactive, Slice, UIComponentType } from \"@elaraai/east-ui\";",
45698
+ "import { Data, Record } from \"@elaraai/e3-ui\";",
45699
+ "import e3 from \"@elaraai/e3\";"
45700
+ ],
45701
+ "languages": [
45702
+ "tsx"
45703
+ ],
45704
+ "source": "// recordBuiltKeysSliced over a key that is no text: the same stock locations, under the same rail, keyed by a struct of their aisle and their bin, which `rowKey` builds from the row as a struct. A record keyed by any type a Dict takes is a source of the rail: it pages through its indexes, filters by zone and by aisle and searches by what its rows hold as a text-keyed one does; a bin typed over moves its location under the struct it then builds, a Save writes it there, and a bin another location has is refused. The grid holds a key as East prints it, and reads it back at its own type\n// inputs: []\n/** A stock location: what it holds, the aisle and the bin its key is built from, and the zone its aisle is in. */\nexport const StockSlot = StructType({ item: StringType, aisle: StringType, bin: IntegerType, zone: StringType });\n\n/** A location's key as a struct: its aisle and its bin. */\nexport const StockSlotKey = StructType({ aisle: StringType, bin: IntegerType });\n\n/** What the bins of an aisle hold, bin by bin. */\nconst HELD = [\"Pallet wrap\", \"Strapping\", \"Corner boards\", \"Labels\", \"Tape\", \"Void fill\", \"Cartons\", \"Dividers\"] as const;\n\n/** The aisles, each with the zone it is in. */\nconst AISLES = [[\"A\", \"Dry\"], [\"B\", \"Dry\"], [\"C\", \"Chilled\"], [\"D\", \"Chilled\"]] as const;\n\n/** Four aisles of eight bins: aisles A and B in the dry zone, C and D in the chilled one. */\nfunction stockSlots(): ValueTypeOf<typeof StockSlot>[] {\n return AISLES.flatMap(([aisle, zone]) => HELD.map((item, at) => ({ item: `${item} ${aisle}${at + 1}`, aisle, bin: BigInt(at + 1), zone })));\n}\n\n/** The same locations keyed by a struct: their aisle and their bin. A Dict over struct keys is a SortedMap, in East's order. */\nexport const recordSlotsByStruct = e3.record(\"record_slots_by_struct\", DictType(StockSlotKey, StockSlot), {\n initial: new SortedMap<ValueTypeOf<typeof StockSlotKey>, ValueTypeOf<typeof StockSlot>>(\n stockSlots().map((slot) => [{ aisle: slot.aisle, bin: slot.bin }, slot] as const), compareFor(StockSlotKey)),\n indexes: (index) => ({\n // What the rail filters and searches by.\n record_slots_by_struct_zone: index.on([\"zone\"]),\n record_slots_by_struct_aisle: index.on([\"aisle\"]),\n record_slots_by_struct_item: index.on([\"item\"]),\n }),\n mutations: (mutation) => ({\n // The locations' patch door — every Save commits through it, each location by its struct key.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const locations = $.let(Record.bind(recordSlotsByStruct));\n // The rail's `rows` source, as the text-keyed locations': the indexes are of the rows' fields, whatever keys them.\n const slice = $.let(Slice.bindRecords(\"record.slots.struct\", {\n rows: {\n source: Data.bindPaged(recordSlotsByStruct, { indexes: [\"record_slots_by_struct_zone\", \"record_slots_by_struct_aisle\", \"record_slots_by_struct_item\"] }),\n label: \"Locations\",\n fields: { zone: { label: \"Zone\", hints: [\"Dry\", \"Chilled\"] }, aisle: { label: \"Aisle\", hints: [\"A\", \"B\", \"C\", \"D\"] }, item: { label: \"Holds\" } },\n search: [\"item\"],\n },\n }));\n const newRow = $.const(East.function([Record.Types.NewRow], Record.Types.Patch(StockSlot), (_$) => Record.patch(StockSlot, { zone: \"Dry\" })));\n return (\n <Box height=\"520px\">\n <Record\n slice={{ slice }}\n record={locations}\n // A location's key, built from its row at the record's key type: a struct of its aisle and its bin.\n rowKey={(location) => ({ aisle: location.aisle, bin: location.bin })}\n title=\"Stock locations\"\n noun={{ singular: \"location\", plural: \"locations\" }}\n columns={{\n item: Record.column.title(StockSlot, { header: \"Holds\", width: \"200px\" }),\n aisle: Record.column.text(StockSlot, { header: \"Aisle\", width: \"96px\" }),\n bin: Record.column.integer(StockSlot, { header: \"Bin\", width: \"96px\" }),\n zone: Record.column.text(StockSlot, { header: \"Zone\", width: \"120px\" }),\n }}\n newRow={newRow}\n name=\"recordStructKeysSliced\"\n />\n </Box>\n );\n }}</Reactive>\n ))"
45705
+ },
45441
45706
  {
45442
45707
  "id": "e3-ui:record.examples.tsx:recordBasic",
45443
45708
  "skill": "e3-ui",
@@ -45920,7 +46185,74 @@
45920
46185
  "languages": [
45921
46186
  "tsx"
45922
46187
  ],
45923
- "source": "// Your edits meeting someone else's save, in one window — step a forklift level, then press Someone else saves, which saves another person's change to the same crew (every level a step down), so yours conflicts and waits to be chosen; an induction you toggle combines with theirs. Someone else removes A. Morgan removes that member — changed by you, a conflict of the whole row to choose, deleted by you too, nothing to choose — and Someone else adds a member adds one under the next key, which the Record's newKey gives a member of yours too: one you added meanwhile takes the key after it, and both are kept; a member you add joins not yet inducted and not trained (newRow), their name left to type\n// inputs: []\nexport const Crew = StructType({ name: StringType, inducted: BooleanType, forklift: StringType });\n\n/** The crew the conflicts example edits, in a record of their own, so no other example's edits meet them. */\nexport const recordConflictCrew = e3.record(\"record_conflict_crew\", DictType(StringType, Crew), {\n initial: new Map([\n [\"C-001\", { name: \"A. Morgan\", inducted: true, forklift: \"2\" }],\n [\"C-002\", { name: \"B. Ellis\", inducted: false, forklift: \"0\" }],\n [\"C-003\", { name: \"C. Patel\", inducted: true, forklift: \"1\" }],\n ]),\n mutations: (mutation) => ({\n // The crew's patch door — every Save commits through it.\n patch: mutation.patch(),\n // Someone else's save: every member's forklift level a step down — Competent to Supervised, Supervised to Not\n // trained, Not trained to Competent — their name and induction as they were.\n elsewhere: mutation.reduce(East.function([DictType(StringType, Crew)], DictType(StringType, Crew), (_$, crew) =>\n crew.map((_$2, member) => ({\n name: member.name,\n inducted: member.inducted,\n forklift: member.forklift.equal(\"2\").ifElse((_$3) => \"1\", (_$3) => member.forklift.equal(\"1\").ifElse((_$4) => \"0\", (_$4) => \"2\")),\n })))),\n // Someone else's save: A. Morgan, C-001, removed — where the record still holds them.\n removes: mutation.reduce(East.function([DictType(StringType, Crew)], DictType(StringType, Crew), ($, crew) => {\n const next = $.let(crew.copy());\n $(next.tryDelete(\"C-001\"));\n return next;\n })),\n // Someone else's save: a member added under the next key, C-004 — where the record holds none there.\n adds: mutation.reduce(East.function([DictType(StringType, Crew)], DictType(StringType, Crew), ($, crew) => {\n const next = $.let(crew.copy());\n $.if(next.has(\"C-004\").not(), ($2) => {\n const joiner = $2.const({ name: \"D. Reyes\", inducted: false, forklift: \"0\" }, Crew);\n $2(next.insert(\"C-004\", joiner));\n });\n return next;\n })),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const members = $.let(Record.bind(recordConflictCrew, [\"patch\"]));\n const others = $.let(Record.bind(recordConflictCrew, [\"elsewhere\", \"removes\", \"adds\"]));\n const theirs = $.const(East.function([], NullType, ($) => { $(others.mutate.elsewhere()); }));\n const theirRemoval = $.const(East.function([], NullType, ($) => { $(others.mutate.removes()); }));\n const theirAddition = $.const(East.function([], NullType, ($) => { $(others.mutate.adds()); }));\n const LevelType = StructType({ key: StringType, name: StringType });\n const levels = $.let([\n { key: \"0\", name: \"Not trained\" },\n { key: \"1\", name: \"Supervised\" },\n { key: \"2\", name: \"Competent\" },\n ], ArrayType(LevelType));\n // A new member's key in the crew's own scheme: given every key taken, the first C-00N none of them is.\n const newKey = $.const(East.function([SetType(StringType)], StringType, ($, taken) => {\n const n = $.let(taken.size().add(1n));\n $.while(taken.has(East.str`C-00${n}`), ($2) => {\n $2.assign(n, n.add(1n));\n });\n return East.str`C-00${n}`;\n }));\n // A new member as they join: not yet inducted, not trained — their name left to type.\n const newRow = $.const(East.function([Record.Types.NewRow], Record.Types.Patch(Crew), (_$) => Record.patch(Crew, { inducted: false, forklift: \"0\" })));\n return (\n <VStack gap=\"3\" align=\"stretch\">\n <HStack gap=\"3\" wrap=\"wrap\">\n <Button variant=\"outline\" onClick={theirs} loading={others.mutate.pending()}>Someone else saves</Button>\n <Button variant=\"outline\" onClick={theirRemoval} loading={others.mutate.pending()}>Someone else removes A. Morgan</Button>\n <Button variant=\"outline\" onClick={theirAddition} loading={others.mutate.pending()}>Someone else adds a member</Button>\n </HStack>\n <Text color=\"fg.muted\">Someone else saves: every forklift level a step down. Their removal: C-001, A. Morgan. Their addition: C-004, D. Reyes.</Text>\n <Box height=\"360px\">\n <Record\n record={members}\n title=\"Crew\"\n noun={{ singular: \"crew member\", plural: \"crew members\" }}\n registers={{ levels: Record.register.members(levels, { kind: \"level\", key: l => l.key, label: l => l.key, meta: l => some(l.name) }) }}\n columns={{\n name: Record.column.title(Crew, { header: \"Name\", width: \"160px\" }),\n inducted: Record.column.toggle(Crew, { header: \"Inducted\", width: \"80px\", on: \"yes\", off: \"no\" }),\n forklift: Record.column.cycle(Crew, \"levels\", { header: \"Forklift\", width: \"72px\", scale: true }),\n }}\n newKey={newKey}\n newRow={newRow}\n name=\"recordConflicts\"\n />\n </Box>\n </VStack>\n );\n }}</Reactive>\n ))"
46188
+ "source": "// Your edits meeting someone else's save, in one window — step a forklift level, then press Someone else saves, which saves another person's change to the same crew (every level a step down), so yours conflicts and waits to be chosen; an induction you toggle combines with theirs. Someone else removes A. Morgan removes that member — changed by you, a conflict of the whole row to choose, deleted by you too, nothing to choose — and Someone else adds a member adds one under the next key, which the Record's newKey gives a member of yours too: one you added meanwhile takes the key after it, and both are kept; a member you add joins not yet inducted and not trained (newRow), their name left to type\n// inputs: []\nexport const Crew = StructType({ name: StringType, inducted: BooleanType, forklift: StringType });\n\n/** The crew the conflicts example edits, in a record of their own, so no other example's edits meet them. */\nexport const recordConflictCrew = e3.record(\"record_conflict_crew\", DictType(StringType, Crew), {\n initial: new Map([\n [\"C-001\", { name: \"A. Morgan\", inducted: true, forklift: \"2\" }],\n [\"C-002\", { name: \"B. Ellis\", inducted: false, forklift: \"0\" }],\n [\"C-003\", { name: \"C. Patel\", inducted: true, forklift: \"1\" }],\n ]),\n mutations: (mutation) => ({\n // The crew's patch door — every Save commits through it.\n patch: mutation.patch(),\n // Someone else's save: every member's forklift level a step down — Competent to Supervised, Supervised to Not\n // trained, Not trained to Competent — their name and induction as they were.\n elsewhere: mutation.reduce(East.function([DictType(StringType, Crew)], DictType(StringType, Crew), (_$, crew) =>\n crew.map((_$2, member) => ({\n name: member.name,\n inducted: member.inducted,\n forklift: member.forklift.equal(\"2\").ifElse((_$3) => \"1\", (_$3) => member.forklift.equal(\"1\").ifElse((_$4) => \"0\", (_$4) => \"2\")),\n })))),\n // Someone else's save: A. Morgan, C-001, removed — where the record still holds them.\n removes: mutation.reduce(East.function([DictType(StringType, Crew)], DictType(StringType, Crew), ($, crew) => {\n const next = $.let(crew.copy());\n $(next.tryDelete(\"C-001\"));\n return next;\n })),\n // Someone else's save: a member added under the next key, C-004 — where the record holds none there.\n adds: mutation.reduce(East.function([DictType(StringType, Crew)], DictType(StringType, Crew), ($, crew) => {\n const next = $.let(crew.copy());\n $.if(next.has(\"C-004\").not(), ($2) => {\n const joiner = $2.const({ name: \"D. Reyes\", inducted: false, forklift: \"0\" }, Crew);\n $2(next.insert(\"C-004\", joiner));\n });\n return next;\n })),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const members = $.let(Record.bind(recordConflictCrew, [\"patch\"]));\n const others = $.let(Record.bind(recordConflictCrew, [\"elsewhere\", \"removes\", \"adds\"]));\n const theirs = $.const(East.function([], NullType, ($) => { $(others.mutate.elsewhere()); }));\n const theirRemoval = $.const(East.function([], NullType, ($) => { $(others.mutate.removes()); }));\n const theirAddition = $.const(East.function([], NullType, ($) => { $(others.mutate.adds()); }));\n const LevelType = StructType({ key: StringType, name: StringType });\n const levels = $.let([\n { key: \"0\", name: \"Not trained\" },\n { key: \"1\", name: \"Supervised\" },\n { key: \"2\", name: \"Competent\" },\n ], ArrayType(LevelType));\n // A new member's key in the crew's own scheme: given every key taken, the first C-NNN none of them is — its\n // number three digits at least, C-009 then C-010.\n const newKey = $.const(East.function([SetType(StringType)], StringType, ($, taken) => {\n const idOf = $.const(East.function([IntegerType], StringType, ($2, n) => {\n const digits = $2.let(East.str`${n}`);\n $2.while(digits.length().lessThan(3n), ($3) => {\n $3.assign(digits, East.str`0${digits}`);\n });\n return East.str`C-${digits}`;\n }));\n const n = $.let(taken.size().add(1n));\n $.while(taken.has(idOf(n)), ($2) => {\n $2.assign(n, n.add(1n));\n });\n return idOf(n);\n }));\n // A new member as they join: not yet inducted, not trained — their name left to type.\n const newRow = $.const(East.function([Record.Types.NewRow], Record.Types.Patch(Crew), (_$) => Record.patch(Crew, { inducted: false, forklift: \"0\" })));\n return (\n <VStack gap=\"3\" align=\"stretch\">\n <HStack gap=\"3\" wrap=\"wrap\">\n <Button variant=\"outline\" onClick={theirs} loading={others.mutate.pending()}>Someone else saves</Button>\n <Button variant=\"outline\" onClick={theirRemoval} loading={others.mutate.pending()}>Someone else removes A. Morgan</Button>\n <Button variant=\"outline\" onClick={theirAddition} loading={others.mutate.pending()}>Someone else adds a member</Button>\n </HStack>\n <Text color=\"fg.muted\">Someone else saves: every forklift level a step down. Their removal: C-001, A. Morgan. Their addition: C-004, D. Reyes.</Text>\n <Box height=\"360px\">\n <Record\n record={members}\n title=\"Crew\"\n noun={{ singular: \"crew member\", plural: \"crew members\" }}\n registers={{ levels: Record.register.members(levels, { kind: \"level\", key: l => l.key, label: l => l.key, meta: l => some(l.name) }) }}\n columns={{\n name: Record.column.title(Crew, { header: \"Name\", width: \"160px\" }),\n inducted: Record.column.toggle(Crew, { header: \"Inducted\", width: \"80px\", on: \"yes\", off: \"no\" }),\n forklift: Record.column.cycle(Crew, \"levels\", { header: \"Forklift\", width: \"72px\", scale: true }),\n }}\n newKey={newKey}\n newRow={newRow}\n name=\"recordConflicts\"\n />\n </Box>\n </VStack>\n );\n }}</Reactive>\n ))"
46189
+ },
46190
+ {
46191
+ "id": "e3-ui:record.examples.tsx:recordStaffIds",
46192
+ "skill": "e3-ui",
46193
+ "package": "e3-ui",
46194
+ "file": "east-ui/packages/e3-ui/test/record/record.examples.tsx",
46195
+ "suite": "",
46196
+ "test": "A record whose rows hold their own key in a field: the staff list keyed by staff id, each member's `id` their key too. `keyField` names the field, so a member Add drafts shows the id the Record keyed them by at once and is saved with it — and takes the next id with their key where someone else's save took theirs first. `newRow` gives a new member their team and says nothing of their id, and the id's column is read only",
46197
+ "keywords": [
46198
+ "Record",
46199
+ "keyField",
46200
+ "key field",
46201
+ "key in a field",
46202
+ "row key",
46203
+ "id",
46204
+ "newKey",
46205
+ "newRow",
46206
+ "Record.patch",
46207
+ "Add",
46208
+ "read only"
46209
+ ],
46210
+ "imports": [
46211
+ "import {",
46212
+ "import { Box, Button, Configurator, HStack, Reactive, SegmentGroup, Slice, State, StatusValueType, Style, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
46213
+ "import { Data, Record } from \"@elaraai/e3-ui\";",
46214
+ "import e3 from \"@elaraai/e3\";",
46215
+ "import { IndexedWork, indexedWorkOrders } from \"../sheet/sheet-records.examples.js\";"
46216
+ ],
46217
+ "languages": [
46218
+ "tsx"
46219
+ ],
46220
+ "source": "// A record whose rows hold their own key in a field: the staff list keyed by staff id, each member's `id` their key too. `keyField` names the field, so a member Add drafts shows the id the Record keyed them by at once and is saved with it — and takes the next id with their key where someone else's save took theirs first. `newRow` gives a new member their team and says nothing of their id, and the id's column is read only\n// inputs: []\n/** A member of staff: their staff id, which their row is keyed by too, their name and their team. */\nexport const StaffMember = StructType({ id: StringType, name: StringType, team: StringType });\n\nexport const recordStaff = e3.record(\"record_staff\", DictType(StringType, StaffMember), {\n initial: new Map([\n [\"S-001\", { id: \"S-001\", name: \"A. Morgan\", team: \"Inbound\" }],\n [\"S-002\", { id: \"S-002\", name: \"B. Ellis\", team: \"Outbound\" }],\n ]),\n mutations: (mutation) => ({\n // The staff list's patch door — every Save commits through it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const staff = $.let(Record.bind(recordStaff));\n // A new member's key in the list's own scheme: given every key taken, the first S-NNN none of them is — its\n // number three digits at least, S-009 then S-010.\n const newKey = $.const(East.function([SetType(StringType)], StringType, ($, taken) => {\n const idOf = $.const(East.function([IntegerType], StringType, ($2, n) => {\n const digits = $2.let(East.str`${n}`);\n $2.while(digits.length().lessThan(3n), ($3) => {\n $3.assign(digits, East.str`0${digits}`);\n });\n return East.str`S-${digits}`;\n }));\n const n = $.let(taken.size().add(1n));\n $.while(taken.has(idOf(n)), ($2) => {\n $2.assign(n, n.add(1n));\n });\n return idOf(n);\n }));\n // A new member as they join: in Inbound, their name left to type — and their id the Record's to keep.\n const newRow = $.const(East.function([Record.Types.NewRow], Record.Types.Patch(StaffMember), (_$) => Record.patch(StaffMember, { team: \"Inbound\" })));\n return (\n <Box height=\"360px\">\n <Record\n record={staff}\n // The field each member's key is held in too: the Record keeps it for every member it adds.\n keyField=\"id\"\n title=\"Staff\"\n noun={{ singular: \"member\", plural: \"members\" }}\n columns={{\n name: Record.column.title(StaffMember, { header: \"Name\", width: \"176px\" }),\n id: Record.column.text(StaffMember, { header: \"Staff id\", width: \"112px\" }),\n team: Record.column.text(StaffMember, { header: \"Team\", width: \"136px\" }),\n }}\n newKey={newKey}\n newRow={newRow}\n name=\"recordStaffIds\"\n />\n </Box>\n );\n }}</Reactive>\n ))"
46221
+ },
46222
+ {
46223
+ "id": "e3-ui:record.examples.tsx:recordBuiltKeys",
46224
+ "skill": "e3-ui",
46225
+ "package": "e3-ui",
46226
+ "file": "east-ui/packages/e3-ui/test/record/record.examples.tsx",
46227
+ "suite": "",
46228
+ "test": "A record whose rows' keys the app builds from the row: stock locations keyed by their aisle and their bin. `rowKey` on the tag builds a row's key from the row, so a location Add drafts is keyed at once by what its cells hold, moves under the key it then builds as its aisle or its bin is typed — in the step of the edit, which Undo takes back with it — and is saved there; one that would build a key another location holds is refused, the status line naming the key. `newRow` gives a new location its aisle. Give `rowKey` or `newKey`, never both; `keyField` names a field of the row that holds its key",
46229
+ "keywords": [
46230
+ "Record",
46231
+ "rowKey",
46232
+ "built key",
46233
+ "key from the row",
46234
+ "row key",
46235
+ "composite key",
46236
+ "natural key",
46237
+ "East.str",
46238
+ "newRow",
46239
+ "Record.patch",
46240
+ "Add",
46241
+ "duplicate key",
46242
+ "key taken",
46243
+ "refused"
46244
+ ],
46245
+ "imports": [
46246
+ "import {",
46247
+ "import { Box, Button, Configurator, HStack, Reactive, SegmentGroup, Slice, State, StatusValueType, Style, Text, UIComponentType, VStack } from \"@elaraai/east-ui\";",
46248
+ "import { Data, Record } from \"@elaraai/e3-ui\";",
46249
+ "import e3 from \"@elaraai/e3\";",
46250
+ "import { IndexedWork, indexedWorkOrders } from \"../sheet/sheet-records.examples.js\";"
46251
+ ],
46252
+ "languages": [
46253
+ "tsx"
46254
+ ],
46255
+ "source": "// A record whose rows' keys the app builds from the row: stock locations keyed by their aisle and their bin. `rowKey` on the tag builds a row's key from the row, so a location Add drafts is keyed at once by what its cells hold, moves under the key it then builds as its aisle or its bin is typed — in the step of the edit, which Undo takes back with it — and is saved there; one that would build a key another location holds is refused, the status line naming the key. `newRow` gives a new location its aisle. Give `rowKey` or `newKey`, never both; `keyField` names a field of the row that holds its key\n// inputs: []\n/** A stock location: what it holds, and the aisle and the bin its key is built from. */\nexport const StockLocation = StructType({ item: StringType, aisle: StringType, bin: IntegerType });\n\nexport const recordLocations = e3.record(\"record_locations\", DictType(StringType, StockLocation), {\n initial: new Map([\n [\"A-1\", { item: \"Pallet wrap\", aisle: \"A\", bin: 1n }],\n [\"A-2\", { item: \"Strapping\", aisle: \"A\", bin: 2n }],\n [\"B-1\", { item: \"Corner boards\", aisle: \"B\", bin: 1n }],\n ]),\n mutations: (mutation) => ({\n // The locations' patch door — every Save commits through it.\n patch: mutation.patch(),\n }),\n});\n\nEast.function([], UIComponentType, (_$) => (\n <Reactive>{$ => {\n const locations = $.let(Record.bind(recordLocations));\n // A new location as it is added: in aisle C, its bin and what it holds left to type.\n const newRow = $.const(East.function([Record.Types.NewRow], Record.Types.Patch(StockLocation), (_$) => Record.patch(StockLocation, { aisle: \"C\" })));\n return (\n <Box height=\"360px\">\n <Record\n record={locations}\n // A location's key, built from its row: its aisle and its bin.\n rowKey={(location) => East.str`${location.aisle}-${location.bin}`}\n title=\"Stock locations\"\n noun={{ singular: \"location\", plural: \"locations\" }}\n columns={{\n item: Record.column.title(StockLocation, { header: \"Holds\", width: \"200px\" }),\n aisle: Record.column.text(StockLocation, { header: \"Aisle\", width: \"96px\" }),\n bin: Record.column.integer(StockLocation, { header: \"Bin\", width: \"96px\" }),\n }}\n newRow={newRow}\n name=\"recordBuiltKeys\"\n />\n </Box>\n );\n }}</Reactive>\n ))"
45924
46256
  },
45925
46257
  {
45926
46258
  "id": "e3-ui:domain.examples.ts:rosterCoverage",
@@ -46036,7 +46368,7 @@
46036
46368
  "languages": [
46037
46369
  "typescript"
46038
46370
  ],
46039
- "source": "// The ready-made fit over one candidate — a person against the week: a trainer off that day whose rest is kept fits Goods' early shift, scored by spare contract hours and a week's more in the slot's group\n// inputs: [leadCandidate] returns: variant(\"fits\", { score: 198, why: \"Goods · 30 h spare\", warn: none })\nEast.function([Roster.Types.Candidate], Roster.Types.Fit, ($, candidate) => {\n // Monday's early shift: the lead's Sunday duty ends at 17:00, so 13 hours' rest is kept; 10 of their 40 contract hours are rostered.\n const fit = $.const(Roster.fit());\n return fit(candidate);\n })"
46371
+ "source": "// The ready-made fit over one candidate — a person against the week: a trainer off that day whose rest is kept fits Goods' early shift, scored by spare contract hours and a week's more in the slot's group\n// inputs: [leadCandidate] returns: variant(\"fits\", { score: 198, why: \"Goods · 30 h spare\", warn: none })\nEast.function([Roster.Types.Candidate()], Roster.Types.Fit, ($, candidate) => {\n // Monday's early shift: the lead's Sunday duty ends at 17:00, so 13 hours' rest is kept; 10 of their 40 contract hours are rostered.\n const fit = $.const(Roster.fit());\n return fit(candidate);\n })"
46040
46372
  },
46041
46373
  {
46042
46374
  "id": "e3-ui:domain.examples.ts:rosterWeekWindow",
@@ -46119,7 +46451,7 @@
46119
46451
  "package": "e3-ui",
46120
46452
  "file": "east-ui/packages/e3-ui/test/roster/domain.examples.ts",
46121
46453
  "suite": "",
46122
- "test": "Roster.answer maps a rule over every person of what a fit's function read (Roster.Types.FitContext), echoing the need and the slot: it places the duties in the week as the page does, and the lead fits while the two associates are refused as not leads",
46454
+ "test": "Roster.answer() maps a rule over every person of what a fit's function read (Roster.Types.FitContext()), echoing the need and the slot: it places the duties in the week as the page does, and the lead fits while the two associates are refused as not leads",
46123
46455
  "keywords": [
46124
46456
  "Roster",
46125
46457
  "Roster.answer",
@@ -46138,7 +46470,7 @@
46138
46470
  "languages": [
46139
46471
  "typescript"
46140
46472
  ],
46141
- "source": "// Roster.answer maps a rule over every person of what a fit's function read (Roster.Types.FitContext), echoing the need and the slot: it places the duties in the week as the page does, and the lead fits while the two associates are refused as not leads\n// inputs: [leadsRequest, read] returns: {\n need: variant(\"leads\", null), slot: { day: 1n, group: \"goods\", shift: \"early\" },\n people: new Map<string, ValueTypeOf<typeof Roster.Types.Fit>>([\n [\"agency\", variant(\"refused\", { group: \"Not a lead\", reason: \"Crew · not a lead\", measure: variant(\"none\", null) })],\n [\"lead\", variant(\"fits\", { score: 198, why: \"Goods · 30 h spare\", warn: none })],\n [\"off\", variant(\"refused\", { group: \"Not a lead\", reason: \"Crew · not a lead\", measure: variant(\"none\", null) })],\n ]),\n }\n/** Small staffing fixture with independently calculable hours and cost. */\nexport const context: ValueTypeOf<typeof Roster.Types.Context> = {\n people: new Map([\n [\"lead\", { key: \"lead\", name: \"Lead\", group: \"goods\", position: \"lead\", skills: new Set([\"reach\"]), contract: 40, agency: false, trainer: true, trainee: false, usual: some(\"early\") }],\n [\"agency\", { key: \"agency\", name: \"Agency\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 0, agency: true, trainer: false, trainee: false, usual: none }],\n [\"off\", { key: \"off\", name: \"Off\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 40, agency: false, trainer: false, trainee: false, usual: none }],\n ]),\n groups: [{ key: \"goods\", label: \"Goods\" }],\n // Goods' one skill, and the duty every group shares.\n activities: [{ key: \"reach\", label: \"Reach truck\", code: \"RT\", group: some(\"goods\") }, { key: \"general\", label: \"General duties\", code: \"GD\", group: none }],\n shifts: [\n { key: \"early\", label: \"Early\", code: \"E\", start: { hour: 6n, minute: 0n }, hours: 8, color: none },\n { key: \"late\", label: \"Late\", code: \"L\", start: { hour: 14n, minute: 0n }, hours: 8, color: none },\n { key: \"night\", label: \"Night\", code: \"N\", start: { hour: 22n, minute: 0n }, hours: 8, color: none },\n ],\n positions: [{ key: \"crew\", label: \"Crew\", code: \"\", lead: false }, { key: \"lead\", label: \"Lead\", code: \"SV\", lead: true }],\n agencies: [{ key: \"agency\", name: \"Staffing agency\" }],\n rules: { rest: 10, lead: true, skill: true, trainer: true },\n};\n\n/** A duty's roles, as the Roster reads them. */\ntype DutyRoles = ValueTypeOf<typeof Schedule.Types.RosterRoles>;\n\n/** The lead's Sunday duty as the Roster reads it: its roles. */\nconst leadSunday: DutyRoles = {\n start: new Date(\"2028-03-05T07:00:00Z\"), end: new Date(\"2028-03-05T17:00:00Z\"), resource: some({ kind: \"people\", key: \"lead\" }),\n shift: \"early\", group: some(\"goods\"), position: some(\"lead\"), activity: some(\"reach\"), hours: 10,\n};\n\n/**\n * What a fit's function read of the same Sunday (#1624): the people it asks about, the week's duties as their roles —\n * the lead's, the agency worker's and the request to the agency — the configuration, and ten hours' rest.\n */\nexport const read: ValueTypeOf<typeof Roster.Types.FitContext> = {\n people: context.people,\n duties: new Map<string, DutyRoles>([\n [\"a\", leadSunday],\n [\"b\", { start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), resource: some({ kind: \"people\", key: \"agency\" }),\n shift: \"early\", group: some(\"goods\"), position: some(\"crew\"), activity: some(\"general\"), hours: 8 }],\n [\"c\", { start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), resource: some({ kind: \"agencies\", key: \"agency\" }),\n shift: \"early\", group: some(\"goods\"), position: some(\"crew\"), activity: none, hours: 8 }],\n ]),\n shifts: context.shifts, groups: context.groups, positions: context.positions, activities: context.activities, rest: 10,\n};\n\nEast.function([Roster.Types.FitRequest, Roster.Types.FitContext], Roster.Types.FitResult, ($, request, read) => {\n const answer = $.const(Roster.answer);\n const fit = $.const(Roster.fit());\n return answer(request, read, fit);\n })"
46473
+ "source": "// Roster.answer() maps a rule over every person of what a fit's function read (Roster.Types.FitContext()), echoing the need and the slot: it places the duties in the week as the page does, and the lead fits while the two associates are refused as not leads\n// inputs: [leadsRequest, read] returns: {\n need: variant(\"leads\", null), slot: { day: 1n, group: \"goods\", shift: \"early\" },\n people: new Map<string, ValueTypeOf<typeof Roster.Types.Fit>>([\n [\"agency\", variant(\"refused\", { group: \"Not a lead\", reason: \"Crew · not a lead\", measure: variant(\"none\", null) })],\n [\"lead\", variant(\"fits\", { score: 198, why: \"Goods · 30 h spare\", warn: none })],\n [\"off\", variant(\"refused\", { group: \"Not a lead\", reason: \"Crew · not a lead\", measure: variant(\"none\", null) })],\n ]),\n }\n/** What a fit's function read of the week (#1624), and one candidate of it, the duties keyed by String. */\nexport const DomainRead = Roster.Types.FitContext(), DomainCandidate = Roster.Types.Candidate();\n\n/** Small staffing fixture with independently calculable hours and cost. */\nexport const context: ValueTypeOf<typeof Roster.Types.Context> = {\n people: new Map([\n [\"lead\", { key: \"lead\", name: \"Lead\", group: \"goods\", position: \"lead\", skills: new Set([\"reach\"]), contract: 40, agency: false, trainer: true, trainee: false, usual: some(\"early\") }],\n [\"agency\", { key: \"agency\", name: \"Agency\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 0, agency: true, trainer: false, trainee: false, usual: none }],\n [\"off\", { key: \"off\", name: \"Off\", group: \"goods\", position: \"crew\", skills: new Set<string>(), contract: 40, agency: false, trainer: false, trainee: false, usual: none }],\n ]),\n groups: [{ key: \"goods\", label: \"Goods\" }],\n // Goods' one skill, and the duty every group shares.\n activities: [{ key: \"reach\", label: \"Reach truck\", code: \"RT\", group: some(\"goods\") }, { key: \"general\", label: \"General duties\", code: \"GD\", group: none }],\n shifts: [\n { key: \"early\", label: \"Early\", code: \"E\", start: { hour: 6n, minute: 0n }, hours: 8, color: none },\n { key: \"late\", label: \"Late\", code: \"L\", start: { hour: 14n, minute: 0n }, hours: 8, color: none },\n { key: \"night\", label: \"Night\", code: \"N\", start: { hour: 22n, minute: 0n }, hours: 8, color: none },\n ],\n positions: [{ key: \"crew\", label: \"Crew\", code: \"\", lead: false }, { key: \"lead\", label: \"Lead\", code: \"SV\", lead: true }],\n agencies: [{ key: \"agency\", name: \"Staffing agency\" }],\n rules: { rest: 10, lead: true, skill: true, trainer: true },\n};\n\n/** A duty's roles, as the Roster reads them. */\ntype DutyRoles = ValueTypeOf<typeof Schedule.Types.RosterRoles>;\n\n/** The lead's Sunday duty as the Roster reads it: its roles. */\nconst leadSunday: DutyRoles = {\n start: new Date(\"2028-03-05T07:00:00Z\"), end: new Date(\"2028-03-05T17:00:00Z\"), resource: some({ kind: \"people\", key: \"lead\" }),\n shift: \"early\", group: some(\"goods\"), position: some(\"lead\"), activity: some(\"reach\"), hours: 10,\n};\n\n/**\n * What a fit's function read of the same Sunday (#1624): the people it asks about, the week's duties as their roles —\n * the lead's, the agency worker's and the request to the agency — the configuration, and ten hours' rest.\n */\nexport const read: ValueTypeOf<typeof DomainRead> = {\n people: context.people,\n duties: new Map<string, DutyRoles>([\n [\"a\", leadSunday],\n [\"b\", { start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), resource: some({ kind: \"people\", key: \"agency\" }),\n shift: \"early\", group: some(\"goods\"), position: some(\"crew\"), activity: some(\"general\"), hours: 8 }],\n [\"c\", { start: new Date(\"2028-03-05T06:00:00Z\"), end: new Date(\"2028-03-05T14:00:00Z\"), resource: some({ kind: \"agencies\", key: \"agency\" }),\n shift: \"early\", group: some(\"goods\"), position: some(\"crew\"), activity: none, hours: 8 }],\n ]),\n shifts: context.shifts, groups: context.groups, positions: context.positions, activities: context.activities, rest: 10,\n};\n\nEast.function([Roster.Types.FitRequest, Roster.Types.FitContext()], Roster.Types.FitResult, ($, request, read) => {\n const answer = $.const(Roster.answer());\n const fit = $.const(Roster.fit());\n return answer(request, read, fit);\n })"
46142
46474
  },
46143
46475
  {
46144
46476
  "id": "e3-ui:optimise.examples.tsx:rosterOptimise",
@@ -46264,7 +46596,7 @@
46264
46596
  "languages": [
46265
46597
  "tsx"
46266
46598
  ],
46267
- "source": "// 500 staff and a year of duties. The week's duties are read through the slice's duty source — an interval index over their times — and the rota's weeks by key, so no record is read whole; indexed staff narrowing keeps full-staff coverage and rules, and a Find fix asks the indexed roster's greedy fit, an e3.function that reads the holders of the need through the staff's indexes and the week's duties through their interval index, the Roster's unsaved duties laid over them (drafts), whatever the rail shows. Hidden duty edits Save by their own keys.\n// inputs: []\nconst stringOrder = compareFor(StringType);\n\nconst WEEK = 7 * 86_400_000;\n\n/** A larger staff pool for these indexed examples, preserving the mock's named people. */\nfunction staffSeed() {\n const people = new Map(warehouseStaff.default);\n const originals = [...people.values()];\n for (let i = 0; people.size < 500; i++) {\n const person = originals[i % originals.length]!;\n people.set(`pool-${1000 + i}`, { ...person, name: `${person.name} ${i + 1}` });\n }\n return people;\n}\n\n/** How many weeks of history before the warehouse's two: with its two, a year. */\nconst HISTORY = 50;\n\n/** A year of duties: the warehouse's two weeks, and each of the fifty weeks before them the week before's duties again, in its own week. */\nfunction dutySeed() {\n const duties = new SortedMap<string, ValueTypeOf<typeof WarehouseDuty>>(warehouseDuties, stringOrder);\n const before = [...warehouseDuties].filter(([, duty]) => duty.start.getTime() < warehousePreviousStart.getTime() + WEEK);\n for (let week = 1; week <= HISTORY; week++) {\n for (const [key, duty] of before) {\n duties.set(`h${week}-${key}`, { ...duty, start: new Date(duty.start.getTime() - week * WEEK), end: new Date(duty.end.getTime() - week * WEEK) });\n }\n }\n return duties;\n}\n\n/** The rota's weeks over the year: the warehouse's two, and each week of history issued at its end. */\nfunction weekSeed() {\n const weeks = new SortedMap<Date, ValueTypeOf<typeof WarehouseWeek>>(warehouseWeeks, compareFor(DateTimeType));\n const issued = warehouseWeeks.get(warehousePreviousStart)!;\n for (let week = 1; week <= HISTORY; week++) {\n const start = new Date(warehousePreviousStart.getTime() - week * WEEK);\n weeks.set(start, { ...issued, state: variant(\"issued\", { at: new Date(start.getTime() + WEEK - 12 * 3_600_000) }) });\n }\n return weeks;\n}\n\nexport const indexedRosterDuties = e3.record(\"indexed_roster_duties\", DictType(StringType, WarehouseDuty), {\n initial: dutySeed(),\n indexes: (index) => ({\n // The year's duties by their times: what the Roster's slice reads a week of them through.\n indexed_roster_duties_by_time: index.interval({ from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const indexedRosterWeeks = e3.record(\"indexed_roster_weeks\", DictType(DateTimeType, WarehouseWeek), {\n initial: weekSeed(),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const indexedRosterStaff = e3.record(\"indexed_roster_staff\", warehouseStaff.type, {\n initial: staffSeed(),\n indexes: (index) => ({\n staff_by_name: index.on([\"name\"]),\n staff_by_team_name: index.on([\"team\", \"name\"]),\n staff_by_trainer: index.on([\"trainer\"]),\n staff_by_skill: index.on([\"skills\"]),\n staff_by_position: index.on([\"position\"]),\n staff_by_agency: index.on([\"agency\"]),\n }),\n});\n\n/**\n * The indexed roster's fit, on e3 (#1624): the warehouse's greedy order over the 500 staff and the year's duties, each\n * read through its own record's indexes — the holders of the need, and the week's duties, the Roster's unsaved duties\n * among them. On a page scoped to some positions (#1621) — the leads' own — it asks about those positions' people\n * alone: it reads the request's `scope`, each value as East prints it.\n */\nexport const indexedStaffFit = e3.function(\"indexed_roster_staff_fit\", {\n inputs: [\n e3.index(indexedRosterDuties.indexes.indexed_roster_duties_by_time), indexedRosterDuties,\n e3.index(indexedRosterStaff.indexes.staff_by_skill),\n e3.index(indexedRosterStaff.indexes.staff_by_position),\n e3.index(indexedRosterStaff.indexes.staff_by_trainer), indexedRosterStaff,\n rosterShiftTimes, rosterTeams, rosterPositions, rosterActivities,\n ],\n // The Roster's unsaved duties are laid over them, and over their index\n drafts: [indexedRosterDuties],\n args: [Roster.Types.FitRequest],\n output: Roster.Types.FitResult,\n}, ($, dutiesByTime, duties, bySkill, byPosition, byTrainer, staff, shiftRows, teamRows, positionRows, activityRows, request) => {\n // The positions the page's scope holds its people to, if it holds them to any.\n const scoped = $.let(false, BooleanType);\n const held = $.let(new Set([]), SetType(StringType));\n $.match(request.scope.tryGet(\"people\"), { some: ($2, where) => {\n $2.match(where.tryGet(\"position\"), { some: ($3, choice) => {\n $3.match(choice, { values: ($4, texts) => {\n $4.assign(scoped, true);\n $4.for(texts, ($5, text) => { $5(held.tryInsert(text.parse(StringType))); });\n } });\n } });\n } });\n // Whom to ask about: the holders of the need, each read through its index — of the scope's positions, on a scoped page.\n const holders = $.let(new Set([]), SetType(StringType));\n $.match(request.need, {\n skill: ($2, skill) => { bySkill.of(skill).each($2, ($3, _carried, key) => { $3(holders.tryInsert(key)); }); },\n trainers: ($2) => { byTrainer.of(true).each($2, ($3, _carried, key) => { $3(holders.tryInsert(key)); }); },\n leads: ($2) => {\n $2.for(positionRows, ($3, position, code) => {\n $3.if(position.lead, ($4) => { byPosition.of(code).each($4, ($5, _carried, key) => { $5(holders.tryInsert(key)); }); });\n });\n },\n });\n const person = $.const(rosterPersonOf);\n const people = $.let(new Map(), DictType(StringType, Roster.Types.Person));\n $.for(holders, ($2, key) => {\n const row = $2.const(staff.get(key));\n $2.if(scoped.not().or(() => held.has(row.position)), ($3) => { $3(people.insert(key, person(row, key))); });\n });\n const roles = $.const(rosterDutyRoles);\n const windowOf = $.const(Roster.window);\n const span = $.const(windowOf(request.start));\n const week = $.let(new Map(), DictType(StringType, Schedule.Types.RosterRoles));\n dutiesByTime.overlapping({ from: span.from, to: span.to }).each($, ($2, _carried, key) => { $2(week.insert(key, roles(duties.get(key)))); });\n const read = $.const(rosterFitRead);\n const answer = $.const(Roster.answer);\n return answer(request, read(people, week, shiftRows, teamRows, positionRows, activityRows), rosterGreedyFit);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const rota = $.let(Record.bind(indexedRosterDuties));\n const entries = $.let(Data.bindPaged(indexedRosterDuties));\n const byTime = $.let(Data.bindPaged(indexedRosterDuties, { indexes: [\"indexed_roster_duties_by_time\"] }));\n const weeks = $.let(Record.bind(indexedRosterWeeks));\n const weekEntries = $.let(Data.bindPaged(indexedRosterWeeks));\n const cover = $.let(Record.bind(rosterCover));\n // Complete staff is the calculation context; visibility is a separate indexed query.\n const staff = $.let(Data.bind(indexedRosterStaff));\n const acts = $.let(Data.bind(rosterActivities));\n // One rail over the week's duties, the staff, opening on Inbound, and the activities (#1342).\n const people = $.let(Data.bindPaged(indexedRosterStaff, { indexes: [\"staff_by_name\", \"staff_by_team_name\", \"staff_by_position\", \"staff_by_trainer\", \"staff_by_agency\", \"staff_by_skill\"] }));\n const activities = $.let(Data.bindPaged(rosterActivities, { indexes: [\"roster_activities_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.rosterRecordIndexes\", {\n duty: { source: byTime, range: \"start\" },\n people: { source: people, icon: { prefix: \"fas\", name: \"user\" }, search: [\"name\", \"skills\"], initial: { team: [\"inbound\"] },\n fields: { team: { label: \"Group\", hints: [\"inbound\", \"picking\", \"dispatch\"] }, name: { label: \"Name\" }, position: { label: \"Position\", hints: [\"lead\", \"deputy\", \"acting\", \"crew\"] },\n trainer: { label: \"Trainer\" }, agency: { label: \"Agency\" }, skills: { label: \"Skills\" } } },\n activities: { source: activities, icon: { prefix: \"fas\", name: \"list-check\" }, fields: { group: { label: \"Group\", hints: [\"inbound\", \"picking\", \"dispatch\", null] } } },\n }, { presets: [{ id: \"trainers\", name: \"Trainers\", where: { people: { trainer: [true] } } }] }));\n const firms = $.let(Data.bind(rosterAgencies));\n const times = $.let(Data.bind(rosterShiftTimes));\n const teams = $.let(Data.bind(rosterTeams));\n const roles = $.let(Data.bind(rosterPositions));\n const ideas = $.let(Data.bind(rosterSuggestions));\n // The app's fit: a Find fix asks it who fits — it reads the 500 staff's holders of the need for itself — and the People tab\n // shows its answer among what the rail shows.\n const fit = $.let(Func.bind(indexedStaffFit));\n return <Box width=\"100%\" height=\"760px\"><Roster id=\"rosterRecordIndexes\" week={{ start: \"sunday\" }} slice={{ slice }} fit={fit} inspector\n view={{ layout: \"shifts\", period: \"day\", date: new Date(\"2028-03-09T00:00:00Z\") }}\n events={{ duty: Schedule.events(rota, {\n name: \"Duty\", icon: \"user-clock\", entries,\n start: \"start\", end: \"end\", resource: { field: \"who\", of: { staff: \"people\", agency: \"agencies\" } },\n shift: \"shift\", group: \"team\", position: \"role\", activity: \"task\",\n hours: d => d.start.durationMinutes(d.end).subtract(d.unpaidBreak).divide(60.0),\n }) }}\n resources={{\n people: Schedule.resources(staff.read(), { name: \"People\", icon: \"user\", label: p => p.name, group: p => p.team,\n position: p => p.position, skills: p => p.skills, contract: p => p.contract, agency: p => p.agency,\n trainer: p => p.trainer, trainee: p => p.trainee, usual: p => p.usual }),\n agencies: Schedule.resources(firms.read(), { name: \"Agencies\", icon: \"building\", label: a => a.name }),\n }}\n periods={Schedule.periods(weeks, { every: \"week\", status: { field: \"state\", draft: \"open\", published: \"issued\" }, dismissed: \"dismissed\", entries: weekEntries })}\n targets={Roster.targets(cover, { day: \"day\", group: \"team\", shift: \"shift\", positions: \"heads\", hours: \"hours\" })}\n shifts={Roster.shifts(times.read(), { label: s => s.label, code: s => s.code, start: s => s.start, hours: s => s.hours, order: s => s.order })}\n groups={Roster.groups(teams.read(), { label: t => t.label, order: t => t.order })}\n positions={Roster.positions(roles.read(), { label: p => p.label, code: p => p.code, lead: p => p.lead, order: p => p.order })}\n activities={Roster.activities(acts.read(), { label: a => a.label, code: a => a.code, group: a => a.group, order: a => a.order })}\n proposals={Roster.proposals(ideas.read(), { person: s => s.person, day: s => s.day, group: s => s.team, shift: s => s.shift, reason: s => s.why })}\n rules={{ rest: 10.0 }}\n library={[Roster.library.people(), Roster.library.activities()]} />\n </Box>;\n }}</Reactive>)"
46599
+ "source": "// 500 staff and a year of duties. The week's duties are read through the slice's duty source — an interval index over their times — and the rota's weeks by key, so no record is read whole; indexed staff narrowing keeps full-staff coverage and rules, and a Find fix asks the indexed roster's greedy fit, an e3.function that reads the holders of the need through the staff's indexes and the week's duties through their interval index, the Roster's unsaved duties laid over them (drafts), whatever the rail shows. Hidden duty edits Save by their own keys.\n// inputs: []\nconst stringOrder = compareFor(StringType);\n\nconst WEEK = 7 * 86_400_000;\n\n/** A larger staff pool for these indexed examples, preserving the mock's named people. */\nfunction staffSeed() {\n const people = new Map(warehouseStaff.default);\n const originals = [...people.values()];\n for (let i = 0; people.size < 500; i++) {\n const person = originals[i % originals.length]!;\n people.set(`pool-${1000 + i}`, { ...person, name: `${person.name} ${i + 1}` });\n }\n return people;\n}\n\n/** How many weeks of history before the warehouse's two: with its two, a year. */\nconst HISTORY = 50;\n\n/** A year of duties: the warehouse's two weeks, and each of the fifty weeks before them the week before's duties again, in its own week. */\nfunction dutySeed() {\n const duties = new SortedMap<string, ValueTypeOf<typeof WarehouseDuty>>(warehouseDuties, stringOrder);\n const before = [...warehouseDuties].filter(([, duty]) => duty.start.getTime() < warehousePreviousStart.getTime() + WEEK);\n for (let week = 1; week <= HISTORY; week++) {\n for (const [key, duty] of before) {\n duties.set(`h${week}-${key}`, { ...duty, start: new Date(duty.start.getTime() - week * WEEK), end: new Date(duty.end.getTime() - week * WEEK) });\n }\n }\n return duties;\n}\n\n/** The rota's weeks over the year: the warehouse's two, and each week of history issued at its end. */\nfunction weekSeed() {\n const weeks = new SortedMap<Date, ValueTypeOf<typeof WarehouseWeek>>(warehouseWeeks, compareFor(DateTimeType));\n const issued = warehouseWeeks.get(warehousePreviousStart)!;\n for (let week = 1; week <= HISTORY; week++) {\n const start = new Date(warehousePreviousStart.getTime() - week * WEEK);\n weeks.set(start, { ...issued, state: variant(\"issued\", { at: new Date(start.getTime() + WEEK - 12 * 3_600_000) }) });\n }\n return weeks;\n}\n\nexport const indexedRosterDuties = e3.record(\"indexed_roster_duties\", DictType(StringType, WarehouseDuty), {\n initial: dutySeed(),\n indexes: (index) => ({\n // The year's duties by their times: what the Roster's slice reads a week of them through.\n indexed_roster_duties_by_time: index.interval({ from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const indexedRosterWeeks = e3.record(\"indexed_roster_weeks\", DictType(DateTimeType, WarehouseWeek), {\n initial: weekSeed(),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\nexport const indexedRosterStaff = e3.record(\"indexed_roster_staff\", warehouseStaff.type, {\n initial: staffSeed(),\n indexes: (index) => ({\n staff_by_name: index.on([\"name\"]),\n staff_by_team_name: index.on([\"team\", \"name\"]),\n staff_by_trainer: index.on([\"trainer\"]),\n staff_by_skill: index.on([\"skills\"]),\n staff_by_position: index.on([\"position\"]),\n staff_by_agency: index.on([\"agency\"]),\n }),\n});\n\n/**\n * The indexed roster's fit, on e3 (#1624): the warehouse's greedy order over the 500 staff and the year's duties, each\n * read through its own record's indexes — the holders of the need, and the week's duties, the Roster's unsaved duties\n * among them. On a page scoped to some positions (#1621) — the leads' own — it asks about those positions' people\n * alone: it reads the request's `scope`, each value as East prints it.\n */\nexport const indexedStaffFit = e3.function(\"indexed_roster_staff_fit\", {\n inputs: [\n e3.index(indexedRosterDuties.indexes.indexed_roster_duties_by_time), indexedRosterDuties,\n e3.index(indexedRosterStaff.indexes.staff_by_skill),\n e3.index(indexedRosterStaff.indexes.staff_by_position),\n e3.index(indexedRosterStaff.indexes.staff_by_trainer), indexedRosterStaff,\n rosterShiftTimes, rosterTeams, rosterPositions, rosterActivities,\n ],\n // The Roster's unsaved duties are laid over them, and over their index\n drafts: [indexedRosterDuties],\n args: [Roster.Types.FitRequest],\n output: Roster.Types.FitResult,\n}, ($, dutiesByTime, duties, bySkill, byPosition, byTrainer, staff, shiftRows, teamRows, positionRows, activityRows, request) => {\n // The positions the page's scope holds its people to, if it holds them to any.\n const scoped = $.let(false, BooleanType);\n const held = $.let(new Set([]), SetType(StringType));\n $.match(request.scope.tryGet(\"people\"), { some: ($2, where) => {\n $2.match(where.tryGet(\"position\"), { some: ($3, choice) => {\n $3.match(choice, { values: ($4, texts) => {\n $4.assign(scoped, true);\n $4.for(texts, ($5, text) => { $5(held.tryInsert(text.parse(StringType))); });\n } });\n } });\n } });\n // Whom to ask about: the holders of the need, each read through its index — of the scope's positions, on a scoped page.\n const holders = $.let(new Set([]), SetType(StringType));\n $.match(request.need, {\n skill: ($2, skill) => { bySkill.of(skill).each($2, ($3, _carried, key) => { $3(holders.tryInsert(key)); }); },\n trainers: ($2) => { byTrainer.of(true).each($2, ($3, _carried, key) => { $3(holders.tryInsert(key)); }); },\n leads: ($2) => {\n $2.for(positionRows, ($3, position, code) => {\n $3.if(position.lead, ($4) => { byPosition.of(code).each($4, ($5, _carried, key) => { $5(holders.tryInsert(key)); }); });\n });\n },\n });\n const person = $.const(rosterPersonOf);\n const people = $.let(new Map(), DictType(StringType, Roster.Types.Person));\n $.for(holders, ($2, key) => {\n const row = $2.const(staff.get(key));\n $2.if(scoped.not().or(() => held.has(row.position)), ($3) => { $3(people.insert(key, person(row, key))); });\n });\n const roles = $.const(rosterDutyRoles);\n const windowOf = $.const(Roster.window);\n const span = $.const(windowOf(request.start));\n const week = $.let(new Map(), DictType(StringType, Schedule.Types.RosterRoles));\n dutiesByTime.overlapping({ from: span.from, to: span.to }).each($, ($2, _carried, key) => { $2(week.insert(key, roles(duties.get(key)))); });\n const read = $.const(rosterFitRead);\n const answer = $.const(Roster.answer());\n return answer(request, read(people, week, shiftRows, teamRows, positionRows, activityRows), rosterGreedyFit);\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const rota = $.let(Record.bind(indexedRosterDuties));\n const entries = $.let(Data.bindPaged(indexedRosterDuties));\n const byTime = $.let(Data.bindPaged(indexedRosterDuties, { indexes: [\"indexed_roster_duties_by_time\"] }));\n const weeks = $.let(Record.bind(indexedRosterWeeks));\n const weekEntries = $.let(Data.bindPaged(indexedRosterWeeks));\n const cover = $.let(Record.bind(rosterCover));\n // Complete staff is the calculation context; visibility is a separate indexed query.\n const staff = $.let(Data.bind(indexedRosterStaff));\n const acts = $.let(Data.bind(rosterActivities));\n // One rail over the week's duties, the staff, opening on Inbound, and the activities (#1342).\n const people = $.let(Data.bindPaged(indexedRosterStaff, { indexes: [\"staff_by_name\", \"staff_by_team_name\", \"staff_by_position\", \"staff_by_trainer\", \"staff_by_agency\", \"staff_by_skill\"] }));\n const activities = $.let(Data.bindPaged(rosterActivities, { indexes: [\"roster_activities_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.rosterRecordIndexes\", {\n duty: { source: byTime, range: \"start\" },\n people: { source: people, icon: { prefix: \"fas\", name: \"user\" }, search: [\"name\", \"skills\"], initial: { team: [\"inbound\"] },\n fields: { team: { label: \"Group\", hints: [\"inbound\", \"picking\", \"dispatch\"] }, name: { label: \"Name\" }, position: { label: \"Position\", hints: [\"lead\", \"deputy\", \"acting\", \"crew\"] },\n trainer: { label: \"Trainer\" }, agency: { label: \"Agency\" }, skills: { label: \"Skills\" } } },\n activities: { source: activities, icon: { prefix: \"fas\", name: \"list-check\" }, fields: { group: { label: \"Group\", hints: [\"inbound\", \"picking\", \"dispatch\", null] } } },\n }, { presets: [{ id: \"trainers\", name: \"Trainers\", where: { people: { trainer: [true] } } }] }));\n const firms = $.let(Data.bind(rosterAgencies));\n const times = $.let(Data.bind(rosterShiftTimes));\n const teams = $.let(Data.bind(rosterTeams));\n const roles = $.let(Data.bind(rosterPositions));\n const ideas = $.let(Data.bind(rosterSuggestions));\n // The app's fit: a Find fix asks it who fits — it reads the 500 staff's holders of the need for itself — and the People tab\n // shows its answer among what the rail shows.\n const fit = $.let(Func.bind(indexedStaffFit));\n return <Box width=\"100%\" height=\"760px\"><Roster id=\"rosterRecordIndexes\" week={{ start: \"sunday\" }} slice={{ slice }} fit={fit} inspector\n view={{ layout: \"shifts\", period: \"day\", date: new Date(\"2028-03-09T00:00:00Z\") }}\n events={{ duty: Schedule.events(rota, {\n name: \"Duty\", icon: \"user-clock\", entries,\n start: \"start\", end: \"end\", resource: { field: \"who\", of: { staff: \"people\", agency: \"agencies\" } },\n shift: \"shift\", group: \"team\", position: \"role\", activity: \"task\",\n hours: d => d.start.durationMinutes(d.end).subtract(d.unpaidBreak).divide(60.0),\n }) }}\n resources={{\n people: Schedule.resources(staff.read(), { name: \"People\", icon: \"user\", label: p => p.name, group: p => p.team,\n position: p => p.position, skills: p => p.skills, contract: p => p.contract, agency: p => p.agency,\n trainer: p => p.trainer, trainee: p => p.trainee, usual: p => p.usual }),\n agencies: Schedule.resources(firms.read(), { name: \"Agencies\", icon: \"building\", label: a => a.name }),\n }}\n periods={Schedule.periods(weeks, { every: \"week\", status: { field: \"state\", draft: \"open\", published: \"issued\" }, dismissed: \"dismissed\", entries: weekEntries })}\n targets={Roster.targets(cover, { day: \"day\", group: \"team\", shift: \"shift\", positions: \"heads\", hours: \"hours\" })}\n shifts={Roster.shifts(times.read(), { label: s => s.label, code: s => s.code, start: s => s.start, hours: s => s.hours, order: s => s.order })}\n groups={Roster.groups(teams.read(), { label: t => t.label, order: t => t.order })}\n positions={Roster.positions(roles.read(), { label: p => p.label, code: p => p.code, lead: p => p.lead, order: p => p.order })}\n activities={Roster.activities(acts.read(), { label: a => a.label, code: a => a.code, group: a => a.group, order: a => a.order })}\n proposals={Roster.proposals(ideas.read(), { person: s => s.person, day: s => s.day, group: s => s.team, shift: s => s.shift, reason: s => s.why })}\n rules={{ rest: 10.0 }}\n library={[Roster.library.people(), Roster.library.activities()]} />\n </Box>;\n }}</Reactive>)"
46268
46600
  },
46269
46601
  {
46270
46602
  "id": "e3-ui:roster-records.examples.tsx:rosterRecordIndexesMobile",
@@ -46345,7 +46677,7 @@
46345
46677
  "languages": [
46346
46678
  "tsx"
46347
46679
  ],
46348
- "source": "// The mock warehouse roster over its own records: its duties, the weeks of its rota, its cover targets and suggestions, 69 staff and an agency, its shift times, teams, positions and activities. One Slice.bindRecords rail over the week's duties, the staff and the activities; the warehouse's pay in its own codes and its check over the pay; a new duty's own fields, a new target's basis and a new week's approver from the app's `values`; Publish; a Positions tab; the inspector; and the warehouse's greedy fit on e3, which a Find fix asks who fits.\n// inputs: []\n/** The duties, both weeks', each the warehouse's own row. */\nexport const rosterDuties = e3.record(\"roster_duties\", DictType(StringType, WarehouseDuty), {\n initial: warehouseDuties,\n indexes: (index) => ({\n // The duties by their times: what the Roster's slice reads a week of them through, its navigation writing the range.\n roster_duties_by_time: index.interval({ from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The weeks of the rota: the one before issued, this one open. */\nexport const rosterWeeks = e3.record(\"roster_rota_weeks\", DictType(DateTimeType, WarehouseWeek), {\n initial: warehouseWeeks,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The cover targets, a row per slot: the week before's, this week's and the forecast's for the week after. */\nexport const rosterCover = e3.record(\"roster_cover\", DictType(StringType, WarehouseCover), {\n initial: warehouseCover,\n indexes: (index) => ({\n // The targets by their day: what the warehouse's optimiser reads a week of them through (#1622).\n roster_cover_by_day: index.interval({ from: \"day\", to: \"day\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The suggestions: someone for a slot, and why. */\nexport const rosterSuggestions = e3.record(\"roster_suggestions\", DictType(StringType, WarehouseSuggestion), {\n initial: warehouseSuggestions,\n mutations: (mutation) => ({\n // The suggestions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\n/** The pay rates, an hour, by the warehouse's own pay codes. */\nexport const rosterPayRates = e3.record(\"roster_pay_rates\", DictType(StringType, FloatType), { initial: warehousePayRates });\n\nexport const rosterStaff = e3.record(\"roster_staff\", DictType(StringType, WarehousePerson), {\n initial: warehousePeople,\n indexes: (index) => ({\n // The rail's fields, each on an index of its own: the staff by group then name, position, trainer, agency, skill and name, the activities by group.\n roster_staff_by_team_name: index.on([\"team\", \"name\"]),\n roster_staff_by_position: index.on([\"position\"]),\n roster_staff_by_trainer: index.on([\"trainer\"]),\n roster_staff_by_agency: index.on([\"agency\"]),\n roster_staff_by_skill: index.on([\"skills\"]),\n roster_staff_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // What the renderer's tests on e3 write and ask beside the examples (#1376): another session's edits of the\n // reference data, a roster the warehouse has locked, and another app's fit over the same staff.\n // The staff's patch door: another session's edit of the staff.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterAgencies = e3.record(\"roster_agencies\", DictType(StringType, WarehouseAgency), { initial: warehouseAgencies });\n\nexport const rosterShiftTimes = e3.record(\"roster_shift_times\", DictType(StringType, WarehouseShift), {\n initial: warehouseShifts,\n mutations: (mutation) => ({\n // The shift times' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterTeams = e3.record(\"roster_teams\", DictType(StringType, WarehouseTeam), {\n initial: warehouseTeams,\n mutations: (mutation) => ({\n // The teams' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterPositions = e3.record(\"roster_positions\", DictType(StringType, WarehousePosition), {\n initial: warehousePositions,\n mutations: (mutation) => ({\n // The positions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\n/** Every activity by its key: each group's skills, and the duty of none (#1342). */\nexport const rosterActivities = e3.record(\"roster_activities\", DictType(StringType, WarehouseActivity), {\n initial: warehouseActivities,\n indexes: (index) => ({\n roster_activities_by_group: index.on([\"group\"]),\n }),\n});\n\n/**\n * A person as the Roster reads one: the reading the page's `people` kind declares, written once more for a function\n * that reads the staff itself (#1624).\n */\nexport const rosterPersonOf = East.function([WarehousePerson, StringType], Roster.Types.Person, (_$, p, key) => ({\n key, name: p.name, group: p.team, position: p.position, skills: p.skills, contract: p.contract,\n agency: p.agency, trainer: p.trainer, trainee: p.trainee, usual: p.usual,\n}));\n\n/**\n * A duty's roles as the Roster reads them: the reading the page's duty kind declares, written once more for a function\n * that reads the duties itself (#1624) — who, as a person or an agency's request, and the hours it counts, its length\n * less its unpaid break.\n */\nexport const rosterDutyRoles = East.function([WarehouseDuty], Schedule.Types.RosterRoles, (_$, d) => ({\n start: d.start, end: d.end,\n resource: some(d.who.match({\n staff: (_$2, key) => East.value({ kind: \"people\", key }, Schedule.Types.ResourceRef),\n agency: (_$2, key) => East.value({ kind: \"agencies\", key }, Schedule.Types.ResourceRef),\n })),\n shift: d.shift, group: some(d.team), position: some(d.role), activity: d.task,\n hours: d.start.durationMinutes(d.end).subtract(d.unpaidBreak).divide(60.0),\n}));\n\n/**\n * The warehouse's fit, on e3: who fits a Find fix's need on its slot — the ready-made rule, then a greedy order: the\n * people off that day with the most spare contract hours first, whatever their group. It is asked the need, the slot and\n * the week's first day, and no row. It reads the holders of the need through the staff's indexes, so nobody else is\n * asked about; the week's duties through their interval index, over the window the Roster reads them over, the Roster's\n * unsaved duties among them; and the shifts, the teams, the positions and the activities from the warehouse's own records.\n */\nexport const rosterStaffFit = e3.function(\"roster_staff_fit\", {\n inputs: [\n e3.index(rosterDuties.indexes.roster_duties_by_time), rosterDuties,\n e3.index(rosterStaff.indexes.roster_staff_by_skill),\n e3.index(rosterStaff.indexes.roster_staff_by_position),\n e3.index(rosterStaff.indexes.roster_staff_by_trainer), rosterStaff,\n rosterShiftTimes, rosterTeams, rosterPositions, rosterActivities,\n ],\n // The Roster's unsaved duties are laid over them, and over their index\n drafts: [rosterDuties],\n args: [Roster.Types.FitRequest],\n output: Roster.Types.FitResult,\n}, ($, dutiesByTime, duties, bySkill, byPosition, byTrainer, staff, shiftRows, teamRows, positionRows, activityRows, request) => {\n // Whom to ask about: the holders of the need, each read through its index. Nobody sent the staff.\n const person = $.const(rosterPersonOf);\n const people = $.let(new Map(), DictType(StringType, Roster.Types.Person));\n $.match(request.need, {\n skill: ($2, skill) => {\n bySkill.of(skill).each($2, ($3, _carried, key) => { $3(people.insert(key, person(staff.get(key), key))); });\n },\n trainers: ($2) => {\n byTrainer.of(true).each($2, ($3, _carried, key) => { $3(people.insert(key, person(staff.get(key), key))); });\n },\n leads: ($2) => {\n $2.for(positionRows, ($3, position, code) => {\n $3.if(position.lead, ($4) => {\n byPosition.of(code).each($4, ($5, _carried, key) => { $5(people.insert(key, person(staff.get(key), key))); });\n });\n });\n },\n });\n // The week's duties, over the window the Roster reads them over. The index carries no row: it gives each duty's key,\n // and the record its row, both at the one drafted state.\n const roles = $.const(rosterDutyRoles);\n const windowOf = $.const(Roster.window);\n const span = $.const(windowOf(request.start));\n const week = $.let(new Map(), DictType(StringType, Schedule.Types.RosterRoles));\n dutiesByTime.overlapping({ from: span.from, to: span.to }).each($, ($2, _carried, key) => { $2(week.insert(key, roles(duties.get(key)))); });\n // The configuration, from the warehouse's own records.\n const shifts = $.let([], ArrayType(Roster.Types.Shift));\n $.for(shiftRows, ($2, s, key) => { $2(shifts.pushLast({ key, label: s.label, code: s.code, start: s.start, hours: s.hours, color: s.colour })); });\n const groups = $.let([], ArrayType(Roster.Types.Group));\n $.for(teamRows, ($2, t, key) => { $2(groups.pushLast({ key, label: t.label })); });\n const positions = $.let([], ArrayType(Roster.Types.Position));\n $.for(positionRows, ($2, p, key) => { $2(positions.pushLast({ key, label: p.label, code: p.code, lead: p.lead })); });\n const activities = $.let([], ArrayType(Roster.Types.Skill));\n $.for(activityRows, ($2, a, key) => { $2(activities.pushLast({ key, label: a.label, code: a.code, group: a.group })); });\n const context = $.const({ people, duties: week, shifts, groups, positions, activities, rest: 10.0 }, Roster.Types.FitContext);\n // The ready-made rule, then the warehouse's order: the most spare contract hours first, whatever the group.\n const answer = $.const(Roster.answer);\n const rule = $.const(Roster.fit());\n return answer(request, context, East.function([Roster.Types.Candidate], Roster.Types.Fit, ($2, candidate) => {\n const verdict = $2.const(rule(candidate));\n $2.match(verdict, { refused: ($3) => { $3.return(verdict); } });\n const fits = $2.const(verdict.unwrap(\"fits\"));\n return variant(\"fits\", { score: candidate.person.contract.subtract(candidate.hours), why: fits.why, warn: fits.warn });\n }));\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n // What the Roster writes: the duties, the weeks of the rota and the cover targets, each through its patch door.\n const rota = $.let(Record.bind(rosterDuties));\n const entries = $.let(Data.bindPaged(rosterDuties));\n const byTime = $.let(Data.bindPaged(rosterDuties, { indexes: [\"roster_duties_by_time\"] }));\n const weeks = $.let(Record.bind(rosterWeeks));\n const cover = $.let(Record.bind(rosterCover));\n // Every person and activity is the calculation scope; the narrowing only chooses which show (#1342).\n const people = $.let(Data.bind(rosterStaff));\n const acts = $.let(Data.bind(rosterActivities));\n const staffIndex = $.let(Data.bindPaged(rosterStaff, { indexes: [\"roster_staff_by_team_name\", \"roster_staff_by_position\", \"roster_staff_by_trainer\", \"roster_staff_by_agency\", \"roster_staff_by_skill\", \"roster_staff_by_name\"] }));\n const actIndex = $.let(Data.bindPaged(rosterActivities, { indexes: [\"roster_activities_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.rosterWarehouse\", {\n // The week's duties: the Roster's navigation writes the range; no chip picks the week.\n duty: { source: byTime, range: \"start\" },\n people: { source: staffIndex, icon: { prefix: \"fas\", name: \"user\" }, search: [\"name\", \"skills\"],\n fields: { team: { label: \"Group\", hints: [{ value: \"inbound\", label: \"Inbound\" }, { value: \"picking\", label: \"Picking\" }, { value: \"dispatch\", label: \"Dispatch\" }] }, position: { label: \"Position\", hints: [{ value: \"lead\", label: \"Lead\" }, { value: \"deputy\", label: \"Deputy\" }, { value: \"acting\", label: \"Acting\" }, { value: \"crew\", label: \"Crew\" }] },\n trainer: { label: \"Trainer\" }, agency: { label: \"Agency\" }, skills: { label: \"Skill\" }, name: { label: \"Name\" } } },\n activities: { source: actIndex, icon: { prefix: \"fas\", name: \"list-check\" }, fields: { group: { label: \"Group\", hints: [{ value: \"inbound\", label: \"Inbound\" }, { value: \"picking\", label: \"Picking\" }, { value: \"dispatch\", label: \"Dispatch\" }, null] } } },\n }, { presets: [{ id: \"leads\", name: \"Leads\", where: { people: { position: [\"lead\", \"deputy\", \"acting\"] } } }] }));\n const firms = $.let(Data.bind(rosterAgencies));\n const times = $.let(Data.bind(rosterShiftTimes));\n const teams = $.let(Data.bind(rosterTeams));\n // Each team's cost centre: what a new duty of the team is booked to.\n const centres = $.const(teams.read().map((_$2, team) => team.costCentre));\n const roles = $.let(Data.bind(rosterPositions));\n const ideas = $.let(Data.bind(rosterSuggestions));\n const rateRows = $.let(Data.bind(rosterPayRates));\n const rates = $.const(rateRows.read());\n // The app's fit: a Find fix asks it who fits, over every person, and the People tab shows its answer.\n const fit = $.let(Func.bind(rosterStaffFit));\n // The warehouse's pay (§5.6), in its own codes. One person's duties for the week in, or one agency's requests;\n // each duty's cost by code out: ordinary time up to the person's contracted hours in the week, OT1 past them,\n // and an agency's hours — its named worker's, or its request's — at its own rate.\n const pay = $.const(East.function([Roster.Types.PayRequest(WarehouseDuty)], Roster.Types.Pay, ($2, req) => {\n const out = $2.let(new Map(), Roster.Types.Pay);\n const zero = $2.const(0.0, FloatType);\n const agency = $2.let(true, BooleanType);\n const contract = $2.let(0.0, FloatType);\n $2.match(req.who, { person: ($3, key) => {\n $3.if(req.context.people.has(key), ($4) => {\n const person = $4.const(req.context.people.get(key));\n $4.assign(agency, person.agency);\n $4.assign(contract, person.contract);\n });\n } });\n const worked = $2.let(0.0, FloatType);\n // The week's duties in time order, so the contract's hours run out where they do.\n const ordered = $2.const(req.duties.toArray(($3, duty, key) => ({ key, duty })).sort(($3, d) => d.duty.start));\n $2.for(ordered, ($3, d) => {\n const costs = $3.let(new Map(), DictType(StringType, FloatType));\n $3.if(agency, ($4) => {\n $4(costs.insert(\"AGENCY\", d.duty.hours.multiply(rates.get(\"AGENCY\", () => 0.0))));\n }).else(($4) => {\n const ordinary = $4.const(East.max(East.min(d.duty.hours, contract.subtract(worked)), zero));\n const over = $4.const(d.duty.hours.subtract(ordinary));\n $4(costs.insert(\"ORD\", ordinary.multiply(rates.get(\"ORD\", () => 0.0))));\n $4.if(East.greater(over, 0.0), ($5) => { $5(costs.insert(\"OT1\", over.multiply(rates.get(\"OT1\", () => 0.0)))); });\n });\n $3.assign(worked, worked.add(d.duty.hours));\n $3(out.insert(d.key, costs));\n });\n return out;\n }));\n // The warehouse's check sees the pay too (§5.8): overtime on a duty nobody has agreed.\n const check = $.const(East.function([Roster.Types.CheckContext(WarehouseDuty)], ArrayType(Roster.Types.Issue), ($2, cx) => {\n const issues = $2.let([], ArrayType(Roster.Types.Issue));\n const slotOf = $2.const(Roster.slotOf);\n $2.for(cx.week.assignments, ($3, a, id) => {\n const costs = $3.const(cx.pay.get(id, () => East.value(new Map(), DictType(StringType, FloatType))));\n $3.if(costs.has(\"OT1\").and(() => East.notEqual(a.row.agreed, some(true))), ($4) => {\n $4(issues.pushLast({ kind: variant(\"breach\", null), tone: variant(\"info\", null),\n title: \"Overtime not agreed\", detail: East.str`${a.row.team} · ${a.row.shift}`,\n slot: slotOf(a.place), assignment: some(id), flag: some(\"OT\"), fix: none }));\n });\n });\n return issues;\n }));\n return <Box width=\"100%\" height=\"760px\"><Roster id=\"rosterWarehouse\" week={{ start: \"sunday\" }} slice={{ slice }} fit={fit}\n pay={pay} currency=\"AUD\" check={check} inspector view={{ layout: \"shifts\", period: \"day\", date: new Date(\"2028-03-09T00:00:00Z\") }}\n events={{ duty: Schedule.events(rota, {\n name: \"Duty\", icon: \"user-clock\", entries,\n start: \"start\", end: \"end\", resource: { field: \"who\", of: { staff: \"people\", agency: \"agencies\" } },\n shift: \"shift\", group: \"team\", position: \"role\", activity: \"task\",\n // The hours a duty counts: its length less its unpaid break.\n hours: d => d.start.durationMinutes(d.end).subtract(d.unpaidBreak).divide(60.0),\n fields: { unpaidBreak: Schedule.field.number({ label: \"Unpaid break\", unit: \"min\", step: 15.0, min: 0.0 }),\n costCentre: Schedule.field.text({ label: \"Cost centre\" }), note: Schedule.field.text({ label: \"Note\" }) },\n // A new duty's own fields, the app's: half an hour's break on a shift over six hours, and its team's cost centre.\n values: d => ({\n unpaidBreak: d.hours.greaterThan(6.0).ifElse(() => 30.0, () => 0.0),\n agreed: none,\n costCentre: d.group.match({ some: (_$2, team) => centres.get(team, () => \"\"), none: () => \"\" }),\n note: \"\",\n }),\n // The app's check on a draft: Save waits while a duty has no cost centre — one a person cleared, or a team's with none.\n ready: d => East.equal(d.costCentre, \"\").ifElse(\n () => variant(\"invalid\", [{ field: \"costCentre\", message: \"Give the duty a cost centre\" }]),\n () => variant(\"ready\", null)),\n }) }}\n resources={{\n people: Schedule.resources(people.read(), { name: \"People\", icon: \"user\", label: p => p.name, group: p => p.team,\n position: p => p.position, skills: p => p.skills, contract: p => p.contract, agency: p => p.agency,\n trainer: p => p.trainer, trainee: p => p.trainee, usual: p => p.usual }),\n agencies: Schedule.resources(firms.read(), { name: \"Agencies\", icon: \"building\", label: a => a.name }),\n }}\n // A week's row the Roster makes, at its first Save or its Publish: Ops approves the warehouse's weeks.\n periods={Schedule.periods(weeks, { every: \"week\", status: { field: \"state\", draft: \"open\", published: \"issued\" }, dismissed: \"dismissed\",\n values: _week => ({ approver: some(\"Ops\") }) })}\n // A target added here is the planner's own, where the forecast's rest on its run.\n targets={Roster.targets(cover, { day: \"day\", group: \"team\", shift: \"shift\", positions: \"heads\", hours: \"hours\", values: _t => ({ basis: \"planner\" }) })}\n shifts={Roster.shifts(times.read(), { label: s => s.label, code: s => s.code, start: s => s.start, hours: s => s.hours, order: s => s.order })}\n groups={Roster.groups(teams.read(), { label: t => t.label, order: t => t.order })}\n positions={Roster.positions(roles.read(), { label: p => p.label, code: p => p.code, lead: p => p.lead, order: p => p.order })}\n activities={Roster.activities(acts.read(), { label: a => a.label, code: a => a.code, group: a => a.group, order: a => a.order })}\n proposals={Roster.proposals(ideas.read(), { person: s => s.person, day: s => s.day, group: s => s.team, shift: s => s.shift, reason: s => s.why })}\n rules={{ rest: 10.0 }}\n library={[Roster.library.people(), Roster.library.activities(), Roster.library.tab(roles.read(), {\n name: \"Positions\", icon: \"id-badge\", label: p => p.label, meta: p => some(p.code),\n drop: (_p, key) => Schedule.patch(WarehouseDuty, { role: key }),\n })]} />\n </Box>;\n }}</Reactive>)"
46680
+ "source": "// The mock warehouse roster over its own records: its duties, the weeks of its rota, its cover targets and suggestions, 69 staff and an agency, its shift times, teams, positions and activities. One Slice.bindRecords rail over the week's duties, the staff and the activities; the warehouse's pay in its own codes and its check over the pay; a new duty's own fields, a new target's basis and a new week's approver from the app's `values`; Publish; a Positions tab; the inspector; and the warehouse's greedy fit on e3, which a Find fix asks who fits.\n// inputs: []\n/** The duties, both weeks', each the warehouse's own row. */\nexport const rosterDuties = e3.record(\"roster_duties\", DictType(StringType, WarehouseDuty), {\n initial: warehouseDuties,\n indexes: (index) => ({\n // The duties by their times: what the Roster's slice reads a week of them through, its navigation writing the range.\n roster_duties_by_time: index.interval({ from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The weeks of the rota: the one before issued, this one open. */\nexport const rosterWeeks = e3.record(\"roster_rota_weeks\", DictType(DateTimeType, WarehouseWeek), {\n initial: warehouseWeeks,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The cover targets, a row per slot: the week before's, this week's and the forecast's for the week after. */\nexport const rosterCover = e3.record(\"roster_cover\", DictType(StringType, WarehouseCover), {\n initial: warehouseCover,\n indexes: (index) => ({\n // The targets by their day: what the warehouse's optimiser reads a week of them through (#1622).\n roster_cover_by_day: index.interval({ from: \"day\", to: \"day\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The suggestions: someone for a slot, and why. */\nexport const rosterSuggestions = e3.record(\"roster_suggestions\", DictType(StringType, WarehouseSuggestion), {\n initial: warehouseSuggestions,\n mutations: (mutation) => ({\n // The suggestions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\n/** The pay rates, an hour, by the warehouse's own pay codes. */\nexport const rosterPayRates = e3.record(\"roster_pay_rates\", DictType(StringType, FloatType), { initial: warehousePayRates });\n\nexport const rosterStaff = e3.record(\"roster_staff\", DictType(StringType, WarehousePerson), {\n initial: warehousePeople,\n indexes: (index) => ({\n // The rail's fields, each on an index of its own: the staff by group then name, position, trainer, agency, skill and name, the activities by group.\n roster_staff_by_team_name: index.on([\"team\", \"name\"]),\n roster_staff_by_position: index.on([\"position\"]),\n roster_staff_by_trainer: index.on([\"trainer\"]),\n roster_staff_by_agency: index.on([\"agency\"]),\n roster_staff_by_skill: index.on([\"skills\"]),\n roster_staff_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // What the renderer's tests on e3 write and ask beside the examples (#1376): another session's edits of the\n // reference data, a roster the warehouse has locked, and another app's fit over the same staff.\n // The staff's patch door: another session's edit of the staff.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterAgencies = e3.record(\"roster_agencies\", DictType(StringType, WarehouseAgency), { initial: warehouseAgencies });\n\nexport const rosterShiftTimes = e3.record(\"roster_shift_times\", DictType(StringType, WarehouseShift), {\n initial: warehouseShifts,\n mutations: (mutation) => ({\n // The shift times' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterTeams = e3.record(\"roster_teams\", DictType(StringType, WarehouseTeam), {\n initial: warehouseTeams,\n mutations: (mutation) => ({\n // The teams' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterPositions = e3.record(\"roster_positions\", DictType(StringType, WarehousePosition), {\n initial: warehousePositions,\n mutations: (mutation) => ({\n // The positions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\n/** Every activity by its key: each group's skills, and the duty of none (#1342). */\nexport const rosterActivities = e3.record(\"roster_activities\", DictType(StringType, WarehouseActivity), {\n initial: warehouseActivities,\n indexes: (index) => ({\n roster_activities_by_group: index.on([\"group\"]),\n }),\n});\n\n/**\n * A person as the Roster reads one: the reading the page's `people` kind declares, written once more for a function\n * that reads the staff itself (#1624).\n */\nexport const rosterPersonOf = East.function([WarehousePerson, StringType], Roster.Types.Person, (_$, p, key) => ({\n key, name: p.name, group: p.team, position: p.position, skills: p.skills, contract: p.contract,\n agency: p.agency, trainer: p.trainer, trainee: p.trainee, usual: p.usual,\n}));\n\n/**\n * A duty's roles as the Roster reads them: the reading the page's duty kind declares, written once more for a function\n * that reads the duties itself (#1624) — who, as a person or an agency's request, and the hours it counts, its length\n * less its unpaid break.\n */\nexport const rosterDutyRoles = East.function([WarehouseDuty], Schedule.Types.RosterRoles, (_$, d) => ({\n start: d.start, end: d.end,\n resource: some(d.who.match({\n staff: (_$2, key) => East.value({ kind: \"people\", key }, Schedule.Types.ResourceRef),\n agency: (_$2, key) => East.value({ kind: \"agencies\", key }, Schedule.Types.ResourceRef),\n })),\n shift: d.shift, group: some(d.team), position: some(d.role), activity: d.task,\n hours: d.start.durationMinutes(d.end).subtract(d.unpaidBreak).divide(60.0),\n}));\n\n/**\n * The warehouse's fit, on e3: who fits a Find fix's need on its slot — the ready-made rule, then a greedy order: the\n * people off that day with the most spare contract hours first, whatever their group. It is asked the need, the slot and\n * the week's first day, and no row. It reads the holders of the need through the staff's indexes, so nobody else is\n * asked about; the week's duties through their interval index, over the window the Roster reads them over, the Roster's\n * unsaved duties among them; and the shifts, the teams, the positions and the activities from the warehouse's own records.\n */\nexport const rosterStaffFit = e3.function(\"roster_staff_fit\", {\n inputs: [\n e3.index(rosterDuties.indexes.roster_duties_by_time), rosterDuties,\n e3.index(rosterStaff.indexes.roster_staff_by_skill),\n e3.index(rosterStaff.indexes.roster_staff_by_position),\n e3.index(rosterStaff.indexes.roster_staff_by_trainer), rosterStaff,\n rosterShiftTimes, rosterTeams, rosterPositions, rosterActivities,\n ],\n // The Roster's unsaved duties are laid over them, and over their index\n drafts: [rosterDuties],\n args: [Roster.Types.FitRequest],\n output: Roster.Types.FitResult,\n}, ($, dutiesByTime, duties, bySkill, byPosition, byTrainer, staff, shiftRows, teamRows, positionRows, activityRows, request) => {\n // Whom to ask about: the holders of the need, each read through its index. Nobody sent the staff.\n const person = $.const(rosterPersonOf);\n const people = $.let(new Map(), DictType(StringType, Roster.Types.Person));\n $.match(request.need, {\n skill: ($2, skill) => {\n bySkill.of(skill).each($2, ($3, _carried, key) => { $3(people.insert(key, person(staff.get(key), key))); });\n },\n trainers: ($2) => {\n byTrainer.of(true).each($2, ($3, _carried, key) => { $3(people.insert(key, person(staff.get(key), key))); });\n },\n leads: ($2) => {\n $2.for(positionRows, ($3, position, code) => {\n $3.if(position.lead, ($4) => {\n byPosition.of(code).each($4, ($5, _carried, key) => { $5(people.insert(key, person(staff.get(key), key))); });\n });\n });\n },\n });\n // The week's duties, over the window the Roster reads them over. The index carries no row: it gives each duty's key,\n // and the record its row, both at the one drafted state.\n const roles = $.const(rosterDutyRoles);\n const windowOf = $.const(Roster.window);\n const span = $.const(windowOf(request.start));\n const week = $.let(new Map(), DictType(StringType, Schedule.Types.RosterRoles));\n dutiesByTime.overlapping({ from: span.from, to: span.to }).each($, ($2, _carried, key) => { $2(week.insert(key, roles(duties.get(key)))); });\n // The configuration, from the warehouse's own records.\n const shifts = $.let([], ArrayType(Roster.Types.Shift));\n $.for(shiftRows, ($2, s, key) => { $2(shifts.pushLast({ key, label: s.label, code: s.code, start: s.start, hours: s.hours, color: s.colour })); });\n const groups = $.let([], ArrayType(Roster.Types.Group));\n $.for(teamRows, ($2, t, key) => { $2(groups.pushLast({ key, label: t.label })); });\n const positions = $.let([], ArrayType(Roster.Types.Position));\n $.for(positionRows, ($2, p, key) => { $2(positions.pushLast({ key, label: p.label, code: p.code, lead: p.lead })); });\n const activities = $.let([], ArrayType(Roster.Types.Skill));\n $.for(activityRows, ($2, a, key) => { $2(activities.pushLast({ key, label: a.label, code: a.code, group: a.group })); });\n const context = $.const({ people, duties: week, shifts, groups, positions, activities, rest: 10.0 }, Roster.Types.FitContext());\n // The ready-made rule, then the warehouse's order: the most spare contract hours first, whatever the group.\n const answer = $.const(Roster.answer());\n const rule = $.const(Roster.fit());\n return answer(request, context, East.function([Roster.Types.Candidate()], Roster.Types.Fit, ($2, candidate) => {\n const verdict = $2.const(rule(candidate));\n $2.match(verdict, { refused: ($3) => { $3.return(verdict); } });\n const fits = $2.const(verdict.unwrap(\"fits\"));\n return variant(\"fits\", { score: candidate.person.contract.subtract(candidate.hours), why: fits.why, warn: fits.warn });\n }));\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n // What the Roster writes: the duties, the weeks of the rota and the cover targets, each through its patch door.\n const rota = $.let(Record.bind(rosterDuties));\n const entries = $.let(Data.bindPaged(rosterDuties));\n const byTime = $.let(Data.bindPaged(rosterDuties, { indexes: [\"roster_duties_by_time\"] }));\n const weeks = $.let(Record.bind(rosterWeeks));\n const cover = $.let(Record.bind(rosterCover));\n // Every person and activity is the calculation scope; the narrowing only chooses which show (#1342).\n const people = $.let(Data.bind(rosterStaff));\n const acts = $.let(Data.bind(rosterActivities));\n const staffIndex = $.let(Data.bindPaged(rosterStaff, { indexes: [\"roster_staff_by_team_name\", \"roster_staff_by_position\", \"roster_staff_by_trainer\", \"roster_staff_by_agency\", \"roster_staff_by_skill\", \"roster_staff_by_name\"] }));\n const actIndex = $.let(Data.bindPaged(rosterActivities, { indexes: [\"roster_activities_by_group\"] }));\n const slice = $.let(Slice.bindRecords(\"ex.rosterWarehouse\", {\n // The week's duties: the Roster's navigation writes the range; no chip picks the week.\n duty: { source: byTime, range: \"start\" },\n people: { source: staffIndex, icon: { prefix: \"fas\", name: \"user\" }, search: [\"name\", \"skills\"],\n fields: { team: { label: \"Group\", hints: [{ value: \"inbound\", label: \"Inbound\" }, { value: \"picking\", label: \"Picking\" }, { value: \"dispatch\", label: \"Dispatch\" }] }, position: { label: \"Position\", hints: [{ value: \"lead\", label: \"Lead\" }, { value: \"deputy\", label: \"Deputy\" }, { value: \"acting\", label: \"Acting\" }, { value: \"crew\", label: \"Crew\" }] },\n trainer: { label: \"Trainer\" }, agency: { label: \"Agency\" }, skills: { label: \"Skill\" }, name: { label: \"Name\" } } },\n activities: { source: actIndex, icon: { prefix: \"fas\", name: \"list-check\" }, fields: { group: { label: \"Group\", hints: [{ value: \"inbound\", label: \"Inbound\" }, { value: \"picking\", label: \"Picking\" }, { value: \"dispatch\", label: \"Dispatch\" }, null] } } },\n }, { presets: [{ id: \"leads\", name: \"Leads\", where: { people: { position: [\"lead\", \"deputy\", \"acting\"] } } }] }));\n const firms = $.let(Data.bind(rosterAgencies));\n const times = $.let(Data.bind(rosterShiftTimes));\n const teams = $.let(Data.bind(rosterTeams));\n // Each team's cost centre: what a new duty of the team is booked to.\n const centres = $.const(teams.read().map((_$2, team) => team.costCentre));\n const roles = $.let(Data.bind(rosterPositions));\n const ideas = $.let(Data.bind(rosterSuggestions));\n const rateRows = $.let(Data.bind(rosterPayRates));\n const rates = $.const(rateRows.read());\n // The app's fit: a Find fix asks it who fits, over every person, and the People tab shows its answer.\n const fit = $.let(Func.bind(rosterStaffFit));\n // The warehouse's pay (§5.6), in its own codes. One person's duties for the week in, or one agency's requests;\n // each duty's cost by code out: ordinary time up to the person's contracted hours in the week, OT1 past them,\n // and an agency's hours — its named worker's, or its request's — at its own rate.\n const pay = $.const(East.function([Roster.Types.PayRequest(WarehouseDuty)], Roster.Types.Pay, ($2, req) => {\n const out = $2.let(new Map(), Roster.Types.Pay);\n const zero = $2.const(0.0, FloatType);\n const agency = $2.let(true, BooleanType);\n const contract = $2.let(0.0, FloatType);\n $2.match(req.who, { person: ($3, key) => {\n $3.if(req.context.people.has(key), ($4) => {\n const person = $4.const(req.context.people.get(key));\n $4.assign(agency, person.agency);\n $4.assign(contract, person.contract);\n });\n } });\n const worked = $2.let(0.0, FloatType);\n // The week's duties in time order, so the contract's hours run out where they do.\n const ordered = $2.const(req.duties.toArray(($3, duty, key) => ({ key, duty })).sort(($3, d) => d.duty.start));\n $2.for(ordered, ($3, d) => {\n const costs = $3.let(new Map(), DictType(StringType, FloatType));\n $3.if(agency, ($4) => {\n $4(costs.insert(\"AGENCY\", d.duty.hours.multiply(rates.get(\"AGENCY\", () => 0.0))));\n }).else(($4) => {\n const ordinary = $4.const(East.max(East.min(d.duty.hours, contract.subtract(worked)), zero));\n const over = $4.const(d.duty.hours.subtract(ordinary));\n $4(costs.insert(\"ORD\", ordinary.multiply(rates.get(\"ORD\", () => 0.0))));\n $4.if(East.greater(over, 0.0), ($5) => { $5(costs.insert(\"OT1\", over.multiply(rates.get(\"OT1\", () => 0.0)))); });\n });\n $3.assign(worked, worked.add(d.duty.hours));\n $3(out.insert(d.key, costs));\n });\n return out;\n }));\n // The warehouse's check sees the pay too (§5.8): overtime on a duty nobody has agreed.\n const check = $.const(East.function([Roster.Types.CheckContext(WarehouseDuty)], ArrayType(Roster.Types.Issue), ($2, cx) => {\n const issues = $2.let([], ArrayType(Roster.Types.Issue));\n const slotOf = $2.const(Roster.slotOf);\n $2.for(cx.week.assignments, ($3, a, id) => {\n const costs = $3.const(cx.pay.get(id, () => East.value(new Map(), DictType(StringType, FloatType))));\n $3.if(costs.has(\"OT1\").and(() => East.notEqual(a.row.agreed, some(true))), ($4) => {\n $4(issues.pushLast({ kind: variant(\"breach\", null), tone: variant(\"info\", null),\n title: \"Overtime not agreed\", detail: East.str`${a.row.team} · ${a.row.shift}`,\n slot: slotOf(a.place), assignment: some(id), flag: some(\"OT\"), fix: none }));\n });\n });\n return issues;\n }));\n return <Box width=\"100%\" height=\"760px\"><Roster id=\"rosterWarehouse\" week={{ start: \"sunday\" }} slice={{ slice }} fit={fit}\n pay={pay} currency=\"AUD\" check={check} inspector view={{ layout: \"shifts\", period: \"day\", date: new Date(\"2028-03-09T00:00:00Z\") }}\n events={{ duty: Schedule.events(rota, {\n name: \"Duty\", icon: \"user-clock\", entries,\n start: \"start\", end: \"end\", resource: { field: \"who\", of: { staff: \"people\", agency: \"agencies\" } },\n shift: \"shift\", group: \"team\", position: \"role\", activity: \"task\",\n // The hours a duty counts: its length less its unpaid break.\n hours: d => d.start.durationMinutes(d.end).subtract(d.unpaidBreak).divide(60.0),\n fields: { unpaidBreak: Schedule.field.number({ label: \"Unpaid break\", unit: \"min\", step: 15.0, min: 0.0 }),\n costCentre: Schedule.field.text({ label: \"Cost centre\" }), note: Schedule.field.text({ label: \"Note\" }) },\n // A new duty's own fields, the app's: half an hour's break on a shift over six hours, and its team's cost centre.\n values: d => ({\n unpaidBreak: d.hours.greaterThan(6.0).ifElse(() => 30.0, () => 0.0),\n agreed: none,\n costCentre: d.group.match({ some: (_$2, team) => centres.get(team, () => \"\"), none: () => \"\" }),\n note: \"\",\n }),\n // The app's check on a draft: Save waits while a duty has no cost centre — one a person cleared, or a team's with none.\n ready: d => East.equal(d.costCentre, \"\").ifElse(\n () => variant(\"invalid\", [{ field: \"costCentre\", message: \"Give the duty a cost centre\" }]),\n () => variant(\"ready\", null)),\n }) }}\n resources={{\n people: Schedule.resources(people.read(), { name: \"People\", icon: \"user\", label: p => p.name, group: p => p.team,\n position: p => p.position, skills: p => p.skills, contract: p => p.contract, agency: p => p.agency,\n trainer: p => p.trainer, trainee: p => p.trainee, usual: p => p.usual }),\n agencies: Schedule.resources(firms.read(), { name: \"Agencies\", icon: \"building\", label: a => a.name }),\n }}\n // A week's row the Roster makes, at its first Save or its Publish: Ops approves the warehouse's weeks.\n periods={Schedule.periods(weeks, { every: \"week\", status: { field: \"state\", draft: \"open\", published: \"issued\" }, dismissed: \"dismissed\",\n values: _week => ({ approver: some(\"Ops\") }) })}\n // A target added here is the planner's own, where the forecast's rest on its run.\n targets={Roster.targets(cover, { day: \"day\", group: \"team\", shift: \"shift\", positions: \"heads\", hours: \"hours\", values: _t => ({ basis: \"planner\" }) })}\n shifts={Roster.shifts(times.read(), { label: s => s.label, code: s => s.code, start: s => s.start, hours: s => s.hours, order: s => s.order })}\n groups={Roster.groups(teams.read(), { label: t => t.label, order: t => t.order })}\n positions={Roster.positions(roles.read(), { label: p => p.label, code: p => p.code, lead: p => p.lead, order: p => p.order })}\n activities={Roster.activities(acts.read(), { label: a => a.label, code: a => a.code, group: a => a.group, order: a => a.order })}\n proposals={Roster.proposals(ideas.read(), { person: s => s.person, day: s => s.day, group: s => s.team, shift: s => s.shift, reason: s => s.why })}\n rules={{ rest: 10.0 }}\n library={[Roster.library.people(), Roster.library.activities(), Roster.library.tab(roles.read(), {\n name: \"Positions\", icon: \"id-badge\", label: p => p.label, meta: p => some(p.code),\n drop: (_p, key) => Schedule.patch(WarehouseDuty, { role: key }),\n })]} />\n </Box>;\n }}</Reactive>)"
46349
46681
  },
46350
46682
  {
46351
46683
  "id": "e3-ui:roster.examples.tsx:rosterMobile",
@@ -46410,7 +46742,7 @@
46410
46742
  "languages": [
46411
46743
  "tsx"
46412
46744
  ],
46413
- "source": "// The app's own words for who is on the Roster (#1516): `vocabulary` replaces Permanent, Agency staff, Leads, Associates, Trainers and Off Mon · available wherever the Roster draws them, its coverage detail's short forms too, and the People tab keeps its groups' order whatever they are called; the badge beside an agency person's name — in the People layout, and on a Shifts chip, a request's too — is its `agencyShort`, each group's row of agency requests its `requests` (#1566), and the People layout's work requirement heading its `demand` (#1568).\n// inputs: []\n/** The duties, both weeks', each the warehouse's own row. */\nexport const rosterDuties = e3.record(\"roster_duties\", DictType(StringType, WarehouseDuty), {\n initial: warehouseDuties,\n indexes: (index) => ({\n // The duties by their times: what the Roster's slice reads a week of them through, its navigation writing the range.\n roster_duties_by_time: index.interval({ from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The weeks of the rota: the one before issued, this one open. */\nexport const rosterWeeks = e3.record(\"roster_rota_weeks\", DictType(DateTimeType, WarehouseWeek), {\n initial: warehouseWeeks,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The cover targets, a row per slot: the week before's, this week's and the forecast's for the week after. */\nexport const rosterCover = e3.record(\"roster_cover\", DictType(StringType, WarehouseCover), {\n initial: warehouseCover,\n indexes: (index) => ({\n // The targets by their day: what the warehouse's optimiser reads a week of them through (#1622).\n roster_cover_by_day: index.interval({ from: \"day\", to: \"day\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The suggestions: someone for a slot, and why. */\nexport const rosterSuggestions = e3.record(\"roster_suggestions\", DictType(StringType, WarehouseSuggestion), {\n initial: warehouseSuggestions,\n mutations: (mutation) => ({\n // The suggestions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterStaff = e3.record(\"roster_staff\", DictType(StringType, WarehousePerson), {\n initial: warehousePeople,\n indexes: (index) => ({\n // The rail's fields, each on an index of its own: the staff by group then name, position, trainer, agency, skill and name, the activities by group.\n roster_staff_by_team_name: index.on([\"team\", \"name\"]),\n roster_staff_by_position: index.on([\"position\"]),\n roster_staff_by_trainer: index.on([\"trainer\"]),\n roster_staff_by_agency: index.on([\"agency\"]),\n roster_staff_by_skill: index.on([\"skills\"]),\n roster_staff_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // What the renderer's tests on e3 write and ask beside the examples (#1376): another session's edits of the\n // reference data, a roster the warehouse has locked, and another app's fit over the same staff.\n // The staff's patch door: another session's edit of the staff.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterAgencies = e3.record(\"roster_agencies\", DictType(StringType, WarehouseAgency), { initial: warehouseAgencies });\n\nexport const rosterShiftTimes = e3.record(\"roster_shift_times\", DictType(StringType, WarehouseShift), {\n initial: warehouseShifts,\n mutations: (mutation) => ({\n // The shift times' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterTeams = e3.record(\"roster_teams\", DictType(StringType, WarehouseTeam), {\n initial: warehouseTeams,\n mutations: (mutation) => ({\n // The teams' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterPositions = e3.record(\"roster_positions\", DictType(StringType, WarehousePosition), {\n initial: warehousePositions,\n mutations: (mutation) => ({\n // The positions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\n/** Every activity by its key: each group's skills, and the duty of none (#1342). */\nexport const rosterActivities = e3.record(\"roster_activities\", DictType(StringType, WarehouseActivity), {\n initial: warehouseActivities,\n indexes: (index) => ({\n roster_activities_by_group: index.on([\"group\"]),\n }),\n});\n\n/**\n * A person as the Roster reads one: the reading the page's `people` kind declares, written once more for a function\n * that reads the staff itself (#1624).\n */\nexport const rosterPersonOf = East.function([WarehousePerson, StringType], Roster.Types.Person, (_$, p, key) => ({\n key, name: p.name, group: p.team, position: p.position, skills: p.skills, contract: p.contract,\n agency: p.agency, trainer: p.trainer, trainee: p.trainee, usual: p.usual,\n}));\n\n/**\n * A duty's roles as the Roster reads them: the reading the page's duty kind declares, written once more for a function\n * that reads the duties itself (#1624) — who, as a person or an agency's request, and the hours it counts, its length\n * less its unpaid break.\n */\nexport const rosterDutyRoles = East.function([WarehouseDuty], Schedule.Types.RosterRoles, (_$, d) => ({\n start: d.start, end: d.end,\n resource: some(d.who.match({\n staff: (_$2, key) => East.value({ kind: \"people\", key }, Schedule.Types.ResourceRef),\n agency: (_$2, key) => East.value({ kind: \"agencies\", key }, Schedule.Types.ResourceRef),\n })),\n shift: d.shift, group: some(d.team), position: some(d.role), activity: d.task,\n hours: d.start.durationMinutes(d.end).subtract(d.unpaidBreak).divide(60.0),\n}));\n\n/**\n * The warehouse's fit, on e3: who fits a Find fix's need on its slot — the ready-made rule, then a greedy order: the\n * people off that day with the most spare contract hours first, whatever their group. It is asked the need, the slot and\n * the week's first day, and no row. It reads the holders of the need through the staff's indexes, so nobody else is\n * asked about; the week's duties through their interval index, over the window the Roster reads them over, the Roster's\n * unsaved duties among them; and the shifts, the teams, the positions and the activities from the warehouse's own records.\n */\nexport const rosterStaffFit = e3.function(\"roster_staff_fit\", {\n inputs: [\n e3.index(rosterDuties.indexes.roster_duties_by_time), rosterDuties,\n e3.index(rosterStaff.indexes.roster_staff_by_skill),\n e3.index(rosterStaff.indexes.roster_staff_by_position),\n e3.index(rosterStaff.indexes.roster_staff_by_trainer), rosterStaff,\n rosterShiftTimes, rosterTeams, rosterPositions, rosterActivities,\n ],\n // The Roster's unsaved duties are laid over them, and over their index\n drafts: [rosterDuties],\n args: [Roster.Types.FitRequest],\n output: Roster.Types.FitResult,\n}, ($, dutiesByTime, duties, bySkill, byPosition, byTrainer, staff, shiftRows, teamRows, positionRows, activityRows, request) => {\n // Whom to ask about: the holders of the need, each read through its index. Nobody sent the staff.\n const person = $.const(rosterPersonOf);\n const people = $.let(new Map(), DictType(StringType, Roster.Types.Person));\n $.match(request.need, {\n skill: ($2, skill) => {\n bySkill.of(skill).each($2, ($3, _carried, key) => { $3(people.insert(key, person(staff.get(key), key))); });\n },\n trainers: ($2) => {\n byTrainer.of(true).each($2, ($3, _carried, key) => { $3(people.insert(key, person(staff.get(key), key))); });\n },\n leads: ($2) => {\n $2.for(positionRows, ($3, position, code) => {\n $3.if(position.lead, ($4) => {\n byPosition.of(code).each($4, ($5, _carried, key) => { $5(people.insert(key, person(staff.get(key), key))); });\n });\n });\n },\n });\n // The week's duties, over the window the Roster reads them over. The index carries no row: it gives each duty's key,\n // and the record its row, both at the one drafted state.\n const roles = $.const(rosterDutyRoles);\n const windowOf = $.const(Roster.window);\n const span = $.const(windowOf(request.start));\n const week = $.let(new Map(), DictType(StringType, Schedule.Types.RosterRoles));\n dutiesByTime.overlapping({ from: span.from, to: span.to }).each($, ($2, _carried, key) => { $2(week.insert(key, roles(duties.get(key)))); });\n // The configuration, from the warehouse's own records.\n const shifts = $.let([], ArrayType(Roster.Types.Shift));\n $.for(shiftRows, ($2, s, key) => { $2(shifts.pushLast({ key, label: s.label, code: s.code, start: s.start, hours: s.hours, color: s.colour })); });\n const groups = $.let([], ArrayType(Roster.Types.Group));\n $.for(teamRows, ($2, t, key) => { $2(groups.pushLast({ key, label: t.label })); });\n const positions = $.let([], ArrayType(Roster.Types.Position));\n $.for(positionRows, ($2, p, key) => { $2(positions.pushLast({ key, label: p.label, code: p.code, lead: p.lead })); });\n const activities = $.let([], ArrayType(Roster.Types.Skill));\n $.for(activityRows, ($2, a, key) => { $2(activities.pushLast({ key, label: a.label, code: a.code, group: a.group })); });\n const context = $.const({ people, duties: week, shifts, groups, positions, activities, rest: 10.0 }, Roster.Types.FitContext);\n // The ready-made rule, then the warehouse's order: the most spare contract hours first, whatever the group.\n const answer = $.const(Roster.answer);\n const rule = $.const(Roster.fit());\n return answer(request, context, East.function([Roster.Types.Candidate], Roster.Types.Fit, ($2, candidate) => {\n const verdict = $2.const(rule(candidate));\n $2.match(verdict, { refused: ($3) => { $3.return(verdict); } });\n const fits = $2.const(verdict.unwrap(\"fits\"));\n return variant(\"fits\", { score: candidate.person.contract.subtract(candidate.hours), why: fits.why, warn: fits.warn });\n }));\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const rota = $.let(Record.bind(rosterDuties));\n const entries = $.let(Data.bindPaged(rosterDuties));\n const byTime = $.let(Data.bindPaged(rosterDuties, { indexes: [\"roster_duties_by_time\"] }));\n const weeks = $.let(Record.bind(rosterWeeks));\n const cover = $.let(Record.bind(rosterCover));\n const people = $.let(Data.bind(rosterStaff));\n const acts = $.let(Data.bind(rosterActivities));\n const slice = $.let(Slice.bindRecords(\"ex.rosterVocabulary\", { duty: { source: byTime, range: \"start\" } }));\n const firms = $.let(Data.bind(rosterAgencies));\n const times = $.let(Data.bind(rosterShiftTimes));\n const teams = $.let(Data.bind(rosterTeams));\n const roles = $.let(Data.bind(rosterPositions));\n const ideas = $.let(Data.bind(rosterSuggestions));\n const fit = $.let(Func.bind(rosterStaffFit));\n return <Box width=\"100%\" height=\"760px\"><Roster id=\"rosterVocabulary\" week={{ start: \"sunday\" }} slice={{ slice }} inspector fit={fit}\n vocabulary={{\n permanent: \"Employees\", permanentShort: \"empl\", agency: \"Contractors\", agencyShort: \"contr\", leads: \"Supervisors\", others: \"Colleagues\", trainers: \"Mentors\",\n available: East.function([StringType], StringType, (_$2, weekday) => East.str`Not rostered ${weekday}`), requests: \"Contractor requests\",\n demand: \"Hours needed\",\n }}\n view={{ layout: \"shifts\", period: \"day\", date: new Date(\"2028-03-09T00:00:00Z\") }}\n events={{ duty: Schedule.events(rota, {\n name: \"Duty\", icon: \"user-clock\", entries,\n start: \"start\", end: \"end\", resource: { field: \"who\", of: { staff: \"people\", agency: \"agencies\" } },\n shift: \"shift\", group: \"team\", position: \"role\", activity: \"task\",\n hours: d => d.start.durationMinutes(d.end).subtract(d.unpaidBreak).divide(60.0),\n }) }}\n resources={{\n people: Schedule.resources(people.read(), { name: \"People\", icon: \"user\", label: p => p.name, group: p => p.team,\n position: p => p.position, skills: p => p.skills, contract: p => p.contract, agency: p => p.agency,\n trainer: p => p.trainer, trainee: p => p.trainee, usual: p => p.usual }),\n agencies: Schedule.resources(firms.read(), { name: \"Agencies\", icon: \"building\", label: a => a.name }),\n }}\n periods={Schedule.periods(weeks, { every: \"week\", status: { field: \"state\", draft: \"open\", published: \"issued\" }, dismissed: \"dismissed\" })}\n targets={Roster.targets(cover, { day: \"day\", group: \"team\", shift: \"shift\", positions: \"heads\", hours: \"hours\" })}\n shifts={Roster.shifts(times.read(), { label: s => s.label, code: s => s.code, start: s => s.start, hours: s => s.hours, order: s => s.order })}\n groups={Roster.groups(teams.read(), { label: t => t.label, order: t => t.order })}\n positions={Roster.positions(roles.read(), { label: p => p.label, code: p => p.code, lead: p => p.lead, order: p => p.order })}\n activities={Roster.activities(acts.read(), { label: a => a.label, code: a => a.code, group: a => a.group, order: a => a.order })}\n proposals={Roster.proposals(ideas.read(), { person: s => s.person, day: s => s.day, group: s => s.team, shift: s => s.shift, reason: s => s.why })}\n rules={{ rest: 10.0 }}\n library={[Roster.library.people(), Roster.library.activities()]} />\n </Box>;\n }}</Reactive>)"
46745
+ "source": "// The app's own words for who is on the Roster (#1516): `vocabulary` replaces Permanent, Agency staff, Leads, Associates, Trainers and Off Mon · available wherever the Roster draws them, its coverage detail's short forms too, and the People tab keeps its groups' order whatever they are called; the badge beside an agency person's name — in the People layout, and on a Shifts chip, a request's too — is its `agencyShort`, each group's row of agency requests its `requests` (#1566), and the People layout's work requirement heading its `demand` (#1568).\n// inputs: []\n/** The duties, both weeks', each the warehouse's own row. */\nexport const rosterDuties = e3.record(\"roster_duties\", DictType(StringType, WarehouseDuty), {\n initial: warehouseDuties,\n indexes: (index) => ({\n // The duties by their times: what the Roster's slice reads a week of them through, its navigation writing the range.\n roster_duties_by_time: index.interval({ from: \"start\", to: \"end\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The weeks of the rota: the one before issued, this one open. */\nexport const rosterWeeks = e3.record(\"roster_rota_weeks\", DictType(DateTimeType, WarehouseWeek), {\n initial: warehouseWeeks,\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The cover targets, a row per slot: the week before's, this week's and the forecast's for the week after. */\nexport const rosterCover = e3.record(\"roster_cover\", DictType(StringType, WarehouseCover), {\n initial: warehouseCover,\n indexes: (index) => ({\n // The targets by their day: what the warehouse's optimiser reads a week of them through (#1622).\n roster_cover_by_day: index.interval({ from: \"day\", to: \"day\" }),\n }),\n mutations: (mutation) => ({\n patch: mutation.patch(),\n }),\n});\n\n/** The suggestions: someone for a slot, and why. */\nexport const rosterSuggestions = e3.record(\"roster_suggestions\", DictType(StringType, WarehouseSuggestion), {\n initial: warehouseSuggestions,\n mutations: (mutation) => ({\n // The suggestions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterStaff = e3.record(\"roster_staff\", DictType(StringType, WarehousePerson), {\n initial: warehousePeople,\n indexes: (index) => ({\n // The rail's fields, each on an index of its own: the staff by group then name, position, trainer, agency, skill and name, the activities by group.\n roster_staff_by_team_name: index.on([\"team\", \"name\"]),\n roster_staff_by_position: index.on([\"position\"]),\n roster_staff_by_trainer: index.on([\"trainer\"]),\n roster_staff_by_agency: index.on([\"agency\"]),\n roster_staff_by_skill: index.on([\"skills\"]),\n roster_staff_by_name: index.on([\"name\"]),\n }),\n mutations: (mutation) => ({\n // What the renderer's tests on e3 write and ask beside the examples (#1376): another session's edits of the\n // reference data, a roster the warehouse has locked, and another app's fit over the same staff.\n // The staff's patch door: another session's edit of the staff.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterAgencies = e3.record(\"roster_agencies\", DictType(StringType, WarehouseAgency), { initial: warehouseAgencies });\n\nexport const rosterShiftTimes = e3.record(\"roster_shift_times\", DictType(StringType, WarehouseShift), {\n initial: warehouseShifts,\n mutations: (mutation) => ({\n // The shift times' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterTeams = e3.record(\"roster_teams\", DictType(StringType, WarehouseTeam), {\n initial: warehouseTeams,\n mutations: (mutation) => ({\n // The teams' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\nexport const rosterPositions = e3.record(\"roster_positions\", DictType(StringType, WarehousePosition), {\n initial: warehousePositions,\n mutations: (mutation) => ({\n // The positions' patch door: another session's edit of them.\n patch: mutation.patch(),\n }),\n});\n\n/** Every activity by its key: each group's skills, and the duty of none (#1342). */\nexport const rosterActivities = e3.record(\"roster_activities\", DictType(StringType, WarehouseActivity), {\n initial: warehouseActivities,\n indexes: (index) => ({\n roster_activities_by_group: index.on([\"group\"]),\n }),\n});\n\n/**\n * A person as the Roster reads one: the reading the page's `people` kind declares, written once more for a function\n * that reads the staff itself (#1624).\n */\nexport const rosterPersonOf = East.function([WarehousePerson, StringType], Roster.Types.Person, (_$, p, key) => ({\n key, name: p.name, group: p.team, position: p.position, skills: p.skills, contract: p.contract,\n agency: p.agency, trainer: p.trainer, trainee: p.trainee, usual: p.usual,\n}));\n\n/**\n * A duty's roles as the Roster reads them: the reading the page's duty kind declares, written once more for a function\n * that reads the duties itself (#1624) — who, as a person or an agency's request, and the hours it counts, its length\n * less its unpaid break.\n */\nexport const rosterDutyRoles = East.function([WarehouseDuty], Schedule.Types.RosterRoles, (_$, d) => ({\n start: d.start, end: d.end,\n resource: some(d.who.match({\n staff: (_$2, key) => East.value({ kind: \"people\", key }, Schedule.Types.ResourceRef),\n agency: (_$2, key) => East.value({ kind: \"agencies\", key }, Schedule.Types.ResourceRef),\n })),\n shift: d.shift, group: some(d.team), position: some(d.role), activity: d.task,\n hours: d.start.durationMinutes(d.end).subtract(d.unpaidBreak).divide(60.0),\n}));\n\n/**\n * The warehouse's fit, on e3: who fits a Find fix's need on its slot — the ready-made rule, then a greedy order: the\n * people off that day with the most spare contract hours first, whatever their group. It is asked the need, the slot and\n * the week's first day, and no row. It reads the holders of the need through the staff's indexes, so nobody else is\n * asked about; the week's duties through their interval index, over the window the Roster reads them over, the Roster's\n * unsaved duties among them; and the shifts, the teams, the positions and the activities from the warehouse's own records.\n */\nexport const rosterStaffFit = e3.function(\"roster_staff_fit\", {\n inputs: [\n e3.index(rosterDuties.indexes.roster_duties_by_time), rosterDuties,\n e3.index(rosterStaff.indexes.roster_staff_by_skill),\n e3.index(rosterStaff.indexes.roster_staff_by_position),\n e3.index(rosterStaff.indexes.roster_staff_by_trainer), rosterStaff,\n rosterShiftTimes, rosterTeams, rosterPositions, rosterActivities,\n ],\n // The Roster's unsaved duties are laid over them, and over their index\n drafts: [rosterDuties],\n args: [Roster.Types.FitRequest],\n output: Roster.Types.FitResult,\n}, ($, dutiesByTime, duties, bySkill, byPosition, byTrainer, staff, shiftRows, teamRows, positionRows, activityRows, request) => {\n // Whom to ask about: the holders of the need, each read through its index. Nobody sent the staff.\n const person = $.const(rosterPersonOf);\n const people = $.let(new Map(), DictType(StringType, Roster.Types.Person));\n $.match(request.need, {\n skill: ($2, skill) => {\n bySkill.of(skill).each($2, ($3, _carried, key) => { $3(people.insert(key, person(staff.get(key), key))); });\n },\n trainers: ($2) => {\n byTrainer.of(true).each($2, ($3, _carried, key) => { $3(people.insert(key, person(staff.get(key), key))); });\n },\n leads: ($2) => {\n $2.for(positionRows, ($3, position, code) => {\n $3.if(position.lead, ($4) => {\n byPosition.of(code).each($4, ($5, _carried, key) => { $5(people.insert(key, person(staff.get(key), key))); });\n });\n });\n },\n });\n // The week's duties, over the window the Roster reads them over. The index carries no row: it gives each duty's key,\n // and the record its row, both at the one drafted state.\n const roles = $.const(rosterDutyRoles);\n const windowOf = $.const(Roster.window);\n const span = $.const(windowOf(request.start));\n const week = $.let(new Map(), DictType(StringType, Schedule.Types.RosterRoles));\n dutiesByTime.overlapping({ from: span.from, to: span.to }).each($, ($2, _carried, key) => { $2(week.insert(key, roles(duties.get(key)))); });\n // The configuration, from the warehouse's own records.\n const shifts = $.let([], ArrayType(Roster.Types.Shift));\n $.for(shiftRows, ($2, s, key) => { $2(shifts.pushLast({ key, label: s.label, code: s.code, start: s.start, hours: s.hours, color: s.colour })); });\n const groups = $.let([], ArrayType(Roster.Types.Group));\n $.for(teamRows, ($2, t, key) => { $2(groups.pushLast({ key, label: t.label })); });\n const positions = $.let([], ArrayType(Roster.Types.Position));\n $.for(positionRows, ($2, p, key) => { $2(positions.pushLast({ key, label: p.label, code: p.code, lead: p.lead })); });\n const activities = $.let([], ArrayType(Roster.Types.Skill));\n $.for(activityRows, ($2, a, key) => { $2(activities.pushLast({ key, label: a.label, code: a.code, group: a.group })); });\n const context = $.const({ people, duties: week, shifts, groups, positions, activities, rest: 10.0 }, Roster.Types.FitContext());\n // The ready-made rule, then the warehouse's order: the most spare contract hours first, whatever the group.\n const answer = $.const(Roster.answer());\n const rule = $.const(Roster.fit());\n return answer(request, context, East.function([Roster.Types.Candidate()], Roster.Types.Fit, ($2, candidate) => {\n const verdict = $2.const(rule(candidate));\n $2.match(verdict, { refused: ($3) => { $3.return(verdict); } });\n const fits = $2.const(verdict.unwrap(\"fits\"));\n return variant(\"fits\", { score: candidate.person.contract.subtract(candidate.hours), why: fits.why, warn: fits.warn });\n }));\n});\n\nEast.function([], UIComponentType, _$ => <Reactive>{$ => {\n const rota = $.let(Record.bind(rosterDuties));\n const entries = $.let(Data.bindPaged(rosterDuties));\n const byTime = $.let(Data.bindPaged(rosterDuties, { indexes: [\"roster_duties_by_time\"] }));\n const weeks = $.let(Record.bind(rosterWeeks));\n const cover = $.let(Record.bind(rosterCover));\n const people = $.let(Data.bind(rosterStaff));\n const acts = $.let(Data.bind(rosterActivities));\n const slice = $.let(Slice.bindRecords(\"ex.rosterVocabulary\", { duty: { source: byTime, range: \"start\" } }));\n const firms = $.let(Data.bind(rosterAgencies));\n const times = $.let(Data.bind(rosterShiftTimes));\n const teams = $.let(Data.bind(rosterTeams));\n const roles = $.let(Data.bind(rosterPositions));\n const ideas = $.let(Data.bind(rosterSuggestions));\n const fit = $.let(Func.bind(rosterStaffFit));\n return <Box width=\"100%\" height=\"760px\"><Roster id=\"rosterVocabulary\" week={{ start: \"sunday\" }} slice={{ slice }} inspector fit={fit}\n vocabulary={{\n permanent: \"Employees\", permanentShort: \"empl\", agency: \"Contractors\", agencyShort: \"contr\", leads: \"Supervisors\", others: \"Colleagues\", trainers: \"Mentors\",\n available: East.function([StringType], StringType, (_$2, weekday) => East.str`Not rostered ${weekday}`), requests: \"Contractor requests\",\n demand: \"Hours needed\",\n }}\n view={{ layout: \"shifts\", period: \"day\", date: new Date(\"2028-03-09T00:00:00Z\") }}\n events={{ duty: Schedule.events(rota, {\n name: \"Duty\", icon: \"user-clock\", entries,\n start: \"start\", end: \"end\", resource: { field: \"who\", of: { staff: \"people\", agency: \"agencies\" } },\n shift: \"shift\", group: \"team\", position: \"role\", activity: \"task\",\n hours: d => d.start.durationMinutes(d.end).subtract(d.unpaidBreak).divide(60.0),\n }) }}\n resources={{\n people: Schedule.resources(people.read(), { name: \"People\", icon: \"user\", label: p => p.name, group: p => p.team,\n position: p => p.position, skills: p => p.skills, contract: p => p.contract, agency: p => p.agency,\n trainer: p => p.trainer, trainee: p => p.trainee, usual: p => p.usual }),\n agencies: Schedule.resources(firms.read(), { name: \"Agencies\", icon: \"building\", label: a => a.name }),\n }}\n periods={Schedule.periods(weeks, { every: \"week\", status: { field: \"state\", draft: \"open\", published: \"issued\" }, dismissed: \"dismissed\" })}\n targets={Roster.targets(cover, { day: \"day\", group: \"team\", shift: \"shift\", positions: \"heads\", hours: \"hours\" })}\n shifts={Roster.shifts(times.read(), { label: s => s.label, code: s => s.code, start: s => s.start, hours: s => s.hours, order: s => s.order })}\n groups={Roster.groups(teams.read(), { label: t => t.label, order: t => t.order })}\n positions={Roster.positions(roles.read(), { label: p => p.label, code: p => p.code, lead: p => p.lead, order: p => p.order })}\n activities={Roster.activities(acts.read(), { label: a => a.label, code: a => a.code, group: a => a.group, order: a => a.order })}\n proposals={Roster.proposals(ideas.read(), { person: s => s.person, day: s => s.day, group: s => s.team, shift: s => s.shift, reason: s => s.why })}\n rules={{ rest: 10.0 }}\n library={[Roster.library.people(), Roster.library.activities()]} />\n </Box>;\n }}</Reactive>)"
46414
46746
  },
46415
46747
  {
46416
46748
  "id": "e3-ui:roster.examples.tsx:rosterPeople",
@@ -49931,6 +50263,7 @@
49931
50263
  "rack-only",
49932
50264
  "memory-limit",
49933
50265
  "gpu",
50266
+ "merges",
49934
50267
  "environment",
49935
50268
  "layers",
49936
50269
  "dataflow",
@@ -49938,7 +50271,7 @@
49938
50271
  "e3-api-server"
49939
50272
  ],
49940
50273
  "imports": [],
49941
- "source": "# Local machine: bind a VPN address the worker can reach.\ne3 rack enroll --listen 100.64.0.10:7331 --label workshop\n# Inside a prepared worker VM, run the printed matching-release configure/enroll\n# commands with its host-provisioned allocation path. Enter the origin and token\n# at their hidden prompts; never put them in shell arguments or plaintext files.\n# HTTP needs --allow-vpn-http plus authenticated VPN and exact host endpoint policy.\n# Enrollment observes a new registration, not activation or task readiness.\n# Independent agents use separate worker VMs; resources/GPU ownership belong to\n# the host lifecycle. Final host/source management and capacity activation remain\n# companion cloud #253 work. Once the service and capacity are active:\ne3 rack policy . set 'train_*' rack --size large --gpu\ne3 rack policy . set 'score_*' rack --memory-limit 8G\ne3 dataflow run . dev --rack -j 4 --memory 8G\ne3 watch src/main.ts . dev --start --rack\ne3 rack list\ne3 rack status\ne3 task logs . dev.train_model --follow\n# Placement preserves hashes/cache. Local planner and fallback retain the budget.\n# A split task's pieces are leased together, each at its memory cap (half as much\n# again as the task was measured to need): a rack books the caps it holds, so it\n# never books more than it has. --memory-limit is a ceiling on one piece's cap;\n# --gpu asks for a rack's GPU (east-py tasks). A piece that outgrows its cap\n# runs again under a larger one; a whole task that does fails.\n# A task that declares a python or node environment runs on a rack that composes\n# environments: this machine installs it for the rack's platform and sends it as\n# layers ([ENV] lines), with no container runtime; tools/image environments, a\n# package with no wheel for the platform or with native code stay local, with\n# the reason on the task's [LOCAL] line.\n# --rack-only waits for busy compatible capacity; infrastructure fallback remains.\n# Custom commands and host-dependent calls stay local by default.\n# For a local API server with the matching optional @elaraai/e3-rack installed:\ne3-api-server --repos ./repos --rack",
50274
+ "source": "# Local machine: bind a VPN address the worker can reach.\ne3 rack enroll --listen 100.64.0.10:7331 --label workshop\n# Inside a prepared worker VM, run the printed matching-release configure/enroll\n# commands with its host-provisioned allocation path. Enter the origin and token\n# at their hidden prompts; never put them in shell arguments or plaintext files.\n# HTTP needs --allow-vpn-http plus authenticated VPN and exact host endpoint policy.\n# Enrollment observes a new registration, not activation or task readiness.\n# Independent agents use separate worker VMs; resources/GPU ownership belong to\n# the host lifecycle. Final host/source management and capacity activation remain\n# companion cloud #253 work. Once the service and capacity are active:\ne3 rack policy . set 'train_*' rack --size large --gpu\ne3 rack policy . set 'score_*' rack --memory-limit 8G\ne3 rack policy . set 'rollup_*' rack --merges local\ne3 dataflow run . dev --rack -j 4 --memory 8G\ne3 watch src/main.ts . dev --start --rack\ne3 rack list\ne3 rack status\ne3 task logs . dev.train_model --follow\n# Placement preserves hashes/cache. Local planner and fallback retain the budget.\n# A split task's pieces are leased together, each at its memory cap (half as much\n# again as the task was measured to need): a rack books the caps it holds, so it\n# never books more than it has. --memory-limit is a ceiling on one piece's cap;\n# --gpu asks for a rack's GPU (east-py tasks). A piece that outgrows its cap\n# runs again under a larger one; a whole task that does fails.\n# --merges local runs a split task's merge/combine units here, its pieces on the\n# rack: their outputs are here already, so no piece goes back up the link.\n# A task that declares a python or node environment runs on a rack that composes\n# environments: this machine installs it for the rack's platform and sends it as\n# layers ([ENV] lines), with no container runtime; tools/image environments, a\n# package with no wheel for the platform or with native code stay local, with\n# the reason on the task's [LOCAL] line.\n# --rack-only waits for busy compatible capacity; infrastructure fallback remains.\n# Custom commands and host-dependent calls stay local by default.\n# For a local API server with the matching optional @elaraai/e3-rack installed:\ne3-api-server --repos ./repos --rack",
49942
50275
  "languages": [
49943
50276
  "typescript"
49944
50277
  ]