@magmonium/cli 0.8.30 → 0.10.3

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.
@@ -21,11 +21,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var invariant_catalog_exports = {};
22
22
  __export(invariant_catalog_exports, {
23
23
  INVARIANTS: () => INVARIANTS,
24
+ codecDrops: () => codecDrops,
25
+ collectEmitGaps: () => collectEmitGaps,
24
26
  invariantScopeOf: () => invariantScopeOf,
25
27
  runInvariants: () => runInvariants
26
28
  });
27
29
  module.exports = __toCommonJS(invariant_catalog_exports);
28
- var import_codegen46 = require("./index.js");
30
+ var import_codegen53 = require("./index.js");
29
31
 
30
32
  // apps/m-one-ui/src/app/pages/design/model/invariant.ts
31
33
  var targetKey = (target2) => {
@@ -615,9 +617,306 @@ var bindingResolves = defineInvariant({
615
617
  })
616
618
  });
617
619
 
618
- // apps/m-one-ui/src/app/pages/design/lib/screen-embed-helper.ts
620
+ // apps/m-one-ui/src/app/pages/design/lib/invariants/binding-resolves-outputs.ts
619
621
  var import_codegen14 = require("./index.js");
620
- var isScreenControl = (control) => control.type === import_codegen14.ControlType.SCREEN && typeof control.screenId === "string";
622
+ var writesGone = (value, state) => {
623
+ if (Array.isArray(value)) return value.some((item) => writesGone(item, state));
624
+ if (!value || typeof value !== "object") return false;
625
+ const record = value;
626
+ if (typeof record.propertyId === "string" && "value" in record && !state.has(record.propertyId))
627
+ return true;
628
+ return Object.values(value).some((item) => writesGone(item, state));
629
+ };
630
+ var bindingResolvesOutputs = defineInvariant({
631
+ name: "binding-resolves-outputs",
632
+ message: "invariant-state-write-unresolved",
633
+ severity: "blocking",
634
+ deps: ["features", "screens", "screenControlMaps"],
635
+ validate: ({ features, screens, screenControlMaps }) => {
636
+ const state = new Set(
637
+ Object.values(features).flatMap(
638
+ (feature) => (0, import_codegen14.storesOf)(feature).flatMap((store) => Object.keys(store.properties ?? {}))
639
+ )
640
+ );
641
+ const found = [];
642
+ for (const screen of screens) {
643
+ const map = screenControlMaps[screen.id] ?? {};
644
+ for (const control of Object.values(map)) {
645
+ if (writesGone([control.outputWrites, control.outputOutcomes], state))
646
+ found.push({
647
+ subject: `${screen.name} \u2192 ${String(control.configs?.["name"] ?? control.id)}`,
648
+ target: { kind: "control", screenId: screen.id, controlId: control.id }
649
+ });
650
+ }
651
+ if (writesGone([screen.methods, screen.autoCalls], state))
652
+ found.push({
653
+ subject: `${screen.name} \u2192 ScreenMethod / AutoCall`,
654
+ target: { kind: "screen", screenId: screen.id, panel: "screen" }
655
+ });
656
+ }
657
+ return found;
658
+ }
659
+ });
660
+
661
+ // apps/m-one-ui/src/app/pages/design/lib/invariants/control-rules.ts
662
+ var import_codegen15 = require("./index.js");
663
+ var nameOf = (map, id) => String(map[id]?.configs?.["name"] ?? id);
664
+ var routerOutletPlaced = defineInvariant({
665
+ name: "router-outlet-placed",
666
+ message: "invariant-router-outlet-misplaced",
667
+ severity: "blocking",
668
+ deps: ["screens", "screenControlMaps"],
669
+ validate: ({ screens, screenControlMaps }) => screens.flatMap((screen) => {
670
+ const outlets = Object.values(screenControlMaps[screen.id] ?? {}).filter(
671
+ (control) => control.type === import_codegen15.ControlType.ROUTER_OUTLET
672
+ );
673
+ const misplaced = (0, import_codegen15.isRoutableKind)(screen.kind) ? outlets.slice(1) : outlets;
674
+ return misplaced.map((control) => ({
675
+ subject: `${screen.name} \u2192 ${nameOf(screenControlMaps[screen.id], control.id)}`,
676
+ target: { kind: "control", screenId: screen.id, controlId: control.id }
677
+ }));
678
+ })
679
+ });
680
+ var controlIdUnique = defineInvariant({
681
+ name: "control-id-unique",
682
+ message: "invariant-control-id-duplicate",
683
+ severity: "blocking",
684
+ deps: ["screens", "screenControlMaps"],
685
+ validate: ({ screens, screenControlMaps }) => {
686
+ const seen = /* @__PURE__ */ new Map();
687
+ const found = [];
688
+ for (const screen of screens) {
689
+ for (const id of Object.keys(screenControlMaps[screen.id] ?? {})) {
690
+ const first = seen.get(id);
691
+ if (first === void 0) {
692
+ seen.set(id, screen.name);
693
+ continue;
694
+ }
695
+ found.push({
696
+ subject: `${screen.name} \u2192 ${nameOf(screenControlMaps[screen.id], id)}, also on ${first}`,
697
+ target: { kind: "control", screenId: screen.id, controlId: id }
698
+ });
699
+ }
700
+ }
701
+ return found;
702
+ }
703
+ });
704
+ var fieldKeyTypeAgrees = defineInvariant({
705
+ name: "field-key-type-agrees",
706
+ message: "invariant-field-key-type-split",
707
+ severity: "blocking",
708
+ deps: ["screens", "screenControlMaps"],
709
+ validate: ({ screens, screenControlMaps }) => screens.flatMap((screen) => {
710
+ const map = screenControlMaps[screen.id] ?? {};
711
+ return Object.values(map).filter((control) => control.type === import_codegen15.ControlType.FIELD).filter((field) => (0, import_codegen15.fieldKeyClashes)(map, field.id, field.configs).length > 0).map((field) => ({
712
+ subject: `${screen.name} \u2192 ${nameOf(map, field.id)}`,
713
+ target: { kind: "control", screenId: screen.id, controlId: field.id }
714
+ }));
715
+ })
716
+ });
717
+ var submitTargetResolves = defineInvariant({
718
+ name: "submit-target-resolves",
719
+ message: "invariant-submit-target-unresolved",
720
+ severity: "blocking",
721
+ deps: ["screens", "screenControlMaps"],
722
+ validate: ({ screens, screenControlMaps }) => screens.flatMap((screen) => {
723
+ const map = screenControlMaps[screen.id] ?? {};
724
+ return Object.values(map).filter((control) => {
725
+ const target2 = control.configs?.[import_codegen15.SUBMIT_TARGET_KEY];
726
+ return typeof target2 === "string" && !map[target2];
727
+ }).map((control) => ({
728
+ subject: `${screen.name} \u2192 ${nameOf(map, control.id)}`,
729
+ target: { kind: "control", screenId: screen.id, controlId: control.id }
730
+ }));
731
+ })
732
+ });
733
+ var formResetResolves = defineInvariant({
734
+ name: "form-reset-resolves",
735
+ message: "invariant-form-reset-unresolved",
736
+ severity: "blocking",
737
+ deps: ["screens", "screenControlMaps"],
738
+ validate: ({ screens, screenControlMaps }) => screens.flatMap((screen) => {
739
+ const map = screenControlMaps[screen.id] ?? {};
740
+ const onControls = Object.values(map).filter(
741
+ (control) => Object.values(control.outputOutcomes ?? {}).some(
742
+ (outcome) => !!(0, import_codegen15.repairCallOutcome)(map, outcome)
743
+ )
744
+ ).map((control) => ({
745
+ subject: `${screen.name} \u2192 ${nameOf(map, control.id)}`,
746
+ target: { kind: "control", screenId: screen.id, controlId: control.id }
747
+ }));
748
+ const onSites = (0, import_codegen15.repairClassCallSites)(map, {
749
+ methods: screen.methods,
750
+ autoCalls: screen.autoCalls
751
+ }) ? [
752
+ {
753
+ subject: `${screen.name} \u2192 ScreenMethod / AutoCall`,
754
+ target: { kind: "screen", screenId: screen.id, panel: "screen" }
755
+ }
756
+ ] : [];
757
+ return [...onControls, ...onSites];
758
+ })
759
+ });
760
+ var ruleFieldResolves = defineInvariant({
761
+ name: "rule-field-resolves",
762
+ message: "invariant-rule-field-unresolved",
763
+ severity: "blocking",
764
+ deps: ["screens", "screenControlMaps"],
765
+ validate: ({ screens, screenControlMaps }) => screens.flatMap((screen) => {
766
+ const map = screenControlMaps[screen.id] ?? {};
767
+ const models = /* @__PURE__ */ new Set([
768
+ ...Object.keys(screen.formModels ?? {}),
769
+ ...Object.values(screen.formModels ?? {}).map((model) => model.id)
770
+ ]);
771
+ if (!models.size) return [];
772
+ const readsGone = (node) => {
773
+ if (Array.isArray(node)) return node.some(readsGone);
774
+ if (!node || typeof node !== "object") return false;
775
+ const path = node.path;
776
+ if (node.kind === "check" && Array.isArray(path) && typeof path[0] === "string" && models.has(path[0]) && typeof path[1] === "string" && !map[path[1]]) {
777
+ return true;
778
+ }
779
+ return Object.values(node).some(readsGone);
780
+ };
781
+ return Object.values(screen.variants ?? {}).filter((variant) => readsGone(variant.rule)).map((variant) => ({
782
+ subject: `${screen.name} \u2192 variant ${variant.name}`,
783
+ target: { kind: "screen", screenId: screen.id, panel: "screen", memberId: variant.id }
784
+ }));
785
+ })
786
+ });
787
+ var embedShapeWithinFeature = defineInvariant({
788
+ name: "embed-shape-within-feature",
789
+ message: "invariant-embed-shape-crosses-feature",
790
+ severity: "blocking",
791
+ deps: ["screens", "screenControlMaps"],
792
+ validate: ({ screens, screenControlMaps }) => {
793
+ const byId = new Map(screens.map((screen) => [screen.id, screen]));
794
+ return screens.flatMap(
795
+ (host) => Object.values(screenControlMaps[host.id] ?? {}).flatMap((control) => {
796
+ const target2 = control.screenId ? byId.get(control.screenId) : void 0;
797
+ if (!target2 || !(0, import_codegen15.embedShapeBlocked)(host, target2)) return [];
798
+ return [
799
+ {
800
+ subject: `${host.name} \u2192 ${target2.name}`,
801
+ target: { kind: "control", screenId: host.id, controlId: control.id }
802
+ }
803
+ ];
804
+ })
805
+ );
806
+ }
807
+ });
808
+
809
+ // apps/m-one-ui/src/app/pages/design/lib/invariants/function-rules.ts
810
+ var import_codegen16 = require("./index.js");
811
+ var functionNameUnshadowed = defineInvariant({
812
+ name: "function-name-unshadowed",
813
+ message: "invariant-function-name-shadowed",
814
+ severity: "blocking",
815
+ deps: ["features", "functions"],
816
+ validate: ({ features, functions }) => {
817
+ const appNames = new Set(Object.values(functions).map((fn) => fn.name));
818
+ return Object.values(features).flatMap(
819
+ (feature) => Object.values(feature.functions ?? {}).filter((fn) => appNames.has(fn.name)).map((fn) => ({
820
+ subject: `${feature.name} \xB7 ${fn.name}`,
821
+ target: { kind: "function", featureId: feature.id, functionId: fn.id }
822
+ }))
823
+ );
824
+ }
825
+ });
826
+ var functionTierFiled = defineInvariant({
827
+ name: "function-tier-filed",
828
+ message: "invariant-function-tier-misfiled",
829
+ severity: "blocking",
830
+ deps: ["features", "functions", "sharedShapes"],
831
+ validate: ({ features, functions, sharedShapes }) => {
832
+ const found = Object.values(functions).filter((fn) => (0, import_codegen16.tierOf)(fn) === "feature" && !fn.tier).filter((fn) => (0, import_codegen16.featureShapeIds)(fn).some((id) => !sharedShapes[id])).map((fn) => ({
833
+ subject: `shared \xB7 ${fn.name}`,
834
+ target: { kind: "function", functionId: fn.id }
835
+ }));
836
+ for (const feature of Object.values(features)) {
837
+ const foreign = (fn) => (0, import_codegen16.featureShapeIds)(fn).some((id) => !feature.shapes[id] && !sharedShapes[id]);
838
+ for (const fn of Object.values(feature.functions ?? {}).filter(foreign))
839
+ found.push({
840
+ subject: `${feature.name} \xB7 ${fn.name}`,
841
+ target: { kind: "function", featureId: feature.id, functionId: fn.id }
842
+ });
843
+ }
844
+ return found;
845
+ }
846
+ });
847
+ var namesBoth = (value) => {
848
+ if (Array.isArray(value)) return value.some(namesBoth);
849
+ if (!value || typeof value !== "object") return false;
850
+ const record = value;
851
+ if (typeof record.functionId === "string" && record.functionId !== "" && typeof record.oneFunction === "string" && record.oneFunction !== "") {
852
+ return true;
853
+ }
854
+ return Object.values(value).some(namesBoth);
855
+ };
856
+ var functionRefExclusive = defineInvariant({
857
+ name: "function-ref-exclusive",
858
+ message: "invariant-function-ref-both",
859
+ severity: "blocking",
860
+ deps: ["features", "screens"],
861
+ validate: ({ features, screens }) => [
862
+ ...Object.values(features).filter((feature) => namesBoth(feature.computeds) || namesBoth(feature.methods) || namesBoth(feature.subStores)).map((feature) => ({
863
+ subject: feature.name,
864
+ target: { kind: "panel", panel: "store", featureId: feature.id }
865
+ })),
866
+ ...screens.filter((screen) => namesBoth(screen.computeds) || namesBoth(screen.methods)).map((screen) => ({
867
+ subject: screen.name,
868
+ target: { kind: "screen", screenId: screen.id, panel: "screen" }
869
+ }))
870
+ ]
871
+ });
872
+
873
+ // apps/m-one-ui/src/app/pages/design/lib/invariants/store-rules.ts
874
+ var import_codegen17 = require("./index.js");
875
+ var storeNameReserved = defineInvariant({
876
+ name: "store-name-reserved",
877
+ message: "invariant-store-name-reserved",
878
+ severity: "blocking",
879
+ deps: ["features"],
880
+ validate: ({ features }) => Object.values(features).flatMap((feature) => {
881
+ const at = { kind: "panel", panel: "store", featureId: feature.id };
882
+ return (0, import_codegen17.storesOf)(feature).flatMap((store) => {
883
+ const subStoreId = store.subStore?.id;
884
+ const owner = subStoreId ? { ...at, subStoreId } : at;
885
+ const found = Object.values(store.methods ?? {}).filter((method) => import_codegen17.RESERVED_METHOD_NAMES.includes(method.name)).map((method) => ({
886
+ subject: `${feature.name} \u2192 method ${method.name}`,
887
+ target: { ...owner, memberId: method.id }
888
+ }));
889
+ if (store.subStore && store.subStore.name === import_codegen17.MAIN_STORE_VALUE)
890
+ found.push({ subject: `${feature.name} \u2192 store ${store.subStore.name}`, target: owner });
891
+ return found;
892
+ });
893
+ })
894
+ });
895
+ var storeMemberNameUnique = defineInvariant({
896
+ name: "store-member-name-unique",
897
+ message: "invariant-store-member-name-taken",
898
+ severity: "blocking",
899
+ deps: ["features"],
900
+ validate: ({ features }) => Object.values(features).flatMap((feature) => {
901
+ const at = { kind: "panel", panel: "store", featureId: feature.id };
902
+ return (0, import_codegen17.storesOf)(feature).flatMap((store) => {
903
+ const subStoreId = store.subStore?.id;
904
+ const owner = subStoreId ? { ...at, subStoreId } : at;
905
+ const others = /* @__PURE__ */ new Set([
906
+ ...Object.values(store.methods ?? {}).map((member) => member.name),
907
+ ...Object.values(store.computeds ?? {}).map((member) => member.name)
908
+ ]);
909
+ return Object.values(store.properties ?? {}).filter((property) => others.has(property.name)).map((property) => ({
910
+ subject: `${feature.name} \u2192 ${property.name}`,
911
+ target: { ...owner, memberId: property.id }
912
+ }));
913
+ });
914
+ })
915
+ });
916
+
917
+ // apps/m-one-ui/src/app/pages/design/lib/screen-embed-helper.ts
918
+ var import_codegen18 = require("./index.js");
919
+ var isScreenControl = (control) => control.type === import_codegen18.ControlType.SCREEN && typeof control.screenId === "string";
621
920
  function embeddedScreenIds(controlMap) {
622
921
  return Object.values(controlMap).filter(isScreenControl).map((control) => control.screenId);
623
922
  }
@@ -632,7 +931,7 @@ function reachableScreenIds(rootId, maps) {
632
931
  }
633
932
  return seen;
634
933
  }
635
- var firesFromMount = (screen) => (0, import_codegen14.isFeatureScreen)(screen) && !!screen.autoCalls?.length;
934
+ var firesFromMount = (screen) => (0, import_codegen18.isFeatureScreen)(screen) && !!screen.autoCalls?.length;
636
935
  function duplicateFeatureEmbeds(rootId, maps, screens) {
637
936
  return [
638
937
  ...new Set(
@@ -660,7 +959,7 @@ function duplicateFeatureEmbedControls(rootId, maps, screens) {
660
959
  if (parent.variants?.length) {
661
960
  gates.add(JSON.stringify([instance, "variants", parent.variants]));
662
961
  }
663
- if (parent.type === import_codegen14.ControlType.BRANCH_ARM) {
962
+ if (parent.type === import_codegen18.ControlType.BRANCH_ARM) {
664
963
  gates.add(
665
964
  JSON.stringify([instance, "arm", parent.parentId, parent.id])
666
965
  );
@@ -702,10 +1001,10 @@ function featureReachEdges(maps, screens) {
702
1001
  const byId = new Map(screens.map((screen) => [screen.id, screen]));
703
1002
  const edges = /* @__PURE__ */ new Map();
704
1003
  for (const screen of screens) {
705
- if (!(0, import_codegen14.isFeatureScreen)(screen)) continue;
1004
+ if (!(0, import_codegen18.isFeatureScreen)(screen)) continue;
706
1005
  for (const id of embeddedScreenIds(maps[screen.id] ?? {})) {
707
1006
  const target2 = byId.get(id);
708
- if (!target2 || !(0, import_codegen14.isFeatureScreen)(target2)) continue;
1007
+ if (!target2 || !(0, import_codegen18.isFeatureScreen)(target2)) continue;
709
1008
  if (target2.featureId === screen.featureId) continue;
710
1009
  const reached = edges.get(screen.featureId) ?? /* @__PURE__ */ new Set();
711
1010
  reached.add(target2.featureId);
@@ -744,7 +1043,7 @@ function screenEmbedProblems(host, maps, screens) {
744
1043
  });
745
1044
  continue;
746
1045
  }
747
- if (!(0, import_codegen14.canEmbedScreen)(host, target2)) {
1046
+ if (!(0, import_codegen18.canEmbedScreen)(host, target2)) {
748
1047
  problems.push({
749
1048
  kind: "illegal-target",
750
1049
  controlId: control.id,
@@ -752,7 +1051,7 @@ function screenEmbedProblems(host, maps, screens) {
752
1051
  });
753
1052
  continue;
754
1053
  }
755
- if ((0, import_codegen14.isFeatureScreen)(host) && (0, import_codegen14.isFeatureScreen)(target2) && wouldCycleFeatures(host.featureId, target2.featureId, featureEdges)) {
1054
+ if ((0, import_codegen18.isFeatureScreen)(host) && (0, import_codegen18.isFeatureScreen)(target2) && wouldCycleFeatures(host.featureId, target2.featureId, featureEdges)) {
756
1055
  problems.push({
757
1056
  kind: "feature-cycle",
758
1057
  controlId: control.id,
@@ -831,6 +1130,27 @@ var screenControlReachable = defineInvariant({
831
1130
  }
832
1131
  }));
833
1132
  }
1133
+ if (problem.kind === "missing-screen") {
1134
+ return [
1135
+ {
1136
+ subject: `${host.name} \u2192 missing Screen ${problem.screenId}`,
1137
+ screenRetarget: true,
1138
+ target: {
1139
+ kind: "control",
1140
+ screenId: host.id,
1141
+ controlId: problem.controlId
1142
+ }
1143
+ }
1144
+ ];
1145
+ }
1146
+ if (problem.kind === "cycle") {
1147
+ return [
1148
+ {
1149
+ subject: `${host.name} \u2192 embeds itself through its ScreenControls`,
1150
+ target: { kind: "screen", screenId: host.id, panel: "screen" }
1151
+ }
1152
+ ];
1153
+ }
834
1154
  return [];
835
1155
  }
836
1156
  )
@@ -845,12 +1165,12 @@ var screenControlReachable = defineInvariant({
845
1165
  });
846
1166
 
847
1167
  // apps/m-one-ui/src/app/pages/design/lib/screen-input-binding-check.ts
848
- var import_codegen15 = require("./index.js");
1168
+ var import_codegen19 = require("./index.js");
849
1169
  var staticFits = (input, value) => {
850
- const primitive = (0, import_codegen15.inputPrimitive)(input);
1170
+ const primitive = (0, import_codegen19.inputPrimitive)(input);
851
1171
  if (!primitive) return false;
852
1172
  if (input.cardinality === "many") {
853
- return (0, import_codegen15.fixedItems)(value).every(
1173
+ return (0, import_codegen19.fixedItems)(value).every(
854
1174
  (item) => staticFits({ ...input, cardinality: "one" }, item)
855
1175
  );
856
1176
  }
@@ -863,20 +1183,20 @@ var staticFits = (input, value) => {
863
1183
  var outputFits = (input, binding, controlMap, screens) => {
864
1184
  if (input.required) return false;
865
1185
  const sibling = controlMap[binding.controlId];
866
- if (!sibling || sibling.type !== import_codegen15.ControlType.SCREEN) return false;
1186
+ if (!sibling || sibling.type !== import_codegen19.ControlType.SCREEN) return false;
867
1187
  const siblingScreen = screens.find(
868
1188
  (screen) => screen.id === sibling.screenId
869
1189
  );
870
1190
  if (!siblingScreen) return false;
871
- const output = (0, import_codegen15.listScreenOutputs)(siblingScreen.outputs).find(
1191
+ const output = (0, import_codegen19.listScreenOutputs)(siblingScreen.outputs).find(
872
1192
  (entry) => entry.id === binding.outputId
873
1193
  );
874
- const primitive = (0, import_codegen15.inputPrimitive)(input);
1194
+ const primitive = (0, import_codegen19.inputPrimitive)(input);
875
1195
  return !!output && !!primitive && output.payload?.dataType === primitive && output.payload?.cardinality === input.cardinality;
876
1196
  };
877
1197
  var sourceScope = (host, control, controlMap, features, functions, enums) => {
878
- const feature = (0, import_codegen15.isFeatureScreen)(host) ? features[host.featureId] : void 0;
879
- const readable = feature ? (0, import_codegen15.readableMembers)(feature, import_codegen15.MAIN_STORE_OWNER) : void 0;
1198
+ const feature = (0, import_codegen19.isFeatureScreen)(host) ? features[host.featureId] : void 0;
1199
+ const readable = feature ? (0, import_codegen19.readableMembers)(feature, import_codegen19.MAIN_STORE_OWNER) : void 0;
880
1200
  const inScope = { ...functions, ...feature?.functions };
881
1201
  const properties = readable?.properties ?? {};
882
1202
  return {
@@ -889,7 +1209,7 @@ var sourceScope = (host, control, controlMap, features, functions, enums) => {
889
1209
  data: {
890
1210
  controlId: control.id,
891
1211
  controlMap,
892
- roots: (0, import_codegen15.propertiesWithComputeds)(
1212
+ roots: (0, import_codegen19.propertiesWithComputeds)(
893
1213
  properties,
894
1214
  readable?.computeds ?? {},
895
1215
  inScope
@@ -919,7 +1239,7 @@ function screenInputProblems(host, controlMap, screens, features, functions, enu
919
1239
  functions,
920
1240
  enums
921
1241
  );
922
- for (const input of (0, import_codegen15.listScreenInputs)(target2.inputs)) {
1242
+ for (const input of (0, import_codegen19.listScreenInputs)(target2.inputs)) {
923
1243
  if (input.origin) continue;
924
1244
  const binding = bound[input.id];
925
1245
  const row = {
@@ -932,13 +1252,13 @@ function screenInputProblems(host, controlMap, screens, features, functions, enu
932
1252
  if (input.required) problems.push({ kind: "required-unbound", ...row });
933
1253
  continue;
934
1254
  }
935
- const fits = binding.kind === "static" ? staticFits(input, binding.value) : binding.kind === "output" ? outputFits(input, binding, controlMap, screens) : (0, import_codegen15.screenInputSourceOptions)(scope, {
936
- dataType: (0, import_codegen15.inputPrimitive)(input),
1255
+ const fits = binding.kind === "static" ? staticFits(input, binding.value) : binding.kind === "output" ? outputFits(input, binding, controlMap, screens) : (0, import_codegen19.screenInputSourceOptions)(scope, {
1256
+ dataType: (0, import_codegen19.inputPrimitive)(input),
937
1257
  cardinality: input.cardinality,
938
1258
  declared: input.dataType,
939
1259
  required: input.required
940
1260
  }).some(
941
- (option) => option.value === (0, import_codegen15.screenInputSourceValue)(binding)
1261
+ (option) => option.value === (0, import_codegen19.screenInputSourceValue)(binding)
942
1262
  );
943
1263
  if (!fits) problems.push({ kind: "unfit", ...row });
944
1264
  }
@@ -999,15 +1319,15 @@ function perScreen(judge) {
999
1319
  }
1000
1320
 
1001
1321
  // apps/m-one-ui/src/app/pages/design/lib/invariants/branch-arm-reachable.ts
1002
- var import_codegen16 = require("./index.js");
1322
+ var import_codegen20 = require("./index.js");
1003
1323
  var ATOM_CAP = 12;
1004
- var foldText = (arm, names) => (0, import_codegen16.controlVariants)(arm).map((entry, index) => {
1324
+ var foldText = (arm, names) => (0, import_codegen20.controlVariants)(arm).map((entry, index) => {
1005
1325
  const name = names.get(entry.id) ?? entry.id;
1006
- const term = (0, import_codegen16.variantJoinIsNot)(entry.join) ? `!${name}` : name;
1326
+ const term = (0, import_codegen20.variantJoinIsNot)(entry.join) ? `!${name}` : name;
1007
1327
  if (index === 0) return term;
1008
- return `${(0, import_codegen16.variantJoinIsAnd)(entry.join) ? "&&" : "||"} ${term}`;
1328
+ return `${(0, import_codegen20.variantJoinIsAnd)(entry.join) ? "&&" : "||"} ${term}`;
1009
1329
  }).join(" ");
1010
- var armSubject = (arm, names) => (0, import_codegen16.armKind)(arm) === "default" ? import_codegen16.ARM_KIND_LABEL.default : foldText(arm, names) || import_codegen16.ARM_KIND_LABEL.branch;
1330
+ var armSubject = (arm, names) => (0, import_codegen20.armKind)(arm) === "default" ? import_codegen20.ARM_KIND_LABEL.default : foldText(arm, names) || import_codegen20.ARM_KIND_LABEL.branch;
1011
1331
  var variantNames = (features, screens, currentScreenId) => {
1012
1332
  const screen = screens.find((one) => one.id === currentScreenId);
1013
1333
  const feature = screen?.featureId ? features[screen.featureId] : void 0;
@@ -1018,13 +1338,13 @@ var variantNames = (features, screens, currentScreenId) => {
1018
1338
  return names;
1019
1339
  };
1020
1340
  var unreachableArmIds = (branchId, controlMap) => {
1021
- const arms = (0, import_codegen16.orderedArms)(branchId, controlMap).filter(
1022
- (arm) => (0, import_codegen16.armKind)(arm) === "default" || (0, import_codegen16.controlVariants)(arm).length > 0
1341
+ const arms = (0, import_codegen20.orderedArms)(branchId, controlMap).filter(
1342
+ (arm) => (0, import_codegen20.armKind)(arm) === "default" || (0, import_codegen20.controlVariants)(arm).length > 0
1023
1343
  );
1024
1344
  if (arms.length < 2) return [];
1025
1345
  const atoms = [
1026
1346
  ...new Set(
1027
- arms.flatMap((arm) => (0, import_codegen16.controlVariants)(arm).map((entry) => entry.id))
1347
+ arms.flatMap((arm) => (0, import_codegen20.controlVariants)(arm).map((entry) => entry.id))
1028
1348
  )
1029
1349
  ];
1030
1350
  if (atoms.length > ATOM_CAP) return [];
@@ -1033,7 +1353,7 @@ var unreachableArmIds = (branchId, controlMap) => {
1033
1353
  for (let row = 0; row < rows; row++) {
1034
1354
  const on = atoms.filter((_, index) => row & 1 << index);
1035
1355
  for (const arm of arms) {
1036
- if ((0, import_codegen16.armKind)(arm) === "default" || (0, import_codegen16.evaluateVariantGate)((0, import_codegen16.controlVariants)(arm), on)) {
1356
+ if ((0, import_codegen20.armKind)(arm) === "default" || (0, import_codegen20.evaluateVariantGate)((0, import_codegen20.controlVariants)(arm), on)) {
1037
1357
  reached.add(arm.id);
1038
1358
  break;
1039
1359
  }
@@ -1045,7 +1365,7 @@ var unreachableArms = perScreen(
1045
1365
  (controlMap, screen, { features, screens }) => {
1046
1366
  const names = variantNames(features, screens, screen.id);
1047
1367
  return Object.entries(controlMap).flatMap(([branchId, control]) => {
1048
- if (control.type !== import_codegen16.ControlType.VARIANT_BRANCH) return [];
1368
+ if (control.type !== import_codegen20.ControlType.VARIANT_BRANCH) return [];
1049
1369
  return unreachableArmIds(branchId, controlMap).map((armId) => ({
1050
1370
  subject: armSubject(controlMap[armId], names),
1051
1371
  target: {
@@ -1067,7 +1387,7 @@ var branchArmReachable = defineInvariant({
1067
1387
  });
1068
1388
 
1069
1389
  // apps/m-one-ui/src/app/pages/design/lib/invariants/computed-args-bound.ts
1070
- var import_codegen17 = require("./index.js");
1390
+ var import_codegen21 = require("./index.js");
1071
1391
  var computedArgsBound = defineInvariant({
1072
1392
  name: "computed-args-bound",
1073
1393
  message: "invariant-computed-args-unbound",
@@ -1075,21 +1395,21 @@ var computedArgsBound = defineInvariant({
1075
1395
  deps: ["features", "screens", "functions"],
1076
1396
  validate: ({ features, screens, functions }) => {
1077
1397
  const scopeFor = (featureId) => featureId ? { ...functions, ...features[featureId]?.functions ?? {} } : functions;
1078
- const broken = (fn, args) => !fn || !(0, import_codegen17.argsComplete)(fn, args);
1398
+ const broken = (fn, args) => !fn || !(0, import_codegen21.argsComplete)(fn, args);
1079
1399
  const stateFindings = Object.values(features).flatMap((feature) => {
1080
1400
  const fns = scopeFor(feature.id);
1081
1401
  const screenId = screens.find((screen) => screen.featureId === feature.id)?.id ?? "";
1082
- return Object.values(feature.computeds ?? {}).filter((computed) => broken((0, import_codegen17.stateComputedFunction)(computed, fns), computed.args)).map((computed) => ({
1402
+ return Object.values(feature.computeds ?? {}).filter((computed) => broken((0, import_codegen21.stateComputedFunction)(computed, fns), computed.args)).map((computed) => ({
1083
1403
  subject: `${feature.name}.${computed.name}`,
1084
1404
  target: { kind: "screen", screenId }
1085
1405
  }));
1086
1406
  });
1087
1407
  const screenFindings = screens.flatMap((screen) => {
1088
1408
  const fns = scopeFor(
1089
- (0, import_codegen17.isFeatureScreen)(screen) ? screen.featureId : void 0
1409
+ (0, import_codegen21.isFeatureScreen)(screen) ? screen.featureId : void 0
1090
1410
  );
1091
1411
  return Object.values(screen.computeds ?? {}).filter(
1092
- (computed) => broken((0, import_codegen17.screenComputedFunction)(computed, fns), computed.args)
1412
+ (computed) => broken((0, import_codegen21.screenComputedFunction)(computed, fns), computed.args)
1093
1413
  ).map((computed) => ({
1094
1414
  subject: `${screen.name}.${computed.name}`,
1095
1415
  target: { kind: "screen", screenId: screen.id }
@@ -1100,7 +1420,7 @@ var computedArgsBound = defineInvariant({
1100
1420
  });
1101
1421
 
1102
1422
  // apps/m-one-ui/src/app/pages/design/lib/invariants/computed-args-typed.ts
1103
- var import_codegen18 = require("./index.js");
1423
+ var import_codegen22 = require("./index.js");
1104
1424
  var computedArgsTyped = defineInvariant({
1105
1425
  name: "computed-args-typed",
1106
1426
  message: "invariant-computed-args-mistyped",
@@ -1111,7 +1431,7 @@ var computedArgsTyped = defineInvariant({
1111
1431
  const stateFindings = Object.values(features).flatMap((feature) => {
1112
1432
  const fns = scopeFor(feature.id);
1113
1433
  const screenId = screens.find((screen) => screen.featureId === feature.id)?.id ?? "";
1114
- const roots = (0, import_codegen18.propertiesWithComputeds)(
1434
+ const roots = (0, import_codegen22.propertiesWithComputeds)(
1115
1435
  feature.properties,
1116
1436
  feature.computeds,
1117
1437
  fns
@@ -1124,7 +1444,7 @@ var computedArgsTyped = defineInvariant({
1124
1444
  )
1125
1445
  ).filter((computed) => {
1126
1446
  const fn = fns[computed.functionId];
1127
- return !!fn && (0, import_codegen18.mistypedStateArgs)(fn, computed.args, roots, feature.shapes).length > 0;
1447
+ return !!fn && (0, import_codegen22.mistypedStateArgs)(fn, computed.args, roots, feature.shapes).length > 0;
1128
1448
  }).map((computed) => ({
1129
1449
  subject: `${feature.name}.${computed.name}`,
1130
1450
  target: { kind: "screen", screenId },
@@ -1133,27 +1453,27 @@ var computedArgsTyped = defineInvariant({
1133
1453
  featureId: feature.id,
1134
1454
  functionId: computed.functionId,
1135
1455
  params: fns[computed.functionId].params.map((param) => {
1136
- const held = (0, import_codegen18.stateComputedArgHeldType)(
1456
+ const held = (0, import_codegen22.stateComputedArgHeldType)(
1137
1457
  computed.args[param.id],
1138
1458
  roots,
1139
1459
  feature.shapes
1140
1460
  );
1141
- return held && !(0, import_codegen18.argAnswersParam)(held, param, feature.shapes) ? { ...param, ...held } : param;
1461
+ return held && !(0, import_codegen22.argAnswersParam)(held, param, feature.shapes) ? { ...param, ...held } : param;
1142
1462
  })
1143
1463
  }
1144
1464
  }));
1145
1465
  });
1146
1466
  const screenFindings = screens.flatMap((screen) => {
1147
- const featureId = (0, import_codegen18.isFeatureScreen)(screen) ? screen.featureId : void 0;
1467
+ const featureId = (0, import_codegen22.isFeatureScreen)(screen) ? screen.featureId : void 0;
1148
1468
  const fns = scopeFor(featureId);
1149
1469
  const feature = featureId ? features[featureId] : void 0;
1150
1470
  const scope = {
1151
1471
  constants: screen.constants,
1152
- variables: (0, import_codegen18.withVariableEnums)(
1472
+ variables: (0, import_codegen22.withVariableEnums)(
1153
1473
  screen.variables ?? {},
1154
1474
  screenControlMaps[screen.id] ?? {}
1155
1475
  ),
1156
- properties: feature ? (0, import_codegen18.propertiesWithComputeds)(
1476
+ properties: feature ? (0, import_codegen22.propertiesWithComputeds)(
1157
1477
  feature.properties,
1158
1478
  feature.computeds,
1159
1479
  fns
@@ -1161,9 +1481,9 @@ var computedArgsTyped = defineInvariant({
1161
1481
  shapes: feature?.shapes ?? {}
1162
1482
  };
1163
1483
  return Object.values(screen.computeds ?? {}).filter((computed) => {
1164
- if ((0, import_codegen18.isOneFunctionComputed)(computed)) return false;
1165
- const fn = (0, import_codegen18.screenComputedFunction)(computed, fns);
1166
- return !!fn && (0, import_codegen18.mistypedScreenArgs)(
1484
+ if ((0, import_codegen22.isOneFunctionComputed)(computed)) return false;
1485
+ const fn = (0, import_codegen22.screenComputedFunction)(computed, fns);
1486
+ return !!fn && (0, import_codegen22.mistypedScreenArgs)(
1167
1487
  fn,
1168
1488
  computed.args,
1169
1489
  screen.inputs ?? {},
@@ -1172,24 +1492,24 @@ var computedArgsTyped = defineInvariant({
1172
1492
  scope
1173
1493
  ).length > 0;
1174
1494
  }).map((computed) => {
1175
- const fn = (0, import_codegen18.screenComputedFunction)(computed, fns);
1495
+ const fn = (0, import_codegen22.screenComputedFunction)(computed, fns);
1176
1496
  const params = fn.params.map((param) => {
1177
1497
  const arg = computed.args[param.id];
1178
- const shapeId = arg?.source === "options" ? (0, import_codegen18.findOptionRowShapeId)(scope.shapes) : void 0;
1498
+ const shapeId = arg?.source === "options" ? (0, import_codegen22.findOptionRowShapeId)(scope.shapes) : void 0;
1179
1499
  const held = shapeId ? {
1180
1500
  dataType: { type: "shape", shapeId },
1181
1501
  cardinality: "many"
1182
- } : (0, import_codegen18.screenComputedArgHeldType)(
1502
+ } : (0, import_codegen22.screenComputedArgHeldType)(
1183
1503
  arg,
1184
1504
  screen.inputs ?? {},
1185
1505
  screen.computeds ?? {},
1186
1506
  fns,
1187
1507
  scope
1188
1508
  );
1189
- return held && !(0, import_codegen18.argAnswersParam)(held, param, scope.shapes) ? { ...param, ...held } : param;
1509
+ return held && !(0, import_codegen22.argAnswersParam)(held, param, scope.shapes) ? { ...param, ...held } : param;
1190
1510
  });
1191
1511
  const repaired = { ...fn, params };
1192
- const canFix = !(0, import_codegen18.isPassthroughComputed)(computed) && !(0, import_codegen18.isOneFunctionComputed)(computed) && (0, import_codegen18.mistypedScreenArgs)(
1512
+ const canFix = !(0, import_codegen22.isPassthroughComputed)(computed) && !(0, import_codegen22.isOneFunctionComputed)(computed) && (0, import_codegen22.mistypedScreenArgs)(
1193
1513
  repaired,
1194
1514
  computed.args,
1195
1515
  screen.inputs ?? {},
@@ -1216,7 +1536,7 @@ var computedArgsTyped = defineInvariant({
1216
1536
  });
1217
1537
 
1218
1538
  // apps/m-one-ui/src/app/pages/design/lib/invariants/one-function-arg-mismatch.ts
1219
- var import_codegen19 = require("./index.js");
1539
+ var import_codegen23 = require("./index.js");
1220
1540
  var sameDataType = (a, b) => a.type === "shape" ? b.type === "shape" && a.shapeId === b.shapeId : a.type === "form" ? b.type === "form" && a.formId === b.formId : a.type === b.type;
1221
1541
  var oneFunctionArgMismatch = defineInvariant({
1222
1542
  name: "one-function-arg-mismatch",
@@ -1225,24 +1545,24 @@ var oneFunctionArgMismatch = defineInvariant({
1225
1545
  deps: ["features", "screens", "functions"],
1226
1546
  validate: ({ features, screens, functions }) => [
1227
1547
  ...screens.flatMap((screen) => {
1228
- const featureId = (0, import_codegen19.isFeatureScreen)(screen) ? screen.featureId : void 0;
1548
+ const featureId = (0, import_codegen23.isFeatureScreen)(screen) ? screen.featureId : void 0;
1229
1549
  const feature = featureId ? features[featureId] : void 0;
1230
1550
  const fns = feature ? { ...functions, ...feature.functions ?? {} } : functions;
1231
1551
  const scope = {
1232
1552
  constants: screen.constants,
1233
1553
  variables: screen.variables,
1234
- properties: feature ? (0, import_codegen19.propertiesWithComputeds)(feature.properties, feature.computeds, fns) : {},
1554
+ properties: feature ? (0, import_codegen23.propertiesWithComputeds)(feature.properties, feature.computeds, fns) : {},
1235
1555
  shapes: feature?.shapes ?? {}
1236
1556
  };
1237
- return Object.values(screen.computeds ?? {}).filter(import_codegen19.isOneFunctionComputed).filter((computed) => {
1238
- const entry = (0, import_codegen19.oneFunctionOf)(computed.oneFunction);
1557
+ return Object.values(screen.computeds ?? {}).filter(import_codegen23.isOneFunctionComputed).filter((computed) => {
1558
+ const entry = (0, import_codegen23.oneFunctionOf)(computed.oneFunction);
1239
1559
  const returns = computed.returns;
1240
1560
  if (!entry || !returns) return false;
1241
1561
  if (!feature) return true;
1242
1562
  return entry.params.some((param) => {
1243
1563
  const arg = computed.args[param.id];
1244
1564
  if (!arg) return false;
1245
- const held = (0, import_codegen19.screenComputedArgHeldType)(
1565
+ const held = (0, import_codegen23.screenComputedArgHeldType)(
1246
1566
  arg,
1247
1567
  screen.inputs ?? {},
1248
1568
  screen.computeds ?? {},
@@ -1250,11 +1570,11 @@ var oneFunctionArgMismatch = defineInvariant({
1250
1570
  scope
1251
1571
  );
1252
1572
  if (!held) return false;
1253
- if (!(0, import_codegen19.oneFunctionArgFits)(param, held, arg.source === "path"))
1573
+ if (!(0, import_codegen23.oneFunctionArgFits)(param, held, arg.source === "path"))
1254
1574
  return true;
1255
1575
  return entry.returnsRow && param.id === entry.rowParamId && (!sameDataType(held.dataType, returns.dataType) || // A `map` turned `map-many` (or back) moves the return
1256
1576
  // between the row and the row list (ADR 0205).
1257
- (0, import_codegen19.oneFunctionReturns)(entry, held.dataType, held.cardinality).cardinality !== returns.cardinality);
1577
+ (0, import_codegen23.oneFunctionReturns)(entry, held.dataType, held.cardinality).cardinality !== returns.cardinality);
1258
1578
  });
1259
1579
  }).map((computed) => ({
1260
1580
  subject: `${screen.name}.${computed.name}`,
@@ -1277,32 +1597,32 @@ var oneFunctionArgMismatch = defineInvariant({
1277
1597
  });
1278
1598
  function stateComputedFindings(feature, functions) {
1279
1599
  const fns = { ...functions, ...feature.functions ?? {} };
1280
- const stores = (0, import_codegen19.storesOf)(feature);
1600
+ const stores = (0, import_codegen23.storesOf)(feature);
1281
1601
  const roots = Object.assign(
1282
1602
  {},
1283
1603
  ...stores.map(
1284
- (owned) => (0, import_codegen19.propertiesWithComputeds)(owned.properties, owned.computeds, fns)
1604
+ (owned) => (0, import_codegen23.propertiesWithComputeds)(owned.properties, owned.computeds, fns)
1285
1605
  )
1286
1606
  );
1287
1607
  return stores.flatMap(
1288
- (owned) => Object.values(owned.computeds).filter(import_codegen19.isOneFunctionStateComputed).filter((computed) => {
1289
- const entry = (0, import_codegen19.oneFunctionOf)(computed.oneFunction);
1608
+ (owned) => Object.values(owned.computeds).filter(import_codegen23.isOneFunctionStateComputed).filter((computed) => {
1609
+ const entry = (0, import_codegen23.oneFunctionOf)(computed.oneFunction);
1290
1610
  const returns = computed.returns;
1291
1611
  if (!entry?.reach.includes("state-computed") || !returns) return false;
1292
1612
  const rowArg = computed.args[entry.rowParamId];
1293
- const row = rowArg?.source === "path" ? (0, import_codegen19.statePathHeldType)(rowArg.path, roots, feature.shapes) : void 0;
1613
+ const row = rowArg?.source === "path" ? (0, import_codegen23.statePathHeldType)(rowArg.path, roots, feature.shapes) : void 0;
1294
1614
  const fits = entry.params.every((param) => {
1295
1615
  const arg = computed.args[param.id];
1296
1616
  if (!arg) return true;
1297
- const held = arg.source === "fixed" ? (0, import_codegen19.oneParamFixedHeld)(param, arg.value) : (0, import_codegen19.statePathHeldType)(arg.path, roots, feature.shapes);
1617
+ const held = arg.source === "fixed" ? (0, import_codegen23.oneParamFixedHeld)(param, arg.value) : (0, import_codegen23.statePathHeldType)(arg.path, roots, feature.shapes);
1298
1618
  if (arg.source === "path" && !held) return true;
1299
- return (0, import_codegen19.oneFunctionArgFits)(param, held, arg.source === "path");
1619
+ return (0, import_codegen23.oneFunctionArgFits)(param, held, arg.source === "path");
1300
1620
  });
1301
1621
  if (!fits) return true;
1302
- if (entry.returnsRow && row && (!sameDataType(row.dataType, returns.dataType) || (0, import_codegen19.oneFunctionReturns)(entry, row.dataType, row.cardinality).cardinality !== returns.cardinality))
1622
+ if (entry.returnsRow && row && (!sameDataType(row.dataType, returns.dataType) || (0, import_codegen23.oneFunctionReturns)(entry, row.dataType, row.cardinality).cardinality !== returns.cardinality))
1303
1623
  return true;
1304
- const key = computed.args[import_codegen19.ONE_FUNCTION_KEY_PARAM];
1305
- if (key?.source === "fixed" && entry.params.some((param) => param.id === import_codegen19.ONE_FUNCTION_KEY_PARAM) && row?.dataType.type === "shape") {
1624
+ const key = computed.args[import_codegen23.ONE_FUNCTION_KEY_PARAM];
1625
+ if (key?.source === "fixed" && entry.params.some((param) => param.id === import_codegen23.ONE_FUNCTION_KEY_PARAM) && row?.dataType.type === "shape") {
1306
1626
  const shape = feature.shapes[row.dataType.shapeId];
1307
1627
  return !!shape && !shape.keys.some(
1308
1628
  (member) => member.name === key.value && member.cardinality === "one" && member.dataType.type === "string"
@@ -1323,36 +1643,36 @@ function stateComputedFindings(feature, functions) {
1323
1643
  }
1324
1644
  function conditionFindings(feature, functions) {
1325
1645
  const fns = { ...functions, ...feature.functions ?? {} };
1326
- const stores = (0, import_codegen19.storesOf)(feature);
1646
+ const stores = (0, import_codegen23.storesOf)(feature);
1327
1647
  const roots = Object.assign(
1328
1648
  {},
1329
1649
  ...stores.map(
1330
- (owned) => (0, import_codegen19.propertiesWithComputeds)(owned.properties, owned.computeds, fns)
1650
+ (owned) => (0, import_codegen23.propertiesWithComputeds)(owned.properties, owned.computeds, fns)
1331
1651
  )
1332
1652
  );
1333
1653
  const mismatched = (condition) => {
1334
1654
  if (!condition.oneFunction) return false;
1335
- const entry = (0, import_codegen19.oneFunctionOf)(condition.oneFunction);
1655
+ const entry = (0, import_codegen23.oneFunctionOf)(condition.oneFunction);
1336
1656
  if (!entry?.reach.includes("call-condition")) return true;
1337
1657
  return entry.params.some((param) => {
1338
1658
  const binding = condition.args[param.id];
1339
1659
  if (binding?.source !== "store") return false;
1340
- const held = (0, import_codegen19.statePathHeldType)(binding.path, roots, feature.shapes);
1341
- return !!held && !(0, import_codegen19.oneFunctionArgFits)(param, held, true);
1660
+ const held = (0, import_codegen23.statePathHeldType)(binding.path, roots, feature.shapes);
1661
+ return !!held && !(0, import_codegen23.oneFunctionArgFits)(param, held, true);
1342
1662
  });
1343
1663
  };
1344
1664
  const computeMismatched = (compute) => {
1345
1665
  if (!compute.oneFunction) return false;
1346
- const entry = (0, import_codegen19.oneFunctionOf)(compute.oneFunction);
1666
+ const entry = (0, import_codegen23.oneFunctionOf)(compute.oneFunction);
1347
1667
  if (!entry?.reach.includes("call-compute") || !compute.returns) return true;
1348
1668
  const returns = compute.returns;
1349
1669
  return entry.params.some((param) => {
1350
1670
  const binding = compute.args[param.id];
1351
1671
  if (binding?.source !== "store") return false;
1352
- const held = (0, import_codegen19.statePathHeldType)(binding.path, roots, feature.shapes);
1672
+ const held = (0, import_codegen23.statePathHeldType)(binding.path, roots, feature.shapes);
1353
1673
  if (!held) return false;
1354
- if (!(0, import_codegen19.oneFunctionArgFits)(param, held, true)) return true;
1355
- return entry.returnsRow && param.id === entry.rowParamId && (!sameDataType(held.dataType, returns.dataType) || (0, import_codegen19.oneFunctionReturns)(entry, held.dataType, held.cardinality).cardinality !== returns.cardinality);
1674
+ if (!(0, import_codegen23.oneFunctionArgFits)(param, held, true)) return true;
1675
+ return entry.returnsRow && param.id === entry.rowParamId && (!sameDataType(held.dataType, returns.dataType) || (0, import_codegen23.oneFunctionReturns)(entry, held.dataType, held.cardinality).cardinality !== returns.cardinality);
1356
1676
  });
1357
1677
  };
1358
1678
  return stores.flatMap(
@@ -1372,7 +1692,7 @@ function conditionFindings(feature, functions) {
1372
1692
  }
1373
1693
 
1374
1694
  // apps/m-one-ui/src/app/pages/design/lib/invariants/one-function-required-param.ts
1375
- var import_codegen20 = require("./index.js");
1695
+ var import_codegen24 = require("./index.js");
1376
1696
  var requiresParam = (method, name) => (method.params ?? []).some(
1377
1697
  (param) => param.name === name && param.required === true
1378
1698
  ) || method.inputs.some(
@@ -1384,12 +1704,12 @@ var oneFunctionRequiredParam = defineInvariant({
1384
1704
  severity: "blocking",
1385
1705
  deps: ["features", "screens", "screenControlMaps"],
1386
1706
  validate: ({ features, screens, screenControlMaps }) => screens.flatMap((screen) => {
1387
- if (!(0, import_codegen20.isFeatureScreen)(screen)) return [];
1707
+ if (!(0, import_codegen24.isFeatureScreen)(screen)) return [];
1388
1708
  const feature = features[screen.featureId];
1389
1709
  if (!feature) return [];
1390
1710
  const methods = Object.assign(
1391
1711
  {},
1392
- ...(0, import_codegen20.storesOf)(feature).map((owned) => owned.methods)
1712
+ ...(0, import_codegen24.storesOf)(feature).map((owned) => owned.methods)
1393
1713
  );
1394
1714
  const computeds = screen.computeds ?? {};
1395
1715
  return Object.values(screenControlMaps[screen.id] ?? {}).flatMap(
@@ -1403,7 +1723,7 @@ var oneFunctionRequiredParam = defineInvariant({
1403
1723
  return false;
1404
1724
  const computed = computeds[root.id];
1405
1725
  const name = row.target[0];
1406
- return !!computed && (0, import_codegen20.isOneFunctionComputed)(computed) && (0, import_codegen20.screenComputedFunction)(computed, {})?.returnUndefined === true && !!name && requiresParam(method, name);
1726
+ return !!computed && (0, import_codegen24.isOneFunctionComputed)(computed) && (0, import_codegen24.screenComputedFunction)(computed, {})?.returnUndefined === true && !!name && requiresParam(method, name);
1407
1727
  }).map((row) => ({
1408
1728
  subject: `${screen.name}.${method.name}(${row.target[0]})`,
1409
1729
  target: {
@@ -1419,7 +1739,7 @@ var oneFunctionRequiredParam = defineInvariant({
1419
1739
  });
1420
1740
 
1421
1741
  // apps/m-one-ui/src/app/pages/design/lib/invariants/confirm-unattended-call.ts
1422
- var import_codegen21 = require("./index.js");
1742
+ var import_codegen25 = require("./index.js");
1423
1743
  var confirmUnattendedCall = defineInvariant({
1424
1744
  name: "confirm-unattended-call",
1425
1745
  message: "invariant-confirm-unattended",
@@ -1429,7 +1749,7 @@ var confirmUnattendedCall = defineInvariant({
1429
1749
  const featureScreen = (featureId) => screens.find((screen) => screen.featureId === featureId)?.id ?? "";
1430
1750
  return Object.values(features).flatMap((feature) => {
1431
1751
  const asking = new Set(
1432
- Object.values(feature.methods).filter((method) => !!(0, import_codegen21.drawnConfirm)(method)).map((method) => method.id)
1752
+ Object.values(feature.methods).filter((method) => !!(0, import_codegen25.drawnConfirm)(method)).map((method) => method.id)
1433
1753
  );
1434
1754
  if (!asking.size) return [];
1435
1755
  const named2 = (methodId) => feature.methods[methodId]?.name ?? methodId;
@@ -1463,15 +1783,15 @@ var confirmUnattendedCall = defineInvariant({
1463
1783
  });
1464
1784
 
1465
1785
  // apps/m-one-ui/src/app/pages/design/lib/invariants/close-overlay-off-overlay.ts
1466
- var import_codegen23 = require("./index.js");
1786
+ var import_codegen27 = require("./index.js");
1467
1787
 
1468
1788
  // apps/m-one-ui/src/app/pages/design/lib/screen-link.ts
1469
- var import_codegen22 = require("./index.js");
1789
+ var import_codegen26 = require("./index.js");
1470
1790
  function overlayLinks(fromScreenId, map) {
1471
1791
  const links = [];
1472
1792
  Object.values(map).forEach((control) => {
1473
1793
  Object.entries(control.directives ?? {}).forEach(([name, directive]) => {
1474
- if (!(0, import_codegen22.isOverlayDirectiveName)(name)) return;
1794
+ if (!(0, import_codegen26.isOverlayDirectiveName)(name)) return;
1475
1795
  const configs = directive.overlayId ? map[directive.overlayId]?.configs : directive.configs;
1476
1796
  const component = configs?.["component"];
1477
1797
  if (typeof component !== "string" || !component) return;
@@ -1485,7 +1805,7 @@ function overlayLinks(fromScreenId, map) {
1485
1805
  });
1486
1806
  return links;
1487
1807
  }
1488
- var cardKind = (control) => control.type === import_codegen22.ControlType.SECTION_CAROUSEL ? "carousel-element" : "card-element";
1808
+ var cardKind = (control) => control.type === import_codegen26.ControlType.SECTION_CAROUSEL ? "carousel-element" : "card-element";
1489
1809
  function controlMapLinks(fromScreenId, map) {
1490
1810
  const links = [];
1491
1811
  Object.values(map).forEach((control) => {
@@ -1507,7 +1827,7 @@ function controlMapLinks(fromScreenId, map) {
1507
1827
  });
1508
1828
  }
1509
1829
  Object.keys(control.outputOpens ?? {}).forEach((output) => {
1510
- const screenId = (0, import_codegen22.outputOpenOf)(control.outputOpens, output)?.screenId;
1830
+ const screenId = (0, import_codegen26.outputOpenOf)(control.outputOpens, output)?.screenId;
1511
1831
  if (!screenId) return;
1512
1832
  links.push({
1513
1833
  kind: "output-open",
@@ -1613,7 +1933,7 @@ var closeOverlayOffOverlay = defineInvariant({
1613
1933
  const closing = screens.map((screen) => ({
1614
1934
  screen,
1615
1935
  controls: Object.values(screenControlMaps[screen.id] ?? {}).filter(
1616
- import_codegen23.controlUsesOverlayRef
1936
+ import_codegen27.controlUsesOverlayRef
1617
1937
  )
1618
1938
  })).filter(({ controls }) => controls.length);
1619
1939
  if (!closing.length) return [];
@@ -1636,7 +1956,7 @@ var closeOverlayOffOverlay = defineInvariant({
1636
1956
  });
1637
1957
 
1638
1958
  // apps/m-one-ui/src/app/pages/design/lib/invariants/outcome-unattended-call.ts
1639
- var import_codegen24 = require("./index.js");
1959
+ var import_codegen28 = require("./index.js");
1640
1960
  var outcomeUnattendedCall = defineInvariant({
1641
1961
  name: "outcome-on-unattended-call",
1642
1962
  message: "invariant-outcome-unattended",
@@ -1648,7 +1968,7 @@ var outcomeUnattendedCall = defineInvariant({
1648
1968
  validate: ({ features, screens, screenControlMaps }) => {
1649
1969
  const featureScreen = (featureId) => screens.find((screen) => screen.featureId === featureId)?.id ?? "";
1650
1970
  return Object.values(features).flatMap((feature) => {
1651
- const armed = (0, import_codegen24.methodArms)(
1971
+ const armed = (0, import_codegen28.methodArms)(
1652
1972
  screens.filter((screen) => screen.featureId === feature.id).map((screen) => screenControlMaps[screen.id] ?? {})
1653
1973
  );
1654
1974
  const wired = new Set(Object.keys(armed));
@@ -1684,21 +2004,21 @@ var outcomeUnattendedCall = defineInvariant({
1684
2004
  });
1685
2005
 
1686
2006
  // apps/m-one-ui/src/app/pages/design/lib/invariants/outcome-call-nested.ts
1687
- var import_codegen25 = require("./index.js");
2007
+ var import_codegen29 = require("./index.js");
1688
2008
  var outcomeCallNested = defineInvariant({
1689
2009
  name: "outcome-call-nested",
1690
2010
  message: "invariant-outcome-call-nested",
1691
2011
  severity: "advisory",
1692
2012
  deps: ["screens", "screenControlMaps"],
1693
2013
  validate: ({ screens, screenControlMaps }) => screens.flatMap((screen) => {
1694
- const onScreen = (outcomes) => outcomes.flatMap(import_codegen25.nestedOutcomeCalls).map((id) => ({
2014
+ const onScreen = (outcomes) => outcomes.flatMap(import_codegen29.nestedOutcomeCalls).map((id) => ({
1695
2015
  subject: `${screen.name} \u2192 ${id}`,
1696
2016
  target: { kind: "screen", screenId: screen.id }
1697
2017
  }));
1698
2018
  const onControls = Object.values(
1699
2019
  screenControlMaps[screen.id] ?? {}
1700
2020
  ).flatMap(
1701
- (control) => Object.values(control.outputOutcomes ?? {}).flatMap(import_codegen25.nestedOutcomeCalls).map((id) => ({
2021
+ (control) => Object.values(control.outputOutcomes ?? {}).flatMap(import_codegen29.nestedOutcomeCalls).map((id) => ({
1702
2022
  subject: `${screen.name} \u2192 ${control.id} \u2192 ${id}`,
1703
2023
  target: {
1704
2024
  kind: "control",
@@ -1753,7 +2073,7 @@ var reactionWritesOwnWatch = defineInvariant({
1753
2073
  });
1754
2074
 
1755
2075
  // apps/m-one-ui/src/app/pages/design/lib/invariants/outcome-nav-complete.ts
1756
- var import_codegen26 = require("./index.js");
2076
+ var import_codegen30 = require("./index.js");
1757
2077
  var outcomeNavComplete = defineInvariant({
1758
2078
  name: "outcome-nav-complete",
1759
2079
  message: "invariant-outcome-nav-incomplete",
@@ -1763,10 +2083,10 @@ var outcomeNavComplete = defineInvariant({
1763
2083
  const controlMap = screenControlMaps[screen.id] ?? {};
1764
2084
  return Object.values(controlMap).flatMap((control) => {
1765
2085
  const broken = Object.values(control.outputOutcomes ?? {}).some(
1766
- (outcome) => import_codegen26.OUTCOME_ARMS.some(
1767
- (arm) => !!(0, import_codegen26.validateOutcomeNav)(outcome?.[arm]?.nav, navMap)
2086
+ (outcome) => import_codegen30.OUTCOME_ARMS.some(
2087
+ (arm) => !!(0, import_codegen30.validateOutcomeNav)(outcome?.[arm]?.nav, navMap)
1768
2088
  )
1769
- ) || (0, import_codegen26.controlNavReferences)(control).some(
2089
+ ) || (0, import_codegen30.controlNavReferences)(control).some(
1770
2090
  (row) => row.some((navId) => !navMap[navId])
1771
2091
  );
1772
2092
  if (!broken) return [];
@@ -1785,7 +2105,7 @@ var outcomeNavComplete = defineInvariant({
1785
2105
  });
1786
2106
 
1787
2107
  // apps/m-one-ui/src/app/pages/design/lib/invariants/field-check-bound.ts
1788
- var import_codegen27 = require("./index.js");
2108
+ var import_codegen31 = require("./index.js");
1789
2109
  var fieldCheckBound = defineInvariant({
1790
2110
  name: "field-check-bound",
1791
2111
  message: "invariant-field-check-unbound",
@@ -1799,9 +2119,9 @@ var unboundChecks = perScreen(
1799
2119
  features,
1800
2120
  functions
1801
2121
  }) => {
1802
- const feature = (0, import_codegen27.isFeatureScreen)(screen) ? features[screen.featureId] : void 0;
2122
+ const feature = (0, import_codegen31.isFeatureScreen)(screen) ? features[screen.featureId] : void 0;
1803
2123
  const properties = feature?.properties ?? {};
1804
- const sources = (0, import_codegen27.limitSources)({
2124
+ const sources = (0, import_codegen31.limitSources)({
1805
2125
  inputs: screen.inputs,
1806
2126
  constants: screen.constants,
1807
2127
  variables: screen.variables,
@@ -1811,13 +2131,13 @@ var unboundChecks = perScreen(
1811
2131
  functions: { ...functions, ...feature?.functions ?? {} }
1812
2132
  });
1813
2133
  return Object.entries(controlMap).flatMap(([controlId, control]) => {
1814
- if (control.type !== import_codegen27.ControlType.FIELD) return [];
1815
- const checks = (0, import_codegen27.fieldChecks)(control);
2134
+ if (control.type !== import_codegen31.ControlType.FIELD) return [];
2135
+ const checks = (0, import_codegen31.fieldChecks)(control);
1816
2136
  if (!checks.length) return [];
1817
- const formId = (0, import_codegen27.owningFormId)(controlId, controlMap);
2137
+ const formId = (0, import_codegen31.owningFormId)(controlId, controlMap);
1818
2138
  const broken = checks.some((check) => {
1819
- if ((0, import_codegen27.checkKind)(check) !== "function") {
1820
- return !(0, import_codegen27.isCheckComplete)(
2139
+ if ((0, import_codegen31.checkKind)(check) !== "function") {
2140
+ return !(0, import_codegen31.isCheckComplete)(
1821
2141
  check,
1822
2142
  functions,
1823
2143
  controlMap,
@@ -1827,15 +2147,15 @@ var unboundChecks = perScreen(
1827
2147
  }
1828
2148
  const fn = functions[check.functionId];
1829
2149
  if (!fn) return true;
1830
- if (!(0, import_codegen27.isFieldCheckEligible)(fn)) return true;
1831
- const writtenFor = (0, import_codegen27.fieldCheckFormId)(fn);
2150
+ if (!(0, import_codegen31.isFieldCheckEligible)(fn)) return true;
2151
+ const writtenFor = (0, import_codegen31.fieldCheckFormId)(fn);
1832
2152
  if (writtenFor && writtenFor !== formId) return true;
1833
- return !(0, import_codegen27.isCheckComplete)(check, functions, controlMap, properties);
2153
+ return !(0, import_codegen31.isCheckComplete)(check, functions, controlMap, properties);
1834
2154
  });
1835
2155
  if (!broken) return [];
1836
2156
  return [
1837
2157
  {
1838
- subject: (0, import_codegen27.resolveFieldName)({
2158
+ subject: (0, import_codegen31.resolveFieldName)({
1839
2159
  id: controlId,
1840
2160
  configs: control.configs
1841
2161
  }),
@@ -1851,7 +2171,7 @@ var unboundChecks = perScreen(
1851
2171
  );
1852
2172
 
1853
2173
  // apps/m-one-ui/src/app/pages/design/lib/invariants/function-case-args.ts
1854
- var import_codegen28 = require("./index.js");
2174
+ var import_codegen32 = require("./index.js");
1855
2175
  var functionCaseArgs = defineInvariant({
1856
2176
  name: "function-case-args",
1857
2177
  message: "invariant-function-case-args",
@@ -1860,20 +2180,20 @@ var functionCaseArgs = defineInvariant({
1860
2180
  validate: ({ features, functions, sharedShapes }) => {
1861
2181
  const shared = sharedShapes ?? {};
1862
2182
  return [
1863
- ...(0, import_codegen28.listFunctions)(functions).map((fn) => ({
2183
+ ...(0, import_codegen32.listFunctions)(functions).map((fn) => ({
1864
2184
  fn,
1865
2185
  featureId: void 0,
1866
- shapes: (0, import_codegen28.shapesInReach)(void 0, shared)
2186
+ shapes: (0, import_codegen32.shapesInReach)(void 0, shared)
1867
2187
  })),
1868
2188
  ...Object.values(features).flatMap(
1869
- (feature) => (0, import_codegen28.listFunctions)(feature.functions).map((fn) => ({
2189
+ (feature) => (0, import_codegen32.listFunctions)(feature.functions).map((fn) => ({
1870
2190
  fn,
1871
2191
  featureId: feature.id,
1872
- shapes: (0, import_codegen28.shapesInReach)(feature, shared)
2192
+ shapes: (0, import_codegen32.shapesInReach)(feature, shared)
1873
2193
  }))
1874
2194
  )
1875
- ].filter(({ fn, shapes }) => (0, import_codegen28.staleCases)(fn, shapes).length > 0).map(({ fn, featureId, shapes }) => ({
1876
- subject: `${fn.name}: ${(0, import_codegen28.staleCases)(fn, shapes).map((entry) => entry.name).join(", ")}`,
2195
+ ].filter(({ fn, shapes }) => (0, import_codegen32.staleCases)(fn, shapes).length > 0).map(({ fn, featureId, shapes }) => ({
2196
+ subject: `${fn.name}: ${(0, import_codegen32.staleCases)(fn, shapes).map((entry) => entry.name).join(", ")}`,
1877
2197
  target: {
1878
2198
  kind: "function",
1879
2199
  ...featureId ? { featureId } : {},
@@ -1883,8 +2203,42 @@ var functionCaseArgs = defineInvariant({
1883
2203
  }
1884
2204
  });
1885
2205
 
2206
+ // apps/m-one-ui/src/app/pages/design/lib/invariants/outcome-transform-self-fold.ts
2207
+ var import_codegen33 = require("./index.js");
2208
+ var outcomeTransformSelfFold = defineInvariant({
2209
+ name: "outcome-transform-self-fold",
2210
+ message: "invariant-outcome-transform-self-fold",
2211
+ severity: "advisory",
2212
+ deps: ["features"],
2213
+ validate: ({ features }) => Object.values(features).flatMap(
2214
+ (feature) => (0, import_codegen33.storesOf)(feature).flatMap((store) => {
2215
+ const methods = Object.values(store.methods ?? {});
2216
+ const landings = methods.flatMap(
2217
+ (method) => (method.response ?? []).map((mapping) => ({ method, mapping }))
2218
+ );
2219
+ const readsItself = ({ mapping }) => !!mapping.transform?.args.some(
2220
+ (arg) => arg.source === "state" && arg.path[0] === mapping.propertyId
2221
+ );
2222
+ return landings.filter((landing) => readsItself(landing)).filter(({ mapping }) => store.properties[mapping.propertyId]?.cardinality === "one").filter(
2223
+ ({ mapping }) => !landings.some(
2224
+ (other) => other.mapping.propertyId === mapping.propertyId && !readsItself(other)
2225
+ )
2226
+ ).map(({ method, mapping }) => ({
2227
+ subject: `${feature.name}.${method.name} \u2192 ${store.properties[mapping.propertyId].name}`,
2228
+ target: {
2229
+ kind: "panel",
2230
+ panel: "store",
2231
+ featureId: feature.id,
2232
+ ...store.owner.kind === "sub" ? { subStoreId: store.owner.subStoreId } : {},
2233
+ memberId: method.id
2234
+ }
2235
+ }));
2236
+ })
2237
+ )
2238
+ });
2239
+
1886
2240
  // apps/m-one-ui/src/app/pages/design/lib/invariants/filter-group-squeeze-orphan.ts
1887
- var import_codegen29 = require("./index.js");
2241
+ var import_codegen34 = require("./index.js");
1888
2242
  var orphanIds = (groupId, controlMap) => {
1889
2243
  const found = [];
1890
2244
  const seen = /* @__PURE__ */ new Set();
@@ -1894,8 +2248,8 @@ var orphanIds = (groupId, controlMap) => {
1894
2248
  for (const childId of controlMap[id]?.childrens ?? []) {
1895
2249
  const child = controlMap[childId];
1896
2250
  if (!child) continue;
1897
- if (child.type === import_codegen29.ControlType.SECTION_FILTER) continue;
1898
- if (child.type === import_codegen29.ControlType.COL) {
2251
+ if (child.type === import_codegen34.ControlType.SECTION_FILTER) continue;
2252
+ if (child.type === import_codegen34.ControlType.COL) {
1899
2253
  walk(childId);
1900
2254
  continue;
1901
2255
  }
@@ -1915,12 +2269,12 @@ var filterGroupSqueezeOrphan = defineInvariant({
1915
2269
  });
1916
2270
  var squeezedOrphans = perScreen(
1917
2271
  (controlMap, screen) => Object.entries(controlMap).flatMap(([groupId, control]) => {
1918
- if (control.type !== import_codegen29.ControlType.SECTION_FILTER_GROUP) return [];
2272
+ if (control.type !== import_codegen34.ControlType.SECTION_FILTER_GROUP) return [];
1919
2273
  const parentId = control.parentId;
1920
- const squeezed = !!control.configs?.["squeeze"] || !!parentId && controlMap[parentId]?.type === import_codegen29.ControlType.SECTION_HEADER;
2274
+ const squeezed = !!control.configs?.["squeeze"] || !!parentId && controlMap[parentId]?.type === import_codegen34.ControlType.SECTION_HEADER;
1921
2275
  if (!squeezed) return [];
1922
2276
  return orphanIds(groupId, controlMap).map((orphanId) => ({
1923
- subject: import_codegen29.CONTROL_LABEL[controlMap[orphanId].type],
2277
+ subject: import_codegen34.CONTROL_LABEL[controlMap[orphanId].type],
1924
2278
  target: {
1925
2279
  kind: "control",
1926
2280
  screenId: screen.id,
@@ -1931,7 +2285,7 @@ var squeezedOrphans = perScreen(
1931
2285
  );
1932
2286
 
1933
2287
  // apps/m-one-ui/src/app/pages/design/lib/invariants/context-group-primary-unique.ts
1934
- var import_codegen30 = require("./index.js");
2288
+ var import_codegen35 = require("./index.js");
1935
2289
  var contextGroupPrimaryUnique = defineInvariant({
1936
2290
  name: "context-group-primary-unique",
1937
2291
  message: "invariant-context-group-primary-unique",
@@ -1942,14 +2296,14 @@ var contextGroupPrimaryUnique = defineInvariant({
1942
2296
  });
1943
2297
  var duplicatePrimaries = perScreen(
1944
2298
  (controlMap, screen) => Object.entries(controlMap).flatMap(([groupId, control]) => {
1945
- if (control.type !== import_codegen30.ControlType.SECTION_BUTTON_GROUP) return [];
2299
+ if (control.type !== import_codegen35.ControlType.SECTION_BUTTON_GROUP) return [];
1946
2300
  if (control.configs?.["variant"] !== "context") return [];
1947
2301
  const primaries = (control.childrens ?? []).filter((childId) => {
1948
2302
  const child = controlMap[childId];
1949
- return child?.type === import_codegen30.ControlType.BUTTON && child.configs?.["variant"] === "primary";
2303
+ return child?.type === import_codegen35.ControlType.BUTTON && child.configs?.["variant"] === "primary";
1950
2304
  });
1951
2305
  return primaries.slice(1).map((buttonId) => ({
1952
- subject: import_codegen30.CONTROL_LABEL[import_codegen30.ControlType.BUTTON],
2306
+ subject: import_codegen35.CONTROL_LABEL[import_codegen35.ControlType.BUTTON],
1953
2307
  target: {
1954
2308
  kind: "control",
1955
2309
  screenId: screen.id,
@@ -1960,77 +2314,143 @@ var duplicatePrimaries = perScreen(
1960
2314
  );
1961
2315
 
1962
2316
  // apps/m-one-ui/src/app/pages/design/lib/hand-binding-helper.ts
1963
- var import_codegen32 = require("./index.js");
2317
+ var import_codegen37 = require("./index.js");
1964
2318
 
1965
2319
  // apps/m-one-ui/src/app/pages/design/lib/control-outputs.ts
1966
- var import_codegen31 = require("./index.js");
2320
+ var import_codegen36 = require("./index.js");
2321
+ var embeddedOutputsOf = (screens, contractOf = () => void 0) => (control) => {
2322
+ if (control.type !== import_codegen36.ControlType.SCREEN) return void 0;
2323
+ if (control.handRef) {
2324
+ const contract = contractOf(control.handRef);
2325
+ return contract ? (0, import_codegen36.handTargetOf)(contract).outputs : void 0;
2326
+ }
2327
+ return screens.find((screen) => screen.id === control.screenId)?.outputs;
2328
+ };
2329
+ var embeddedOutputOf = (control, key, embedded) => embedded?.(control)?.[(0, import_codegen36.outputArmBaseKey)(key)];
2330
+ var outputPayloadShape = (control, key, embedded) => control.type === import_codegen36.ControlType.SCREEN ? embeddedOutputOf(control, key, embedded)?.payload?.dataType ?? "void" : (0, import_codegen36.payloadShape)(key, control.type, control.configs);
2331
+ var outputCallLabelOf = (control, key, embedded) => {
2332
+ const label2 = (0, import_codegen36.outputCallLabel)(control, key);
2333
+ const name = embeddedOutputOf(control, key, embedded)?.name;
2334
+ const base = (0, import_codegen36.outputArmBaseKey)(key);
2335
+ return name && label2.startsWith(base) ? `${name}${label2.slice(base.length)}` : label2;
2336
+ };
1967
2337
  var CONTROL_OUTPUTS = {
1968
- [import_codegen31.ControlType.BUTTON]: ["clicked"],
1969
- [import_codegen31.ControlType.CONTEXT_MENU]: ["action"],
2338
+ [import_codegen36.ControlType.BUTTON]: ["clicked"],
2339
+ [import_codegen36.ControlType.CONTEXT_MENU]: ["action"],
1970
2340
  // The picker's own value, once the User has moved it — the write half of the
1971
2341
  // controlled binding, drawn as a StateWrite rather than as `[(audience)]`
1972
2342
  // (ADR 0187, ADR 0065). Offered whatever the two halves hold: a picker bound
1973
2343
  // to no `audience` still edits its own value and still fires this.
1974
- [import_codegen31.ControlType.AUDIENCE_PICKER]: ["audienceChange"],
1975
- [import_codegen31.ControlType.CARD]: ["clicked"],
2344
+ [import_codegen36.ControlType.AUDIENCE_PICKER]: ["audienceChange"],
2345
+ [import_codegen36.ControlType.CARD]: ["clicked"],
1976
2346
  // `submitted` is offered only under a Button declaring `isSubmit` — see
1977
2347
  // `outputsOf` below.
1978
- [import_codegen31.ControlType.FORM]: ["submitted", "dataChange", "formInitialized"],
2348
+ [import_codegen36.ControlType.FORM]: ["submitted", "dataChange", "formInitialized"],
1979
2349
  // The Field's own `dataChange`, at field granularity — the value the User
1980
2350
  // typed into this one field, not the form's record (libs/one ADR 0032).
1981
2351
  // Needs no Button, the way the form's does not (see `outputsOf`).
1982
- [import_codegen31.ControlType.FIELD]: ["dataChange"],
1983
- [import_codegen31.ControlType.SECTION]: ["inView"],
1984
- [import_codegen31.ControlType.SECTION_HEADER]: ["actionClick", "action", "back"],
2352
+ [import_codegen36.ControlType.FIELD]: ["dataChange"],
2353
+ [import_codegen36.ControlType.SECTION]: ["inView"],
2354
+ [import_codegen36.ControlType.SECTION_HEADER]: ["actionClick", "action", "back"],
1985
2355
  // Debounced already by the component — what arrives here is the term the User
1986
2356
  // stopped typing, which is the only thing worth binding a call to.
1987
- [import_codegen31.ControlType.SECTION_SEARCH]: ["searchChange"],
2357
+ [import_codegen36.ControlType.SECTION_SEARCH]: ["searchChange"],
1988
2358
  // One output for the whole bar, carrying the Button that was pressed — an
1989
2359
  // `m-action` names its Buttons rather than holding them, so there is no
1990
2360
  // per-Button Control for a binding to sit on (ADR 0009).
1991
- [import_codegen31.ControlType.SECTION_ACTION]: ["clicked"],
2361
+ [import_codegen36.ControlType.SECTION_ACTION]: ["clicked"],
1992
2362
  // Which slide is showing, every time it changes — by drag, by indicator, or
1993
2363
  // by the clock. Two spellings of the one event, because what a caller binds
1994
2364
  // differs: `slideChange` carries the position, `itemChange` the row behind it,
1995
2365
  // which is what a call needing the slide's own data takes.
1996
- [import_codegen31.ControlType.SECTION_CAROUSEL]: ["slideChange", "itemChange"],
2366
+ [import_codegen36.ControlType.SECTION_CAROUSEL]: ["slideChange", "itemChange"],
1997
2367
  // The whole group's selection, every time any Filter beneath it changes
1998
2368
  // (libs/one ADR 0025). Per-change rather than on-close: a group has no single
1999
2369
  // close event full-width, and `switchMap` in the emitted store already drops
2000
2370
  // the responses of calls a later change supersedes.
2001
- [import_codegen31.ControlType.SECTION_FILTER_GROUP]: ["filterChange"],
2371
+ [import_codegen36.ControlType.SECTION_FILTER_GROUP]: ["filterChange"],
2002
2372
  // Offered only outside a group — see `outputsOf` below.
2003
- [import_codegen31.ControlType.SECTION_FILTER]: ["filterChange"],
2373
+ [import_codegen36.ControlType.SECTION_FILTER]: ["filterChange"],
2004
2374
  // One payload, `{offset, perPage}`, and both members are pickable — a
2005
2375
  // CallArgMapping reading `event.offset` gets a number, which is what an
2006
2376
  // ApiOperation's query param takes. The whole `$event` works too, unlike a
2007
2377
  // FilterGroup's list of pairs (ADR 0097).
2008
- [import_codegen31.ControlType.SECTION_PAGINATION]: ["paginationChange"],
2378
+ [import_codegen36.ControlType.SECTION_PAGINATION]: ["paginationChange"],
2009
2379
  // `{id, direction}`, after the rows were reordered in place — bound when the
2010
2380
  // table holds one page of a longer list and whoever fetches has to sort the
2011
2381
  // rest (ADR 0148). `tableInitialized` fires once, after the first render —
2012
2382
  // no payload, the Form's `formInitialized` for a table.
2013
- [import_codegen31.ControlType.SECTION_TABLE]: ["sortChange", "tableInitialized"],
2383
+ [import_codegen36.ControlType.SECTION_TABLE]: ["sortChange", "tableInitialized"],
2014
2384
  // Repeated rows emit their Repeat item; static rows emit `undefined`.
2015
- [import_codegen31.ControlType.SECTION_TABLE_ROW]: ["rowClick"],
2385
+ [import_codegen36.ControlType.SECTION_TABLE_ROW]: ["rowClick"],
2016
2386
  // The preset picked, and the window it drew as `{from, to}` ISO text — both
2017
2387
  // members pickable, each a date an ApiOperation's param takes. Fired when the
2018
2388
  // reader picks a preset or lets go of the navigator, never because an input
2019
2389
  // moved, so a fetch bound here cannot loop (libs/one GLOSSARY.md
2020
2390
  // SectionChart, the SectionPagination rule of ADR 0097).
2021
- [import_codegen31.ControlType.SECTION_CHART]: ["rangeChange", "windowChange"],
2391
+ [import_codegen36.ControlType.SECTION_CHART]: ["rangeChange", "windowChange"],
2022
2392
  // Offered under the `link` variant alone — see `outputsOf` below.
2023
- [import_codegen31.ControlType.TEXT_OUTPUT]: ["clicked"]
2393
+ [import_codegen36.ControlType.TEXT_OUTPUT]: ["clicked"]
2024
2394
  };
2395
+ function outputsOf(control, controlMap, embedded) {
2396
+ if (control.type === import_codegen36.ControlType.SCREEN) {
2397
+ return (0, import_codegen36.listScreenOutputs)(embedded?.(control)).map((output) => output.id);
2398
+ }
2399
+ if (control.type === import_codegen36.ControlType.PLUGIN) {
2400
+ return (0, import_codegen36.pluginNamesOf)(control.configs, import_codegen36.PLUGIN_OUTPUTS_KEY);
2401
+ }
2402
+ const offered = CONTROL_OUTPUTS[control.type] ?? [];
2403
+ if (control.type === import_codegen36.ControlType.FORM) {
2404
+ return controlMap && !hasSubmitButton(control, controlMap) && !(control.id && (0, import_codegen36.hasSubmitTargetButton)(control.id, controlMap)) ? offered.filter((output) => output !== "submitted") : offered;
2405
+ }
2406
+ if (control.type === import_codegen36.ControlType.SECTION_FILTER) {
2407
+ return controlMap && insideFilterGroup(control, controlMap) ? [] : offered;
2408
+ }
2409
+ if (control.type !== import_codegen36.ControlType.TEXT_OUTPUT) return offered;
2410
+ const variant = control.configs?.["variant"];
2411
+ const isLink = variant === "link" || variant === "link-small";
2412
+ return isLink && !(0, import_codegen36.hasRouterLinkDirective)(control) ? offered : [];
2413
+ }
2414
+ function hasSubmitButton(control, controlMap) {
2415
+ const queue = [...control.childrens ?? []];
2416
+ const seen = /* @__PURE__ */ new Set();
2417
+ while (queue.length) {
2418
+ const id = queue.shift();
2419
+ if (!id || seen.has(id)) continue;
2420
+ seen.add(id);
2421
+ const child = controlMap[id];
2422
+ if (!child || child.type === import_codegen36.ControlType.FORM) continue;
2423
+ if (child.type === import_codegen36.ControlType.BUTTON && child.configs?.["isSubmit"] === true)
2424
+ return true;
2425
+ queue.push(...child.childrens ?? []);
2426
+ }
2427
+ return false;
2428
+ }
2429
+ function insideFilterGroup(control, controlMap) {
2430
+ const seen = /* @__PURE__ */ new Set();
2431
+ let current = control.parentId ? controlMap[control.parentId] : void 0;
2432
+ while (current && !seen.has(current.id)) {
2433
+ if (current.type === import_codegen36.ControlType.SECTION_FILTER_GROUP) return true;
2434
+ seen.add(current.id);
2435
+ current = current.parentId ? controlMap[current.parentId] : void 0;
2436
+ }
2437
+ return false;
2438
+ }
2439
+ function offersOutputKey(control, controlMap, key, embedded) {
2440
+ if ((0, import_codegen36.hasRouterLink)(control.directives?.["routerLink"]?.configs)) return false;
2441
+ const base = (0, import_codegen36.outputArmBaseKey)(key);
2442
+ const output = (0, import_codegen36.isMenuActionKey)(base) ? import_codegen36.MENU_ACTION_OUTPUT : base;
2443
+ return outputsOf(control, controlMap, embedded).includes(output);
2444
+ }
2025
2445
  var OUTPUT_MAP_FIELDS = [
2026
- ...import_codegen31.OUTPUT_GROUP_MAPS,
2446
+ ...import_codegen36.OUTPUT_GROUP_MAPS,
2027
2447
  "outputCalls",
2028
2448
  "outputArms"
2029
2449
  ];
2030
2450
  var wiredOutputKeys = (control) => [
2031
2451
  ...new Set(
2032
2452
  OUTPUT_MAP_FIELDS.flatMap(
2033
- (field) => Object.keys(control[field] ?? {}).map(import_codegen31.outputArmBaseKey)
2453
+ (field) => Object.keys(control[field] ?? {}).map(import_codegen36.outputArmBaseKey)
2034
2454
  )
2035
2455
  )
2036
2456
  ];
@@ -2040,7 +2460,7 @@ var CLEARED_OUTPUT_WIRING = Object.fromEntries(
2040
2460
 
2041
2461
  // apps/m-one-ui/src/app/pages/design/lib/hand-binding-helper.ts
2042
2462
  var handControls = (controlMap) => Object.values(controlMap).filter(
2043
- (control) => control.type === import_codegen32.ControlType.SCREEN && !!control.handRef
2463
+ (control) => control.type === import_codegen37.ControlType.SCREEN && !!control.handRef
2044
2464
  );
2045
2465
  var unmountableReason = (handRef, hand) => {
2046
2466
  const contract = hand.contracts[handRef];
@@ -2050,7 +2470,7 @@ var unmountableReason = (handRef, hand) => {
2050
2470
  );
2051
2471
  return skipped ? skipped.reason : "gone";
2052
2472
  }
2053
- const blockers = (0, import_codegen32.mountBlockers)(contract);
2473
+ const blockers = (0, import_codegen37.mountBlockers)(contract);
2054
2474
  return blockers.length ? `required: ${blockers.join(", ")}` : void 0;
2055
2475
  };
2056
2476
  var memberOf = (screen, binding) => {
@@ -2121,7 +2541,7 @@ var unboundRequiredInputs = (control, contract) => {
2121
2541
  };
2122
2542
  var mountedContract = (control, hand) => {
2123
2543
  const contract = control.handRef ? hand.contracts[control.handRef] : void 0;
2124
- return contract && (0, import_codegen32.isMountable)(contract) ? contract : void 0;
2544
+ return contract && (0, import_codegen37.isMountable)(contract) ? contract : void 0;
2125
2545
  };
2126
2546
 
2127
2547
  // apps/m-one-ui/src/app/pages/design/lib/invariants/hand-binding-resolves.ts
@@ -2210,7 +2630,7 @@ var handScreenResolves = defineInvariant({
2210
2630
  });
2211
2631
 
2212
2632
  // apps/m-one-ui/src/app/pages/design/lib/invariants/reserved-variant-name-free.ts
2213
- var import_codegen33 = require("./index.js");
2633
+ var import_codegen38 = require("./index.js");
2214
2634
  var reservedVariantNameFree = defineInvariant({
2215
2635
  name: "reserved-variant-name-free",
2216
2636
  message: "invariant-reserved-variant-name",
@@ -2222,7 +2642,7 @@ var reservedVariantNameFree = defineInvariant({
2222
2642
  const held = [
2223
2643
  ...Object.values(feature.properties).map((property) => property.name),
2224
2644
  ...Object.values(feature.variants).map((variant) => variant.name)
2225
- ].filter(import_codegen33.isReservedVariantName);
2645
+ ].filter(import_codegen38.isReservedVariantName);
2226
2646
  return held.length ? [
2227
2647
  {
2228
2648
  subject: `${feature.name}.${held[0]}`,
@@ -2239,7 +2659,7 @@ var reservedVariantNameFree = defineInvariant({
2239
2659
  ...Object.values(screen.outputs ?? {}),
2240
2660
  ...Object.values(screen.constants ?? {}),
2241
2661
  ...Object.values(screen.computeds ?? {})
2242
- ].map((member) => member.name).filter(import_codegen33.isReservedVariantName);
2662
+ ].map((member) => member.name).filter(import_codegen38.isReservedVariantName);
2243
2663
  return held.length ? [
2244
2664
  {
2245
2665
  subject: `${screen.name}.${held[0]}`,
@@ -2252,13 +2672,13 @@ var reservedVariantNameFree = defineInvariant({
2252
2672
  });
2253
2673
 
2254
2674
  // apps/m-one-ui/src/app/pages/design/lib/invariants/feature-name-free.ts
2255
- var import_codegen34 = require("./index.js");
2675
+ var import_codegen39 = require("./index.js");
2256
2676
  var featureNameFree = defineInvariant({
2257
2677
  name: "feature-name-free",
2258
2678
  message: "invariant-feature-name-reserved",
2259
2679
  severity: "advisory",
2260
2680
  deps: ["features", "screens"],
2261
- validate: ({ features, screens }) => Object.values(features).filter((feature) => (0, import_codegen34.isReservedFeatureName)(feature.name)).map((feature) => ({
2681
+ validate: ({ features, screens }) => Object.values(features).filter((feature) => (0, import_codegen39.isReservedFeatureName)(feature.name)).map((feature) => ({
2262
2682
  subject: feature.name,
2263
2683
  target: {
2264
2684
  kind: "screen",
@@ -2268,25 +2688,25 @@ var featureNameFree = defineInvariant({
2268
2688
  });
2269
2689
 
2270
2690
  // apps/m-one-ui/src/app/pages/design/lib/compare-register.ts
2271
- var import_codegen38 = require("./index.js");
2691
+ var import_codegen43 = require("./index.js");
2272
2692
 
2273
2693
  // apps/m-one-ui/src/app/pages/design/lib/code-tree.ts
2274
- var import_codegen35 = require("./index.js");
2694
+ var import_codegen40 = require("./index.js");
2275
2695
  var CODE_AREA_ROOTS = [
2276
- ["pages", `${import_codegen35.PAGES_ROOT}/`],
2277
- ["features", `${import_codegen35.FEATURES_ROOT}/`],
2278
- ["widgets", `${import_codegen35.WIDGETS_ROOT}/`],
2696
+ ["pages", `${import_codegen40.PAGES_ROOT}/`],
2697
+ ["features", `${import_codegen40.FEATURES_ROOT}/`],
2698
+ ["widgets", `${import_codegen40.WIDGETS_ROOT}/`],
2279
2699
  ["shared", "src/app/shared/"],
2280
2700
  ["mag_assets", "mag_assets/"],
2281
2701
  ["magmonium", ".magmonium/"]
2282
2702
  ];
2283
2703
 
2284
2704
  // apps/m-one-ui/src/app/pages/design/lib/function-register.ts
2285
- var import_codegen36 = require("./index.js");
2705
+ var import_codegen41 = require("./index.js");
2286
2706
  var everyFunction = (appFunctions, features) => [
2287
- ...(0, import_codegen36.listFunctions)(appFunctions).map((fn) => ({ fn })),
2288
- ...(0, import_codegen36.listFeatures)(features).flatMap(
2289
- (feature) => (0, import_codegen36.listFunctions)(feature.functions).map((fn) => ({
2707
+ ...(0, import_codegen41.listFunctions)(appFunctions).map((fn) => ({ fn })),
2708
+ ...(0, import_codegen41.listFeatures)(features).flatMap(
2709
+ (feature) => (0, import_codegen41.listFunctions)(feature.functions).map((fn) => ({
2290
2710
  fn,
2291
2711
  featureId: feature.id
2292
2712
  }))
@@ -2301,14 +2721,14 @@ var canonical = (value) => {
2301
2721
  };
2302
2722
 
2303
2723
  // apps/m-one-ui/src/app/pages/design/lib/shape-register.ts
2304
- var import_codegen37 = require("./index.js");
2724
+ var import_codegen42 = require("./index.js");
2305
2725
 
2306
2726
  // apps/m-one-ui/src/app/pages/design/lib/compare-register.ts
2307
- var import_codegen39 = require("./index.js");
2727
+ var import_codegen44 = require("./index.js");
2308
2728
  var everyShape = (features, sharedShapes = {}) => [
2309
- ...(0, import_codegen38.listShapes)(sharedShapes).map((shape) => ({ shape })),
2310
- ...(0, import_codegen38.listFeatures)(features).flatMap(
2311
- (feature) => (0, import_codegen38.listShapes)(feature.shapes).filter((shape) => !(0, import_codegen38.isSharedShapeId)(shape.id)).map((shape) => ({ shape, featureId: feature.id }))
2729
+ ...(0, import_codegen43.listShapes)(sharedShapes).map((shape) => ({ shape })),
2730
+ ...(0, import_codegen43.listFeatures)(features).flatMap(
2731
+ (feature) => (0, import_codegen43.listShapes)(feature.shapes).filter((shape) => !(0, import_codegen43.isSharedShapeId)(shape.id)).map((shape) => ({ shape, featureId: feature.id }))
2312
2732
  )
2313
2733
  ];
2314
2734
  var distinctPair = (kind, a, b) => ({ kind, ids: a < b ? [a, b] : [b, a] });
@@ -2394,24 +2814,24 @@ var themeSelectionResolves = defineInvariant({
2394
2814
  });
2395
2815
 
2396
2816
  // apps/m-one-ui/src/app/pages/design/lib/invariants/search-feed-resolves.ts
2397
- var import_codegen40 = require("./index.js");
2817
+ var import_codegen45 = require("./index.js");
2398
2818
  var searchFeedResolves = defineInvariant({
2399
2819
  name: "search-feed-resolves",
2400
2820
  message: "invariant-search-feed-unresolved",
2401
2821
  severity: "advisory",
2402
2822
  deps: ["features", "functions"],
2403
2823
  validate: ({ features, functions }) => Object.values(features).flatMap(
2404
- (feature) => (0, import_codegen40.storesOf)(feature).flatMap((store) => {
2824
+ (feature) => (0, import_codegen45.storesOf)(feature).flatMap((store) => {
2405
2825
  const feed = store.searchFeed;
2406
2826
  if (!feed) return [];
2407
2827
  const property = store.properties[feed.propertyId];
2408
2828
  const rows = property?.cardinality === "many" ? property.dataType : void 0;
2409
2829
  if (feed.functionId) {
2410
2830
  const fn = feature.functions?.[feed.functionId] ?? functions[feed.functionId];
2411
- if (fn && (0, import_codegen40.isSearchFeedFunction)(fn, property, feature.shapes) && (0, import_codegen40.searchFeedArgsComplete)(fn, feed.args)) {
2831
+ if (fn && (0, import_codegen45.isSearchFeedFunction)(fn, property, feature.shapes) && (0, import_codegen45.searchFeedArgsComplete)(fn, feed.args)) {
2412
2832
  return [];
2413
2833
  }
2414
- } else if (rows && (0, import_codegen40.resolveSearchFeedMember)(feed.title, rows, feature.shapes)) {
2834
+ } else if (rows && (0, import_codegen45.resolveSearchFeedMember)(feed.title, rows, feature.shapes)) {
2415
2835
  return [];
2416
2836
  }
2417
2837
  return [
@@ -2430,14 +2850,14 @@ var searchFeedResolves = defineInvariant({
2430
2850
  });
2431
2851
 
2432
2852
  // apps/m-one-ui/src/app/pages/design/lib/invariants/search-answer-resolves.ts
2433
- var import_codegen41 = require("./index.js");
2853
+ var import_codegen46 = require("./index.js");
2434
2854
  var searchAnswerResolves = defineInvariant({
2435
2855
  name: "search-answer-resolves",
2436
2856
  message: "invariant-search-answer-unresolved",
2437
2857
  severity: "advisory",
2438
2858
  deps: ["navMap", "screens"],
2439
2859
  validate: ({ navMap, screens }) => {
2440
- const screenId = (0, import_codegen41.searchAnswerScreenId)(navMap);
2860
+ const screenId = (0, import_codegen46.searchAnswerScreenId)(navMap);
2441
2861
  if (!screenId) return [];
2442
2862
  const screen = screens.find((s) => s.id === screenId);
2443
2863
  if (screen && (screen.kind === "app_widget" || screen.kind === "feature")) {
@@ -2446,30 +2866,50 @@ var searchAnswerResolves = defineInvariant({
2446
2866
  return [
2447
2867
  {
2448
2868
  subject: screen?.name ?? screenId,
2449
- target: { kind: "nav", navId: import_codegen41.SEARCH_NAV_ID }
2869
+ target: { kind: "nav", navId: import_codegen46.SEARCH_NAV_ID }
2450
2870
  }
2451
2871
  ];
2452
2872
  }
2453
2873
  });
2454
2874
 
2455
2875
  // apps/m-one-ui/src/app/pages/design/lib/invariants/state-path-resolves.ts
2456
- var import_codegen42 = require("./index.js");
2876
+ var import_codegen47 = require("./index.js");
2457
2877
  var reachOf = (feature, shared) => ({
2458
2878
  properties: Object.assign(
2459
2879
  {},
2460
- ...(0, import_codegen42.storesOf)(feature).map((store) => store.properties)
2880
+ ...(0, import_codegen47.storesOf)(feature).map((store) => store.properties)
2461
2881
  ),
2462
- shapes: (0, import_codegen42.shapesInReach)(feature, shared)
2882
+ shapes: (0, import_codegen47.shapesInReach)(feature, shared)
2463
2883
  });
2464
- function holdsDeadPath(value, reach) {
2884
+ function declaredIds(value, into = /* @__PURE__ */ new Set()) {
2885
+ if (Array.isArray(value)) value.forEach((item) => declaredIds(item, into));
2886
+ else if (value && typeof value === "object") {
2887
+ const id = value.id;
2888
+ if (typeof id === "string") into.add(id);
2889
+ Object.values(value).forEach((item) => declaredIds(item, into));
2890
+ }
2891
+ return into;
2892
+ }
2893
+ var STATE_ROOT_KINDS = /* @__PURE__ */ new Set(["property", "computed"]);
2894
+ var STATE_SOURCES = /* @__PURE__ */ new Set(["state", "path", "store"]);
2895
+ function holdsDeadPath(value, reach, roots, state) {
2465
2896
  if (Array.isArray(value)) {
2466
2897
  if (value.length > 1 && value.every((id) => typeof id === "string") && value[0] in reach.properties && !value.slice(1).some((id) => id in reach.properties)) {
2467
- return !(0, import_codegen42.isPathResolved)(value, reach.properties, reach.shapes);
2898
+ return !(0, import_codegen47.isPathResolved)(value, reach.properties, reach.shapes);
2468
2899
  }
2469
- return value.some((item) => holdsDeadPath(item, reach));
2900
+ return value.some((item) => holdsDeadPath(item, reach, roots, state));
2470
2901
  }
2471
2902
  if (value && typeof value === "object") {
2472
- return Object.values(value).some((item) => holdsDeadPath(item, reach));
2903
+ const record = value;
2904
+ const path = record.path;
2905
+ if (roots && record.root === void 0 && (record.source === void 0 || typeof record.source === "string" && STATE_SOURCES.has(record.source)) && Array.isArray(path) && path.length > 0 && path.every((id) => typeof id === "string") && !roots.has(path[0])) {
2906
+ return true;
2907
+ }
2908
+ const root = record.root;
2909
+ if (state && root && typeof root.kind === "string" && STATE_ROOT_KINDS.has(root.kind) && typeof root.id === "string" && !state.has(root.id)) {
2910
+ return true;
2911
+ }
2912
+ return Object.values(value).some((item) => holdsDeadPath(item, reach, roots, state));
2473
2913
  }
2474
2914
  return false;
2475
2915
  }
@@ -2486,19 +2926,28 @@ var statePathResolves = defineInvariant({
2486
2926
  validate: ({ features, screens, navMap, sharedShapes }) => {
2487
2927
  const found = [];
2488
2928
  const reaches = /* @__PURE__ */ new Map();
2929
+ const state = new Set(
2930
+ Object.values(features).flatMap(
2931
+ (feature) => (0, import_codegen47.storesOf)(feature).flatMap((store) => [
2932
+ ...Object.keys(store.properties ?? {}),
2933
+ ...Object.keys(store.computeds ?? {})
2934
+ ])
2935
+ )
2936
+ );
2937
+ const rootsFor = (holder, extra = []) => /* @__PURE__ */ new Set([...state, ...declaredIds(holder), ...extra]);
2489
2938
  for (const feature of Object.values(features)) {
2490
2939
  const reach = reachOf(feature, sharedShapes);
2491
2940
  reaches.set(feature.id, reach);
2492
2941
  const at = { kind: "panel", panel: "store", featureId: feature.id };
2493
2942
  for (const variant of named(feature.variants)) {
2494
- if (holdsDeadPath(variant.value, reach)) {
2943
+ if (holdsDeadPath(variant.value, reach, rootsFor(variant.value), state)) {
2495
2944
  found.push({
2496
2945
  subject: `${feature.name} \u2192 variant ${variant.name}`,
2497
2946
  target: { ...at, memberId: variant.id }
2498
2947
  });
2499
2948
  }
2500
2949
  }
2501
- for (const store of (0, import_codegen42.storesOf)(feature)) {
2950
+ for (const store of (0, import_codegen47.storesOf)(feature)) {
2502
2951
  const subStoreId = store.subStore?.id;
2503
2952
  const owner = subStoreId ? { ...at, subStoreId } : at;
2504
2953
  const prefix = store.subStore ? `${feature.name} \u2192 ${store.subStore.name}` : feature.name;
@@ -2508,7 +2957,7 @@ var statePathResolves = defineInvariant({
2508
2957
  ["timer", store.timers]
2509
2958
  ]) {
2510
2959
  for (const member of named(members)) {
2511
- if (holdsDeadPath(member.value, reach)) {
2960
+ if (holdsDeadPath(member.value, reach, rootsFor(member.value), state)) {
2512
2961
  found.push({
2513
2962
  subject: `${prefix} \u2192 ${word} ${member.name}`,
2514
2963
  target: { ...owner, memberId: member.id }
@@ -2519,11 +2968,19 @@ var statePathResolves = defineInvariant({
2519
2968
  }
2520
2969
  }
2521
2970
  for (const screen of screens) {
2522
- const reach = (0, import_codegen42.isFeatureScreen)(screen) ? reaches.get(screen.featureId) : void 0;
2971
+ const reach = (0, import_codegen47.isFeatureScreen)(screen) ? reaches.get(screen.featureId) : void 0;
2523
2972
  if (!reach) continue;
2524
2973
  const at = { kind: "screen", screenId: screen.id, panel: "screen" };
2974
+ const own = [
2975
+ ...Object.keys(screen.inputs ?? {}),
2976
+ ...Object.keys(screen.computeds ?? {}),
2977
+ ...Object.keys(screen.constants ?? {}),
2978
+ ...Object.keys(screen.variables ?? {}),
2979
+ ...Object.keys(screen.formModels ?? {}),
2980
+ ...Object.values(screen.formModels ?? {}).map((model) => model.id)
2981
+ ];
2525
2982
  for (const variant of named(screen.variants)) {
2526
- if (holdsDeadPath(variant.value, reach)) {
2983
+ if (holdsDeadPath(variant.value, reach, rootsFor(variant.value, own), state)) {
2527
2984
  found.push({
2528
2985
  subject: `${screen.name} \u2192 variant ${variant.name}`,
2529
2986
  target: { ...at, memberId: variant.id }
@@ -2531,7 +2988,7 @@ var statePathResolves = defineInvariant({
2531
2988
  }
2532
2989
  }
2533
2990
  for (const computed of named(screen.computeds)) {
2534
- if (holdsDeadPath(computed.value, reach)) {
2991
+ if (holdsDeadPath(computed.value, reach, rootsFor(computed.value, own), state)) {
2535
2992
  found.push({
2536
2993
  subject: `${screen.name} \u2192 computed ${computed.name}`,
2537
2994
  target: { ...at, computedId: computed.id }
@@ -2544,7 +3001,7 @@ var statePathResolves = defineInvariant({
2544
3001
  shapes: Object.assign({}, ...[...reaches.values()].map((r) => r.shapes))
2545
3002
  };
2546
3003
  for (const nav of Object.values(navMap)) {
2547
- if (holdsDeadPath(nav, everywhere)) {
3004
+ if (holdsDeadPath(nav, everywhere, rootsFor(nav), state)) {
2548
3005
  found.push({
2549
3006
  subject: `nav ${nav.label ?? nav.navId}`,
2550
3007
  target: { kind: "nav", navId: nav.navId }
@@ -2556,21 +3013,21 @@ var statePathResolves = defineInvariant({
2556
3013
  });
2557
3014
 
2558
3015
  // apps/m-one-ui/src/app/pages/design/lib/invariants/rule-operand-fits.ts
2559
- var import_codegen43 = require("./index.js");
3016
+ var import_codegen48 = require("./index.js");
2560
3017
  var unfit = (check, properties, shapes) => {
2561
- const error = (0, import_codegen43.checkError)(check, properties, shapes);
3018
+ const error = (0, import_codegen48.checkError)(check, properties, shapes);
2562
3019
  if (error === "rule-path-missing") return false;
2563
3020
  if (error === "rule-operator-invalid" || error === "rule-path-not-leaf" || error === "rule-operand-missing" && check.operand.kind === "path") {
2564
3021
  return true;
2565
3022
  }
2566
- if ((0, import_codegen43.isUnaryOperator)(check.operator) || check.operand.kind !== "literal") {
3023
+ if ((0, import_codegen48.isUnaryOperator)(check.operator) || check.operand.kind !== "literal") {
2567
3024
  return false;
2568
3025
  }
2569
- const segments = (0, import_codegen43.resolvePath)(check.path, properties, shapes);
2570
- if (!check.count && (0, import_codegen43.pathLeafEnumId)(segments)) return false;
2571
- const type = (0, import_codegen43.operandType)((0, import_codegen43.pathLeafType)(segments), !!check.count);
3026
+ const segments = (0, import_codegen48.resolvePath)(check.path, properties, shapes);
3027
+ if (!check.count && (0, import_codegen48.pathLeafEnumId)(segments)) return false;
3028
+ const type = (0, import_codegen48.operandType)((0, import_codegen48.pathLeafType)(segments), !!check.count);
2572
3029
  if (!type) return false;
2573
- return (0, import_codegen43.validateLiteral)(String(check.operand.value), { type }, "one") === "value-type-mismatch";
3030
+ return (0, import_codegen48.validateLiteral)(String(check.operand.value), { type }, "one") === "value-type-mismatch";
2574
3031
  };
2575
3032
  var ruleOperandFits = defineInvariant({
2576
3033
  name: "rule-operand-fits",
@@ -2582,11 +3039,11 @@ var ruleOperandFits = defineInvariant({
2582
3039
  for (const feature of Object.values(features)) {
2583
3040
  const properties = Object.assign(
2584
3041
  {},
2585
- ...(0, import_codegen43.storesOf)(feature).map((store) => store.properties)
3042
+ ...(0, import_codegen48.storesOf)(feature).map((store) => store.properties)
2586
3043
  );
2587
- const shapes = (0, import_codegen43.shapesInReach)(feature, sharedShapes);
3044
+ const shapes = (0, import_codegen48.shapesInReach)(feature, sharedShapes);
2588
3045
  for (const variant of Object.values(feature.variants ?? {})) {
2589
- if ((0, import_codegen43.ruleChecks)(variant.rule).some(
3046
+ if ((0, import_codegen48.ruleChecks)(variant.rule).some(
2590
3047
  (check) => unfit(check, properties, shapes)
2591
3048
  )) {
2592
3049
  found.push({
@@ -2606,7 +3063,7 @@ var ruleOperandFits = defineInvariant({
2606
3063
  });
2607
3064
 
2608
3065
  // apps/m-one-ui/src/app/pages/design/lib/invariants/timer-complete.ts
2609
- var import_codegen44 = require("./index.js");
3066
+ var import_codegen49 = require("./index.js");
2610
3067
  var timerComplete = defineInvariant({
2611
3068
  name: "timer-complete",
2612
3069
  message: "invariant-timer-incomplete",
@@ -2615,7 +3072,7 @@ var timerComplete = defineInvariant({
2615
3072
  validate: ({ features, screens }) => {
2616
3073
  const featureScreen = (featureId) => screens.find((screen) => screen.featureId === featureId)?.id ?? "";
2617
3074
  return Object.values(features).flatMap(
2618
- (feature) => Object.values(feature.timers ?? {}).filter((timer) => (0, import_codegen44.timerError)(timer)).map((timer) => ({
3075
+ (feature) => Object.values(feature.timers ?? {}).filter((timer) => (0, import_codegen49.timerError)(timer)).map((timer) => ({
2619
3076
  subject: `${feature.name}.${timer.name}`,
2620
3077
  target: {
2621
3078
  kind: "screen",
@@ -2627,20 +3084,20 @@ var timerComplete = defineInvariant({
2627
3084
  });
2628
3085
 
2629
3086
  // apps/m-one-ui/src/app/pages/design/lib/invariants/variant-gate-satisfiable.ts
2630
- var import_codegen45 = require("./index.js");
3087
+ var import_codegen50 = require("./index.js");
2631
3088
  var ATOM_CAP2 = 12;
2632
3089
  var foldText2 = (entries, names) => entries.map((entry, index) => {
2633
3090
  const name = names.get(entry.id) ?? entry.id;
2634
- const term = (0, import_codegen45.variantJoinIsNot)(entry.join) ? `!${name}` : name;
3091
+ const term = (0, import_codegen50.variantJoinIsNot)(entry.join) ? `!${name}` : name;
2635
3092
  if (index === 0) return term;
2636
- return `${(0, import_codegen45.variantJoinIsAnd)(entry.join) ? "&&" : "||"} ${term}`;
3093
+ return `${(0, import_codegen50.variantJoinIsAnd)(entry.join) ? "&&" : "||"} ${term}`;
2637
3094
  }).join(" ");
2638
3095
  var variantNames2 = (features, screens, currentScreenId) => {
2639
3096
  const screen = screens.find((one) => one.id === currentScreenId);
2640
3097
  const feature = screen?.featureId ? features[screen.featureId] : void 0;
2641
3098
  const names = /* @__PURE__ */ new Map([
2642
- [import_codegen45.ELSE_VARIANT_ID, import_codegen45.ELSE_VARIANT_NAME],
2643
- [import_codegen45.BUSY_VARIANT_ID, import_codegen45.BUSY_VARIANT_NAME]
3099
+ [import_codegen50.ELSE_VARIANT_ID, import_codegen50.ELSE_VARIANT_NAME],
3100
+ [import_codegen50.BUSY_VARIANT_ID, import_codegen50.BUSY_VARIANT_NAME]
2644
3101
  ]);
2645
3102
  Object.values(feature?.variants ?? {}).forEach(
2646
3103
  (variant) => names.set(variant.id, variant.name)
@@ -2650,16 +3107,16 @@ var variantNames2 = (features, screens, currentScreenId) => {
2650
3107
  var satisfiable = (gates) => {
2651
3108
  const atoms = [
2652
3109
  ...new Set(
2653
- gates.flat().map((entry) => entry.id).filter((id) => !(0, import_codegen45.isReservedVariantId)(id))
3110
+ gates.flat().map((entry) => entry.id).filter((id) => !(0, import_codegen50.isReservedVariantId)(id))
2654
3111
  )
2655
3112
  ];
2656
3113
  if (atoms.length > ATOM_CAP2) return true;
2657
3114
  const rows = 1 << atoms.length;
2658
3115
  for (let row = 0; row < rows; row++) {
2659
3116
  const on = atoms.filter((_, index) => row & 1 << index);
2660
- const base = on.length ? on : [...on, import_codegen45.ELSE_VARIANT_ID];
2661
- for (const withBusy of [base, [...base, import_codegen45.BUSY_VARIANT_ID]]) {
2662
- if (gates.every((gate) => (0, import_codegen45.evaluateVariantGate)(gate, withBusy))) {
3117
+ const base = on.length ? on : [...on, import_codegen50.ELSE_VARIANT_ID];
3118
+ for (const withBusy of [base, [...base, import_codegen50.BUSY_VARIANT_ID]]) {
3119
+ if (gates.every((gate) => (0, import_codegen50.evaluateVariantGate)(gate, withBusy))) {
2663
3120
  return true;
2664
3121
  }
2665
3122
  }
@@ -2678,9 +3135,9 @@ var unsatisfiableGates = perScreen(
2678
3135
  (controlMap, screen, { features, screens }) => {
2679
3136
  const names = variantNames2(features, screens, screen.id);
2680
3137
  return Object.entries(controlMap).flatMap(([controlId, control]) => {
2681
- const own = (0, import_codegen45.controlVariants)(control);
3138
+ const own = (0, import_codegen50.controlVariants)(control);
2682
3139
  if (!own.length) return [];
2683
- const above = (0, import_codegen45.enclosingGates)(controlId, controlMap);
3140
+ const above = (0, import_codegen50.enclosingGates)(controlId, controlMap);
2684
3141
  if (above === null) return [];
2685
3142
  const gates = [own, ...above];
2686
3143
  if (satisfiable(gates)) return [];
@@ -2700,6 +3157,865 @@ var unsatisfiableGates = perScreen(
2700
3157
  }
2701
3158
  );
2702
3159
 
3160
+ // apps/m-one-ui/src/app/pages/design/lib/codec-drops.ts
3161
+ var parse = (text) => {
3162
+ if (text === void 0) return void 0;
3163
+ try {
3164
+ return JSON.parse(text);
3165
+ } catch {
3166
+ return void 0;
3167
+ }
3168
+ };
3169
+ var label = (row, id) => typeof row?.name === "string" && row.name ? row.name : id;
3170
+ function codecDrops(files, source, root = ".magmonium") {
3171
+ const raw = parse(files[`${root}/index.json`]);
3172
+ if (!raw) return [];
3173
+ const found = [];
3174
+ const drop = (kind, key, subject, target2) => found.push({
3175
+ id: `codec-dropped-${kind}::${key}`,
3176
+ invariant: `codec-dropped-${kind}`,
3177
+ message: "invariant-codec-dropped",
3178
+ subject,
3179
+ severity: "blocking",
3180
+ target: target2
3181
+ });
3182
+ for (const [featureId, rawFeature] of Object.entries(raw.features ?? {})) {
3183
+ const fname = label(rawFeature, featureId);
3184
+ const feature = source.features[featureId];
3185
+ const at = { kind: "panel", panel: "store", featureId };
3186
+ if (!feature) {
3187
+ drop("feature", featureId, `Feature ${fname}`, at);
3188
+ continue;
3189
+ }
3190
+ const members = (store, decoded, prefix, owner) => {
3191
+ for (const [word, key] of [
3192
+ ["property", "properties"],
3193
+ ["computed", "computeds"],
3194
+ ["method", "methods"],
3195
+ ["timer", "timers"]
3196
+ ]) {
3197
+ for (const [id, row] of Object.entries(store?.[key] ?? {})) {
3198
+ if (!decoded?.[key]?.[id])
3199
+ drop(word, `${featureId}:${id}`, `${prefix} \u2192 ${word} ${label(row, id)}`, { ...owner, memberId: id });
3200
+ }
3201
+ }
3202
+ };
3203
+ members(rawFeature, feature, fname, at);
3204
+ for (const [subId, rawSub] of Object.entries(rawFeature?.subStores ?? {})) {
3205
+ const sub = feature.subStores?.[subId];
3206
+ if (!sub) {
3207
+ drop("substore", `${featureId}:${subId}`, `${fname} \u2192 store ${label(rawSub, subId)}`, at);
3208
+ continue;
3209
+ }
3210
+ members(rawSub, sub, `${fname} \u2192 ${label(rawSub, subId)}`, { ...at, subStoreId: subId });
3211
+ }
3212
+ }
3213
+ const decodedFunctions = /* @__PURE__ */ new Set([
3214
+ ...Object.keys(source.functions),
3215
+ ...Object.values(source.features).flatMap((feature) => Object.keys(feature.functions ?? {}))
3216
+ ]);
3217
+ const rawFunctions = [
3218
+ ...Object.entries(raw.functions ?? {}).map(([id, row]) => [id, row, void 0]),
3219
+ ...Object.entries(raw.features ?? {}).flatMap(
3220
+ ([featureId, feature]) => Object.entries(feature?.functions ?? {}).map(([id, row]) => [id, row, featureId])
3221
+ )
3222
+ ];
3223
+ for (const [id, row, featureId] of rawFunctions) {
3224
+ if (!decodedFunctions.has(id))
3225
+ drop("function", id, `function ${label(row, id)}`, {
3226
+ kind: "function",
3227
+ ...featureId ? { featureId } : {},
3228
+ functionId: id
3229
+ });
3230
+ }
3231
+ const decodedScreens = new Map(source.screens.map((slot) => [slot.meta.id, slot]));
3232
+ for (const rawScreen of raw.screens ?? []) {
3233
+ const id = typeof rawScreen.id === "string" ? rawScreen.id : void 0;
3234
+ if (!id) continue;
3235
+ const name = label(rawScreen, id);
3236
+ const slot = decodedScreens.get(id);
3237
+ if (!slot) {
3238
+ drop("screen", id, `Screen ${name}`, { kind: "screen", screenId: id });
3239
+ continue;
3240
+ }
3241
+ for (const [cid, row] of Object.entries(rawScreen.computeds ?? {})) {
3242
+ if (!slot.meta.computeds?.[cid])
3243
+ drop("screen-computed", `${id}:${cid}`, `${name} \u2192 computed ${label(row, cid)}`, {
3244
+ kind: "screen",
3245
+ screenId: id,
3246
+ panel: "screen",
3247
+ computedId: cid
3248
+ });
3249
+ }
3250
+ const rawSlot = parse(
3251
+ files[`${root}/screens/${id}.json`]
3252
+ );
3253
+ for (const [controlId, control] of Object.entries(rawSlot?.state?.controlMap ?? {})) {
3254
+ if (!slot.state.controlMap[controlId])
3255
+ drop("control", `${id}:${controlId}`, `${name} \u2192 ${String(control?.type ?? "control")} ${controlId}`, {
3256
+ kind: "screen",
3257
+ screenId: id
3258
+ });
3259
+ }
3260
+ }
3261
+ return found;
3262
+ }
3263
+
3264
+ // apps/m-one-ui/src/app/pages/design/lib/emit-gap-helper.ts
3265
+ var import_codegen52 = require("./index.js");
3266
+
3267
+ // apps/m-one-ui/src/app/pages/design/lib/store-method-check.ts
3268
+ var import_codegen51 = require("./index.js");
3269
+ function storeMethodError(method, scope) {
3270
+ const name = (0, import_codegen51.validateMethodName)(method.name, scope.siblings, method.id);
3271
+ if (name) return name;
3272
+ if ((0, import_codegen51.isStorageMethod)(method)) {
3273
+ const config = method.storage;
3274
+ if (!config?.key.trim()) return "emit-gap-storage-method";
3275
+ if (config.op !== "delete" && !scope.properties[config.propertyId ?? ""]) {
3276
+ return "emit-gap-storage-method";
3277
+ }
3278
+ return void 0;
3279
+ }
3280
+ if ((0, import_codegen51.isCacheMethod)(method)) {
3281
+ return (0, import_codegen51.cacheMethodError)(
3282
+ method,
3283
+ scope.methods,
3284
+ scope.properties,
3285
+ scope.operationOf
3286
+ );
3287
+ }
3288
+ const operation = scope.operationOf(method);
3289
+ if (!operation) return "emit-gap-unknown-operation";
3290
+ return (0, import_codegen51.validateInputs)(method, operation) ?? (0, import_codegen51.computeInputMemberError)(method, scope.functions, scope.shapes);
3291
+ }
3292
+
3293
+ // apps/m-one-ui/src/app/pages/design/lib/emit-gap-helper.ts
3294
+ var controlLabel = (control) => {
3295
+ const name = String(control.configs?.["name"] ?? "").trim();
3296
+ return name || control.type;
3297
+ };
3298
+ var featureSliceOf = (meta, features, appFunctions) => {
3299
+ if (!(0, import_codegen52.isFeatureScreen)(meta)) {
3300
+ return {
3301
+ methods: {},
3302
+ properties: {},
3303
+ functions: { ...appFunctions },
3304
+ computeds: {},
3305
+ roots: {},
3306
+ shapes: {}
3307
+ };
3308
+ }
3309
+ const feature = features[meta.featureId];
3310
+ const functions = { ...appFunctions, ...feature?.functions ?? {} };
3311
+ const readable = feature ? (0, import_codegen52.readableMembers)(feature, import_codegen52.MAIN_STORE_OWNER) : void 0;
3312
+ return {
3313
+ methods: readable?.methods ?? {},
3314
+ properties: readable?.properties ?? {},
3315
+ functions,
3316
+ computeds: readable?.computeds ?? {},
3317
+ roots: (0, import_codegen52.propertiesWithComputeds)(
3318
+ readable?.properties ?? {},
3319
+ readable?.computeds ?? {},
3320
+ functions
3321
+ ),
3322
+ shapes: feature?.shapes ?? {}
3323
+ };
3324
+ };
3325
+ var screenBindingOptions = (meta, controlMap, slice, inputs, variables, where) => ({
3326
+ ...where.controlId ? { controlId: where.controlId } : {},
3327
+ controlMap,
3328
+ roots: slice.roots,
3329
+ properties: slice.properties,
3330
+ shapes: slice.shapes,
3331
+ inputs,
3332
+ screenComputeds: meta.computeds,
3333
+ screenVariables: variables,
3334
+ formModels: meta.formModels,
3335
+ functions: slice.functions,
3336
+ enums: slice.enums,
3337
+ allowAlias: where.allowAlias
3338
+ });
3339
+ var callSiteError = (method, operationOf, rows, payload, constants, functions, bindings, properties = {}, methods = {}, eventMembers = []) => {
3340
+ if (!method) return "emit-gap-unknown-method";
3341
+ const op = operationOf(method);
3342
+ if (!op && !(0, import_codegen52.isStorageMethod)(method) && !(0, import_codegen52.isCacheMethod)(method)) {
3343
+ return "emit-gap-unknown-operation";
3344
+ }
3345
+ const args = (0, import_codegen52.isCacheMethod)(method) ? (0, import_codegen52.cacheMethodArgs)(method, methods, operationOf) : op ? (0, import_codegen52.methodArgs)(method, op) : (0, import_codegen52.storageMethodArgs)(method, properties);
3346
+ return (0, import_codegen52.validateCallArgs)(
3347
+ args,
3348
+ rows,
3349
+ payload,
3350
+ eventMembers,
3351
+ constants,
3352
+ functions,
3353
+ { roots: properties, bindings }
3354
+ );
3355
+ };
3356
+ var collectControlGaps = (gaps, meta, controlMap, slice, constants, inputs, variables, operationOf, screens = []) => {
3357
+ const embedded = embeddedOutputsOf(screens);
3358
+ const emitBindings = (control, scope) => ({
3359
+ options: screenBindingOptions(meta, controlMap, slice, inputs, variables, {
3360
+ controlId: control.id,
3361
+ allowAlias: scope === "template"
3362
+ })
3363
+ });
3364
+ Object.values(controlMap).forEach((control) => {
3365
+ const outputs = new Set([
3366
+ ...Object.keys(control.outputs ?? {}),
3367
+ ...Object.keys(control.outputWrites ?? {}),
3368
+ ...Object.keys(control.outputScreenWrites ?? {}),
3369
+ // An output that only opens a Screen holds nothing in the maps above, and
3370
+ // an overlay naming a Screen that is gone is a gesture that does nothing.
3371
+ ...Object.keys(control.outputOpens ?? {}),
3372
+ // An output whose rows all sit in an arm holds nothing in the three maps
3373
+ // above, and a broken row there is still a row that will not emit.
3374
+ ...Object.keys(control.outputOutcomes ?? {}),
3375
+ // An output whose one block is a ScreenEmit holds nothing in them
3376
+ // either, and a half-drawn emission is still a gesture that does
3377
+ // nothing (ADR 0143).
3378
+ ...Object.keys(control.outputEmits ?? {}),
3379
+ // A ScreenMethod whose parameters this call site leaves unanswered is a
3380
+ // call that cannot be spelled (ADR 0149).
3381
+ ...Object.keys(control.outputScreenMethods ?? {})
3382
+ ].filter(
3383
+ (output) => offersOutputKey(control, controlMap, output, embedded)
3384
+ ));
3385
+ const eventMembers = (0, import_codegen52.formEventMembers)(controlMap, control.id);
3386
+ const eventFields = (0, import_codegen52.formEventFieldTypes)(controlMap, control.id);
3387
+ const callBindings = screenBindingOptions(
3388
+ meta,
3389
+ controlMap,
3390
+ slice,
3391
+ inputs,
3392
+ variables,
3393
+ { controlId: control.id, allowAlias: true }
3394
+ );
3395
+ outputs.forEach((output) => {
3396
+ const methodId = control.outputs?.[output];
3397
+ const globalMethod = methodId ? (0, import_codegen52.globalMethodOf)(methodId) : void 0;
3398
+ if (methodId) {
3399
+ const err = globalMethod ? (0, import_codegen52.validateCallArgs)(
3400
+ (0, import_codegen52.globalMethodArgs)(globalMethod),
3401
+ (0, import_codegen52.outputArgRows)(control.outputArgs, output),
3402
+ outputPayloadShape(control, output, embedded),
3403
+ eventMembers,
3404
+ constants,
3405
+ slice.functions,
3406
+ { roots: slice.properties, bindings: callBindings }
3407
+ ) : callSiteError(
3408
+ slice.methods[methodId],
3409
+ operationOf,
3410
+ (0, import_codegen52.outputArgRows)(control.outputArgs, output),
3411
+ outputPayloadShape(control, output, embedded),
3412
+ constants,
3413
+ slice.functions,
3414
+ callBindings,
3415
+ slice.properties,
3416
+ slice.methods,
3417
+ eventMembers
3418
+ );
3419
+ if (err) {
3420
+ gaps.push({
3421
+ kind: "call-arg",
3422
+ screenId: meta.id,
3423
+ screenName: meta.name,
3424
+ message: err,
3425
+ subject: `${meta.name} \xB7 ${controlLabel(control)} \xB7 ${outputCallLabelOf(control, output, embedded)}`,
3426
+ controlId: control.id,
3427
+ output,
3428
+ methodId
3429
+ });
3430
+ }
3431
+ }
3432
+ const screenMethodId = control.outputScreenMethods?.[output];
3433
+ const screenMethod = screenMethodId ? meta.methods?.[screenMethodId] : void 0;
3434
+ if (screenMethod && (0, import_codegen52.screenMethodArgs)(screenMethod).length) {
3435
+ const err = (0, import_codegen52.validateCallArgs)(
3436
+ (0, import_codegen52.screenMethodArgs)(screenMethod),
3437
+ (0, import_codegen52.outputArgRows)(control.outputArgs, output),
3438
+ outputPayloadShape(control, output, embedded),
3439
+ eventMembers,
3440
+ constants,
3441
+ slice.functions,
3442
+ { roots: slice.properties, bindings: callBindings }
3443
+ );
3444
+ if (err) {
3445
+ gaps.push({
3446
+ kind: "call-arg",
3447
+ screenId: meta.id,
3448
+ screenName: meta.name,
3449
+ message: err,
3450
+ subject: `${meta.name} \xB7 ${controlLabel(control)} \xB7 ${outputCallLabelOf(control, output, embedded)}`,
3451
+ controlId: control.id,
3452
+ output
3453
+ });
3454
+ }
3455
+ }
3456
+ import_codegen52.OUTCOME_ARMS.forEach((arm) => {
3457
+ const rows = control.outputOutcomes?.[output]?.[arm];
3458
+ if (!rows) return;
3459
+ const resetErr = (0, import_codegen52.validateFormResets)(
3460
+ controlMap,
3461
+ rows.formResets ?? [],
3462
+ meta.formModels ?? {}
3463
+ );
3464
+ if (resetErr) {
3465
+ gaps.push({
3466
+ kind: "call-outcome",
3467
+ screenId: meta.id,
3468
+ screenName: meta.name,
3469
+ message: resetErr,
3470
+ subject: `${meta.name} \xB7 ${controlLabel(control)} \xB7 ${outputCallLabelOf(control, output, embedded)} \xB7 ${arm}`,
3471
+ controlId: control.id,
3472
+ output
3473
+ });
3474
+ }
3475
+ const armScreenWriteErr = (0, import_codegen52.validateScreenWrites)(
3476
+ variables,
3477
+ rows.screenWrites ?? [],
3478
+ outputPayloadShape(control, output, embedded),
3479
+ [],
3480
+ inputs,
3481
+ constants,
3482
+ slice.functions,
3483
+ eventFields
3484
+ );
3485
+ if (armScreenWriteErr) {
3486
+ gaps.push({
3487
+ kind: "call-outcome",
3488
+ screenId: meta.id,
3489
+ screenName: meta.name,
3490
+ message: armScreenWriteErr,
3491
+ subject: `${meta.name} \xB7 ${controlLabel(control)} \xB7 ${outputCallLabelOf(control, output, embedded)} \xB7 ${arm}`,
3492
+ controlId: control.id,
3493
+ output
3494
+ });
3495
+ }
3496
+ const armWriteErr = Object.keys(slice.properties).length ? (0, import_codegen52.validateStateWrites)(
3497
+ slice.properties,
3498
+ rows.writes ?? [],
3499
+ outputPayloadShape(control, output, embedded),
3500
+ [],
3501
+ inputs,
3502
+ constants,
3503
+ slice.functions,
3504
+ eventFields
3505
+ ) : void 0;
3506
+ if (armWriteErr) {
3507
+ gaps.push({
3508
+ kind: "call-outcome",
3509
+ screenId: meta.id,
3510
+ screenName: meta.name,
3511
+ message: armWriteErr,
3512
+ subject: `${meta.name} \xB7 ${controlLabel(control)} \xB7 ${outputCallLabelOf(control, output, embedded)} \xB7 ${arm}`,
3513
+ controlId: control.id,
3514
+ output
3515
+ });
3516
+ }
3517
+ });
3518
+ const openErr = (0, import_codegen52.validateOutputOpen)(
3519
+ (0, import_codegen52.outputOpenOf)(control.outputOpens, output),
3520
+ [...screens],
3521
+ outputPayloadShape(control, output, embedded),
3522
+ inputs,
3523
+ constants
3524
+ );
3525
+ if (openErr) {
3526
+ gaps.push({
3527
+ kind: "output-open",
3528
+ screenId: meta.id,
3529
+ screenName: meta.name,
3530
+ message: openErr,
3531
+ subject: `${meta.name} \xB7 ${controlLabel(control)} \xB7 ${output}`,
3532
+ controlId: control.id,
3533
+ output
3534
+ });
3535
+ }
3536
+ const emitErr = (0, import_codegen52.validateScreenEmits)(
3537
+ meta.outputs ?? {},
3538
+ (0, import_codegen52.screenEmitRows)(control.outputEmits, output),
3539
+ outputPayloadShape(control, output, embedded),
3540
+ [],
3541
+ inputs,
3542
+ constants,
3543
+ emitBindings(control, "template")
3544
+ );
3545
+ if (emitErr) {
3546
+ gaps.push({
3547
+ kind: "emit",
3548
+ screenId: meta.id,
3549
+ screenName: meta.name,
3550
+ message: emitErr,
3551
+ subject: `${meta.name} \xB7 ${controlLabel(control)} \xB7 ${output}`,
3552
+ controlId: control.id,
3553
+ output
3554
+ });
3555
+ }
3556
+ const open = (0, import_codegen52.outputOpenOf)(control.outputOpens, output);
3557
+ const opened = open?.screenId ? screens.find((one) => one.id === open.screenId) : void 0;
3558
+ for (const [outputId, wire] of Object.entries(open?.outputs ?? {})) {
3559
+ const declared = opened?.outputs?.[outputId];
3560
+ const failing = [
3561
+ ...wire.binding ? [wire.binding] : [],
3562
+ ...(wire.calls ?? []).filter((call) => !!call.methodId)
3563
+ ].map((one) => ({
3564
+ one,
3565
+ err: callSiteError(
3566
+ slice.methods[one.methodId],
3567
+ operationOf,
3568
+ one.args ?? [],
3569
+ declared?.payload ? declared.payload.dataType : "void",
3570
+ constants,
3571
+ slice.functions,
3572
+ // A wire's call is emitted into the class body (ADR 0144).
3573
+ screenBindingOptions(meta, controlMap, slice, inputs, variables, {
3574
+ allowAlias: false
3575
+ }),
3576
+ slice.properties,
3577
+ slice.methods
3578
+ )
3579
+ })).find(({ err }) => !!err);
3580
+ const callErr = failing?.err;
3581
+ const binding = failing?.one ?? wire.binding;
3582
+ const wireErr = !declared ? "screen-emit-unknown-output" : callErr ?? (0, import_codegen52.validateScreenEmits)(
3583
+ meta.outputs ?? {},
3584
+ wire.emits ?? [],
3585
+ declared.payload ? declared.payload.dataType : "void",
3586
+ [],
3587
+ inputs,
3588
+ constants,
3589
+ emitBindings(control, "class")
3590
+ );
3591
+ if (!wireErr) continue;
3592
+ gaps.push({
3593
+ kind: "output-open-output",
3594
+ screenId: meta.id,
3595
+ screenName: meta.name,
3596
+ message: wireErr,
3597
+ subject: `${meta.name} \xB7 ${controlLabel(control)} \xB7 ${output} \xB7 ${declared?.name ?? outputId}`,
3598
+ controlId: control.id,
3599
+ output,
3600
+ ...binding ? { methodId: binding.methodId } : {}
3601
+ });
3602
+ }
3603
+ const screenWriteErr = (0, import_codegen52.validateScreenWrites)(
3604
+ variables,
3605
+ (0, import_codegen52.screenWriteRows)(control.outputScreenWrites, output),
3606
+ outputPayloadShape(control, output, embedded),
3607
+ [],
3608
+ inputs,
3609
+ constants,
3610
+ slice.functions,
3611
+ eventFields
3612
+ );
3613
+ if (screenWriteErr) {
3614
+ gaps.push({
3615
+ kind: "screen-write",
3616
+ screenId: meta.id,
3617
+ screenName: meta.name,
3618
+ message: screenWriteErr,
3619
+ subject: `${meta.name} \xB7 ${controlLabel(control)} \xB7 ${output}`,
3620
+ controlId: control.id,
3621
+ output
3622
+ });
3623
+ }
3624
+ const writeRows = (0, import_codegen52.stateWriteRows)(control.outputWrites, output);
3625
+ if (!writeRows.length) return;
3626
+ if (!Object.keys(slice.properties).length) return;
3627
+ const writeErr = (0, import_codegen52.validateStateWrites)(
3628
+ slice.properties,
3629
+ writeRows,
3630
+ outputPayloadShape(control, output, embedded),
3631
+ [],
3632
+ inputs,
3633
+ constants,
3634
+ slice.functions,
3635
+ eventFields
3636
+ );
3637
+ if (writeErr) {
3638
+ gaps.push({
3639
+ kind: "state-write",
3640
+ screenId: meta.id,
3641
+ screenName: meta.name,
3642
+ message: writeErr,
3643
+ subject: `${meta.name} \xB7 ${controlLabel(control)} \xB7 ${output}`,
3644
+ controlId: control.id,
3645
+ output
3646
+ });
3647
+ }
3648
+ });
3649
+ });
3650
+ };
3651
+ var collectBindingGaps = (gaps, meta, controlMap, slice) => {
3652
+ Object.values(controlMap).forEach((control) => {
3653
+ Object.entries(control.bindings ?? {}).forEach(([slot, binding]) => {
3654
+ if (!binding.transform) return;
3655
+ const err = (0, import_codegen52.transformIncomplete)(
3656
+ binding.transform,
3657
+ slice.functions,
3658
+ slice.roots,
3659
+ slice.shapes
3660
+ );
3661
+ if (!err) return;
3662
+ gaps.push({
3663
+ kind: "binding",
3664
+ screenId: meta.id,
3665
+ screenName: meta.name,
3666
+ message: err,
3667
+ subject: `${meta.name} \xB7 ${controlLabel(control)} \xB7 ${slot}`,
3668
+ // The parameter still unanswered where one of them is, so the panel
3669
+ // names what to go and fill in rather than only the call it sits under.
3670
+ detail: (0, import_codegen52.transformGapDetail)(
3671
+ binding.transform,
3672
+ slice.functions,
3673
+ slice.roots,
3674
+ slice.shapes
3675
+ ) ?? (0, import_codegen52.transformLabel)(binding.transform, slice.functions),
3676
+ controlId: control.id,
3677
+ slot
3678
+ });
3679
+ });
3680
+ });
3681
+ };
3682
+ var autoCallReadError = (call, bindings) => {
3683
+ if (!call.reads?.length) return void 0;
3684
+ const offered = new Set(
3685
+ (0, import_codegen52.bindingOptions)(bindings, () => true).map((option) => option.value)
3686
+ );
3687
+ return call.reads.every((read) => offered.has((0, import_codegen52.encodeBinding)(read))) ? void 0 : "auto-call-read-gone";
3688
+ };
3689
+ var collectAutoCallGaps = (gaps, meta, calls, slice, constants, operationOf, bindings) => {
3690
+ calls.forEach((call) => {
3691
+ const err = (0, import_codegen52.screenAutoCallError)(call) ?? (call.methodId ? callSiteError(
3692
+ slice.methods[call.methodId],
3693
+ operationOf,
3694
+ call.args,
3695
+ "void",
3696
+ constants,
3697
+ slice.functions,
3698
+ bindings,
3699
+ slice.properties,
3700
+ slice.methods
3701
+ ) : void 0) ?? (0, import_codegen52.validateScreenEmits)(
3702
+ meta.outputs ?? {},
3703
+ call.emits ?? [],
3704
+ "void",
3705
+ [],
3706
+ meta.inputs ?? {},
3707
+ constants,
3708
+ { options: bindings }
3709
+ ) ?? autoCallReadError(call, bindings);
3710
+ if (!err) return;
3711
+ gaps.push({
3712
+ kind: "auto-call",
3713
+ screenId: meta.id,
3714
+ screenName: meta.name,
3715
+ message: err,
3716
+ subject: `${meta.name} \xB7 auto-call`,
3717
+ ...call.methodId ? { methodId: call.methodId } : {},
3718
+ autoCallId: call.id
3719
+ });
3720
+ });
3721
+ };
3722
+ var collectMethodGaps = (gaps, scope) => {
3723
+ Object.values(scope.features).forEach((feature) => {
3724
+ const screen = scope.screens.find(
3725
+ ({ meta }) => (0, import_codegen52.isFeatureScreen)(meta) && meta.featureId === feature.id
3726
+ )?.meta;
3727
+ const functions = { ...scope.functions, ...feature.functions ?? {} };
3728
+ (0, import_codegen52.storesOf)(feature).forEach((owned) => {
3729
+ const readable = (0, import_codegen52.readableMembers)(feature, owned.owner);
3730
+ Object.values(owned.methods).forEach((method) => {
3731
+ const error = storeMethodError(method, {
3732
+ operationOf: scope.operationOf,
3733
+ siblings: owned.methods,
3734
+ methods: readable.methods,
3735
+ properties: readable.properties,
3736
+ functions,
3737
+ shapes: feature.shapes ?? {}
3738
+ });
3739
+ if (!error || error === "emit-gap-unknown-operation") return;
3740
+ gaps.push({
3741
+ kind: "method",
3742
+ screenId: screen?.id ?? "",
3743
+ screenName: screen?.name ?? feature.name,
3744
+ message: error,
3745
+ subject: `${feature.name} \xB7 ${method.name}`,
3746
+ methodId: method.id
3747
+ });
3748
+ });
3749
+ });
3750
+ });
3751
+ };
3752
+ var collectResponseGaps = (gaps, scope) => {
3753
+ Object.values(scope.features).forEach((feature) => {
3754
+ const screen = scope.screens.find(
3755
+ ({ meta }) => (0, import_codegen52.isFeatureScreen)(meta) && meta.featureId === feature.id
3756
+ )?.meta;
3757
+ (0, import_codegen52.storesOf)(feature).forEach((owned) => {
3758
+ const readable = (0, import_codegen52.readableMembers)(feature, owned.owner);
3759
+ Object.values(owned.methods).forEach((method) => {
3760
+ const read = scope.operationOf(method);
3761
+ if (!read) return;
3762
+ const emitted = (0, import_codegen52.emittedOperation)(read, feature.shapes);
3763
+ const roots = (0, import_codegen52.propertiesWithComputeds)(
3764
+ readable.properties,
3765
+ readable.computeds,
3766
+ feature.functions ?? {}
3767
+ );
3768
+ const judge = (mapping, op) => {
3769
+ if (mapping.transform) {
3770
+ const failure = (0, import_codegen52.outcomeTransformFailure)(
3771
+ mapping,
3772
+ method,
3773
+ op,
3774
+ readable.properties,
3775
+ feature.shapes,
3776
+ feature.functions ?? {},
3777
+ roots
3778
+ );
3779
+ return failure && { err: failure.error, ...failure };
3780
+ }
3781
+ const err = (0, import_codegen52.responseMappingError)(
3782
+ mapping,
3783
+ op,
3784
+ readable.properties,
3785
+ feature.shapes
3786
+ );
3787
+ return err && {
3788
+ err,
3789
+ detail: (0, import_codegen52.responseMappingDetail)(
3790
+ mapping,
3791
+ op,
3792
+ readable.properties,
3793
+ feature.shapes
3794
+ ),
3795
+ paramIndex: void 0
3796
+ };
3797
+ };
3798
+ method.response.forEach((mapping) => {
3799
+ const verdict = judge(mapping, read) ?? judge(mapping, emitted);
3800
+ if (!verdict) return;
3801
+ const { err, detail, paramIndex } = verdict;
3802
+ gaps.push({
3803
+ kind: "response",
3804
+ screenId: screen?.id ?? "",
3805
+ screenName: screen?.name ?? feature.name,
3806
+ message: err,
3807
+ subject: `${feature.name} \xB7 ${method.name} \xB7 ${mapping.code}`,
3808
+ ...detail ? { detail } : {},
3809
+ methodId: method.id,
3810
+ anchor: `${mapping.code}:${mapping.propertyId}`,
3811
+ ...paramIndex !== void 0 ? { paramIndex } : {}
3812
+ });
3813
+ });
3814
+ });
3815
+ });
3816
+ });
3817
+ };
3818
+ var collectShadowedShapeGaps = (gaps, scope) => {
3819
+ Object.values(scope.features).forEach((feature) => {
3820
+ const screen = scope.screens.find(
3821
+ ({ meta }) => (0, import_codegen52.isFeatureScreen)(meta) && meta.featureId === feature.id
3822
+ )?.meta;
3823
+ const reads = (0, import_codegen52.storesOf)(feature).flatMap(
3824
+ (owned) => Object.values(owned.methods).flatMap((method) => {
3825
+ const op = scope.operationOf(method);
3826
+ return op ? [{ method, op }] : [];
3827
+ })
3828
+ );
3829
+ (0, import_codegen52.shadowedShapes)(
3830
+ reads.map(({ op }) => op),
3831
+ feature.shapes
3832
+ ).forEach((shadow) => {
3833
+ const first = reads.find(
3834
+ ({ op }) => (0, import_codegen52.shadowedShapes)([op], feature.shapes).some(
3835
+ (row) => row.shapeId === shadow.shapeId
3836
+ )
3837
+ );
3838
+ gaps.push({
3839
+ kind: "response",
3840
+ screenId: screen?.id ?? "",
3841
+ screenName: screen?.name ?? feature.name,
3842
+ message: "emit-gap-shape-shadowed",
3843
+ subject: `${feature.name} \xB7 ${shadow.name}`,
3844
+ detail: shadow.details.join("; "),
3845
+ ...first ? { methodId: first.method.id } : {},
3846
+ anchor: shadow.shapeId
3847
+ });
3848
+ });
3849
+ });
3850
+ };
3851
+ var collectNavInstanceGaps = (gaps, scope) => {
3852
+ const navMap = scope.navMap;
3853
+ if (!navMap) return;
3854
+ Object.values(navMap).filter((nav) => nav.presentation === "dynamic" && !!nav.instanceSource).forEach((nav) => {
3855
+ const source = nav.instanceSource;
3856
+ if (!source?.featureId) return;
3857
+ const subject = `${nav.navId} \xB7 :${(0, import_codegen52.navParam)(nav)}`;
3858
+ const push = (message, detail) => {
3859
+ gaps.push({
3860
+ kind: "nav-instance",
3861
+ screenId: "",
3862
+ screenName: nav.navId,
3863
+ message,
3864
+ subject,
3865
+ ...detail ? { detail } : {},
3866
+ navId: nav.navId
3867
+ });
3868
+ };
3869
+ const feature = scope.features[source.featureId];
3870
+ if (!feature) return push("instance-resolver-feature-gone");
3871
+ if (!source.functionId) return push("instance-resolver-unbound");
3872
+ const fn = feature.functions?.[source.functionId];
3873
+ if (!fn) return push("instance-resolver-function-gone");
3874
+ if (!(0, import_codegen52.navInstanceReturn)(fn, feature))
3875
+ return push("instance-resolver-return-unfit", fn.name);
3876
+ const unmapped = (0, import_codegen52.unmappedParams)(fn, source.args);
3877
+ if (unmapped.length)
3878
+ push("instance-resolver-args-unmapped", unmapped.join(", "));
3879
+ });
3880
+ };
3881
+ var collectEmitGaps = (scope) => {
3882
+ const gaps = [];
3883
+ const embedded = embeddedOutputsOf(scope.screens.map(({ meta }) => meta));
3884
+ scope.screens.forEach(({ meta, state }) => {
3885
+ const slice = {
3886
+ ...featureSliceOf(meta, scope.features, scope.functions),
3887
+ enums: scope.enums
3888
+ };
3889
+ collectControlGaps(
3890
+ gaps,
3891
+ meta,
3892
+ state.controlMap,
3893
+ slice,
3894
+ meta.constants ?? {},
3895
+ meta.inputs ?? {},
3896
+ meta.variables ?? {},
3897
+ scope.operationOf,
3898
+ scope.screens.map((screen) => screen.meta)
3899
+ );
3900
+ Object.values(state.controlMap).forEach((control) => {
3901
+ Object.keys(control.outputArms ?? {}).forEach((output) => {
3902
+ if (!offersOutputKey(control, state.controlMap, output, embedded)) return;
3903
+ (0, import_codegen52.outputArms)(control, output).forEach((arm, index) => {
3904
+ if ((0, import_codegen52.isOutputArmComplete)(arm)) return;
3905
+ gaps.push({
3906
+ kind: "binding",
3907
+ screenId: meta.id,
3908
+ screenName: meta.name,
3909
+ subject: `${meta.name} \xB7 ${controlLabel(control)} \xB7 ${output} ${index + 1}`,
3910
+ controlId: control.id,
3911
+ slot: (0, import_codegen52.outputArmKey)(output, arm.id),
3912
+ message: arm.checks.length ? "Finish this arm condition \u2014 a check is missing its subject, operator or value." : "Give this arm a condition, or it never runs."
3913
+ });
3914
+ });
3915
+ });
3916
+ });
3917
+ Object.values(state.controlMap).forEach((control) => {
3918
+ const outputs = /* @__PURE__ */ new Set([
3919
+ ...Object.keys(control.outputNavs ?? {}),
3920
+ ...Object.keys(control.outputNewTabs ?? {})
3921
+ ]);
3922
+ outputs.forEach((output) => {
3923
+ if (!offersOutputKey(control, state.controlMap, output, embedded)) return;
3924
+ const message = (0, import_codegen52.validateOutputNewTab)(
3925
+ (0, import_codegen52.outputNewTabOf)(control.outputNewTabs, output),
3926
+ slice.functions
3927
+ ) ?? (scope.navMap ? (0, import_codegen52.validateOutputNav)(
3928
+ (0, import_codegen52.outputNavOf)(control.outputNavs, output),
3929
+ scope.navMap
3930
+ ) : void 0);
3931
+ if (!message) return;
3932
+ gaps.push({
3933
+ kind: "output-link",
3934
+ screenId: meta.id,
3935
+ screenName: meta.name,
3936
+ message,
3937
+ subject: `${meta.name} \xB7 ${controlLabel(control)} \xB7 ${output}`,
3938
+ controlId: control.id,
3939
+ output
3940
+ });
3941
+ });
3942
+ });
3943
+ Object.values(state.controlMap).forEach((control) => {
3944
+ if (control.type !== import_codegen52.ControlType.CONTEXT_MENU) return;
3945
+ const binding = control.bindings?.["options"];
3946
+ const message = binding ? (0, import_codegen52.bindingGapReason)(binding, {
3947
+ properties: slice.roots,
3948
+ shapes: slice.shapes,
3949
+ computeds: slice.computeds,
3950
+ functions: slice.functions,
3951
+ inputs: meta.inputs,
3952
+ screenComputeds: meta.computeds,
3953
+ screenVariables: meta.variables,
3954
+ formModels: meta.formModels,
3955
+ constants: meta.constants,
3956
+ storeProp: "store",
3957
+ controlMap: state.controlMap
3958
+ }) : (0, import_codegen52.menuOptionsOf)(control).some((group) => group.length) ? void 0 : "Author menu options or bind a collection.";
3959
+ if (message)
3960
+ gaps.push({
3961
+ kind: "binding",
3962
+ screenId: meta.id,
3963
+ screenName: meta.name,
3964
+ subject: `${meta.name} \xB7 ${controlLabel(control)} \xB7 options`,
3965
+ controlId: control.id,
3966
+ slot: "options",
3967
+ message
3968
+ });
3969
+ (0, import_codegen52.menuActionSlots)(control).forEach((slot, index) => {
3970
+ if ((0, import_codegen52.isMenuActionSlotComplete)(slot)) return;
3971
+ gaps.push({
3972
+ kind: "binding",
3973
+ screenId: meta.id,
3974
+ screenName: meta.name,
3975
+ subject: `${meta.name} \xB7 ${controlLabel(control)} \xB7 action ${index + 1}`,
3976
+ controlId: control.id,
3977
+ slot: (0, import_codegen52.menuActionKey)(slot.id),
3978
+ message: slot.checks.length ? "Finish this action condition \u2014 a check is missing its operator or value." : "Give this action a condition, or it fires for nothing."
3979
+ });
3980
+ });
3981
+ if (binding) return;
3982
+ (0, import_codegen52.staleMenuActionItems)(control).forEach(
3983
+ ({ slotId, itemId }) => gaps.push({
3984
+ kind: "binding",
3985
+ screenId: meta.id,
3986
+ screenName: meta.name,
3987
+ subject: `${meta.name} \xB7 ${controlLabel(control)} \xB7 ${itemId}`,
3988
+ controlId: control.id,
3989
+ slot: (0, import_codegen52.menuActionKey)(slotId),
3990
+ message: "This menu no longer holds the item this action is gated on."
3991
+ })
3992
+ );
3993
+ });
3994
+ collectBindingGaps(gaps, meta, state.controlMap, slice);
3995
+ collectAutoCallGaps(
3996
+ gaps,
3997
+ meta,
3998
+ meta.autoCalls ?? [],
3999
+ slice,
4000
+ meta.constants ?? {},
4001
+ scope.operationOf,
4002
+ screenBindingOptions(
4003
+ meta,
4004
+ state.controlMap,
4005
+ slice,
4006
+ meta.inputs ?? {},
4007
+ meta.variables ?? {},
4008
+ { allowAlias: false }
4009
+ )
4010
+ );
4011
+ });
4012
+ collectShadowedShapeGaps(gaps, scope);
4013
+ collectResponseGaps(gaps, scope);
4014
+ collectMethodGaps(gaps, scope);
4015
+ collectNavInstanceGaps(gaps, scope);
4016
+ return gaps;
4017
+ };
4018
+
2703
4019
  // apps/m-one-ui/src/app/pages/design/lib/invariant-catalog.ts
2704
4020
  var INVARIANTS = [
2705
4021
  appScaffoldComplete,
@@ -2731,6 +4047,7 @@ var INVARIANTS = [
2731
4047
  filterGroupSqueezeOrphan,
2732
4048
  contextGroupPrimaryUnique,
2733
4049
  functionCaseArgs,
4050
+ outcomeTransformSelfFold,
2734
4051
  handBindingResolves,
2735
4052
  handRequiredInputBound,
2736
4053
  handScreenResolves,
@@ -2751,17 +4068,32 @@ var INVARIANTS = [
2751
4068
  ruleOperandFits,
2752
4069
  themeSelectionResolves,
2753
4070
  timerComplete,
2754
- variantGateSatisfiable
4071
+ variantGateSatisfiable,
4072
+ // Gesture rules, judged on the design as it stands so an edit made outside
4073
+ // the editor meets them too (0128_11).
4074
+ routerOutletPlaced,
4075
+ controlIdUnique,
4076
+ fieldKeyTypeAgrees,
4077
+ submitTargetResolves,
4078
+ formResetResolves,
4079
+ ruleFieldResolves,
4080
+ embedShapeWithinFeature,
4081
+ storeNameReserved,
4082
+ storeMemberNameUnique,
4083
+ functionNameUnshadowed,
4084
+ functionTierFiled,
4085
+ functionRefExclusive,
4086
+ bindingResolvesOutputs
2755
4087
  ];
2756
4088
  var runInvariants = (scope) => INVARIANTS.flatMap((invariant) => invariant.run(scope));
2757
4089
  var invariantScopeOf = (source, themeCatalog) => ({
2758
4090
  appTarget: source.appTarget,
2759
4091
  wcConfig: source.wcConfig,
2760
- features: (0, import_codegen46.featuresAsRead)(
4092
+ features: (0, import_codegen53.featuresAsRead)(
2761
4093
  source.features,
2762
4094
  source.sharedShapes,
2763
4095
  source.screens.map(({ meta, state }) => ({
2764
- ...(0, import_codegen46.isFeatureScreen)(meta) ? { featureId: meta.featureId } : {},
4096
+ ...(0, import_codegen53.isFeatureScreen)(meta) ? { featureId: meta.featureId } : {},
2765
4097
  controlMap: state.controlMap
2766
4098
  }))
2767
4099
  ),
@@ -2783,6 +4115,8 @@ var invariantScopeOf = (source, themeCatalog) => ({
2783
4115
  // Annotate the CommonJS export names for ESM import in node:
2784
4116
  0 && (module.exports = {
2785
4117
  INVARIANTS,
4118
+ codecDrops,
4119
+ collectEmitGaps,
2786
4120
  invariantScopeOf,
2787
4121
  runInvariants
2788
4122
  });