@magmonium/cli 0.8.19 → 0.8.21

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.
package/codegen/index.js CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // libs/codegen/src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ ACTION_NAME_READER: () => ACTION_NAME_READER,
23
24
  ALL_VARIANT: () => ALL_VARIANT,
24
25
  API_SEGMENT: () => API_SEGMENT,
25
26
  APP_CONFIG_SOURCE: () => APP_CONFIG_SOURCE,
@@ -123,6 +124,7 @@ __export(index_exports, {
123
124
  EMPTY_STORE_HOOK: () => EMPTY_STORE_HOOK,
124
125
  EMPTY_STORE_METHODS: () => EMPTY_STORE_METHODS,
125
126
  EMPTY_WC_CONFIG: () => EMPTY_WC_CONFIG,
127
+ ENUM_VALUE_READER: () => ENUM_VALUE_READER,
126
128
  ENVIRONMENT_PRESETS: () => ENVIRONMENT_PRESETS,
127
129
  FALLBACK_APP_COLOR: () => FALLBACK_APP_COLOR,
128
130
  FALLBACK_SLOTS: () => FALLBACK_SLOTS,
@@ -221,6 +223,11 @@ __export(index_exports, {
221
223
  NO_ROOT_PREFIX: () => NO_ROOT_PREFIX,
222
224
  NO_TRANSLATE_CONFIG_KEY: () => NO_TRANSLATE_CONFIG_KEY,
223
225
  ONE_CONFIG_SOURCE: () => ONE_CONFIG_SOURCE,
226
+ ONE_FUNCTIONS: () => ONE_FUNCTIONS,
227
+ ONE_FUNCTION_CATALOG: () => ONE_FUNCTION_CATALOG,
228
+ ONE_FUNCTION_ID_PARAM: () => ONE_FUNCTION_ID_PARAM,
229
+ ONE_FUNCTION_MAP_PARAM: () => ONE_FUNCTION_MAP_PARAM,
230
+ ONE_FUNCTION_PREFIX: () => ONE_FUNCTION_PREFIX,
224
231
  ONE_IMPORT_MODULE: () => ONE_IMPORT_MODULE,
225
232
  ONE_PACKAGE_VERSION: () => ONE_PACKAGE_VERSION,
226
233
  OPEN_SCREEN_INPUT_SOURCES: () => OPEN_SCREEN_INPUT_SOURCES,
@@ -290,12 +297,18 @@ __export(index_exports, {
290
297
  SEARCH_TEXT_INPUT: () => SEARCH_TEXT_INPUT,
291
298
  SECTION_TABLE_COLUMNS_KEY: () => SECTION_TABLE_COLUMNS_KEY,
292
299
  SECTION_TABLE_SEED_COLUMNS: () => SECTION_TABLE_SEED_COLUMNS,
300
+ SECTION_TABLE_SORT_DIRECTION: () => SECTION_TABLE_SORT_DIRECTION,
301
+ SECTION_TABLE_SORT_ID: () => SECTION_TABLE_SORT_ID,
302
+ SECTION_TABLE_SORT_OUTPUT: () => SECTION_TABLE_SORT_OUTPUT,
293
303
  SHARDED_FOLDERS: () => SHARDED_FOLDERS,
294
304
  SHARED_FUNCTIONS: () => SHARED_FUNCTIONS,
295
305
  SHARED_LIB_ROOT: () => SHARED_LIB_ROOT,
296
306
  SHARED_SHAPES: () => SHARED_SHAPES,
297
307
  SHARED_SHAPE_ID_PREFIX: () => SHARED_SHAPE_ID_PREFIX,
298
308
  SHIPPED_SHELL_PATHS: () => SHIPPED_SHELL_PATHS,
309
+ SORT_DIRECTION_ENUM: () => SORT_DIRECTION_ENUM,
310
+ SORT_DIRECTION_ENUM_ID: () => SORT_DIRECTION_ENUM_ID,
311
+ SORT_DIRECTION_VALUES: () => SORT_DIRECTION_VALUES,
299
312
  SOURCE_LANG: () => SOURCE_LANG,
300
313
  STARTER_GROUP: () => STARTER_GROUP,
301
314
  STAT_TEXT_SOURCES: () => STAT_TEXT_SOURCES,
@@ -334,6 +347,7 @@ __export(index_exports, {
334
347
  acceptsPatterns: () => acceptsPatterns,
335
348
  actionButtonEntries: () => actionButtonEntries,
336
349
  actionButtonOverrides: () => actionButtonOverrides,
350
+ actionEnumFile: () => actionEnumFile,
337
351
  actionEnumValues: () => actionEnumValues,
338
352
  actionEnums: () => actionEnums,
339
353
  actionRenderIds: () => actionRenderIds,
@@ -503,6 +517,8 @@ __export(index_exports, {
503
517
  collectThemeAssets: () => collectThemeAssets,
504
518
  collectTranslationAssets: () => collectTranslationAssets,
505
519
  collectTypedComponentInputs: () => collectTypedComponentInputs,
520
+ colorPipeExpression: () => colorPipeExpression,
521
+ colorPipeOf: () => colorPipeOf,
506
522
  columnNeedsId: () => columnNeedsId,
507
523
  compactControlGroups: () => compactControlGroups,
508
524
  compactControlMap: () => compactControlMap,
@@ -525,6 +541,7 @@ __export(index_exports, {
525
541
  computedRootIds: () => computedRootIds,
526
542
  conditionCheckType: () => conditionCheckType,
527
543
  conditionError: () => conditionError,
544
+ conditionFunction: () => conditionFunction,
528
545
  conditionId: () => conditionId,
529
546
  conditionKind: () => conditionKind,
530
547
  configurableResponses: () => configurableResponses,
@@ -536,6 +553,8 @@ __export(index_exports, {
536
553
  contentTemplateTag: () => contentTemplateTag,
537
554
  contrastRatio: () => contrastRatio,
538
555
  controlDrawsDenial: () => controlDrawsDenial,
556
+ controlEnumValues: () => controlEnumValues,
557
+ controlEnums: () => controlEnums,
539
558
  controlMapReadsState: () => controlMapReadsState,
540
559
  controlMapStateRootIds: () => controlMapStateRootIds,
541
560
  controlMapUsesAuth: () => controlMapUsesAuth,
@@ -624,6 +643,7 @@ __export(index_exports, {
624
643
  embedShapeBlocked: () => embedShapeBlocked,
625
644
  embeddedRefOf: () => embeddedRefOf,
626
645
  emissionShapeLookup: () => emissionShapeLookup,
646
+ emitEnumFile: () => emitEnumFile,
627
647
  emitFullAppFiles: () => emitFullAppFiles,
628
648
  emitGeneratedFiles: () => emitGeneratedFiles,
629
649
  emitOverlayFiles: () => emitOverlayFiles,
@@ -641,6 +661,16 @@ __export(index_exports, {
641
661
  encodeRoot: () => encodeRoot,
642
662
  endWithNewline: () => endWithNewline,
643
663
  ensureWritable: () => ensureWritable,
664
+ enumEventStateWrites: () => enumEventStateWrites,
665
+ enumEventWrites: () => enumEventWrites,
666
+ enumFileBase: () => enumFileBase,
667
+ enumIdOf: () => enumIdOf,
668
+ enumLabels: () => enumLabels,
669
+ enumMemberLabel: () => enumMemberLabel,
670
+ enumMemberName: () => enumMemberName,
671
+ enumModule: () => enumModule,
672
+ enumNameOf: () => enumNameOf,
673
+ enumValuesOf: () => enumValuesOf,
644
674
  evaluateVariantGate: () => evaluateVariantGate,
645
675
  eventPayloadTsType: () => eventPayloadTsType,
646
676
  everyFormReset: () => everyFormReset,
@@ -848,6 +878,7 @@ __export(index_exports, {
848
878
  isCompleteVisibilitySource: () => isCompleteVisibilitySource,
849
879
  isCompositionKind: () => isCompositionKind,
850
880
  isComputedEligible: () => isComputedEligible,
881
+ isControlEnum: () => isControlEnum,
851
882
  isControlVisible: () => isControlVisible,
852
883
  isCountdown: () => isCountdown,
853
884
  isCustomPath: () => isCustomPath,
@@ -895,6 +926,7 @@ __export(index_exports, {
895
926
  isNavRowShape: () => isNavRowShape,
896
927
  isNavVisibilityFunction: () => isNavVisibilityFunction,
897
928
  isOnChange: () => isOnChange,
929
+ isOneFunctionComputed: () => isOneFunctionComputed,
898
930
  isOptionRowShape: () => isOptionRowShape,
899
931
  isOrderingMenuActionOperator: () => isOrderingMenuActionOperator,
900
932
  isOrderingOutputArmOperator: () => isOrderingOutputArmOperator,
@@ -975,14 +1007,17 @@ __export(index_exports, {
975
1007
  jsNativesInGroup: () => jsNativesInGroup,
976
1008
  keyCandidates: () => keyCandidates,
977
1009
  keyIdKeeper: () => keyIdKeeper,
1010
+ labelChainOf: () => labelChainOf,
978
1011
  labelEmission: () => labelEmission,
979
1012
  labelReadIsTranslated: () => labelReadIsTranslated,
980
1013
  landingNavId: () => landingNavId,
981
1014
  landsOn: () => landsOn,
982
1015
  landsUnconditionally: () => landsUnconditionally,
983
- layerLabel: () => layerLabel,
984
1016
  levelStateComputeds: () => levelStateComputeds,
985
1017
  libImportsFrom: () => libImportsFrom,
1018
+ liftToList: () => liftToList,
1019
+ liftToListInTemplate: () => liftToListInTemplate,
1020
+ liftsToList: () => liftsToList,
986
1021
  linkDrift: () => linkDrift,
987
1022
  linkTargetKind: () => linkTargetKind,
988
1023
  linkedVariableReaders: () => linkedVariableReaders,
@@ -992,6 +1027,7 @@ __export(index_exports, {
992
1027
  listFeatures: () => listFeatures,
993
1028
  listFilesUnder: () => listFilesUnder,
994
1029
  listFunctions: () => listFunctions,
1030
+ listOneFunctions: () => listOneFunctions,
995
1031
  listScreenComputeds: () => listScreenComputeds,
996
1032
  listScreenInputs: () => listScreenInputs,
997
1033
  listScreenOutputs: () => listScreenOutputs,
@@ -1100,6 +1136,7 @@ __export(index_exports, {
1100
1136
  navRowMiss: () => navRowMiss,
1101
1137
  navRowSourceBindings: () => navRowSourceBindings,
1102
1138
  navRowSourceOptions: () => navRowSourceOptions,
1139
+ navRowStoreOptions: () => navRowStoreOptions,
1103
1140
  navSegmentId: () => navSegmentId,
1104
1141
  navTailPathsOf: () => navTailPathsOf,
1105
1142
  navVariantNavIds: () => navVariantNavIds,
@@ -1147,6 +1184,13 @@ __export(index_exports, {
1147
1184
  normalizeTranslationKey: () => normalizeTranslationKey,
1148
1185
  normalizeVariantName: () => normalizeVariantName,
1149
1186
  offersOutputArms: () => offersOutputArms,
1187
+ oneFunctionArgFits: () => oneFunctionArgFits,
1188
+ oneFunctionFromPickValue: () => oneFunctionFromPickValue,
1189
+ oneFunctionOf: () => oneFunctionOf,
1190
+ oneFunctionPickValue: () => oneFunctionPickValue,
1191
+ oneFunctionReturns: () => oneFunctionReturns,
1192
+ oneFunctionSignature: () => oneFunctionSignature,
1193
+ oneFunctionSignatureText: () => oneFunctionSignatureText,
1150
1194
  openError: () => openError,
1151
1195
  openId: () => openId,
1152
1196
  openInputAnswered: () => openInputAnswered,
@@ -1403,6 +1447,7 @@ __export(index_exports, {
1403
1447
  sanitizeControlGroups: () => sanitizeControlGroups,
1404
1448
  sanitizeControlVariants: () => sanitizeControlVariants,
1405
1449
  sanitizeDistinct: () => sanitizeDistinct,
1450
+ sanitizeEnums: () => sanitizeEnums,
1406
1451
  sanitizeMemberPath: () => sanitizeMemberPath,
1407
1452
  sanitizeNavMap: () => sanitizeNavMap,
1408
1453
  sanitizeNpmAllowlist: () => sanitizeNpmAllowlist,
@@ -1433,6 +1478,7 @@ __export(index_exports, {
1433
1478
  screenControlAttrs: () => screenControlAttrs,
1434
1479
  screenControlHasRequiredInputBindings: () => screenControlHasRequiredInputBindings,
1435
1480
  screenControlInputGuards: () => screenControlInputGuards,
1481
+ screenControlLiftsInput: () => screenControlLiftsInput,
1436
1482
  screenEmbedGapReason: () => screenEmbedGapReason,
1437
1483
  screenEmitBindingTargets: () => screenEmitBindingTargets,
1438
1484
  screenEmitConstTargets: () => screenEmitConstTargets,
@@ -1466,6 +1512,10 @@ __export(index_exports, {
1466
1512
  screenPropertiesWithComputeds: () => screenPropertiesWithComputeds,
1467
1513
  screenTest: () => screenTest,
1468
1514
  screenVariableActionEnumIds: () => screenVariableActionEnumIds,
1515
+ screenVariableDataType: () => screenVariableDataType,
1516
+ screenVariableEnumId: () => screenVariableEnumId,
1517
+ screenVariableEnumIds: () => screenVariableEnumIds,
1518
+ screenVariableEnums: () => screenVariableEnums,
1469
1519
  screenVariableInitialAllowed: () => screenVariableInitialAllowed,
1470
1520
  screenVariableInitialIssue: () => screenVariableInitialIssue,
1471
1521
  screenVariableSourceType: () => screenVariableSourceType,
@@ -1491,6 +1541,8 @@ __export(index_exports, {
1491
1541
  sectionTableEmissions: () => sectionTableEmissions,
1492
1542
  sectionTableRef: () => sectionTableRef,
1493
1543
  sectionTableRows: () => sectionTableRows,
1544
+ sectionTableSortEnums: () => sectionTableSortEnums,
1545
+ sectionTableSortIds: () => sectionTableSortIds,
1494
1546
  seedColumn: () => seedColumn,
1495
1547
  seedColumns: () => seedColumns,
1496
1548
  seedInstanceArgs: () => seedInstanceArgs,
@@ -1524,6 +1576,7 @@ __export(index_exports, {
1524
1576
  shapesInReach: () => shapesInReach,
1525
1577
  sharedShapeHolders: () => sharedShapeHolders,
1526
1578
  signatureChanged: () => signatureChanged,
1579
+ signatureEnums: () => signatureEnums,
1527
1580
  signatureFormIds: () => signatureFormIds,
1528
1581
  signatureNamesOptionRow: () => signatureNamesOptionRow,
1529
1582
  signatureShapeIds: () => signatureShapeIds,
@@ -1531,9 +1584,11 @@ __export(index_exports, {
1531
1584
  slug: () => slug,
1532
1585
  slugifyComponentName: () => slugifyComponentName,
1533
1586
  slugifyMessage: () => slugifyMessage,
1587
+ sortRowEnumId: () => sortRowEnumId,
1534
1588
  sourceCarriesTrackKey: () => sourceCarriesTrackKey,
1535
1589
  staleCases: () => staleCases,
1536
1590
  staleMenuActionItems: () => staleMenuActionItems,
1591
+ stampStatePropertyEnums: () => stampStatePropertyEnums,
1537
1592
  standardMenuConfigs: () => standardMenuConfigs,
1538
1593
  starterFunction: () => starterFunction,
1539
1594
  stateComputedArgExpression: () => stateComputedArgExpression,
@@ -1553,6 +1608,7 @@ __export(index_exports, {
1553
1608
  stateWriteTargets: () => stateWriteTargets,
1554
1609
  stateWriteToggleAllowed: () => stateWriteToggleAllowed,
1555
1610
  stateWriteValueKinds: () => stateWriteValueKinds,
1611
+ staticHeadSource: () => staticHeadSource,
1556
1612
  staticLabelSource: () => staticLabelSource,
1557
1613
  staticLiteralType: () => staticLiteralType,
1558
1614
  staticLiteralValue: () => staticLiteralValue,
@@ -1560,6 +1616,8 @@ __export(index_exports, {
1560
1616
  storeAppOptions: () => storeAppOptions,
1561
1617
  storeHookCallError: () => storeHookCallError,
1562
1618
  storeNameScope: () => storeNameScope,
1619
+ storeOwnerOfValue: () => storeOwnerOfValue,
1620
+ storeOwnerValue: () => storeOwnerValue,
1563
1621
  storeReaders: () => storeReaders,
1564
1622
  storeTest: () => storeTest,
1565
1623
  storesOf: () => storesOf,
@@ -1695,7 +1753,9 @@ __export(index_exports, {
1695
1753
  withEmittedTests: () => withEmittedTests,
1696
1754
  withFormShapes: () => withFormShapes,
1697
1755
  withListRowShape: () => withListRowShape,
1756
+ withScreenEnums: () => withScreenEnums,
1698
1757
  withScreenMethodCallSites: () => withScreenMethodCallSites,
1758
+ withVariableEnums: () => withVariableEnums,
1699
1759
  wouldComputedCycle: () => wouldComputedCycle,
1700
1760
  wouldCycle: () => wouldCycle,
1701
1761
  wouldScreenComputedCycle: () => wouldScreenComputedCycle,
@@ -1711,6 +1771,7 @@ var ControlType = /* @__PURE__ */ ((ControlType2) => {
1711
1771
  ControlType2["SECTION"] = "section";
1712
1772
  ControlType2["SECTION_HEADER"] = "section_header";
1713
1773
  ControlType2["SECTION_HEADER_LABEL"] = "section_header_label";
1774
+ ControlType2["SECTION_FOOTER"] = "section_footer";
1714
1775
  ControlType2["SECTION_HERO"] = "section_hero";
1715
1776
  ControlType2["SECTION_CAROUSEL"] = "section_carousel";
1716
1777
  ControlType2["SECTION_TABLE"] = "section_table";
@@ -1743,6 +1804,8 @@ var ControlType = /* @__PURE__ */ ((ControlType2) => {
1743
1804
  ControlType2["STAT_VALUE"] = "stat_value";
1744
1805
  ControlType2["STAT_CORNER"] = "stat_corner";
1745
1806
  ControlType2["HEAT_SWATCH"] = "heat_swatch";
1807
+ ControlType2["SCORE_SET"] = "score_set";
1808
+ ControlType2["SCORE_SET_ITEM"] = "score_set_item";
1746
1809
  ControlType2["FORM"] = "form";
1747
1810
  ControlType2["FIELD"] = "field";
1748
1811
  ControlType2["SECTION_BUTTON_GROUP"] = "section_button_group";
@@ -1836,6 +1899,19 @@ var OPTION_ROW_TYPE_NAME = "DropdownOption";
1836
1899
  var OPTION_ROW_TYPE_PACKAGE = "@magmonium/one";
1837
1900
  var AUDIENCE_TYPE_NAME = "Audience";
1838
1901
  var AUDIENCE_TYPE_PACKAGE = "@magmonium/one";
1902
+ var SORT_DIRECTION_ENUM_ID = "section-table-sort-direction";
1903
+ function screenVariableDataType(variable) {
1904
+ return {
1905
+ type: variable.dataType,
1906
+ ...variable.actionEnumId ? { actionEnumId: variable.actionEnumId } : {},
1907
+ ...variable.sortEnumId ? { sortEnumId: variable.sortEnumId } : {}
1908
+ };
1909
+ }
1910
+ var enumIdOf = (dataType) => dataType?.actionEnumId ?? dataType?.sortEnumId;
1911
+ var isControlEnum = (dataType) => {
1912
+ const id = enumIdOf(dataType);
1913
+ return !!id && id !== SORT_DIRECTION_ENUM_ID;
1914
+ };
1839
1915
  var isMapCardinality = (cardinality) => cardinality === "map" || cardinality === "map-many";
1840
1916
  var SHARED_SHAPE_ID_PREFIX = "shared-";
1841
1917
  var isSharedShapeId = (id) => !!id && id.startsWith(SHARED_SHAPE_ID_PREFIX);
@@ -2084,6 +2160,9 @@ var featureShapeIds = (fn) => signatureShapeIds(fn).filter((id) => !isSharedShap
2084
2160
  var returnCardinalityOf = (fn) => fn.returnCardinality ?? "one";
2085
2161
  function tierOf(fn) {
2086
2162
  if (featureShapeIds(fn).length > 0) return "feature";
2163
+ if (fn.params.some((param) => isControlEnum(param.dataType)) || isControlEnum(fn.returnType)) {
2164
+ return "feature";
2165
+ }
2087
2166
  return fn.tier === "feature" ? "feature" : "app";
2088
2167
  }
2089
2168
  var isAppTier = (fn) => tierOf(fn) === "app";
@@ -2310,8 +2389,8 @@ var elementMismatch = (source, sourceShapes, target, targetShapes, seen, at, mis
2310
2389
  return void 0;
2311
2390
  };
2312
2391
  function dataTypeFits(source, sourceShapes, target, targetShapes, keyed = false) {
2313
- const cardinalityFits = source.cardinality === target.cardinality || keyed && source.cardinality === "many" && isMapCardinality(target.cardinality);
2314
- if (!cardinalityFits) return false;
2392
+ const cardinalityFits2 = source.cardinality === target.cardinality || keyed && source.cardinality === "many" && isMapCardinality(target.cardinality);
2393
+ if (!cardinalityFits2) return false;
2315
2394
  return elementFits(
2316
2395
  source.dataType,
2317
2396
  sourceShapes,
@@ -2321,8 +2400,8 @@ function dataTypeFits(source, sourceShapes, target, targetShapes, keyed = false)
2321
2400
  );
2322
2401
  }
2323
2402
  function dataTypeMismatch(source, sourceShapes, target, targetShapes, keyed = false, label = "value", missingFrom = "the response") {
2324
- const cardinalityFits = source.cardinality === target.cardinality || keyed && source.cardinality === "many" && isMapCardinality(target.cardinality);
2325
- if (!cardinalityFits) {
2403
+ const cardinalityFits2 = source.cardinality === target.cardinality || keyed && source.cardinality === "many" && isMapCardinality(target.cardinality);
2404
+ if (!cardinalityFits2) {
2326
2405
  return `${label} \u2014 ${target.cardinality} expected, ${source.cardinality} arrives`;
2327
2406
  }
2328
2407
  return elementMismatch(
@@ -2565,7 +2644,8 @@ var formFileBase = (formName) => `${formName.replace(/_/g, "-")}-form`;
2565
2644
  function tsTypeExpression(shapes, dataType, cardinality, actionEnumName = () => void 0) {
2566
2645
  const shapeKey = shapeKeyOf(dataType);
2567
2646
  const interfaceNameOf = dataType?.type === "form" ? formInterfaceName : shapeInterfaceName;
2568
- const enumName = dataType?.actionEnumId ? actionEnumName(dataType.actionEnumId) : void 0;
2647
+ const enumId = dataType?.actionEnumId ?? dataType?.sortEnumId;
2648
+ const enumName = enumId ? actionEnumName(enumId) : void 0;
2569
2649
  const element = shapeKey !== void 0 ? interfaceNameOf(shapes[shapeKey]?.name ?? "") : enumName ?? (dataType?.type === "file" ? "File" : dataType?.type === "option" ? OPTION_ROW_TYPE_NAME : dataType?.type === "audience" ? AUDIENCE_TYPE_NAME : dataType?.type) ?? "string";
2570
2650
  const named = element || "unknown";
2571
2651
  if (cardinality === "many") return `${named}[]`;
@@ -3172,10 +3252,14 @@ var contentTemplateTag = (host) => {
3172
3252
  var contentOf = (node) => (node.childrens ?? []).find((child) => child.type === "content" /* CONTENT */);
3173
3253
  var hasContent = (node) => (node.childrens ?? []).some((child) => child.type === "content" /* CONTENT */);
3174
3254
 
3255
+ // libs/codegen/src/model/one-import-module.ts
3256
+ var ONE_IMPORT_MODULE = "@magmonium/one";
3257
+
3175
3258
  // libs/codegen/src/model/control-const.ts
3176
3259
  var CONTROL_RELATIONSHIPS = {
3177
3260
  ["section" /* SECTION */]: [
3178
3261
  "section_header" /* SECTION_HEADER */,
3262
+ "section_footer" /* SECTION_FOOTER */,
3179
3263
  "section_search" /* SECTION_SEARCH */,
3180
3264
  "section_action" /* SECTION_ACTION */,
3181
3265
  "section_filter" /* SECTION_FILTER */,
@@ -3224,6 +3308,10 @@ var CONTROL_RELATIONSHIPS = {
3224
3308
  // line is, and everything beside it (the toggle, the input) is the bar
3225
3309
  // itself rather than a child.
3226
3310
  ["section_search" /* SECTION_SEARCH */]: ["section_header_label" /* SECTION_HEADER_LABEL */],
3311
+ // Its label slot and nothing else — the SectionHeader's title slot, caught
3312
+ // by the footer's unselected `ng-content`. Everything else a footer is
3313
+ // (`sticky`, `align`) is a setting rather than a child.
3314
+ ["section_footer" /* SECTION_FOOTER */]: ["section_header_label" /* SECTION_HEADER_LABEL */],
3227
3315
  // Buttons and nothing else — and unlike the SectionButtonGroup it looks like,
3228
3316
  // they are *consumed* rather than projected: an `m-action` renders raw
3229
3317
  // `<button>`s from a list, so a Button dropped here emits no tag of its own
@@ -3270,6 +3358,7 @@ var CONTROL_RELATIONSHIPS = {
3270
3358
  "user" /* USER */,
3271
3359
  "stat" /* STAT */,
3272
3360
  "heat_swatch" /* HEAT_SWATCH */,
3361
+ "score_set" /* SCORE_SET */,
3273
3362
  "flex" /* FLEX */,
3274
3363
  "card" /* CARD */,
3275
3364
  "chat_bubble" /* CHAT_BUBBLE */,
@@ -3334,6 +3423,7 @@ var CONTROL_RELATIONSHIPS = {
3334
3423
  "user" /* USER */,
3335
3424
  "stat" /* STAT */,
3336
3425
  "heat_swatch" /* HEAT_SWATCH */,
3426
+ "score_set" /* SCORE_SET */,
3337
3427
  "flex" /* FLEX */,
3338
3428
  "card" /* CARD */,
3339
3429
  "chat_bubble" /* CHAT_BUBBLE */,
@@ -3359,6 +3449,7 @@ var CONTROL_RELATIONSHIPS = {
3359
3449
  "user" /* USER */,
3360
3450
  "stat" /* STAT */,
3361
3451
  "heat_swatch" /* HEAT_SWATCH */,
3452
+ "score_set" /* SCORE_SET */,
3362
3453
  "flex" /* FLEX */,
3363
3454
  "card" /* CARD */,
3364
3455
  "chat_bubble" /* CHAT_BUBBLE */,
@@ -3392,6 +3483,7 @@ var CONTROL_RELATIONSHIPS = {
3392
3483
  "user" /* USER */,
3393
3484
  "stat" /* STAT */,
3394
3485
  "heat_swatch" /* HEAT_SWATCH */,
3486
+ "score_set" /* SCORE_SET */,
3395
3487
  "flex" /* FLEX */,
3396
3488
  "card" /* CARD */,
3397
3489
  "chat_bubble" /* CHAT_BUBBLE */,
@@ -3429,6 +3521,7 @@ var CONTROL_RELATIONSHIPS = {
3429
3521
  "user" /* USER */,
3430
3522
  "stat" /* STAT */,
3431
3523
  "heat_swatch" /* HEAT_SWATCH */,
3524
+ "score_set" /* SCORE_SET */,
3432
3525
  "card" /* CARD */,
3433
3526
  "chat_bubble" /* CHAT_BUBBLE */,
3434
3527
  "section_carousel" /* SECTION_CAROUSEL */,
@@ -3462,6 +3555,7 @@ var CONTROL_RELATIONSHIPS = {
3462
3555
  "user" /* USER */,
3463
3556
  "stat" /* STAT */,
3464
3557
  "heat_swatch" /* HEAT_SWATCH */,
3558
+ "score_set" /* SCORE_SET */,
3465
3559
  "card" /* CARD */,
3466
3560
  "chat_bubble" /* CHAT_BUBBLE */,
3467
3561
  "section_carousel" /* SECTION_CAROUSEL */,
@@ -3527,6 +3621,7 @@ var CONTROL_RELATIONSHIPS = {
3527
3621
  "plugin" /* PLUGIN */,
3528
3622
  "user" /* USER */,
3529
3623
  "heat_swatch" /* HEAT_SWATCH */,
3624
+ "score_set" /* SCORE_SET */,
3530
3625
  "button" /* BUTTON */,
3531
3626
  "context_menu" /* CONTEXT_MENU */,
3532
3627
  "audience_picker" /* AUDIENCE_PICKER */,
@@ -3606,6 +3701,12 @@ var CONTROL_RELATIONSHIPS = {
3606
3701
  // A leaf: a block of colour holds nothing, and the figure it stands for is a
3607
3702
  // text laid beside it by the Flex that holds both.
3608
3703
  ["heat_swatch" /* HEAT_SWATCH */]: [],
3704
+ // Its Scores and nothing else — a headline is an attribute, and what the set
3705
+ // draws is read off its items, never projected markup (libs/one GLOSSARY.md
3706
+ // ScoreSet). Seeded with three, the first primary, so a fresh drop draws.
3707
+ ["score_set" /* SCORE_SET */]: ["score_set_item" /* SCORE_SET_ITEM */],
3708
+ // A leaf: an item renders nothing of its own.
3709
+ ["score_set_item" /* SCORE_SET_ITEM */]: [],
3609
3710
  // Content like a Logo, but the one content Control that is not a leaf: what
3610
3711
  // `m-user` projects beneath the name is a ContentControl, the same single
3611
3712
  // child a card Field takes and gated the same way, through `contentSlotOf`.
@@ -3662,6 +3763,8 @@ var canUseArmKind = (branch, kind, controlMap, currentArmId) => {
3662
3763
  var CONTROL_MAX_CHILDREN = {
3663
3764
  ["section" /* SECTION */]: {
3664
3765
  ["section_header" /* SECTION_HEADER */]: 1,
3766
+ // One `<ng-content select="m-section-footer" />` closing the Section.
3767
+ ["section_footer" /* SECTION_FOOTER */]: 1,
3665
3768
  ["section_search" /* SECTION_SEARCH */]: 1,
3666
3769
  // One `<ng-content select="m-action, m-one-action" />` per Section, so a
3667
3770
  // second bar has nowhere to land (libs/one SectionComponent).
@@ -3749,7 +3852,8 @@ var canPlaceChild = (parent, childType, controlMap) => {
3749
3852
  if (isSectionHeaderSlotFamily(childType)) {
3750
3853
  const hosts = [
3751
3854
  "section_header" /* SECTION_HEADER */,
3752
- "section_search" /* SECTION_SEARCH */
3855
+ "section_search" /* SECTION_SEARCH */,
3856
+ "section_footer" /* SECTION_FOOTER */
3753
3857
  ];
3754
3858
  if (!parent || !hosts.includes(parent.type)) return false;
3755
3859
  return !(parent.childrens ?? []).some(
@@ -3800,6 +3904,7 @@ var OWN_DIRECTIVES = {
3800
3904
  ["section" /* SECTION */]: ["mAccordion", "mAccordionGroup", "routerLink"],
3801
3905
  ["section_header" /* SECTION_HEADER */]: ["routerLink"],
3802
3906
  ["section_header_label" /* SECTION_HEADER_LABEL */]: ["routerLink"],
3907
+ ["section_footer" /* SECTION_FOOTER */]: ["routerLink"],
3803
3908
  ["section_search" /* SECTION_SEARCH */]: ["routerLink"],
3804
3909
  ["section_filter" /* SECTION_FILTER */]: ["routerLink"],
3805
3910
  ["section_filter_group" /* SECTION_FILTER_GROUP */]: ["routerLink"],
@@ -3843,6 +3948,8 @@ var OWN_DIRECTIVES = {
3843
3948
  ["stat_value" /* STAT_VALUE */]: ["routerLink"],
3844
3949
  ["stat_corner" /* STAT_CORNER */]: ["routerLink"],
3845
3950
  ["heat_swatch" /* HEAT_SWATCH */]: ["routerLink"],
3951
+ ["score_set" /* SCORE_SET */]: [],
3952
+ ["score_set_item" /* SCORE_SET_ITEM */]: [],
3846
3953
  ["form" /* FORM */]: ["routerLink"],
3847
3954
  ["field" /* FIELD */]: ["mOptions", "routerLink"],
3848
3955
  // Nothing to attach: a ContentControl emits an `ng-template` — where a
@@ -3975,6 +4082,7 @@ var CONTROL_LABEL = {
3975
4082
  ["section" /* SECTION */]: "section",
3976
4083
  ["section_header" /* SECTION_HEADER */]: "section-header",
3977
4084
  ["section_header_label" /* SECTION_HEADER_LABEL */]: "section-header-label",
4085
+ ["section_footer" /* SECTION_FOOTER */]: "section-footer",
3978
4086
  ["section_search" /* SECTION_SEARCH */]: "section-search",
3979
4087
  ["section_filter" /* SECTION_FILTER */]: "section-filter",
3980
4088
  ["section_filter_group" /* SECTION_FILTER_GROUP */]: "section-filter-group",
@@ -4011,6 +4119,8 @@ var CONTROL_LABEL = {
4011
4119
  ["stat_value" /* STAT_VALUE */]: "stat-value",
4012
4120
  ["stat_corner" /* STAT_CORNER */]: "stat-corner",
4013
4121
  ["heat_swatch" /* HEAT_SWATCH */]: "heat-swatch",
4122
+ ["score_set" /* SCORE_SET */]: "score-set-control",
4123
+ ["score_set_item" /* SCORE_SET_ITEM */]: "score-set-item-control",
4014
4124
  ["nav_header" /* NAV_HEADER */]: "nav-header",
4015
4125
  ["form" /* FORM */]: "form",
4016
4126
  ["field" /* FIELD */]: "field",
@@ -4038,6 +4148,7 @@ var CONTROL_ICON = {
4038
4148
  ["section" /* SECTION */]: "control_section",
4039
4149
  ["section_header" /* SECTION_HEADER */]: "control_section_header",
4040
4150
  ["section_header_label" /* SECTION_HEADER_LABEL */]: "control_section_header_label",
4151
+ ["section_footer" /* SECTION_FOOTER */]: "control_section_footer",
4041
4152
  ["section_search" /* SECTION_SEARCH */]: "control_section_search",
4042
4153
  // Reuse the search glyph until filter artwork joins the shared set — the
4043
4154
  // same stand-in CARD takes from the side panel.
@@ -4079,6 +4190,9 @@ var CONTROL_ICON = {
4079
4190
  ["stat_corner" /* STAT_CORNER */]: "control_stat_corner",
4080
4191
  // Reuse the Stat glyph until swatch artwork joins the shared set.
4081
4192
  ["heat_swatch" /* HEAT_SWATCH */]: "control_stat",
4193
+ // Reuse the Stat glyph until score artwork joins the shared set.
4194
+ ["score_set" /* SCORE_SET */]: "control_stat",
4195
+ ["score_set_item" /* SCORE_SET_ITEM */]: "control_stat_value",
4082
4196
  ["nav_header" /* NAV_HEADER */]: "control_nav_header",
4083
4197
  ["form" /* FORM */]: "control_form",
4084
4198
  ["field" /* FIELD */]: "control_field",
@@ -4126,7 +4240,6 @@ var DIRECTIVE_CODEGEN = {
4126
4240
  mPadding: "PaddingDirective",
4127
4241
  mMargin: "MarginDirective"
4128
4242
  };
4129
- var ONE_IMPORT_MODULE = "@magmonium/one";
4130
4243
  var CONTROL_CODEGEN = {
4131
4244
  ["section" /* SECTION */]: {
4132
4245
  tag: "m-section",
@@ -4137,6 +4250,12 @@ var CONTROL_CODEGEN = {
4137
4250
  tag: "m-section-header",
4138
4251
  component: "SectionHeaderComponent"
4139
4252
  },
4253
+ // Folderless for the section_header's reason — `sticky` and `align` are its
4254
+ // only settings, both scalars, and its text is the projected label slot.
4255
+ ["section_footer" /* SECTION_FOOTER */]: {
4256
+ tag: "m-section-footer",
4257
+ component: "SectionFooterComponent"
4258
+ },
4140
4259
  // Folderless for the section_header's reason — SectionSearchComponent takes
4141
4260
  // `searchLabel`, `debounce`, `startOpen` and `sticky` as individual inputs
4142
4261
  // rather than a `config` bag, so there is nothing a `name="<id>"` could
@@ -4340,6 +4459,16 @@ var CONTROL_CODEGEN = {
4340
4459
  tag: "m-heat-swatch",
4341
4460
  component: "HeatSwatchComponent"
4342
4461
  },
4462
+ // Folderless for the Stat's reason: no list, no artwork, every setting a
4463
+ // scalar on the tag (libs/one GLOSSARY.md ScoreSet).
4464
+ ["score_set" /* SCORE_SET */]: {
4465
+ tag: "m-score-set",
4466
+ component: "ScoreSetComponent"
4467
+ },
4468
+ ["score_set_item" /* SCORE_SET_ITEM */]: {
4469
+ tag: "m-score-set-item",
4470
+ component: "ScoreSetItemComponent"
4471
+ },
4343
4472
  // Navigation header with back button and breadcrumb trail.
4344
4473
  // Folderless as it uses NavStore internally and takes no config.
4345
4474
  ["nav_header" /* NAV_HEADER */]: {
@@ -4719,6 +4848,159 @@ var screenMethodCalls = (method) => method ? [
4719
4848
  ...method.calls ?? []
4720
4849
  ] : [];
4721
4850
 
4851
+ // libs/codegen/src/model/one-function-catalog.ts
4852
+ var ONE_FUNCTION_ID_PARAM = "id";
4853
+ var ONE_FUNCTION_MAP_PARAM = "map";
4854
+ var ONE_FUNCTION_PREFIX = "one:";
4855
+ var ONE_FUNCTIONS = [
4856
+ {
4857
+ // `getFromMap<T>(id, map: Record<string, T>): T | undefined` — the row a
4858
+ // `map` holds under an id, typically a ScreenInput a Page was handed.
4859
+ name: "getFromMap",
4860
+ importFrom: ONE_IMPORT_MODULE,
4861
+ reach: ["screen-computed"],
4862
+ returnsRow: true,
4863
+ params: [
4864
+ { id: ONE_FUNCTION_ID_PARAM, name: "id", rule: "string-one" },
4865
+ { id: ONE_FUNCTION_MAP_PARAM, name: "map", rule: "map-path" }
4866
+ ],
4867
+ rowParamId: ONE_FUNCTION_MAP_PARAM,
4868
+ rowCardinality: "map",
4869
+ signature: (row) => ({
4870
+ params: [
4871
+ {
4872
+ id: ONE_FUNCTION_ID_PARAM,
4873
+ name: "id",
4874
+ dataType: { type: "string" },
4875
+ cardinality: "one",
4876
+ acceptsUndefined: true
4877
+ },
4878
+ {
4879
+ id: ONE_FUNCTION_MAP_PARAM,
4880
+ name: "map",
4881
+ dataType: row,
4882
+ cardinality: "map",
4883
+ acceptsUndefined: true
4884
+ }
4885
+ ],
4886
+ returnType: row,
4887
+ returnCardinality: "one",
4888
+ returnUndefined: true
4889
+ })
4890
+ },
4891
+ {
4892
+ // `existsInMap(id, map: Record<string, unknown>): boolean` — whether a
4893
+ // `map` holds anything under an id (ADR 0202). `false` rather than
4894
+ // `undefined` while either is, so a gate on an unloaded store reads "not
4895
+ // there yet" and a computed over it never needs `?.`.
4896
+ name: "existsInMap",
4897
+ importFrom: ONE_IMPORT_MODULE,
4898
+ reach: ["screen-computed", "call-condition"],
4899
+ returnsRow: false,
4900
+ params: [
4901
+ { id: ONE_FUNCTION_ID_PARAM, name: "id", rule: "string-one" },
4902
+ { id: ONE_FUNCTION_MAP_PARAM, name: "map", rule: "map-path" }
4903
+ ],
4904
+ rowParamId: ONE_FUNCTION_MAP_PARAM,
4905
+ rowCardinality: "map",
4906
+ signature: (row) => ({
4907
+ params: [
4908
+ {
4909
+ id: ONE_FUNCTION_ID_PARAM,
4910
+ name: "id",
4911
+ dataType: { type: "string" },
4912
+ cardinality: "one",
4913
+ acceptsUndefined: true
4914
+ },
4915
+ {
4916
+ id: ONE_FUNCTION_MAP_PARAM,
4917
+ name: "map",
4918
+ dataType: row,
4919
+ cardinality: "map",
4920
+ acceptsUndefined: true
4921
+ }
4922
+ ],
4923
+ returnType: { type: "boolean" },
4924
+ returnCardinality: "one"
4925
+ })
4926
+ },
4927
+ {
4928
+ // `notExistsInMap(id, map: Record<string, unknown>): boolean` — the
4929
+ // named inverse, offered on CallConditions (ADR 0202).
4930
+ name: "notExistsInMap",
4931
+ importFrom: ONE_IMPORT_MODULE,
4932
+ reach: ["call-condition"],
4933
+ returnsRow: false,
4934
+ params: [
4935
+ { id: ONE_FUNCTION_ID_PARAM, name: "id", rule: "string-one" },
4936
+ { id: ONE_FUNCTION_MAP_PARAM, name: "map", rule: "map-path" }
4937
+ ],
4938
+ rowParamId: ONE_FUNCTION_MAP_PARAM,
4939
+ rowCardinality: "map",
4940
+ signature: (row) => ({
4941
+ params: [
4942
+ {
4943
+ id: ONE_FUNCTION_ID_PARAM,
4944
+ name: "id",
4945
+ dataType: { type: "string" },
4946
+ cardinality: "one",
4947
+ acceptsUndefined: true
4948
+ },
4949
+ {
4950
+ id: ONE_FUNCTION_MAP_PARAM,
4951
+ name: "map",
4952
+ dataType: row,
4953
+ cardinality: "map",
4954
+ acceptsUndefined: true
4955
+ }
4956
+ ],
4957
+ returnType: { type: "boolean" },
4958
+ returnCardinality: "one"
4959
+ })
4960
+ }
4961
+ ];
4962
+ var ONE_FUNCTION_CATALOG = Object.fromEntries(ONE_FUNCTIONS.map((entry2) => [entry2.name, entry2]));
4963
+ var oneFunctionOf = (name3) => name3 ? ONE_FUNCTIONS.find((entry2) => entry2.name === name3) : void 0;
4964
+ var listOneFunctions = (reach = "screen-computed") => ONE_FUNCTIONS.filter((entry2) => entry2.reach.includes(reach)).sort(
4965
+ (a, b) => a.name.localeCompare(b.name)
4966
+ );
4967
+ var oneFunctionPickValue = (name3) => `${ONE_FUNCTION_PREFIX}${name3}`;
4968
+ var oneFunctionFromPickValue = (value) => value?.startsWith(ONE_FUNCTION_PREFIX) ? oneFunctionOf(value.slice(ONE_FUNCTION_PREFIX.length)) : void 0;
4969
+ function oneFunctionArgFits(param, held, fromPath) {
4970
+ if (!held) return false;
4971
+ if (param.rule === "string-one")
4972
+ return held.dataType.type === "string" && held.cardinality === "one";
4973
+ return fromPath && held.cardinality === "map";
4974
+ }
4975
+ function oneFunctionReturns(entry2, row) {
4976
+ const signature = entry2.signature(row);
4977
+ return {
4978
+ dataType: signature.returnType,
4979
+ cardinality: signature.returnCardinality,
4980
+ ...signature.returnUndefined ? { optional: true } : {}
4981
+ };
4982
+ }
4983
+ function oneFunctionSignature(entry2, returns) {
4984
+ return {
4985
+ id: "",
4986
+ name: entry2.name,
4987
+ // An entry answering a fixed type stores that type, not the row: its
4988
+ // `map` is spelled `Record<string, unknown>` by the library, so the stand-in
4989
+ // over the stored type reads the same at every reader.
4990
+ ...entry2.signature(returns.dataType),
4991
+ body: ""
4992
+ };
4993
+ }
4994
+ function oneFunctionSignatureText(entry2, rowLabel) {
4995
+ const generic = entry2.returnsRow && !rowLabel;
4996
+ const t = entry2.returnsRow ? rowLabel ?? "T" : "unknown";
4997
+ const params = entry2.params.map(
4998
+ (param) => param.rule === "string-one" ? `${param.name}: string` : `${param.name}: Record<string, ${t}>`
4999
+ ).join(", ");
5000
+ const returns = entry2.returnsRow ? `${t} | undefined` : "boolean";
5001
+ return `${entry2.name}${generic ? "<T>" : ""}(${params}): ${returns}`;
5002
+ }
5003
+
4722
5004
  // libs/codegen/src/lib/pure-function-helper.ts
4723
5005
  function normalizeFunctionName(raw) {
4724
5006
  const cleaned = raw.trim().replace(
@@ -4753,35 +5035,62 @@ function listFunctions(functions) {
4753
5035
  (a, b) => a.name.localeCompare(b.name)
4754
5036
  );
4755
5037
  }
4756
- function paramTypeText(shapes, param) {
4757
- const type = tsTypeExpression(shapes, param.dataType, param.cardinality);
5038
+ var enumNameIn = (enums) => (id) => enums?.find((entry2) => entry2.id === id)?.name;
5039
+ function paramTypeText(shapes, param, enums) {
5040
+ const type = tsTypeExpression(
5041
+ shapes,
5042
+ param.dataType,
5043
+ param.cardinality,
5044
+ enumNameIn(enums)
5045
+ );
4758
5046
  return param.acceptsUndefined ? `${type} | undefined` : type;
4759
5047
  }
4760
- function paramListText(shapes, params) {
4761
- return params.map((param) => `${param.name}: ${paramTypeText(shapes, param)}`).join(", ");
5048
+ function paramListText(shapes, params, enums) {
5049
+ return params.map((param) => `${param.name}: ${paramTypeText(shapes, param, enums)}`).join(", ");
4762
5050
  }
4763
- function returnTypeText(shapes, fn) {
4764
- const type = tsTypeExpression(shapes, fn.returnType, fn.returnCardinality);
5051
+ function returnTypeText(shapes, fn, enums) {
5052
+ const type = tsTypeExpression(
5053
+ shapes,
5054
+ fn.returnType,
5055
+ fn.returnCardinality,
5056
+ enumNameIn(enums)
5057
+ );
4765
5058
  const widened = fn.returnUndefined ? `${type} | undefined` : type;
4766
5059
  return fn.returnAsync ? `Promise<${widened}>` : widened;
4767
5060
  }
4768
- function signatureText(shapes, fn) {
5061
+ function signatureText(shapes, fn, enums) {
4769
5062
  return `export const ${fn.name} = ${fn.returnAsync ? "async " : ""}(${paramListText(
4770
5063
  shapes,
4771
- fn.params
4772
- )}): ${returnTypeText(shapes, fn)} => {`;
5064
+ fn.params,
5065
+ enums
5066
+ )}): ${returnTypeText(shapes, fn, enums)} => {`;
5067
+ }
5068
+ function signatureEnums(fn, enums) {
5069
+ const ids = [
5070
+ ...fn.params.map((param) => enumIdOf(param.dataType)),
5071
+ enumIdOf(fn.returnType)
5072
+ ].filter((id) => !!id);
5073
+ const named = [...new Set(ids)].map((id) => enums?.find((entry2) => entry2.id === id)).filter((entry2) => !!entry2);
5074
+ const seen = new Set(named.map((entry2) => entry2.name));
5075
+ const read = (enums ?? []).filter((entry2) => {
5076
+ if (seen.has(entry2.name)) return false;
5077
+ if (!new RegExp(`\\b${entry2.name}\\b`).test(fn.body ?? "")) return false;
5078
+ seen.add(entry2.name);
5079
+ return true;
5080
+ });
5081
+ return [...named, ...read];
4773
5082
  }
4774
- function functionJsDoc(shapes, fn) {
5083
+ function functionJsDoc(shapes, fn, enums) {
4775
5084
  const summary = (fn.description ?? "").trim();
4776
5085
  if (!summary) return "";
4777
5086
  const summaryLines = summary.split(/\n+/).map((line) => line.trim()).filter(Boolean).map((line) => ` * ${line}`);
4778
5087
  const paramLines = fn.params.map(
4779
- (param) => ` * @param ${param.name} - ${paramTypeText(shapes, param)}`
5088
+ (param) => ` * @param ${param.name} - ${paramTypeText(shapes, param, enums)}`
4780
5089
  );
4781
- const returns = ` * @returns ${returnTypeText(shapes, fn)}`;
5090
+ const returns = ` * @returns ${returnTypeText(shapes, fn, enums)}`;
4782
5091
  return ["/**", ...summaryLines, ...paramLines, returns, " */"].join("\n");
4783
5092
  }
4784
- function generateFunctionFile(shapes, fn) {
5093
+ function generateFunctionFile(shapes, fn, enums) {
4785
5094
  const npmImports = (fn.imports ?? []).map((entry2) => {
4786
5095
  const names = entry2.names.join(", ");
4787
5096
  return names ? `import { ${names} } from '${entry2.package}';` : "";
@@ -4799,15 +5108,18 @@ function generateFunctionFile(shapes, fn) {
4799
5108
  )}';`
4800
5109
  ).join("\n");
4801
5110
  const optionImport = signatureNamesOptionRow(fn) ? `import { ${OPTION_ROW_TYPE_NAME} } from '${OPTION_ROW_TYPE_PACKAGE}';` : "";
4802
- const imports = [npmImports, optionImport, shapeImports, formImports].filter(Boolean).join("\n");
4803
- const doc = functionJsDoc(shapes, fn);
5111
+ const enumImports = signatureEnums(fn, enums).map(
5112
+ (entry2) => entry2.library ? `import { ${entry2.name} } from '@magmonium/one';` : `import { ${entry2.name} } from '../type/${entry2.fileName.replace(/\.ts$/, "")}';`
5113
+ ).join("\n");
5114
+ const imports = [npmImports, optionImport, enumImports, shapeImports, formImports].filter(Boolean).join("\n");
5115
+ const doc = functionJsDoc(shapes, fn, enums);
4804
5116
  const head = [imports, doc].filter(Boolean).join("\n\n");
4805
5117
  const prefix = head ? `${head}
4806
5118
 
4807
5119
  ` : "";
4808
5120
  const body = fn.body.trim();
4809
5121
  const indented = body ? body.split("\n").map((line) => line.trim() ? ` ${line}` : line).join("\n") : "";
4810
- return `${prefix}${signatureText(shapes, fn)}
5122
+ return `${prefix}${signatureText(shapes, fn, enums)}
4811
5123
  ${indented}
4812
5124
  };
4813
5125
  `;
@@ -4877,7 +5189,11 @@ function screenComputedRootIds(computed) {
4877
5189
  function screenComputedFunction(computed, functions) {
4878
5190
  if (computed.functionId) return functions[computed.functionId];
4879
5191
  if (!computed.returns) return void 0;
4880
- const { dataType, cardinality } = computed.returns;
5192
+ const { dataType, cardinality, optional } = computed.returns;
5193
+ if (computed.oneFunction) {
5194
+ const entry2 = oneFunctionOf(computed.oneFunction);
5195
+ return entry2 ? oneFunctionSignature(entry2, computed.returns) : void 0;
5196
+ }
4881
5197
  return {
4882
5198
  id: "",
4883
5199
  name: "",
@@ -4886,10 +5202,12 @@ function screenComputedFunction(computed, functions) {
4886
5202
  ],
4887
5203
  returnType: dataType,
4888
5204
  returnCardinality: cardinality,
5205
+ ...optional ? { returnUndefined: true } : {},
4889
5206
  body: `return ${PASSTHROUGH_PARAM_ID};`
4890
5207
  };
4891
5208
  }
4892
- var isPassthroughComputed = (computed) => !computed.functionId;
5209
+ var isPassthroughComputed = (computed) => !computed.functionId && !computed.oneFunction;
5210
+ var isOneFunctionComputed = (computed) => !computed.functionId && !!computed.oneFunction;
4893
5211
  function screenComputedNavIds(computed) {
4894
5212
  return Object.values(computed.args).flatMap(
4895
5213
  (arg) => arg.source === "nav" && arg.navId ? [arg.navId] : []
@@ -4947,7 +5265,7 @@ function wouldScreenComputedCycle(computeds, hostId, targetId) {
4947
5265
  };
4948
5266
  return walk(targetId);
4949
5267
  }
4950
- var sameType = (a, b) => a.type === "shape" ? b.type === "shape" && a.shapeId === b.shapeId : a.type === b.type;
5268
+ var sameType = (held, param) => held.type === "shape" ? param.type === "shape" && held.shapeId === param.shapeId : held.type === param.type && (!enumIdOf(param) || enumIdOf(held) === enumIdOf(param));
4951
5269
  function argPathOptions(roots, shapes, param, computeds = {}) {
4952
5270
  return readablePaths(roots, shapes, computeds).filter((option2) => argAnswersParam(option2.held, param, shapes)).map(({ path, label }) => ({ path, label }));
4953
5271
  }
@@ -5023,7 +5341,7 @@ function screenComputedArgHeldType(arg, inputs, siblings, functions, scope = {})
5023
5341
  if (arg.source === "variable") {
5024
5342
  const variable = scope.variables?.[arg.variableId];
5025
5343
  return variable ? {
5026
- dataType: { type: variable.dataType },
5344
+ dataType: screenVariableDataType(variable),
5027
5345
  cardinality: variable.cardinality
5028
5346
  } : void 0;
5029
5347
  }
@@ -5113,7 +5431,7 @@ function screenPropertiesWithComputeds(properties, computeds = {}, functions = {
5113
5431
  result[variable.id] = {
5114
5432
  id: variable.id,
5115
5433
  name: variable.name,
5116
- dataType: { type: variable.dataType },
5434
+ dataType: screenVariableDataType(variable),
5117
5435
  cardinality: variable.cardinality
5118
5436
  };
5119
5437
  }
@@ -6797,7 +7115,11 @@ var BINDING_SLOT = {
6797
7115
  // A [HeatSwatch]'s figure, named for the `m-heat-swatch` input it lands on.
6798
7116
  // Content by the `total` test: what the block paints *is* the datum, one per
6799
7117
  // row inside a Repeat.
6800
- value: "value"
7118
+ value: "value",
7119
+ // A [ScoreSet]'s Score Date, named for the `m-score-set` input it lands on.
7120
+ // Content by the `total` test: whether the set reads stale *is* the datum's
7121
+ // age, read off the same record its Scores are.
7122
+ scoreDate: "scoreDate"
6801
7123
  };
6802
7124
  var USER_VALUE_SLOTS = [
6803
7125
  BINDING_SLOT.id,
@@ -6966,7 +7288,7 @@ var bindingDataType = (source, ctx) => {
6966
7288
  dataType = computed ? screenComputedFunction(computed, ctx.functions ?? {})?.returnType : void 0;
6967
7289
  } else if (root.kind === "screen_variable") {
6968
7290
  const variable = ctx.variables?.[root.id];
6969
- dataType = variable ? { type: variable.dataType } : void 0;
7291
+ dataType = variable ? screenVariableDataType(variable) : void 0;
6970
7292
  } else if (root.kind === "form_model") {
6971
7293
  const model = ctx.formModels?.[root.id];
6972
7294
  dataType = model ? { type: "form", formId: model.formId } : void 0;
@@ -8156,7 +8478,7 @@ var bindingCardinality = (binding, scope, seen = /* @__PURE__ */ new Set()) => {
8156
8478
  }
8157
8479
  case "screen_variable": {
8158
8480
  const variable = scope.screenVariables?.[root.id];
8159
- dataType = variable ? { type: variable.dataType } : void 0;
8481
+ dataType = variable ? screenVariableDataType(variable) : void 0;
8160
8482
  cardinality = variable?.cardinality;
8161
8483
  break;
8162
8484
  }
@@ -8694,7 +9016,7 @@ var screenRoots = (scope) => [
8694
9016
  ...Object.values(scope.screenVariables ?? {}).map((variable) => ({
8695
9017
  root: { kind: "screen_variable", id: variable.id },
8696
9018
  name: variable.name,
8697
- dataType: { type: variable.dataType },
9019
+ dataType: screenVariableDataType(variable),
8698
9020
  cardinality: variable.cardinality
8699
9021
  })),
8700
9022
  // A FormModel is the one Screen-owned root walked into rather than read
@@ -9041,7 +9363,15 @@ var sameType4 = (a, b) => {
9041
9363
  }
9042
9364
  return true;
9043
9365
  };
9044
- var bindingFits = (option2, target) => option2.cardinality === target.cardinality && option2.dataType?.type === target.dataType?.type && (option2.dataType?.type !== "shape" || target.dataType?.type !== "shape" || option2.dataType.shapeId === target.dataType.shapeId);
9366
+ var stringEnumFits = (read, target, enums) => {
9367
+ if (read.cardinality !== target.cardinality) return false;
9368
+ if (target.dataType?.type !== "string" || read.dataType?.type !== "enum") {
9369
+ return false;
9370
+ }
9371
+ const appEnum = enums?.[read.dataType.enumId];
9372
+ return !!appEnum?.hasValue && appEnum.valueType === "string";
9373
+ };
9374
+ var bindingFits = (option2, target, enums) => stringEnumFits(option2, target, enums) || option2.cardinality === target.cardinality && option2.dataType?.type === target.dataType?.type && (option2.dataType?.type !== "shape" || target.dataType?.type !== "shape" || option2.dataType.shapeId === target.dataType.shapeId);
9045
9375
  var eventMemberType = (row, scope) => {
9046
9376
  const path = row.event ?? [];
9047
9377
  if (row.source !== "event" || path.length !== 1) return void 0;
@@ -9050,7 +9380,7 @@ var eventMemberType = (row, scope) => {
9050
9380
  function callArgEventMismatch(row, target, scope) {
9051
9381
  if (!target?.dataType || row.transform) return false;
9052
9382
  const member = eventMemberType(row, scope);
9053
- return !!member && !sameType4(target, member);
9383
+ return !!member && !sameType4(target, member) && !stringEnumFits(member, target, scope.bindings?.enums);
9054
9384
  }
9055
9385
  var AUTO_CASTS = {
9056
9386
  string: { number: "Number", boolean: "Boolean" },
@@ -9062,6 +9392,7 @@ function callArgTypeMismatch(row, target, scope) {
9062
9392
  if (row.source !== "binding" && row.source !== "event") return void 0;
9063
9393
  const read = bindingPipeType(row, target, scope);
9064
9394
  if (!read || sameType4(target, read)) return void 0;
9395
+ if (stringEnumFits(read, target, scope.bindings?.enums)) return void 0;
9065
9396
  const expected = {
9066
9397
  dataType: target.dataType,
9067
9398
  cardinality: target.cardinality
@@ -9113,7 +9444,7 @@ var rowComplete = (row, target, payload, fieldNames, constants, functions, scope
9113
9444
  (option2) => option2.value === value
9114
9445
  );
9115
9446
  if (!picked) return "call-arg-unknown-binding";
9116
- if (!bindingFits(picked, target) && !row.transform) {
9447
+ if (!bindingFits(picked, target, scope.bindings?.enums) && !row.transform) {
9117
9448
  return "call-arg-type-mismatch";
9118
9449
  }
9119
9450
  } else if (row.source === "storage") {
@@ -9703,7 +10034,9 @@ var inputPrimitive = (input) => input.dataType.type === "shape" || input.dataTyp
9703
10034
  // boundary (ADR 0038) — so it is no ScreenInput's type either. An `audience`
9704
10035
  // joins it: a picker's value is held and bound as a whole, not narrowed to a
9705
10036
  // primitive here (ADR 0187).
9706
- input.dataType.type === "option" || input.dataType.type === "audience" ? void 0 : input.dataType.type;
10037
+ input.dataType.type === "option" || input.dataType.type === "audience" || // An AppTarget Enum (ADR 0204): matched by enumId in the source picker, not
10038
+ // by primitive type. A static literal cannot name a member identity.
10039
+ input.dataType.type === "enum" ? void 0 : input.dataType.type;
9707
10040
  function mergeScreenInputs(declared = {}, inferred = []) {
9708
10041
  const byName = /* @__PURE__ */ new Map();
9709
10042
  for (const input of listScreenInputs(declared)) {
@@ -9785,6 +10118,7 @@ function screenInputExpression(binding, target, wires, renderBinding = () => voi
9785
10118
  case "variable":
9786
10119
  case "constant":
9787
10120
  case "computed":
10121
+ case "enum-member":
9788
10122
  return void 0;
9789
10123
  // resolved by the caller, which knows this Screen's names
9790
10124
  case "output": {
@@ -9818,10 +10152,27 @@ function screenMemberExpression(binding, ctx) {
9818
10152
  const name3 = ctx.constants?.[binding.constantId]?.name;
9819
10153
  return name3 ?? void 0;
9820
10154
  }
10155
+ case "enum-member": {
10156
+ const appEnum = ctx.appEnums?.[binding.enumId];
10157
+ const member = appEnum?.members.find((m) => m.id === binding.memberId);
10158
+ return appEnum && member ? `${appEnum.name}.${member.key}` : void 0;
10159
+ }
9821
10160
  default:
9822
10161
  return void 0;
9823
10162
  }
9824
10163
  }
10164
+ var liftsToList = (target, source) => target.cardinality === "many" && source.cardinality === "one";
10165
+ var liftToList = (expression, present) => present ? `[${expression}]` : `${expression} !== undefined ? [${expression}] : []`;
10166
+ var liftToListInTemplate = (expression) => `${expression} | toList`;
10167
+ function screenControlLiftsInput(node, ctx, readSource) {
10168
+ if (node.type !== "screen" /* SCREEN */) return false;
10169
+ const ref = embeddedRefOf(node, ctx);
10170
+ if (!ref) return false;
10171
+ return Object.entries(ref.inputs).some(([inputId, target]) => {
10172
+ const binding = node.screenInputs?.[inputId];
10173
+ return !!binding && liftsToList(target, readSource(binding));
10174
+ });
10175
+ }
9825
10176
  function screenControlInputGuards(node, ctx, renderBinding = () => void 0, bindingPresent = () => true, computedPresent = () => true) {
9826
10177
  if (node.type !== "screen" /* SCREEN */) return [];
9827
10178
  const ref = embeddedRefOf(node, ctx);
@@ -9854,7 +10205,10 @@ function screenControlInputGuards(node, ctx, renderBinding = () => void 0, bindi
9854
10205
  }
9855
10206
  return [...guards.values()];
9856
10207
  }
9857
- function screenControlAttrs(node, ctx, wires, renderMethodCall, renderStateWrite = () => void 0, renderScreenWrites = () => [], renderScreenEmits = () => [], renderBinding = () => void 0, inputAliases = /* @__PURE__ */ new Map()) {
10208
+ function screenControlAttrs(node, ctx, wires, renderMethodCall, renderStateWrite = () => void 0, renderScreenWrites = () => [], renderScreenEmits = () => [], renderBinding = () => void 0, inputAliases = /* @__PURE__ */ new Map(), readSource = () => ({
10209
+ cardinality: void 0,
10210
+ present: true
10211
+ })) {
9858
10212
  if (node.type !== "screen" /* SCREEN */) return "";
9859
10213
  const ref = embeddedRefOf(node, ctx);
9860
10214
  if (!ref) return "";
@@ -9863,7 +10217,8 @@ function screenControlAttrs(node, ctx, wires, renderMethodCall, renderStateWrite
9863
10217
  const binding = node.screenInputs?.[inputId];
9864
10218
  if (!binding) return "";
9865
10219
  const read = screenMemberExpression(binding, ctx) ?? screenInputExpression(binding, target, wires, renderBinding);
9866
- const expr = read === void 0 ? void 0 : inputAliases.get(read) ?? read;
10220
+ const alias = read === void 0 ? void 0 : inputAliases.get(read);
10221
+ const expr = read === void 0 ? void 0 : liftsToList(target, readSource(binding)) ? liftToListInTemplate(alias ?? read) : alias ?? read;
9867
10222
  if (target.required && expr === void 0) return void 0;
9868
10223
  return expr === void 0 ? "" : ` [${target.name}]="${expr}"`;
9869
10224
  });
@@ -9958,6 +10313,8 @@ var unresolvedInputLeg = (binding, describeBinding) => {
9958
10313
  return "reads a ScreenConstant that is gone";
9959
10314
  case "computed":
9960
10315
  return "reads a ScreenComputed that is gone";
10316
+ case "enum-member":
10317
+ return "reads an Enum member that is gone";
9961
10318
  case "output":
9962
10319
  return "reads an output whose wire is gone";
9963
10320
  case "data":
@@ -9965,7 +10322,150 @@ var unresolvedInputLeg = (binding, describeBinding) => {
9965
10322
  }
9966
10323
  };
9967
10324
 
9968
- // libs/codegen/src/lib/state-write-helper.ts
10325
+ // libs/codegen/src/lib/section-table-helper.ts
10326
+ var SECTION_TABLE_COLUMNS_KEY = "columns";
10327
+ var SECTION_TABLE_SEED_COLUMNS = 3;
10328
+ var ALIGNS = ["left", "center", "right"];
10329
+ var DATA_TYPES = ["text", "number", "date"];
10330
+ var seedColumn = (index) => ({
10331
+ label: `column-${index + 1}`
10332
+ });
10333
+ var seedColumns = (count = SECTION_TABLE_SEED_COLUMNS) => Array.from({ length: count }, (_, i) => seedColumn(i));
10334
+ var text = (value) => {
10335
+ const trimmed = typeof value === "string" ? value.trim() : "";
10336
+ return trimmed || void 0;
10337
+ };
10338
+ function toSectionTableColumns(value) {
10339
+ if (!Array.isArray(value)) return [];
10340
+ return value.filter((raw) => !!raw && typeof raw === "object").map((raw) => {
10341
+ const column = {};
10342
+ const id = text(raw["id"]);
10343
+ if (id) column.id = id;
10344
+ const label = text(raw["label"]);
10345
+ if (label) column.label = label;
10346
+ if (ALIGNS.includes(raw["align"])) {
10347
+ column.align = raw["align"];
10348
+ }
10349
+ const span = Number(raw["span"]);
10350
+ if (raw["span"] != null && raw["span"] !== "" && Number.isFinite(span)) {
10351
+ column.span = Math.min(12, Math.max(1, Math.round(span)));
10352
+ }
10353
+ if (raw["sortable"] === true) column.sortable = true;
10354
+ if (DATA_TYPES.includes(raw["dataType"])) {
10355
+ column.dataType = raw["dataType"];
10356
+ }
10357
+ if (raw["defaultSort"] === true) column.defaultSort = true;
10358
+ if (raw["ascending"] === true) column.ascending = true;
10359
+ if (raw["freeze"] === true) column.freeze = true;
10360
+ if (raw["squeeze"] === true) column.squeeze = true;
10361
+ return column;
10362
+ });
10363
+ }
10364
+ var columnNeedsId = (column) => (!!column.sortable || !!column.defaultSort) && !column.id;
10365
+ var sectionTableSortIds = (columns) => [
10366
+ ...new Set(
10367
+ columns.filter((column) => column.sortable || column.defaultSort).map((column) => column.id).filter((id) => !!id)
10368
+ )
10369
+ ];
10370
+ var putSectionTableColumn = (columns, index, column) => {
10371
+ const next = index >= columns.length ? [...columns, column] : columns.map((current, i) => i === index ? column : current);
10372
+ if (!column.defaultSort) return next;
10373
+ return next.map((current, i) => {
10374
+ if (i === index || !current.defaultSort) return current;
10375
+ const { defaultSort: _defaultSort, ascending: _ascending, ...rest } = current;
10376
+ return rest;
10377
+ });
10378
+ };
10379
+ var enclosingSectionTable = (control, controlMap) => {
10380
+ const seen = /* @__PURE__ */ new Set();
10381
+ let current = control?.parentId ? controlMap[control.parentId] : void 0;
10382
+ while (current && isTaglessFamily(current.type) && !seen.has(current.id)) {
10383
+ seen.add(current.id);
10384
+ current = current.parentId ? controlMap[current.parentId] : void 0;
10385
+ }
10386
+ return current?.type === "section_table" /* SECTION_TABLE */ ? current : void 0;
10387
+ };
10388
+ var sectionTableRows = (tableId, controlMap) => {
10389
+ const rows = [];
10390
+ const walk = (ids) => ids.forEach((id) => {
10391
+ const control = controlMap[id];
10392
+ if (!control) return;
10393
+ if (control.type === "section_table_row" /* SECTION_TABLE_ROW */) rows.push(control);
10394
+ else if (isTaglessFamily(control.type)) walk(control.childrens ?? []);
10395
+ });
10396
+ walk(controlMap[tableId]?.childrens ?? []);
10397
+ return rows;
10398
+ };
10399
+ var tableHasRepeat = (tableId, controlMap) => {
10400
+ const walk = (ids) => ids.some((id) => {
10401
+ const control = controlMap[id];
10402
+ if (!control || !isTaglessFamily(control.type)) return false;
10403
+ return control.type === "repeat" /* REPEAT */ || walk(control.childrens ?? []);
10404
+ });
10405
+ return walk(controlMap[tableId]?.childrens ?? []);
10406
+ };
10407
+ var sectionTableRef = (id) => `sectionTable_${id.replace(/[^a-zA-Z0-9_]/g, "_")}`;
10408
+ var newCell = (id, parentId) => ({
10409
+ id,
10410
+ type: "section_table_cell" /* SECTION_TABLE_CELL */,
10411
+ parentId,
10412
+ configs: {},
10413
+ childrens: []
10414
+ });
10415
+ var descendants = (id, controlMap) => (controlMap[id]?.childrens ?? []).flatMap((child) => [
10416
+ child,
10417
+ ...descendants(child, controlMap)
10418
+ ]);
10419
+ function syncSectionTableCells(controlMap, tableId, change, genId2) {
10420
+ const next = { ...controlMap };
10421
+ sectionTableRows(tableId, controlMap).forEach((row) => {
10422
+ const cells = [...row.childrens];
10423
+ const pad2 = (length) => {
10424
+ while (cells.length < length) {
10425
+ const id = genId2();
10426
+ next[id] = newCell(id, row.id);
10427
+ cells.push(id);
10428
+ }
10429
+ };
10430
+ if (change.kind === "add") {
10431
+ pad2(change.index);
10432
+ const id = genId2();
10433
+ next[id] = newCell(id, row.id);
10434
+ cells.splice(change.index, 0, id);
10435
+ } else if (change.kind === "remove") {
10436
+ const [removed] = cells.splice(change.index, 1);
10437
+ if (removed) {
10438
+ [removed, ...descendants(removed, controlMap)].forEach(
10439
+ (id) => delete next[id]
10440
+ );
10441
+ }
10442
+ } else {
10443
+ pad2(Math.max(change.from, change.to) + 1);
10444
+ const [moved] = cells.splice(change.from, 1);
10445
+ cells.splice(change.to, 0, moved);
10446
+ }
10447
+ next[row.id] = { ...row, childrens: cells };
10448
+ });
10449
+ return next;
10450
+ }
10451
+ function seedSectionTableRow(rowId, parentId, cellCount, genId2) {
10452
+ const cells = Array.from(
10453
+ { length: Math.max(1, cellCount) },
10454
+ () => newCell(genId2(), rowId)
10455
+ );
10456
+ return {
10457
+ [rowId]: {
10458
+ id: rowId,
10459
+ type: "section_table_row" /* SECTION_TABLE_ROW */,
10460
+ parentId,
10461
+ configs: {},
10462
+ childrens: cells.map((cell) => cell.id)
10463
+ },
10464
+ ...Object.fromEntries(cells.map((cell) => [cell.id, cell]))
10465
+ };
10466
+ }
10467
+
10468
+ // libs/codegen/src/lib/screen-write-helper.ts
9969
10469
  var VALUE_KINDS = [
9970
10470
  "fixed",
9971
10471
  "const",
@@ -9974,17 +10474,337 @@ var VALUE_KINDS = [
9974
10474
  "event",
9975
10475
  "input"
9976
10476
  ];
9977
- var isStateWrite = (value) => typeof value === "object" && value !== null && "propertyId" in value && typeof value.propertyId === "string" && "value" in value && typeof value.value === "object" && value.value !== null && VALUE_KINDS.includes(value.value?.kind);
10477
+ var isScreenWrite = (value) => typeof value === "object" && value !== null && "variableId" in value && typeof value.variableId === "string" && "value" in value && typeof value.value === "object" && value.value !== null && VALUE_KINDS.includes(value.value?.kind);
10478
+ function screenWriteRows(writes, output) {
10479
+ const rows = writes?.[output];
10480
+ if (Array.isArray(rows)) return rows.filter(isScreenWrite);
10481
+ if (isScreenWrite(rows)) return [rows];
10482
+ return [];
10483
+ }
10484
+ function screenWriteTargets(variables, enumName = () => void 0) {
10485
+ return Object.values(variables).sort((a, b) => a.name.localeCompare(b.name)).map((variable) => ({
10486
+ variable,
10487
+ label: `${enumName(variable) ?? typeSigil({ type: variable.dataType }, variable.cardinality)} - ${variable.name}`
10488
+ }));
10489
+ }
10490
+ function findScreenVariable(variables, variableId) {
10491
+ return variables[variableId];
10492
+ }
10493
+ function screenWriteFixedAllowed(variable) {
10494
+ return variable.cardinality === "one";
10495
+ }
10496
+ function screenWriteToggleAllowed(variable) {
10497
+ return variable.cardinality === "one" && variable.dataType === "boolean";
10498
+ }
10499
+ function screenWriteEventAllowed(payload) {
10500
+ return payload !== "void";
10501
+ }
10502
+ function screenWriteInputTargets(inputs, variable) {
10503
+ return Object.values(inputs).filter(
10504
+ (input) => inputPrimitive(input) === variable.dataType && input.cardinality === variable.cardinality
10505
+ ).sort((a, b) => a.name.localeCompare(b.name));
10506
+ }
10507
+ function screenWriteConstTargets(constants, variable) {
10508
+ if (variable.cardinality !== "one") return [];
10509
+ return Object.values(constants).filter((constant) => constant.dataType === variable.dataType).sort((a, b) => a.name.localeCompare(b.name));
10510
+ }
10511
+ function screenWriteValueKinds(variable, payload, inputs, constants = {}) {
10512
+ const kinds = [];
10513
+ if (screenWriteFixedAllowed(variable)) kinds.push("fixed");
10514
+ if (screenWriteConstTargets(constants, variable).length) kinds.push("const");
10515
+ kinds.push("clear");
10516
+ if (screenWriteToggleAllowed(variable)) kinds.push("toggle");
10517
+ if (screenWriteEventAllowed(payload)) kinds.push("event");
10518
+ if (screenWriteInputTargets(inputs, variable).length) kinds.push("input");
10519
+ return kinds;
10520
+ }
10521
+ function defaultScreenWriteValue(variable, payload, inputs, constants = {}) {
10522
+ const [kind] = screenWriteValueKinds(variable, payload, inputs, constants);
10523
+ return buildScreenWriteValue(kind ?? "clear", variable, inputs, constants);
10524
+ }
10525
+ function buildScreenWriteValue(kind, variable, inputs, constants = {}) {
10526
+ if (kind === "fixed") return { kind: "fixed", value: "" };
10527
+ if (kind === "toggle") return { kind: "toggle" };
10528
+ if (kind === "event") return { kind: "event" };
10529
+ if (kind === "const") {
10530
+ const [only] = screenWriteConstTargets(constants, variable);
10531
+ return { kind: "const", constantId: only?.id ?? "" };
10532
+ }
10533
+ if (kind === "input") {
10534
+ const [only] = screenWriteInputTargets(inputs, variable);
10535
+ return { kind: "input", inputId: only?.id ?? "" };
10536
+ }
10537
+ return { kind: "clear" };
10538
+ }
10539
+ function nextScreenWriteRow(variables, rows, payload, inputs, constants = {}) {
10540
+ const taken = new Set(rows.map((row) => row.variableId));
10541
+ const free = screenWriteTargets(variables).find(
10542
+ (target) => !taken.has(target.variable.id)
10543
+ );
10544
+ if (!free) return void 0;
10545
+ return {
10546
+ variableId: free.variable.id,
10547
+ value: defaultScreenWriteValue(free.variable, payload, inputs, constants)
10548
+ };
10549
+ }
10550
+ function validateScreenWrites(variables, rows, payload, fieldNames, inputs, constants = {}) {
10551
+ const seen = /* @__PURE__ */ new Set();
10552
+ for (const row of rows) {
10553
+ if (seen.has(row.variableId)) return "screen-write-duplicate";
10554
+ seen.add(row.variableId);
10555
+ const variable = findScreenVariable(variables, row.variableId);
10556
+ if (!variable) return "screen-write-unknown-variable";
10557
+ const value = row.value;
10558
+ if (!screenWriteValueKinds(variable, payload, inputs, constants).includes(
10559
+ value.kind
10560
+ )) {
10561
+ return "screen-write-value-not-allowed";
10562
+ }
10563
+ if (value.kind === "fixed" && !String(value.value ?? "").trim()) {
10564
+ return "screen-write-incomplete";
10565
+ }
10566
+ if (value.kind === "const") {
10567
+ if (!value.constantId) return "screen-write-incomplete";
10568
+ if (!screenWriteConstTargets(constants, variable).some(
10569
+ (c) => c.id === value.constantId
10570
+ )) {
10571
+ return "screen-write-unknown-const";
10572
+ }
10573
+ }
10574
+ if (value.kind === "input") {
10575
+ if (!value.inputId) return "screen-write-incomplete";
10576
+ if (!screenWriteInputTargets(inputs, variable).some(
10577
+ (i) => i.id === value.inputId
10578
+ )) {
10579
+ return "screen-write-unknown-input";
10580
+ }
10581
+ }
10582
+ if (value.kind === "event" && value.path?.length && fieldNames.length && !value.path.every((name3) => fieldNames.includes(name3))) {
10583
+ return "screen-write-incomplete";
10584
+ }
10585
+ }
10586
+ return void 0;
10587
+ }
10588
+ var IDENTIFIER2 = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
10589
+ var memberAccess4 = (segment) => IDENTIFIER2.test(segment) ? `.${segment}` : `['${segment}']`;
10590
+ var valueExpression = (value, variable, payload, inputs, constants, eventRoot, self = "", eventMember) => {
10591
+ if (value.kind === "clear") return "undefined";
10592
+ if (value.kind === "toggle") return `!${self}${variable.name}()`;
10593
+ if (value.kind === "fixed") {
10594
+ return literalExpression(value.value, { type: variable.dataType });
10595
+ }
10596
+ if (value.kind === "const") {
10597
+ const constant = constants[value.constantId];
10598
+ return constant ? `${self}${constant.name}` : void 0;
10599
+ }
10600
+ if (value.kind === "input") {
10601
+ const input = inputs[value.inputId];
10602
+ return input ? `${self}${input.name}()` : void 0;
10603
+ }
10604
+ if (payload !== "record" || !value.path?.length) {
10605
+ return typeof eventRoot === "string" ? eventRoot : eventRoot(variable);
10606
+ }
10607
+ const read = `$event${value.path.map(memberAccess4).join("")}`;
10608
+ return eventMember ? eventMember(
10609
+ value.path,
10610
+ read,
10611
+ "$event",
10612
+ variable.cardinality,
10613
+ variable.dataType
10614
+ ) : read;
10615
+ };
10616
+ function screenWriteStatements(variables, rows, payload, fieldNames, inputs, constants = {}, eventRoot = "$event", scope = "template", eventMember, narrow) {
10617
+ if (!rows.length) return [];
10618
+ if (validateScreenWrites(
10619
+ variables,
10620
+ rows,
10621
+ payload,
10622
+ fieldNames,
10623
+ inputs,
10624
+ constants
10625
+ )) {
10626
+ return [];
10627
+ }
10628
+ const statements = [];
10629
+ for (const row of rows) {
10630
+ const variable = findScreenVariable(variables, row.variableId);
10631
+ if (!variable) return [];
10632
+ const self = scope === "class" ? "this." : "";
10633
+ const expr = valueExpression(
10634
+ row.value,
10635
+ variable,
10636
+ payload,
10637
+ inputs,
10638
+ constants,
10639
+ eventRoot,
10640
+ self,
10641
+ eventMember
10642
+ );
10643
+ if (expr === void 0) return [];
10644
+ const narrowed = narrow ? narrow(variable, row.value, expr) : expr;
10645
+ statements.push({
10646
+ name: variable.name,
10647
+ text: `${self}${variable.name}.set(${narrowed})`
10648
+ });
10649
+ }
10650
+ return statements.sort((a, b) => a.name.localeCompare(b.name)).map((statement) => statement.text);
10651
+ }
10652
+ function screenWriteInputIds(control) {
10653
+ return everyScreenWrite(control).map((row) => row.value.kind === "input" ? row.value.inputId : "").filter(Boolean);
10654
+ }
10655
+ function everyScreenWrite(control) {
10656
+ const from = (map) => Object.keys(map ?? {}).flatMap((key2) => screenWriteRows(map, key2));
10657
+ return [
10658
+ ...from(control.outputScreenWrites),
10659
+ ...from(control.screenOutputScreenWrites),
10660
+ ...armScreenWrites(control)
10661
+ ];
10662
+ }
10663
+ function armScreenWrites(control) {
10664
+ return [
10665
+ ...[
10666
+ ...Object.values(control.outputOutcomes ?? {}),
10667
+ ...Object.values(control.screenOutputOutcomes ?? {})
10668
+ ].flatMap((outcome) => [
10669
+ ...outcome.success?.screenWrites ?? [],
10670
+ ...outcome.denied?.screenWrites ?? [],
10671
+ ...outcome.failure?.screenWrites ?? []
10672
+ ]),
10673
+ // And the rows an OverlayAnswer runs on what the overlay handed back
10674
+ // (ADR 0131), which name a ScreenVariable the same way.
10675
+ ...Object.values(control.outputOpens ?? {}).flatMap(
10676
+ (open) => open.answer?.screenWrites ?? []
10677
+ )
10678
+ ];
10679
+ }
10680
+ function screenVariableActionEnumIds(controls, variableId) {
10681
+ return Object.values(controls).filter((control) => control.type === "section_action" /* SECTION_ACTION */).filter(
10682
+ (control) => everyScreenWrite(control).some(
10683
+ (row) => row.variableId === variableId && row.value.kind === "event"
10684
+ )
10685
+ ).map((control) => control.id);
10686
+ }
10687
+ var SECTION_TABLE_SORT_OUTPUT = "sortChange";
10688
+ var SECTION_TABLE_SORT_ID = "id";
10689
+ var SECTION_TABLE_SORT_DIRECTION = "direction";
10690
+ var SORT_DIRECTION_VALUES = ["asc", "desc"];
10691
+ var sortRowEnumId = (tableId, path) => {
10692
+ if (path?.length !== 1) return void 0;
10693
+ if (path[0] === SECTION_TABLE_SORT_ID) return tableId;
10694
+ return path[0] === SECTION_TABLE_SORT_DIRECTION ? SORT_DIRECTION_ENUM_ID : void 0;
10695
+ };
10696
+ function enumEventWrites(control) {
10697
+ if (control.type === "section_action" /* SECTION_ACTION */) {
10698
+ return everyScreenWrite(control).filter((row) => row.value.kind === "event").map((row) => ({ row, enumId: control.id }));
10699
+ }
10700
+ if (control.type !== "section_table" /* SECTION_TABLE */) return [];
10701
+ return Object.keys(control.outputScreenWrites ?? {}).filter((output) => baseOutputName(output) === SECTION_TABLE_SORT_OUTPUT).flatMap((output) => screenWriteRows(control.outputScreenWrites, output)).flatMap((row) => {
10702
+ const enumId = row.value.kind === "event" ? sortRowEnumId(control.id, row.value.path) : void 0;
10703
+ return enumId ? [{ row, enumId }] : [];
10704
+ });
10705
+ }
10706
+ function controlEnumValues(node) {
10707
+ if (node.type === "section_action" /* SECTION_ACTION */) return actionEnumValues(node);
10708
+ if (node.type !== "section_table" /* SECTION_TABLE */) return [];
10709
+ return sectionTableSortIds(
10710
+ toSectionTableColumns(node.configs?.[SECTION_TABLE_COLUMNS_KEY])
10711
+ );
10712
+ }
10713
+ function screenVariableEnumIds(controls, variableId) {
10714
+ return [
10715
+ ...new Set(
10716
+ Object.values(controls).flatMap(enumEventWrites).filter(({ row }) => row.variableId === variableId).map(({ enumId }) => enumId)
10717
+ )
10718
+ ];
10719
+ }
10720
+ function enumValuesOf(enumId, tree) {
10721
+ if (enumId === SORT_DIRECTION_ENUM_ID) return [...SORT_DIRECTION_VALUES];
10722
+ const find = (nodes) => {
10723
+ for (const node2 of nodes) {
10724
+ if (node2.id === enumId) return node2;
10725
+ const child = find(node2.childrens);
10726
+ if (child) return child;
10727
+ }
10728
+ return void 0;
10729
+ };
10730
+ const node = find(tree);
10731
+ return node ? controlEnumValues(node) : [];
10732
+ }
10733
+ function screenVariableEnumId(controls, variable) {
10734
+ if (variable.dataType !== "string" || variable.cardinality !== "one") {
10735
+ return void 0;
10736
+ }
10737
+ const ids = screenVariableEnumIds(controls, variable.id);
10738
+ return ids.length === 1 ? ids[0] : void 0;
10739
+ }
10740
+ function withVariableEnums(variables, controls) {
10741
+ let changed = false;
10742
+ const next = Object.fromEntries(
10743
+ Object.entries(variables).map(([id, variable]) => {
10744
+ const enumId = screenVariableEnumId(controls, variable);
10745
+ const action = !!enumId && controls[enumId]?.type === "section_action" /* SECTION_ACTION */;
10746
+ const actionEnumId = enumId && action ? enumId : void 0;
10747
+ const sortEnumId = enumId && !action ? enumId : void 0;
10748
+ if (variable.actionEnumId === actionEnumId && variable.sortEnumId === sortEnumId) {
10749
+ return [id, variable];
10750
+ }
10751
+ changed = true;
10752
+ const {
10753
+ actionEnumId: _action,
10754
+ sortEnumId: _sort,
10755
+ ...rest
10756
+ } = variable;
10757
+ return [
10758
+ id,
10759
+ {
10760
+ ...rest,
10761
+ ...actionEnumId ? { actionEnumId } : {},
10762
+ ...sortEnumId ? { sortEnumId } : {}
10763
+ }
10764
+ ];
10765
+ })
10766
+ );
10767
+ return changed ? next : variables;
10768
+ }
10769
+ function hasScreenVariableActionEnumConflict(controls) {
10770
+ const enumIdsByVariable = /* @__PURE__ */ new Map();
10771
+ for (const control of Object.values(controls)) {
10772
+ for (const { row, enumId } of enumEventWrites(control)) {
10773
+ const ids = enumIdsByVariable.get(row.variableId) ?? /* @__PURE__ */ new Set();
10774
+ ids.add(enumId);
10775
+ enumIdsByVariable.set(row.variableId, ids);
10776
+ if (ids.size > 1) return true;
10777
+ }
10778
+ }
10779
+ return false;
10780
+ }
10781
+ function countScreenWriteReferences(controls, variableId) {
10782
+ return Object.values(controls).reduce(
10783
+ (total, control) => total + everyScreenWrite(control).filter((row) => row.variableId === variableId).length,
10784
+ 0
10785
+ );
10786
+ }
10787
+
10788
+ // libs/codegen/src/lib/state-write-helper.ts
10789
+ var VALUE_KINDS2 = [
10790
+ "fixed",
10791
+ "const",
10792
+ "clear",
10793
+ "toggle",
10794
+ "event",
10795
+ "input"
10796
+ ];
10797
+ var isStateWrite = (value) => typeof value === "object" && value !== null && "propertyId" in value && typeof value.propertyId === "string" && "value" in value && typeof value.value === "object" && value.value !== null && VALUE_KINDS2.includes(value.value?.kind);
9978
10798
  function stateWriteRows(writes, output) {
9979
10799
  const rows = writes?.[output];
9980
10800
  if (Array.isArray(rows)) return rows.filter(isStateWrite);
9981
10801
  if (isStateWrite(rows)) return [rows];
9982
10802
  return [];
9983
10803
  }
9984
- function stateWriteTargets(properties) {
10804
+ function stateWriteTargets(properties, enumName = () => void 0) {
9985
10805
  return listDataProperties(properties).map((property) => ({
9986
10806
  property,
9987
- label: `${typeSigil(property.dataType, property.cardinality)} - ${property.name}`
10807
+ label: `${enumName(property) ?? typeSigil(property.dataType, property.cardinality)} - ${property.name}`
9988
10808
  }));
9989
10809
  }
9990
10810
  function findStateWriteProperty(properties, propertyId) {
@@ -10088,9 +10908,9 @@ function validateStateWrites(properties, rows, payload, fieldNames, inputs, cons
10088
10908
  }
10089
10909
  return void 0;
10090
10910
  }
10091
- var IDENTIFIER2 = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
10092
- var memberAccess4 = (segment) => IDENTIFIER2.test(segment) ? `.${segment}` : `['${segment}']`;
10093
- var valueExpression = (value, property, payload, storeProp, inputs, constants, eventRoot, self = "", eventMember) => {
10911
+ var IDENTIFIER3 = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
10912
+ var memberAccess5 = (segment) => IDENTIFIER3.test(segment) ? `.${segment}` : `['${segment}']`;
10913
+ var valueExpression2 = (value, property, payload, storeProp, inputs, constants, eventRoot, self = "", eventMember) => {
10094
10914
  if (value.kind === "clear") return "undefined";
10095
10915
  if (value.kind === "toggle") return `!${storeProp}.${property.name}()`;
10096
10916
  if (value.kind === "fixed") {
@@ -10104,8 +10924,10 @@ var valueExpression = (value, property, payload, storeProp, inputs, constants, e
10104
10924
  const input = inputs[value.inputId];
10105
10925
  return input ? `${self}${input.name}()` : void 0;
10106
10926
  }
10107
- if (payload !== "record" || !value.path?.length) return eventRoot;
10108
- const read = `$event${value.path.map(memberAccess4).join("")}`;
10927
+ if (payload !== "record" || !value.path?.length) {
10928
+ return typeof eventRoot === "string" ? eventRoot : eventRoot(property);
10929
+ }
10930
+ const read = `$event${value.path.map(memberAccess5).join("")}`;
10109
10931
  return eventMember ? eventMember(
10110
10932
  value.path,
10111
10933
  read,
@@ -10114,7 +10936,7 @@ var valueExpression = (value, property, payload, storeProp, inputs, constants, e
10114
10936
  property.dataType
10115
10937
  ) : read;
10116
10938
  };
10117
- function stateWritePatchExpression(properties, rows, payload, fieldNames, inputs, storeProp, constants = {}, eventRoot = "$event", scope = "template", eventMember) {
10939
+ function stateWritePatchExpression(properties, rows, payload, fieldNames, inputs, storeProp, constants = {}, eventRoot = "$event", scope = "template", eventMember, narrow) {
10118
10940
  if (!rows.length) return void 0;
10119
10941
  if (validateStateWrites(
10120
10942
  properties,
@@ -10130,7 +10952,7 @@ function stateWritePatchExpression(properties, rows, payload, fieldNames, inputs
10130
10952
  for (const row of rows) {
10131
10953
  const property = findStateWriteProperty(properties, row.propertyId);
10132
10954
  if (!property) return void 0;
10133
- const expr = valueExpression(
10955
+ const expr = valueExpression2(
10134
10956
  row.value,
10135
10957
  property,
10136
10958
  payload,
@@ -10142,7 +10964,11 @@ function stateWritePatchExpression(properties, rows, payload, fieldNames, inputs
10142
10964
  eventMember
10143
10965
  );
10144
10966
  if (expr === void 0) return void 0;
10145
- members.push({ name: property.name, text: `${property.name}: ${expr}` });
10967
+ const narrowed = narrow ? narrow(property, row.value, expr) : expr;
10968
+ members.push({
10969
+ name: property.name,
10970
+ text: `${property.name}: ${narrowed}`
10971
+ });
10146
10972
  }
10147
10973
  members.sort((a, b) => a.name.localeCompare(b.name));
10148
10974
  return `${storeProp}.patch({ ${members.map((m) => m.text).join(", ")} })`;
@@ -10182,242 +11008,45 @@ function countStateWriteReferences(controls, propertyId) {
10182
11008
  0
10183
11009
  );
10184
11010
  }
10185
-
10186
- // libs/codegen/src/lib/screen-write-helper.ts
10187
- var VALUE_KINDS2 = [
10188
- "fixed",
10189
- "const",
10190
- "clear",
10191
- "toggle",
10192
- "event",
10193
- "input"
10194
- ];
10195
- var isScreenWrite = (value) => typeof value === "object" && value !== null && "variableId" in value && typeof value.variableId === "string" && "value" in value && typeof value.value === "object" && value.value !== null && VALUE_KINDS2.includes(value.value?.kind);
10196
- function screenWriteRows(writes, output) {
10197
- const rows = writes?.[output];
10198
- if (Array.isArray(rows)) return rows.filter(isScreenWrite);
10199
- if (isScreenWrite(rows)) return [rows];
10200
- return [];
10201
- }
10202
- function screenWriteTargets(variables) {
10203
- return Object.values(variables).sort((a, b) => a.name.localeCompare(b.name)).map((variable) => ({
10204
- variable,
10205
- label: `${typeSigil({ type: variable.dataType }, variable.cardinality)} - ${variable.name}`
10206
- }));
10207
- }
10208
- function findScreenVariable(variables, variableId) {
10209
- return variables[variableId];
10210
- }
10211
- function screenWriteFixedAllowed(variable) {
10212
- return variable.cardinality === "one";
10213
- }
10214
- function screenWriteToggleAllowed(variable) {
10215
- return variable.cardinality === "one" && variable.dataType === "boolean";
10216
- }
10217
- function screenWriteEventAllowed(payload) {
10218
- return payload !== "void";
10219
- }
10220
- function screenWriteInputTargets(inputs, variable) {
10221
- return Object.values(inputs).filter(
10222
- (input) => inputPrimitive(input) === variable.dataType && input.cardinality === variable.cardinality
10223
- ).sort((a, b) => a.name.localeCompare(b.name));
10224
- }
10225
- function screenWriteConstTargets(constants, variable) {
10226
- if (variable.cardinality !== "one") return [];
10227
- return Object.values(constants).filter((constant) => constant.dataType === variable.dataType).sort((a, b) => a.name.localeCompare(b.name));
10228
- }
10229
- function screenWriteValueKinds(variable, payload, inputs, constants = {}) {
10230
- const kinds = [];
10231
- if (screenWriteFixedAllowed(variable)) kinds.push("fixed");
10232
- if (screenWriteConstTargets(constants, variable).length) kinds.push("const");
10233
- kinds.push("clear");
10234
- if (screenWriteToggleAllowed(variable)) kinds.push("toggle");
10235
- if (screenWriteEventAllowed(payload)) kinds.push("event");
10236
- if (screenWriteInputTargets(inputs, variable).length) kinds.push("input");
10237
- return kinds;
10238
- }
10239
- function defaultScreenWriteValue(variable, payload, inputs, constants = {}) {
10240
- const [kind] = screenWriteValueKinds(variable, payload, inputs, constants);
10241
- return buildScreenWriteValue(kind ?? "clear", variable, inputs, constants);
10242
- }
10243
- function buildScreenWriteValue(kind, variable, inputs, constants = {}) {
10244
- if (kind === "fixed") return { kind: "fixed", value: "" };
10245
- if (kind === "toggle") return { kind: "toggle" };
10246
- if (kind === "event") return { kind: "event" };
10247
- if (kind === "const") {
10248
- const [only] = screenWriteConstTargets(constants, variable);
10249
- return { kind: "const", constantId: only?.id ?? "" };
11011
+ function enumEventStateWrites(control) {
11012
+ if (control.type === "section_action" /* SECTION_ACTION */) {
11013
+ return everyStateWrite(control).filter((row) => row.value.kind === "event" && !row.value.path?.length).map((row) => ({ row, enumId: control.id }));
10250
11014
  }
10251
- if (kind === "input") {
10252
- const [only] = screenWriteInputTargets(inputs, variable);
10253
- return { kind: "input", inputId: only?.id ?? "" };
10254
- }
10255
- return { kind: "clear" };
11015
+ if (control.type !== "section_table" /* SECTION_TABLE */) return [];
11016
+ return Object.keys(control.outputWrites ?? {}).filter((output) => baseOutputName(output) === SECTION_TABLE_SORT_OUTPUT).flatMap((output) => stateWriteRows(control.outputWrites, output)).flatMap((row) => {
11017
+ const enumId = row.value.kind === "event" ? sortRowEnumId(control.id, row.value.path) : void 0;
11018
+ return enumId ? [{ row, enumId }] : [];
11019
+ });
10256
11020
  }
10257
- function nextScreenWriteRow(variables, rows, payload, inputs, constants = {}) {
10258
- const taken = new Set(rows.map((row) => row.variableId));
10259
- const free = screenWriteTargets(variables).find(
10260
- (target) => !taken.has(target.variable.id)
11021
+ function stampStatePropertyEnums(properties, controlMaps) {
11022
+ const sources = /* @__PURE__ */ new Map();
11023
+ controlMaps.forEach(
11024
+ (controls) => Object.values(controls).forEach(
11025
+ (control) => enumEventStateWrites(control).forEach(({ row, enumId }) => {
11026
+ const enums = sources.get(row.propertyId) ?? /* @__PURE__ */ new Map();
11027
+ enums.set(enumId, control);
11028
+ sources.set(row.propertyId, enums);
11029
+ })
11030
+ )
10261
11031
  );
10262
- if (!free) return void 0;
10263
- return {
10264
- variableId: free.variable.id,
10265
- value: defaultScreenWriteValue(free.variable, payload, inputs, constants)
10266
- };
10267
- }
10268
- function validateScreenWrites(variables, rows, payload, fieldNames, inputs, constants = {}) {
10269
- const seen = /* @__PURE__ */ new Set();
10270
- for (const row of rows) {
10271
- if (seen.has(row.variableId)) return "screen-write-duplicate";
10272
- seen.add(row.variableId);
10273
- const variable = findScreenVariable(variables, row.variableId);
10274
- if (!variable) return "screen-write-unknown-variable";
10275
- const value = row.value;
10276
- if (!screenWriteValueKinds(variable, payload, inputs, constants).includes(
10277
- value.kind
10278
- )) {
10279
- return "screen-write-value-not-allowed";
10280
- }
10281
- if (value.kind === "fixed" && !String(value.value ?? "").trim()) {
10282
- return "screen-write-incomplete";
10283
- }
10284
- if (value.kind === "const") {
10285
- if (!value.constantId) return "screen-write-incomplete";
10286
- if (!screenWriteConstTargets(constants, variable).some(
10287
- (c) => c.id === value.constantId
10288
- )) {
10289
- return "screen-write-unknown-const";
10290
- }
11032
+ let changed = false;
11033
+ const next = { ...properties };
11034
+ sources.forEach((enums, propertyId) => {
11035
+ const property = properties[propertyId];
11036
+ const [[enumId, control]] = [...enums];
11037
+ if (!property || enums.size !== 1 || property.dataType.type !== "string" || property.cardinality !== "one" || property.dataType.actionEnumId || property.dataType.sortEnumId) {
11038
+ return;
10291
11039
  }
10292
- if (value.kind === "input") {
10293
- if (!value.inputId) return "screen-write-incomplete";
10294
- if (!screenWriteInputTargets(inputs, variable).some(
10295
- (i) => i.id === value.inputId
10296
- )) {
10297
- return "screen-write-unknown-input";
11040
+ changed = true;
11041
+ next[propertyId] = {
11042
+ ...property,
11043
+ dataType: {
11044
+ ...property.dataType,
11045
+ ...control.type === "section_action" /* SECTION_ACTION */ ? { actionEnumId: enumId } : { sortEnumId: enumId }
10298
11046
  }
10299
- }
10300
- if (value.kind === "event" && value.path?.length && fieldNames.length && !value.path.every((name3) => fieldNames.includes(name3))) {
10301
- return "screen-write-incomplete";
10302
- }
10303
- }
10304
- return void 0;
10305
- }
10306
- var IDENTIFIER3 = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
10307
- var memberAccess5 = (segment) => IDENTIFIER3.test(segment) ? `.${segment}` : `['${segment}']`;
10308
- var valueExpression2 = (value, variable, payload, inputs, constants, eventRoot, self = "", eventMember) => {
10309
- if (value.kind === "clear") return "undefined";
10310
- if (value.kind === "toggle") return `!${self}${variable.name}()`;
10311
- if (value.kind === "fixed") {
10312
- return literalExpression(value.value, { type: variable.dataType });
10313
- }
10314
- if (value.kind === "const") {
10315
- const constant = constants[value.constantId];
10316
- return constant ? `${self}${constant.name}` : void 0;
10317
- }
10318
- if (value.kind === "input") {
10319
- const input = inputs[value.inputId];
10320
- return input ? `${self}${input.name}()` : void 0;
10321
- }
10322
- if (payload !== "record" || !value.path?.length) return eventRoot;
10323
- const read = `$event${value.path.map(memberAccess5).join("")}`;
10324
- return eventMember ? eventMember(
10325
- value.path,
10326
- read,
10327
- "$event",
10328
- variable.cardinality,
10329
- variable.dataType
10330
- ) : read;
10331
- };
10332
- function screenWriteStatements(variables, rows, payload, fieldNames, inputs, constants = {}, eventRoot = "$event", scope = "template", eventMember) {
10333
- if (!rows.length) return [];
10334
- if (validateScreenWrites(
10335
- variables,
10336
- rows,
10337
- payload,
10338
- fieldNames,
10339
- inputs,
10340
- constants
10341
- )) {
10342
- return [];
10343
- }
10344
- const statements = [];
10345
- for (const row of rows) {
10346
- const variable = findScreenVariable(variables, row.variableId);
10347
- if (!variable) return [];
10348
- const self = scope === "class" ? "this." : "";
10349
- const expr = valueExpression2(
10350
- row.value,
10351
- variable,
10352
- payload,
10353
- inputs,
10354
- constants,
10355
- eventRoot,
10356
- self,
10357
- eventMember
10358
- );
10359
- if (expr === void 0) return [];
10360
- statements.push({
10361
- name: variable.name,
10362
- text: `${self}${variable.name}.set(${expr})`
10363
- });
10364
- }
10365
- return statements.sort((a, b) => a.name.localeCompare(b.name)).map((statement) => statement.text);
10366
- }
10367
- function screenWriteInputIds(control) {
10368
- return everyScreenWrite(control).map((row) => row.value.kind === "input" ? row.value.inputId : "").filter(Boolean);
10369
- }
10370
- function everyScreenWrite(control) {
10371
- const from = (map) => Object.keys(map ?? {}).flatMap((key2) => screenWriteRows(map, key2));
10372
- return [
10373
- ...from(control.outputScreenWrites),
10374
- ...from(control.screenOutputScreenWrites),
10375
- ...armScreenWrites(control)
10376
- ];
10377
- }
10378
- function armScreenWrites(control) {
10379
- return [
10380
- ...[
10381
- ...Object.values(control.outputOutcomes ?? {}),
10382
- ...Object.values(control.screenOutputOutcomes ?? {})
10383
- ].flatMap((outcome) => [
10384
- ...outcome.success?.screenWrites ?? [],
10385
- ...outcome.denied?.screenWrites ?? [],
10386
- ...outcome.failure?.screenWrites ?? []
10387
- ]),
10388
- // And the rows an OverlayAnswer runs on what the overlay handed back
10389
- // (ADR 0131), which name a ScreenVariable the same way.
10390
- ...Object.values(control.outputOpens ?? {}).flatMap(
10391
- (open) => open.answer?.screenWrites ?? []
10392
- )
10393
- ];
10394
- }
10395
- function screenVariableActionEnumIds(controls, variableId) {
10396
- return Object.values(controls).filter((control) => control.type === "section_action" /* SECTION_ACTION */).filter(
10397
- (control) => everyScreenWrite(control).some(
10398
- (row) => row.variableId === variableId && row.value.kind === "event"
10399
- )
10400
- ).map((control) => control.id);
10401
- }
10402
- function hasScreenVariableActionEnumConflict(controls) {
10403
- const actionEnumIdsByVariable = /* @__PURE__ */ new Map();
10404
- for (const control of Object.values(controls)) {
10405
- if (control.type !== "section_action" /* SECTION_ACTION */) continue;
10406
- for (const row of everyScreenWrite(control)) {
10407
- if (row.value.kind !== "event") continue;
10408
- const ids = actionEnumIdsByVariable.get(row.variableId) ?? /* @__PURE__ */ new Set();
10409
- ids.add(control.id);
10410
- actionEnumIdsByVariable.set(row.variableId, ids);
10411
- if (ids.size > 1) return true;
10412
- }
10413
- }
10414
- return false;
10415
- }
10416
- function countScreenWriteReferences(controls, variableId) {
10417
- return Object.values(controls).reduce(
10418
- (total, control) => total + everyScreenWrite(control).filter((row) => row.variableId === variableId).length,
10419
- 0
10420
- );
11047
+ };
11048
+ });
11049
+ return changed ? next : properties;
10421
11050
  }
10422
11051
 
10423
11052
  // libs/codegen/src/lib/output-arm-helper.ts
@@ -12025,7 +12654,7 @@ var OUTPUT_PAYLOADS_BY_CONTROL = {
12025
12654
  ["section_pagination" /* SECTION_PAGINATION */]: { paginationChange: "record" },
12026
12655
  // libs/one SectionTableSort — the column's id and the direction.
12027
12656
  ["section_table" /* SECTION_TABLE */]: { sortChange: "record" },
12028
- ["section_table_row" /* SECTION_TABLE_ROW */]: { rowClick: "void" },
12657
+ ["section_table_row" /* SECTION_TABLE_ROW */]: { rowClick: "record" },
12029
12658
  // libs/one SectionChart: the preset id picked (or `custom` once the window
12030
12659
  // was dragged), and the window itself as `{from, to}` ISO text — what an
12031
12660
  // ApiOperation's date params take (GLOSSARY.md SectionChartWindow).
@@ -12044,6 +12673,8 @@ var OUTPUT_PAYLOADS_BY_CONTROL = {
12044
12673
  var FIELD_STRING_READER = "fieldString";
12045
12674
  var FIELD_NUMBER_READER = "fieldNumber";
12046
12675
  var FIELD_BOOLEAN_READER = "fieldBoolean";
12676
+ var ACTION_NAME_READER = "actionName";
12677
+ var ENUM_VALUE_READER = "enumValue";
12047
12678
  var OUTPUT_PAYLOAD_MEMBERS = {
12048
12679
  ["section_action" /* SECTION_ACTION */]: { clicked: { name: "S" } },
12049
12680
  ["context_menu" /* CONTEXT_MENU */]: {
@@ -12308,6 +12939,7 @@ function shadowedShapes(ops, shapes) {
12308
12939
  out.set(twin.id, {
12309
12940
  name: shapeInterfaceName(twin.name),
12310
12941
  shapeId: twin.id,
12942
+ specShapeId: spec.id,
12311
12943
  details
12312
12944
  });
12313
12945
  }
@@ -12531,8 +13163,9 @@ function importShapes(dataType, from, existing, mintId, overwriteExisting = fals
12531
13163
  (candidate) => sameOrigin(candidate.origin, source.origin)
12532
13164
  )?.id : void 0;
12533
13165
  const sameSchema = (candidate) => !source.origin || !candidate.origin || candidate.name === source.name;
13166
+ const sameLayout = (candidate) => !!candidate.positional === !!source.positional;
12534
13167
  const structural = Object.values(candidates).find(
12535
- (candidate) => sameSchema(candidate) && dataTypeFits(
13168
+ (candidate) => sameSchema(candidate) && sameLayout(candidate) && dataTypeFits(
12536
13169
  { dataType: { type: "shape", shapeId }, cardinality: "one" },
12537
13170
  from,
12538
13171
  {
@@ -12559,6 +13192,8 @@ function importShapes(dataType, from, existing, mintId, overwriteExisting = fals
12559
13192
  id: id2,
12560
13193
  name: source.name,
12561
13194
  keys: [],
13195
+ // A tuple stays a tuple: the spec's layout, not the held one (ADR 0196).
13196
+ ...source.positional ? { positional: true } : {},
12562
13197
  ...source.origin ? { origin: source.origin } : shapes[id2]?.origin ? { origin: shapes[id2].origin } : {}
12563
13198
  };
12564
13199
  shapes[id2] = shape;
@@ -12746,6 +13381,8 @@ var cacheMethodReads = (method) => method.cache?.propertyId ? [method.cache.prop
12746
13381
  // libs/codegen/src/lib/store-ownership.ts
12747
13382
  var MAIN_STORE_OWNER = { kind: "main" };
12748
13383
  var MAIN_STORE_VALUE = "main";
13384
+ var storeOwnerValue = (owner) => owner.kind === "main" ? MAIN_STORE_VALUE : owner.subStoreId;
13385
+ var storeOwnerOfValue = (value) => value && value !== MAIN_STORE_VALUE ? { kind: "sub", subStoreId: value } : MAIN_STORE_OWNER;
12749
13386
  var subStoresOf = (feature) => Object.values(feature.subStores ?? {});
12750
13387
  function storesOf(feature) {
12751
13388
  const main2 = {
@@ -13536,6 +14173,22 @@ var FORMAT_PIPE_CATALOG = [
13536
14173
  { name: "forceSign", dataType: BOOL2, default: false }
13537
14174
  ]
13538
14175
  },
14176
+ {
14177
+ // The one entry that pipes into `color` rather than `label`: it reads the
14178
+ // raw head value beside the label chain, so `amount | money` and
14179
+ // `amount | signColor` stand together on one tag (ADR 0200).
14180
+ name: "signColor",
14181
+ component: "SignColorPipe",
14182
+ importFrom: ONE_IMPORT_MODULE,
14183
+ inputType: NUM2,
14184
+ returnType: STR2,
14185
+ target: "color",
14186
+ params: [
14187
+ // Theme keys rather than hex, so a gain and a loss follow the theme.
14188
+ { name: "positive", dataType: STR2, default: "success" },
14189
+ { name: "negative", dataType: STR2, default: "error" }
14190
+ ]
14191
+ },
13539
14192
  {
13540
14193
  name: "timeAgo",
13541
14194
  component: "TimeAgoPipe",
@@ -13594,6 +14247,7 @@ var FORMAT_PIPE_LABEL = {
13594
14247
  money: "pipe-money",
13595
14248
  compactNumber: "pipe-compact-number",
13596
14249
  percentage: "pipe-percentage",
14250
+ signColor: "pipe-sign-color",
13597
14251
  timeAgo: "pipe-time-ago",
13598
14252
  date: "pipe-date"
13599
14253
  };
@@ -13601,6 +14255,7 @@ var FORMAT_PIPE_ICON = {
13601
14255
  money: "pipe_money",
13602
14256
  compactNumber: "pipe_compact_number",
13603
14257
  percentage: "pipe_percentage",
14258
+ signColor: "pipe_sign_color",
13604
14259
  timeAgo: "pipe_time_ago",
13605
14260
  date: "pipe_date"
13606
14261
  };
@@ -13608,6 +14263,7 @@ var FORMAT_PIPE_FORM = {
13608
14263
  money: "pipe_money_form",
13609
14264
  compactNumber: "pipe_compact_number_form",
13610
14265
  percentage: "pipe_percentage_form",
14266
+ signColor: "pipe_sign_color_form",
13611
14267
  timeAgo: void 0,
13612
14268
  date: "pipe_date_form"
13613
14269
  };
@@ -13658,23 +14314,39 @@ var acceptsFormatPipe = (control) => {
13658
14314
  if (!hasTextSource(control?.type)) return false;
13659
14315
  return textSourceOf(control) !== TEXT_SOURCE.translated;
13660
14316
  };
14317
+ var pipesInto = (pipe, target) => (formatPipeEntry(pipe.name)?.target ?? "label") === target;
14318
+ var labelChainOf = (chain) => chain.filter((pipe) => pipesInto(pipe, "label"));
14319
+ var colorPipeOf = (chain) => chain.find((pipe) => pipesInto(pipe, "color"));
13661
14320
  var sameDataType = (a, b) => !!a && !!b && a.type === b.type;
13662
14321
  var chainReturnType = (chain) => {
13663
- const last = chain.length ? chain[chain.length - 1] : void 0;
14322
+ const label = labelChainOf(chain);
14323
+ const last = label.length ? label[label.length - 1] : void 0;
13664
14324
  return formatPipeEntry(last?.name)?.returnType;
13665
14325
  };
13666
14326
  var canAppendFormatPipe = (control, name3, headType) => {
13667
14327
  if (!acceptsFormatPipe(control)) return false;
13668
14328
  const entry2 = formatPipeEntry(name3);
13669
14329
  if (!entry2) return false;
13670
- const flowing = chainReturnType(formatPipesOf(control));
13671
- if (!flowing) return !headType || sameDataType(headType, entry2.inputType);
14330
+ const chain = formatPipesOf(control);
14331
+ if (entry2.target === "color") {
14332
+ if (colorPipeOf(chain)) return false;
14333
+ const head = chainInputType(labelChainOf(chain)) ?? headType;
14334
+ return !head || sameDataType(head, entry2.inputType);
14335
+ }
14336
+ const flowing = chainReturnType(chain);
14337
+ if (!flowing) {
14338
+ const head = headType ?? chainInputType(chain);
14339
+ return !head || sameDataType(head, entry2.inputType);
14340
+ }
13672
14341
  return sameDataType(flowing, entry2.inputType);
13673
14342
  };
13674
14343
  var appendableFormatPipes = (control, headType) => FORMAT_PIPE_CATALOG.filter(
13675
14344
  (entry2) => canAppendFormatPipe(control, entry2.name, headType)
13676
14345
  );
13677
- var chainInputType = (chain) => formatPipeEntry(chain.length ? chain[0].name : void 0)?.inputType;
14346
+ var chainInputType = (chain) => {
14347
+ const head = labelChainOf(chain)[0] ?? colorPipeOf(chain);
14348
+ return formatPipeEntry(head?.name)?.inputType;
14349
+ };
13678
14350
  var staticLiteralType = (control) => chainInputType(formatPipesOf(control));
13679
14351
  var literalAtType = (type, raw) => {
13680
14352
  if (raw === void 0 || raw === null || raw === "") return void 0;
@@ -13733,24 +14405,36 @@ var entryArgs = (entry2, pipe, scope) => {
13733
14405
  }
13734
14406
  return sources.slice(0, last + 1);
13735
14407
  };
13736
- var formatPipeExpression = (chain, expr, scope) => chain.reduce((source, pipe) => {
14408
+ var pipeCall = (source, pipe, scope) => {
13737
14409
  const entry2 = formatPipeEntry(pipe.name);
13738
- if (!entry2) return source;
14410
+ if (!entry2) return void 0;
13739
14411
  const args = entryArgs(entry2, pipe, scope);
13740
- if (!args) return source;
14412
+ if (!args) return void 0;
13741
14413
  const suffix = args.length ? `:${args.join(":")}` : "";
13742
14414
  const call = `${source} | ${entry2.name}${suffix}`;
13743
14415
  return entry2.nullable ? `(${call}) ?? ''` : call;
13744
- }, expr);
14416
+ };
14417
+ var formatPipeExpression = (chain, expr, scope) => labelChainOf(chain).reduce(
14418
+ (source, pipe) => pipeCall(source, pipe, scope) ?? source,
14419
+ expr
14420
+ );
14421
+ var colorPipeExpression = (chain, expr, scope) => {
14422
+ const pipe = colorPipeOf(chain);
14423
+ return pipe ? pipeCall(expr, pipe, scope) : void 0;
14424
+ };
13745
14425
  var formatPipeCanvasSuffix = (control) => formatPipesOf(control).map((pipe) => formatPipeEntry(pipe.name)?.name).filter((name3) => !!name3).map((name3) => `|${name3}`).join("");
13746
14426
  var formatPipeImports = (chain) => chain.map((pipe) => formatPipeEntry(pipe.name)).filter((entry2) => !!entry2).map(({ component, importFrom }) => ({ component, importFrom }));
13747
14427
  var staticLabelSource = (chain, raw) => {
14428
+ if (!labelChainOf(chain).length) return void 0;
14429
+ return staticHeadSource(chain, raw);
14430
+ };
14431
+ var staticHeadSource = (chain, raw) => {
13748
14432
  if (!chain.length) return void 0;
13749
14433
  const value = literalAtType(chainInputType(chain), raw);
13750
14434
  return value === void 0 ? void 0 : literalSource2(value);
13751
14435
  };
13752
14436
  var labelEmission = (chain, headType) => {
13753
- if (!chain.length) return "raw";
14437
+ if (!labelChainOf(chain).length) return "raw";
13754
14438
  if (!headType || sameDataType(headType, chainInputType(chain)))
13755
14439
  return "piped";
13756
14440
  return headType.type === "string" ? "raw" : "none";
@@ -14225,6 +14909,13 @@ var createCondition = () => ({
14225
14909
  check: { source: "store", operator: "not_exists" }
14226
14910
  });
14227
14911
  var conditionKind = (condition) => condition.kind ?? "function";
14912
+ function conditionFunction(condition, functions) {
14913
+ if (condition.oneFunction) {
14914
+ const entry2 = oneFunctionOf(condition.oneFunction);
14915
+ return entry2?.reach.includes("call-condition") ? oneFunctionSignature(entry2, { dataType: { type: "string" } }) : void 0;
14916
+ }
14917
+ return functions[condition.functionId];
14918
+ }
14228
14919
  var answersBoolean = (fn) => fn.returnType.type === "boolean" && fn.returnCardinality === "one";
14229
14920
  function conditionCheckType(check, args, properties, shapes) {
14230
14921
  const read = check.source === "args" ? check.arg ? argValue2({ source: "args", arg: check.arg }, args, properties, shapes) : void 0 : check.path?.length ? argValue2(
@@ -14252,6 +14943,26 @@ function conditionError(condition, args, functions, properties, shapes) {
14252
14943
  if (conditionKind(condition) === "check") {
14253
14944
  return checkError2(condition.check, args, properties, shapes);
14254
14945
  }
14946
+ const entry2 = condition.oneFunction ? oneFunctionOf(condition.oneFunction) : void 0;
14947
+ if (condition.oneFunction) {
14948
+ if (!entry2?.reach.includes("call-condition"))
14949
+ return "condition-no-function";
14950
+ for (const param of entry2.params) {
14951
+ const binding = condition.args[param.id];
14952
+ if (!binding) return "condition-args";
14953
+ if (binding.source === "fixed") {
14954
+ if (param.rule !== "string-one" || typeof binding.value !== "string")
14955
+ return "condition-type";
14956
+ continue;
14957
+ }
14958
+ const read = argValue2(binding, args, properties, shapes);
14959
+ if (!read) return "condition-args";
14960
+ const held = read.value.dataType ? { dataType: read.value.dataType, cardinality: read.value.cardinality } : void 0;
14961
+ if (!oneFunctionArgFits(param, held, binding.source === "store"))
14962
+ return "condition-type";
14963
+ }
14964
+ return void 0;
14965
+ }
14255
14966
  const fn = functions[condition.functionId];
14256
14967
  if (!fn) return "condition-no-function";
14257
14968
  if (!answersBoolean(fn)) return "condition-not-boolean";
@@ -15810,6 +16521,7 @@ function generateStoreMethods(methods, operationOf, properties, shapes, function
15810
16521
  const calls = [];
15811
16522
  const errorTypeAliases = [];
15812
16523
  const argShapes = /* @__PURE__ */ new Set();
16524
+ const oneFunctionNames = /* @__PURE__ */ new Set();
15813
16525
  for (const method of list) {
15814
16526
  if (isCacheMethod(method)) continue;
15815
16527
  const op = operationOf(method);
@@ -16127,7 +16839,8 @@ ${failureArms.map(
16127
16839
  true
16128
16840
  );
16129
16841
  }
16130
- const fn = functions[condition.functionId];
16842
+ const fn = conditionFunction(condition, functions);
16843
+ if (condition.oneFunction && fn) oneFunctionNames.add(fn.name);
16131
16844
  const waits = [];
16132
16845
  const callArgs2 = (fn?.params ?? []).map((param) => {
16133
16846
  const binding = condition.args[param.id];
@@ -16157,9 +16870,10 @@ ${failureArms.map(
16157
16870
  waits.push(`${read} !== undefined`);
16158
16871
  return statePathExpression(binding.path, roots, shapes, true, receiverOf);
16159
16872
  });
16873
+ const negate = condition.oneFunction && condition.negate ? "!" : "";
16160
16874
  return [
16161
16875
  ...Array.from(new Set(waits)),
16162
- `${fn?.name}(${callArgs2.join(", ")})`
16876
+ `${negate}${fn?.name}(${callArgs2.join(", ")})`
16163
16877
  ].join(" && ");
16164
16878
  });
16165
16879
  const conditionBlock = conditions.length ? `
@@ -16435,7 +17149,8 @@ ${beforePersists.map((line) => ` ${line}`).join("\n")}
16435
17149
  // A CallCompute's and a CallCondition's PureFunction are spelled in
16436
17150
  // the store's own pipe, so they are imported the same way.
16437
17151
  ...(method.computes ?? []).map((compute) => compute.functionId).filter((id) => !!id && !!functions[id]),
16438
- ...(method.conditions ?? []).filter((condition) => conditionKind(condition) === "function").map((condition) => condition.functionId).filter((id) => !!id && !!functions[id]),
17152
+ // A OneFunction is the library's, imported by `oneFunctions`.
17153
+ ...(method.conditions ?? []).filter((condition) => conditionKind(condition) === "function").filter((condition) => !condition.oneFunction).map((condition) => condition.functionId).filter((id) => !!id && !!functions[id]),
16439
17154
  ...templateTransformRefs(
16440
17155
  method.inputs.map((mapping) => mapping.transform),
16441
17156
  functions
@@ -16444,7 +17159,8 @@ ${beforePersists.map((line) => ` ${line}`).join("\n")}
16444
17159
  )
16445
17160
  ).sort();
16446
17161
  return functionIds.length ? { functionIds } : {};
16447
- })()
17162
+ })(),
17163
+ ...oneFunctionNames.size ? { oneFunctions: [...oneFunctionNames].sort() } : {}
16448
17164
  };
16449
17165
  }
16450
17166
  function generateCacheMethods(methods, operationOf, properties, shapes, roots = properties, receiverOf = OWN_STORE, callable = methods) {
@@ -17125,18 +17841,190 @@ function pruneOutputLinkArgs(control, drop) {
17125
17841
  return dropped;
17126
17842
  }
17127
17843
 
17844
+ // libs/codegen/src/lib/tree-helper.ts
17845
+ function buildTree(controlMap, rootControlIds, selection) {
17846
+ const state = (id) => selection ? variantRenderState(id, controlMap, selection) : "solid";
17847
+ const resolveDirectives = (ctrl) => {
17848
+ if (!ctrl.directives) return void 0;
17849
+ const resolved = {};
17850
+ for (const [name3, directive] of Object.entries(ctrl.directives)) {
17851
+ if (directive.overlayId) {
17852
+ const overlay = controlMap[directive.overlayId];
17853
+ if (overlay) {
17854
+ resolved[name3] = {
17855
+ overlayId: directive.overlayId,
17856
+ type: overlay.type,
17857
+ configs: overlay.configs
17858
+ };
17859
+ }
17860
+ } else {
17861
+ resolved[name3] = { configs: directive.configs ?? {} };
17862
+ }
17863
+ }
17864
+ return Object.keys(resolved).length > 0 ? resolved : void 0;
17865
+ };
17866
+ const toNode = (ctrl) => {
17867
+ const childrens = getChildren(ctrl.id);
17868
+ const fullyFaded = state(ctrl.id) === "faded" && childrens.every((child) => child.faded);
17869
+ return {
17870
+ type: ctrl.type,
17871
+ id: ctrl.id,
17872
+ configs: ctrl.configs,
17873
+ childrens,
17874
+ directives: resolveDirectives(ctrl),
17875
+ ...ctrl.source ? { source: ctrl.source } : {},
17876
+ ...ctrl.variants?.length ? { variants: ctrl.variants } : {},
17877
+ // Carried through so renderBranch can order the `@else` last and spell it
17878
+ // without reaching back into ControlMap mid-walk (GLOSSARY.md DefaultArm).
17879
+ ...ctrl.armKind ? { armKind: ctrl.armKind } : {},
17880
+ ...ctrl.variantKind ? { variantKind: ctrl.variantKind } : {},
17881
+ ...ctrl.outputs && Object.keys(ctrl.outputs).length ? { outputs: ctrl.outputs } : {},
17882
+ ...ctrl.outputArgs && Object.keys(ctrl.outputArgs).length ? { outputArgs: ctrl.outputArgs } : {},
17883
+ ...ctrl.outputWrites && Object.keys(ctrl.outputWrites).length ? { outputWrites: ctrl.outputWrites } : {},
17884
+ ...ctrl.outputEmits && Object.keys(ctrl.outputEmits).length ? { outputEmits: ctrl.outputEmits } : {},
17885
+ ...ctrl.outputScreenWrites && Object.keys(ctrl.outputScreenWrites).length ? { outputScreenWrites: ctrl.outputScreenWrites } : {},
17886
+ ...ctrl.outputOpens && Object.keys(ctrl.outputOpens).length ? { outputOpens: ctrl.outputOpens } : {},
17887
+ ...ctrl.outputNavs && Object.keys(ctrl.outputNavs).length ? { outputNavs: ctrl.outputNavs } : {},
17888
+ ...ctrl.outputNewTabs && Object.keys(ctrl.outputNewTabs).length ? { outputNewTabs: ctrl.outputNewTabs } : {},
17889
+ ...ctrl.outputOutcomes && Object.keys(ctrl.outputOutcomes).length ? { outputOutcomes: ctrl.outputOutcomes } : {},
17890
+ // Without this the codegen walk reads `outputArms` off a Tree that never
17891
+ // carried it, every gated output falls back to ungated, and its groups —
17892
+ // filed under `<output>|arm:<armId>` — are skipped as qualified keys. The
17893
+ // output emits nothing at all (GLOSSARY.md OutputArm).
17894
+ ...ctrl.outputArms && Object.keys(ctrl.outputArms).length ? { outputArms: ctrl.outputArms } : {},
17895
+ // Without this every group fires its first call alone: the rest are
17896
+ // filed under `<group>|call:<callId>` and read in the order this holds
17897
+ // (GLOSSARY.md OutputCall).
17898
+ ...ctrl.outputCalls && Object.keys(ctrl.outputCalls).length ? { outputCalls: ctrl.outputCalls } : {},
17899
+ ...ctrl.outputScreenMethods && Object.keys(ctrl.outputScreenMethods).length ? { outputScreenMethods: ctrl.outputScreenMethods } : {},
17900
+ ...ctrl.menuActions?.length ? { menuActions: ctrl.menuActions } : {},
17901
+ ...ctrl.screenId ? { screenId: ctrl.screenId } : {},
17902
+ // The other answer to what a ScreenControl mounts (ADR 0088). Carried
17903
+ // for `screenId`'s reason: the Canvas labels its placeholder from it and
17904
+ // codegen emits its tag.
17905
+ ...ctrl.handRef ? { handRef: ctrl.handRef } : {},
17906
+ ...ctrl.screenInputs && Object.keys(ctrl.screenInputs).length ? { screenInputs: ctrl.screenInputs } : {},
17907
+ // Carried for `screenId`'s reason: the Canvas draws the embed's box at
17908
+ // it and codegen emits it on the tag.
17909
+ ...ctrl.maxWidth ? { maxWidth: ctrl.maxWidth } : {},
17910
+ ...ctrl.screenOutputs && Object.keys(ctrl.screenOutputs).length ? { screenOutputs: ctrl.screenOutputs } : {},
17911
+ ...ctrl.screenOutputCalls && Object.keys(ctrl.screenOutputCalls).length ? { screenOutputCalls: ctrl.screenOutputCalls } : {},
17912
+ ...ctrl.screenOutputWrites && Object.keys(ctrl.screenOutputWrites).length ? { screenOutputWrites: ctrl.screenOutputWrites } : {},
17913
+ ...ctrl.screenOutputEmits && Object.keys(ctrl.screenOutputEmits).length ? { screenOutputEmits: ctrl.screenOutputEmits } : {},
17914
+ ...ctrl.screenOutputScreenWrites && Object.keys(ctrl.screenOutputScreenWrites).length ? { screenOutputScreenWrites: ctrl.screenOutputScreenWrites } : {},
17915
+ ...ctrl.checks?.length ? { checks: ctrl.checks } : {},
17916
+ ...ctrl.formatPipes?.length ? { formatPipes: ctrl.formatPipes } : {},
17917
+ ...ctrl.cards ? { cards: ctrl.cards } : {},
17918
+ ...ctrl.search ? { search: ctrl.search } : {},
17919
+ // A Repeat's row count, carried for `cards`' reason: the Canvas draws
17920
+ // its sample rows from the Tree alone. Nothing else reads it — codegen
17921
+ // never emits a count (GLOSSARY.md SampleValue).
17922
+ ...ctrl.repeat?.sampleRows !== void 0 ? { sampleRows: ctrl.repeat.sampleRows } : {},
17923
+ ...fullyFaded ? { faded: true } : {}
17924
+ };
17925
+ };
17926
+ const getChildren = (parentId) => {
17927
+ const parent = controlMap[parentId];
17928
+ if (!parent || !parent.childrens) return [];
17929
+ return parent.childrens.map((childId) => controlMap[childId]).filter(Boolean).filter((ctrl) => state(ctrl.id) !== "hidden").map(toNode);
17930
+ };
17931
+ const tree = rootControlIds.map((id) => controlMap[id]).filter(Boolean).filter((ctrl) => state(ctrl.id) !== "hidden").map(toNode);
17932
+ return selection ? markFadedRoots(tree) : tree;
17933
+ }
17934
+ function markFadedRoots(nodes, underFaded = false) {
17935
+ return nodes.map((node) => {
17936
+ const faded = !underFaded && node.faded;
17937
+ const next = {
17938
+ ...node,
17939
+ childrens: markFadedRoots(node.childrens, underFaded || !!node.faded)
17940
+ };
17941
+ if (faded) {
17942
+ next.faded = true;
17943
+ } else {
17944
+ delete next.faded;
17945
+ }
17946
+ return next;
17947
+ });
17948
+ }
17949
+
17950
+ // libs/codegen/src/lib/enum-label-helper.ts
17951
+ function enumLabels(controlMap, rootControlIds, properties = {}) {
17952
+ const names = new Map(
17953
+ controlEnums([
17954
+ { tree: buildTree(controlMap, rootControlIds), controlMap }
17955
+ ]).map((entry2) => [entry2.id, entry2.name])
17956
+ );
17957
+ const stamped = stampStatePropertyEnums(properties, [controlMap]);
17958
+ const control = (controlId) => names.get(controlId);
17959
+ return {
17960
+ control,
17961
+ variable: (variable) => {
17962
+ const id = screenVariableEnumId(controlMap, variable);
17963
+ return id ? control(id) : void 0;
17964
+ },
17965
+ property: (property) => {
17966
+ const dataType = (stamped[property.id] ?? property).dataType;
17967
+ const id = dataType.actionEnumId ?? dataType.sortEnumId;
17968
+ return id ? control(id) : void 0;
17969
+ }
17970
+ };
17971
+ }
17972
+ function enumMemberLabel(key2) {
17973
+ if (!key2) return "";
17974
+ return key2.split("_").map(
17975
+ (word, i) => i === 0 ? word.charAt(0).toUpperCase() + word.slice(1).toLowerCase() : word.toLowerCase()
17976
+ ).join(" ");
17977
+ }
17978
+ function enumNameOf(seed) {
17979
+ return seed.replace(/^[^A-Za-z]+/, "").replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
17980
+ }
17981
+ function enumFileBase(name3) {
17982
+ return name3.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
17983
+ }
17984
+ function emitEnumFile(appEnum) {
17985
+ const asString2 = appEnum.hasValue && appEnum.valueType === "string";
17986
+ const members = appEnum.members.map((m, index) => {
17987
+ if (asString2) {
17988
+ const text2 = typeof m.value === "string" ? m.value : m.key;
17989
+ const quoted = `'${text2.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
17990
+ return ` ${m.key} = ${quoted},`;
17991
+ }
17992
+ const own = appEnum.hasValue && typeof m.value === "number";
17993
+ return ` ${m.key} = ${own ? m.value : index},`;
17994
+ }).join("\n");
17995
+ const fileName = `shared/type/${appEnum.fileName}.ts`;
17996
+ return {
17997
+ path: `src/app/${fileName}`,
17998
+ fileName,
17999
+ contents: `export enum ${appEnum.name} {
18000
+ ${members}
18001
+ }
18002
+ `
18003
+ };
18004
+ }
18005
+
17128
18006
  // libs/codegen/src/lib/screen-input-source-helper.ts
17129
18007
  var SCREEN_SOURCE_SEP = "::";
17130
18008
  var encode = (kind, id) => `${kind}${SCREEN_SOURCE_SEP}${id}`;
18009
+ var cardinalityFits = (source, target) => source === target || target === "many" && source === "one";
17131
18010
  function screenInputSourceOptions(scope, want) {
17132
18011
  const { dataType, cardinality, required } = want;
17133
18012
  const byName = (rows) => [...rows].sort((a, b) => a.name.localeCompare(b.name));
18013
+ if (want.declared?.type === "enum") {
18014
+ return enumSourceOptions(
18015
+ scope,
18016
+ want.declared.enumId,
18017
+ cardinality,
18018
+ !!required,
18019
+ byName
18020
+ );
18021
+ }
17134
18022
  const members = dataType ? screenMemberOptions(scope, dataType, cardinality, !!required, byName) : [];
17135
18023
  return [...members, ...dataOptions(scope, want)];
17136
18024
  }
17137
18025
  function screenMemberOptions(scope, dataType, cardinality, required, byName) {
17138
18026
  const inputs = byName(Object.values(scope.inputs ?? {})).filter(
17139
- (input) => inputPrimitive(input) === dataType && input.cardinality === cardinality
18027
+ (input) => inputPrimitive(input) === dataType && cardinalityFits(input.cardinality, cardinality)
17140
18028
  ).map((input) => ({
17141
18029
  value: encode("input", input.id),
17142
18030
  label: input.name,
@@ -17144,7 +18032,7 @@ function screenMemberOptions(scope, dataType, cardinality, required, byName) {
17144
18032
  ...required && !input.required ? { optional: true } : {}
17145
18033
  }));
17146
18034
  const variables = byName(Object.values(scope.variables ?? {})).filter(
17147
- (variable) => variable.dataType === dataType && variable.cardinality === cardinality
18035
+ (variable) => variable.dataType === dataType && cardinalityFits(variable.cardinality, cardinality)
17148
18036
  ).map((variable) => ({
17149
18037
  value: encode("variable", variable.id),
17150
18038
  label: variable.name,
@@ -17155,17 +18043,17 @@ function screenMemberOptions(scope, dataType, cardinality, required, byName) {
17155
18043
  // Always `signal<T | undefined>`, whatever it is seeded with.
17156
18044
  ...required ? { optional: true } : {}
17157
18045
  }));
17158
- const constants = cardinality === "one" ? byName(Object.values(scope.constants ?? {})).filter((constant) => constant.dataType === dataType).map((constant) => ({
18046
+ const constants = byName(Object.values(scope.constants ?? {})).filter((constant) => constant.dataType === dataType).map((constant) => ({
17159
18047
  value: encode("constant", constant.id),
17160
18048
  label: constant.name,
17161
18049
  binding: {
17162
18050
  kind: "constant",
17163
18051
  constantId: constant.id
17164
18052
  }
17165
- })) : [];
18053
+ }));
17166
18054
  const computeds = byName(Object.values(scope.computeds ?? {})).filter((computed) => {
17167
18055
  const fn = screenComputedFunction(computed, scope.functions ?? {});
17168
- return !!fn && fn.returnType.type === dataType && fn.returnCardinality === cardinality;
18056
+ return !!fn && fn.returnType.type === dataType && cardinalityFits(returnCardinalityOf(fn), cardinality);
17169
18057
  }).map((computed) => ({
17170
18058
  value: encode("computed", computed.id),
17171
18059
  label: computed.name,
@@ -17183,6 +18071,30 @@ function screenMemberOptions(scope, dataType, cardinality, required, byName) {
17183
18071
  }));
17184
18072
  return [...inputs, ...variables, ...constants, ...computeds];
17185
18073
  }
18074
+ function enumSourceOptions(scope, enumId, cardinality, required, byName) {
18075
+ const inputs = byName(Object.values(scope.inputs ?? {})).filter(
18076
+ (input) => input.dataType.type === "enum" && input.dataType.enumId === enumId && cardinalityFits(input.cardinality, cardinality)
18077
+ ).map((input) => ({
18078
+ value: encode("input", input.id),
18079
+ label: input.name,
18080
+ binding: { kind: "input", inputId: input.id },
18081
+ ...required && !input.required ? { optional: true } : {}
18082
+ }));
18083
+ const appEnum = scope.enums?.[enumId];
18084
+ const members = appEnum ? [...appEnum.members].sort((a, b) => a.key.localeCompare(b.key)).map((member) => ({
18085
+ value: encode(
18086
+ "enum-member",
18087
+ `${enumId}${SCREEN_SOURCE_SEP}${member.id}`
18088
+ ),
18089
+ label: enumMemberLabel(member.key),
18090
+ binding: {
18091
+ kind: "enum-member",
18092
+ enumId,
18093
+ memberId: member.id
18094
+ }
18095
+ })) : [];
18096
+ return [...inputs, ...members];
18097
+ }
17186
18098
  var sameType6 = (candidate, declared) => {
17187
18099
  if (candidate?.type !== declared.type) return false;
17188
18100
  return declared.type === "shape" ? candidate.type === "shape" && candidate.shapeId === declared.shapeId : true;
@@ -17195,7 +18107,7 @@ function dataOptions(scope, want) {
17195
18107
  const listedAsMember = !!want.dataType;
17196
18108
  return bindingOptions(
17197
18109
  data,
17198
- (candidate, rowCardinality) => rowCardinality === cardinality && sameType6(candidate, declared)
18110
+ (candidate, rowCardinality) => cardinalityFits(rowCardinality, cardinality) && sameType6(candidate, declared)
17199
18111
  ).filter(
17200
18112
  ({ binding }) => !(listedAsMember && binding.path.length === 0 && memberRoots.has(binding.root.kind))
17201
18113
  ).map(({ value, label, binding }) => ({
@@ -17215,6 +18127,11 @@ function screenInputSourceValue(binding) {
17215
18127
  return encode("constant", binding.constantId);
17216
18128
  case "computed":
17217
18129
  return encode("computed", binding.computedId);
18130
+ case "enum-member":
18131
+ return encode(
18132
+ "enum-member",
18133
+ `${binding.enumId}${SCREEN_SOURCE_SEP}${binding.memberId}`
18134
+ );
17218
18135
  case "data":
17219
18136
  return encode("data", encodeBinding(binding.binding));
17220
18137
  default:
@@ -17362,10 +18279,13 @@ function validateOutputOpen(open, screens, payload, hostInputs, constants = {},
17362
18279
  }
17363
18280
  var IDENTIFIER5 = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
17364
18281
  var memberAccess6 = (segment) => IDENTIFIER5.test(segment) ? `.${segment}` : `['${segment}']`;
17365
- function valueExpression3(value, input, payload, hostInputs, constants, eventRoot, self, eventMember, renderMember = () => void 0, renderBinding = () => void 0) {
18282
+ function valueExpression3(value, input, payload, hostInputs, constants, eventRoot, self, eventMember, renderMember = () => void 0, renderBinding = () => void 0, readSource) {
17366
18283
  if (value.kind === "clear") return "undefined";
17367
- if (value.kind === "screen")
17368
- return value.binding.kind === "data" ? renderBinding(value.binding.binding) : renderMember(value.binding);
18284
+ if (value.kind === "screen") {
18285
+ const read2 = value.binding.kind === "data" ? renderBinding(value.binding.binding) : renderMember(value.binding);
18286
+ const source = readSource?.(value.binding);
18287
+ return read2 !== void 0 && source && liftsToList(input, source) ? liftToList(read2, source.present) : read2;
18288
+ }
17369
18289
  if (value.kind === "fixed")
17370
18290
  return literalExpression(value.value, input.dataType);
17371
18291
  if (value.kind === "const") {
@@ -17383,7 +18303,7 @@ function valueExpression3(value, input, payload, hostInputs, constants, eventRoo
17383
18303
  return eventMember ? eventMember(value.path, read, "$event", input.cardinality, input.dataType) : read;
17384
18304
  }
17385
18305
  var outputOpenReadsEvent = (open) => !!open && outputOpenInputs(open).some((row) => row.value.kind === "event");
17386
- function outputOpenInputEntries(open, declared, payload, hostInputs, constants, eventRoot, self, eventMember, renderMember, renderBinding) {
18306
+ function outputOpenInputEntries(open, declared, payload, hostInputs, constants, eventRoot, self, eventMember, renderMember, renderBinding, readSource) {
17387
18307
  const byId = new Map(declared.map((input) => [input.id, input]));
17388
18308
  const entries = [];
17389
18309
  for (const row of outputOpenInputs(open)) {
@@ -17399,7 +18319,8 @@ function outputOpenInputEntries(open, declared, payload, hostInputs, constants,
17399
18319
  self,
17400
18320
  eventMember,
17401
18321
  renderMember,
17402
- renderBinding
18322
+ renderBinding,
18323
+ readSource
17403
18324
  );
17404
18325
  if (expr === void 0) return void 0;
17405
18326
  entries.push(`${input.name}: ${expr}`);
@@ -18540,144 +19461,6 @@ var acceptedRemoteLink = (typed) => {
18540
19461
  return link === "" || LINK_SLUG.test(link) ? link : void 0;
18541
19462
  };
18542
19463
 
18543
- // libs/codegen/src/lib/section-table-helper.ts
18544
- var SECTION_TABLE_COLUMNS_KEY = "columns";
18545
- var SECTION_TABLE_SEED_COLUMNS = 3;
18546
- var ALIGNS = ["left", "center", "right"];
18547
- var DATA_TYPES = ["text", "number", "date"];
18548
- var seedColumn = (index) => ({
18549
- label: `column-${index + 1}`
18550
- });
18551
- var seedColumns = (count = SECTION_TABLE_SEED_COLUMNS) => Array.from({ length: count }, (_, i) => seedColumn(i));
18552
- var text = (value) => {
18553
- const trimmed = typeof value === "string" ? value.trim() : "";
18554
- return trimmed || void 0;
18555
- };
18556
- function toSectionTableColumns(value) {
18557
- if (!Array.isArray(value)) return [];
18558
- return value.filter((raw) => !!raw && typeof raw === "object").map((raw) => {
18559
- const column = {};
18560
- const id = text(raw["id"]);
18561
- if (id) column.id = id;
18562
- const label = text(raw["label"]);
18563
- if (label) column.label = label;
18564
- if (ALIGNS.includes(raw["align"])) {
18565
- column.align = raw["align"];
18566
- }
18567
- const span = Number(raw["span"]);
18568
- if (raw["span"] != null && raw["span"] !== "" && Number.isFinite(span)) {
18569
- column.span = Math.min(12, Math.max(1, Math.round(span)));
18570
- }
18571
- if (raw["sortable"] === true) column.sortable = true;
18572
- if (DATA_TYPES.includes(raw["dataType"])) {
18573
- column.dataType = raw["dataType"];
18574
- }
18575
- if (raw["defaultSort"] === true) column.defaultSort = true;
18576
- if (raw["ascending"] === true) column.ascending = true;
18577
- if (raw["freeze"] === true) column.freeze = true;
18578
- if (raw["squeeze"] === true) column.squeeze = true;
18579
- return column;
18580
- });
18581
- }
18582
- var columnNeedsId = (column) => (!!column.sortable || !!column.defaultSort) && !column.id;
18583
- var putSectionTableColumn = (columns, index, column) => {
18584
- const next = index >= columns.length ? [...columns, column] : columns.map((current, i) => i === index ? column : current);
18585
- if (!column.defaultSort) return next;
18586
- return next.map((current, i) => {
18587
- if (i === index || !current.defaultSort) return current;
18588
- const { defaultSort: _defaultSort, ascending: _ascending, ...rest } = current;
18589
- return rest;
18590
- });
18591
- };
18592
- var enclosingSectionTable = (control, controlMap) => {
18593
- const seen = /* @__PURE__ */ new Set();
18594
- let current = control?.parentId ? controlMap[control.parentId] : void 0;
18595
- while (current && isTaglessFamily(current.type) && !seen.has(current.id)) {
18596
- seen.add(current.id);
18597
- current = current.parentId ? controlMap[current.parentId] : void 0;
18598
- }
18599
- return current?.type === "section_table" /* SECTION_TABLE */ ? current : void 0;
18600
- };
18601
- var sectionTableRows = (tableId, controlMap) => {
18602
- const rows = [];
18603
- const walk = (ids) => ids.forEach((id) => {
18604
- const control = controlMap[id];
18605
- if (!control) return;
18606
- if (control.type === "section_table_row" /* SECTION_TABLE_ROW */) rows.push(control);
18607
- else if (isTaglessFamily(control.type)) walk(control.childrens ?? []);
18608
- });
18609
- walk(controlMap[tableId]?.childrens ?? []);
18610
- return rows;
18611
- };
18612
- var tableHasRepeat = (tableId, controlMap) => {
18613
- const walk = (ids) => ids.some((id) => {
18614
- const control = controlMap[id];
18615
- if (!control || !isTaglessFamily(control.type)) return false;
18616
- return control.type === "repeat" /* REPEAT */ || walk(control.childrens ?? []);
18617
- });
18618
- return walk(controlMap[tableId]?.childrens ?? []);
18619
- };
18620
- var sectionTableRef = (id) => `sectionTable_${id.replace(/[^a-zA-Z0-9_]/g, "_")}`;
18621
- var newCell = (id, parentId) => ({
18622
- id,
18623
- type: "section_table_cell" /* SECTION_TABLE_CELL */,
18624
- parentId,
18625
- configs: {},
18626
- childrens: []
18627
- });
18628
- var descendants = (id, controlMap) => (controlMap[id]?.childrens ?? []).flatMap((child) => [
18629
- child,
18630
- ...descendants(child, controlMap)
18631
- ]);
18632
- function syncSectionTableCells(controlMap, tableId, change, genId2) {
18633
- const next = { ...controlMap };
18634
- sectionTableRows(tableId, controlMap).forEach((row) => {
18635
- const cells = [...row.childrens];
18636
- const pad2 = (length) => {
18637
- while (cells.length < length) {
18638
- const id = genId2();
18639
- next[id] = newCell(id, row.id);
18640
- cells.push(id);
18641
- }
18642
- };
18643
- if (change.kind === "add") {
18644
- pad2(change.index);
18645
- const id = genId2();
18646
- next[id] = newCell(id, row.id);
18647
- cells.splice(change.index, 0, id);
18648
- } else if (change.kind === "remove") {
18649
- const [removed] = cells.splice(change.index, 1);
18650
- if (removed) {
18651
- [removed, ...descendants(removed, controlMap)].forEach(
18652
- (id) => delete next[id]
18653
- );
18654
- }
18655
- } else {
18656
- pad2(Math.max(change.from, change.to) + 1);
18657
- const [moved] = cells.splice(change.from, 1);
18658
- cells.splice(change.to, 0, moved);
18659
- }
18660
- next[row.id] = { ...row, childrens: cells };
18661
- });
18662
- return next;
18663
- }
18664
- function seedSectionTableRow(rowId, parentId, cellCount, genId2) {
18665
- const cells = Array.from(
18666
- { length: Math.max(1, cellCount) },
18667
- () => newCell(genId2(), rowId)
18668
- );
18669
- return {
18670
- [rowId]: {
18671
- id: rowId,
18672
- type: "section_table_row" /* SECTION_TABLE_ROW */,
18673
- parentId,
18674
- configs: {},
18675
- childrens: cells.map((cell) => cell.id)
18676
- },
18677
- ...Object.fromEntries(cells.map((cell) => [cell.id, cell]))
18678
- };
18679
- }
18680
-
18681
19464
  // libs/codegen/src/lib/search-codegen.ts
18682
19465
  var searchMemberName = (component) => {
18683
19466
  const stem = component.replace(/Component$/, "") || component;
@@ -19383,7 +20166,7 @@ function formModelShapeKeys(controlMap, formId) {
19383
20166
  return buildFormShape(controlMap, formId)?.keys ?? [];
19384
20167
  }
19385
20168
  function formModelKeyType(key2) {
19386
- if (key2.dataType.type === "shape" || key2.dataType.type === "form" || key2.dataType.type === "option" || key2.dataType.type === "audience") {
20169
+ if (key2.dataType.type === "shape" || key2.dataType.type === "form" || key2.dataType.type === "option" || key2.dataType.type === "audience" || key2.dataType.type === "enum") {
19387
20170
  return void 0;
19388
20171
  }
19389
20172
  if (!isKeyCardinality(key2.cardinality)) return void 0;
@@ -19431,7 +20214,7 @@ function formModelSourceType(source, scope) {
19431
20214
  input.cardinality
19432
20215
  );
19433
20216
  }
19434
- if (input.dataType.type === "form" || input.dataType.type === "option" || input.dataType.type === "audience") {
20217
+ if (input.dataType.type === "form" || input.dataType.type === "option" || input.dataType.type === "audience" || input.dataType.type === "enum") {
19435
20218
  return void 0;
19436
20219
  }
19437
20220
  if (source.member?.length) return void 0;
@@ -19450,7 +20233,7 @@ function formModelSourceType(source, scope) {
19450
20233
  fn.returnCardinality
19451
20234
  );
19452
20235
  }
19453
- if (fn.returnType.type === "form" || fn.returnType.type === "option" || fn.returnType.type === "audience") {
20236
+ if (fn.returnType.type === "form" || fn.returnType.type === "option" || fn.returnType.type === "audience" || fn.returnType.type === "enum") {
19454
20237
  return void 0;
19455
20238
  }
19456
20239
  if (source.member?.length) return void 0;
@@ -19672,7 +20455,7 @@ function screenVariableSourceType(source, scope) {
19672
20455
  const input = scope.inputs[source.inputId];
19673
20456
  if (!input || input.dataType.type === "shape") return void 0;
19674
20457
  if (input.dataType.type === "form") return void 0;
19675
- if (input.dataType.type === "file" || input.dataType.type === "option" || input.dataType.type === "audience") {
20458
+ if (input.dataType.type === "file" || input.dataType.type === "option" || input.dataType.type === "audience" || input.dataType.type === "enum") {
19676
20459
  return void 0;
19677
20460
  }
19678
20461
  if (!isVariableCardinality(input.cardinality)) return void 0;
@@ -19681,7 +20464,7 @@ function screenVariableSourceType(source, scope) {
19681
20464
  if (source.source === "computed") {
19682
20465
  const computed = scope.computeds[source.computedId];
19683
20466
  const fn = computed ? screenComputedFunction(computed, scope.functions) : void 0;
19684
- if (!fn || fn.returnType.type === "shape" || fn.returnType.type === "form" || fn.returnType.type === "file" || fn.returnType.type === "option" || fn.returnType.type === "audience") {
20467
+ if (!fn || fn.returnType.type === "shape" || fn.returnType.type === "form" || fn.returnType.type === "file" || fn.returnType.type === "option" || fn.returnType.type === "audience" || fn.returnType.type === "enum") {
19685
20468
  return void 0;
19686
20469
  }
19687
20470
  if (!isVariableCardinality(fn.returnCardinality)) return void 0;
@@ -19748,6 +20531,15 @@ function linkedVariableReaders(variables, source) {
19748
20531
  }
19749
20532
 
19750
20533
  // libs/codegen/src/lib/codegen-helper.ts
20534
+ var SORT_DIRECTION_ENUM = {
20535
+ id: SORT_DIRECTION_ENUM_ID,
20536
+ name: "SectionTableSortDirection",
20537
+ fileName: "",
20538
+ values: [...SORT_DIRECTION_VALUES],
20539
+ members: ["Asc", "Desc"],
20540
+ library: true
20541
+ };
20542
+ var enumImportLine = (entry2, fromTypeDir) => entry2.library ? `import { ${entry2.name} } from '@magmonium/one';` : `import { ${entry2.name} } from '${fromTypeDir}${enumModule(entry2)}';`;
19751
20543
  function variantGuard(node, names, storeProp) {
19752
20544
  const held = (node.variants ?? []).map((entry2) => {
19753
20545
  const name3 = names.get(entry2.id);
@@ -19994,6 +20786,9 @@ function bodyConfigs(node) {
19994
20786
  if (node.type === "list" /* LIST */) {
19995
20787
  delete configs["items"];
19996
20788
  }
20789
+ if (hasTextSource(node.type) && colorPipeOf(node.formatPipes ?? [])) {
20790
+ delete configs["color"];
20791
+ }
19997
20792
  if (node.type === "audience_picker" /* AUDIENCE_PICKER */) {
19998
20793
  delete configs[AUDIENCE_PICKER_LEVELS_KEY];
19999
20794
  }
@@ -20106,6 +20901,11 @@ var NUMBER_ONLY_KEYS = /* @__PURE__ */ new Set(["xs", "sm", "md", "lg", "xl", "x
20106
20901
  var IMG_NUMBER_ONLY_KEYS = /* @__PURE__ */ new Set([...NUMBER_ONLY_KEYS, "width", "height"]);
20107
20902
  var FILTER_BOUND_SLOTS = [BINDING_SLOT.min, BINDING_SLOT.max];
20108
20903
  var FILTER_NUMBER_ONLY_KEYS = /* @__PURE__ */ new Set([...NUMBER_ONLY_KEYS, "min", "max"]);
20904
+ var SCORE_ITEM_NUMBER_ONLY_KEYS = /* @__PURE__ */ new Set([...NUMBER_ONLY_KEYS, "value"]);
20905
+ var SCORE_SET_NUMBER_ONLY_KEYS = /* @__PURE__ */ new Set([
20906
+ ...NUMBER_ONLY_KEYS,
20907
+ "staleAfterDays"
20908
+ ]);
20109
20909
  var SECTION_TABLE_INPUTS = /* @__PURE__ */ new Set([
20110
20910
  "sticky",
20111
20911
  "margin",
@@ -20282,13 +21082,82 @@ function actionEnums(tree) {
20282
21082
  walk(tree);
20283
21083
  return out;
20284
21084
  }
21085
+ var enumMemberName = (entry2, index) => entry2.members?.[index] ?? toPascalCase(entry2.values[index] ?? "");
20285
21086
  var actionEnumFile = (entry2) => ({
20286
21087
  fileName: `${TYPE_SEGMENT}/${entry2.fileName}`,
20287
21088
  contents: `export enum ${entry2.name} {
20288
- ${entry2.values.map((value) => ` ${toPascalCase(value)} = '${value}',`).join("\n")}
21089
+ ${entry2.values.map((value, i) => ` ${enumMemberName(entry2, i)} = '${value}',`).join("\n")}
20289
21090
  }
20290
21091
  `
20291
21092
  });
21093
+ var enumModule = (entry2) => entry2.fileName.replace(/\.ts$/, "");
21094
+ var sortMemberNames = (values) => {
21095
+ const taken = /* @__PURE__ */ new Set();
21096
+ return values.map((value) => {
21097
+ const pascal4 = toPascalCase(value.replace(/[^A-Za-z0-9]+/g, "-")) || "Column";
21098
+ const base = /^[0-9]/.test(pascal4) ? `_${pascal4}` : pascal4;
21099
+ let name3 = base;
21100
+ for (let n = 2; taken.has(name3); n += 1) name3 = `${base}${n}`;
21101
+ taken.add(name3);
21102
+ return name3;
21103
+ });
21104
+ };
21105
+ function sectionTableSortEnums(controlMap, taken = /* @__PURE__ */ new Set()) {
21106
+ return sectionTableEmissions(controlMap).flatMap((emission) => {
21107
+ const values = sectionTableSortIds(emission.columns);
21108
+ if (!values.length) return [];
21109
+ const base = `${toPascalCase(
21110
+ emission.memberName.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)
21111
+ )}SortColumn`;
21112
+ let name3 = base;
21113
+ for (let n = 2; taken.has(name3); n += 1) name3 = `${base}${n}`;
21114
+ taken.add(name3);
21115
+ return [
21116
+ {
21117
+ id: emission.id,
21118
+ name: name3,
21119
+ fileName: `${name3.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`).replace(/^-/, "")}.ts`,
21120
+ values,
21121
+ members: sortMemberNames(values)
21122
+ }
21123
+ ];
21124
+ });
21125
+ }
21126
+ function controlEnums(screens) {
21127
+ const actions = actionEnums(screens.flatMap((screen) => screen.tree));
21128
+ const taken = /* @__PURE__ */ new Set([...actions.map((entry2) => entry2.name), SORT_DIRECTION_ENUM.name]);
21129
+ const hasTable = screens.some(
21130
+ (screen) => Object.values(screen.controlMap).some(
21131
+ (control) => control.type === "section_table" /* SECTION_TABLE */
21132
+ )
21133
+ );
21134
+ return [
21135
+ ...actions,
21136
+ ...screens.flatMap(
21137
+ (screen) => sectionTableSortEnums(screen.controlMap, taken)
21138
+ ),
21139
+ ...hasTable ? [SORT_DIRECTION_ENUM] : []
21140
+ ];
21141
+ }
21142
+ var withScreenEnums = (ctx, tree) => {
21143
+ const variables = ctx.variables ? withVariableEnums(ctx.variables, ctx.controlMap ?? {}) : void 0;
21144
+ if (ctx.enums && variables === ctx.variables) return ctx;
21145
+ return {
21146
+ ...ctx,
21147
+ ...variables ? { variables } : {},
21148
+ enums: ctx.enums ?? controlEnums([{ tree, controlMap: ctx.controlMap ?? {} }])
21149
+ };
21150
+ };
21151
+ function screenVariableEnums(ctx) {
21152
+ const out = /* @__PURE__ */ new Map();
21153
+ const controls = ctx.controlMap ?? {};
21154
+ Object.values(withVariableEnums(ctx.variables ?? {}, controls)).forEach((variable) => {
21155
+ const id = variable.actionEnumId ?? variable.sortEnumId;
21156
+ const entry2 = id ? ctx.enums?.find((candidate) => candidate.id === id) : void 0;
21157
+ if (entry2) out.set(variable.id, entry2);
21158
+ });
21159
+ return out;
21160
+ }
20292
21161
  function sectionTableEmissions(controlMap) {
20293
21162
  const used = /* @__PURE__ */ new Set();
20294
21163
  return Object.values(controlMap).filter((control) => control.type === "section_table" /* SECTION_TABLE */).map((control) => ({
@@ -20307,25 +21176,44 @@ function sectionTableEmissions(controlMap) {
20307
21176
  });
20308
21177
  }
20309
21178
  var sectionTablesFileBase = (fileBase) => `${fileBase}-tables`;
20310
- function sectionTableFiles(emissions, fileBase) {
21179
+ function sectionTableFiles(emissions, fileBase, enums) {
20311
21180
  if (!emissions.length) return [];
20312
- const consts = emissions.map(
20313
- (emission) => `export const ${emission.memberName}: SectionTableConfig = {
20314
- columns: ${JSON.stringify(
20315
- emission.columns,
20316
- null,
20317
- 2
20318
- ).split("\n").join("\n ")},
21181
+ const enumOf = (id) => enums.find((entry2) => entry2.id === id);
21182
+ const columnsLiteral = (emission) => {
21183
+ const entry2 = enumOf(emission.id);
21184
+ if (!entry2) return JSON.stringify(emission.columns, null, 2);
21185
+ const member = (id) => `${entry2.name}.${enumMemberName(entry2, entry2.values.indexOf(id))}`;
21186
+ const columns = emission.columns.map((column) => {
21187
+ const { id, ...rest } = column;
21188
+ return id && entry2.values.includes(id) ? { id: `\0${member(id)}\0`, ...rest } : rest;
21189
+ });
21190
+ return JSON.stringify(columns, null, 2).replace(
21191
+ /"\\u0000([^"\\]+)\\u0000"/g,
21192
+ "$1"
21193
+ );
21194
+ };
21195
+ const consts = emissions.map((emission) => {
21196
+ const entry2 = enumOf(emission.id);
21197
+ return `export const ${emission.memberName}: SectionTableConfig${entry2 ? `<${entry2.name}>` : ""} = {
21198
+ columns: ${columnsLiteral(emission).split("\n").join("\n ")},
20319
21199
  };
21200
+ `;
21201
+ }).join("\n");
21202
+ const enumImports = emissions.map((emission) => enumOf(emission.id)).filter((entry2) => !!entry2).map(
21203
+ (entry2) => `import { ${entry2.name} } from './${enumModule(entry2)}';
20320
21204
  `
20321
- ).join("\n");
21205
+ ).join("");
20322
21206
  return [
20323
21207
  {
20324
21208
  fileName: `${TYPE_SEGMENT}/${sectionTablesFileBase(fileBase)}.ts`,
20325
21209
  contents: `import type { SectionTableConfig } from '@magmonium/one';
20326
-
21210
+ ${enumImports}
20327
21211
  ${consts}`
20328
- }
21212
+ },
21213
+ // The enums themselves, beside the const that names them. A Feature emits
21214
+ // its own once more among its type files; the path and the text are the
21215
+ // same, and the second write is dropped (emit-app-files `written`).
21216
+ ...emissions.map((emission) => enumOf(emission.id)).filter((entry2) => !!entry2).map(actionEnumFile)
20329
21217
  ];
20330
21218
  }
20331
21219
  function actionButtonsAttr(node, names) {
@@ -20338,6 +21226,8 @@ function inlineAttrs(node) {
20338
21226
  var numberOnlyKeysOf = (type) => {
20339
21227
  if (type === "img" /* IMG */) return IMG_NUMBER_ONLY_KEYS;
20340
21228
  if (type === "section_filter" /* SECTION_FILTER */) return FILTER_NUMBER_ONLY_KEYS;
21229
+ if (type === "score_set_item" /* SCORE_SET_ITEM */) return SCORE_ITEM_NUMBER_ONLY_KEYS;
21230
+ if (type === "score_set" /* SCORE_SET */) return SCORE_SET_NUMBER_ONLY_KEYS;
20341
21231
  return NUMBER_ONLY_KEYS;
20342
21232
  };
20343
21233
  function wrapInGuard(markup, guard, pad2) {
@@ -20591,6 +21481,8 @@ var attrBindingSlots = (type) => {
20591
21481
  if (type === "app_logo" /* APP_LOGO */) return APP_LOGO_VALUE_SLOTS;
20592
21482
  if (type === "section_pagination" /* SECTION_PAGINATION */) return [BINDING_SLOT.total];
20593
21483
  if (type === "heat_swatch" /* HEAT_SWATCH */) return [BINDING_SLOT.value];
21484
+ if (type === "score_set_item" /* SCORE_SET_ITEM */) return [BINDING_SLOT.value];
21485
+ if (type === "score_set" /* SCORE_SET */) return [BINDING_SLOT.scoreDate];
20594
21486
  if (type === "section_chart_series" /* SECTION_CHART_SERIES */)
20595
21487
  return [BINDING_SLOT.data, BINDING_SLOT.label];
20596
21488
  return hasTextSource(type) ? [BINDING_SLOT.label] : [];
@@ -20653,6 +21545,47 @@ var bindingScope = (ctx, storeProp) => ({
20653
21545
  // would spell a member on an object the class never injected (ADR 0040).
20654
21546
  storeProp: ctx.hasStore ? storeProp : void 0
20655
21547
  });
21548
+ var screenComputedPresentIn = (ctx, computedId) => {
21549
+ const computed = ctx.screenComputeds?.[computedId];
21550
+ return !!computed && !screenComputedIsOptional(
21551
+ computed,
21552
+ screenComputedFunction(computed, ctx.functions ?? {}),
21553
+ ctx.inputs ?? {},
21554
+ ctx.screenComputeds ?? {},
21555
+ ctx.functions ?? {}
21556
+ );
21557
+ };
21558
+ var screenSourceReader = (ctx, scope) => (binding) => {
21559
+ switch (binding.kind) {
21560
+ case "input": {
21561
+ const input = ctx.inputs?.[binding.inputId];
21562
+ return { cardinality: input?.cardinality, present: !!input?.required };
21563
+ }
21564
+ case "variable":
21565
+ return {
21566
+ cardinality: ctx.variables?.[binding.variableId]?.cardinality,
21567
+ present: false
21568
+ };
21569
+ case "constant":
21570
+ case "enum-member":
21571
+ return { cardinality: "one", present: true };
21572
+ case "computed": {
21573
+ const computed = ctx.screenComputeds?.[binding.computedId];
21574
+ const fn = computed ? screenComputedFunction(computed, ctx.functions ?? {}) : void 0;
21575
+ return {
21576
+ cardinality: fn ? returnCardinalityOf(fn) : void 0,
21577
+ present: screenComputedPresentIn(ctx, binding.computedId)
21578
+ };
21579
+ }
21580
+ case "data":
21581
+ return {
21582
+ cardinality: bindingCardinality(binding.binding, scope),
21583
+ present: bindingAlwaysPresent(binding.binding, scope)
21584
+ };
21585
+ default:
21586
+ return { cardinality: void 0, present: true };
21587
+ }
21588
+ };
20656
21589
  var callArgBindings = (ctx, storeProp, where = {}) => ({
20657
21590
  bindingScope: {
20658
21591
  ...bindingScope(ctx, storeProp),
@@ -20672,6 +21605,7 @@ var callArgBindings = (ctx, storeProp, where = {}) => ({
20672
21605
  screenComputeds: ctx.screenComputeds,
20673
21606
  screenVariables: ctx.variables,
20674
21607
  functions: ctx.functions,
21608
+ enums: ctx.appEnums,
20675
21609
  allowAlias: !where.memberPrefix
20676
21610
  }
20677
21611
  });
@@ -20720,7 +21654,7 @@ var boundCardinality = (binding, ctx) => {
20720
21654
  }
20721
21655
  case "screen_variable": {
20722
21656
  const variable = ctx.variables?.[binding.root.id];
20723
- dataType = variable ? { type: variable.dataType } : void 0;
21657
+ dataType = variable ? screenVariableDataType(variable) : void 0;
20724
21658
  cardinality = variable?.cardinality;
20725
21659
  break;
20726
21660
  }
@@ -20769,6 +21703,13 @@ var paginationTotalRead = (node, ctx, storeProp) => {
20769
21703
  );
20770
21704
  };
20771
21705
  var formModelNameFor = (formId, ctx) => Object.values(ctx.formModels ?? {}).find((model) => model.formId === formId)?.name;
21706
+ function colorAttr(node, piped) {
21707
+ if (!colorPipeOf(node.formatPipes ?? [])) return "";
21708
+ const authored = node.configs?.["color"];
21709
+ const fallback = typeof authored === "string" && authored.trim() ? authored.trim() : "";
21710
+ if (!piped) return fallback ? ` color="${fallback}"` : "";
21711
+ return fallback ? ` [color]="(${piped}) ?? ${literalSource2(fallback)}"` : ` [color]="${piped}"`;
21712
+ }
20772
21713
  function boundAttrs(node, ctx, storeProp) {
20773
21714
  const bindings = ctx.controlMap?.[node.id]?.bindings;
20774
21715
  const chain = node.formatPipes ?? [];
@@ -20779,8 +21720,9 @@ function boundAttrs(node, ctx, storeProp) {
20779
21720
  const parts = [];
20780
21721
  if (hasTextSource(node.type) && bindings?.[BINDING_SLOT.label]) {
20781
21722
  const binding = bindings[BINDING_SLOT.label];
20782
- const emission = labelEmission(chain, boundDataType(binding, ctx));
20783
- const translated = labelReadIsTranslated(binding, chain);
21723
+ const headType = boundDataType(binding, ctx);
21724
+ const emission = labelEmission(chain, headType);
21725
+ const translated = labelReadIsTranslated(binding, labelChainOf(chain));
20784
21726
  const expr = emission === "piped" ? bindingExpression(binding, scope) : emission === "raw" ? textBindingExpression(binding, scope, translated) : void 0;
20785
21727
  const piped = expr && emission === "piped" ? withBindingFallback(formatPipeExpression(chain, expr, scope), binding) : expr;
20786
21728
  if (piped) {
@@ -20788,6 +21730,10 @@ function boundAttrs(node, ctx, storeProp) {
20788
21730
  ` [label]="${piped}"${translated ? "" : ' [noTranslate]="true"'}`
20789
21731
  );
20790
21732
  }
21733
+ const color = colorPipeOf(chain);
21734
+ const colorInput = formatPipeEntry(color?.name)?.inputType;
21735
+ const raw = !headType || !colorInput || headType.type === colorInput.type ? bindingExpression(binding, scope) : void 0;
21736
+ parts.push(colorAttr(node, raw && colorPipeExpression(chain, raw, scope)));
20791
21737
  } else if (hasTextSource(node.type) && chain.length) {
20792
21738
  const source = staticLabelSource(chain, node.configs?.[BINDING_SLOT.label]);
20793
21739
  if (source) {
@@ -20795,6 +21741,8 @@ function boundAttrs(node, ctx, storeProp) {
20795
21741
  ` [label]="${formatPipeExpression(chain, source, scope)}" [noTranslate]="true"`
20796
21742
  );
20797
21743
  }
21744
+ const head = staticHeadSource(chain, node.configs?.[BINDING_SLOT.label]);
21745
+ parts.push(colorAttr(node, head && colorPipeExpression(chain, head, scope)));
20798
21746
  }
20799
21747
  if (node.type === "form" /* FORM */) {
20800
21748
  const model = formModelNameFor(node.id, ctx);
@@ -20811,6 +21759,14 @@ function boundAttrs(node, ctx, storeProp) {
20811
21759
  const expr = bindingExpression(bindings[BINDING_SLOT.value], scope);
20812
21760
  if (expr) parts.push(` [value]="${expr}"`);
20813
21761
  }
21762
+ if (node.type === "score_set_item" /* SCORE_SET_ITEM */ && bindings?.[BINDING_SLOT.value]) {
21763
+ const expr = bindingExpression(bindings[BINDING_SLOT.value], scope);
21764
+ if (expr) parts.push(` [value]="${expr}"`);
21765
+ }
21766
+ if (node.type === "score_set" /* SCORE_SET */ && bindings?.[BINDING_SLOT.scoreDate]) {
21767
+ const expr = bindingExpression(bindings[BINDING_SLOT.scoreDate], scope);
21768
+ if (expr) parts.push(` [scoreDate]="${expr}"`);
21769
+ }
20814
21770
  if (node.type === "section_chart_series" /* SECTION_CHART_SERIES */ && bindings?.[BINDING_SLOT.data]) {
20815
21771
  const expr = bindingExpression(bindings[BINDING_SLOT.data], scope);
20816
21772
  if (expr) parts.push(` [data]="${expr}"`);
@@ -20982,6 +21938,12 @@ function tagAttrs(node, ctx, storeProp) {
20982
21938
  delete configs2[BINDING_SLOT.value];
20983
21939
  return `${inlineAttrs({ ...node, configs: configs2 })}${boundAttrs(node, ctx, storeProp)}`;
20984
21940
  }
21941
+ const scoreSlot = node.type === "score_set_item" /* SCORE_SET_ITEM */ ? BINDING_SLOT.value : node.type === "score_set" /* SCORE_SET */ ? BINDING_SLOT.scoreDate : void 0;
21942
+ if (scoreSlot && ctx.controlMap?.[node.id]?.bindings?.[scoreSlot]) {
21943
+ const configs2 = { ...node.configs ?? {} };
21944
+ delete configs2[scoreSlot];
21945
+ return `${inlineAttrs({ ...node, configs: configs2 })}${boundAttrs(node, ctx, storeProp)}`;
21946
+ }
20985
21947
  if (node.type === "section_filter" /* SECTION_FILTER */) {
20986
21948
  const bindings = ctx.controlMap?.[node.id]?.bindings;
20987
21949
  const configs2 = { ...node.configs ?? {} };
@@ -21320,6 +22282,13 @@ function statePatchFor(node, output, payload, storeProp, ctx, writes = node.outp
21320
22282
  if (!properties) return void 0;
21321
22283
  const rows = stateWriteRows(writes, output);
21322
22284
  if (!rows.length) return void 0;
22285
+ const enumById = new Map((ctx.enums ?? []).map((entry2) => [entry2.id, entry2]));
22286
+ const enumOf = ({ id }) => {
22287
+ const dataType = properties[id]?.dataType;
22288
+ const enumId = dataType?.actionEnumId ?? dataType?.sortEnumId;
22289
+ return enumId ? enumById.get(enumId) : void 0;
22290
+ };
22291
+ const root = actionEventRoot(node, eventRoot, enumOf);
21323
22292
  return stateWritePatchExpression(
21324
22293
  properties,
21325
22294
  rows,
@@ -21335,13 +22304,14 @@ function statePatchFor(node, output, payload, storeProp, ctx, writes = node.outp
21335
22304
  // resolve was a row the panel called complete and codegen dropped in
21336
22305
  // silence, taking every other row on the output with it (ADR 0043).
21337
22306
  ctx.constants ?? {},
21338
- eventRoot,
22307
+ root,
21339
22308
  scope,
21340
22309
  // A FilterGroup's payload is keyed by its Filters and its value type is the
21341
22310
  // union of what any of them carries, so a member read is cast down to that
21342
22311
  // Filter's own shape (libs/one ADR 0026). Undefined for every other
21343
22312
  // Control, whose members are already typed.
21344
- filterGroupEventMember(node)
22313
+ filterGroupEventMember(node),
22314
+ enumNarrow(node, output, enumOf)
21345
22315
  );
21346
22316
  }
21347
22317
  function screenWritesFor(node, output, payload, ctx, writes = node.outputScreenWrites, eventRoot = "$event", scope = "template") {
@@ -21349,6 +22319,9 @@ function screenWritesFor(node, output, payload, ctx, writes = node.outputScreenW
21349
22319
  if (!variables) return [];
21350
22320
  const rows = screenWriteRows(writes, output);
21351
22321
  if (!rows.length) return [];
22322
+ const enums = screenVariableEnums(ctx);
22323
+ const enumOf = ({ id }) => enums.get(id);
22324
+ const root = actionEventRoot(node, eventRoot, enumOf);
21352
22325
  return screenWriteStatements(
21353
22326
  variables,
21354
22327
  rows,
@@ -21358,11 +22331,38 @@ function screenWritesFor(node, output, payload, ctx, writes = node.outputScreenW
21358
22331
  [],
21359
22332
  ctx.inputs ?? {},
21360
22333
  ctx.constants ?? {},
21361
- eventRoot,
22334
+ root,
21362
22335
  scope,
21363
- filterGroupEventMember(node)
22336
+ filterGroupEventMember(node),
22337
+ enumNarrow(node, output, enumOf)
21364
22338
  );
21365
22339
  }
22340
+ function enumNarrow(node, output, enumOf) {
22341
+ return (target, value, expr) => {
22342
+ const entry2 = enumOf(target);
22343
+ if (!entry2 || value.kind === "clear") return expr;
22344
+ if (value.kind === "event") {
22345
+ if (node.type === "section_action" /* SECTION_ACTION */ && !value.path?.length) {
22346
+ return expr;
22347
+ }
22348
+ const sorted = node.type === "section_table" /* SECTION_TABLE */ && baseOutputName(output) === SECTION_TABLE_SORT_OUTPUT && sortRowEnumId(node.id, value.path) === entry2.id;
22349
+ if (sorted) return expr;
22350
+ }
22351
+ if (value.kind === "fixed") {
22352
+ const index = entry2.values.indexOf(value.value);
22353
+ if (index >= 0) return `${entry2.name}.${enumMemberName(entry2, index)}`;
22354
+ }
22355
+ return `${ENUM_VALUE_READER}(${expr}, ${entry2.name})`;
22356
+ };
22357
+ }
22358
+ function actionEventRoot(node, eventRoot, enumOf) {
22359
+ const bare = /^(.+)\?\.name \?\? ''$/.exec(eventRoot);
22360
+ if (node.type !== "section_action" /* SECTION_ACTION */ || !bare) return eventRoot;
22361
+ return (target) => {
22362
+ const entry2 = enumOf(target);
22363
+ return entry2 ? `${ACTION_NAME_READER}(${bare[1]}, ${entry2.name})` : eventRoot;
22364
+ };
22365
+ }
21366
22366
  function screenEmitsFor(node, trigger, payload, ctx, emits = node.outputEmits, eventRoot = "$event", scope = "template", storeProp = "") {
21367
22367
  const outputs = ctx.outputs;
21368
22368
  if (!outputs) return [];
@@ -21469,6 +22469,20 @@ function payloadAttr(node, payloads) {
21469
22469
  const prop = payloads.get(payloadPropKey(node));
21470
22470
  return prop && !prop.modeled ? ` [data]="${prop.name}!"` : "";
21471
22471
  }
22472
+ function sectionTableRowItemAttr(node, controlMap) {
22473
+ if (node.type !== "section_table_row" /* SECTION_TABLE_ROW */ || !controlMap) return "";
22474
+ const seen = /* @__PURE__ */ new Set();
22475
+ let current = controlMap[node.id];
22476
+ while (current?.parentId && !seen.has(current.id)) {
22477
+ seen.add(current.id);
22478
+ current = controlMap[current.parentId];
22479
+ if (current?.type === "repeat" /* REPEAT */) {
22480
+ return ` [item]="${repeatSpec(current).itemAlias}"`;
22481
+ }
22482
+ if (current?.type === "section_table" /* SECTION_TABLE */) return "";
22483
+ }
22484
+ return "";
22485
+ }
21472
22486
  function renderTag(node, indent2, names, methods, operationOf, storeProp, ctx, wires, payloads) {
21473
22487
  const pad2 = " ".repeat(indent2);
21474
22488
  if (node.type === "screen" /* SCREEN */) {
@@ -21478,16 +22492,7 @@ function renderTag(node, indent2, names, methods, operationOf, storeProp, ctx, w
21478
22492
  ctx,
21479
22493
  (binding) => bindingExpression(binding, guardScope),
21480
22494
  (binding) => bindingAlwaysPresent(binding, guardScope),
21481
- (computedId) => {
21482
- const computed = ctx.screenComputeds?.[computedId];
21483
- return !!computed && !screenComputedIsOptional(
21484
- computed,
21485
- screenComputedFunction(computed, ctx.functions ?? {}),
21486
- ctx.inputs ?? {},
21487
- ctx.screenComputeds ?? {},
21488
- ctx.functions ?? {}
21489
- );
21490
- }
22495
+ (computedId) => screenComputedPresentIn(ctx, computedId)
21491
22496
  );
21492
22497
  const inputAliases = new Map(
21493
22498
  guards.map((guard) => [guard.expression, guard.alias])
@@ -21547,7 +22552,8 @@ function renderTag(node, indent2, names, methods, operationOf, storeProp, ctx, w
21547
22552
  // sits in, a StateProperty — emits through the same walk every other
21548
22553
  // bound slot does (GLOSSARY.md DataBinding).
21549
22554
  (binding) => bindingExpression(binding, bindingScope(ctx, storeProp)),
21550
- inputAliases
22555
+ inputAliases,
22556
+ screenSourceReader(ctx, guardScope)
21551
22557
  );
21552
22558
  if (bound === void 0) {
21553
22559
  const name3 = node.handRef ?? node.screenId ?? "an embedded Screen";
@@ -21595,7 +22601,7 @@ ${" ".repeat(indent2 + index)}}`,
21595
22601
  ctx.overlayNames,
21596
22602
  bindingScope(ctx, storeProp),
21597
22603
  ctx.controlMap?.[node.id]?.bindings
21598
- )}${outputAttrs(node, methods, operationOf, storeProp, ctx)}`;
22604
+ )}${sectionTableRowItemAttr(node, ctx.controlMap)}${outputAttrs(node, methods, operationOf, storeProp, ctx)}`;
21599
22605
  if (node.type === "section_action" /* SECTION_ACTION */) {
21600
22606
  return `${pad2}<${tag}${attrs}${actionButtonsAttr(node, ctx.actionButtonNames)} />`;
21601
22607
  }
@@ -21683,6 +22689,7 @@ ${pad2}</${tag}>` : `${pad2}<${tag}${attrs} />`;
21683
22689
  }
21684
22690
  function planScreenEmit(tree, variants = {}, featureName = "feature", ctx = {}) {
21685
22691
  const writtenTags = /* @__PURE__ */ new Set();
22692
+ ctx = withScreenEnums(ctx, tree);
21686
22693
  return {
21687
22694
  ctx: {
21688
22695
  ...ctx,
@@ -21703,7 +22710,7 @@ function planScreenEmit(tree, variants = {}, featureName = "feature", ctx = {})
21703
22710
  }
21704
22711
  function generateHtml(tree, variants = {}, methods = {}, operationOf = () => void 0, featureName = "feature", ctx = {}, plan) {
21705
22712
  const codegenCtx = plan?.ctx ?? {
21706
- ...ctx,
22713
+ ...withScreenEnums(ctx, tree),
21707
22714
  translateParamsMember: ctx.translateParamsMember ?? `${toCamelCase(slugifyComponentName(featureName))}TranslateParams`,
21708
22715
  // Assigned here rather than per node: a name is unique across the Screen or
21709
22716
  // it is not unique at all, and the class assigns the same names from the
@@ -21846,6 +22853,18 @@ function collectPayloadReaders(tree, methods, operationOf, storeProp, ctx) {
21846
22853
  walk(tree);
21847
22854
  return [...used].sort();
21848
22855
  }
22856
+ function everyOutputAttrs(tree, methods, operationOf, storeProp, ctx) {
22857
+ const out = [];
22858
+ const walk = (nodes) => nodes.forEach((node) => {
22859
+ out.push(outputAttrs(node, methods, operationOf, storeProp, ctx));
22860
+ walk(node.childrens);
22861
+ });
22862
+ walk(tree);
22863
+ return out.join("\n");
22864
+ }
22865
+ var ENUM_READERS = [ACTION_NAME_READER, ENUM_VALUE_READER];
22866
+ var enumReadersIn = (text2) => ENUM_READERS.filter((reader) => text2.includes(`${reader}(`));
22867
+ var enumsNamedIn = (text2, enums) => enums.filter((entry2) => new RegExp(`\\b${entry2.name}\\b`).test(text2));
21849
22868
  function hasStateWrite(tree, ctx) {
21850
22869
  if (!ctx.properties) return false;
21851
22870
  return tree.some(
@@ -21971,12 +22990,36 @@ var transformMembersBlock = (refs, functions) => {
21971
22990
  return decls.length ? `
21972
22991
  ${decls.map((d) => d.line).join("")}` : "";
21973
22992
  };
21974
- var inputDeclsBlock = (inputs, lookup) => {
22993
+ var enumMemberEnums = (controls, appEnums = {}) => {
22994
+ const ids = /* @__PURE__ */ new Set();
22995
+ const add = (binding) => {
22996
+ if (binding.kind === "enum-member") ids.add(binding.enumId);
22997
+ };
22998
+ Object.values(controls).forEach((control) => {
22999
+ Object.values(control.screenInputs ?? {}).forEach(add);
23000
+ Object.keys(control.outputOpens ?? {}).forEach((output) => {
23001
+ const open = outputOpenOf(control.outputOpens, output);
23002
+ if (!open) return;
23003
+ outputOpenInputs(open).forEach((row) => {
23004
+ if (row.value.kind === "screen") add(row.value.binding);
23005
+ });
23006
+ });
23007
+ });
23008
+ return [...ids].map((id) => appEnums[id]).filter((appEnum) => !!appEnum).sort((a, b) => a.name.localeCompare(b.name));
23009
+ };
23010
+ var inputDeclsBlock = (inputs, lookup, appEnums) => {
21975
23011
  if (!inputs.length) return "";
21976
- return "\n" + inputs.map(
21977
- ({ decl, required }) => ` readonly ${decl.name} = input${required ? ".required" : ""}<${componentInputTsType(decl, lookup)}>();
21978
- `
21979
- ).join("");
23012
+ return "\n" + inputs.map(({ decl, required }) => {
23013
+ let tsType;
23014
+ if (decl.dataType?.type === "enum") {
23015
+ const appEnum = appEnums?.[decl.dataType.enumId];
23016
+ tsType = appEnum ? appEnum.name : "string";
23017
+ } else {
23018
+ tsType = componentInputTsType(decl, lookup);
23019
+ }
23020
+ return ` readonly ${decl.name} = input${required ? ".required" : ""}<${tsType}>();
23021
+ `;
23022
+ }).join("");
21980
23023
  };
21981
23024
  var constantDeclsBlock = (constants) => {
21982
23025
  if (!constants.length) return "";
@@ -22094,18 +23137,17 @@ var variableDeclsBlock = (variables, scope) => {
22094
23137
  );
22095
23138
  };
22096
23139
  return "\n" + [...variables].sort((a, b) => a.name.localeCompare(b.name)).map((variable) => {
22097
- const type = tsTypeExpression(
22098
- {},
22099
- { type: variable.dataType },
22100
- variable.cardinality
22101
- );
23140
+ const entry2 = scope.enums?.get(variable.id);
23141
+ const type = entry2 ? entry2.name : tsTypeExpression({}, { type: variable.dataType }, variable.cardinality);
22102
23142
  const read = sourceRead(variable);
22103
23143
  if (read) {
22104
- return ` protected readonly ${variable.name} = linkedSignal<${type} | undefined>(() => ${read});
23144
+ const narrowed = entry2 ? `${ENUM_VALUE_READER}(${read}, ${entry2.name})` : read;
23145
+ return ` protected readonly ${variable.name} = linkedSignal<${type} | undefined>(() => ${narrowed});
22105
23146
  `;
22106
23147
  }
22107
23148
  const seed = screenVariableInitialAllowed(variable) ? (variable.initial ?? "").trim() : "";
22108
- const start = seed ? literalExpression(seed, { type: variable.dataType }) : "undefined";
23149
+ const member = entry2 ? entry2.values.indexOf(seed) : -1;
23150
+ const start = !seed ? "undefined" : entry2 ? member >= 0 ? `${entry2.name}.${enumMemberName(entry2, member)}` : "undefined" : literalExpression(seed, { type: variable.dataType });
22109
23151
  return ` protected readonly ${variable.name} = signal<${type} | undefined>(${start});
22110
23152
  `;
22111
23153
  }).join("");
@@ -22340,7 +23382,8 @@ function outputOpenEmit(node, output, ctx, storeProp, indent2 = " ", methods
22340
23382
  (binding) => bindingExpression(binding, {
22341
23383
  ...bindingScope(ctx, storeProp),
22342
23384
  memberPrefix: "this."
22343
- })
23385
+ }),
23386
+ screenSourceReader(ctx, bindingScope(ctx, storeProp))
22344
23387
  );
22345
23388
  if (!entries) return void 0;
22346
23389
  return {
@@ -23707,9 +24750,18 @@ ${read.map(([expr, local]) => ` const ${local} = ${expr};`).join("\n")}` :
23707
24750
  return emitted.length ? `
23708
24751
  ${emitted.join("")}` : "";
23709
24752
  }
23710
- var componentInputTypeImports = (inputs, lookup, shapes, featureName) => {
24753
+ var componentInputTypeImports = (inputs, lookup, shapes, featureName, appEnums) => {
23711
24754
  const roots = inputs.flatMap(componentInputShapeIds);
23712
- if (!roots.length) return "";
24755
+ const enumImports = [
24756
+ ...new Set(
24757
+ inputs.filter((input) => input.dataType?.type === "enum").map((input) => {
24758
+ const enumId = input.dataType.enumId;
24759
+ const appEnum = appEnums?.[enumId];
24760
+ return appEnum ? `import { ${appEnum.name} } from '../../../shared/type/${appEnum.fileName}';` : void 0;
24761
+ }).filter((line) => !!line)
24762
+ )
24763
+ ].sort();
24764
+ if (!roots.length && !enumImports.length) return "";
23713
24765
  const drawnPool = {
23714
24766
  ...Object.fromEntries(
23715
24767
  Object.entries(lookup).filter(([id]) => isSharedShapeId(id))
@@ -23730,7 +24782,7 @@ ${spec.map((shape) => ` ${shapeInterfaceName(shape.name)},`).sort().join(
23730
24782
  )}
23731
24783
  } from '../${TYPE_SEGMENT}/${apiTypesModule(featureName)}';`
23732
24784
  ] : [];
23733
- return [...drawnImports, ...specImports].join("\n") + "\n";
24785
+ return [...enumImports, ...drawnImports, ...specImports].join("\n") + "\n";
23734
24786
  };
23735
24787
  var variantNameMap = (variants) => new Map(
23736
24788
  listSelectableVariants(variants).map((variant) => [
@@ -23750,6 +24802,13 @@ function collectComponentImportEntries(tree, ctx = {}) {
23750
24802
  from: ref.importFrom,
23751
24803
  tag: ref.tag
23752
24804
  });
24805
+ if (screenControlLiftsInput(
24806
+ node,
24807
+ ctx,
24808
+ screenSourceReader(ctx, bindingScope(ctx, ""))
24809
+ )) {
24810
+ entries.push({ component: "ToListPipe", from: ONE_IMPORT_MODULE });
24811
+ }
23753
24812
  }
23754
24813
  } else {
23755
24814
  const codegen = codegenFor(node.type);
@@ -23793,7 +24852,7 @@ function collectComponentImportEntries(tree, ctx = {}) {
23793
24852
  );
23794
24853
  if (bindingsNeedTranslate(
23795
24854
  ctx.controlMap?.[node.id]?.bindings,
23796
- node.formatPipes ?? []
24855
+ labelChainOf(node.formatPipes ?? [])
23797
24856
  )) {
23798
24857
  entries.push({ component: "TranslatePipe", from: ONE_IMPORT_MODULE });
23799
24858
  }
@@ -23863,9 +24922,9 @@ function generateStateType(featureName, properties, shapes = {}, enums = [], ini
23863
24922
  const enumById = new Map(enums.map((entry2) => [entry2.id, entry2]));
23864
24923
  const enumImports = Array.from(
23865
24924
  new Set(
23866
- dataProperties.map((property) => property.dataType.actionEnumId).map((id) => id ? enumById.get(id) : void 0).filter((entry2) => !!entry2).map(
23867
- (entry2) => `import { ${entry2.name} } from './${entry2.fileName.replace(/\.ts$/, "")}';`
23868
- )
24925
+ dataProperties.map(
24926
+ (property) => property.dataType.actionEnumId ?? property.dataType.sortEnumId
24927
+ ).map((id) => id ? enumById.get(id) : void 0).filter((entry2) => !!entry2).map((entry2) => enumImportLine(entry2, "./"))
23869
24928
  )
23870
24929
  ).join("\n");
23871
24930
  const members = dataProperties.map(
@@ -24119,6 +25178,8 @@ ${lines.join("\n")}
24119
25178
  ...drawn.needsModal ? [MODAL_STORE] : [],
24120
25179
  // A `denied` arm's refusal is claimed off the library (api ADR 0005).
24121
25180
  ...drawn.needsDenial ? ["claimDenial"] : [],
25181
+ // A CallCondition asking a OneFunction (ADR 0202).
25182
+ ...drawn.oneFunctions ?? [],
24122
25183
  ...hooks.needsStorage || drawn.needsStorage || storageMethods.needsStorage ? [STORAGE_SERVICE] : [],
24123
25184
  // What the host's search box is read through, drawn per row the way every
24124
25185
  // other source's import is (ADR 0184).
@@ -24437,6 +25498,7 @@ function screenTouchedSubStores(ctx, tree, methods, operationOf, constants, clas
24437
25498
  );
24438
25499
  }
24439
25500
  function generateTs(tree, naming, featureName, variants = {}, methods = {}, operationOf = () => void 0, shapes = {}, ctx = {}, html, plan) {
25501
+ ctx = withScreenEnums(ctx, tree);
24440
25502
  const components = collectUsedComponents(
24441
25503
  tree,
24442
25504
  ctx,
@@ -24707,7 +25769,8 @@ ${tables.map(
24707
25769
  inputs.map((i) => i.decl),
24708
25770
  lookup,
24709
25771
  shapes,
24710
- featureName
25772
+ featureName,
25773
+ ctx.appEnums
24711
25774
  );
24712
25775
  const screenComputedsBody = screenComputedsBlock(
24713
25776
  screenComputeds,
@@ -24735,7 +25798,11 @@ ${tables.map(
24735
25798
  } : {},
24736
25799
  // Every CompositionKind: a `computed` arg walking into a sibling's shape
24737
25800
  // return needs the keys named whether or not a store is injected.
24738
- shapes
25801
+ shapes,
25802
+ // The Screen's own variables, which a `variable` arg reads as
25803
+ // `this.<name>()`. Missing here, every such arg emitted `undefined` and
25804
+ // the computed answered nothing however the variable moved.
25805
+ variables: ctx.variables ?? {}
24739
25806
  }
24740
25807
  );
24741
25808
  const menuConditionScreenRoots = screenPropertiesWithComputeds(
@@ -24907,11 +25974,28 @@ ${tables.map(
24907
25974
  storeProp,
24908
25975
  ctx
24909
25976
  );
24910
- const payloadReaderImport = payloadReaders.length ? `import { ${payloadReaders.join(", ")} } from '@magmonium/one';
25977
+ const templateText = html ?? everyOutputAttrs(tree, methods, operationOf, storeProp, ctx);
25978
+ const templateReaders = enumReadersIn(templateText);
25979
+ const templateEnums = enumsNamedIn(templateText, ctx.enums ?? []).map(
25980
+ (entry2) => entry2.name
25981
+ );
25982
+ const templateMembers = [
25983
+ .../* @__PURE__ */ new Set([...payloadReaders, ...templateReaders])
25984
+ ].sort();
25985
+ const payloadReaderImport = templateMembers.length ? `import { ${templateMembers.join(", ")} } from '@magmonium/one';
24911
25986
  ` : "";
24912
- const payloadReadersBody = payloadReaders.length ? "\n" + payloadReaders.map((reader) => ` protected readonly ${reader} = ${reader};
25987
+ const payloadReadersBody = templateMembers.length || templateEnums.length ? "\n" + [...templateMembers, ...templateEnums.sort()].map((reader) => ` protected readonly ${reader} = ${reader};
24913
25988
  `).join("") : "";
24914
- const assetOptionsImport = screenComputedsBody.includes("assetOptions(") ? `import { assetOptions } from '@magmonium/one';
25989
+ const oneFunctionImports = [
25990
+ ...new Set(
25991
+ Object.values(screenComputeds).filter((computed) => isOneFunctionComputed(computed)).map((computed) => computed.oneFunction).filter((name3) => screenComputedsBody.includes(`${name3}(`))
25992
+ )
25993
+ ];
25994
+ const libraryImports = [
25995
+ ...screenComputedsBody.includes("assetOptions(") ? ["assetOptions"] : [],
25996
+ ...oneFunctionImports
25997
+ ].sort();
25998
+ const assetOptionsImport = libraryImports.length ? `import { ${libraryImports.join(", ")} } from '@magmonium/one';
24915
25999
  ` : "";
24916
26000
  const busyImport = busyOnClass ? `import { ${BUSY_SIGNAL} } from '@magmonium/one';
24917
26001
  ` : "";
@@ -24932,14 +26016,16 @@ ${tables.map(
24932
26016
  protected readonly ${GLOBAL_METHOD_STORES[store].prop} = inject(${GLOBAL_METHOD_STORES[store].className});
24933
26017
  `
24934
26018
  ).join("");
24935
- const inputsBody = inputDeclsBlock(inputs, lookup);
26019
+ const inputsBody = inputDeclsBlock(inputs, lookup, ctx.appEnums);
24936
26020
  const constantsBody = constantDeclsBlock(Object.values(constants));
26021
+ const variableEnums = screenVariableEnums(ctx);
24937
26022
  const variablesBody = variableDeclsBlock(variables, {
24938
26023
  inputs: ctx.inputs ?? {},
24939
26024
  computeds: screenComputeds,
24940
26025
  ...needsStore ? { storeProp: featureStoreProp(featureName) } : {},
24941
26026
  properties: ctx.properties ?? {},
24942
- shapes
26027
+ shapes,
26028
+ enums: variableEnums
24943
26029
  });
24944
26030
  const formModels = Object.values(ctx.formModels ?? {});
24945
26031
  const formModelsBody = formModelDeclsBlock(formModels, {
@@ -25028,8 +26114,31 @@ ${tables.map(
25028
26114
  templateRefs,
25029
26115
  ctx.functions ?? {}
25030
26116
  );
26117
+ const memberEnums = enumMemberEnums(ctx.controlMap ?? {}, ctx.appEnums);
26118
+ const memberEnumImports = memberEnums.map(
26119
+ (appEnum) => `import { ${appEnum.name} } from '../../../shared/type/${appEnum.fileName}';`
26120
+ ).filter((line) => !inputTypeImports.includes(line)).map((line) => `${line}
26121
+ `).join("");
26122
+ const memberEnumsBody = memberEnums.length ? `
26123
+ ${memberEnums.map(
26124
+ (appEnum) => ` protected readonly ${appEnum.name} = ${appEnum.name};
26125
+ `
26126
+ ).join("")}` : "";
26127
+ const classText = `${variablesBody}${screenMethodsBody}${outcomeHandlersBody}${menuActionHandlersBody}${outputArmHandlersBody}${wiresBody}`;
26128
+ const enumNames = /* @__PURE__ */ new Set([
26129
+ ...[...variableEnums.values()].map((entry2) => entry2.name),
26130
+ ...templateEnums,
26131
+ ...enumsNamedIn(classText, ctx.enums ?? []).map((entry2) => entry2.name)
26132
+ ]);
26133
+ const enumImports = (ctx.enums ?? []).filter((entry2) => enumNames.has(entry2.name)).sort((a, b) => a.name.localeCompare(b.name)).map((entry2) => `${enumImportLine(entry2, `../${TYPE_SEGMENT}/`)}
26134
+ `).join("");
26135
+ const classReaders = enumReadersIn(classText).filter(
26136
+ (reader) => !templateMembers.includes(reader)
26137
+ );
26138
+ const classReaderImport = classReaders.length ? `import { ${classReaders.join(", ")} } from '@magmonium/one';
26139
+ ` : "";
25031
26140
  return `${angularImports}
25032
- ${`${outcomeHandlersBody}${menuActionHandlersBody}`.includes("$event: MenuItem") ? "import type { MenuItem } from '@magmonium/one';\n" : ""}${contextMenuConfigBody ? "import type { ContextMenu } from '@magmonium/one';\n" : ""}${audiencePickerConfigBody ? "import type { AudiencePicker } from '@magmonium/one';\n" : ""}${environmentImport}${inputTypeImports}${importsBlock}${validationImports}${sectionTableImport}${formModelImports}${storeImport}${busyImport}${authImport}${globalStoreImports}${modalImport}${overlayRefImport}${navRefImport}${navRouterImport}${assetOptionsImport}${payloadReaderImport}${screenFunctionImport}
26141
+ ${`${outcomeHandlersBody}${menuActionHandlersBody}`.includes("$event: MenuItem") ? "import type { MenuItem } from '@magmonium/one';\n" : ""}${contextMenuConfigBody ? "import type { ContextMenu } from '@magmonium/one';\n" : ""}${audiencePickerConfigBody ? "import type { AudiencePicker } from '@magmonium/one';\n" : ""}${environmentImport}${inputTypeImports}${memberEnumImports}${importsBlock}${validationImports}${sectionTableImport}${formModelImports}${storeImport}${busyImport}${authImport}${globalStoreImports}${modalImport}${overlayRefImport}${navRefImport}${navRouterImport}${assetOptionsImport}${payloadReaderImport}${classReaderImport}${enumImports}${screenFunctionImport}
25033
26142
  @Component({
25034
26143
  selector: '${naming.selector}',
25035
26144
  changeDetection: ChangeDetectionStrategy.OnPush,
@@ -25049,7 +26158,7 @@ ${`${outcomeHandlersBody}${menuActionHandlersBody}`.includes("$event: MenuItem")
25049
26158
  width: 100%
25050
26159
  \`,
25051
26160
  })
25052
- export class ${naming.className} {${storeBody}${busyBody}${authBody}${globalStoreBody}${modalBody}${overlayRefBody}${navRefBody}${navRouterBody}${imgApiOriginBody}${inputsBody}${constantsBody}${screenComputedsBody}${variablesBody}${formModelsBody}${screenVariantsBody}${cardsBody}${searchBody}${messageParamsBody}${outputsBody}${wiresBody}${overlayProps}${contextMenuConfigBody}${audiencePickerConfigBody}${payloadsBody}${transformMembersBody}${payloadReadersBody}${sectionTablesBody}${checksBody}${screenMethodsBody}${outputOpenBody}${outputLinkBody}${outcomeHandlersBody}${menuActionHandlersBody}${menuConditionBody}${outputArmHandlersBody}${autoCallsBody}}
26161
+ export class ${naming.className} {${storeBody}${busyBody}${authBody}${globalStoreBody}${modalBody}${overlayRefBody}${navRefBody}${navRouterBody}${imgApiOriginBody}${inputsBody}${constantsBody}${screenComputedsBody}${variablesBody}${formModelsBody}${screenVariantsBody}${cardsBody}${searchBody}${messageParamsBody}${outputsBody}${wiresBody}${overlayProps}${contextMenuConfigBody}${audiencePickerConfigBody}${payloadsBody}${transformMembersBody}${memberEnumsBody}${payloadReadersBody}${sectionTablesBody}${checksBody}${screenMethodsBody}${outputOpenBody}${outputLinkBody}${outcomeHandlersBody}${menuActionHandlersBody}${menuConditionBody}${outputArmHandlersBody}${autoCallsBody}}
25053
26162
  `;
25054
26163
  }
25055
26164
  function assetName(node) {
@@ -25164,7 +26273,8 @@ function generateCode(tree, featureName, screenName, properties = {}, variants =
25164
26273
  // that wanted it was dropped.
25165
26274
  properties: ctx.properties ?? properties,
25166
26275
  shapes: ctx.shapes ?? shapes,
25167
- translateParamsMember: ctx.translateParamsMember ?? `${toCamelCase(naming.fileBase)}TranslateParams`
26276
+ translateParamsMember: ctx.translateParamsMember ?? `${toCamelCase(naming.fileBase)}TranslateParams`,
26277
+ enums: withScreenEnums(ctx, tree).enums
25168
26278
  };
25169
26279
  const apiMethods = Object.values(ctx.subStores ?? {}).reduce(
25170
26280
  (acc, sub) => ({ ...acc, ...sub.methods }),
@@ -25191,7 +26301,9 @@ function generateCode(tree, featureName, screenName, properties = {}, variants =
25191
26301
  operationOf,
25192
26302
  shapes,
25193
26303
  codegenCtx,
25194
- void 0,
26304
+ // The template, which the class reads for the enum reads it declares
26305
+ // members for (ADR 0203); the tags it prunes by still come from `plan`.
26306
+ html,
25195
26307
  plan
25196
26308
  ),
25197
26309
  assets: collectControlAssets(tree, codegenCtx.controlMap),
@@ -25209,7 +26321,8 @@ function generateCode(tree, featureName, screenName, properties = {}, variants =
25209
26321
  ),
25210
26322
  sectionTableFiles: sectionTableFiles(
25211
26323
  sectionTableEmissions(ctx.controlMap ?? {}),
25212
- naming.fileBase
26324
+ naming.fileBase,
26325
+ codegenCtx.enums ?? []
25213
26326
  ),
25214
26327
  screenFacts: {
25215
26328
  className: naming.className,
@@ -25319,7 +26432,7 @@ function generateFeatureCode(feature, context) {
25319
26432
  // per store: each `withState` reads its own interface (ADR 0093).
25320
26433
  typeFiles: [
25321
26434
  ...generateShapeFiles(feature.shapes),
25322
- ...context.actionEnums.map(actionEnumFile),
26435
+ ...context.actionEnums.filter((entry2) => !entry2.library).map(actionEnumFile),
25323
26436
  ...apiTypes ? [{ fileName: apiTypesFile(feature.name), contents: apiTypes }] : [],
25324
26437
  ...stores.stateFiles
25325
26438
  ]
@@ -25381,7 +26494,7 @@ __export(package_exports, {
25381
26494
  version: () => version
25382
26495
  });
25383
26496
  var name = "@magmonium/one";
25384
- var version = "0.4.60";
26497
+ var version = "0.4.79";
25385
26498
  var description = "Magmonium One \u2014 Angular design-system primitives for mm Apps";
25386
26499
  var author = "magmonium";
25387
26500
  var license = "MIT";
@@ -25449,7 +26562,7 @@ __export(package_exports2, {
25449
26562
  version: () => version2
25450
26563
  });
25451
26564
  var name2 = "@magmonium/cli";
25452
- var version2 = "0.8.19";
26565
+ var version2 = "0.8.21";
25453
26566
  var description2 = "A powerful and extensible asset compilation tool that can be shared across multiple projects";
25454
26567
  var bin = {
25455
26568
  "mag-cli": "bin/cli.js"
@@ -25583,7 +26696,6 @@ function isDescendant(ancestorId, candidateId, controlMap) {
25583
26696
  }
25584
26697
  return false;
25585
26698
  }
25586
- var layerLabel = (layer) => layer === 0 ? "root-layer" : `Layer ${layer}`;
25587
26699
  function getAvailableLayers(controlMap, selection) {
25588
26700
  const layers = /* @__PURE__ */ new Set();
25589
26701
  layers.add(0);
@@ -25777,14 +26889,24 @@ function findNavRowShapeId(shapes) {
25777
26889
  )?.id;
25778
26890
  }
25779
26891
  var NEW_COMPUTED = "__new_computed__";
25780
- var navRowFeatureOptions = (features) => features.filter((feature) => navRowSourceOptions(feature).length > 0).map((feature) => ({ value: feature.id, label: feature.name }));
26892
+ var navRowFeatureOptions = (features, canAuthor = () => false) => features.filter(
26893
+ (feature) => canAuthor(feature.id) || navRowSourceOptions(feature).length > 0
26894
+ ).map((feature) => ({ value: feature.id, label: feature.name }));
26895
+ var navRowStoreOptions = (feature) => feature ? [
26896
+ { value: MAIN_STORE_VALUE, label: feature.name },
26897
+ ...subStoresOf(feature).map((subStore) => ({
26898
+ value: subStore.id,
26899
+ label: subStoreFullName(feature.name, subStore.name)
26900
+ }))
26901
+ ] : [];
25781
26902
  var newComputedOption = () => ({
25782
26903
  value: NEW_COMPUTED,
25783
26904
  label: "create-computed"
25784
26905
  });
25785
- function navRowSourceOptions(feature) {
26906
+ function navRowSourceOptions(feature, owner) {
25786
26907
  if (!feature) return [];
25787
- return storesOf(feature).flatMap(
26908
+ const value = owner && storeOwnerValue(owner);
26909
+ return storesOf(feature).filter((store) => !value || storeOwnerValue(store.owner) === value).flatMap(
25788
26910
  (store) => Object.values(store.computeds).filter((computed) => {
25789
26911
  const fn = feature.functions?.[computed.functionId];
25790
26912
  return !!fn && isNavRowShape(fn.returnType, fn.returnCardinality, feature.shapes);
@@ -27418,7 +28540,15 @@ function sanitizeDataType(value, shapes) {
27418
28540
  return typeof formId === "string" && formId ? { type: "form", formId } : fallback;
27419
28541
  }
27420
28542
  if (dataType.type === "option") return { type: "option" };
27421
- return dataType.type === "number" || dataType.type === "boolean" ? { type: dataType.type } : fallback;
28543
+ if (dataType.type === "number" || dataType.type === "boolean") {
28544
+ return { type: dataType.type };
28545
+ }
28546
+ const { actionEnumId, sortEnumId } = dataType;
28547
+ return {
28548
+ type: "string",
28549
+ ...typeof actionEnumId === "string" && actionEnumId ? { actionEnumId } : {},
28550
+ ...typeof sortEnumId === "string" && sortEnumId ? { sortEnumId } : {}
28551
+ };
27422
28552
  }
27423
28553
  function sanitizeCardinality(value) {
27424
28554
  const holder = value;
@@ -27762,7 +28892,12 @@ function sanitizeMethods(methods, properties, functions = {}) {
27762
28892
  const debounce = rawDebounce && typeof rawDebounce.id === "string" && !!rawDebounce.id && typeof rawDebounce.seconds === "number" && rawDebounce.seconds > 0 ? { id: rawDebounce.id, seconds: rawDebounce.seconds } : void 0;
27763
28893
  const functionCondition = (condition) => ({
27764
28894
  id: condition.id,
27765
- functionId: condition.functionId,
28895
+ // A OneFunction is held by name and keeps no register id (ADR 0202).
28896
+ functionId: condition.oneFunction ? "" : condition.functionId,
28897
+ ...condition.oneFunction ? {
28898
+ oneFunction: condition.oneFunction,
28899
+ ...condition.negate === true ? { negate: true } : {}
28900
+ } : {},
27766
28901
  args: Object.fromEntries(
27767
28902
  Object.entries(condition.args).filter(([, binding]) => {
27768
28903
  if (!binding) return false;
@@ -27773,7 +28908,7 @@ function sanitizeMethods(methods, properties, functions = {}) {
27773
28908
  )
27774
28909
  });
27775
28910
  const conditions = (Array.isArray(method.conditions) ? method.conditions : []).filter(
27776
- (condition) => !!condition && typeof condition.id === "string" && !!condition.id && (condition.kind === "check" ? !!condition.check && (condition.check.source === "store" || condition.check.source === "args") && RULE_OPERATORS.includes(condition.check.operator) : typeof condition.functionId === "string" && !!functions[condition.functionId] && !!condition.args && typeof condition.args === "object")
28911
+ (condition) => !!condition && typeof condition.id === "string" && !!condition.id && (condition.kind === "check" ? !!condition.check && (condition.check.source === "store" || condition.check.source === "args") && RULE_OPERATORS.includes(condition.check.operator) : (typeof condition.oneFunction === "string" ? !!condition.oneFunction : typeof condition.functionId === "string" && !!functions[condition.functionId]) && !!condition.args && typeof condition.args === "object")
27777
28912
  ).map((condition) => {
27778
28913
  const check = condition.check;
27779
28914
  if (condition.kind !== "check" || !check)
@@ -28161,8 +29296,18 @@ function sanitizeStateComputeds(value, functions, reservedNames) {
28161
29296
  var PRIMITIVE_TYPES = ["string", "number", "boolean"];
28162
29297
  var dataTypeName = (value) => value && typeof value === "object" ? value.type : value;
28163
29298
  var sanitizePrimitive = (value) => PRIMITIVE_TYPES.includes(value) ? value : "string";
28164
- var sanitizeInputDataType = (value, shapes) => value && typeof value === "object" && value.type === "shape" ? sanitizeDataType(value, shapes) : { type: sanitizePrimitive(dataTypeName(value)) };
28165
- function sanitizeScreenInputs(inputs, shapes) {
29299
+ var sanitizeInputDataType = (value, shapes, enums) => {
29300
+ if (value && typeof value === "object") {
29301
+ const type = value.type;
29302
+ if (type === "shape") return sanitizeDataType(value, shapes);
29303
+ if (type === "enum") {
29304
+ const enumId = value.enumId;
29305
+ return typeof enumId === "string" && enumId && enums[enumId] ? { type: "enum", enumId } : { type: "string" };
29306
+ }
29307
+ }
29308
+ return { type: sanitizePrimitive(dataTypeName(value)) };
29309
+ };
29310
+ function sanitizeScreenInputs(inputs, shapes, enums) {
28166
29311
  if (!inputs || typeof inputs !== "object") return {};
28167
29312
  const result = {};
28168
29313
  const takenNames = /* @__PURE__ */ new Set();
@@ -28176,7 +29321,7 @@ function sanitizeScreenInputs(inputs, shapes) {
28176
29321
  result[id] = {
28177
29322
  id,
28178
29323
  name: input.name,
28179
- dataType: sanitizeInputDataType(input.dataType, shapes),
29324
+ dataType: sanitizeInputDataType(input.dataType, shapes, enums),
28180
29325
  cardinality: sanitizeCardinality(input),
28181
29326
  ...input.required ? { required: true } : {},
28182
29327
  ...input.origin === "card" ? { origin: "card" } : {},
@@ -28572,8 +29717,26 @@ function sanitizeScreenComputeds(value, functions, inputs, constants, variables,
28572
29717
  continue;
28573
29718
  }
28574
29719
  const returns = computed.functionId ? void 0 : sanitizeComputedReturns(computed.returns);
29720
+ const oneFunction = !computed.functionId && typeof computed.oneFunction === "string" ? computed.oneFunction : void 0;
29721
+ if (oneFunction && returns && !oneFunctionOf(oneFunction)) {
29722
+ taken.add(computed.name);
29723
+ result[id] = {
29724
+ id,
29725
+ name: computed.name,
29726
+ oneFunction,
29727
+ args: computed.args ?? {},
29728
+ returns
29729
+ };
29730
+ continue;
29731
+ }
28575
29732
  const fn = computed.functionId ? functions[computed.functionId] : returns ? screenComputedFunction(
28576
- { id, name: computed.name, args: {}, returns },
29733
+ {
29734
+ id,
29735
+ name: computed.name,
29736
+ args: {},
29737
+ returns,
29738
+ ...oneFunction ? { oneFunction } : {}
29739
+ },
28577
29740
  {}
28578
29741
  ) : void 0;
28579
29742
  if (!fn) continue;
@@ -28595,7 +29758,13 @@ function sanitizeScreenComputeds(value, functions, inputs, constants, variables,
28595
29758
  fn.params.filter((param) => answers(stored[param.id])).map((param) => [param.id, stored[param.id]])
28596
29759
  );
28597
29760
  taken.add(computed.name);
28598
- result[id] = returns ? { id, name: computed.name, args, returns } : { id, name: computed.name, functionId: fn.id, args };
29761
+ result[id] = returns ? {
29762
+ id,
29763
+ name: computed.name,
29764
+ ...oneFunction ? { oneFunction } : {},
29765
+ args,
29766
+ returns
29767
+ } : { id, name: computed.name, functionId: fn.id, args };
28599
29768
  }
28600
29769
  return result;
28601
29770
  }
@@ -28603,16 +29772,25 @@ function sanitizeComputedReturns(value) {
28603
29772
  if (!value || typeof value !== "object") return void 0;
28604
29773
  const raw = value.dataType;
28605
29774
  const cardinality = sanitizeCardinality(value);
29775
+ const optional = value.optional === true ? { optional: true } : {};
28606
29776
  if (!raw || typeof raw !== "object") return void 0;
28607
29777
  if (raw.type === "shape" && typeof raw.shapeId === "string" && raw.shapeId)
28608
- return { dataType: { type: "shape", shapeId: raw.shapeId }, cardinality };
29778
+ return {
29779
+ dataType: { type: "shape", shapeId: raw.shapeId },
29780
+ cardinality,
29781
+ ...optional
29782
+ };
28609
29783
  if (raw.type === "form" && typeof raw.formId === "string" && raw.formId)
28610
- return { dataType: { type: "form", formId: raw.formId }, cardinality };
29784
+ return {
29785
+ dataType: { type: "form", formId: raw.formId },
29786
+ cardinality,
29787
+ ...optional
29788
+ };
28611
29789
  if (raw.type === "string" || raw.type === "number" || raw.type === "boolean" || raw.type === "option")
28612
- return { dataType: { type: raw.type }, cardinality };
29790
+ return { dataType: { type: raw.type }, cardinality, ...optional };
28613
29791
  return void 0;
28614
29792
  }
28615
- function sanitizeScreens(screens, features, appFunctions, sharedShapes = {}) {
29793
+ function sanitizeScreens(screens, features, appFunctions, sharedShapes = {}, enums = {}) {
28616
29794
  if (!Array.isArray(screens)) return [];
28617
29795
  const result = [];
28618
29796
  const seenIds = /* @__PURE__ */ new Set();
@@ -28637,10 +29815,14 @@ function sanitizeScreens(screens, features, appFunctions, sharedShapes = {}) {
28637
29815
  } else {
28638
29816
  meta = { id: screen.id, name: screen.name, kind };
28639
29817
  }
28640
- const inputs = sanitizeScreenInputs(screen.inputs, {
28641
- ...sharedShapes,
28642
- ...kind === "feature" && features[screen.featureId]?.shapes || {}
28643
- });
29818
+ const inputs = sanitizeScreenInputs(
29819
+ screen.inputs,
29820
+ {
29821
+ ...sharedShapes,
29822
+ ...kind === "feature" && features[screen.featureId]?.shapes || {}
29823
+ },
29824
+ enums
29825
+ );
28644
29826
  if (Object.keys(inputs).length) meta.inputs = inputs;
28645
29827
  const variants = sanitizeVariants(screen.variants);
28646
29828
  if (Object.keys(variants).length) meta.variants = variants;
@@ -28913,6 +30095,70 @@ function sanitizeDistinct(raw) {
28913
30095
  return [{ kind, ids: a < b ? [a, b] : [b, a] }];
28914
30096
  });
28915
30097
  }
30098
+ var ENUM_NAME = /^[A-Z][A-Za-z0-9]*$/;
30099
+ var ENUM_MEMBER_KEY = /^[A-Z][A-Z0-9_]*$/;
30100
+ function sanitizeEnums(raw) {
30101
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return {};
30102
+ const result = {};
30103
+ const takenNames = /* @__PURE__ */ new Set();
30104
+ for (const [id, value] of Object.entries(raw)) {
30105
+ if (!value || typeof value !== "object") continue;
30106
+ const stored = value;
30107
+ if (typeof stored.name !== "string" || !ENUM_NAME.test(stored.name)) continue;
30108
+ if (takenNames.has(stored.name)) continue;
30109
+ const hasValue = stored.hasValue === true;
30110
+ const valueType = stored.valueType === "string" ? "string" : "number";
30111
+ const members = sanitizeEnumMembers(stored.members, hasValue, valueType);
30112
+ if (!members.length) continue;
30113
+ takenNames.add(stored.name);
30114
+ result[id] = {
30115
+ id,
30116
+ name: stored.name,
30117
+ // Derived rather than trusted, so a rename cannot leave the emitted path
30118
+ // disagreeing with the name beside it.
30119
+ fileName: enumFileBase(stored.name),
30120
+ members,
30121
+ hasValue,
30122
+ ...valueType === "string" ? { valueType } : {}
30123
+ };
30124
+ }
30125
+ return result;
30126
+ }
30127
+ var sanitizeEnumMembers = (raw, hasValue, valueType) => {
30128
+ if (!Array.isArray(raw)) return [];
30129
+ const members = [];
30130
+ const takenKeys = /* @__PURE__ */ new Set();
30131
+ const takenValues = /* @__PURE__ */ new Set();
30132
+ const takenTexts = /* @__PURE__ */ new Set();
30133
+ for (const entry2 of raw) {
30134
+ if (!entry2 || typeof entry2 !== "object") continue;
30135
+ const stored = entry2;
30136
+ if (typeof stored.key !== "string" || !ENUM_MEMBER_KEY.test(stored.key)) {
30137
+ continue;
30138
+ }
30139
+ if (takenKeys.has(stored.key)) continue;
30140
+ let value;
30141
+ if (hasValue && valueType === "string") {
30142
+ const given = typeof stored.value === "string" && stored.value.trim() ? stored.value : stored.key;
30143
+ let text2 = takenTexts.has(given) ? stored.key : given;
30144
+ for (let n = 2; takenTexts.has(text2); n++) text2 = `${stored.key}_${n}`;
30145
+ takenTexts.add(text2);
30146
+ value = text2;
30147
+ } else if (hasValue) {
30148
+ const given = typeof stored.value === "number" && Number.isFinite(stored.value) ? Math.trunc(stored.value) : void 0;
30149
+ value = given !== void 0 && !takenValues.has(given) ? given : 0;
30150
+ while (takenValues.has(value)) value += 1;
30151
+ takenValues.add(value);
30152
+ }
30153
+ takenKeys.add(stored.key);
30154
+ members.push({
30155
+ id: typeof stored.id === "string" && stored.id ? stored.id : stored.key,
30156
+ key: stored.key,
30157
+ ...value !== void 0 ? { value } : {}
30158
+ });
30159
+ }
30160
+ return members;
30161
+ };
28916
30162
  function relocateShapeTypedFunctions(appFunctions, features) {
28917
30163
  const misfiled = Object.values(appFunctions).filter(
28918
30164
  (fn) => featureShapeIds(fn).length > 0
@@ -28940,6 +30186,7 @@ function relocateShapeTypedFunctions(appFunctions, features) {
28940
30186
  }
28941
30187
  function decodeWorkspace(stored, docs) {
28942
30188
  const sharedShapes = sanitizeShapes(stored.sharedShapes, {}, "shared");
30189
+ const enums = sanitizeEnums(stored.enums);
28943
30190
  const appFunctions = sanitizePureFunctions(
28944
30191
  stored.functions,
28945
30192
  everyStoredShape(stored.features, sharedShapes)
@@ -28953,7 +30200,8 @@ function decodeWorkspace(stored, docs) {
28953
30200
  stored.screens,
28954
30201
  features,
28955
30202
  appFunctions,
28956
- sharedShapes
30203
+ sharedShapes,
30204
+ enums
28957
30205
  );
28958
30206
  const usedFeatures = new Set(
28959
30207
  screens.filter((screen) => screen.kind === "feature" && screen.featureId).map((screen) => screen.featureId)
@@ -29000,6 +30248,7 @@ function decodeWorkspace(stored, docs) {
29000
30248
  // it was found in.
29001
30249
  functions: refiled.functions,
29002
30250
  sharedShapes,
30251
+ enums,
29003
30252
  distinct: sanitizeDistinct(stored.distinct)
29004
30253
  },
29005
30254
  currentScreenId,
@@ -29210,6 +30459,7 @@ function buildDesignSource(ws, operations = drawnOperations(ws)) {
29210
30459
  screens: ws.screens.map(({ meta }) => meta),
29211
30460
  functions: ws.functions,
29212
30461
  sharedShapes: ws.sharedShapes ?? {},
30462
+ enums: ws.enums ?? {},
29213
30463
  distinct: ws.distinct ?? [],
29214
30464
  // Travels though GLOSSARY.md files it beside AiProvider: that grouping is
29215
30465
  // Reset Project's scope, not disk. This is a list of package names and
@@ -29352,6 +30602,7 @@ function readDesignSource(files3) {
29352
30602
  screens,
29353
30603
  functions: workspace.functions,
29354
30604
  sharedShapes: workspace.sharedShapes ?? {},
30605
+ enums: workspace.enums ?? {},
29355
30606
  distinct: workspace.distinct ?? [],
29356
30607
  npmAllowlist: sanitizeNpmAllowlist(stored.npmAllowlist),
29357
30608
  icons: workspace.icons,
@@ -29394,112 +30645,6 @@ var designSourceEmitted = (ws) => Object.entries(buildDesignSource(ws)).map(([pa
29394
30645
  contents
29395
30646
  }));
29396
30647
 
29397
- // libs/codegen/src/lib/tree-helper.ts
29398
- function buildTree(controlMap, rootControlIds, selection) {
29399
- const state = (id) => selection ? variantRenderState(id, controlMap, selection) : "solid";
29400
- const resolveDirectives = (ctrl) => {
29401
- if (!ctrl.directives) return void 0;
29402
- const resolved = {};
29403
- for (const [name3, directive] of Object.entries(ctrl.directives)) {
29404
- if (directive.overlayId) {
29405
- const overlay = controlMap[directive.overlayId];
29406
- if (overlay) {
29407
- resolved[name3] = {
29408
- overlayId: directive.overlayId,
29409
- type: overlay.type,
29410
- configs: overlay.configs
29411
- };
29412
- }
29413
- } else {
29414
- resolved[name3] = { configs: directive.configs ?? {} };
29415
- }
29416
- }
29417
- return Object.keys(resolved).length > 0 ? resolved : void 0;
29418
- };
29419
- const toNode = (ctrl) => {
29420
- const childrens = getChildren(ctrl.id);
29421
- const fullyFaded = state(ctrl.id) === "faded" && childrens.every((child) => child.faded);
29422
- return {
29423
- type: ctrl.type,
29424
- id: ctrl.id,
29425
- configs: ctrl.configs,
29426
- childrens,
29427
- directives: resolveDirectives(ctrl),
29428
- ...ctrl.source ? { source: ctrl.source } : {},
29429
- ...ctrl.variants?.length ? { variants: ctrl.variants } : {},
29430
- // Carried through so renderBranch can order the `@else` last and spell it
29431
- // without reaching back into ControlMap mid-walk (GLOSSARY.md DefaultArm).
29432
- ...ctrl.armKind ? { armKind: ctrl.armKind } : {},
29433
- ...ctrl.variantKind ? { variantKind: ctrl.variantKind } : {},
29434
- ...ctrl.outputs && Object.keys(ctrl.outputs).length ? { outputs: ctrl.outputs } : {},
29435
- ...ctrl.outputArgs && Object.keys(ctrl.outputArgs).length ? { outputArgs: ctrl.outputArgs } : {},
29436
- ...ctrl.outputWrites && Object.keys(ctrl.outputWrites).length ? { outputWrites: ctrl.outputWrites } : {},
29437
- ...ctrl.outputEmits && Object.keys(ctrl.outputEmits).length ? { outputEmits: ctrl.outputEmits } : {},
29438
- ...ctrl.outputScreenWrites && Object.keys(ctrl.outputScreenWrites).length ? { outputScreenWrites: ctrl.outputScreenWrites } : {},
29439
- ...ctrl.outputOpens && Object.keys(ctrl.outputOpens).length ? { outputOpens: ctrl.outputOpens } : {},
29440
- ...ctrl.outputNavs && Object.keys(ctrl.outputNavs).length ? { outputNavs: ctrl.outputNavs } : {},
29441
- ...ctrl.outputNewTabs && Object.keys(ctrl.outputNewTabs).length ? { outputNewTabs: ctrl.outputNewTabs } : {},
29442
- ...ctrl.outputOutcomes && Object.keys(ctrl.outputOutcomes).length ? { outputOutcomes: ctrl.outputOutcomes } : {},
29443
- // Without this the codegen walk reads `outputArms` off a Tree that never
29444
- // carried it, every gated output falls back to ungated, and its groups —
29445
- // filed under `<output>|arm:<armId>` — are skipped as qualified keys. The
29446
- // output emits nothing at all (GLOSSARY.md OutputArm).
29447
- ...ctrl.outputArms && Object.keys(ctrl.outputArms).length ? { outputArms: ctrl.outputArms } : {},
29448
- // Without this every group fires its first call alone: the rest are
29449
- // filed under `<group>|call:<callId>` and read in the order this holds
29450
- // (GLOSSARY.md OutputCall).
29451
- ...ctrl.outputCalls && Object.keys(ctrl.outputCalls).length ? { outputCalls: ctrl.outputCalls } : {},
29452
- ...ctrl.outputScreenMethods && Object.keys(ctrl.outputScreenMethods).length ? { outputScreenMethods: ctrl.outputScreenMethods } : {},
29453
- ...ctrl.menuActions?.length ? { menuActions: ctrl.menuActions } : {},
29454
- ...ctrl.screenId ? { screenId: ctrl.screenId } : {},
29455
- // The other answer to what a ScreenControl mounts (ADR 0088). Carried
29456
- // for `screenId`'s reason: the Canvas labels its placeholder from it and
29457
- // codegen emits its tag.
29458
- ...ctrl.handRef ? { handRef: ctrl.handRef } : {},
29459
- ...ctrl.screenInputs && Object.keys(ctrl.screenInputs).length ? { screenInputs: ctrl.screenInputs } : {},
29460
- // Carried for `screenId`'s reason: the Canvas draws the embed's box at
29461
- // it and codegen emits it on the tag.
29462
- ...ctrl.maxWidth ? { maxWidth: ctrl.maxWidth } : {},
29463
- ...ctrl.screenOutputs && Object.keys(ctrl.screenOutputs).length ? { screenOutputs: ctrl.screenOutputs } : {},
29464
- ...ctrl.screenOutputCalls && Object.keys(ctrl.screenOutputCalls).length ? { screenOutputCalls: ctrl.screenOutputCalls } : {},
29465
- ...ctrl.screenOutputWrites && Object.keys(ctrl.screenOutputWrites).length ? { screenOutputWrites: ctrl.screenOutputWrites } : {},
29466
- ...ctrl.screenOutputEmits && Object.keys(ctrl.screenOutputEmits).length ? { screenOutputEmits: ctrl.screenOutputEmits } : {},
29467
- ...ctrl.screenOutputScreenWrites && Object.keys(ctrl.screenOutputScreenWrites).length ? { screenOutputScreenWrites: ctrl.screenOutputScreenWrites } : {},
29468
- ...ctrl.checks?.length ? { checks: ctrl.checks } : {},
29469
- ...ctrl.formatPipes?.length ? { formatPipes: ctrl.formatPipes } : {},
29470
- ...ctrl.cards ? { cards: ctrl.cards } : {},
29471
- ...ctrl.search ? { search: ctrl.search } : {},
29472
- // A Repeat's row count, carried for `cards`' reason: the Canvas draws
29473
- // its sample rows from the Tree alone. Nothing else reads it — codegen
29474
- // never emits a count (GLOSSARY.md SampleValue).
29475
- ...ctrl.repeat?.sampleRows !== void 0 ? { sampleRows: ctrl.repeat.sampleRows } : {},
29476
- ...fullyFaded ? { faded: true } : {}
29477
- };
29478
- };
29479
- const getChildren = (parentId) => {
29480
- const parent = controlMap[parentId];
29481
- if (!parent || !parent.childrens) return [];
29482
- return parent.childrens.map((childId) => controlMap[childId]).filter(Boolean).filter((ctrl) => state(ctrl.id) !== "hidden").map(toNode);
29483
- };
29484
- const tree = rootControlIds.map((id) => controlMap[id]).filter(Boolean).filter((ctrl) => state(ctrl.id) !== "hidden").map(toNode);
29485
- return selection ? markFadedRoots(tree) : tree;
29486
- }
29487
- function markFadedRoots(nodes, underFaded = false) {
29488
- return nodes.map((node) => {
29489
- const faded = !underFaded && node.faded;
29490
- const next = {
29491
- ...node,
29492
- childrens: markFadedRoots(node.childrens, underFaded || !!node.faded)
29493
- };
29494
- if (faded) {
29495
- next.faded = true;
29496
- } else {
29497
- delete next.faded;
29498
- }
29499
- return next;
29500
- });
29501
- }
29502
-
29503
30648
  // libs/codegen/src/lib/overlay-widgets-helper.ts
29504
30649
  var overlayWidgetScreenIds = (maps) => {
29505
30650
  const ids = /* @__PURE__ */ new Set();
@@ -31676,7 +32821,11 @@ var pureFunctionTest = (path, fn, shapes) => ({
31676
32821
  (entry2) => block(
31677
32822
  entry2.name,
31678
32823
  [
31679
- `expect(await ${fn.name}(${entry2.args.join(", ")})).toEqual(${entry2.expected});`
32824
+ // A case is authored as literals, and a literal is no member
32825
+ // of an enum a parameter names: called the way the smoke test
32826
+ // above is, so `'total'` reaches it as the string it is at
32827
+ // runtime (ADR 0203).
32828
+ `expect(await ${namesEnum(fn) ? `(${fn.name} as (...args: unknown[]) => unknown)` : fn.name}(${entry2.args.join(", ")})).toEqual(${entry2.expected});`
31680
32829
  ],
31681
32830
  true
31682
32831
  )
@@ -31684,6 +32833,7 @@ var pureFunctionTest = (path, fn, shapes) => ({
31684
32833
  ]
31685
32834
  )
31686
32835
  });
32836
+ var namesEnum = (fn) => fn.params.some((param) => !!enumIdOf(param.dataType));
31687
32837
  var URL_HELPERS = [
31688
32838
  `const ANY_SEGMENT = '__segment__';`,
31689
32839
  `const urlPattern = (urls: HttpService, domain: string, segments: string[], version?: 'v2'): RegExp =>`,
@@ -32784,23 +33934,33 @@ var screenCtxOf = (ws, meta, controlMap) => {
32784
33934
  // holds no StateProperty and no StateComputed, so every other Feature-owned
32785
33935
  // field here is empty and could not tell a Feature Screen from a Page
32786
33936
  // (ADR 0063).
32787
- hasStore: !!feature
33937
+ hasStore: !!feature,
33938
+ // A Feature Screen names its enums as the Feature's state file does, the
33939
+ // list being drawn across every Screen of it; a storeless one derives its
33940
+ // own from itself (ADR 0203).
33941
+ ...feature ? { enums: featureEnums(ws, feature.id) } : {},
33942
+ // AppTarget-owned Enums an input may name, so the class imports the one
33943
+ // shared type and declares `input<Status>()` (ADR 0204).
33944
+ appEnums: ws.enums ?? {}
32788
33945
  };
32789
33946
  };
33947
+ var featureEnums = (ws, featureId) => controlEnums(
33948
+ ws.screens.filter(
33949
+ (screen) => screen.meta.kind === "feature" && screen.meta.featureId === featureId
33950
+ ).map((screen) => ({
33951
+ tree: buildTree(screen.state.controlMap, screen.state.rootControlIds),
33952
+ controlMap: screen.state.controlMap
33953
+ }))
33954
+ );
32790
33955
  var featureContextOf = (ws, feature) => ({
32791
33956
  operationOf: ws.operationOf,
32792
33957
  // App-tier first, the Feature's own over the top: the narrower scope, and a
32793
33958
  // name collision between them is already refused (ADR 0045).
32794
33959
  functions: { ...ws.functions, ...feature.functions ?? {} },
32795
33960
  // Derived from every Screen before the Feature's shared state file is
32796
- // emitted, so a property may name an action bar drawn on a sibling Screen.
32797
- actionEnums: actionEnums(
32798
- ws.screens.filter(
32799
- (screen) => screen.meta.kind === "feature" && screen.meta.featureId === feature.id
32800
- ).flatMap(
32801
- (screen) => buildTree(screen.state.controlMap, screen.state.rootControlIds)
32802
- )
32803
- ),
33961
+ // emitted, so a property may name an action bar or a sorting table drawn on
33962
+ // a sibling Screen.
33963
+ actionEnums: featureEnums(ws, feature.id),
32804
33964
  usesBusy: featureUsesBusy(ws, feature.id),
32805
33965
  armed: featureMethodArms(ws, feature.id),
32806
33966
  // The Screen a StoreMethod opens once it has landed (GLOSSARY.md OpenScreen).
@@ -32835,14 +33995,23 @@ var emitFunctionFiles = (ws) => {
32835
33995
  listFunctions(ws.functions).forEach((fn) => {
32836
33996
  const path = `${SHARED_LIB_ROOT}/${functionFileBase(fn.name)}.ts`;
32837
33997
  const shapes = { ...ws.sharedShapes ?? {}, ...forms };
32838
- push({ path, contents: generateFunctionFile(shapes, fn) });
33998
+ push({
33999
+ path,
34000
+ contents: generateFunctionFile(shapes, fn, [SORT_DIRECTION_ENUM])
34001
+ });
32839
34002
  push(pureFunctionTest(path, fn, shapes));
32840
34003
  });
32841
34004
  Object.values(ws.features).forEach((feature) => {
32842
34005
  listFunctions(feature.functions ?? {}).forEach((fn) => {
32843
34006
  const path = functionFilePath(fn, feature.name);
32844
34007
  const shapes = { ...feature.shapes, ...forms };
32845
- push({ path, contents: generateFunctionFile(shapes, fn) });
34008
+ push({
34009
+ path,
34010
+ contents: generateFunctionFile(shapes, fn, [
34011
+ ...featureEnums(ws, feature.id),
34012
+ SORT_DIRECTION_ENUM
34013
+ ])
34014
+ });
32846
34015
  push(pureFunctionTest(path, fn, shapes));
32847
34016
  });
32848
34017
  });
@@ -32855,7 +34024,40 @@ var emitSharedShapeFiles = (ws) => {
32855
34024
  contents: generateShapeInterface(shared, shape)
32856
34025
  }));
32857
34026
  };
32858
- var inReach = (ws) => ws.sharedShapes ? { ...ws, features: featuresInReach(ws.features, ws.sharedShapes) } : ws;
34027
+ var emitEnumFiles = (ws) => {
34028
+ const enums = ws.enums ?? {};
34029
+ return Object.values(enums).map((appEnum) => emitEnumFile(appEnum));
34030
+ };
34031
+ var inReach = (ws) => withPropertyEnums(
34032
+ ws.sharedShapes ? { ...ws, features: featuresInReach(ws.features, ws.sharedShapes) } : ws
34033
+ );
34034
+ var withPropertyEnums = (ws) => {
34035
+ const features = Object.fromEntries(
34036
+ Object.entries(ws.features).map(([id, feature]) => {
34037
+ const controlMaps = ws.screens.filter(
34038
+ (screen) => screen.meta.kind === "feature" && screen.meta.featureId === id
34039
+ ).map((screen) => screen.state.controlMap);
34040
+ const subStores = feature.subStores ? Object.fromEntries(
34041
+ Object.entries(feature.subStores).map(([subId, sub]) => [
34042
+ subId,
34043
+ {
34044
+ ...sub,
34045
+ properties: stampStatePropertyEnums(sub.properties, controlMaps)
34046
+ }
34047
+ ])
34048
+ ) : void 0;
34049
+ return [
34050
+ id,
34051
+ {
34052
+ ...feature,
34053
+ properties: stampStatePropertyEnums(feature.properties, controlMaps),
34054
+ ...subStores ? { subStores } : {}
34055
+ }
34056
+ ];
34057
+ })
34058
+ );
34059
+ return { ...ws, features };
34060
+ };
32859
34061
  var emitFormShapeFiles = (ws) => {
32860
34062
  const functions = { ...ws.functions };
32861
34063
  Object.values(ws.features).forEach((feature) => {
@@ -33139,6 +34341,7 @@ var emitFullAppFiles = (authored, stringify) => {
33139
34341
  files3.push(...emitFunctionFiles(ws));
33140
34342
  files3.push(...emitFormShapeFiles(ws));
33141
34343
  files3.push(...emitSharedShapeFiles(ws));
34344
+ files3.push(...emitEnumFiles(ws));
33142
34345
  files3.push(...navGeneratedFiles(ws));
33143
34346
  if (ws.appAssetTree) {
33144
34347
  Object.entries(ws.appAssetTree).forEach(([folder, folderFiles]) => {
@@ -33210,6 +34413,7 @@ var emitOverlayFiles = (authored, stringify) => {
33210
34413
  files3.push(...emitFunctionFiles(ws));
33211
34414
  files3.push(...emitFormShapeFiles(ws));
33212
34415
  files3.push(...emitSharedShapeFiles(ws));
34416
+ files3.push(...emitEnumFiles(ws));
33213
34417
  files3.push(...navGeneratedFiles(ws));
33214
34418
  if (ws.appAssetTree) {
33215
34419
  Object.entries(ws.appAssetTree).forEach(([folder, folderFiles]) => {
@@ -33329,6 +34533,7 @@ var HISTORY_LABELS = [
33329
34533
  "edit-binding",
33330
34534
  "edit-variant",
33331
34535
  "edit-shape",
34536
+ "edit-enum",
33332
34537
  "edit-method",
33333
34538
  "edit-store",
33334
34539
  "edit-timer",
@@ -33367,6 +34572,7 @@ var HISTORY_AUTHORED_KEYS = [
33367
34572
  "navMap",
33368
34573
  "functions",
33369
34574
  "sharedShapes",
34575
+ "enums",
33370
34576
  "distinct",
33371
34577
  "wcConfig"
33372
34578
  ];
@@ -33377,6 +34583,7 @@ var HISTORY_SELECTION_KEYS = [
33377
34583
  ];
33378
34584
  // Annotate the CommonJS export names for ESM import in node:
33379
34585
  0 && (module.exports = {
34586
+ ACTION_NAME_READER,
33380
34587
  ALL_VARIANT,
33381
34588
  API_SEGMENT,
33382
34589
  APP_CONFIG_SOURCE,
@@ -33480,6 +34687,7 @@ var HISTORY_SELECTION_KEYS = [
33480
34687
  EMPTY_STORE_HOOK,
33481
34688
  EMPTY_STORE_METHODS,
33482
34689
  EMPTY_WC_CONFIG,
34690
+ ENUM_VALUE_READER,
33483
34691
  ENVIRONMENT_PRESETS,
33484
34692
  FALLBACK_APP_COLOR,
33485
34693
  FALLBACK_SLOTS,
@@ -33578,6 +34786,11 @@ var HISTORY_SELECTION_KEYS = [
33578
34786
  NO_ROOT_PREFIX,
33579
34787
  NO_TRANSLATE_CONFIG_KEY,
33580
34788
  ONE_CONFIG_SOURCE,
34789
+ ONE_FUNCTIONS,
34790
+ ONE_FUNCTION_CATALOG,
34791
+ ONE_FUNCTION_ID_PARAM,
34792
+ ONE_FUNCTION_MAP_PARAM,
34793
+ ONE_FUNCTION_PREFIX,
33581
34794
  ONE_IMPORT_MODULE,
33582
34795
  ONE_PACKAGE_VERSION,
33583
34796
  OPEN_SCREEN_INPUT_SOURCES,
@@ -33647,12 +34860,18 @@ var HISTORY_SELECTION_KEYS = [
33647
34860
  SEARCH_TEXT_INPUT,
33648
34861
  SECTION_TABLE_COLUMNS_KEY,
33649
34862
  SECTION_TABLE_SEED_COLUMNS,
34863
+ SECTION_TABLE_SORT_DIRECTION,
34864
+ SECTION_TABLE_SORT_ID,
34865
+ SECTION_TABLE_SORT_OUTPUT,
33650
34866
  SHARDED_FOLDERS,
33651
34867
  SHARED_FUNCTIONS,
33652
34868
  SHARED_LIB_ROOT,
33653
34869
  SHARED_SHAPES,
33654
34870
  SHARED_SHAPE_ID_PREFIX,
33655
34871
  SHIPPED_SHELL_PATHS,
34872
+ SORT_DIRECTION_ENUM,
34873
+ SORT_DIRECTION_ENUM_ID,
34874
+ SORT_DIRECTION_VALUES,
33656
34875
  SOURCE_LANG,
33657
34876
  STARTER_GROUP,
33658
34877
  STAT_TEXT_SOURCES,
@@ -33691,6 +34910,7 @@ var HISTORY_SELECTION_KEYS = [
33691
34910
  acceptsPatterns,
33692
34911
  actionButtonEntries,
33693
34912
  actionButtonOverrides,
34913
+ actionEnumFile,
33694
34914
  actionEnumValues,
33695
34915
  actionEnums,
33696
34916
  actionRenderIds,
@@ -33860,6 +35080,8 @@ var HISTORY_SELECTION_KEYS = [
33860
35080
  collectThemeAssets,
33861
35081
  collectTranslationAssets,
33862
35082
  collectTypedComponentInputs,
35083
+ colorPipeExpression,
35084
+ colorPipeOf,
33863
35085
  columnNeedsId,
33864
35086
  compactControlGroups,
33865
35087
  compactControlMap,
@@ -33882,6 +35104,7 @@ var HISTORY_SELECTION_KEYS = [
33882
35104
  computedRootIds,
33883
35105
  conditionCheckType,
33884
35106
  conditionError,
35107
+ conditionFunction,
33885
35108
  conditionId,
33886
35109
  conditionKind,
33887
35110
  configurableResponses,
@@ -33893,6 +35116,8 @@ var HISTORY_SELECTION_KEYS = [
33893
35116
  contentTemplateTag,
33894
35117
  contrastRatio,
33895
35118
  controlDrawsDenial,
35119
+ controlEnumValues,
35120
+ controlEnums,
33896
35121
  controlMapReadsState,
33897
35122
  controlMapStateRootIds,
33898
35123
  controlMapUsesAuth,
@@ -33981,6 +35206,7 @@ var HISTORY_SELECTION_KEYS = [
33981
35206
  embedShapeBlocked,
33982
35207
  embeddedRefOf,
33983
35208
  emissionShapeLookup,
35209
+ emitEnumFile,
33984
35210
  emitFullAppFiles,
33985
35211
  emitGeneratedFiles,
33986
35212
  emitOverlayFiles,
@@ -33998,6 +35224,16 @@ var HISTORY_SELECTION_KEYS = [
33998
35224
  encodeRoot,
33999
35225
  endWithNewline,
34000
35226
  ensureWritable,
35227
+ enumEventStateWrites,
35228
+ enumEventWrites,
35229
+ enumFileBase,
35230
+ enumIdOf,
35231
+ enumLabels,
35232
+ enumMemberLabel,
35233
+ enumMemberName,
35234
+ enumModule,
35235
+ enumNameOf,
35236
+ enumValuesOf,
34001
35237
  evaluateVariantGate,
34002
35238
  eventPayloadTsType,
34003
35239
  everyFormReset,
@@ -34205,6 +35441,7 @@ var HISTORY_SELECTION_KEYS = [
34205
35441
  isCompleteVisibilitySource,
34206
35442
  isCompositionKind,
34207
35443
  isComputedEligible,
35444
+ isControlEnum,
34208
35445
  isControlVisible,
34209
35446
  isCountdown,
34210
35447
  isCustomPath,
@@ -34252,6 +35489,7 @@ var HISTORY_SELECTION_KEYS = [
34252
35489
  isNavRowShape,
34253
35490
  isNavVisibilityFunction,
34254
35491
  isOnChange,
35492
+ isOneFunctionComputed,
34255
35493
  isOptionRowShape,
34256
35494
  isOrderingMenuActionOperator,
34257
35495
  isOrderingOutputArmOperator,
@@ -34332,14 +35570,17 @@ var HISTORY_SELECTION_KEYS = [
34332
35570
  jsNativesInGroup,
34333
35571
  keyCandidates,
34334
35572
  keyIdKeeper,
35573
+ labelChainOf,
34335
35574
  labelEmission,
34336
35575
  labelReadIsTranslated,
34337
35576
  landingNavId,
34338
35577
  landsOn,
34339
35578
  landsUnconditionally,
34340
- layerLabel,
34341
35579
  levelStateComputeds,
34342
35580
  libImportsFrom,
35581
+ liftToList,
35582
+ liftToListInTemplate,
35583
+ liftsToList,
34343
35584
  linkDrift,
34344
35585
  linkTargetKind,
34345
35586
  linkedVariableReaders,
@@ -34349,6 +35590,7 @@ var HISTORY_SELECTION_KEYS = [
34349
35590
  listFeatures,
34350
35591
  listFilesUnder,
34351
35592
  listFunctions,
35593
+ listOneFunctions,
34352
35594
  listScreenComputeds,
34353
35595
  listScreenInputs,
34354
35596
  listScreenOutputs,
@@ -34457,6 +35699,7 @@ var HISTORY_SELECTION_KEYS = [
34457
35699
  navRowMiss,
34458
35700
  navRowSourceBindings,
34459
35701
  navRowSourceOptions,
35702
+ navRowStoreOptions,
34460
35703
  navSegmentId,
34461
35704
  navTailPathsOf,
34462
35705
  navVariantNavIds,
@@ -34504,6 +35747,13 @@ var HISTORY_SELECTION_KEYS = [
34504
35747
  normalizeTranslationKey,
34505
35748
  normalizeVariantName,
34506
35749
  offersOutputArms,
35750
+ oneFunctionArgFits,
35751
+ oneFunctionFromPickValue,
35752
+ oneFunctionOf,
35753
+ oneFunctionPickValue,
35754
+ oneFunctionReturns,
35755
+ oneFunctionSignature,
35756
+ oneFunctionSignatureText,
34507
35757
  openError,
34508
35758
  openId,
34509
35759
  openInputAnswered,
@@ -34760,6 +36010,7 @@ var HISTORY_SELECTION_KEYS = [
34760
36010
  sanitizeControlGroups,
34761
36011
  sanitizeControlVariants,
34762
36012
  sanitizeDistinct,
36013
+ sanitizeEnums,
34763
36014
  sanitizeMemberPath,
34764
36015
  sanitizeNavMap,
34765
36016
  sanitizeNpmAllowlist,
@@ -34790,6 +36041,7 @@ var HISTORY_SELECTION_KEYS = [
34790
36041
  screenControlAttrs,
34791
36042
  screenControlHasRequiredInputBindings,
34792
36043
  screenControlInputGuards,
36044
+ screenControlLiftsInput,
34793
36045
  screenEmbedGapReason,
34794
36046
  screenEmitBindingTargets,
34795
36047
  screenEmitConstTargets,
@@ -34823,6 +36075,10 @@ var HISTORY_SELECTION_KEYS = [
34823
36075
  screenPropertiesWithComputeds,
34824
36076
  screenTest,
34825
36077
  screenVariableActionEnumIds,
36078
+ screenVariableDataType,
36079
+ screenVariableEnumId,
36080
+ screenVariableEnumIds,
36081
+ screenVariableEnums,
34826
36082
  screenVariableInitialAllowed,
34827
36083
  screenVariableInitialIssue,
34828
36084
  screenVariableSourceType,
@@ -34848,6 +36104,8 @@ var HISTORY_SELECTION_KEYS = [
34848
36104
  sectionTableEmissions,
34849
36105
  sectionTableRef,
34850
36106
  sectionTableRows,
36107
+ sectionTableSortEnums,
36108
+ sectionTableSortIds,
34851
36109
  seedColumn,
34852
36110
  seedColumns,
34853
36111
  seedInstanceArgs,
@@ -34881,6 +36139,7 @@ var HISTORY_SELECTION_KEYS = [
34881
36139
  shapesInReach,
34882
36140
  sharedShapeHolders,
34883
36141
  signatureChanged,
36142
+ signatureEnums,
34884
36143
  signatureFormIds,
34885
36144
  signatureNamesOptionRow,
34886
36145
  signatureShapeIds,
@@ -34888,9 +36147,11 @@ var HISTORY_SELECTION_KEYS = [
34888
36147
  slug,
34889
36148
  slugifyComponentName,
34890
36149
  slugifyMessage,
36150
+ sortRowEnumId,
34891
36151
  sourceCarriesTrackKey,
34892
36152
  staleCases,
34893
36153
  staleMenuActionItems,
36154
+ stampStatePropertyEnums,
34894
36155
  standardMenuConfigs,
34895
36156
  starterFunction,
34896
36157
  stateComputedArgExpression,
@@ -34910,6 +36171,7 @@ var HISTORY_SELECTION_KEYS = [
34910
36171
  stateWriteTargets,
34911
36172
  stateWriteToggleAllowed,
34912
36173
  stateWriteValueKinds,
36174
+ staticHeadSource,
34913
36175
  staticLabelSource,
34914
36176
  staticLiteralType,
34915
36177
  staticLiteralValue,
@@ -34917,6 +36179,8 @@ var HISTORY_SELECTION_KEYS = [
34917
36179
  storeAppOptions,
34918
36180
  storeHookCallError,
34919
36181
  storeNameScope,
36182
+ storeOwnerOfValue,
36183
+ storeOwnerValue,
34920
36184
  storeReaders,
34921
36185
  storeTest,
34922
36186
  storesOf,
@@ -35052,7 +36316,9 @@ var HISTORY_SELECTION_KEYS = [
35052
36316
  withEmittedTests,
35053
36317
  withFormShapes,
35054
36318
  withListRowShape,
36319
+ withScreenEnums,
35055
36320
  withScreenMethodCallSites,
36321
+ withVariableEnums,
35056
36322
  wouldComputedCycle,
35057
36323
  wouldCycle,
35058
36324
  wouldScreenComputedCycle,