@magmonium/cli 0.8.24 → 0.8.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/codegen/index.js +1198 -594
  2. package/package.json +1 -1
package/codegen/index.js CHANGED
@@ -243,6 +243,7 @@ __export(index_exports, {
243
243
  OUTPUT_ARM_SEPARATOR: () => OUTPUT_ARM_SEPARATOR,
244
244
  OUTPUT_ARM_SOURCES: () => OUTPUT_ARM_SOURCES,
245
245
  OUTPUT_CALL_SEPARATOR: () => OUTPUT_CALL_SEPARATOR,
246
+ OUTPUT_GROUP_MAPS: () => OUTPUT_GROUP_MAPS,
246
247
  OUTPUT_PAYLOADS: () => OUTPUT_PAYLOADS,
247
248
  PAGES_ROOT: () => PAGES_ROOT,
248
249
  PAGE_FILING: () => PAGE_FILING,
@@ -484,6 +485,7 @@ __export(index_exports, {
484
485
  caseLiteral: () => caseLiteral,
485
486
  caseLiteralValue: () => caseLiteralValue,
486
487
  casesFromJson: () => casesFromJson,
488
+ castTransform: () => castTransform,
487
489
  chainCall: () => chainCall,
488
490
  chainInputType: () => chainInputType,
489
491
  chainReturnType: () => chainReturnType,
@@ -498,6 +500,7 @@ __export(index_exports, {
498
500
  childNavId: () => childNavId,
499
501
  classCardScope: () => classCardScope,
500
502
  clearOutputCallRows: () => clearOutputCallRows,
503
+ clearOutputGroupRows: () => clearOutputGroupRows,
501
504
  coerceImgSrcOrigin: () => coerceImgSrcOrigin,
502
505
  collectCardEmits: () => collectCardEmits,
503
506
  collectComputedOptionSets: () => collectComputedOptionSets,
@@ -651,6 +654,7 @@ __export(index_exports, {
651
654
  emitOverlayFiles: () => emitOverlayFiles,
652
655
  emitShippedShellFiles: () => emitShippedShellFiles,
653
656
  emitTransformExpr: () => emitTransformExpr,
657
+ emittedDataType: () => emittedDataType,
654
658
  emittedFormIds: () => emittedFormIds,
655
659
  emittedOperation: () => emittedOperation,
656
660
  emittedResponse: () => emittedResponse,
@@ -693,6 +697,7 @@ __export(index_exports, {
693
697
  featureStoreFile: () => featureStoreFile,
694
698
  featureStoreProp: () => featureStoreProp,
695
699
  featureStorePropName: () => featureStorePropName,
700
+ featuresAsRead: () => featuresAsRead,
696
701
  featuresInReach: () => featuresInReach,
697
702
  fieldCanBeAbsent: () => fieldCanBeAbsent,
698
703
  fieldCheckArgParams: () => fieldCheckArgParams,
@@ -729,6 +734,7 @@ __export(index_exports, {
729
734
  fixedItems: () => fixedItems,
730
735
  fnv64: () => fnv64,
731
736
  foldedButtonName: () => foldedButtonName,
737
+ foldedButtonNames: () => foldedButtonNames,
732
738
  foldedButtons: () => foldedButtons,
733
739
  foldedRouterLink: () => foldedRouterLink,
734
740
  formEventMembers: () => formEventMembers,
@@ -987,6 +993,7 @@ __export(index_exports, {
987
993
  isUnaryOutputArmOperator: () => isUnaryOutputArmOperator,
988
994
  isUsableTranslation: () => isUsableTranslation,
989
995
  isValidAssetPath: () => isValidAssetPath,
996
+ isValidControlGroupCategory: () => isValidControlGroupCategory,
990
997
  isValidControlGroupName: () => isValidControlGroupName,
991
998
  isValidFormName: () => isValidFormName,
992
999
  isValidFunctionName: () => isValidFunctionName,
@@ -1010,10 +1017,12 @@ __export(index_exports, {
1010
1017
  isVariantJoin: () => isVariantJoin,
1011
1018
  isVariantKind: () => isVariantKind,
1012
1019
  jsNativesInGroup: () => jsNativesInGroup,
1020
+ keptNodeId: () => keptNodeId,
1013
1021
  keyCandidates: () => keyCandidates,
1014
1022
  keyIdKeeper: () => keyIdKeeper,
1015
1023
  labelChainOf: () => labelChainOf,
1016
1024
  labelEmission: () => labelEmission,
1025
+ labelHeadType: () => labelHeadType,
1017
1026
  labelReadIsTranslated: () => labelReadIsTranslated,
1018
1027
  landingNavId: () => landingNavId,
1019
1028
  landsOn: () => landsOn,
@@ -1304,6 +1313,7 @@ __export(index_exports, {
1304
1313
  pathChipDisplay: () => pathChipDisplay,
1305
1314
  pathCrossesCollection: () => pathCrossesCollection,
1306
1315
  pathDisplay: () => pathDisplay,
1316
+ pathLeafEnumId: () => pathLeafEnumId,
1307
1317
  pathLeafType: () => pathLeafType,
1308
1318
  pathsFor: () => pathsFor,
1309
1319
  payloadEventRoot: () => payloadEventRoot,
@@ -1446,6 +1456,7 @@ __export(index_exports, {
1446
1456
  ruleReferencedIds: () => ruleReferencedIds,
1447
1457
  ruleRootProperties: () => ruleRootProperties,
1448
1458
  sameCallTarget: () => sameCallTarget,
1459
+ sameFeaturesAsRead: () => sameFeaturesAsRead,
1449
1460
  sameOrigin: () => sameOrigin,
1450
1461
  sameOwner: () => sameOwner,
1451
1462
  sampleRows: () => sampleRows,
@@ -1591,6 +1602,7 @@ __export(index_exports, {
1591
1602
  slugifyMessage: () => slugifyMessage,
1592
1603
  sortRowEnumId: () => sortRowEnumId,
1593
1604
  sourceCarriesTrackKey: () => sourceCarriesTrackKey,
1605
+ stableId: () => stableId,
1594
1606
  staleCases: () => staleCases,
1595
1607
  staleMenuActionItems: () => staleMenuActionItems,
1596
1608
  stampStatePropertyEnums: () => stampStatePropertyEnums,
@@ -1757,14 +1769,20 @@ __export(index_exports, {
1757
1769
  withCases: () => withCases,
1758
1770
  withDefaultRow: () => withDefaultRow,
1759
1771
  withEmittedTests: () => withEmittedTests,
1772
+ withEventTransform: () => withEventTransform,
1760
1773
  withFormShapes: () => withFormShapes,
1761
1774
  withListRowShape: () => withListRowShape,
1775
+ withPropertyEnums: () => withPropertyEnums,
1762
1776
  withScreenEnums: () => withScreenEnums,
1763
1777
  withScreenMethodCallSites: () => withScreenMethodCallSites,
1764
1778
  withVariableEnums: () => withVariableEnums,
1765
1779
  wouldComputedCycle: () => wouldComputedCycle,
1766
1780
  wouldCycle: () => wouldCycle,
1767
1781
  wouldScreenComputedCycle: () => wouldScreenComputedCycle,
1782
+ writeEventIssue: () => writeEventIssue,
1783
+ writeEventMismatch: () => writeEventMismatch,
1784
+ writeEventReadType: () => writeEventReadType,
1785
+ writeEventTransforms: () => writeEventTransforms,
1768
1786
  writeFileAt: () => writeFileAt,
1769
1787
  writeIdIn: () => writeIdIn,
1770
1788
  writeIdOf: () => writeIdOf,
@@ -1812,9 +1830,9 @@ var ControlType = /* @__PURE__ */ ((ControlType2) => {
1812
1830
  ControlType2["HEAT_SWATCH"] = "heat_swatch";
1813
1831
  ControlType2["SCORE_SET"] = "score_set";
1814
1832
  ControlType2["SCORE_SET_ITEM"] = "score_set_item";
1815
- ControlType2["PRICE_LADDER"] = "price_ladder";
1816
- ControlType2["PRICE_LADDER_MARK"] = "price_ladder_mark";
1817
- ControlType2["PRICE_LADDER_SIGNAL"] = "price_ladder_signal";
1833
+ ControlType2["SCALE"] = "scale";
1834
+ ControlType2["SCALE_MARK"] = "scale_mark";
1835
+ ControlType2["SCALE_RELATION"] = "scale_relation";
1818
1836
  ControlType2["FORM"] = "form";
1819
1837
  ControlType2["FIELD"] = "field";
1820
1838
  ControlType2["SECTION_BUTTON_GROUP"] = "section_button_group";
@@ -2004,6 +2022,17 @@ var actionRenderIds = (node) => {
2004
2022
  const entries = actionButtonEntries(node);
2005
2023
  return entries.length ? Object.fromEntries(entries.map(([name3, button]) => [name3, button.id])) : void 0;
2006
2024
  };
2025
+ var foldedButtonNames = (tree) => {
2026
+ const names = /* @__PURE__ */ new Map();
2027
+ const walk = (nodes) => nodes.forEach((node) => {
2028
+ actionButtonEntries(node).forEach(
2029
+ ([name3, button]) => names.set(button.id, name3)
2030
+ );
2031
+ walk(node.childrens);
2032
+ });
2033
+ walk(tree);
2034
+ return names;
2035
+ };
2007
2036
  var actionButtonEntries = (node) => {
2008
2037
  const counts = /* @__PURE__ */ new Map();
2009
2038
  const taken = /* @__PURE__ */ new Set();
@@ -2288,6 +2317,24 @@ function genId() {
2288
2317
  return v.toString(16);
2289
2318
  });
2290
2319
  }
2320
+ function stableId(seed) {
2321
+ const lane = (offset) => {
2322
+ let hash = offset;
2323
+ for (let i = 0; i < seed.length; i++) {
2324
+ hash ^= seed.charCodeAt(i);
2325
+ hash = Math.imul(hash, 16777619) >>> 0;
2326
+ }
2327
+ return hash.toString(16).padStart(8, "0");
2328
+ };
2329
+ const hex = [2166136261, 16777619, 84696351, 1802464869].map(lane).join("");
2330
+ return [
2331
+ hex.slice(0, 8),
2332
+ hex.slice(8, 12),
2333
+ `5${hex.slice(13, 16)}`,
2334
+ `${(parseInt(hex[16], 16) & 3 | 8).toString(16)}${hex.slice(17, 20)}`,
2335
+ hex.slice(20, 32)
2336
+ ].join("-");
2337
+ }
2291
2338
 
2292
2339
  // libs/codegen/src/lib/state-shape-helper.ts
2293
2340
  function normalizeShapeName(raw) {
@@ -2693,7 +2740,7 @@ var formFileBase = (formName) => `${formName.replace(/_/g, "-")}-form`;
2693
2740
  function tsTypeExpression(shapes, dataType, cardinality, actionEnumName = () => void 0) {
2694
2741
  const shapeKey = shapeKeyOf(dataType);
2695
2742
  const interfaceNameOf = dataType?.type === "form" ? formInterfaceName : shapeInterfaceName;
2696
- const enumId = dataType?.actionEnumId ?? dataType?.sortEnumId;
2743
+ const enumId = enumIdOf(dataType);
2697
2744
  const enumName = enumId ? actionEnumName(enumId) : void 0;
2698
2745
  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";
2699
2746
  const named = element || "unknown";
@@ -3256,7 +3303,7 @@ var mountSegmentOf = (token) => {
3256
3303
  return kind ? { kind } : { kind: "static", value: token };
3257
3304
  };
3258
3305
  var mountTokenOf = (segment) => segment.kind === "static" ? (segment.value ?? "").trim() : MOUNT_TOKEN[segment.kind];
3259
- var parseMountPattern = (text2) => text2.split("/").map((t) => t.trim()).filter(Boolean).map(mountSegmentOf);
3306
+ var parseMountPattern = (text3) => text3.split("/").map((t) => t.trim()).filter(Boolean).map(mountSegmentOf);
3260
3307
  var mountPatternText = (pattern) => pattern.map(mountTokenOf).join("/");
3261
3308
  var mountPatternProblem = (pattern) => {
3262
3309
  const navUrls = pattern.filter((s) => s.kind === "navUrl").length;
@@ -3273,6 +3320,105 @@ var mountPatternProblem = (pattern) => {
3273
3320
  return void 0;
3274
3321
  };
3275
3322
 
3323
+ // libs/one/src/lib/shared/ui/scale/lib/price-relations.ts
3324
+ var compare = (key2, left, op, right, more = {}) => ({
3325
+ key: key2,
3326
+ ...more.hidden ? {} : { label: key2 },
3327
+ tone: more.tone ?? "neutral",
3328
+ type: "compare",
3329
+ left,
3330
+ op,
3331
+ rightKind: more.pct === void 0 ? "mark" : "pct",
3332
+ right,
3333
+ ...more.pct === void 0 ? {} : { rightValue: more.pct },
3334
+ ...more.n === void 0 ? {} : { n: more.n },
3335
+ ...more.hidden ? { hidden: true } : {},
3336
+ ...more.bracket ? { bracket: true } : {}
3337
+ });
3338
+ var combine = (key2, mode, of, tone = "neutral", hidden = false) => ({
3339
+ key: key2,
3340
+ ...hidden ? {} : { label: key2 },
3341
+ tone,
3342
+ type: "combine",
3343
+ mode,
3344
+ of,
3345
+ ...hidden ? { hidden: true } : {}
3346
+ });
3347
+ var SMAS = ["sma10", "sma50", "sma100", "sma200"];
3348
+ var CONVERGING = SMAS.flatMap((a) => SMAS.filter((b) => b !== a).map((b) => `${a}-under-103-of-${b}`));
3349
+ var PRICE_RULES = [
3350
+ compare("golden-cross", "sma50", "gte", "sma200", { tone: "gold", bracket: true }),
3351
+ compare("death-cross", "sma50", "lt", "sma200", { tone: "down", bracket: true }),
3352
+ combine("death-cross-near", "all", ["golden-cross", "cross-near"], "down"),
3353
+ combine("golden-cross-near", "all", ["death-cross", "cross-near"], "gold"),
3354
+ combine("bullish-alignment", "all", ["above-sma10", "sma10-above-sma50", "sma50-above-sma100", "sma100-above-sma200"], "up"),
3355
+ combine("bearish-alignment", "all", ["below-sma10", "sma10-below-sma50", "sma50-below-sma100", "sma100-below-sma200"], "down"),
3356
+ combine("strongly-bullish", "all", ["above-sma50", "above-sma200"], "up"),
3357
+ combine("bullish-support", "all", ["not-above-sma50", "above-sma200"], "up"),
3358
+ combine("recovering", "all", ["above-sma50", "not-above-sma200"]),
3359
+ combine("bearish-pressure", "all", ["not-above-sma50", "not-above-sma200"], "down"),
3360
+ compare("stretched", "current", "gt", "sma200", { tone: "warn", pct: 120 }),
3361
+ compare("far-below-sma-200", "current", "lt", "sma200", { tone: "down", pct: 80 }),
3362
+ combine("averages-converging", "all", CONVERGING, "warn"),
3363
+ compare("52w-breakout", "current", "gte", "high52w", { tone: "up" }),
3364
+ combine("near-52w-high", "all", ["below-52w-high", "within-3-of-52w-high"], "up"),
3365
+ compare("new-52w-low", "current", "lte", "low52w", { tone: "down" }),
3366
+ combine("near-52w-low", "all", ["above-52w-low", "within-3-of-52w-low"], "down"),
3367
+ combine("forecast-against-trend", "any", ["against-up", "against-down"], "warn"),
3368
+ compare("forecast-above-52w-high", "forecast", "gt", "high52w")
3369
+ ];
3370
+ var PRICE_HELPERS = [
3371
+ compare("cross-near", "sma50", "within", "sma200", { n: 1, hidden: true }),
3372
+ compare("above-sma10", "current", "gt", "sma10", { hidden: true }),
3373
+ compare("sma10-above-sma50", "sma10", "gt", "sma50", { hidden: true }),
3374
+ compare("sma50-above-sma100", "sma50", "gt", "sma100", { hidden: true }),
3375
+ compare("sma100-above-sma200", "sma100", "gt", "sma200", { hidden: true }),
3376
+ compare("below-sma10", "current", "lt", "sma10", { hidden: true }),
3377
+ compare("sma10-below-sma50", "sma10", "lt", "sma50", { hidden: true }),
3378
+ compare("sma50-below-sma100", "sma50", "lt", "sma100", { hidden: true }),
3379
+ compare("sma100-below-sma200", "sma100", "lt", "sma200", { hidden: true }),
3380
+ compare("above-sma50", "current", "gt", "sma50", { hidden: true }),
3381
+ compare("above-sma200", "current", "gt", "sma200", { hidden: true }),
3382
+ compare("not-above-sma50", "current", "lte", "sma50", { hidden: true }),
3383
+ compare("not-above-sma200", "current", "lte", "sma200", { hidden: true }),
3384
+ ...SMAS.flatMap(
3385
+ (a) => SMAS.filter((b) => b !== a).map((b) => compare(`${a}-under-103-of-${b}`, a, "lt", b, { pct: 103, hidden: true }))
3386
+ ),
3387
+ compare("below-52w-high", "current", "lt", "high52w", { hidden: true }),
3388
+ // gap(high, current) < 3% ⇔ current > high / 1.03.
3389
+ compare("within-3-of-52w-high", "current", "gt", "high52w", { pct: 100 / 1.03, hidden: true }),
3390
+ compare("above-52w-low", "current", "gt", "low52w", { hidden: true }),
3391
+ compare("within-3-of-52w-low", "current", "lt", "low52w", { pct: 103, hidden: true }),
3392
+ compare("forecast-up", "forecast", "gt", "current", { hidden: true }),
3393
+ compare("forecast-down", "forecast", "lt", "current", { hidden: true }),
3394
+ combine("bear-trend", "any", ["death-cross", "bearish-alignment"], "neutral", true),
3395
+ combine("bull-trend", "any", ["golden-cross", "bullish-alignment"], "neutral", true),
3396
+ combine("against-up", "all", ["forecast-up", "bear-trend"], "neutral", true),
3397
+ combine("against-down", "all", ["forecast-down", "bull-trend"], "neutral", true)
3398
+ ];
3399
+ var BY_KEY = new Map([...PRICE_RULES, ...PRICE_HELPERS].map((r) => [r.key, r]));
3400
+ var isPriceRule = (name3) => typeof name3 === "string" && PRICE_RULES.some((r) => r.key === name3);
3401
+ var asHidden = (relation) => {
3402
+ const rest = { ...relation };
3403
+ delete rest.label;
3404
+ delete rest.bracket;
3405
+ return { ...rest, hidden: true };
3406
+ };
3407
+ var priceRelationsFor = (rules) => {
3408
+ const asked = new Set(rules);
3409
+ const out = /* @__PURE__ */ new Map();
3410
+ const visit = (key2) => {
3411
+ const relation = BY_KEY.get(key2);
3412
+ if (!relation || out.has(key2)) return;
3413
+ out.set(key2, asked.has(key2) ? relation : asHidden(relation));
3414
+ for (const k of relation.of ?? []) visit(k);
3415
+ };
3416
+ rules.forEach((key2) => BY_KEY.has(key2) && !out.has(key2) && out.set(key2, BY_KEY.get(key2)));
3417
+ for (const key2 of rules) for (const k of BY_KEY.get(key2)?.of ?? []) visit(k);
3418
+ return [...out.values()];
3419
+ };
3420
+ var PRICE_SCALE_RELATIONS = priceRelationsFor(PRICE_RULES.map((r) => r.key));
3421
+
3276
3422
  // libs/codegen/src/lib/content-slot.ts
3277
3423
  var contentSlotOf = (control) => {
3278
3424
  if (isCardHolder(control) || control?.type === "list" /* LIST */) {
@@ -3359,7 +3505,7 @@ var CONTROL_RELATIONSHIPS = {
3359
3505
  ["section_search" /* SECTION_SEARCH */]: ["section_header_label" /* SECTION_HEADER_LABEL */],
3360
3506
  // Its label slot and nothing else — the SectionHeader's title slot, caught
3361
3507
  // by the footer's unselected `ng-content`. Everything else a footer is
3362
- // (`sticky`, `align`) is a setting rather than a child.
3508
+ // (`sticky`, `align`, `fullWidth`) is a setting rather than a child.
3363
3509
  ["section_footer" /* SECTION_FOOTER */]: ["section_header_label" /* SECTION_HEADER_LABEL */],
3364
3510
  // Buttons and nothing else — and unlike the SectionButtonGroup it looks like,
3365
3511
  // they are *consumed* rather than projected: an `m-action` renders raw
@@ -3408,7 +3554,7 @@ var CONTROL_RELATIONSHIPS = {
3408
3554
  "stat" /* STAT */,
3409
3555
  "heat_swatch" /* HEAT_SWATCH */,
3410
3556
  "score_set" /* SCORE_SET */,
3411
- "price_ladder" /* PRICE_LADDER */,
3557
+ "scale" /* SCALE */,
3412
3558
  "flex" /* FLEX */,
3413
3559
  "card" /* CARD */,
3414
3560
  "chat_bubble" /* CHAT_BUBBLE */,
@@ -3474,7 +3620,7 @@ var CONTROL_RELATIONSHIPS = {
3474
3620
  "stat" /* STAT */,
3475
3621
  "heat_swatch" /* HEAT_SWATCH */,
3476
3622
  "score_set" /* SCORE_SET */,
3477
- "price_ladder" /* PRICE_LADDER */,
3623
+ "scale" /* SCALE */,
3478
3624
  "flex" /* FLEX */,
3479
3625
  "card" /* CARD */,
3480
3626
  "chat_bubble" /* CHAT_BUBBLE */,
@@ -3501,7 +3647,7 @@ var CONTROL_RELATIONSHIPS = {
3501
3647
  "stat" /* STAT */,
3502
3648
  "heat_swatch" /* HEAT_SWATCH */,
3503
3649
  "score_set" /* SCORE_SET */,
3504
- "price_ladder" /* PRICE_LADDER */,
3650
+ "scale" /* SCALE */,
3505
3651
  "flex" /* FLEX */,
3506
3652
  "card" /* CARD */,
3507
3653
  "chat_bubble" /* CHAT_BUBBLE */,
@@ -3536,7 +3682,7 @@ var CONTROL_RELATIONSHIPS = {
3536
3682
  "stat" /* STAT */,
3537
3683
  "heat_swatch" /* HEAT_SWATCH */,
3538
3684
  "score_set" /* SCORE_SET */,
3539
- "price_ladder" /* PRICE_LADDER */,
3685
+ "scale" /* SCALE */,
3540
3686
  "flex" /* FLEX */,
3541
3687
  "card" /* CARD */,
3542
3688
  "chat_bubble" /* CHAT_BUBBLE */,
@@ -3575,7 +3721,7 @@ var CONTROL_RELATIONSHIPS = {
3575
3721
  "stat" /* STAT */,
3576
3722
  "heat_swatch" /* HEAT_SWATCH */,
3577
3723
  "score_set" /* SCORE_SET */,
3578
- "price_ladder" /* PRICE_LADDER */,
3724
+ "scale" /* SCALE */,
3579
3725
  "card" /* CARD */,
3580
3726
  "chat_bubble" /* CHAT_BUBBLE */,
3581
3727
  "section_carousel" /* SECTION_CAROUSEL */,
@@ -3610,7 +3756,7 @@ var CONTROL_RELATIONSHIPS = {
3610
3756
  "stat" /* STAT */,
3611
3757
  "heat_swatch" /* HEAT_SWATCH */,
3612
3758
  "score_set" /* SCORE_SET */,
3613
- "price_ladder" /* PRICE_LADDER */,
3759
+ "scale" /* SCALE */,
3614
3760
  "card" /* CARD */,
3615
3761
  "chat_bubble" /* CHAT_BUBBLE */,
3616
3762
  "section_carousel" /* SECTION_CAROUSEL */,
@@ -3677,7 +3823,7 @@ var CONTROL_RELATIONSHIPS = {
3677
3823
  "user" /* USER */,
3678
3824
  "heat_swatch" /* HEAT_SWATCH */,
3679
3825
  "score_set" /* SCORE_SET */,
3680
- "price_ladder" /* PRICE_LADDER */,
3826
+ "scale" /* SCALE */,
3681
3827
  "button" /* BUTTON */,
3682
3828
  "context_menu" /* CONTEXT_MENU */,
3683
3829
  "audience_picker" /* AUDIENCE_PICKER */,
@@ -3763,16 +3909,12 @@ var CONTROL_RELATIONSHIPS = {
3763
3909
  ["score_set" /* SCORE_SET */]: ["score_set_item" /* SCORE_SET_ITEM */],
3764
3910
  // A leaf: an item renders nothing of its own.
3765
3911
  ["score_set_item" /* SCORE_SET_ITEM */]: [],
3766
- // Its levels and chips and nothing else — every other setting is an
3767
- // attribute (libs/one GLOSSARY.md PriceLadder). Dropped empty; the Canvas
3768
- // lists each child as a row so it can be named and picked.
3769
- ["price_ladder" /* PRICE_LADDER */]: [
3770
- "price_ladder_mark" /* PRICE_LADDER_MARK */,
3771
- "price_ladder_signal" /* PRICE_LADDER_SIGNAL */
3772
- ],
3773
- // Leaves: the ladder draws both.
3774
- ["price_ladder_mark" /* PRICE_LADDER_MARK */]: [],
3775
- ["price_ladder_signal" /* PRICE_LADDER_SIGNAL */]: [],
3912
+ // Its marks and relations and nothing else — every other setting is an
3913
+ // attribute (libs/one GLOSSARY.md Scale).
3914
+ ["scale" /* SCALE */]: ["scale_mark" /* SCALE_MARK */, "scale_relation" /* SCALE_RELATION */],
3915
+ // Leaves: the scale draws both.
3916
+ ["scale_mark" /* SCALE_MARK */]: [],
3917
+ ["scale_relation" /* SCALE_RELATION */]: [],
3776
3918
  // Content like a Logo, but the one content Control that is not a leaf: what
3777
3919
  // `m-user` projects beneath the name is a ContentControl, the same single
3778
3920
  // child a card Field takes and gated the same way, through `contentSlotOf`.
@@ -4016,9 +4158,9 @@ var OWN_DIRECTIVES = {
4016
4158
  ["heat_swatch" /* HEAT_SWATCH */]: ["routerLink"],
4017
4159
  ["score_set" /* SCORE_SET */]: [],
4018
4160
  ["score_set_item" /* SCORE_SET_ITEM */]: [],
4019
- ["price_ladder" /* PRICE_LADDER */]: [],
4020
- ["price_ladder_mark" /* PRICE_LADDER_MARK */]: [],
4021
- ["price_ladder_signal" /* PRICE_LADDER_SIGNAL */]: [],
4161
+ ["scale" /* SCALE */]: [],
4162
+ ["scale_mark" /* SCALE_MARK */]: [],
4163
+ ["scale_relation" /* SCALE_RELATION */]: [],
4022
4164
  ["form" /* FORM */]: ["routerLink"],
4023
4165
  ["field" /* FIELD */]: ["mOptions", "routerLink"],
4024
4166
  // Nothing to attach: a ContentControl emits an `ng-template` — where a
@@ -4190,9 +4332,9 @@ var CONTROL_LABEL = {
4190
4332
  ["heat_swatch" /* HEAT_SWATCH */]: "heat-swatch",
4191
4333
  ["score_set" /* SCORE_SET */]: "score-set-control",
4192
4334
  ["score_set_item" /* SCORE_SET_ITEM */]: "score-set-item-control",
4193
- ["price_ladder" /* PRICE_LADDER */]: "price-ladder-control",
4194
- ["price_ladder_mark" /* PRICE_LADDER_MARK */]: "price-ladder-mark-control",
4195
- ["price_ladder_signal" /* PRICE_LADDER_SIGNAL */]: "price-ladder-signal-control",
4335
+ ["scale" /* SCALE */]: "scale-control",
4336
+ ["scale_mark" /* SCALE_MARK */]: "scale-mark-control",
4337
+ ["scale_relation" /* SCALE_RELATION */]: "scale-relation-control",
4196
4338
  ["nav_header" /* NAV_HEADER */]: "nav-header",
4197
4339
  ["form" /* FORM */]: "form",
4198
4340
  ["field" /* FIELD */]: "field",
@@ -4266,9 +4408,9 @@ var CONTROL_ICON = {
4266
4408
  ["score_set" /* SCORE_SET */]: "control_stat",
4267
4409
  ["score_set_item" /* SCORE_SET_ITEM */]: "control_stat_value",
4268
4410
  // Reuse the Stat glyphs until ladder artwork joins the shared set.
4269
- ["price_ladder" /* PRICE_LADDER */]: "control_stat",
4270
- ["price_ladder_mark" /* PRICE_LADDER_MARK */]: "control_stat_value",
4271
- ["price_ladder_signal" /* PRICE_LADDER_SIGNAL */]: "control_stat_corner",
4411
+ ["scale" /* SCALE */]: "control_stat",
4412
+ ["scale_mark" /* SCALE_MARK */]: "control_stat_value",
4413
+ ["scale_relation" /* SCALE_RELATION */]: "control_stat_corner",
4272
4414
  ["nav_header" /* NAV_HEADER */]: "control_nav_header",
4273
4415
  ["form" /* FORM */]: "control_form",
4274
4416
  ["field" /* FIELD */]: "control_field",
@@ -4326,8 +4468,9 @@ var CONTROL_CODEGEN = {
4326
4468
  tag: "m-section-header",
4327
4469
  component: "SectionHeaderComponent"
4328
4470
  },
4329
- // Folderless for the section_header's reason — `sticky` and `align` are its
4330
- // only settings, both scalars, and its text is the projected label slot.
4471
+ // Folderless for the section_header's reason — `sticky`, `align` and
4472
+ // `fullWidth` are its only settings, all scalars, and its text is the
4473
+ // projected label slot.
4331
4474
  ["section_footer" /* SECTION_FOOTER */]: {
4332
4475
  tag: "m-section-footer",
4333
4476
  component: "SectionFooterComponent"
@@ -4545,18 +4688,12 @@ var CONTROL_CODEGEN = {
4545
4688
  tag: "m-score-set-item",
4546
4689
  component: "ScoreSetItemComponent"
4547
4690
  },
4548
- // Folderless for the ScoreSet's reason (libs/one GLOSSARY.md PriceLadder).
4549
- ["price_ladder" /* PRICE_LADDER */]: {
4550
- tag: "m-price-ladder",
4551
- component: "PriceLadderComponent"
4552
- },
4553
- ["price_ladder_mark" /* PRICE_LADDER_MARK */]: {
4554
- tag: "m-price-ladder-mark",
4555
- component: "PriceLadderMarkComponent"
4556
- },
4557
- ["price_ladder_signal" /* PRICE_LADDER_SIGNAL */]: {
4558
- tag: "m-price-ladder-signal",
4559
- component: "PriceLadderSignalComponent"
4691
+ // Folderless for the ScoreSet's reason (libs/one GLOSSARY.md Scale).
4692
+ ["scale" /* SCALE */]: { tag: "m-scale", component: "ScaleComponent" },
4693
+ ["scale_mark" /* SCALE_MARK */]: { tag: "m-scale-mark", component: "ScaleMarkComponent" },
4694
+ ["scale_relation" /* SCALE_RELATION */]: {
4695
+ tag: "m-scale-relation",
4696
+ component: "ScaleRelationComponent"
4560
4697
  },
4561
4698
  // Navigation header with back button and breadcrumb trail.
4562
4699
  // Folderless as it uses NavStore internally and takes no config.
@@ -4942,156 +5079,83 @@ var ONE_FUNCTION_ID_PARAM = "id";
4942
5079
  var ONE_FUNCTION_MAP_PARAM = "map";
4943
5080
  var ONE_FUNCTION_DATA_PARAM = "data";
4944
5081
  var ONE_FUNCTION_PREFIX = "one:";
5082
+ var signatureParam = (param, row) => ({
5083
+ id: param.id,
5084
+ name: param.name,
5085
+ dataType: param.rule === "string-one" ? { type: "string" } : row,
5086
+ cardinality: param.rule === "map-path" ? "map" : "one",
5087
+ acceptsUndefined: true
5088
+ });
5089
+ var defineOneFunction = (spec) => {
5090
+ const { returns, ...entry2 } = spec;
5091
+ return {
5092
+ ...entry2,
5093
+ importFrom: ONE_IMPORT_MODULE,
5094
+ returnsRow: returns !== "boolean",
5095
+ signature: (row) => ({
5096
+ params: entry2.params.map((param) => signatureParam(param, row)),
5097
+ ...returns === "boolean" ? { returnType: { type: "boolean" }, returnCardinality: "one" } : returns === "row" ? { returnType: row, returnCardinality: "one", returnUndefined: true } : { returnType: row, returnCardinality: "map" }
5098
+ })
5099
+ };
5100
+ };
4945
5101
  var ONE_FUNCTIONS = [
4946
- {
4947
- // `getFromMap<T>(id, map: Record<string, T>): T | undefined` — the row a
4948
- // `map` holds under an id, typically a ScreenInput a Page was handed.
5102
+ // `getFromMap<T>(id, map: Record<string, T>): T | undefined` — the row a
5103
+ // `map` holds under an id, typically a ScreenInput a Page was handed.
5104
+ defineOneFunction({
4949
5105
  name: "getFromMap",
4950
- importFrom: ONE_IMPORT_MODULE,
4951
5106
  reach: ["screen-computed"],
4952
- returnsRow: true,
5107
+ returns: "row",
4953
5108
  params: [
4954
5109
  { id: ONE_FUNCTION_ID_PARAM, name: "id", rule: "string-one" },
4955
5110
  { id: ONE_FUNCTION_MAP_PARAM, name: "map", rule: "map-path" }
4956
5111
  ],
4957
5112
  rowParamId: ONE_FUNCTION_MAP_PARAM,
4958
- rowCardinality: "map",
4959
- signature: (row) => ({
4960
- params: [
4961
- {
4962
- id: ONE_FUNCTION_ID_PARAM,
4963
- name: "id",
4964
- dataType: { type: "string" },
4965
- cardinality: "one",
4966
- acceptsUndefined: true
4967
- },
4968
- {
4969
- id: ONE_FUNCTION_MAP_PARAM,
4970
- name: "map",
4971
- dataType: row,
4972
- cardinality: "map",
4973
- acceptsUndefined: true
4974
- }
4975
- ],
4976
- returnType: row,
4977
- returnCardinality: "one",
4978
- returnUndefined: true
4979
- })
4980
- },
4981
- {
4982
- // `existsInMap(id, map: Record<string, unknown>): boolean` — whether a
4983
- // `map` holds anything under an id (ADR 0202). `false` rather than
4984
- // `undefined` while either is, so a gate on an unloaded store reads "not
4985
- // there yet" and a computed over it never needs `?.`.
5113
+ rowCardinality: "map"
5114
+ }),
5115
+ // `existsInMap(id, map: Record<string, unknown>): boolean` — whether a
5116
+ // `map` holds anything under an id (ADR 0202). `false` rather than
5117
+ // `undefined` while either is, so a gate on an unloaded store reads "not
5118
+ // there yet" and a computed over it never needs `?.`.
5119
+ defineOneFunction({
4986
5120
  name: "existsInMap",
4987
- importFrom: ONE_IMPORT_MODULE,
4988
5121
  reach: ["screen-computed", "call-condition"],
4989
- returnsRow: false,
5122
+ returns: "boolean",
4990
5123
  params: [
4991
5124
  { id: ONE_FUNCTION_ID_PARAM, name: "id", rule: "string-one" },
4992
5125
  { id: ONE_FUNCTION_MAP_PARAM, name: "map", rule: "map-path" }
4993
5126
  ],
4994
5127
  rowParamId: ONE_FUNCTION_MAP_PARAM,
4995
- rowCardinality: "map",
4996
- signature: (row) => ({
4997
- params: [
4998
- {
4999
- id: ONE_FUNCTION_ID_PARAM,
5000
- name: "id",
5001
- dataType: { type: "string" },
5002
- cardinality: "one",
5003
- acceptsUndefined: true
5004
- },
5005
- {
5006
- id: ONE_FUNCTION_MAP_PARAM,
5007
- name: "map",
5008
- dataType: row,
5009
- cardinality: "map",
5010
- acceptsUndefined: true
5011
- }
5012
- ],
5013
- returnType: { type: "boolean" },
5014
- returnCardinality: "one"
5015
- })
5016
- },
5017
- {
5018
- // `notExistsInMap(id, map: Record<string, unknown>): boolean` — the
5019
- // named inverse, offered on CallConditions (ADR 0202).
5128
+ rowCardinality: "map"
5129
+ }),
5130
+ // `notExistsInMap(id, map: Record<string, unknown>): boolean` — the
5131
+ // named inverse, offered on CallConditions (ADR 0202).
5132
+ defineOneFunction({
5020
5133
  name: "notExistsInMap",
5021
- importFrom: ONE_IMPORT_MODULE,
5022
5134
  reach: ["call-condition"],
5023
- returnsRow: false,
5135
+ returns: "boolean",
5024
5136
  params: [
5025
5137
  { id: ONE_FUNCTION_ID_PARAM, name: "id", rule: "string-one" },
5026
5138
  { id: ONE_FUNCTION_MAP_PARAM, name: "map", rule: "map-path" }
5027
5139
  ],
5028
5140
  rowParamId: ONE_FUNCTION_MAP_PARAM,
5029
- rowCardinality: "map",
5030
- signature: (row) => ({
5031
- params: [
5032
- {
5033
- id: ONE_FUNCTION_ID_PARAM,
5034
- name: "id",
5035
- dataType: { type: "string" },
5036
- cardinality: "one",
5037
- acceptsUndefined: true
5038
- },
5039
- {
5040
- id: ONE_FUNCTION_MAP_PARAM,
5041
- name: "map",
5042
- dataType: row,
5043
- cardinality: "map",
5044
- acceptsUndefined: true
5045
- }
5046
- ],
5047
- returnType: { type: "boolean" },
5048
- returnCardinality: "one"
5049
- })
5050
- },
5051
- {
5052
- // `setInMap<T>(id, data: T, map: Record<string, T>): Record<string, T>` —
5053
- // the map with `data` held under `id`, every other entry kept (ADR 0205).
5054
- // `loadCoin(id)` answers one coin and `coinsById[id]` is where it lands.
5055
- // Offered on an OutcomeTransform alone, where the landing names `T`.
5141
+ rowCardinality: "map"
5142
+ }),
5143
+ // `setInMap<T>(id, data: T, map: Record<string, T>): Record<string, T>` —
5144
+ // the map with `data` held under `id`, every other entry kept (ADR 0205).
5145
+ // `loadCoin(id)` answers one coin and `coinsById[id]` is where it lands.
5146
+ // Offered on an OutcomeTransform alone, where the landing names `T`.
5147
+ defineOneFunction({
5056
5148
  name: "setInMap",
5057
- importFrom: ONE_IMPORT_MODULE,
5058
5149
  reach: ["outcome-transform"],
5059
- returnsRow: true,
5150
+ returns: "row-map",
5060
5151
  params: [
5061
5152
  { id: ONE_FUNCTION_ID_PARAM, name: "id", rule: "string-one" },
5062
5153
  { id: ONE_FUNCTION_DATA_PARAM, name: "data", rule: "row-one" },
5063
5154
  { id: ONE_FUNCTION_MAP_PARAM, name: "map", rule: "map-path" }
5064
5155
  ],
5065
5156
  rowParamId: ONE_FUNCTION_DATA_PARAM,
5066
- rowCardinality: "one",
5067
- signature: (row) => ({
5068
- params: [
5069
- {
5070
- id: ONE_FUNCTION_ID_PARAM,
5071
- name: "id",
5072
- dataType: { type: "string" },
5073
- cardinality: "one",
5074
- acceptsUndefined: true
5075
- },
5076
- {
5077
- id: ONE_FUNCTION_DATA_PARAM,
5078
- name: "data",
5079
- dataType: row,
5080
- cardinality: "one",
5081
- acceptsUndefined: true
5082
- },
5083
- {
5084
- id: ONE_FUNCTION_MAP_PARAM,
5085
- name: "map",
5086
- dataType: row,
5087
- cardinality: "map",
5088
- acceptsUndefined: true
5089
- }
5090
- ],
5091
- returnType: row,
5092
- returnCardinality: "map"
5093
- })
5094
- }
5157
+ rowCardinality: "one"
5158
+ })
5095
5159
  ];
5096
5160
  var ONE_FUNCTION_CATALOG = Object.fromEntries(ONE_FUNCTIONS.map((entry2) => [entry2.name, entry2]));
5097
5161
  var oneFunctionOf = (name3) => name3 ? ONE_FUNCTIONS.find((entry2) => entry2.name === name3) : void 0;
@@ -5895,6 +5959,8 @@ function functionUsage(functionId, stateComputeds, screenComputeds, fieldCheckNa
5895
5959
  (mapping) => mapping.transform?.functionId === functionId
5896
5960
  ) || (method.computes ?? []).some(
5897
5961
  (compute) => compute.functionId === functionId
5962
+ ) || (method.persists ?? []).some(
5963
+ (persist) => persist.sourceKind === "function" && persist.transform?.functionId === functionId
5898
5964
  ) || (method.conditions ?? []).some(
5899
5965
  (condition) => condition.kind !== "check" && condition.functionId === functionId
5900
5966
  )
@@ -6646,6 +6712,15 @@ var outcomeTransformFunctionIds = (methods) => Array.from(
6646
6712
  ).sort();
6647
6713
 
6648
6714
  // libs/codegen/src/lib/value-transform-helper.ts
6715
+ var AUTO_CASTS = {
6716
+ string: { number: "Number", boolean: "Boolean" },
6717
+ number: { string: "String" }
6718
+ };
6719
+ function castTransform(from, to) {
6720
+ if (from.cardinality !== "one" || to.cardinality !== "one") return void 0;
6721
+ const cast = AUTO_CASTS[from.dataType.type]?.[to.dataType.type];
6722
+ return cast ? unaryCall(nativeTarget({ group: "number", name: cast }), 1) : void 0;
6723
+ }
6649
6724
  var SURFACE_LEAVES = {
6650
6725
  input: new Set(INPUT_TRANSFORM_LEAVES),
6651
6726
  "call-arg": new Set(CALL_ARG_TRANSFORM_LEAVES),
@@ -7289,11 +7364,7 @@ var BINDING_SLOT = {
7289
7364
  // A [ScoreSet]'s Score Date, named for the `m-score-set` input it lands on.
7290
7365
  // Content by the `total` test: whether the set reads stale *is* the datum's
7291
7366
  // age, read off the same record its Scores are.
7292
- scoreDate: "scoreDate",
7293
- // A [PriceLadder]'s forward estimate, named for the `m-price-ladder` input it
7294
- // lands on. Content by the `total` test: the forecast *is* the datum. The
7295
- // ladder's current price and a mark's level ride `value`.
7296
- target: "target"
7367
+ scoreDate: "scoreDate"
7297
7368
  };
7298
7369
  var USER_VALUE_SLOTS = [
7299
7370
  BINDING_SLOT.id,
@@ -7632,6 +7703,14 @@ var hop = (segment) => segment.position === void 0 ? `?.${segment.name}` : `?.[$
7632
7703
  var isPrimitiveType = (dataType) => dataType.type !== "shape" && dataType.type !== "form" && dataType.type !== "option";
7633
7704
  var seq = 0;
7634
7705
  var nodeId = () => `rn${seq += 1}`;
7706
+ var keptNodeId = (stored, taken) => {
7707
+ const match = typeof stored === "string" ? /^rn([1-9]\d*)$/.exec(stored) : null;
7708
+ const id = match && !taken.has(stored) ? stored : "";
7709
+ if (match && id) seq = Math.max(seq, Number(match[1]));
7710
+ const kept = id || nodeId();
7711
+ taken.add(kept);
7712
+ return kept;
7713
+ };
7635
7714
  var createCheck = () => ({
7636
7715
  id: nodeId(),
7637
7716
  kind: "check",
@@ -7698,7 +7777,12 @@ var pathCrossesCollection = (segments) => segments.some((segment) => segment.car
7698
7777
  function pathLeafType(segments) {
7699
7778
  const last = segments[segments.length - 1];
7700
7779
  if (!last || !isPrimitiveType(last.dataType)) return void 0;
7701
- return last.dataType.type;
7780
+ const type = last.dataType.type;
7781
+ return type === "string" || type === "number" || type === "boolean" ? type : void 0;
7782
+ }
7783
+ function pathLeafEnumId(segments) {
7784
+ const last = segments[segments.length - 1];
7785
+ return last?.dataType.type === "enum" ? last.dataType.enumId : void 0;
7702
7786
  }
7703
7787
  var canCount = (segments) => {
7704
7788
  const last = segments[segments.length - 1];
@@ -7736,8 +7820,9 @@ var STRING_OPERATORS = [
7736
7820
  var BOOLEAN_OPERATORS = ["==", "!="];
7737
7821
  var UNARY_OPERATORS = ["exists", "not_exists"];
7738
7822
  var isUnaryOperator = (operator) => UNARY_OPERATORS.includes(operator);
7739
- function operatorsFor(leaf, counted, resolved = false) {
7823
+ function operatorsFor(leaf, counted, resolved = false, enumLeaf = false) {
7740
7824
  if (counted) return NUMBER_OPERATORS;
7825
+ if (enumLeaf) return [...BOOLEAN_OPERATORS, ...UNARY_OPERATORS];
7741
7826
  if (leaf === "number") return [...NUMBER_OPERATORS, ...UNARY_OPERATORS];
7742
7827
  if (leaf === "boolean") return [...BOOLEAN_OPERATORS, ...UNARY_OPERATORS];
7743
7828
  if (leaf === "string") return [...STRING_OPERATORS, ...UNARY_OPERATORS];
@@ -7879,17 +7964,21 @@ function checkError(check, properties, shapes) {
7879
7964
  const counted = !!check.count;
7880
7965
  if (counted && !canCount(segments)) return "rule-path-not-leaf";
7881
7966
  const leaf = pathLeafType(segments);
7967
+ const enumId = counted ? void 0 : pathLeafEnumId(segments);
7882
7968
  const unary = isUnaryOperator(check.operator);
7883
- if (!counted && !leaf && !unary) return "rule-path-not-leaf";
7884
- if (!operatorsFor(leaf, counted, true).includes(check.operator))
7969
+ if (!counted && !leaf && !enumId && !unary) return "rule-path-not-leaf";
7970
+ if (!operatorsFor(leaf, counted, true, !!enumId).includes(check.operator))
7885
7971
  return "rule-operator-invalid";
7886
7972
  if (unary) return null;
7973
+ if (enumId && check.operand.kind === "literal") {
7974
+ return typeof check.operand.value === "string" && check.operand.value ? null : "rule-operand-missing";
7975
+ }
7887
7976
  if (check.operand.kind === "path") {
7888
7977
  const right = resolvePath(check.operand.path, properties, shapes);
7889
7978
  if (!check.operand.path.length || right.length !== check.operand.path.length)
7890
7979
  return "rule-operand-missing";
7891
7980
  if (pathCrossesCollection(right)) return "rule-operand-missing";
7892
- if (pathLeafType(right) !== operandType(leaf, counted))
7981
+ if (pathLeafType(right) !== operandType(leaf, counted) || pathLeafEnumId(right) !== enumId)
7893
7982
  return "rule-operand-missing";
7894
7983
  }
7895
7984
  return null;
@@ -7986,11 +8075,21 @@ function comparisonSource(left, operator, right) {
7986
8075
  if (operator === "not_contains") return `!${left}.includes(${right})`;
7987
8076
  return `${left} ${JS_OPERATOR[operator]} ${right}`;
7988
8077
  }
7989
- function generateCheckExpression(check, properties, shapes, prefix = "") {
8078
+ function enumMemberSource(check, segments, enums) {
8079
+ if (check.count || check.operand.kind !== "literal") return void 0;
8080
+ const enumId = pathLeafEnumId(segments);
8081
+ if (!enumId) return void 0;
8082
+ const appEnum = enums[enumId];
8083
+ const key2 = check.operand.value;
8084
+ return appEnum && appEnum.members.some((member) => member.key === key2) ? `${appEnum.name}.${key2}` : null;
8085
+ }
8086
+ function generateCheckExpression(check, properties, shapes, prefix = "", enums = {}) {
7990
8087
  const segments = resolvePath(check.path, properties, shapes);
7991
8088
  if (!segments.length) return "false";
7992
8089
  const unary = isUnaryOperator(check.operator);
7993
- const rawRight = unary ? "" : operandSource(check.operand, properties, shapes, prefix);
8090
+ const member = unary ? void 0 : enumMemberSource(check, segments, enums);
8091
+ if (member === null) return "false";
8092
+ const rawRight = unary ? "" : member ?? operandSource(check.operand, properties, shapes, prefix);
7994
8093
  const right = unary ? "" : check.operand.kind === "path" ? guardOptional(rawRight, check.operator) : rawRight;
7995
8094
  const leaf = (value, optional = false) => comparisonSource(
7996
8095
  // Unary asks about undefined itself, so the optional fallbacks that make
@@ -8048,12 +8147,12 @@ function generateFunctionExpression(leaf, properties, shapes, functions, prefix
8048
8147
  const call = `${fn.name}(${args.join(", ")})`;
8049
8148
  return guards.length ? `(${[...guards, call].join(" && ")})` : call;
8050
8149
  }
8051
- function generateRuleExpression(node, properties, shapes, top = true, prefix = "", callReceiver = "", functions = {}) {
8150
+ function generateRuleExpression(node, properties, shapes, top = true, prefix = "", callReceiver = "", functions = {}, enums = {}) {
8052
8151
  if (node.kind === "function") {
8053
8152
  return functionError(node, properties, shapes, functions) ? "false" : generateFunctionExpression(node, properties, shapes, functions, prefix);
8054
8153
  }
8055
8154
  if (node.kind === "check") {
8056
- return checkError(node, properties, shapes) ? "false" : generateCheckExpression(node, properties, shapes, prefix);
8155
+ return checkError(node, properties, shapes) ? "false" : generateCheckExpression(node, properties, shapes, prefix, enums);
8057
8156
  }
8058
8157
  if (node.kind === "call") {
8059
8158
  return callError(node, properties, shapes) ? "false" : generateCallExpression(node, properties, shapes, prefix, callReceiver);
@@ -8071,7 +8170,8 @@ function generateRuleExpression(node, properties, shapes, top = true, prefix = "
8071
8170
  false,
8072
8171
  prefix,
8073
8172
  callReceiver,
8074
- functions
8173
+ functions,
8174
+ enums
8075
8175
  )
8076
8176
  );
8077
8177
  const joined = parts.join(joiner);
@@ -9547,8 +9647,13 @@ var stringEnumFits = (read, target, enums) => {
9547
9647
  };
9548
9648
  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);
9549
9649
  var eventMemberType = (row, scope) => {
9650
+ if (row.source !== "event") return void 0;
9550
9651
  const path = row.event ?? [];
9551
- if (row.source !== "event" || path.length !== 1) return void 0;
9652
+ const payload = scope.payload;
9653
+ if (!path.length && (payload === "string" || payload === "number" || payload === "boolean")) {
9654
+ return { dataType: { type: payload }, cardinality: "one" };
9655
+ }
9656
+ if (path.length !== 1) return void 0;
9552
9657
  return scope.fields?.[path[0]];
9553
9658
  };
9554
9659
  function callArgEventMismatch(row, target, scope) {
@@ -9556,10 +9661,6 @@ function callArgEventMismatch(row, target, scope) {
9556
9661
  const member = eventMemberType(row, scope);
9557
9662
  return !!member && !sameType4(target, member) && !stringEnumFits(member, target, scope.bindings?.enums);
9558
9663
  }
9559
- var AUTO_CASTS = {
9560
- string: { number: "Number", boolean: "Boolean" },
9561
- number: { string: "String" }
9562
- };
9563
9664
  var typeName = (type) => type.cardinality === "many" ? `${type.dataType.type}[]` : type.dataType.type;
9564
9665
  function callArgTypeMismatch(row, target, scope) {
9565
9666
  if (!target?.dataType || row.transform) return void 0;
@@ -9571,11 +9672,11 @@ function callArgTypeMismatch(row, target, scope) {
9571
9672
  dataType: target.dataType,
9572
9673
  cardinality: target.cardinality
9573
9674
  };
9574
- const cast = read.cardinality === "one" && expected.cardinality === "one" ? AUTO_CASTS[read.dataType.type]?.[expected.dataType.type] : void 0;
9675
+ const fix = castTransform(read, expected);
9575
9676
  return {
9576
9677
  from: typeName(read),
9577
9678
  to: typeName(expected),
9578
- ...cast ? { fix: unaryCall(nativeTarget({ group: "number", name: cast }), 1) } : {}
9679
+ ...fix ? { fix } : {}
9579
9680
  };
9580
9681
  }
9581
9682
  var bindingPipeType = (row, target, scope) => {
@@ -9694,7 +9795,7 @@ function validateCallArgs(args, rows, payload, fieldNames = [], constants = {},
9694
9795
  fieldNames,
9695
9796
  constants,
9696
9797
  functions,
9697
- scope
9798
+ { payload, ...scope }
9698
9799
  );
9699
9800
  if (err) return err;
9700
9801
  }
@@ -9934,15 +10035,15 @@ var CALL_ARG_SOURCES = [
9934
10035
  var callArgReadsVariable = (row, variableId) => row?.source === "binding" && row.binding?.root.kind === "screen_variable" && row.binding.root.id === variableId;
9935
10036
  var callArgTargetKey = targetKey;
9936
10037
  var parseCallArgTargetKey = (raw) => {
9937
- const text2 = raw.trim();
9938
- if (!text2 || text2 === "args") return [];
9939
- return text2.startsWith("args.") ? text2.slice("args.".length).split(".").filter(Boolean) : text2.split(".").filter(Boolean);
10038
+ const text3 = raw.trim();
10039
+ if (!text3 || text3 === "args") return [];
10040
+ return text3.startsWith("args.") ? text3.slice("args.".length).split(".").filter(Boolean) : text3.split(".").filter(Boolean);
9940
10041
  };
9941
10042
  var callArgEventKey = eventKey;
9942
10043
  var parseCallArgEventKey = (raw) => {
9943
- const text2 = raw.trim();
9944
- if (!text2 || text2 === "event") return [];
9945
- return text2.startsWith("event.") ? text2.slice("event.".length).split(".").filter(Boolean) : text2.split(".").filter(Boolean);
10044
+ const text3 = raw.trim();
10045
+ if (!text3 || text3 === "event") return [];
10046
+ return text3.startsWith("event.") ? text3.slice("event.".length).split(".").filter(Boolean) : text3.split(".").filter(Boolean);
9946
10047
  };
9947
10048
 
9948
10049
  // libs/codegen/src/lib/screen-codegen.ts
@@ -10388,6 +10489,57 @@ function screenWriteToggleAllowed(variable) {
10388
10489
  function screenWriteEventAllowed(payload) {
10389
10490
  return payload !== "void";
10390
10491
  }
10492
+ function writeEventReadType(value, payload) {
10493
+ if (value.kind !== "event" || value.path?.length) return void 0;
10494
+ if (payload === "string" || payload === "number" || payload === "boolean") {
10495
+ return { dataType: { type: payload }, cardinality: "one" };
10496
+ }
10497
+ return void 0;
10498
+ }
10499
+ function writeEventIssue(value, payload, target, functions) {
10500
+ if (value.kind !== "event") return void 0;
10501
+ const read = writeEventReadType(value, payload);
10502
+ if (value.transform) {
10503
+ const err = validateTransform(
10504
+ value.transform,
10505
+ target,
10506
+ read ?? target,
10507
+ "call-arg",
10508
+ functions
10509
+ );
10510
+ if (!err) return void 0;
10511
+ return err === "value-transform-incomplete" ? "incomplete" : "type-mismatch";
10512
+ }
10513
+ if (!read || target.cardinality !== "one") return void 0;
10514
+ return read.dataType.type === target.dataType.type ? void 0 : "type-mismatch";
10515
+ }
10516
+ function writeEventMismatch(value, payload, target) {
10517
+ if (value.kind !== "event" || value.transform) return void 0;
10518
+ const read = writeEventReadType(value, payload);
10519
+ if (!read || target.cardinality !== "one" || read.dataType.type === target.dataType.type) {
10520
+ return void 0;
10521
+ }
10522
+ const fix = castTransform(read, target);
10523
+ return {
10524
+ from: read.dataType.type,
10525
+ to: target.dataType.type,
10526
+ ...fix ? { fix } : {}
10527
+ };
10528
+ }
10529
+ function writeEventTransforms(rows) {
10530
+ return rows.flatMap(
10531
+ (row) => row.value.kind === "event" && row.value.transform ? [row.value.transform] : []
10532
+ );
10533
+ }
10534
+ function withEventTransform(value, read, target, functions, constants, scope) {
10535
+ if (value.kind !== "event" || !value.transform) return read;
10536
+ return emitTransformExpr(
10537
+ value.transform,
10538
+ read,
10539
+ { functions, constants, scope },
10540
+ target
10541
+ );
10542
+ }
10391
10543
  function screenWriteInputTargets(inputs, variable) {
10392
10544
  return Object.values(inputs).filter(
10393
10545
  (input) => inputPrimitive(input) === variable.dataType && input.cardinality === variable.cardinality
@@ -10436,7 +10588,7 @@ function nextScreenWriteRow(variables, rows, payload, inputs, constants = {}) {
10436
10588
  value: defaultScreenWriteValue(free.variable, payload, inputs, constants)
10437
10589
  };
10438
10590
  }
10439
- function validateScreenWrites(variables, rows, payload, fieldNames, inputs, constants = {}) {
10591
+ function validateScreenWrites(variables, rows, payload, fieldNames, inputs, constants = {}, functions = {}) {
10440
10592
  const seen = /* @__PURE__ */ new Set();
10441
10593
  for (const row of rows) {
10442
10594
  if (seen.has(row.variableId)) return "screen-write-duplicate";
@@ -10471,6 +10623,14 @@ function validateScreenWrites(variables, rows, payload, fieldNames, inputs, cons
10471
10623
  if (value.kind === "event" && value.path?.length && fieldNames.length && !value.path.every((name3) => fieldNames.includes(name3))) {
10472
10624
  return "screen-write-incomplete";
10473
10625
  }
10626
+ const issue = writeEventIssue(
10627
+ value,
10628
+ payload,
10629
+ { dataType: { type: variable.dataType }, cardinality: variable.cardinality },
10630
+ functions
10631
+ );
10632
+ if (issue === "incomplete") return "screen-write-incomplete";
10633
+ if (issue) return "screen-write-type-mismatch";
10474
10634
  }
10475
10635
  return void 0;
10476
10636
  }
@@ -10502,7 +10662,7 @@ var valueExpression = (value, variable, payload, inputs, constants, eventRoot, s
10502
10662
  variable.dataType
10503
10663
  ) : read;
10504
10664
  };
10505
- function screenWriteStatements(variables, rows, payload, fieldNames, inputs, constants = {}, eventRoot = "$event", scope = "template", eventMember, narrow) {
10665
+ function screenWriteStatements(variables, rows, payload, fieldNames, inputs, constants = {}, eventRoot = "$event", scope = "template", eventMember, narrow, functions = {}) {
10506
10666
  if (!rows.length) return [];
10507
10667
  if (validateScreenWrites(
10508
10668
  variables,
@@ -10510,7 +10670,8 @@ function screenWriteStatements(variables, rows, payload, fieldNames, inputs, con
10510
10670
  payload,
10511
10671
  fieldNames,
10512
10672
  inputs,
10513
- constants
10673
+ constants,
10674
+ functions
10514
10675
  )) {
10515
10676
  return [];
10516
10677
  }
@@ -10530,7 +10691,15 @@ function screenWriteStatements(variables, rows, payload, fieldNames, inputs, con
10530
10691
  eventMember
10531
10692
  );
10532
10693
  if (expr === void 0) return [];
10533
- const narrowed = narrow ? narrow(variable, row.value, expr) : expr;
10694
+ const transformed = withEventTransform(
10695
+ row.value,
10696
+ expr,
10697
+ { type: variable.dataType },
10698
+ functions,
10699
+ constants,
10700
+ scope
10701
+ );
10702
+ const narrowed = narrow ? narrow(variable, row.value, transformed) : transformed;
10534
10703
  statements.push({
10535
10704
  name: variable.name,
10536
10705
  text: `${self}${variable.name}.set(${narrowed})`
@@ -10757,7 +10926,7 @@ function nextStateWriteRow(properties, rows, payload, inputs, constants = {}) {
10757
10926
  value: defaultStateWriteValue(free.property, payload, inputs, constants)
10758
10927
  };
10759
10928
  }
10760
- function validateStateWrites(properties, rows, payload, fieldNames, inputs, constants = {}) {
10929
+ function validateStateWrites(properties, rows, payload, fieldNames, inputs, constants = {}, functions = {}) {
10761
10930
  const seen = /* @__PURE__ */ new Set();
10762
10931
  for (const row of rows) {
10763
10932
  if (seen.has(row.propertyId)) return "state-write-duplicate";
@@ -10792,6 +10961,14 @@ function validateStateWrites(properties, rows, payload, fieldNames, inputs, cons
10792
10961
  if (value.kind === "event" && value.path?.length && fieldNames.length && !value.path.every((name3) => fieldNames.includes(name3))) {
10793
10962
  return "state-write-incomplete";
10794
10963
  }
10964
+ const issue = writeEventIssue(
10965
+ value,
10966
+ payload,
10967
+ { dataType: property.dataType, cardinality: property.cardinality },
10968
+ functions
10969
+ );
10970
+ if (issue === "incomplete") return "state-write-incomplete";
10971
+ if (issue) return "state-write-type-mismatch";
10795
10972
  }
10796
10973
  return void 0;
10797
10974
  }
@@ -10823,7 +11000,7 @@ var valueExpression2 = (value, property, payload, storeProp, inputs, constants,
10823
11000
  property.dataType
10824
11001
  ) : read;
10825
11002
  };
10826
- function stateWritePatchExpression(properties, rows, payload, fieldNames, inputs, storeProp, constants = {}, eventRoot = "$event", scope = "template", eventMember, narrow) {
11003
+ function stateWritePatchExpression(properties, rows, payload, fieldNames, inputs, storeProp, constants = {}, eventRoot = "$event", scope = "template", eventMember, narrow, functions = {}) {
10827
11004
  if (!rows.length) return void 0;
10828
11005
  if (validateStateWrites(
10829
11006
  properties,
@@ -10831,7 +11008,8 @@ function stateWritePatchExpression(properties, rows, payload, fieldNames, inputs
10831
11008
  payload,
10832
11009
  fieldNames,
10833
11010
  inputs,
10834
- constants
11011
+ constants,
11012
+ functions
10835
11013
  )) {
10836
11014
  return void 0;
10837
11015
  }
@@ -10851,7 +11029,15 @@ function stateWritePatchExpression(properties, rows, payload, fieldNames, inputs
10851
11029
  eventMember
10852
11030
  );
10853
11031
  if (expr === void 0) return void 0;
10854
- const narrowed = narrow ? narrow(property, row.value, expr) : expr;
11032
+ const transformed = withEventTransform(
11033
+ row.value,
11034
+ expr,
11035
+ property.dataType,
11036
+ functions,
11037
+ constants,
11038
+ scope
11039
+ );
11040
+ const narrowed = narrow ? narrow(property, row.value, transformed) : transformed;
10855
11041
  members.push({
10856
11042
  name: property.name,
10857
11043
  text: `${property.name}: ${narrowed}`
@@ -10933,6 +11119,70 @@ function stampStatePropertyEnums(properties, controlMaps) {
10933
11119
  });
10934
11120
  return changed ? next : properties;
10935
11121
  }
11122
+ var featuresAsRead = (features, sharedShapes, screens) => withPropertyEnums(featuresInReach(features, sharedShapes), screens);
11123
+ function withPropertyEnums(features, screens) {
11124
+ let changed = false;
11125
+ const next = Object.fromEntries(
11126
+ Object.entries(features).map(([id, feature]) => {
11127
+ const controlMaps = screens.filter((screen) => screen.featureId === id).map((screen) => screen.controlMap);
11128
+ if (!controlMaps.length) return [id, feature];
11129
+ const properties = stampStatePropertyEnums(
11130
+ feature.properties,
11131
+ controlMaps
11132
+ );
11133
+ let subChanged = false;
11134
+ const subStores = feature.subStores ? Object.fromEntries(
11135
+ Object.entries(feature.subStores).map(([subId, sub]) => {
11136
+ const stamped = stampStatePropertyEnums(
11137
+ sub.properties,
11138
+ controlMaps
11139
+ );
11140
+ if (stamped === sub.properties) return [subId, sub];
11141
+ subChanged = true;
11142
+ return [subId, { ...sub, properties: stamped }];
11143
+ })
11144
+ ) : void 0;
11145
+ if (properties === feature.properties && !subChanged) {
11146
+ return [id, feature];
11147
+ }
11148
+ changed = true;
11149
+ return [
11150
+ id,
11151
+ { ...feature, properties, ...subChanged ? { subStores } : {} }
11152
+ ];
11153
+ })
11154
+ );
11155
+ return changed ? next : features;
11156
+ }
11157
+ var sameEntries = (a, b, same) => {
11158
+ if (a === b) return true;
11159
+ if (!a || !b) return false;
11160
+ const keys = Object.keys(a);
11161
+ return keys.length === Object.keys(b).length && keys.every((key2) => key2 in b && same(a[key2], b[key2]));
11162
+ };
11163
+ var sameFields = (a, b, deep = {}) => {
11164
+ if (a === b) return true;
11165
+ const keys = Object.keys(a);
11166
+ if (keys.length !== Object.keys(b).length) return false;
11167
+ return keys.every((key2) => {
11168
+ const same = deep[key2];
11169
+ return same ? key2 in b && same(a[key2], b[key2]) : a[key2] === b[key2];
11170
+ });
11171
+ };
11172
+ var sameProperty = (a, b) => sameFields(a, b, { dataType: (x, y) => sameFields(x, y) });
11173
+ var sameProperties = (a, b) => sameEntries(a, b, sameProperty);
11174
+ var sameFeaturesAsRead = (a, b) => sameEntries(
11175
+ a,
11176
+ b,
11177
+ (x, y) => sameFields(x, y, {
11178
+ properties: sameProperties,
11179
+ subStores: (p2, q) => sameEntries(
11180
+ p2,
11181
+ q,
11182
+ (s, t) => sameFields(s, t, { properties: sameProperties })
11183
+ )
11184
+ })
11185
+ );
10936
11186
 
10937
11187
  // libs/codegen/src/lib/output-call-helper.ts
10938
11188
  var OUTPUT_CALL_SEPARATOR = "|call:";
@@ -11145,12 +11395,13 @@ var outputArmBaseKey = (key2) => {
11145
11395
  const group = outputCallGroupKey(key2);
11146
11396
  return isOutputArmKey(group) ? group.slice(0, group.indexOf(OUTPUT_ARM_SEPARATOR)) : group;
11147
11397
  };
11148
- var OUTPUT_MAPS = [
11398
+ var OUTPUT_GROUP_MAPS = [
11149
11399
  "outputs",
11150
11400
  "outputScreenMethods",
11151
11401
  "outputArgs",
11152
11402
  "outputWrites",
11153
11403
  "outputScreenWrites",
11404
+ "outputEmits",
11154
11405
  "outputOutcomes",
11155
11406
  "outputOpens",
11156
11407
  "outputNavs",
@@ -11160,7 +11411,7 @@ var offersOutputArms = (control) => !!control && control.type !== "context_menu"
11160
11411
  var wiredArmIds = (control, output) => {
11161
11412
  if (!control) return [];
11162
11413
  const ids = /* @__PURE__ */ new Set();
11163
- OUTPUT_MAPS.forEach(
11414
+ OUTPUT_GROUP_MAPS.forEach(
11164
11415
  (map) => Object.keys(control[map] ?? {}).forEach((key2) => {
11165
11416
  if (isOutputArmKey(key2) && outputArmBaseKey(key2) === output) {
11166
11417
  ids.add(outputArmIdOf(key2));
@@ -11276,7 +11527,7 @@ var withArms = (control, output, arms) => {
11276
11527
  };
11277
11528
  var rowsAt = (control, key2) => {
11278
11529
  const held = {};
11279
- OUTPUT_MAPS.forEach((map) => {
11530
+ OUTPUT_GROUP_MAPS.forEach((map) => {
11280
11531
  const rows = control[map];
11281
11532
  if (rows && key2 in rows) held[map] = rows[key2];
11282
11533
  });
@@ -11285,7 +11536,7 @@ var rowsAt = (control, key2) => {
11285
11536
  var moveRows = (control, from, to) => {
11286
11537
  const held = rowsAt(control, from);
11287
11538
  const next = moveOutputCallRows(control, from, to);
11288
- OUTPUT_MAPS.forEach((map) => {
11539
+ OUTPUT_GROUP_MAPS.forEach((map) => {
11289
11540
  const rows = next[map];
11290
11541
  const has = rows && from in rows;
11291
11542
  if (!has && !(map in held)) return;
@@ -11295,11 +11546,11 @@ var moveRows = (control, from, to) => {
11295
11546
  });
11296
11547
  return next;
11297
11548
  };
11298
- var clearRows = (control, key2) => {
11549
+ var clearOutputGroupRows = (control, key2) => {
11299
11550
  const cleared = clearOutputCallRows(control, key2);
11300
11551
  const next = { ...cleared };
11301
11552
  let held = cleared !== control;
11302
- OUTPUT_MAPS.forEach((map) => {
11553
+ OUTPUT_GROUP_MAPS.forEach((map) => {
11303
11554
  const rows = cleared[map];
11304
11555
  if (!rows || !(key2 in rows)) return;
11305
11556
  const { [key2]: _dropped, ...rest } = rows;
@@ -11324,7 +11575,7 @@ function toDirectOutput(control, output) {
11324
11575
  const [first, ...rest] = arms;
11325
11576
  const kept = moveRows(control, outputArmKey(output, first.id), output);
11326
11577
  const cleared = rest.reduce(
11327
- (held, arm) => clearRows(held, outputArmKey(output, arm.id)),
11578
+ (held, arm) => clearOutputGroupRows(held, outputArmKey(output, arm.id)),
11328
11579
  kept
11329
11580
  );
11330
11581
  return withArms(cleared, output, []);
@@ -11396,7 +11647,7 @@ function removeOutputArm(control, output, armId) {
11396
11647
  output,
11397
11648
  arms.filter((arm) => arm.id !== armId)
11398
11649
  );
11399
- return clearRows(dropped, outputArmKey(output, armId));
11650
+ return clearOutputGroupRows(dropped, outputArmKey(output, armId));
11400
11651
  }
11401
11652
  var BLOCK_LIST_MAPS = {
11402
11653
  "state-write": "outputWrites",
@@ -11448,7 +11699,7 @@ function moveOutputBlock(control, from, block2, to) {
11448
11699
  [map]: writeKey(writeKey(all, from, void 0), to, row)
11449
11700
  };
11450
11701
  }
11451
- var outputGroupHoldsBlocks = (control, key2) => Object.keys(rowsAt(control, key2)).length > 0 || (control.outputEmits?.[key2]?.length ?? 0) > 0 || outputCallIds(control, key2).length > 0;
11702
+ var outputGroupHoldsBlocks = (control, key2) => Object.keys(rowsAt(control, key2)).length > 0 || outputCallIds(control, key2).length > 0;
11452
11703
  function tidyOutputArms(control, output) {
11453
11704
  let next = control;
11454
11705
  for (const arm of outputArms(next, output)) {
@@ -12236,22 +12487,11 @@ var baseOutputName = (key2) => {
12236
12487
  const base = outputArmBaseKey(key2);
12237
12488
  return isMenuActionKey(base) ? MENU_ACTION_OUTPUT : base;
12238
12489
  };
12239
- var OUTPUT_MAPS2 = [
12240
- "outputs",
12241
- "outputScreenMethods",
12242
- "outputArgs",
12243
- "outputWrites",
12244
- "outputScreenWrites",
12245
- "outputOutcomes",
12246
- "outputOpens",
12247
- "outputNavs",
12248
- "outputNewTabs"
12249
- ];
12250
12490
  var wiresMenuActions = (control) => control?.type === "context_menu" /* CONTEXT_MENU */;
12251
12491
  var wiredKeys = (control) => {
12252
12492
  if (!control) return [];
12253
12493
  const keys = /* @__PURE__ */ new Set();
12254
- OUTPUT_MAPS2.forEach(
12494
+ OUTPUT_GROUP_MAPS.forEach(
12255
12495
  (map) => Object.keys(control[map] ?? {}).forEach((key2) => {
12256
12496
  if (isMenuActionKey(key2)) keys.add(outputCallGroupKey(key2));
12257
12497
  })
@@ -12348,21 +12588,7 @@ function removeMenuActionSlot(control, slotId) {
12348
12588
  control,
12349
12589
  slots.filter((slot) => slot.id !== slotId)
12350
12590
  );
12351
- return clearMenuActionRows(dropped, slotId);
12352
- }
12353
- function clearMenuActionRows(control, slotId) {
12354
- const key2 = menuActionKey(slotId);
12355
- const cleared = clearOutputCallRows(control, key2);
12356
- const next = { ...cleared };
12357
- let held = cleared !== control;
12358
- OUTPUT_MAPS2.forEach((map) => {
12359
- const rows = cleared[map];
12360
- if (!rows || !(key2 in rows)) return;
12361
- const { [key2]: _dropped, ...rest } = rows;
12362
- next[map] = Object.keys(rest).length ? rest : void 0;
12363
- held = true;
12364
- });
12365
- return held ? next : control;
12591
+ return clearOutputGroupRows(dropped, menuActionKey(slotId));
12366
12592
  }
12367
12593
  function renameMenuItemId(control, from, to) {
12368
12594
  const before = from.trim();
@@ -13188,9 +13414,9 @@ ${" ".repeat(depth)}}` : "{}";
13188
13414
  }
13189
13415
  var LITERAL_SOURCE = "=";
13190
13416
  function literalType(value) {
13191
- const text2 = value.trim();
13192
- if (text2 === "true" || text2 === "false") return { type: "boolean" };
13193
- if (text2 !== "" && !Number.isNaN(Number(text2))) return { type: "number" };
13417
+ const text3 = value.trim();
13418
+ if (text3 === "true" || text3 === "false") return { type: "boolean" };
13419
+ if (text3 !== "" && !Number.isNaN(Number(text3))) return { type: "number" };
13194
13420
  return { type: "string" };
13195
13421
  }
13196
13422
  function validateLiteral(value, dataType, cardinality) {
@@ -13204,11 +13430,11 @@ function validateLiteral(value, dataType, cardinality) {
13204
13430
  return is === dataType.type ? void 0 : "value-type-mismatch";
13205
13431
  }
13206
13432
  function literalExpression(value, dataType) {
13207
- const text2 = String(value ?? "").trim();
13208
- const type = dataType?.type ?? literalType(text2).type;
13209
- if (type === "boolean") return text2 === "true" ? "true" : "false";
13210
- if (type === "number") return String(Number(text2) || 0);
13211
- return `'${text2.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
13433
+ const text3 = String(value ?? "").trim();
13434
+ const type = dataType?.type ?? literalType(text3).type;
13435
+ if (type === "boolean") return text3 === "true" ? "true" : "false";
13436
+ if (type === "number") return String(Number(text3) || 0);
13437
+ return `'${text3.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
13212
13438
  }
13213
13439
  function fixedExpression(value, dataType, cardinality) {
13214
13440
  if (cardinality !== "many") return literalExpression(value, dataType);
@@ -13561,7 +13787,11 @@ var persistRoots = (persists) => (persists ?? []).filter(
13561
13787
  ).map((persist) => ({
13562
13788
  id: persist.source?.[0],
13563
13789
  path: persist.source
13564
- }));
13790
+ })).concat(
13791
+ (persists ?? []).flatMap(
13792
+ (persist) => persist.sourceKind === "function" && persist.transform ? transformRoots2(persist.transform) : []
13793
+ )
13794
+ );
13565
13795
  function methodReaders(method, owner, into) {
13566
13796
  const push = (read, kind) => {
13567
13797
  if (read.id) into.push(readerOf(owner, kind, method.name, read));
@@ -13700,6 +13930,7 @@ var subStorePropName = (suffix) => camelOf(suffix);
13700
13930
  function subStoreSuffixError(feature, suffix, ignoreId) {
13701
13931
  if (!suffix) return "sub-store-name-empty";
13702
13932
  if (!isValidSlug(suffix)) return "sub-store-name-invalid";
13933
+ if (suffix === MAIN_STORE_VALUE) return "sub-store-name-reserved";
13703
13934
  const taken = subStoresOf(feature).some(
13704
13935
  (subStore) => subStore.name === suffix && subStore.id !== ignoreId
13705
13936
  );
@@ -14424,6 +14655,10 @@ var canAppendFormatPipe = (control, name3, headType) => {
14424
14655
  }
14425
14656
  return sameDataType(flowing, entry2.inputType);
14426
14657
  };
14658
+ var labelHeadType = (control, scope) => {
14659
+ const binding = control?.bindings?.[BINDING_SLOT.label];
14660
+ return binding ? emittedDataType(binding, scope) : void 0;
14661
+ };
14427
14662
  var appendableFormatPipes = (control, headType) => FORMAT_PIPE_CATALOG.filter(
14428
14663
  (entry2) => canAppendFormatPipe(control, entry2.name, headType)
14429
14664
  );
@@ -14564,8 +14799,8 @@ var bindingDisplayText = (binding, scope) => {
14564
14799
  return store ? `${store}.${path}` : path;
14565
14800
  };
14566
14801
  var bindingCanvasText = (binding, scope) => {
14567
- const text2 = bindingDisplayText(binding, scope);
14568
- return text2 ? `{${text2}}` : "";
14802
+ const text3 = bindingDisplayText(binding, scope);
14803
+ return text3 ? `{${text3}}` : "";
14569
14804
  };
14570
14805
  var applyBindingText = (tree, controlMap, scope) => {
14571
14806
  const applyToNode = (node) => {
@@ -14579,10 +14814,10 @@ var applyBindingText = (tree, controlMap, scope) => {
14579
14814
  }
14580
14815
  const bindingText = Object.fromEntries(
14581
14816
  Object.entries(bindings).map(([slot, binding]) => {
14582
- const text2 = bindingCanvasText(binding, scope);
14817
+ const text3 = bindingCanvasText(binding, scope);
14583
14818
  return [
14584
14819
  slot,
14585
- slot === "label" && pipes && text2 ? `${text2.slice(0, -1)}${pipes}}` : text2
14820
+ slot === "label" && pipes && text3 ? `${text3.slice(0, -1)}${pipes}}` : text3
14586
14821
  ];
14587
14822
  })
14588
14823
  );
@@ -15118,21 +15353,21 @@ function validateTranslationKey(raw, existing, libraryKeys) {
15118
15353
  if (existing[key2] !== void 0) return "translation-key-taken";
15119
15354
  return void 0;
15120
15355
  }
15121
- function slugifyMessage(text2) {
15122
- return text2.trim().toLowerCase().replace(/<\$?\w+>/g, " ").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, TRANSLATION_KEY_MAX_LENGTH).replace(/-+$/, "");
15356
+ function slugifyMessage(text3) {
15357
+ return text3.trim().toLowerCase().replace(/<\$?\w+>/g, " ").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, TRANSLATION_KEY_MAX_LENGTH).replace(/-+$/, "");
15123
15358
  }
15124
- function extractMessageVariables(text2) {
15125
- if (!text2) return [];
15359
+ function extractMessageVariables(text3) {
15360
+ if (!text3) return [];
15126
15361
  const found = /* @__PURE__ */ new Set();
15127
- for (const match of text2.matchAll(MESSAGE_VARIABLE_PATTERN)) {
15362
+ for (const match of text3.matchAll(MESSAGE_VARIABLE_PATTERN)) {
15128
15363
  found.add(match[1]);
15129
15364
  }
15130
15365
  return Array.from(found);
15131
15366
  }
15132
- function extractAllVariables(text2) {
15133
- if (!text2) return [];
15367
+ function extractAllVariables(text3) {
15368
+ if (!text3) return [];
15134
15369
  const found = /* @__PURE__ */ new Map();
15135
- for (const match of text2.matchAll(ANY_VARIABLE_PATTERN)) {
15370
+ for (const match of text3.matchAll(ANY_VARIABLE_PATTERN)) {
15136
15371
  const name3 = match[2];
15137
15372
  if (!found.has(name3)) {
15138
15373
  found.set(name3, { name: name3, translated: match[1] === "$" });
@@ -15201,7 +15436,14 @@ function collectTranslationAssets(controlMap, translations, extraKeys = []) {
15201
15436
  return Array.from(referenced).filter((key2) => translations[key2]).sort().map((key2) => ({
15202
15437
  path: translationAssetPath(key2),
15203
15438
  key: key2,
15204
- langs: translations[key2]
15439
+ // Languages in code order: the map holds them in the order they were
15440
+ // translated, which differs between a fresh translate and one read back
15441
+ // from disk, and the file would reorder with nothing changed.
15442
+ langs: Object.fromEntries(
15443
+ Object.entries(translations[key2]).sort(
15444
+ ([a], [b]) => a < b ? -1 : a > b ? 1 : 0
15445
+ )
15446
+ )
15205
15447
  }));
15206
15448
  }
15207
15449
  function variableDrift(sourceText, langText) {
@@ -15215,8 +15457,8 @@ function variableDrift(sourceText, langText) {
15215
15457
  function hasVariableDrift(drift) {
15216
15458
  return drift.missing.length > 0 || drift.unknown.length > 0;
15217
15459
  }
15218
- var extractMarkdownLinkUrls = (text2) => Array.from(
15219
- text2?.matchAll(MARKDOWN_LINK_URL_PATTERN) ?? [],
15460
+ var extractMarkdownLinkUrls = (text3) => Array.from(
15461
+ text3?.matchAll(MARKDOWN_LINK_URL_PATTERN) ?? [],
15220
15462
  (match) => match[1]
15221
15463
  );
15222
15464
  var unmatched = (expected, actual) => {
@@ -15288,9 +15530,9 @@ function pruneOrphanMessageBindings(control, translations) {
15288
15530
  typeof value === "string" ? value : void 0
15289
15531
  );
15290
15532
  if (!key2) continue;
15291
- const text2 = translations[key2]?.[SOURCE_LANG];
15292
- if (text2 === void 0) return control;
15293
- extractAllVariables(text2).forEach(({ name: name3 }) => named.add(name3));
15533
+ const text3 = translations[key2]?.[SOURCE_LANG];
15534
+ if (text3 === void 0) return control;
15535
+ extractAllVariables(text3).forEach(({ name: name3 }) => named.add(name3));
15294
15536
  }
15295
15537
  const kept = Object.entries(bindings).filter(
15296
15538
  ([slot]) => !isMessageSlot(slot) || named.has(messageSlotName(slot))
@@ -15618,8 +15860,8 @@ function outcomeFormIds(outcome, controls) {
15618
15860
  }
15619
15861
 
15620
15862
  // libs/codegen/src/lib/card-codegen.ts
15621
- var camelCase = (text2, fallback = "card") => {
15622
- const parts = text2.split(/[^A-Za-z0-9]+/).filter(Boolean);
15863
+ var camelCase = (text3, fallback = "card") => {
15864
+ const parts = text3.split(/[^A-Za-z0-9]+/).filter(Boolean);
15623
15865
  const name3 = parts.map(
15624
15866
  (part, index) => index === 0 ? part.charAt(0).toLowerCase() + part.slice(1) : part.charAt(0).toUpperCase() + part.slice(1)
15625
15867
  ).join("");
@@ -16317,11 +16559,56 @@ function patchLiteral(mappings, properties, shapes, functions, subject, cast = f
16317
16559
  return { declarations, statements };
16318
16560
  }
16319
16561
  var castRead = (read, cast, type) => cast ? `(${read} as ${type} | undefined)` : read;
16320
- function persistStatements(method, timing, subject, storage, roots, shapes, receiverOf = OWN_STORE) {
16562
+ var persistAsMapping = (persist) => ({
16563
+ code: "",
16564
+ propertyId: persist.propertyId ?? "",
16565
+ source: [],
16566
+ ...persist.transform ? { transform: persist.transform } : {}
16567
+ });
16568
+ var persistFunctionEmits = (persist, method, roots, context) => !!persist.transform && persist.transform.args.every((arg) => arg.source !== "response") && !outcomeTransformError(
16569
+ persistAsMapping(persist),
16570
+ method,
16571
+ context.op,
16572
+ roots,
16573
+ context.lookup,
16574
+ context.functions,
16575
+ roots
16576
+ );
16577
+ function persistStatements(method, timing, subject, storage, roots, shapes, receiverOf = OWN_STORE, context) {
16321
16578
  return (method.persists ?? []).filter(
16322
16579
  (persist) => (persist.shelf === "store" ? !!roots[persist.propertyId ?? ""] && persistSourceKind(persist) !== "state" : !!persist.key.trim()) && (persist.timing ?? "after") === timing && !(timing === "before" && (persist.sourceKind ?? "state") === "response")
16323
- ).map((persist) => {
16580
+ ).filter((persist) => {
16581
+ const kind = persistSourceKind(persist);
16582
+ if (kind !== "clear" && kind !== "function") return true;
16583
+ if (timing !== "before" || persist.shelf !== "store") return false;
16584
+ return kind === "clear" || !!context && persistFunctionEmits(persist, method, roots, context);
16585
+ }).flatMap((persist) => {
16324
16586
  const target = persist.shelf === "store" ? roots[persist.propertyId ?? ""] : void 0;
16587
+ const kind = persistSourceKind(persist);
16588
+ if (target && kind === "clear") {
16589
+ return [`patchState(${receiverOf(target.id)}, { ${target.name}: undefined });`];
16590
+ }
16591
+ if (target && kind === "function" && context) {
16592
+ const patch = patchLiteral(
16593
+ [persistAsMapping(persist)],
16594
+ roots,
16595
+ context.lookup,
16596
+ context.functions,
16597
+ subject,
16598
+ false,
16599
+ roots,
16600
+ context.taken,
16601
+ receiverOf,
16602
+ NO_GATE,
16603
+ context.stateType,
16604
+ context.oneFunctionNames,
16605
+ context.spelledShapes
16606
+ );
16607
+ return [
16608
+ ...patch.declarations,
16609
+ ...patch.statements.map((statement) => `${statement};`)
16610
+ ];
16611
+ }
16325
16612
  const setter = persist.shelf === "session" ? "setSession" : "setLocal";
16326
16613
  const sourceKind = persist.sourceKind ?? (timing === "before" ? "state" : "response");
16327
16614
  const read = sourceKind === "state" ? statePathExpression(
@@ -16635,7 +16922,6 @@ function generateStoreMethods(methods, operationOf, properties, shapes, function
16635
16922
  return `${a.name}: ${type}${narrowed ? "" : " | undefined"}`;
16636
16923
  }), ...callbackMembers].join("; ")} }${settleOnly ? " | void" : ""}`;
16637
16924
  const argType = argObjectType(false);
16638
- const argName = args.length === 0 ? "()" : `({ ${args.map((a) => a.name).join(", ")} })`;
16639
16925
  const sent = sentParams(method, op);
16640
16926
  const callArgs = sent.map(
16641
16927
  (p2) => paramExpression(
@@ -16748,6 +17034,15 @@ function generateStoreMethods(methods, operationOf, properties, shapes, function
16748
17034
  oneFunctionNames,
16749
17035
  argShapes
16750
17036
  );
17037
+ const persistContext = {
17038
+ op,
17039
+ functions,
17040
+ lookup,
17041
+ taken,
17042
+ stateType,
17043
+ oneFunctionNames,
17044
+ spelledShapes: argShapes
17045
+ };
16751
17046
  const beforePersists = persistStatements(
16752
17047
  method,
16753
17048
  "before",
@@ -16755,7 +17050,8 @@ function generateStoreMethods(methods, operationOf, properties, shapes, function
16755
17050
  "storage",
16756
17051
  roots,
16757
17052
  shapes,
16758
- receiverOf
17053
+ receiverOf,
17054
+ persistContext
16759
17055
  );
16760
17056
  const afterPersists = persistStatements(
16761
17057
  method,
@@ -16995,7 +17291,14 @@ ${failureArms.map(
16995
17291
  (binding) => binding.source === "compute" && binding.name === compute.name
16996
17292
  )
16997
17293
  );
16998
- if (readByKept || readsCompute(compute.name)) computes.unshift(compute);
17294
+ const readByPersist = (method.persists ?? []).some(
17295
+ (persist) => persistSourceKind(persist) === "function" && (persist.transform?.args ?? []).some(
17296
+ (binding) => binding.source === "compute" && binding.name === compute.name
17297
+ )
17298
+ );
17299
+ if (readByKept || readByPersist || readsCompute(compute.name)) {
17300
+ computes.unshift(compute);
17301
+ }
16999
17302
  }
17000
17303
  const computeGuards = [];
17001
17304
  let computeGuardsReadArgs = false;
@@ -17113,11 +17416,23 @@ ${confirmOptions(
17113
17416
  emitsModal = true;
17114
17417
  if (confirmHandsBack) emitsMap = true;
17115
17418
  }
17116
- const beforeUsesArgs = (method.persists ?? []).some(
17117
- (persist) => (persist.timing ?? "after") === "before" && persistSourceKind(persist) === "args" && (persist.shelf === "store" ? !!roots[persist.propertyId ?? ""] : !!persist.key.trim())
17419
+ const beforeRows = (method.persists ?? []).filter(
17420
+ (persist) => (persist.timing ?? "after") === "before" && (persist.shelf === "store" ? !!roots[persist.propertyId ?? ""] : !!persist.key.trim())
17118
17421
  );
17422
+ const beforeBindings = beforeRows.filter(
17423
+ (persist) => persistSourceKind(persist) === "function" && persist.shelf === "store" && persistFunctionEmits(persist, method, roots, persistContext)
17424
+ ).flatMap((persist) => persist.transform?.args ?? []);
17425
+ const beforeUsesArgs = args.length > 0 && (beforeRows.some((persist) => persistSourceKind(persist) === "args") || beforeBindings.some((binding) => binding.source === "args"));
17426
+ const beforeUsesCompute = beforeBindings.some(
17427
+ (binding) => binding.source === "compute"
17428
+ );
17429
+ const beforeNames = [
17430
+ ...beforeUsesArgs ? args.map((a) => a.name) : [],
17431
+ ...beforeUsesCompute ? ["compute"] : []
17432
+ ];
17433
+ const beforeArg = beforeNames.length ? `({ ${beforeNames.join(", ")} })` : "()";
17119
17434
  const beforeBlock = beforePersists.length ? `
17120
- tap(${beforeUsesArgs ? argName : "()"} => {
17435
+ tap(${beforeArg} => {
17121
17436
  ${beforePersists.map((line) => ` ${line}`).join("\n")}
17122
17437
  }),` : "";
17123
17438
  const callReadsCompute = computes.some(
@@ -17229,6 +17544,8 @@ ${beforePersists.map((line) => ` ${line}`).join("\n")}
17229
17544
  new Set(
17230
17545
  list.flatMap((method) => [
17231
17546
  ...method.response.map((mapping) => mapping.transform?.functionId).filter((id) => !!id && !!functions[id]),
17547
+ // A `before` Store row's function is spelled in the same file.
17548
+ ...(method.persists ?? []).filter((persist) => persistSourceKind(persist) === "function").map((persist) => persist.transform?.functionId).filter((id) => !!id && !!functions[id]),
17232
17549
  // The store file spells an input's transforms too, so a
17233
17550
  // PureFunction one names is imported beside the ones an outcome
17234
17551
  // names — a call the file never imported is the one thing worse
@@ -17925,127 +18242,15 @@ function pruneOutputLinkArgs(control, drop) {
17925
18242
  return dropped;
17926
18243
  }
17927
18244
 
17928
- // libs/codegen/src/lib/tree-helper.ts
17929
- function buildTree(controlMap, rootControlIds, selection) {
17930
- const state = (id) => selection ? variantRenderState(id, controlMap, selection) : "solid";
17931
- const resolveDirectives = (ctrl) => {
17932
- if (!ctrl.directives) return void 0;
17933
- const resolved = {};
17934
- for (const [name3, directive] of Object.entries(ctrl.directives)) {
17935
- if (directive.overlayId) {
17936
- const overlay = controlMap[directive.overlayId];
17937
- if (overlay) {
17938
- resolved[name3] = {
17939
- overlayId: directive.overlayId,
17940
- type: overlay.type,
17941
- configs: overlay.configs
17942
- };
17943
- }
17944
- } else {
17945
- resolved[name3] = { configs: directive.configs ?? {} };
17946
- }
17947
- }
17948
- return Object.keys(resolved).length > 0 ? resolved : void 0;
17949
- };
17950
- const toNode = (ctrl) => {
17951
- const childrens = getChildren(ctrl.id);
17952
- const fullyFaded = state(ctrl.id) === "faded" && childrens.every((child) => child.faded);
17953
- return {
17954
- type: ctrl.type,
17955
- id: ctrl.id,
17956
- configs: ctrl.configs,
17957
- childrens,
17958
- directives: resolveDirectives(ctrl),
17959
- ...ctrl.source ? { source: ctrl.source } : {},
17960
- ...ctrl.variants?.length ? { variants: ctrl.variants } : {},
17961
- // Carried through so renderBranch can order the `@else` last and spell it
17962
- // without reaching back into ControlMap mid-walk (GLOSSARY.md DefaultArm).
17963
- ...ctrl.armKind ? { armKind: ctrl.armKind } : {},
17964
- ...ctrl.variantKind ? { variantKind: ctrl.variantKind } : {},
17965
- ...ctrl.outputs && Object.keys(ctrl.outputs).length ? { outputs: ctrl.outputs } : {},
17966
- ...ctrl.outputArgs && Object.keys(ctrl.outputArgs).length ? { outputArgs: ctrl.outputArgs } : {},
17967
- ...ctrl.outputWrites && Object.keys(ctrl.outputWrites).length ? { outputWrites: ctrl.outputWrites } : {},
17968
- ...ctrl.outputEmits && Object.keys(ctrl.outputEmits).length ? { outputEmits: ctrl.outputEmits } : {},
17969
- ...ctrl.outputScreenWrites && Object.keys(ctrl.outputScreenWrites).length ? { outputScreenWrites: ctrl.outputScreenWrites } : {},
17970
- ...ctrl.outputOpens && Object.keys(ctrl.outputOpens).length ? { outputOpens: ctrl.outputOpens } : {},
17971
- ...ctrl.outputNavs && Object.keys(ctrl.outputNavs).length ? { outputNavs: ctrl.outputNavs } : {},
17972
- ...ctrl.outputNewTabs && Object.keys(ctrl.outputNewTabs).length ? { outputNewTabs: ctrl.outputNewTabs } : {},
17973
- ...ctrl.outputOutcomes && Object.keys(ctrl.outputOutcomes).length ? { outputOutcomes: ctrl.outputOutcomes } : {},
17974
- // Without this the codegen walk reads `outputArms` off a Tree that never
17975
- // carried it, every gated output falls back to ungated, and its groups —
17976
- // filed under `<output>|arm:<armId>` — are skipped as qualified keys. The
17977
- // output emits nothing at all (GLOSSARY.md OutputArm).
17978
- ...ctrl.outputArms && Object.keys(ctrl.outputArms).length ? { outputArms: ctrl.outputArms } : {},
17979
- // Without this every group fires its first call alone: the rest are
17980
- // filed under `<group>|call:<callId>` and read in the order this holds
17981
- // (GLOSSARY.md OutputCall).
17982
- ...ctrl.outputCalls && Object.keys(ctrl.outputCalls).length ? { outputCalls: ctrl.outputCalls } : {},
17983
- ...ctrl.outputScreenMethods && Object.keys(ctrl.outputScreenMethods).length ? { outputScreenMethods: ctrl.outputScreenMethods } : {},
17984
- ...ctrl.menuActions?.length ? { menuActions: ctrl.menuActions } : {},
17985
- ...ctrl.screenId ? { screenId: ctrl.screenId } : {},
17986
- // The other answer to what a ScreenControl mounts (ADR 0088). Carried
17987
- // for `screenId`'s reason: the Canvas labels its placeholder from it and
17988
- // codegen emits its tag.
17989
- ...ctrl.handRef ? { handRef: ctrl.handRef } : {},
17990
- ...ctrl.screenInputs && Object.keys(ctrl.screenInputs).length ? { screenInputs: ctrl.screenInputs } : {},
17991
- // Carried for `screenId`'s reason: the Canvas draws the embed's box at
17992
- // it and codegen emits it on the tag.
17993
- ...ctrl.maxWidth ? { maxWidth: ctrl.maxWidth } : {},
17994
- ...ctrl.checks?.length ? { checks: ctrl.checks } : {},
17995
- ...ctrl.formatPipes?.length ? { formatPipes: ctrl.formatPipes } : {},
17996
- ...ctrl.cards ? { cards: ctrl.cards } : {},
17997
- ...ctrl.search ? { search: ctrl.search } : {},
17998
- // A Repeat's row count, carried for `cards`' reason: the Canvas draws
17999
- // its sample rows from the Tree alone. Nothing else reads it — codegen
18000
- // never emits a count (GLOSSARY.md SampleValue).
18001
- ...ctrl.repeat?.sampleRows !== void 0 ? { sampleRows: ctrl.repeat.sampleRows } : {},
18002
- ...fullyFaded ? { faded: true } : {}
18003
- };
18004
- };
18005
- const getChildren = (parentId) => {
18006
- const parent = controlMap[parentId];
18007
- if (!parent || !parent.childrens) return [];
18008
- return parent.childrens.map((childId) => controlMap[childId]).filter(Boolean).filter((ctrl) => state(ctrl.id) !== "hidden").map(toNode);
18009
- };
18010
- const tree = rootControlIds.map((id) => controlMap[id]).filter(Boolean).filter((ctrl) => state(ctrl.id) !== "hidden").map(toNode);
18011
- return selection ? markFadedRoots(tree) : tree;
18012
- }
18013
- function markFadedRoots(nodes, underFaded = false) {
18014
- return nodes.map((node) => {
18015
- const faded = !underFaded && node.faded;
18016
- const next = {
18017
- ...node,
18018
- childrens: markFadedRoots(node.childrens, underFaded || !!node.faded)
18019
- };
18020
- if (faded) {
18021
- next.faded = true;
18022
- } else {
18023
- delete next.faded;
18024
- }
18025
- return next;
18026
- });
18027
- }
18028
-
18029
18245
  // libs/codegen/src/lib/enum-label-helper.ts
18030
- function enumLabels(controlMap, rootControlIds, properties = {}) {
18031
- const names = new Map(
18032
- controlEnums([
18033
- { tree: buildTree(controlMap, rootControlIds), controlMap }
18034
- ]).map((entry2) => [entry2.id, entry2.name])
18035
- );
18036
- const stamped = stampStatePropertyEnums(properties, [controlMap]);
18246
+ function enumLabels(enums, controlMap, properties = {}) {
18247
+ const names = new Map(enums.map((entry2) => [entry2.id, entry2.name]));
18037
18248
  const control = (controlId) => names.get(controlId);
18249
+ const named = (id) => id ? control(id) : void 0;
18038
18250
  return {
18039
18251
  control,
18040
- variable: (variable) => {
18041
- const id = screenVariableEnumId(controlMap, variable);
18042
- return id ? control(id) : void 0;
18043
- },
18044
- property: (property) => {
18045
- const dataType = (stamped[property.id] ?? property).dataType;
18046
- const id = dataType.actionEnumId ?? dataType.sortEnumId;
18047
- return id ? control(id) : void 0;
18048
- }
18252
+ variable: (variable) => named(screenVariableEnumId(controlMap, variable)),
18253
+ property: (property) => named(enumIdOf((properties[property.id] ?? property).dataType))
18049
18254
  };
18050
18255
  }
18051
18256
  function enumMemberLabel(key2) {
@@ -18064,8 +18269,8 @@ function emitEnumFile(appEnum) {
18064
18269
  const asString2 = appEnum.hasValue && appEnum.valueType === "string";
18065
18270
  const members = appEnum.members.map((m, index) => {
18066
18271
  if (asString2) {
18067
- const text2 = typeof m.value === "string" ? m.value : m.key;
18068
- const quoted = `'${text2.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
18272
+ const text3 = typeof m.value === "string" ? m.value : m.key;
18273
+ const quoted = `'${text3.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
18069
18274
  return ` ${m.key} = ${quoted},`;
18070
18275
  }
18071
18276
  const own = appEnum.hasValue && typeof m.value === "number";
@@ -18451,6 +18656,9 @@ function outputOpenStatement(open, ref, inputEntries, indent2, answer, outputs =
18451
18656
  `as: '${open.as}',`,
18452
18657
  `widget: () =>`,
18453
18658
  ` import('${ref.importFrom}').then((m) => m.${ref.className}),`,
18659
+ // The loader above is a new function every call; the name is what tells
18660
+ // a SidePanel already holding this Screen apart (libs/one SidePanel).
18661
+ ...open.as === "side_panel" ? [`screen: '${ref.className}',`] : [],
18454
18662
  ...inputEntries.length ? ["inputs: {", ...inputEntries.map((entry2) => ` ${entry2},`), "},"] : [],
18455
18663
  ...settings.filter(Boolean)
18456
18664
  ];
@@ -19547,14 +19755,14 @@ var searchEmit = (node, control, screenRef) => {
19547
19755
  if (!screenId) return void 0;
19548
19756
  const ref = screenRef?.(screenId);
19549
19757
  if (!ref) return void 0;
19550
- const text2 = listScreenInputs(ref.inputs).find(
19758
+ const text3 = listScreenInputs(ref.inputs).find(
19551
19759
  (declared) => declared.origin === "search"
19552
19760
  );
19553
- if (!text2) return void 0;
19761
+ if (!text3) return void 0;
19554
19762
  const elementMember = searchMemberName(ref.component);
19555
19763
  return {
19556
19764
  elementMember,
19557
- resultInput: text2.name,
19765
+ resultInput: text3.name,
19558
19766
  block: `
19559
19767
  protected readonly ${elementMember} = ${ref.component};
19560
19768
  `,
@@ -20633,7 +20841,7 @@ function variantGuard(node, names, storeProp) {
20633
20841
  }
20634
20842
  return expr;
20635
20843
  }
20636
- function screenVariantsBlock(variants, inputs, computeds, constants, variables, stateComputeds, functions, properties, shapes, storeProp, formModels = {}) {
20844
+ function screenVariantsBlock(variants, inputs, computeds, constants, variables, stateComputeds, functions, properties, shapes, storeProp, formModels = {}, appEnums = {}) {
20637
20845
  const screenRoots2 = screenPropertiesWithComputeds(
20638
20846
  inputs,
20639
20847
  computeds,
@@ -20659,7 +20867,8 @@ function screenVariantsBlock(variants, inputs, computeds, constants, variables,
20659
20867
  (id) => screenRoots2[id] ? constants[id] ? { prefix: "", isSignal: false } : { prefix: "this.", isSignal: true } : `this.${storeProp}.`,
20660
20868
  // A RuleCall asks the root store this class injects (usesAuth).
20661
20869
  "this.",
20662
- functions
20870
+ functions,
20871
+ appEnums
20663
20872
  )}`
20664
20873
  );
20665
20874
  return {
@@ -20711,8 +20920,8 @@ var widgetLoaderExpr = (ref) => ({
20711
20920
  });
20712
20921
  function overlayConfigLiteral(configs) {
20713
20922
  const entries = Object.entries(configs).map(([key2, value]) => {
20714
- const text2 = isRawExpr(value) ? value[RAW_EXPR].split("\n").join("\n ") : JSON.stringify(value, null, 2).split("\n").join("\n ");
20715
- return ` ${JSON.stringify(key2)}: ${text2}`;
20923
+ const text3 = isRawExpr(value) ? value[RAW_EXPR].split("\n").join("\n ") : JSON.stringify(value, null, 2).split("\n").join("\n ");
20924
+ return ` ${JSON.stringify(key2)}: ${text3}`;
20716
20925
  });
20717
20926
  return entries.length ? `{
20718
20927
  ${entries.join(",\n")}
@@ -20980,20 +21189,24 @@ var SCORE_SET_NUMBER_ONLY_KEYS = /* @__PURE__ */ new Set([
20980
21189
  ...NUMBER_ONLY_KEYS,
20981
21190
  "staleAfterDays"
20982
21191
  ]);
20983
- var PRICE_LADDER_NUMBER_ONLY_KEYS = /* @__PURE__ */ new Set([
20984
- ...NUMBER_ONLY_KEYS,
20985
- "value",
20986
- "target",
20987
- "targetLow",
20988
- "targetHigh",
20989
- "maxSpanPct"
20990
- ]);
20991
- var PRICE_LADDER_MARK_NUMBER_ONLY_KEYS = /* @__PURE__ */ new Set([
20992
- ...NUMBER_ONLY_KEYS,
20993
- "value",
20994
- "rank"
20995
- ]);
20996
- var PRICE_LADDER_SLOTS = [BINDING_SLOT.value, BINDING_SLOT.target];
21192
+ var SCALE_NUMBER_ONLY_KEYS = /* @__PURE__ */ new Set([...NUMBER_ONLY_KEYS, "min", "max", "maxSpanPct"]);
21193
+ var SCALE_MARK_NUMBER_ONLY_KEYS = /* @__PURE__ */ new Set([...NUMBER_ONLY_KEYS, "value", "low", "high"]);
21194
+ var SCALE_RELATION_NUMBER_ONLY_KEYS = /* @__PURE__ */ new Set([...NUMBER_ONLY_KEYS, "rightValue", "n"]);
21195
+ var NUMBER_ONLY_KEYS_BY_TYPE = {
21196
+ ["img" /* IMG */]: IMG_NUMBER_ONLY_KEYS,
21197
+ ["section_filter" /* SECTION_FILTER */]: FILTER_NUMBER_ONLY_KEYS,
21198
+ ["score_set_item" /* SCORE_SET_ITEM */]: SCORE_ITEM_NUMBER_ONLY_KEYS,
21199
+ ["score_set" /* SCORE_SET */]: SCORE_SET_NUMBER_ONLY_KEYS,
21200
+ ["scale" /* SCALE */]: SCALE_NUMBER_ONLY_KEYS,
21201
+ ["scale_mark" /* SCALE_MARK */]: SCALE_MARK_NUMBER_ONLY_KEYS,
21202
+ ["scale_relation" /* SCALE_RELATION */]: SCALE_RELATION_NUMBER_ONLY_KEYS
21203
+ };
21204
+ var RAW_BOUND_SLOTS = {
21205
+ ["heat_swatch" /* HEAT_SWATCH */]: [BINDING_SLOT.value],
21206
+ ["score_set_item" /* SCORE_SET_ITEM */]: [BINDING_SLOT.value],
21207
+ ["score_set" /* SCORE_SET */]: [BINDING_SLOT.scoreDate],
21208
+ ["scale_mark" /* SCALE_MARK */]: [BINDING_SLOT.value]
21209
+ };
20997
21210
  var SECTION_TABLE_INPUTS = /* @__PURE__ */ new Set([
20998
21211
  "sticky",
20999
21212
  "margin",
@@ -21037,20 +21250,10 @@ function actionButtonPropNames(tree) {
21037
21250
  walk(tree);
21038
21251
  return byId;
21039
21252
  }
21040
- function collectActionButtonProps(tree, names = actionButtonPropNames(tree)) {
21041
- const props = [];
21042
- const walk = (nodes) => {
21043
- nodes.forEach((node) => {
21044
- const propName = names.get(node.id);
21045
- const buttons = propName ? actionButtonOverrides(node) : void 0;
21046
- if (propName && buttons) {
21047
- props.push({ name: propName, configs: buttons });
21048
- }
21049
- walk(node.childrens);
21050
- });
21051
- };
21052
- walk(tree);
21053
- return props;
21253
+ function withoutNameConfig(node) {
21254
+ if (!node.configs || !("name" in node.configs)) return node;
21255
+ const { name: _name, ...configs } = node.configs;
21256
+ return { ...node, configs };
21054
21257
  }
21055
21258
  function contextMenuConfigPropNames(tree) {
21056
21259
  const names = /* @__PURE__ */ new Map();
@@ -21240,7 +21443,7 @@ function screenVariableEnums(ctx) {
21240
21443
  const out = /* @__PURE__ */ new Map();
21241
21444
  const controls = ctx.controlMap ?? {};
21242
21445
  Object.values(withVariableEnums(ctx.variables ?? {}, controls)).forEach((variable) => {
21243
- const id = variable.actionEnumId ?? variable.sortEnumId;
21446
+ const id = enumIdOf(screenVariableDataType(variable));
21244
21447
  const entry2 = id ? ctx.enums?.find((candidate) => candidate.id === id) : void 0;
21245
21448
  if (entry2) out.set(variable.id, entry2);
21246
21449
  });
@@ -21304,23 +21507,10 @@ ${consts}`
21304
21507
  ...emissions.map((emission) => enumOf(emission.id)).filter((entry2) => !!entry2).map(actionEnumFile)
21305
21508
  ];
21306
21509
  }
21307
- function actionButtonsAttr(node, names) {
21308
- const prop = names?.get(node.id);
21309
- return prop ? ` [buttons]="${prop}"` : "";
21310
- }
21311
21510
  function inlineAttrs(node) {
21312
21511
  return attrsFrom(bodyConfigs(node), numberOnlyKeysOf(node.type));
21313
21512
  }
21314
- var numberOnlyKeysOf = (type) => {
21315
- if (type === "img" /* IMG */) return IMG_NUMBER_ONLY_KEYS;
21316
- if (type === "section_filter" /* SECTION_FILTER */) return FILTER_NUMBER_ONLY_KEYS;
21317
- if (type === "score_set_item" /* SCORE_SET_ITEM */) return SCORE_ITEM_NUMBER_ONLY_KEYS;
21318
- if (type === "score_set" /* SCORE_SET */) return SCORE_SET_NUMBER_ONLY_KEYS;
21319
- if (type === "price_ladder" /* PRICE_LADDER */) return PRICE_LADDER_NUMBER_ONLY_KEYS;
21320
- if (type === "price_ladder_mark" /* PRICE_LADDER_MARK */)
21321
- return PRICE_LADDER_MARK_NUMBER_ONLY_KEYS;
21322
- return NUMBER_ONLY_KEYS;
21323
- };
21513
+ var numberOnlyKeysOf = (type) => NUMBER_ONLY_KEYS_BY_TYPE[type] ?? NUMBER_ONLY_KEYS;
21324
21514
  function wrapInGuard(markup, guard, pad2) {
21325
21515
  if (!guard) return markup;
21326
21516
  return `${pad2}@if (${guard}) {
@@ -21345,7 +21535,7 @@ function renderBranch(node, indent2, names, methods, operationOf, storeProp, ctx
21345
21535
  chain.push({ arm, guard });
21346
21536
  }
21347
21537
  if (!chain.length) return "";
21348
- const body = (arm, at) => arm.childrens.map(
21538
+ const render = (children, at) => children.map(
21349
21539
  (child) => renderNode(
21350
21540
  child,
21351
21541
  at,
@@ -21357,19 +21547,73 @@ function renderBranch(node, indent2, names, methods, operationOf, storeProp, ctx
21357
21547
  wires,
21358
21548
  payloads
21359
21549
  )
21360
- ).filter(Boolean).join("\n");
21361
- if (chain.length === 1 && !chain[0].guard) return body(chain[0].arm, indent2);
21550
+ ).filter(Boolean);
21551
+ if (chain.length === 1 && !chain[0].guard) {
21552
+ return render(chain[0].arm.childrens, indent2).join("\n");
21553
+ }
21362
21554
  const pad2 = " ".repeat(indent2);
21363
- const lines = [];
21364
- chain.forEach((entry2, index) => {
21365
- lines.push(
21366
- index === 0 ? `${pad2}@if (${entry2.guard}) {` : entry2.guard ? `${pad2}} @else if (${entry2.guard}) {` : `${pad2}} @else {`
21367
- );
21368
- const inner = body(entry2.arm, indent2 + 1);
21369
- if (inner) lines.push(inner);
21370
- });
21371
- lines.push(`${pad2}}`);
21372
- return lines.join("\n");
21555
+ const slots = branchSlots(chain.map((entry2) => entry2.arm));
21556
+ const chainFor = (slot) => {
21557
+ const lines = [];
21558
+ chain.forEach((entry2, index) => {
21559
+ lines.push(
21560
+ index === 0 ? `${pad2}@if (${entry2.guard}) {` : entry2.guard ? `${pad2}} @else if (${entry2.guard}) {` : `${pad2}} @else {`
21561
+ );
21562
+ const children = entry2.arm.childrens.filter(
21563
+ (child) => projectionSlotOf(child) === slot
21564
+ );
21565
+ const wrap = !!slot && children.length > 1;
21566
+ const inner = render(children, indent2 + (wrap ? 2 : 1));
21567
+ if (!inner.length) return;
21568
+ if (wrap) {
21569
+ lines.push(
21570
+ `${pad2} <ng-container ngProjectAs="${slot}">`,
21571
+ ...inner,
21572
+ `${pad2} </ng-container>`
21573
+ );
21574
+ } else {
21575
+ lines.push(...inner);
21576
+ }
21577
+ });
21578
+ lines.push(`${pad2}}`);
21579
+ return lines.join("\n");
21580
+ };
21581
+ return slots.map(chainFor).join("\n");
21582
+ }
21583
+ var NAMED_SLOT_TAGS = /* @__PURE__ */ new Set([
21584
+ "m-section-header",
21585
+ "m-section-hero",
21586
+ "m-jumbotron",
21587
+ "m-section-search",
21588
+ "m-section-stepper",
21589
+ "m-section-badges",
21590
+ "m-section-toggle",
21591
+ "m-action",
21592
+ "m-one-action",
21593
+ "m-section-back",
21594
+ "m-section-filter",
21595
+ "m-section-filter-group",
21596
+ "m-carousel",
21597
+ "m-one-carousel",
21598
+ "m-section-pagination",
21599
+ "m-section-footer",
21600
+ "m-app-logo"
21601
+ ]);
21602
+ function projectionSlotOf(node) {
21603
+ const tag = codegenFor(node.type)?.tag.split(" ")[0];
21604
+ return tag && NAMED_SLOT_TAGS.has(tag) ? tag : "";
21605
+ }
21606
+ function branchSlots(arms) {
21607
+ const named = /* @__PURE__ */ new Set();
21608
+ let hasDefault = false;
21609
+ for (const arm of arms) {
21610
+ for (const child of arm.childrens) {
21611
+ const slot = projectionSlotOf(child);
21612
+ if (slot) named.add(slot);
21613
+ else hasDefault = true;
21614
+ }
21615
+ }
21616
+ return [...hasDefault || !named.size ? [""] : [], ...named];
21373
21617
  }
21374
21618
  function renderRepeat(node, indent2, names, methods, operationOf, storeProp, ctx, wires, payloads) {
21375
21619
  const pad2 = " ".repeat(indent2);
@@ -21571,11 +21815,8 @@ var attrBindingSlots = (type) => {
21571
21815
  if (type === "remote" /* REMOTE */) return REMOTE_VALUE_SLOTS;
21572
21816
  if (type === "app_logo" /* APP_LOGO */) return APP_LOGO_VALUE_SLOTS;
21573
21817
  if (type === "section_pagination" /* SECTION_PAGINATION */) return [BINDING_SLOT.total];
21574
- if (type === "heat_swatch" /* HEAT_SWATCH */) return [BINDING_SLOT.value];
21575
- if (type === "score_set_item" /* SCORE_SET_ITEM */) return [BINDING_SLOT.value];
21576
- if (type === "score_set" /* SCORE_SET */) return [BINDING_SLOT.scoreDate];
21577
- if (type === "price_ladder" /* PRICE_LADDER */) return PRICE_LADDER_SLOTS;
21578
- if (type === "price_ladder_mark" /* PRICE_LADDER_MARK */) return [BINDING_SLOT.value];
21818
+ const raw = RAW_BOUND_SLOTS[type];
21819
+ if (raw) return raw;
21579
21820
  if (type === "section_chart_series" /* SECTION_CHART_SERIES */)
21580
21821
  return [BINDING_SLOT.data, BINDING_SLOT.label];
21581
21822
  return hasTextSource(type) ? [BINDING_SLOT.label] : [];
@@ -21848,20 +22089,7 @@ function boundAttrs(node, ctx, storeProp) {
21848
22089
  }
21849
22090
  const total = paginationTotalRead(node, ctx, storeProp);
21850
22091
  if (total) parts.push(` [total]="${total.read}"`);
21851
- if (node.type === "heat_swatch" /* HEAT_SWATCH */ && bindings?.[BINDING_SLOT.value]) {
21852
- const expr = bindingExpression(bindings[BINDING_SLOT.value], scope);
21853
- if (expr) parts.push(` [value]="${expr}"`);
21854
- }
21855
- if (node.type === "score_set_item" /* SCORE_SET_ITEM */ && bindings?.[BINDING_SLOT.value]) {
21856
- const expr = bindingExpression(bindings[BINDING_SLOT.value], scope);
21857
- if (expr) parts.push(` [value]="${expr}"`);
21858
- }
21859
- if (node.type === "score_set" /* SCORE_SET */ && bindings?.[BINDING_SLOT.scoreDate]) {
21860
- const expr = bindingExpression(bindings[BINDING_SLOT.scoreDate], scope);
21861
- if (expr) parts.push(` [scoreDate]="${expr}"`);
21862
- }
21863
- const ladderSlots = node.type === "price_ladder" /* PRICE_LADDER */ ? PRICE_LADDER_SLOTS : node.type === "price_ladder_mark" /* PRICE_LADDER_MARK */ ? [BINDING_SLOT.value] : [];
21864
- for (const slot of ladderSlots) {
22092
+ for (const slot of RAW_BOUND_SLOTS[node.type] ?? []) {
21865
22093
  if (!bindings?.[slot]) continue;
21866
22094
  const expr = bindingExpression(bindings[slot], scope);
21867
22095
  if (expr) parts.push(` [${slot}]="${expr}"`);
@@ -22032,26 +22260,15 @@ function tagAttrs(node, ctx, storeProp) {
22032
22260
  delete configs2["link"];
22033
22261
  return `${inlineAttrs({ ...node, configs: configs2 })}${boundAttrs(node, ctx, storeProp)}`;
22034
22262
  }
22035
- if (node.type === "heat_swatch" /* HEAT_SWATCH */ && ctx.controlMap?.[node.id]?.bindings?.[BINDING_SLOT.value]) {
22036
- const configs2 = { ...node.configs ?? {} };
22037
- delete configs2[BINDING_SLOT.value];
22038
- return `${inlineAttrs({ ...node, configs: configs2 })}${boundAttrs(node, ctx, storeProp)}`;
22039
- }
22040
- const scoreSlot = node.type === "score_set_item" /* SCORE_SET_ITEM */ ? BINDING_SLOT.value : node.type === "score_set" /* SCORE_SET */ ? BINDING_SLOT.scoreDate : void 0;
22041
- if (scoreSlot && ctx.controlMap?.[node.id]?.bindings?.[scoreSlot]) {
22263
+ const bound = ctx.controlMap?.[node.id]?.bindings ?? {};
22264
+ const rawBound = (RAW_BOUND_SLOTS[node.type] ?? []).filter(
22265
+ (slot) => bound[slot]
22266
+ );
22267
+ if (rawBound.length) {
22042
22268
  const configs2 = { ...node.configs ?? {} };
22043
- delete configs2[scoreSlot];
22269
+ for (const slot of rawBound) delete configs2[slot];
22044
22270
  return `${inlineAttrs({ ...node, configs: configs2 })}${boundAttrs(node, ctx, storeProp)}`;
22045
22271
  }
22046
- if (node.type === "price_ladder" /* PRICE_LADDER */ || node.type === "price_ladder_mark" /* PRICE_LADDER_MARK */) {
22047
- const bound = ctx.controlMap?.[node.id]?.bindings ?? {};
22048
- const slots = attrBindingSlots(node.type).filter((s) => bound[s]);
22049
- if (slots.length) {
22050
- const configs2 = { ...node.configs ?? {} };
22051
- for (const s of slots) delete configs2[s];
22052
- return `${inlineAttrs({ ...node, configs: configs2 })}${boundAttrs(node, ctx, storeProp)}`;
22053
- }
22054
- }
22055
22272
  if (node.type === "section_filter" /* SECTION_FILTER */) {
22056
22273
  const bindings = ctx.controlMap?.[node.id]?.bindings;
22057
22274
  const configs2 = { ...node.configs ?? {} };
@@ -22411,8 +22628,7 @@ function statePatchFor(node, output, payload, storeProp, ctx, writes = node.outp
22411
22628
  if (!rows.length) return void 0;
22412
22629
  const enumById = new Map((ctx.enums ?? []).map((entry2) => [entry2.id, entry2]));
22413
22630
  const enumOf = ({ id }) => {
22414
- const dataType = properties[id]?.dataType;
22415
- const enumId = dataType?.actionEnumId ?? dataType?.sortEnumId;
22631
+ const enumId = enumIdOf(properties[id]?.dataType);
22416
22632
  return enumId ? enumById.get(enumId) : void 0;
22417
22633
  };
22418
22634
  const root = actionEventRoot(node, eventRoot, enumOf);
@@ -22438,7 +22654,8 @@ function statePatchFor(node, output, payload, storeProp, ctx, writes = node.outp
22438
22654
  // Filter's own shape (libs/one ADR 0026). Undefined for every other
22439
22655
  // Control, whose members are already typed.
22440
22656
  filterGroupEventMember(node),
22441
- enumNarrow(node, output, enumOf)
22657
+ enumNarrow(node, output, enumOf),
22658
+ ctx.functions ?? {}
22442
22659
  );
22443
22660
  }
22444
22661
  function screenWritesFor(node, output, payload, ctx, writes = node.outputScreenWrites, eventRoot = "$event", scope = "template") {
@@ -22461,7 +22678,8 @@ function screenWritesFor(node, output, payload, ctx, writes = node.outputScreenW
22461
22678
  root,
22462
22679
  scope,
22463
22680
  filterGroupEventMember(node),
22464
- enumNarrow(node, output, enumOf)
22681
+ enumNarrow(node, output, enumOf),
22682
+ ctx.functions ?? {}
22465
22683
  );
22466
22684
  }
22467
22685
  function enumNarrow(node, output, enumOf) {
@@ -22528,8 +22746,8 @@ var payloadPropBase = (node) => {
22528
22746
  return String(node.type);
22529
22747
  return name3;
22530
22748
  };
22531
- var camelCase2 = (text2) => {
22532
- const parts = text2.split(/[^A-Za-z0-9]+/).filter(Boolean);
22749
+ var camelCase2 = (text3) => {
22750
+ const parts = text3.split(/[^A-Za-z0-9]+/).filter(Boolean);
22533
22751
  if (!parts.length) return "form";
22534
22752
  const name3 = parts.map(
22535
22753
  (part, i) => i === 0 ? part.charAt(0).toLowerCase() + part.slice(1) : part.charAt(0).toUpperCase() + part.slice(1)
@@ -22688,15 +22906,14 @@ ${" ".repeat(indent2 + index)}}`,
22688
22906
  ctx
22689
22907
  );
22690
22908
  }
22691
- const attrs = `${tagAttrs(node, ctx, storeProp)}${payloadAttr(node, payloads)}${directiveAttrs(
22909
+ const foldedName = ctx.foldedButtonNames?.get(node.id);
22910
+ const attrNode = foldedName ? withoutNameConfig(node) : node;
22911
+ const attrs = `${foldedName ? ` name="${foldedName}"` : ""}${tagAttrs(attrNode, ctx, storeProp)}${payloadAttr(node, payloads)}${directiveAttrs(
22692
22912
  node,
22693
22913
  ctx.overlayNames,
22694
22914
  bindingScope(ctx, storeProp),
22695
22915
  ctx.controlMap?.[node.id]?.bindings
22696
- )}${sectionTableRowItemAttr(node, ctx.controlMap)}${outputAttrs(node, methods, operationOf, storeProp, ctx)}`;
22697
- if (node.type === "section_action" /* SECTION_ACTION */) {
22698
- return `${pad2}<${tag}${attrs}${actionButtonsAttr(node, ctx.actionButtonNames)} />`;
22699
- }
22916
+ )}${sectionTableRowItemAttr(node, ctx.controlMap)}${foldedName ? "" : outputAttrs(node, methods, operationOf, storeProp, ctx)}`;
22700
22917
  const totalGuard = paginationTotalRead(node, ctx, storeProp)?.guard;
22701
22918
  if (totalGuard) {
22702
22919
  return `${pad2}@if (${totalGuard}; as ${PAGINATION_TOTAL_ALIAS}) {
@@ -22804,7 +23021,7 @@ function planScreenEmit(tree, variants = {}, featureName = "feature", ctx = {})
22804
23021
  // or it is not unique at all, and the class assigns the same names from
22805
23022
  // the same Tree.
22806
23023
  overlayNames: overlayPropNames(tree),
22807
- actionButtonNames: actionButtonPropNames(tree),
23024
+ foldedButtonNames: foldedButtonNames(tree),
22808
23025
  contextMenuConfigNames: contextMenuConfigPropNames(tree),
22809
23026
  audiencePickerConfigNames: audiencePickerConfigPropNames(tree),
22810
23027
  menuVariants: menuVariantLookup(variants, ctx.screenVariants),
@@ -22822,7 +23039,7 @@ function generateHtml(tree, variants = {}, methods = {}, operationOf = () => voi
22822
23039
  // it is not unique at all, and the class assigns the same names from the
22823
23040
  // same Tree.
22824
23041
  overlayNames: overlayPropNames(tree),
22825
- actionButtonNames: actionButtonPropNames(tree),
23042
+ foldedButtonNames: foldedButtonNames(tree),
22826
23043
  contextMenuConfigNames: contextMenuConfigPropNames(tree),
22827
23044
  audiencePickerConfigNames: audiencePickerConfigPropNames(tree),
22828
23045
  menuVariants: menuVariantLookup(variants, ctx.screenVariants),
@@ -22970,8 +23187,8 @@ function everyOutputAttrs(tree, methods, operationOf, storeProp, ctx) {
22970
23187
  return out.join("\n");
22971
23188
  }
22972
23189
  var ENUM_READERS = [ACTION_NAME_READER, ENUM_VALUE_READER];
22973
- var enumReadersIn = (text2) => ENUM_READERS.filter((reader) => text2.includes(`${reader}(`));
22974
- var enumsNamedIn = (text2, enums) => enums.filter((entry2) => new RegExp(`\\b${entry2.name}\\b`).test(text2));
23190
+ var enumReadersIn = (text3) => ENUM_READERS.filter((reader) => text3.includes(`${reader}(`));
23191
+ var enumsNamedIn = (text3, enums) => enums.filter((entry2) => new RegExp(`\\b${entry2.name}\\b`).test(text3));
22975
23192
  function hasStateWrite(tree, ctx) {
22976
23193
  if (!ctx.properties) return false;
22977
23194
  return tree.some(
@@ -23039,6 +23256,50 @@ function collectTemplateTransforms(tree, methods, operationOf, constants = {}, f
23039
23256
  if (row.transform) exprs.push(row.transform);
23040
23257
  }
23041
23258
  }
23259
+ if (ctx) {
23260
+ for (const output of Object.keys(node.outputScreenMethods ?? {})) {
23261
+ if (screenMethodCall(node, output, ctx, storeProp, "") === void 0)
23262
+ continue;
23263
+ for (const row of outputArgRows(node.outputArgs, output)) {
23264
+ if (row.transform) exprs.push(row.transform);
23265
+ }
23266
+ }
23267
+ for (const output of Object.keys(node.outputScreenWrites ?? {})) {
23268
+ const emits = screenWritesFor(
23269
+ node,
23270
+ output,
23271
+ nodePayloadShape(node, output, ctx),
23272
+ ctx,
23273
+ node.outputScreenWrites,
23274
+ nodePayloadEventRoot(node, output)
23275
+ ).length;
23276
+ if (emits) {
23277
+ exprs.push(
23278
+ ...writeEventTransforms(
23279
+ screenWriteRows(node.outputScreenWrites, output)
23280
+ )
23281
+ );
23282
+ }
23283
+ }
23284
+ for (const output of Object.keys(node.outputWrites ?? {})) {
23285
+ const emits = statePatchFor(
23286
+ node,
23287
+ output,
23288
+ nodePayloadShape(node, output, ctx),
23289
+ storeProp,
23290
+ ctx,
23291
+ node.outputWrites,
23292
+ nodePayloadEventRoot(node, output)
23293
+ );
23294
+ if (emits) {
23295
+ exprs.push(
23296
+ ...writeEventTransforms(
23297
+ stateWriteRows(node.outputWrites, output)
23298
+ )
23299
+ );
23300
+ }
23301
+ }
23302
+ }
23042
23303
  for (const binding of Object.values(
23043
23304
  controlMap[node.id]?.bindings ?? {}
23044
23305
  )) {
@@ -23331,7 +23592,9 @@ function screenMethodsBlock(screenMethods, methods, operationOf, storeProp, ctx,
23331
23592
  constants,
23332
23593
  eventRoot,
23333
23594
  "class",
23334
- screenMethodParamRead
23595
+ screenMethodParamRead,
23596
+ void 0,
23597
+ ctx.functions ?? {}
23335
23598
  )
23336
23599
  );
23337
23600
  statements.push(
@@ -23358,7 +23621,9 @@ function screenMethodsBlock(screenMethods, methods, operationOf, storeProp, ctx,
23358
23621
  constants,
23359
23622
  eventRoot,
23360
23623
  "class",
23361
- screenMethodParamRead
23624
+ screenMethodParamRead,
23625
+ void 0,
23626
+ ctx.functions ?? {}
23362
23627
  );
23363
23628
  if (patch) statements.push(patch);
23364
23629
  }
@@ -23996,7 +24261,16 @@ function menuConditionMembersBlock(tree, ctx, roots, screenRoots2, constants, sh
23996
24261
  };
23997
24262
  const menuConditionExpression = (rule, variants) => {
23998
24263
  if (variants?.length) return variantFold(variants);
23999
- return rule ? generateRuleExpression(rule, roots, shapes, true, prefix, "this.") : void 0;
24264
+ return rule ? generateRuleExpression(
24265
+ rule,
24266
+ roots,
24267
+ shapes,
24268
+ true,
24269
+ prefix,
24270
+ "this.",
24271
+ {},
24272
+ ctx.appEnums
24273
+ ) : void 0;
24000
24274
  };
24001
24275
  const walk = (nodes) => {
24002
24276
  for (const node of nodes) {
@@ -24192,7 +24466,7 @@ ${body ? `${body}
24192
24466
  return emitted.join("");
24193
24467
  }
24194
24468
  function outputArmHandlerName(controlId, output) {
24195
- const part = (text2) => text2.split(/[^a-zA-Z0-9]+/).filter(Boolean).map((piece) => piece.charAt(0).toUpperCase() + piece.slice(1)).join("");
24469
+ const part = (text3) => text3.split(/[^a-zA-Z0-9]+/).filter(Boolean).map((piece) => piece.charAt(0).toUpperCase() + piece.slice(1)).join("");
24196
24470
  return `onArm${part(controlId.slice(0, 8))}${part(output)}`;
24197
24471
  }
24198
24472
  function armSubjectExpr(check, node, ctx, storeProp, payload, eventRoot) {
@@ -25028,7 +25302,6 @@ function collectComponentImportEntries(tree, ctx = {}) {
25028
25302
  )) {
25029
25303
  entries.push({ component: "TranslatePipe", from: ONE_IMPORT_MODULE });
25030
25304
  }
25031
- if (node.type === "section_action" /* SECTION_ACTION */) return;
25032
25305
  if (node.type === "repeat" /* REPEAT */ && ctx.controlMap?.[node.id] && isKeyedRepeat(ctx.controlMap[node.id], bindingScope(ctx, ""))) {
25033
25306
  entries.push({ component: "KeyValuePipe", from: "@angular/common" });
25034
25307
  }
@@ -25094,9 +25367,7 @@ function generateStateType(featureName, properties, shapes = {}, enums = [], ini
25094
25367
  const enumById = new Map(enums.map((entry2) => [entry2.id, entry2]));
25095
25368
  const enumImports = Array.from(
25096
25369
  new Set(
25097
- dataProperties.map(
25098
- (property) => property.dataType.actionEnumId ?? property.dataType.sortEnumId
25099
- ).map((id) => id ? enumById.get(id) : void 0).filter((entry2) => !!entry2).map((entry2) => enumImportLine(entry2, "./"))
25370
+ dataProperties.map((property) => enumIdOf(property.dataType)).map((id) => id ? enumById.get(id) : void 0).filter((entry2) => !!entry2).map((entry2) => enumImportLine(entry2, "./"))
25100
25371
  )
25101
25372
  ).join("\n");
25102
25373
  const members = dataProperties.map(
@@ -25695,11 +25966,7 @@ function generateTs(tree, naming, featureName, variants = {}, methods = {}, oper
25695
25966
  tree,
25696
25967
  ctx.overlayWidget,
25697
25968
  plan?.ctx.overlayNames ?? overlayPropNames(tree)
25698
- ),
25699
- // A SectionAction's folded Buttons take the same route for the same reason:
25700
- // the list is authored, never changes at runtime, and cannot be written in
25701
- // the template without tripping `no-inline-config-template` (ADR 0090).
25702
- ...collectActionButtonProps(tree, plan?.ctx.actionButtonNames)
25969
+ )
25703
25970
  ].map(
25704
25971
  (prop) => ` protected readonly ${prop.name} = ${overlayConfigLiteral(
25705
25972
  prop.configs
@@ -26024,7 +26291,8 @@ ${tables.map(
26024
26291
  // (ADR 0175).
26025
26292
  { ...ctx.shapes ?? shapes, ...formShapeMap(ctx.controlMap ?? {}) },
26026
26293
  needsStore ? featureStoreProp(featureName) : "",
26027
- ctx.formModels ?? {}
26294
+ ctx.formModels ?? {},
26295
+ ctx.appEnums ?? {}
26028
26296
  );
26029
26297
  const outputOpenBody = outputOpenMembersBlock(
26030
26298
  tree,
@@ -26113,6 +26381,17 @@ ${tables.map(
26113
26381
  const fn = (ctx.functions ?? {})[one.functionId ?? ""];
26114
26382
  if (fn) screenFunctions.set(fn.name, fn);
26115
26383
  }
26384
+ const handlerTransforms = writeEventTransforms([
26385
+ ...handler.screenWrites ?? [],
26386
+ ...handler.writes ?? []
26387
+ ]);
26388
+ for (const id of templateTransformRefs(
26389
+ handlerTransforms,
26390
+ ctx.functions ?? {}
26391
+ ).functionIds) {
26392
+ const fn = (ctx.functions ?? {})[id];
26393
+ if (fn) screenFunctions.set(fn.name, fn);
26394
+ }
26116
26395
  }
26117
26396
  for (const control of Object.values(ctx.controlMap ?? {})) {
26118
26397
  for (const output of Object.keys(control.outputNewTabs ?? {})) {
@@ -26299,7 +26578,11 @@ ${tables.map(
26299
26578
  ctx.functions ?? {}
26300
26579
  );
26301
26580
  const memberEnums = enumMemberEnums(ctx.controlMap ?? {}, ctx.appEnums);
26302
- const memberEnumImports = memberEnums.map(
26581
+ const ruleText = `${screenVariantsBody}${menuConditionBody}`;
26582
+ const ruleEnums = Object.values(ctx.appEnums ?? {}).filter((appEnum) => !memberEnums.includes(appEnum)).filter(
26583
+ (appEnum) => new RegExp(`(^|[^\\w.])${appEnum.name}\\.`).test(ruleText)
26584
+ ).sort((a, b) => a.name.localeCompare(b.name));
26585
+ const memberEnumImports = [...memberEnums, ...ruleEnums].map(
26303
26586
  (appEnum) => `import { ${appEnum.name} } from '../../../shared/type/${appEnum.fileName}';`
26304
26587
  ).filter((line) => !inputTypeImports.includes(line)).map((line) => `${line}
26305
26588
  `).join("");
@@ -26640,8 +26923,8 @@ var docEmitPath = (name3, lang) => `mag_assets/${docSourcePath(name3, lang)}`;
26640
26923
  function docsToFiles(docs, pathOf) {
26641
26924
  const files3 = {};
26642
26925
  for (const [name3, byLang] of Object.entries(docs)) {
26643
- for (const [lang, text2] of Object.entries(byLang)) {
26644
- files3[pathOf(name3, lang)] = text2;
26926
+ for (const [lang, text3] of Object.entries(byLang)) {
26927
+ files3[pathOf(name3, lang)] = text3;
26645
26928
  }
26646
26929
  }
26647
26930
  return files3;
@@ -26649,14 +26932,14 @@ function docsToFiles(docs, pathOf) {
26649
26932
  function docsFromFiles(files3, root) {
26650
26933
  const docs = {};
26651
26934
  const prefix = `${root}/`;
26652
- for (const [path, text2] of Object.entries(files3)) {
26935
+ for (const [path, text3] of Object.entries(files3)) {
26653
26936
  if (!path.startsWith(prefix) || !path.endsWith(MARKDOWN_EXTENSION)) continue;
26654
26937
  const parts = path.slice(prefix.length).split("/");
26655
26938
  if (parts.length !== 2) continue;
26656
26939
  const [lang, file] = parts;
26657
26940
  const name3 = file.slice(0, -MARKDOWN_EXTENSION.length);
26658
26941
  if (!lang || !name3) continue;
26659
- (docs[name3] ??= {})[lang] = text2;
26942
+ (docs[name3] ??= {})[lang] = text3;
26660
26943
  }
26661
26944
  return docs;
26662
26945
  }
@@ -26678,7 +26961,7 @@ __export(package_exports, {
26678
26961
  version: () => version
26679
26962
  });
26680
26963
  var name = "@magmonium/one";
26681
- var version = "0.4.82";
26964
+ var version = "0.4.88";
26682
26965
  var description = "Magmonium One \u2014 Angular design-system primitives for mm Apps";
26683
26966
  var author = "magmonium";
26684
26967
  var license = "MIT";
@@ -26746,7 +27029,7 @@ __export(package_exports2, {
26746
27029
  version: () => version2
26747
27030
  });
26748
27031
  var name2 = "@magmonium/cli";
26749
- var version2 = "0.8.24";
27032
+ var version2 = "0.8.25";
26750
27033
  var description2 = "A powerful and extensible asset compilation tool that can be shared across multiple projects";
26751
27034
  var bin = {
26752
27035
  "mag-cli": "bin/cli.js"
@@ -26853,9 +27136,202 @@ var timersReferencing = (timers, propertyId) => Object.values(timers ?? {}).filt
26853
27136
  (timer) => timerPropertyIds(timer).includes(propertyId)
26854
27137
  );
26855
27138
 
27139
+ // libs/codegen/src/lib/price-ladder-migration.ts
27140
+ var PRICE_LEVELS = {
27141
+ sma10: { label: "sma-10", kind: "level" },
27142
+ sma50: { label: "sma-50", kind: "level" },
27143
+ sma100: { label: "sma-100", kind: "level" },
27144
+ sma200: { label: "sma-200", kind: "level" },
27145
+ ema10: { label: "ema-10", kind: "level" },
27146
+ ema50: { label: "ema-50", kind: "level" },
27147
+ ema100: { label: "ema-100", kind: "level" },
27148
+ ema200: { label: "ema-200", kind: "level" },
27149
+ low52w: { label: "52w-low", kind: "bound" },
27150
+ high52w: { label: "52w-high", kind: "bound" },
27151
+ current: { label: "current-price", kind: "level" },
27152
+ forecast: { label: "model-forecast", kind: "target" }
27153
+ };
27154
+ var LADDER = "price_ladder";
27155
+ var LADDER_MARK = "price_ladder_mark";
27156
+ var LADDER_SIGNAL = "price_ladder_signal";
27157
+ var CURRENCY_OF_SYMBOL = { "\u20B9": "INR", $: "USD", "\u20AC": "EUR", "\xA3": "GBP", "\xA5": "JPY" };
27158
+ var VARIANT_TO_ORIENTATION = { line: "horizontal", list: "vertical" };
27159
+ var LADDER_ONLY = [
27160
+ "value",
27161
+ "valueLabel",
27162
+ "target",
27163
+ "targetLow",
27164
+ "targetHigh",
27165
+ "targetLabel",
27166
+ "targetNote",
27167
+ "variant",
27168
+ "symbol",
27169
+ "signals",
27170
+ "crossFrom",
27171
+ "crossTo",
27172
+ "crossTone"
27173
+ ];
27174
+ var orientationOf = (variant) => typeof variant === "string" ? VARIANT_TO_ORIENTATION[variant] : void 0;
27175
+ var recordOf = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
27176
+ var numberOr = (value) => typeof value === "number" && Number.isFinite(value) ? value : void 0;
27177
+ var text2 = (value) => typeof value === "string" ? value.trim() : "";
27178
+ var without = (record, keys) => Object.fromEntries(Object.entries(record).filter(([k]) => !keys.includes(k)));
27179
+ var defined = (record) => Object.fromEntries(Object.entries(record).filter(([, v]) => v !== void 0 && v !== ""));
27180
+ var signalNames = (raw) => (typeof raw === "string" ? raw.split(/[\s,]+/) : Array.isArray(raw) ? raw : []).filter(
27181
+ (s) => typeof s === "string" && !!s
27182
+ );
27183
+ var migratePriceLadders = (controlMap) => {
27184
+ const map = recordOf(controlMap);
27185
+ if (!map) return controlMap;
27186
+ const out = { ...map };
27187
+ for (const [id, raw] of Object.entries(map)) {
27188
+ const ladder = recordOf(raw);
27189
+ if (ladder?.["type"] === LADDER) migrateLadder(id, ladder, out);
27190
+ }
27191
+ return out;
27192
+ };
27193
+ var migrateLadder = (id, ladder, out) => {
27194
+ const configs = recordOf(ladder["configs"]) ?? {};
27195
+ const bindings = recordOf(ladder["bindings"]) ?? {};
27196
+ const childIds = (Array.isArray(ladder["childrens"]) ? ladder["childrens"] : []).filter(
27197
+ (c) => typeof c === "string"
27198
+ );
27199
+ const mint = (key2) => {
27200
+ const base = `${id}_${key2.replace(/[^a-z0-9]+/gi, "_")}`;
27201
+ let candidate = base;
27202
+ for (let n = 2; candidate in out; n++) candidate = `${base}_${n}`;
27203
+ return candidate;
27204
+ };
27205
+ const add = (key2, type, own, extra = {}) => {
27206
+ const cid = mint(key2);
27207
+ out[cid] = { id: cid, type, parentId: id, childrens: [], configs: { name: cid, ...defined(own) }, ...extra };
27208
+ return cid;
27209
+ };
27210
+ const markKeys = /* @__PURE__ */ new Set();
27211
+ for (const cid of childIds) {
27212
+ const mark = recordOf(out[cid]);
27213
+ if (mark?.["type"] !== LADDER_MARK) continue;
27214
+ const own = recordOf(mark["configs"]) ?? {};
27215
+ const key2 = text2(own["key"]) || cid;
27216
+ const level = PRICE_LEVELS[key2];
27217
+ markKeys.add(key2);
27218
+ const kind = key2 === "forecast" ? "target" : key2 === "current" ? "level" : text2(own["kind"]) || level?.kind || "level";
27219
+ out[cid] = {
27220
+ ...mark,
27221
+ type: "scale_mark",
27222
+ configs: defined({
27223
+ ...without(own, ["rank", "note", "kind", "label"]),
27224
+ key: key2,
27225
+ label: text2(own["label"]) || level?.label,
27226
+ kind: kind === "level" ? void 0 : kind,
27227
+ primary: key2 === "current" ? true : void 0,
27228
+ ...key2 === "forecast" ? { low: numberOr(configs["targetLow"]), high: numberOr(configs["targetHigh"]) } : {}
27229
+ })
27230
+ };
27231
+ }
27232
+ const leading = [];
27233
+ if (!markKeys.has("current")) {
27234
+ leading.push(
27235
+ add(
27236
+ "current",
27237
+ "scale_mark",
27238
+ { key: "current", label: text2(configs["valueLabel"]) || "current-price", value: numberOr(configs["value"]), primary: true },
27239
+ bindings["value"] ? { bindings: { value: bindings["value"] } } : {}
27240
+ )
27241
+ );
27242
+ }
27243
+ const forecast = {
27244
+ value: numberOr(configs["target"]),
27245
+ low: numberOr(configs["targetLow"]),
27246
+ high: numberOr(configs["targetHigh"])
27247
+ };
27248
+ if (!markKeys.has("forecast") && (forecast.value !== void 0 || forecast.low !== void 0 || forecast.high !== void 0 || bindings["target"])) {
27249
+ leading.push(
27250
+ add(
27251
+ "forecast",
27252
+ "scale_mark",
27253
+ { key: "forecast", label: text2(configs["targetLabel"]) || "model-forecast", kind: "target", ...forecast },
27254
+ bindings["target"] ? { bindings: { value: bindings["target"] } } : {}
27255
+ )
27256
+ );
27257
+ }
27258
+ const asked = new Set(signalNames(configs["signals"]));
27259
+ const carried = /* @__PURE__ */ new Set();
27260
+ for (const cid of childIds) {
27261
+ const signal = recordOf(out[cid]);
27262
+ if (signal?.["type"] !== LADDER_SIGNAL) continue;
27263
+ const own = recordOf(signal["configs"]) ?? {};
27264
+ const rule = text2(own["rule"]);
27265
+ if (isPriceRule(rule)) {
27266
+ asked.add(rule);
27267
+ carried.add(rule);
27268
+ const relation = priceRelationsFor([rule])[0];
27269
+ out[cid] = {
27270
+ ...signal,
27271
+ type: "scale_relation",
27272
+ configs: defined({
27273
+ name: own["name"],
27274
+ ...relation,
27275
+ label: text2(own["label"]) || relation.label,
27276
+ detail: text2(own["detail"]) || void 0
27277
+ })
27278
+ };
27279
+ } else {
27280
+ out[cid] = {
27281
+ ...signal,
27282
+ type: "scale_relation",
27283
+ configs: defined({
27284
+ name: own["name"],
27285
+ key: text2(own["key"]) || cid,
27286
+ label: text2(own["label"]),
27287
+ tone: text2(own["tone"]) || "neutral",
27288
+ type: "always",
27289
+ detail: text2(own["detail"])
27290
+ })
27291
+ };
27292
+ }
27293
+ }
27294
+ const trailing = [];
27295
+ const rules = priceRelationsFor(asked.has("all") ? PRICE_RULES.map((r) => r.key) : [...asked]);
27296
+ for (const relation of rules) {
27297
+ if (carried.has(relation.key)) continue;
27298
+ trailing.push(add(relation.key, "scale_relation", { ...relation }));
27299
+ }
27300
+ const from = text2(configs["crossFrom"]);
27301
+ const to = text2(configs["crossTo"]);
27302
+ if (from && to) {
27303
+ const tone = text2(configs["crossTone"]) || "neutral";
27304
+ for (const [key2, op] of [["cross-pair-above", "gte"], ["cross-pair-below", "lt"]]) {
27305
+ trailing.push(
27306
+ add(key2, "scale_relation", { key: key2, tone, type: "compare", left: from, op, rightKind: "mark", right: to, hidden: true, bracket: true })
27307
+ );
27308
+ }
27309
+ }
27310
+ const symbol = typeof configs["symbol"] === "string" ? configs["symbol"] : "\u20B9";
27311
+ const currency = CURRENCY_OF_SYMBOL[symbol];
27312
+ const restBindings = without(bindings, ["value", "target"]);
27313
+ const ladderRest = without(ladder, ["bindings"]);
27314
+ out[id] = {
27315
+ ...ladderRest,
27316
+ type: "scale",
27317
+ childrens: [...leading, ...childIds, ...trailing],
27318
+ configs: defined({
27319
+ ...without(configs, LADDER_ONLY),
27320
+ format: currency ? "currency" : "number",
27321
+ currency: currency && currency !== "INR" ? currency : void 0,
27322
+ unit: currency ? void 0 : symbol,
27323
+ // `auto` is the Scale's default, so it is not written.
27324
+ orientation: orientationOf(configs["variant"]),
27325
+ maxSpanPct: numberOr(configs["maxSpanPct"]) ?? 60
27326
+ }),
27327
+ ...Object.keys(restBindings).length ? { bindings: restBindings } : {}
27328
+ };
27329
+ };
27330
+
26856
27331
  // libs/codegen/src/model/control-group.ts
26857
27332
  var CONTROL_GROUP_NAME_MAX = 40;
26858
27333
  var NAME_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
27334
+ var isValidControlGroupCategory = (category) => typeof category === "string" && NAME_PATTERN.test(category) && category.length <= CONTROL_GROUP_NAME_MAX;
26859
27335
  var isValidControlGroupName = (name3) => NAME_PATTERN.test(name3) && name3.length <= CONTROL_GROUP_NAME_MAX;
26860
27336
 
26861
27337
  // libs/codegen/src/lib/layer-helper.ts
@@ -28050,8 +28526,8 @@ var withCases = (fn, cases) => {
28050
28526
  return next;
28051
28527
  };
28052
28528
  var caseArityMatches = (fn, entry2) => entry2.args.length === fn.params.length;
28053
- var caseLiteralValue = (text2) => {
28054
- const source = text2.trim();
28529
+ var caseLiteralValue = (text3) => {
28530
+ const source = text3.trim();
28055
28531
  if (!source) return { ok: false };
28056
28532
  let at = 0;
28057
28533
  const skip = () => {
@@ -28328,7 +28804,7 @@ var caseEquals = (actual, expected) => {
28328
28804
  };
28329
28805
 
28330
28806
  // libs/codegen/src/lib/workspace-codec.ts
28331
- var WORKSPACE_SCHEMA_VERSION = 30;
28807
+ var WORKSPACE_SCHEMA_VERSION = 31;
28332
28808
  var MIGRATION_FLOOR = 18;
28333
28809
  var DEPLOY_TOKEN_METHOD_IDS = {
28334
28810
  "@UserStore.ensureDeployToken": "@AuthStore.ensureDeployToken",
@@ -28424,40 +28900,54 @@ var mapBlobControls = (blob, step) => {
28424
28900
  }
28425
28901
  return next;
28426
28902
  };
28903
+ var mapBlobControlMaps = (blob, step) => {
28904
+ const next = { ...blob };
28905
+ if ("controlMap" in next) next["controlMap"] = step(next["controlMap"]);
28906
+ const groups = next["controlGroups"];
28907
+ if (groups && typeof groups === "object") {
28908
+ next["controlGroups"] = Object.fromEntries(
28909
+ Object.entries(groups).map(([name3, group]) => [
28910
+ name3,
28911
+ group && typeof group === "object" ? { ...group, controls: step(group["controls"]) } : group
28912
+ ])
28913
+ );
28914
+ }
28915
+ return next;
28916
+ };
28427
28917
  var SCREEN_OUTPUT_SIBLINGS = [
28428
28918
  ["screenOutputCalls", "outputCalls"],
28429
28919
  ["screenOutputWrites", "outputWrites"],
28430
28920
  ["screenOutputScreenWrites", "outputScreenWrites"],
28431
28921
  ["screenOutputOutcomes", "outputOutcomes"]
28432
28922
  ];
28433
- var recordOf = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
28923
+ var recordOf2 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
28434
28924
  var migrateScreenOutputMaps = (control) => {
28435
28925
  if (!Object.keys(control).some((key2) => key2.startsWith("screenOutput"))) {
28436
28926
  return control;
28437
28927
  }
28438
28928
  const next = { ...control };
28439
28929
  const merge = (field, key2, value) => {
28440
- next[field] = { ...recordOf(next[field]) ?? {}, [key2]: value };
28930
+ next[field] = { ...recordOf2(next[field]) ?? {}, [key2]: value };
28441
28931
  };
28442
28932
  for (const [from, to] of SCREEN_OUTPUT_SIBLINGS) {
28443
- for (const [key2, value] of Object.entries(recordOf(control[from]) ?? {})) {
28933
+ for (const [key2, value] of Object.entries(recordOf2(control[from]) ?? {})) {
28444
28934
  merge(to, key2, value);
28445
28935
  }
28446
28936
  delete next[from];
28447
28937
  }
28448
- const emits = recordOf(control["screenOutputEmits"]) ?? {};
28938
+ const emits = recordOf2(control["screenOutputEmits"]) ?? {};
28449
28939
  for (const [key2, rows] of Object.entries(emits)) {
28450
28940
  merge("outputEmits", key2, rows);
28451
28941
  }
28452
28942
  delete next["screenOutputEmits"];
28453
- const bindings = recordOf(control["screenOutputs"]) ?? {};
28943
+ const bindings = recordOf2(control["screenOutputs"]) ?? {};
28454
28944
  for (const [key2, raw] of Object.entries(bindings)) {
28455
28945
  const binding = raw;
28456
28946
  if (binding?.kind === "method") {
28457
28947
  merge("outputs", key2, binding.methodId);
28458
28948
  if (binding.args?.length) merge("outputArgs", key2, binding.args);
28459
28949
  } else if (binding?.kind === "output") {
28460
- const drawn = recordOf(next["outputEmits"])?.[key2];
28950
+ const drawn = recordOf2(next["outputEmits"])?.[key2];
28461
28951
  merge("outputEmits", key2, [
28462
28952
  ...Array.isArray(drawn) ? drawn : [],
28463
28953
  { id: `reemit-${key2}`, outputId: binding.outputId, value: { kind: "event" } }
@@ -28564,6 +29054,10 @@ var screenOnly = (step) => ({
28564
29054
  step
28565
29055
  });
28566
29056
  var MIGRATIONS = {
29057
+ // 30 → 31: a PriceLadder becomes a Scale — its marks ScaleMarks, its chips
29058
+ // and picked indicators ScaleRelations — in a Screen's ControlMap and in
29059
+ // every ControlGroup (libs/one GLOSSARY.md Scale).
29060
+ 30: everyKind((blob) => mapBlobControlMaps(blob, migratePriceLadders)),
28567
29061
  // 29 → 30: a ScreenControl's ScreenOutputs move onto the standard output
28568
29062
  // maps, in a Screen's ControlMap and in every ControlGroup (ADR 0207).
28569
29063
  29: everyKind((blob) => mapBlobControls(blob, migrateScreenOutputMaps)),
@@ -28912,13 +29406,13 @@ function sanitizeOperand(value) {
28912
29406
  const literal = operand["value"];
28913
29407
  return typeof literal === "string" || typeof literal === "number" || typeof literal === "boolean" ? { kind: "literal", value: literal } : fallback;
28914
29408
  }
28915
- function sanitizeRuleNode(value, depth = 0) {
29409
+ function sanitizeRuleNode(value, taken, depth = 0) {
28916
29410
  if (!value || typeof value !== "object" || depth > 32) return void 0;
28917
29411
  const node = value;
28918
- const id = nodeId();
29412
+ const id = keptNodeId(node["id"], taken);
28919
29413
  const kind = node["kind"];
28920
29414
  if (kind === "group") {
28921
- const children = Array.isArray(node["children"]) ? node["children"].map((child) => sanitizeRuleNode(child, depth + 1)).filter((child) => !!child) : [];
29415
+ const children = Array.isArray(node["children"]) ? node["children"].map((child) => sanitizeRuleNode(child, taken, depth + 1)).filter((child) => !!child) : [];
28922
29416
  return {
28923
29417
  id,
28924
29418
  kind: "group",
@@ -28983,7 +29477,7 @@ function sanitizeRuleNode(value, depth = 0) {
28983
29477
  };
28984
29478
  }
28985
29479
  var sanitizeRule = (value) => {
28986
- const node = sanitizeRuleNode(value);
29480
+ const node = sanitizeRuleNode(value, /* @__PURE__ */ new Set());
28987
29481
  return node && node.kind === "group" ? node : createRule();
28988
29482
  };
28989
29483
  function sanitizeVariants(variants) {
@@ -29089,19 +29583,22 @@ function sanitizeMethods(methods, properties, functions = {}) {
29089
29583
  (persist) => !!persist && typeof persist.id === "string" && !!persist.id && typeof persist.key === "string" && Array.isArray(persist.source) && persist.source.every((segment) => typeof segment === "string")
29090
29584
  ).map((persist) => {
29091
29585
  const timing = persist.timing === "before" ? "before" : "after";
29092
- const sourceKind = persist.sourceKind === "args" || persist.sourceKind === "state" || persist.sourceKind === "fixed" || persist.sourceKind === "response" ? persist.sourceKind : timing === "before" ? "state" : "response";
29586
+ const sourceKind = persist.sourceKind === "args" || persist.sourceKind === "state" || persist.sourceKind === "fixed" || persist.sourceKind === "response" || persist.sourceKind === "clear" || persist.sourceKind === "function" ? persist.sourceKind : timing === "before" ? "state" : "response";
29093
29587
  const shelf = persist.shelf === "store" ? "store" : persist.shelf === "session" ? "session" : "local";
29094
29588
  const target = properties[persist.propertyId ?? ""];
29095
29589
  const value2 = shelf === "store" && sourceKind === "fixed" && target?.dataType.type === "boolean" && target.cardinality === "one" ? persist.value === "true" || persist.value === "false" ? persist.value : "undefined" : persist.value;
29590
+ const { transform: rawTransform, ...rest } = persist;
29591
+ const transform = sourceKind === "function" ? sanitizeOutcomeTransform(rawTransform, functions) : void 0;
29096
29592
  return {
29097
- ...persist,
29593
+ ...rest,
29098
29594
  timing,
29099
29595
  sourceKind,
29100
29596
  shelf,
29101
- ...value2 !== void 0 ? { value: value2 } : {}
29597
+ ...value2 !== void 0 ? { value: value2 } : {},
29598
+ ...transform && transform.args.every((arg) => arg.source !== "response") ? { transform } : {}
29102
29599
  };
29103
29600
  }).filter(
29104
- (persist) => (persist.sourceKind !== "response" || persist.timing === "after") && (persist.sourceKind !== "state" || !!persist.source.length && !!properties[persist.source[0]]) && (persist.sourceKind !== "args" || !!persist.arg) && (persist.sourceKind !== "fixed" || typeof persist.value === "string") && (persist.shelf === "store" ? persist.sourceKind !== "state" && !!properties[persist.propertyId ?? ""] : !!persist.key.trim())
29601
+ (persist) => (persist.sourceKind !== "clear" && persist.sourceKind !== "function" || persist.timing === "before" && persist.shelf === "store") && (persist.sourceKind !== "function" || !!persist.transform) && (persist.sourceKind !== "response" || persist.timing === "after") && (persist.sourceKind !== "state" || !!persist.source.length && !!properties[persist.source[0]]) && (persist.sourceKind !== "args" || !!persist.arg) && (persist.sourceKind !== "fixed" || typeof persist.value === "string") && (persist.shelf === "store" ? persist.sourceKind !== "state" && !!properties[persist.propertyId ?? ""] : !!persist.key.trim())
29105
29602
  );
29106
29603
  const computes = (Array.isArray(method.computes) ? method.computes : []).filter(
29107
29604
  (compute) => !!compute && typeof compute.id === "string" && !!compute.id && typeof compute.name === "string" && !!compute.name.trim() && typeof compute.functionId === "string" && !!functions[compute.functionId] && !!compute.args && typeof compute.args === "object"
@@ -30206,7 +30703,9 @@ function sanitizeControlGroups(groups) {
30206
30703
  // Recomputed rather than read: the count is what the chip says out loud,
30207
30704
  // and a stored one that disagreed with the map would be a lie the User
30208
30705
  // reads on every render.
30209
- count: Object.keys(controls).length - 1
30706
+ count: Object.keys(controls).length - 1,
30707
+ // Kept only when it could name a heading; anything else is uncategorised.
30708
+ ...isValidControlGroupCategory(candidate["category"]) ? { category: candidate["category"] } : {}
30210
30709
  };
30211
30710
  }
30212
30711
  return result;
@@ -30403,10 +30902,10 @@ var sanitizeEnumMembers = (raw, hasValue, valueType) => {
30403
30902
  let value;
30404
30903
  if (hasValue && valueType === "string") {
30405
30904
  const given = typeof stored.value === "string" && stored.value.trim() ? stored.value : stored.key;
30406
- let text2 = takenTexts.has(given) ? stored.key : given;
30407
- for (let n = 2; takenTexts.has(text2); n++) text2 = `${stored.key}_${n}`;
30408
- takenTexts.add(text2);
30409
- value = text2;
30905
+ let text3 = takenTexts.has(given) ? stored.key : given;
30906
+ for (let n = 2; takenTexts.has(text3); n++) text3 = `${stored.key}_${n}`;
30907
+ takenTexts.add(text3);
30908
+ value = text3;
30410
30909
  } else if (hasValue) {
30411
30910
  const given = typeof stored.value === "number" && Number.isFinite(stored.value) ? Math.trunc(stored.value) : void 0;
30412
30911
  value = given !== void 0 && !takenValues.has(given) ? given : 0;
@@ -30766,14 +31265,19 @@ function buildDesignSource(ws, operations = drawnOperations(ws)) {
30766
31265
  });
30767
31266
  Object.entries(
30768
31267
  docsToFiles(ws.docs ?? {}, (name3, lang) => docSourcePath(name3, lang))
30769
- ).forEach(([path, text2]) => {
30770
- files3[`${DESIGN_ASSETS_DIR}/${path}`] = text2;
31268
+ ).forEach(([path, text3]) => {
31269
+ files3[`${DESIGN_ASSETS_DIR}/${path}`] = text3;
30771
31270
  });
30772
31271
  ws.screens.forEach(({ meta, state }) => {
30773
31272
  files3[`${DESIGN_SCREENS_DIR}/${meta.id}.json`] = json({
30774
31273
  v: WORKSPACE_SCHEMA_VERSION,
30775
31274
  meta,
30776
- state: { ...state, controlMap: compactControlMap(state.controlMap) }
31275
+ state: {
31276
+ ...state,
31277
+ selectedControl: void 0,
31278
+ selectedLayerId: 0,
31279
+ controlMap: compactControlMap(state.controlMap)
31280
+ }
30777
31281
  });
30778
31282
  });
30779
31283
  files3[DESIGN_WRITE_ID_PATH] = `${designWriteId(files3)}
@@ -30781,10 +31285,10 @@ function buildDesignSource(ws, operations = drawnOperations(ws)) {
30781
31285
  return files3;
30782
31286
  }
30783
31287
  var isDesignSourcePath = (path) => path === DESIGN_INDEX_PATH || path === DESIGN_WRITE_ID_PATH || path === DESIGN_EMITTED_PATH || path === DESIGN_NAV_PATH || path === DESIGN_HAND_PATH || path === DESIGN_OPERATIONS_PATH || path.startsWith(`${DESIGN_SCREENS_DIR}/`) || path.startsWith(`${DESIGN_ASSETS_DIR}/`);
30784
- var parsed = (text2) => {
30785
- if (text2 === void 0) return void 0;
31288
+ var parsed = (text3) => {
31289
+ if (text3 === void 0) return void 0;
30786
31290
  try {
30787
- return JSON.parse(text2);
31291
+ return JSON.parse(text3);
30788
31292
  } catch {
30789
31293
  return void 0;
30790
31294
  }
@@ -30836,9 +31340,9 @@ function readDesignSource(files3) {
30836
31340
  const stored = step.blob;
30837
31341
  const docs = docsFromFiles(
30838
31342
  Object.fromEntries(
30839
- Object.entries(files3).filter(([path]) => path.startsWith(`${DESIGN_ASSETS_DIR}/`)).map(([path, text2]) => [
31343
+ Object.entries(files3).filter(([path]) => path.startsWith(`${DESIGN_ASSETS_DIR}/`)).map(([path, text3]) => [
30840
31344
  path.slice(`${DESIGN_ASSETS_DIR}/`.length),
30841
- text2
31345
+ text3
30842
31346
  ])
30843
31347
  ),
30844
31348
  DOCS_FOLDER
@@ -30905,8 +31409,8 @@ function rewrites(files3, source) {
30905
31409
  );
30906
31410
  return [...paths].some((path) => files3[path] !== encoded[path]);
30907
31411
  }
30908
- function writeIdOf(text2) {
30909
- const id = text2?.trim();
31412
+ function writeIdOf(text3) {
31413
+ const id = text3?.trim();
30910
31414
  return id ? id : void 0;
30911
31415
  }
30912
31416
  var designSourceEmitted = (ws) => Object.entries(buildDesignSource(ws)).map(([path, contents]) => ({
@@ -30914,6 +31418,107 @@ var designSourceEmitted = (ws) => Object.entries(buildDesignSource(ws)).map(([pa
30914
31418
  contents
30915
31419
  }));
30916
31420
 
31421
+ // libs/codegen/src/lib/tree-helper.ts
31422
+ function buildTree(controlMap, rootControlIds, selection) {
31423
+ const state = (id) => selection ? variantRenderState(id, controlMap, selection) : "solid";
31424
+ const resolveDirectives = (ctrl) => {
31425
+ if (!ctrl.directives) return void 0;
31426
+ const resolved = {};
31427
+ for (const [name3, directive] of Object.entries(ctrl.directives)) {
31428
+ if (directive.overlayId) {
31429
+ const overlay = controlMap[directive.overlayId];
31430
+ if (overlay) {
31431
+ resolved[name3] = {
31432
+ overlayId: directive.overlayId,
31433
+ type: overlay.type,
31434
+ configs: overlay.configs
31435
+ };
31436
+ }
31437
+ } else {
31438
+ resolved[name3] = { configs: directive.configs ?? {} };
31439
+ }
31440
+ }
31441
+ return Object.keys(resolved).length > 0 ? resolved : void 0;
31442
+ };
31443
+ const toNode = (ctrl) => {
31444
+ const childrens = getChildren(ctrl.id);
31445
+ const fullyFaded = state(ctrl.id) === "faded" && childrens.every((child) => child.faded);
31446
+ return {
31447
+ type: ctrl.type,
31448
+ id: ctrl.id,
31449
+ configs: ctrl.configs,
31450
+ childrens,
31451
+ directives: resolveDirectives(ctrl),
31452
+ ...ctrl.source ? { source: ctrl.source } : {},
31453
+ ...ctrl.variants?.length ? { variants: ctrl.variants } : {},
31454
+ // Carried through so renderBranch can order the `@else` last and spell it
31455
+ // without reaching back into ControlMap mid-walk (GLOSSARY.md DefaultArm).
31456
+ ...ctrl.armKind ? { armKind: ctrl.armKind } : {},
31457
+ ...ctrl.variantKind ? { variantKind: ctrl.variantKind } : {},
31458
+ ...ctrl.outputs && Object.keys(ctrl.outputs).length ? { outputs: ctrl.outputs } : {},
31459
+ ...ctrl.outputArgs && Object.keys(ctrl.outputArgs).length ? { outputArgs: ctrl.outputArgs } : {},
31460
+ ...ctrl.outputWrites && Object.keys(ctrl.outputWrites).length ? { outputWrites: ctrl.outputWrites } : {},
31461
+ ...ctrl.outputEmits && Object.keys(ctrl.outputEmits).length ? { outputEmits: ctrl.outputEmits } : {},
31462
+ ...ctrl.outputScreenWrites && Object.keys(ctrl.outputScreenWrites).length ? { outputScreenWrites: ctrl.outputScreenWrites } : {},
31463
+ ...ctrl.outputOpens && Object.keys(ctrl.outputOpens).length ? { outputOpens: ctrl.outputOpens } : {},
31464
+ ...ctrl.outputNavs && Object.keys(ctrl.outputNavs).length ? { outputNavs: ctrl.outputNavs } : {},
31465
+ ...ctrl.outputNewTabs && Object.keys(ctrl.outputNewTabs).length ? { outputNewTabs: ctrl.outputNewTabs } : {},
31466
+ ...ctrl.outputOutcomes && Object.keys(ctrl.outputOutcomes).length ? { outputOutcomes: ctrl.outputOutcomes } : {},
31467
+ // Without this the codegen walk reads `outputArms` off a Tree that never
31468
+ // carried it, every gated output falls back to ungated, and its groups —
31469
+ // filed under `<output>|arm:<armId>` — are skipped as qualified keys. The
31470
+ // output emits nothing at all (GLOSSARY.md OutputArm).
31471
+ ...ctrl.outputArms && Object.keys(ctrl.outputArms).length ? { outputArms: ctrl.outputArms } : {},
31472
+ // Without this every group fires its first call alone: the rest are
31473
+ // filed under `<group>|call:<callId>` and read in the order this holds
31474
+ // (GLOSSARY.md OutputCall).
31475
+ ...ctrl.outputCalls && Object.keys(ctrl.outputCalls).length ? { outputCalls: ctrl.outputCalls } : {},
31476
+ ...ctrl.outputScreenMethods && Object.keys(ctrl.outputScreenMethods).length ? { outputScreenMethods: ctrl.outputScreenMethods } : {},
31477
+ ...ctrl.menuActions?.length ? { menuActions: ctrl.menuActions } : {},
31478
+ ...ctrl.screenId ? { screenId: ctrl.screenId } : {},
31479
+ // The other answer to what a ScreenControl mounts (ADR 0088). Carried
31480
+ // for `screenId`'s reason: the Canvas labels its placeholder from it and
31481
+ // codegen emits its tag.
31482
+ ...ctrl.handRef ? { handRef: ctrl.handRef } : {},
31483
+ ...ctrl.screenInputs && Object.keys(ctrl.screenInputs).length ? { screenInputs: ctrl.screenInputs } : {},
31484
+ // Carried for `screenId`'s reason: the Canvas draws the embed's box at
31485
+ // it and codegen emits it on the tag.
31486
+ ...ctrl.maxWidth ? { maxWidth: ctrl.maxWidth } : {},
31487
+ ...ctrl.checks?.length ? { checks: ctrl.checks } : {},
31488
+ ...ctrl.formatPipes?.length ? { formatPipes: ctrl.formatPipes } : {},
31489
+ ...ctrl.cards ? { cards: ctrl.cards } : {},
31490
+ ...ctrl.search ? { search: ctrl.search } : {},
31491
+ // A Repeat's row count, carried for `cards`' reason: the Canvas draws
31492
+ // its sample rows from the Tree alone. Nothing else reads it — codegen
31493
+ // never emits a count (GLOSSARY.md SampleValue).
31494
+ ...ctrl.repeat?.sampleRows !== void 0 ? { sampleRows: ctrl.repeat.sampleRows } : {},
31495
+ ...fullyFaded ? { faded: true } : {}
31496
+ };
31497
+ };
31498
+ const getChildren = (parentId) => {
31499
+ const parent = controlMap[parentId];
31500
+ if (!parent || !parent.childrens) return [];
31501
+ return parent.childrens.map((childId) => controlMap[childId]).filter(Boolean).filter((ctrl) => state(ctrl.id) !== "hidden").map(toNode);
31502
+ };
31503
+ const tree = rootControlIds.map((id) => controlMap[id]).filter(Boolean).filter((ctrl) => state(ctrl.id) !== "hidden").map(toNode);
31504
+ return selection ? markFadedRoots(tree) : tree;
31505
+ }
31506
+ function markFadedRoots(nodes, underFaded = false) {
31507
+ return nodes.map((node) => {
31508
+ const faded = !underFaded && node.faded;
31509
+ const next = {
31510
+ ...node,
31511
+ childrens: markFadedRoots(node.childrens, underFaded || !!node.faded)
31512
+ };
31513
+ if (faded) {
31514
+ next.faded = true;
31515
+ } else {
31516
+ delete next.faded;
31517
+ }
31518
+ return next;
31519
+ });
31520
+ }
31521
+
30917
31522
  // libs/codegen/src/lib/overlay-widgets-helper.ts
30918
31523
  var overlayWidgetScreenIds = (maps) => {
30919
31524
  const ids = /* @__PURE__ */ new Set();
@@ -31607,7 +32212,7 @@ var GENERATED_SET = [
31607
32212
  var inGeneratedSet = (path) => isGeneratedPath(path) || !isCustomPath(path) && path.startsWith("src/app/shared/type/");
31608
32213
 
31609
32214
  // libs/codegen/src/lib/scaffold-helper.ts
31610
- var endWithNewline = (text2) => text2.endsWith("\n") ? text2 : `${text2}
32215
+ var endWithNewline = (text3) => text3.endsWith("\n") ? text3 : `${text3}
31611
32216
  `;
31612
32217
  var NG_VERSION = "22.2.1";
31613
32218
  var TS_VERSION = "6.0.3";
@@ -34297,36 +34902,17 @@ var emitEnumFiles = (ws) => {
34297
34902
  const enums = ws.enums ?? {};
34298
34903
  return Object.values(enums).map((appEnum) => emitEnumFile(appEnum));
34299
34904
  };
34300
- var inReach = (ws) => withPropertyEnums(
34301
- ws.sharedShapes ? { ...ws, features: featuresInReach(ws.features, ws.sharedShapes) } : ws
34302
- );
34303
- var withPropertyEnums = (ws) => {
34304
- const features = Object.fromEntries(
34305
- Object.entries(ws.features).map(([id, feature]) => {
34306
- const controlMaps = ws.screens.filter(
34307
- (screen) => screen.meta.kind === "feature" && screen.meta.featureId === id
34308
- ).map((screen) => screen.state.controlMap);
34309
- const subStores = feature.subStores ? Object.fromEntries(
34310
- Object.entries(feature.subStores).map(([subId, sub]) => [
34311
- subId,
34312
- {
34313
- ...sub,
34314
- properties: stampStatePropertyEnums(sub.properties, controlMaps)
34315
- }
34316
- ])
34317
- ) : void 0;
34318
- return [
34319
- id,
34320
- {
34321
- ...feature,
34322
- properties: stampStatePropertyEnums(feature.properties, controlMaps),
34323
- ...subStores ? { subStores } : {}
34324
- }
34325
- ];
34326
- })
34327
- );
34328
- return { ...ws, features };
34329
- };
34905
+ var inReach = (ws) => ({
34906
+ ...ws,
34907
+ features: featuresAsRead(
34908
+ ws.features,
34909
+ ws.sharedShapes ?? {},
34910
+ ws.screens.map(({ meta, state }) => ({
34911
+ ...meta.kind === "feature" ? { featureId: meta.featureId } : {},
34912
+ controlMap: state.controlMap
34913
+ }))
34914
+ )
34915
+ });
34330
34916
  var emitFormShapeFiles = (ws) => {
34331
34917
  const functions = { ...ws.functions };
34332
34918
  Object.values(ws.features).forEach((feature) => {
@@ -34781,7 +35367,7 @@ var VALUE_SOURCES = [
34781
35367
  VALUE_SOURCE.static,
34782
35368
  VALUE_SOURCE.dynamic
34783
35369
  ];
34784
- var hasValueSource = (type) => type === "price_ladder_mark" /* PRICE_LADDER_MARK */;
35370
+ var hasValueSource = (type) => type === "scale_mark" /* SCALE_MARK */;
34785
35371
  var isValueSource = (value) => VALUE_SOURCES.includes(value);
34786
35372
  var valueSourceOf = (control) => {
34787
35373
  if (control?.valueSource) return control.valueSource;
@@ -35091,6 +35677,7 @@ var HISTORY_SELECTION_KEYS = [
35091
35677
  OUTPUT_ARM_SEPARATOR,
35092
35678
  OUTPUT_ARM_SOURCES,
35093
35679
  OUTPUT_CALL_SEPARATOR,
35680
+ OUTPUT_GROUP_MAPS,
35094
35681
  OUTPUT_PAYLOADS,
35095
35682
  PAGES_ROOT,
35096
35683
  PAGE_FILING,
@@ -35332,6 +35919,7 @@ var HISTORY_SELECTION_KEYS = [
35332
35919
  caseLiteral,
35333
35920
  caseLiteralValue,
35334
35921
  casesFromJson,
35922
+ castTransform,
35335
35923
  chainCall,
35336
35924
  chainInputType,
35337
35925
  chainReturnType,
@@ -35346,6 +35934,7 @@ var HISTORY_SELECTION_KEYS = [
35346
35934
  childNavId,
35347
35935
  classCardScope,
35348
35936
  clearOutputCallRows,
35937
+ clearOutputGroupRows,
35349
35938
  coerceImgSrcOrigin,
35350
35939
  collectCardEmits,
35351
35940
  collectComputedOptionSets,
@@ -35499,6 +36088,7 @@ var HISTORY_SELECTION_KEYS = [
35499
36088
  emitOverlayFiles,
35500
36089
  emitShippedShellFiles,
35501
36090
  emitTransformExpr,
36091
+ emittedDataType,
35502
36092
  emittedFormIds,
35503
36093
  emittedOperation,
35504
36094
  emittedResponse,
@@ -35541,6 +36131,7 @@ var HISTORY_SELECTION_KEYS = [
35541
36131
  featureStoreFile,
35542
36132
  featureStoreProp,
35543
36133
  featureStorePropName,
36134
+ featuresAsRead,
35544
36135
  featuresInReach,
35545
36136
  fieldCanBeAbsent,
35546
36137
  fieldCheckArgParams,
@@ -35577,6 +36168,7 @@ var HISTORY_SELECTION_KEYS = [
35577
36168
  fixedItems,
35578
36169
  fnv64,
35579
36170
  foldedButtonName,
36171
+ foldedButtonNames,
35580
36172
  foldedButtons,
35581
36173
  foldedRouterLink,
35582
36174
  formEventMembers,
@@ -35835,6 +36427,7 @@ var HISTORY_SELECTION_KEYS = [
35835
36427
  isUnaryOutputArmOperator,
35836
36428
  isUsableTranslation,
35837
36429
  isValidAssetPath,
36430
+ isValidControlGroupCategory,
35838
36431
  isValidControlGroupName,
35839
36432
  isValidFormName,
35840
36433
  isValidFunctionName,
@@ -35858,10 +36451,12 @@ var HISTORY_SELECTION_KEYS = [
35858
36451
  isVariantJoin,
35859
36452
  isVariantKind,
35860
36453
  jsNativesInGroup,
36454
+ keptNodeId,
35861
36455
  keyCandidates,
35862
36456
  keyIdKeeper,
35863
36457
  labelChainOf,
35864
36458
  labelEmission,
36459
+ labelHeadType,
35865
36460
  labelReadIsTranslated,
35866
36461
  landingNavId,
35867
36462
  landsOn,
@@ -36152,6 +36747,7 @@ var HISTORY_SELECTION_KEYS = [
36152
36747
  pathChipDisplay,
36153
36748
  pathCrossesCollection,
36154
36749
  pathDisplay,
36750
+ pathLeafEnumId,
36155
36751
  pathLeafType,
36156
36752
  pathsFor,
36157
36753
  payloadEventRoot,
@@ -36294,6 +36890,7 @@ var HISTORY_SELECTION_KEYS = [
36294
36890
  ruleReferencedIds,
36295
36891
  ruleRootProperties,
36296
36892
  sameCallTarget,
36893
+ sameFeaturesAsRead,
36297
36894
  sameOrigin,
36298
36895
  sameOwner,
36299
36896
  sampleRows,
@@ -36439,6 +37036,7 @@ var HISTORY_SELECTION_KEYS = [
36439
37036
  slugifyMessage,
36440
37037
  sortRowEnumId,
36441
37038
  sourceCarriesTrackKey,
37039
+ stableId,
36442
37040
  staleCases,
36443
37041
  staleMenuActionItems,
36444
37042
  stampStatePropertyEnums,
@@ -36605,14 +37203,20 @@ var HISTORY_SELECTION_KEYS = [
36605
37203
  withCases,
36606
37204
  withDefaultRow,
36607
37205
  withEmittedTests,
37206
+ withEventTransform,
36608
37207
  withFormShapes,
36609
37208
  withListRowShape,
37209
+ withPropertyEnums,
36610
37210
  withScreenEnums,
36611
37211
  withScreenMethodCallSites,
36612
37212
  withVariableEnums,
36613
37213
  wouldComputedCycle,
36614
37214
  wouldCycle,
36615
37215
  wouldScreenComputedCycle,
37216
+ writeEventIssue,
37217
+ writeEventMismatch,
37218
+ writeEventReadType,
37219
+ writeEventTransforms,
36616
37220
  writeFileAt,
36617
37221
  writeIdIn,
36618
37222
  writeIdOf,