@neocompose/cli 0.77.1 → 0.79.0

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.
@@ -1071,7 +1071,8 @@ var SystemProtectionKind = {
1071
1071
  DialoguePriorityDefault: "dialoguePriorityDefault",
1072
1072
  PolicyImmutable: "policyImmutable",
1073
1073
  PolicyDeleteBlocked: "policyDeleteBlocked",
1074
- ScriptRuntime: "scriptRuntime"
1074
+ ScriptRuntime: "scriptRuntime",
1075
+ SystemPreset: "systemPreset"
1075
1076
  };
1076
1077
  function isWithId(value) {
1077
1078
  return typeof value?.id === "string";
@@ -1088,7 +1089,7 @@ function isEpochMillis(value) {
1088
1089
  return Number.isFinite(value);
1089
1090
  }
1090
1091
  function isSystemProtectionKind(value) {
1091
- return value === SystemProtectionKind.WorldAuthoring || value === SystemProtectionKind.DialogueMemorySchema || value === SystemProtectionKind.DialogueMemoryContainer || value === SystemProtectionKind.DialoguePriorityDefault || value === SystemProtectionKind.PolicyImmutable || value === SystemProtectionKind.PolicyDeleteBlocked || value === SystemProtectionKind.ScriptRuntime;
1092
+ return value === SystemProtectionKind.WorldAuthoring || value === SystemProtectionKind.DialogueMemorySchema || value === SystemProtectionKind.DialogueMemoryContainer || value === SystemProtectionKind.DialoguePriorityDefault || value === SystemProtectionKind.PolicyImmutable || value === SystemProtectionKind.PolicyDeleteBlocked || value === SystemProtectionKind.ScriptRuntime || value === SystemProtectionKind.SystemPreset;
1092
1093
  }
1093
1094
  function isSystemMetadata(value) {
1094
1095
  const v = value;
@@ -1490,6 +1491,7 @@ var MemberKind = /* @__PURE__ */ ((MemberKind7) => {
1490
1491
  MemberKind7[MemberKind7["NSDelegate"] = 25] = "NSDelegate";
1491
1492
  MemberKind7[MemberKind7["NSAction"] = 26] = "NSAction";
1492
1493
  MemberKind7[MemberKind7["Variant"] = 27] = "Variant";
1494
+ MemberKind7[MemberKind7["Set"] = 28] = "Set";
1493
1495
  return MemberKind7;
1494
1496
  })(MemberKind || {});
1495
1497
 
@@ -1504,13 +1506,13 @@ var TAXONOMY = {
1504
1506
  [4 /* Float */]: [1 /* Direct */, BINDABLE, "number", null, 4],
1505
1507
  [5 /* Dictionary */]: [1 /* Direct */, BINDABLE, "collection", null, 11],
1506
1508
  [6 /* List */]: [1 /* Direct */, BINDABLE, "collection", null, 12],
1507
- [7 /* Class */]: [1 /* Direct */, BINDABLE, "class", null, 13],
1508
- [8 /* Enum */]: [1 /* Direct */, BINDABLE, "core", null, 14],
1509
- [9 /* Lookup */]: [1 /* Direct */, STORED, "collection", null, 15],
1510
- [10 /* NSProperty */]: [1 /* Direct */, 0, "code", null, 17],
1511
- [11 /* Sprite */]: [1 /* Direct */, BINDABLE, "core", null, 23],
1512
- [12 /* Audio */]: [1 /* Direct */, BINDABLE, "core", null, 24],
1513
- [13 /* Function */]: [1 /* Direct */, 8 /* Signature */, "code", null, 22],
1509
+ [7 /* Class */]: [1 /* Direct */, BINDABLE, "class", null, 14],
1510
+ [8 /* Enum */]: [1 /* Direct */, BINDABLE, "core", null, 15],
1511
+ [9 /* Lookup */]: [1 /* Direct */, STORED, "collection", null, 16],
1512
+ [10 /* NSProperty */]: [1 /* Direct */, 0, "code", null, 18],
1513
+ [11 /* Sprite */]: [1 /* Direct */, BINDABLE, "core", null, 24],
1514
+ [12 /* Audio */]: [1 /* Direct */, BINDABLE, "core", null, 25],
1515
+ [13 /* Function */]: [1 /* Direct */, 8 /* Signature */, "code", null, 23],
1514
1516
  [14 /* Vector2 */]: [1 /* Direct */, BINDABLE, "vector", 2, 6],
1515
1517
  [15 /* Vector2Int */]: [1 /* Direct */, BINDABLE, "vector", 2, 7],
1516
1518
  [16 /* Vector3 */]: [1 /* Direct */, BINDABLE, "vector", 3, 8],
@@ -1520,7 +1522,7 @@ var TAXONOMY = {
1520
1522
  STORED,
1521
1523
  "collection",
1522
1524
  null,
1523
- 16
1525
+ 17
1524
1526
  ],
1525
1527
  [19 /* Color */]: [1 /* Direct */, BINDABLE, "core", null, 10],
1526
1528
  [20 /* Decimal */]: [1 /* Direct */, BINDABLE, "number", null, 5],
@@ -1537,7 +1539,7 @@ var TAXONOMY = {
1537
1539
  8 /* Signature */,
1538
1540
  "code",
1539
1541
  null,
1540
- 18
1542
+ 19
1541
1543
  ],
1542
1544
  [24 /* FunctionRef */]: [0 /* None */, STORED, null, null, null],
1543
1545
  [25 /* NSDelegate */]: [
@@ -1545,16 +1547,17 @@ var TAXONOMY = {
1545
1547
  STORED | 8 /* Signature */,
1546
1548
  "code",
1547
1549
  null,
1548
- 19
1550
+ 20
1549
1551
  ],
1550
1552
  [26 /* NSAction */]: [
1551
1553
  1 /* Direct */,
1552
1554
  STORED | 8 /* Signature */,
1553
1555
  "code",
1554
1556
  null,
1555
- 20
1557
+ 21
1556
1558
  ],
1557
- [27 /* Variant */]: [1 /* Direct */, STORED, "world", null, 21]
1559
+ [27 /* Variant */]: [1 /* Direct */, STORED, "world", null, 22],
1560
+ [28 /* Set */]: [1 /* Direct */, BINDABLE, "collection", null, 13]
1558
1561
  };
1559
1562
  var ALL_MEMBER_KINDS = [
1560
1563
  0 /* Null */,
@@ -1584,7 +1587,8 @@ var ALL_MEMBER_KINDS = [
1584
1587
  24 /* FunctionRef */,
1585
1588
  25 /* NSDelegate */,
1586
1589
  26 /* NSAction */,
1587
- 27 /* Variant */
1590
+ 27 /* Variant */,
1591
+ 28 /* Set */
1588
1592
  ];
1589
1593
  var DIRECT_MEMBER_KINDS = ALL_MEMBER_KINDS.filter(
1590
1594
  (kind) => TAXONOMY[kind][0] === 1 /* Direct */
@@ -1656,7 +1660,9 @@ var AUTOMATIC_MEMBER_DISTRIBUTION = {
1656
1660
  /** Listener count grows with content. */
1657
1661
  [26 /* NSAction */]: { sparse: "listenerCount" },
1658
1662
  /** Fixed class, variant, and optional bound-row ids. */
1659
- [27 /* Variant */]: 1 /* Packed */
1663
+ [27 /* Variant */]: 1 /* Packed */,
1664
+ /** Entry count grows with content. */
1665
+ [28 /* Set */]: { sparse: "entryCount" }
1660
1666
  };
1661
1667
  function memberKindSupportsDistribution(kind) {
1662
1668
  return memberKindSupportsStorage(kind);
@@ -3012,7 +3018,7 @@ function isNSTypeInfoCollection(value) {
3012
3018
  }
3013
3019
  function isNSTypeInfoCollectionInternal(value, ancestors) {
3014
3020
  if (!isNSTypeInfoBase(value)) return false;
3015
- if (value.type !== 6 /* List */ && value.type !== 5 /* Dictionary */) {
3021
+ if (value.type !== 6 /* List */ && value.type !== 28 /* Set */ && value.type !== 5 /* Dictionary */) {
3016
3022
  return false;
3017
3023
  }
3018
3024
  const v = value;
@@ -3033,6 +3039,11 @@ function isNSTypeInfoCollectionInternal(value, ancestors) {
3033
3039
  if (v.listMemberId.length === 0) return false;
3034
3040
  if (v.type !== 6 /* List */) return false;
3035
3041
  }
3042
+ if (v.setMemberId !== void 0) {
3043
+ if (typeof v.setMemberId !== "string") return false;
3044
+ if (v.setMemberId.length === 0) return false;
3045
+ if (v.type !== 28 /* Set */) return false;
3046
+ }
3036
3047
  return true;
3037
3048
  }
3038
3049
  function isNSTypeInfoLookup(value) {
@@ -3110,7 +3121,7 @@ function typeInfoContainsUnknown(value, ancestors) {
3110
3121
  if (ancestors.has(value)) return true;
3111
3122
  ancestors.add(value);
3112
3123
  try {
3113
- if (value.type === 6 /* List */ || value.type === 5 /* Dictionary */ || value.type === 9 /* Lookup */) {
3124
+ if (value.type === 6 /* List */ || value.type === 28 /* Set */ || value.type === 5 /* Dictionary */ || value.type === 9 /* Lookup */) {
3114
3125
  return typeInfoContainsUnknown(value.entryTypeInfo, ancestors);
3115
3126
  }
3116
3127
  if (value.type === 25 /* NSDelegate */) {
@@ -3766,7 +3777,7 @@ function isNSFunctionCollectionQuery(value) {
3766
3777
  case "TakeWhile":
3767
3778
  return isNSCollectionBoolFunction(info);
3768
3779
  case "SelectMany":
3769
- return isNSFunctionWithReturnType(info.function) && (info.function.typeInfo.type === 6 /* List */ || info.function.typeInfo.type === 9 /* Lookup */) && info.function.typeInfo.required;
3780
+ return isNSFunctionWithReturnType(info.function) && (info.function.typeInfo.type === 6 /* List */ || info.function.typeInfo.type === 28 /* Set */ || info.function.typeInfo.type === 9 /* Lookup */) && info.function.typeInfo.required;
3770
3781
  case "OrderBy":
3771
3782
  case "OrderByDescending":
3772
3783
  return isNSFunctionWithReturnType(info.function) && ["int", "float", "decimal", "string", "bool"].includes(info.keyType);
@@ -3777,6 +3788,8 @@ function isNSFunctionCollectionQuery(value) {
3777
3788
  return isNSPointer(info.otherPointer);
3778
3789
  case "Reverse":
3779
3790
  return true;
3791
+ case "ToSet":
3792
+ return info.reference === void 0 || info.reference === true;
3780
3793
  default:
3781
3794
  return false;
3782
3795
  }
@@ -4127,7 +4140,7 @@ function typeInfosInvariantlyEqual(left, right) {
4127
4140
  if (left.type === 8 /* Enum */ && right.type === 8 /* Enum */) {
4128
4141
  return left.enumId === right.enumId;
4129
4142
  }
4130
- if ((left.type === 6 /* List */ || left.type === 5 /* Dictionary */) && (right.type === 6 /* List */ || right.type === 5 /* Dictionary */)) {
4143
+ if ((left.type === 6 /* List */ || left.type === 28 /* Set */ || left.type === 5 /* Dictionary */) && (right.type === 6 /* List */ || right.type === 28 /* Set */ || right.type === 5 /* Dictionary */)) {
4131
4144
  if (left.keyEnumId !== right.keyEnumId) return false;
4132
4145
  return typeInfosInvariantlyEqual(left.entryTypeInfo, right.entryTypeInfo);
4133
4146
  }
@@ -4529,10 +4542,22 @@ function isListKind(value) {
4529
4542
  function isMemberListBase(value) {
4530
4543
  const v = asMemberBaseForKind(value, 6 /* List */);
4531
4544
  if (v === null) return false;
4532
- if (typeof v.entryMemberId !== "string") return false;
4533
4545
  if (v.listKind !== void 0 && v.listKind !== null && !isListKind(v.listKind)) {
4534
4546
  return false;
4535
4547
  }
4548
+ return hasValidEntryCollectionFields(v);
4549
+ }
4550
+ function isMemberSetBase(value) {
4551
+ const v = asMemberBaseForKind(value, 28 /* Set */);
4552
+ if (v === null) return false;
4553
+ if (v.listKind !== void 0) return false;
4554
+ return hasValidEntryCollectionFields(v);
4555
+ }
4556
+ function isMemberEntryCollectionBase(value) {
4557
+ return isMemberListBase(value) || isMemberSetBase(value);
4558
+ }
4559
+ function hasValidEntryCollectionFields(v) {
4560
+ if (typeof v.entryMemberId !== "string") return false;
4536
4561
  if (v.valueTypeInfo !== void 0 && v.valueTypeInfo !== null && (!isNSTypeInfo(v.valueTypeInfo) || v.valueTypeInfo.type !== 7 /* Class */)) {
4537
4562
  return false;
4538
4563
  }
@@ -4557,14 +4582,21 @@ function isMemberListBase(value) {
4557
4582
  }
4558
4583
  function isMemberList(value) {
4559
4584
  if (!isMemberListBase(value)) return false;
4560
- if (!isWithId(value)) return false;
4561
4585
  return isWithId(value);
4562
4586
  }
4587
+ function isMemberSet(value) {
4588
+ if (!isMemberSetBase(value)) return false;
4589
+ return isWithId(value);
4590
+ }
4591
+ function isMemberEntryCollection(value) {
4592
+ return isMemberList(value) || isMemberSet(value);
4593
+ }
4563
4594
  function listKindOf(member) {
4595
+ if (member.kind === 28 /* Set */) return 0 /* Ordered */;
4564
4596
  return member.listKind ?? 0 /* Ordered */;
4565
4597
  }
4566
4598
  function isMemberWithEntries(value) {
4567
- return isMemberListBase(value) || isMemberDictionaryBase(value);
4599
+ return isMemberEntryCollectionBase(value) || isMemberDictionaryBase(value);
4568
4600
  }
4569
4601
  function isMemberClassBase(value) {
4570
4602
  const v = asMemberBaseForKind(value, 7 /* Class */);
@@ -5091,7 +5123,7 @@ function isMemberBase(value) {
5091
5123
  if (payload !== void 0 && v?.kind !== 7 /* Class */ && v?.kind !== 21 /* Generic */) {
5092
5124
  return false;
5093
5125
  }
5094
- const matchesConcreteType = isMemberNullBase(value) || isMemberBoolBase(value) || isMemberIntBase(value) || isMemberStringBase(value) || isMemberFloatBase(value) || isMemberDictionaryBase(value) || isMemberListBase(value) || isMemberClassBase(value) || isMemberEnumBase(value) || isMemberLookupBase(value) || isMemberDialogueLookupBase(value) || isMemberNSPropertyBase(value) || isMemberNSPropertyContractBase(value) || isMemberSpriteBase(value) || isMemberAudioBase(value) || isMemberFunctionBase(value) || isMemberNSFunctionBase(value) || isMemberNSFunction(value) || isMemberDelegateBase(value) || isMemberActionBase(value) || isMemberFunctionRefBase(value) || isMemberVariantBase(value) || isMemberVector2Base(value) || isMemberVector2IntBase(value) || isMemberVector3Base(value) || isMemberVector3IntBase(value) || isMemberColorBase(value) || isMemberDecimalBase(value) || isMemberGenericBase(value);
5126
+ const matchesConcreteType = isMemberNullBase(value) || isMemberBoolBase(value) || isMemberIntBase(value) || isMemberStringBase(value) || isMemberFloatBase(value) || isMemberDictionaryBase(value) || isMemberListBase(value) || isMemberSetBase(value) || isMemberClassBase(value) || isMemberEnumBase(value) || isMemberLookupBase(value) || isMemberDialogueLookupBase(value) || isMemberNSPropertyBase(value) || isMemberNSPropertyContractBase(value) || isMemberSpriteBase(value) || isMemberAudioBase(value) || isMemberFunctionBase(value) || isMemberNSFunctionBase(value) || isMemberNSFunction(value) || isMemberDelegateBase(value) || isMemberActionBase(value) || isMemberFunctionRefBase(value) || isMemberVariantBase(value) || isMemberVector2Base(value) || isMemberVector2IntBase(value) || isMemberVector3Base(value) || isMemberVector3IntBase(value) || isMemberColorBase(value) || isMemberDecimalBase(value) || isMemberGenericBase(value);
5095
5127
  if (!matchesConcreteType) return false;
5096
5128
  if (!isValidDocsText(v?.docsText)) return false;
5097
5129
  if (typeof v?.name !== "string") return false;
@@ -5503,7 +5535,7 @@ var ProjectSchemaIndex = class {
5503
5535
  for (const member of source.members) {
5504
5536
  this.membersById.set(member.id, member);
5505
5537
  append(this.membersByName, member.name, member);
5506
- if (isMemberList(member) || isMemberDictionary(member)) {
5538
+ if (isMemberEntryCollection(member) || isMemberDictionary(member)) {
5507
5539
  append(
5508
5540
  this.containerMemberIdsByEntryId,
5509
5541
  member.entryMemberId,
@@ -6591,7 +6623,7 @@ var WORLD_SYSTEM_CLASS_DEFINITIONS = [
6591
6623
  {
6592
6624
  classId: "system_fb9c4080-0148-530e-b9c0-8cd1c17ff8e7",
6593
6625
  name: "NeoCellPattern",
6594
- docsText: "An immutable ordered pattern of cell offsets, relative to an origin.\nHand-built patterns preserve order and duplicates; factories order cells nearest first.",
6626
+ docsText: "An ordered pattern of cell offsets, relative to an origin.\nHand-built patterns preserve order and duplicates; factories order cells nearest first.",
6595
6627
  modifier: 2 /* Sealed */,
6596
6628
  constructorIds: ["system_f68684d6-6ea0-5d57-9f96-d544b17bf369"],
6597
6629
  constructors: [
@@ -6630,63 +6662,55 @@ var WORLD_SYSTEM_CLASS_DEFINITIONS = [
6630
6662
  },
6631
6663
  {
6632
6664
  memberId: "system_d90a6e51-0b1e-5354-b4e2-ad4155a833f1",
6633
- memberKind: "computed",
6665
+ memberKind: "class",
6666
+ protection: SystemProtectionKind.SystemPreset,
6634
6667
  modifier: 3 /* Static */,
6668
+ storage: 1 /* Immutable */,
6669
+ staticInitializerCode: "new NeoCellPattern(offsets: [new(0, 0)])",
6635
6670
  docsText: "Only the origin cell.",
6636
- returnTypeInfo: {
6637
- type: 7,
6638
- required: true,
6639
- classId: "system_fb9c4080-0148-530e-b9c0-8cd1c17ff8e7"
6640
- },
6641
- code: "return new NeoCellPattern(offsets: [new(0, 0)]);",
6671
+ schemaClassWorldKind: "cellPattern",
6642
6672
  requirement: 1 /* Required */,
6643
6673
  schemaKey: "Center"
6644
6674
  },
6645
6675
  {
6646
6676
  memberId: "system_57290d57-16dd-54d6-ad1e-81a72bd7f457",
6647
- memberKind: "computed",
6677
+ memberKind: "class",
6678
+ protection: SystemProtectionKind.SystemPreset,
6648
6679
  modifier: 3 /* Static */,
6680
+ storage: 1 /* Immutable */,
6681
+ staticInitializerCode: "NeoCellPattern.Cross(1, null, .Center)",
6649
6682
  docsText: "The four edge-adjacent cells, excluding the origin.",
6650
- returnTypeInfo: {
6651
- type: 7,
6652
- required: true,
6653
- classId: "system_fb9c4080-0148-530e-b9c0-8cd1c17ff8e7"
6654
- },
6655
- code: "return NeoCellPattern.Cross(1, null, .Center);",
6683
+ schemaClassWorldKind: "cellPattern",
6656
6684
  requirement: 1 /* Required */,
6657
6685
  schemaKey: "FourNeighbors"
6658
6686
  },
6659
6687
  {
6660
6688
  memberId: "system_a8f2f798-7988-5df8-8294-decdd4316c7e",
6661
- memberKind: "computed",
6689
+ memberKind: "class",
6690
+ protection: SystemProtectionKind.SystemPreset,
6662
6691
  modifier: 3 /* Static */,
6692
+ storage: 1 /* Immutable */,
6693
+ staticInitializerCode: "NeoCellPattern.Box(1, null, .Center)",
6663
6694
  docsText: "The eight surrounding cells, excluding the origin.",
6664
- returnTypeInfo: {
6665
- type: 7,
6666
- required: true,
6667
- classId: "system_fb9c4080-0148-530e-b9c0-8cd1c17ff8e7"
6668
- },
6669
- code: "return NeoCellPattern.Box(1, null, .Center);",
6695
+ schemaClassWorldKind: "cellPattern",
6670
6696
  requirement: 1 /* Required */,
6671
6697
  schemaKey: "EightNeighbors"
6672
6698
  },
6673
6699
  {
6674
6700
  memberId: "system_98d035f6-9f7d-5d2b-ae01-70ce90621333",
6675
- memberKind: "computed",
6701
+ memberKind: "class",
6702
+ protection: SystemProtectionKind.SystemPreset,
6676
6703
  modifier: 3 /* Static */,
6704
+ storage: 1 /* Immutable */,
6705
+ staticInitializerCode: "new NeoCellPattern(offsets: [])",
6677
6706
  docsText: "No cells.",
6678
- returnTypeInfo: {
6679
- type: 7,
6680
- required: true,
6681
- classId: "system_fb9c4080-0148-530e-b9c0-8cd1c17ff8e7"
6682
- },
6683
- code: "return new NeoCellPattern(offsets: []);",
6707
+ schemaClassWorldKind: "cellPattern",
6684
6708
  requirement: 1 /* Required */,
6685
6709
  schemaKey: "Empty"
6686
6710
  },
6687
6711
  {
6688
6712
  memberId: "system_aaad2df6-e31e-5f5d-95b9-e265211faed5",
6689
- memberKind: "function",
6713
+ memberKind: "nsFunction",
6690
6714
  modifier: 3 /* Static */,
6691
6715
  docsText: "A filled rectangle of offsets. Omitting radiusY uses radiusX on both axes.",
6692
6716
  returnTypeInfo: {
@@ -6713,11 +6737,12 @@ var WORLD_SYSTEM_CLASS_DEFINITIONS = [
6713
6737
  }
6714
6738
  ],
6715
6739
  dispatch: 0 /* Synchronous */,
6740
+ code: 'int y = radiusY ?? radiusX;\nif (radiusX < 0 || y < 0) {\n throw $"Box radii must be non-negative; got {radiusX}, {y}.";\n}\nreturn NeoCellPattern.Shells(-radiusX, radiusX, -y, y, excluding == NeoCellPatternExcluding.Center ? 1 : 0);',
6716
6741
  schemaKey: "Box"
6717
6742
  },
6718
6743
  {
6719
6744
  memberId: "system_df8ebca6-a1d1-57c1-8762-227943fc51d8",
6720
- memberKind: "function",
6745
+ memberKind: "nsFunction",
6721
6746
  modifier: 3 /* Static */,
6722
6747
  docsText: "Axis-aligned offsets. Omitting radiusY uses radiusX on both axes.",
6723
6748
  returnTypeInfo: {
@@ -6744,11 +6769,12 @@ var WORLD_SYSTEM_CLASS_DEFINITIONS = [
6744
6769
  }
6745
6770
  ],
6746
6771
  dispatch: 0 /* Synchronous */,
6772
+ code: 'int y = radiusY ?? radiusX;\nif (radiusX < 0 || y < 0) {\n throw $"Cross radii must be non-negative; got {radiusX}, {y}.";\n}\nList<Vector2Int> cells = [];\nif (excluding == NeoCellPatternExcluding.None) {\n cells.Add(new(0, 0));\n}\nfor (int distance = 1; distance <= Math.Max(radiusX, y); distance++) {\n if (distance <= radiusX) {\n cells.Add(new(-distance, 0));\n cells.Add(new(distance, 0));\n }\n if (distance <= y) {\n cells.Add(new(0, -distance));\n cells.Add(new(0, distance));\n }\n}\nreturn new NeoCellPattern(offsets: cells);',
6747
6773
  schemaKey: "Cross"
6748
6774
  },
6749
6775
  {
6750
6776
  memberId: "system_82222600-f67f-5127-bb2d-278381b4ef2f",
6751
- memberKind: "function",
6777
+ memberKind: "nsFunction",
6752
6778
  modifier: 3 /* Static */,
6753
6779
  docsText: "The square ring at the given Chebyshev radius. Zero returns the center.",
6754
6780
  returnTypeInfo: {
@@ -6758,11 +6784,12 @@ var WORLD_SYSTEM_CLASS_DEFINITIONS = [
6758
6784
  },
6759
6785
  argumentTypes: [{ name: "radius", type: 2, required: true }],
6760
6786
  dispatch: 0 /* Synchronous */,
6787
+ code: 'if (radius < 0) {\n throw $"Ring radius must be non-negative; got {radius}.";\n}\nreturn NeoCellPattern.Shells(-radius, radius, -radius, radius, radius);',
6761
6788
  schemaKey: "Ring"
6762
6789
  },
6763
6790
  {
6764
6791
  memberId: "system_d803cfd5-ce53-57da-abc2-7cd69befeb01",
6765
- memberKind: "function",
6792
+ memberKind: "nsFunction",
6766
6793
  modifier: 3 /* Static */,
6767
6794
  docsText: "Cells from the origin through size minus one. Both dimensions must be positive.",
6768
6795
  returnTypeInfo: {
@@ -6772,11 +6799,12 @@ var WORLD_SYSTEM_CLASS_DEFINITIONS = [
6772
6799
  },
6773
6800
  argumentTypes: [{ name: "size", type: 15, required: true }],
6774
6801
  dispatch: 0 /* Synchronous */,
6802
+ code: 'if (size.x < 1 || size.y < 1) {\n throw $"Rect size must be positive; got {size.x}, {size.y}.";\n}\nreturn NeoCellPattern.Shells(0, size.x - 1, 0, size.y - 1, 0);',
6775
6803
  schemaKey: "Rect"
6776
6804
  },
6777
6805
  {
6778
6806
  memberId: "system_ef0d4cbb-7182-5d93-9bb8-60a5a18f81a5",
6779
- memberKind: "function",
6807
+ memberKind: "nsFunction",
6780
6808
  modifier: 3 /* Static */,
6781
6809
  docsText: "Offsets from the origin through length steps in direction. Center excludes only the origin.",
6782
6810
  returnTypeInfo: {
@@ -6798,6 +6826,7 @@ var WORLD_SYSTEM_CLASS_DEFINITIONS = [
6798
6826
  }
6799
6827
  ],
6800
6828
  dispatch: 0 /* Synchronous */,
6829
+ code: 'if (direction.x == 0 && direction.y == 0) {\n throw "Line direction must be non-zero.";\n}\nif (length < 0) {\n throw $"Line length must be non-negative; got {length}.";\n}\nList<Vector2Int> cells = [];\nif (excluding == NeoCellPatternExcluding.None) {\n cells.Add(new(0, 0));\n}\nfor (int step = 1; step <= length; step++) {\n cells.Add(new(direction.x * step, direction.y * step));\n}\nreturn new NeoCellPattern(offsets: cells);',
6801
6830
  schemaKey: "Line"
6802
6831
  },
6803
6832
  {
@@ -6880,6 +6909,28 @@ var WORLD_SYSTEM_CLASS_DEFINITIONS = [
6880
6909
  ],
6881
6910
  dispatch: 0 /* Synchronous */,
6882
6911
  schemaKey: "Union"
6912
+ },
6913
+ {
6914
+ memberId: "system_faf10f4f-f5c2-47d8-b4e2-8f196c756668",
6915
+ memberKind: "nsFunction",
6916
+ access: 2 /* Private */,
6917
+ modifier: 3 /* Static */,
6918
+ docsText: "Square shells firstShell through the rectangle's Chebyshev radius, each clipped to the rectangle.\nA shell runs left column, then bottom/top pairs by x, then right column.",
6919
+ returnTypeInfo: {
6920
+ type: 7,
6921
+ required: true,
6922
+ classId: "system_fb9c4080-0148-530e-b9c0-8cd1c17ff8e7"
6923
+ },
6924
+ argumentTypes: [
6925
+ { name: "minX", type: 2, required: true },
6926
+ { name: "maxX", type: 2, required: true },
6927
+ { name: "minY", type: 2, required: true },
6928
+ { name: "maxY", type: 2, required: true },
6929
+ { name: "firstShell", type: 2, required: true }
6930
+ ],
6931
+ dispatch: 0 /* Synchronous */,
6932
+ code: "List<Vector2Int> cells = [];\nint radius = Math.Max(Math.Max(-minX, maxX), Math.Max(-minY, maxY));\nfor (int shell = firstShell; shell <= radius; shell++) {\n int firstY = Math.Max(minY, -shell);\n int lastY = Math.Min(maxY, shell);\n if (shell == 0) {\n if (minX <= 0 && maxX >= 0 && firstY <= lastY) {\n cells.Add(new(0, 0));\n }\n } else if (firstY <= lastY) {\n if (-shell >= minX && -shell <= maxX) {\n for (int y = firstY; y <= lastY; y++) {\n cells.Add(new(-shell, y));\n }\n }\n bool bottom = -shell >= minY && -shell <= maxY;\n bool top = shell >= minY && shell <= maxY;\n if (bottom || top) {\n for (int x = Math.Max(minX, -shell + 1); x <= Math.Min(maxX, shell - 1); x++) {\n if (bottom) {\n cells.Add(new(x, -shell));\n }\n if (top) {\n cells.Add(new(x, shell));\n }\n }\n }\n if (shell >= minX && shell <= maxX) {\n for (int y = firstY; y <= lastY; y++) {\n cells.Add(new(shell, y));\n }\n }\n }\n}\nreturn new NeoCellPattern(offsets: cells);",
6933
+ schemaKey: "Shells"
6883
6934
  }
6884
6935
  ],
6885
6936
  supportingFields: [
@@ -7348,7 +7399,7 @@ var WORLD_SYSTEM_CLASS_DEFINITIONS = [
7348
7399
  {
7349
7400
  memberId: "system_f5ca386c-990c-54a1-8473-2d49d2cd887d",
7350
7401
  memberKind: "function",
7351
- docsText: "Objects at the cells around this placement, in pattern order. Use GetObjects<T>(pattern) to filter by class. A repeated footprint can appear more than once.",
7402
+ docsText: "Objects at the cells around this placement, shifted by offset, in pattern order. Use GetObjects<T>(pattern, offset) to filter by class. A repeated footprint can appear more than once.",
7352
7403
  returnTypeInfo: {
7353
7404
  type: 6,
7354
7405
  required: true,
@@ -7364,6 +7415,12 @@ var WORLD_SYSTEM_CLASS_DEFINITIONS = [
7364
7415
  type: 7,
7365
7416
  required: true,
7366
7417
  classId: "system_fb9c4080-0148-530e-b9c0-8cd1c17ff8e7"
7418
+ },
7419
+ {
7420
+ name: "offset",
7421
+ type: 15,
7422
+ required: false,
7423
+ defaultValue: { value: null }
7367
7424
  }
7368
7425
  ],
7369
7426
  dispatch: 0 /* Synchronous */,
@@ -7372,7 +7429,7 @@ var WORLD_SYSTEM_CLASS_DEFINITIONS = [
7372
7429
  {
7373
7430
  memberId: "system_593e6208-e2ca-505e-9933-04b17102b6d2",
7374
7431
  memberKind: "function",
7375
- docsText: "The first tile found in pattern order around this placement, or null. Each cell uses the grid layer precedence.",
7432
+ docsText: "The first tile found in pattern order around this placement, shifted by offset, or null. Each cell uses the grid layer precedence.",
7376
7433
  returnTypeInfo: {
7377
7434
  type: 7,
7378
7435
  required: false,
@@ -7384,10 +7441,46 @@ var WORLD_SYSTEM_CLASS_DEFINITIONS = [
7384
7441
  type: 7,
7385
7442
  required: true,
7386
7443
  classId: "system_fb9c4080-0148-530e-b9c0-8cd1c17ff8e7"
7444
+ },
7445
+ {
7446
+ name: "offset",
7447
+ type: 15,
7448
+ required: false,
7449
+ defaultValue: { value: null }
7387
7450
  }
7388
7451
  ],
7389
7452
  dispatch: 0 /* Synchronous */,
7390
7453
  schemaKey: "GetTile"
7454
+ },
7455
+ {
7456
+ memberId: "system_5a41d36a-bcd9-4867-9e46-d743f6e09582",
7457
+ memberKind: "function",
7458
+ docsText: "The tiles at the cells around this placement, shifted by offset, in pattern order. Each cell uses the grid layer precedence and empty cells are skipped.",
7459
+ returnTypeInfo: {
7460
+ type: 6,
7461
+ required: true,
7462
+ entryTypeInfo: {
7463
+ type: 7,
7464
+ required: true,
7465
+ classId: "system_d7fa161b-b269-4bf1-9ec9-3aebec67e6e0"
7466
+ }
7467
+ },
7468
+ argumentTypes: [
7469
+ {
7470
+ name: "pattern",
7471
+ type: 7,
7472
+ required: true,
7473
+ classId: "system_fb9c4080-0148-530e-b9c0-8cd1c17ff8e7"
7474
+ },
7475
+ {
7476
+ name: "offset",
7477
+ type: 15,
7478
+ required: false,
7479
+ defaultValue: { value: null }
7480
+ }
7481
+ ],
7482
+ dispatch: 0 /* Synchronous */,
7483
+ schemaKey: "GetTiles"
7391
7484
  }
7392
7485
  ],
7393
7486
  supportingFields: [
@@ -8991,9 +9084,9 @@ function openBindingTypeInfo(member, env, classes, members) {
8991
9084
  ...Object.keys(typeArguments).length === 0 ? {} : { typeArguments }
8992
9085
  };
8993
9086
  }
8994
- if (isMemberListBase(resolved)) {
9087
+ if (isMemberEntryCollectionBase(resolved)) {
8995
9088
  return {
8996
- type: 6 /* List */,
9089
+ type: resolved.kind,
8997
9090
  required,
8998
9091
  entryTypeInfo: nested(resolved.entryMemberId)
8999
9092
  };
@@ -9019,7 +9112,7 @@ function callableBindingMember(memberId, slotName, members) {
9019
9112
  }
9020
9113
  function mapGenericTypeInfo(typeInfo, close) {
9021
9114
  if (typeInfo.type === 21 /* Generic */) return close(typeInfo);
9022
- if (typeInfo.type === 6 /* List */ || typeInfo.type === 5 /* Dictionary */ || typeInfo.type === 9 /* Lookup */) {
9115
+ if (typeInfo.type === 6 /* List */ || typeInfo.type === 28 /* Set */ || typeInfo.type === 5 /* Dictionary */ || typeInfo.type === 9 /* Lookup */) {
9023
9116
  return {
9024
9117
  ...typeInfo,
9025
9118
  entryTypeInfo: mapGenericTypeInfo(typeInfo.entryTypeInfo, close)
@@ -9102,6 +9195,14 @@ function typeInfoFromArgumentSignature(signature) {
9102
9195
  entryTypeInfo: typeInfoFromArgumentSignature(listSignature.entry)
9103
9196
  };
9104
9197
  }
9198
+ if (signature.type === 28 /* Set */) {
9199
+ const setSignature = signature;
9200
+ return {
9201
+ type: 28 /* Set */,
9202
+ required: setSignature.required,
9203
+ entryTypeInfo: typeInfoFromArgumentSignature(setSignature.entry)
9204
+ };
9205
+ }
9105
9206
  if (signature.type === 5 /* Dictionary */) {
9106
9207
  const dictionarySignature = signature;
9107
9208
  return {
@@ -9198,6 +9299,13 @@ function typeArgumentSignatureOfMember(member, env, members, seen = /* @__PURE__
9198
9299
  entry: entrySignature(resolved.entryMemberId, env, members, seen)
9199
9300
  };
9200
9301
  }
9302
+ if (isMemberSetBase(resolved)) {
9303
+ return {
9304
+ type: 28 /* Set */,
9305
+ required,
9306
+ entry: entrySignature(resolved.entryMemberId, env, members, seen)
9307
+ };
9308
+ }
9201
9309
  if (isMemberDictionaryBase(resolved)) {
9202
9310
  return {
9203
9311
  type: 5 /* Dictionary */,
@@ -9301,6 +9409,11 @@ function signaturesEqual(a, b) {
9301
9409
  if (al.listKind !== bl.listKind) return false;
9302
9410
  return signaturesEqual(al.entry, bl.entry);
9303
9411
  }
9412
+ if (a.type === 28 /* Set */ && b.type === 28 /* Set */) {
9413
+ const as = a;
9414
+ const bs = b;
9415
+ return signaturesEqual(as.entry, bs.entry);
9416
+ }
9304
9417
  if (a.type === 5 /* Dictionary */ && b.type === 5 /* Dictionary */) {
9305
9418
  const ad = a;
9306
9419
  const bd = b;
@@ -9664,7 +9777,7 @@ function valueSettlesConstruction(member, body, context, path, storedRow = false
9664
9777
  const value = body.value;
9665
9778
  if (value == null) return !isRequiredMember(member);
9666
9779
  const isClass = isMemberClassBase(member);
9667
- const isCollection = isMemberListBase(member) || isMemberDictionaryBase(member);
9780
+ const isCollection = isMemberWithEntries(member);
9668
9781
  if (!isClass && !isCollection) return true;
9669
9782
  if (isClass && member.payload === 1 /* Partial */) return true;
9670
9783
  if (typeof value !== "object") return false;
@@ -9844,6 +9957,40 @@ var UNITY_TEXTURE_2D_OVERRIDE_PATHS = /* @__PURE__ */ new Set([
9844
9957
  "compressionQuality",
9845
9958
  "crunchedCompression",
9846
9959
  "platformSettings",
9960
+ "platformSettings.default.maxTextureSize",
9961
+ "platformSettings.default.resizeAlgorithm",
9962
+ "platformSettings.default.format",
9963
+ "platformSettings.default.textureCompression",
9964
+ "platformSettings.default.crunchedCompression",
9965
+ "platformSettings.default.compressionQuality",
9966
+ "platformSettings.standalone.override",
9967
+ "platformSettings.standalone.maxTextureSize",
9968
+ "platformSettings.standalone.resizeAlgorithm",
9969
+ "platformSettings.standalone.format",
9970
+ "platformSettings.standalone.textureCompression",
9971
+ "platformSettings.standalone.crunchedCompression",
9972
+ "platformSettings.standalone.compressionQuality",
9973
+ "platformSettings.web.override",
9974
+ "platformSettings.web.maxTextureSize",
9975
+ "platformSettings.web.resizeAlgorithm",
9976
+ "platformSettings.web.format",
9977
+ "platformSettings.web.textureCompression",
9978
+ "platformSettings.web.crunchedCompression",
9979
+ "platformSettings.web.compressionQuality",
9980
+ "spriteSettings.pivotAlignment",
9981
+ "spriteSettings.pivot.x",
9982
+ "spriteSettings.pivot.y",
9983
+ "spriteSettings.generatePhysicsShape",
9984
+ "normalMapSettings.createFromGrayscale",
9985
+ "normalMapSettings.bumpiness",
9986
+ "normalMapSettings.filtering",
9987
+ "normalMapSettings.flipGreenChannel",
9988
+ "cookieSettings.lightType",
9989
+ "singleChannelSettings.component",
9990
+ "swizzle.r",
9991
+ "swizzle.g",
9992
+ "swizzle.b",
9993
+ "swizzle.a",
9847
9994
  "spriteSettings",
9848
9995
  "spriteSettings.spriteMode",
9849
9996
  "spriteSettings.pixelsPerUnit",
@@ -10752,7 +10899,7 @@ function storedLeafFieldIssueMessage(issue) {
10752
10899
  }
10753
10900
  function* storedValueChildEntries(args) {
10754
10901
  const entryMemberId = args.member.entryMemberId;
10755
- if (args.member.kind === 6 /* List */ && typeof entryMemberId === "string") {
10902
+ if ((args.member.kind === 6 /* List */ || args.member.kind === 28 /* Set */) && typeof entryMemberId === "string") {
10756
10903
  const ids = args.member.listKind === 1 /* Unordered */ && args.unorderedValueIds !== void 0 ? args.unorderedValueIds : Array.isArray(args.body) ? args.body : [];
10757
10904
  let pathIndex = 0;
10758
10905
  for (const valueId of ids) {
@@ -11000,7 +11147,7 @@ function isConstantMember(document2, resolved, reads) {
11000
11147
  if (fixedness === 0 /* Writable */) return false;
11001
11148
  const declared = resolved.defaultValue;
11002
11149
  if (declared == null) return false;
11003
- if (fixedness === 1 /* ReadOnly */ && (isMemberListBase(resolved) || isMemberDictionaryBase(resolved)))
11150
+ if (fixedness === 1 /* ReadOnly */ && isMemberWithEntries(resolved))
11004
11151
  return false;
11005
11152
  return !declarationVaries(
11006
11153
  {
@@ -11081,7 +11228,7 @@ function declarationVaries(walk, member, body, rowId, scope) {
11081
11228
  }
11082
11229
  return owned !== Object.keys(value).length;
11083
11230
  }
11084
- if (isMemberListBase(member)) {
11231
+ if (isMemberEntryCollectionBase(member)) {
11085
11232
  if (rowId !== null && listKindOf(member) === 1 /* Unordered */)
11086
11233
  walk.reads?.containerIds.add(rowId);
11087
11234
  const entryIds = listKindOf(member) !== 1 /* Unordered */ ? value : rowId === null ? [] : document2.unorderedListEntryIds?.(rowId) ?? (walk.membership ??= buildUnorderedListMembershipIndex(
@@ -11134,7 +11281,7 @@ function typeHoldsWritable(walk, member, fixedness) {
11134
11281
  }
11135
11282
  return false;
11136
11283
  }
11137
- if (isMemberListBase(member) || isMemberDictionaryBase(member)) {
11284
+ if (isMemberWithEntries(member)) {
11138
11285
  const entryMember = resolvedInDocument(
11139
11286
  walk.document,
11140
11287
  findMemberInDocument(walk.document, member.entryMemberId)
@@ -11481,7 +11628,7 @@ function buildDefaultMemberValueCore(args, resolvedMember) {
11481
11628
  recordStorageKeyDeclaration(args.storageKeyDeclarations, value2.id, member);
11482
11629
  return value2;
11483
11630
  }
11484
- if (isMemberListBase(member)) {
11631
+ if (isMemberEntryCollectionBase(member)) {
11485
11632
  const list = cloneDefaultListRecord({
11486
11633
  document: args.document,
11487
11634
  projectId: args.projectId,
@@ -11949,7 +12096,7 @@ function cloneDefaultValueForMemberCore(args, sourceValue) {
11949
12096
  value: record4,
11950
12097
  classId: effectiveClassId !== member.classId || sourceValue.constructorArgs != null || anchorsParentClassPartition ? effectiveClassId : void 0
11951
12098
  };
11952
- } else if (isMemberListBase(member)) {
12099
+ } else if (isMemberEntryCollectionBase(member)) {
11953
12100
  body = cloneDefaultListRecord({
11954
12101
  document: args.document,
11955
12102
  projectId: args.projectId,
@@ -11990,7 +12137,7 @@ function cloneDefaultValueForMemberCore(args, sourceValue) {
11990
12137
  value.sourceValueId = sourceValue.sourceValueId ?? sourceValue.id;
11991
12138
  if (sourceValue.genericBindings != null) {
11992
12139
  value.genericBindings = { ...sourceValue.genericBindings };
11993
- } else if (isMemberListBase(member) || isMemberDictionaryBase(member)) {
12140
+ } else if (isMemberWithEntries(member)) {
11994
12141
  stampGenericBindings(value, member, args);
11995
12142
  }
11996
12143
  args.createdValues.push(value);
@@ -12366,12 +12513,12 @@ function validateListIndexDefinitions(ctx, listMember) {
12366
12513
  let list;
12367
12514
  try {
12368
12515
  const resolved = resolveMember(listMember, ctx.members);
12369
- if (!isMemberListBase(resolved)) return errors;
12516
+ if (!isMemberEntryCollectionBase(resolved)) return errors;
12370
12517
  list = resolved;
12371
12518
  } catch (error) {
12372
12519
  errors.push({
12373
12520
  memberId: listMember.id,
12374
- message: `List member "${listMember.name}" (${listMember.id}) cannot resolve its inheritance chain: ${errorMessage(error)}.`
12521
+ message: `${MemberKind[listMember.kind]} member "${listMember.name}" (${listMember.id}) cannot resolve its inheritance chain: ${errorMessage(error)}.`
12375
12522
  });
12376
12523
  return errors;
12377
12524
  }
@@ -12383,7 +12530,7 @@ function validateListIndexDefinitions(ctx, listMember) {
12383
12530
  if (entryRecord === void 0) {
12384
12531
  errors.push({
12385
12532
  memberId: listMember.id,
12386
- message: `Indexed List member "${listMember.name}" (${listMember.id}) references missing entry member "${list.entryMemberId}".`
12533
+ message: `Indexed ${MemberKind[listMember.kind]} member "${listMember.name}" (${listMember.id}) references missing entry member "${list.entryMemberId}".`
12387
12534
  });
12388
12535
  return errors;
12389
12536
  }
@@ -12393,14 +12540,14 @@ function validateListIndexDefinitions(ctx, listMember) {
12393
12540
  } catch (error) {
12394
12541
  errors.push({
12395
12542
  memberId: listMember.id,
12396
- message: `Indexed List member "${listMember.name}" (${listMember.id}) cannot resolve entry member "${list.entryMemberId}": ${errorMessage(error)}.`
12543
+ message: `Indexed ${MemberKind[listMember.kind]} member "${listMember.name}" (${listMember.id}) cannot resolve entry member "${list.entryMemberId}": ${errorMessage(error)}.`
12397
12544
  });
12398
12545
  return errors;
12399
12546
  }
12400
12547
  if (!isMemberClassBase(entry)) {
12401
12548
  errors.push({
12402
12549
  memberId: listMember.id,
12403
- message: `Indexed List member "${listMember.name}" (${listMember.id}) must have a Class entry member; "${entry.name}" has kind ${MemberKind[entry.kind]}.`
12550
+ message: `Indexed ${MemberKind[listMember.kind]} member "${listMember.name}" (${listMember.id}) must have a Class entry member; "${entry.name}" has kind ${MemberKind[entry.kind]}.`
12404
12551
  });
12405
12552
  return errors;
12406
12553
  }
@@ -12410,7 +12557,7 @@ function validateListIndexDefinitions(ctx, listMember) {
12410
12557
  if (entryClass === void 0) {
12411
12558
  errors.push({
12412
12559
  memberId: listMember.id,
12413
- message: `Indexed List member "${listMember.name}" (${listMember.id}) references missing entry class "${entry.classId}".`
12560
+ message: `Indexed ${MemberKind[listMember.kind]} member "${listMember.name}" (${listMember.id}) references missing entry class "${entry.classId}".`
12414
12561
  });
12415
12562
  return errors;
12416
12563
  }
@@ -12433,7 +12580,7 @@ function validateListIndexDefinitions(ctx, listMember) {
12433
12580
  errors.push({
12434
12581
  memberId: listMember.id,
12435
12582
  schemaKey: definition.schemaKey,
12436
- message: `List index "${definition.schemaKey}" on "${listMember.name}" (${listMember.id}) does not resolve on entry class "${runtimeClass.name}" (${runtimeClass.id}).`
12583
+ message: `${MemberKind[listMember.kind]} index "${definition.schemaKey}" on "${listMember.name}" (${listMember.id}) does not resolve on entry class "${runtimeClass.name}" (${runtimeClass.id}).`
12437
12584
  });
12438
12585
  continue;
12439
12586
  }
@@ -12442,7 +12589,7 @@ function validateListIndexDefinitions(ctx, listMember) {
12442
12589
  errors.push({
12443
12590
  memberId: listMember.id,
12444
12591
  schemaKey: definition.schemaKey,
12445
- message: `List index "${definition.schemaKey}" on "${listMember.name}" (${listMember.id}) is invalid for entry class "${runtimeClass.name}" (${runtimeClass.id}): ${domain.error}.`
12592
+ message: `${MemberKind[listMember.kind]} index "${definition.schemaKey}" on "${listMember.name}" (${listMember.id}) is invalid for entry class "${runtimeClass.name}" (${runtimeClass.id}): ${domain.error}.`
12446
12593
  });
12447
12594
  continue;
12448
12595
  }
@@ -12454,7 +12601,7 @@ function validateListIndexDefinitions(ctx, listMember) {
12454
12601
  errors.push({
12455
12602
  memberId: listMember.id,
12456
12603
  schemaKey: definition.schemaKey,
12457
- message: `List index "${definition.schemaKey}" on "${listMember.name}" (${listMember.id}) changes key domain on entry subclass "${runtimeClass.name}" (${runtimeClass.id}); every runtime subclass must resolve the same String or Enum domain.`
12604
+ message: `${MemberKind[listMember.kind]} index "${definition.schemaKey}" on "${listMember.name}" (${listMember.id}) changes key domain on entry subclass "${runtimeClass.name}" (${runtimeClass.id}); every runtime subclass must resolve the same String or Enum domain.`
12458
12605
  });
12459
12606
  }
12460
12607
  }
@@ -12465,7 +12612,7 @@ function resolveListIndexDefinitions(ctx, listMember) {
12465
12612
  const errors = validateListIndexDefinitions(ctx, listMember);
12466
12613
  if (errors.length > 0) throw new Error(errors[0].message);
12467
12614
  const list = resolveMember(listMember, ctx.members);
12468
- if (!isMemberListBase(list)) return [];
12615
+ if (!isMemberEntryCollectionBase(list)) return [];
12469
12616
  const entryRecord = ctx.members.find(
12470
12617
  (member) => member.id === list.entryMemberId
12471
12618
  );
@@ -12485,7 +12632,7 @@ function resolveListIndexDefinitions(ctx, listMember) {
12485
12632
  );
12486
12633
  if (field === null) {
12487
12634
  throw new Error(
12488
- `Validated List index "${definition.schemaKey}" no longer resolves on entry class "${entryClass.name}".`
12635
+ `Validated ${MemberKind[list.kind]} index "${definition.schemaKey}" no longer resolves on entry class "${entryClass.name}".`
12489
12636
  );
12490
12637
  }
12491
12638
  const domain = classifyIndexKeyDomain(field.member, ctx.enums);
@@ -12811,7 +12958,7 @@ var EffectiveStorageResolver = class {
12811
12958
  }
12812
12959
  continue;
12813
12960
  }
12814
- if (member.kind === 6 /* List */ || member.kind === 5 /* Dictionary */) {
12961
+ if (member.kind === 6 /* List */ || member.kind === 28 /* Set */ || member.kind === 5 /* Dictionary */) {
12815
12962
  const entryId = this.resolvedEntryMemberId(member.id);
12816
12963
  if (entryId !== void 0) addEdge(entryId, member.id);
12817
12964
  }
@@ -12961,7 +13108,7 @@ function compiledConstructionTypeMembers(members, bodies, projectId) {
12961
13108
  requirement: type.required ? 1 /* Required */ : 0 /* Optional */
12962
13109
  };
12963
13110
  const fields = (() => {
12964
- if (type.type === 6 /* List */ || type.type === 5 /* Dictionary */) {
13111
+ if (type.type === 6 /* List */ || type.type === 28 /* Set */ || type.type === 5 /* Dictionary */) {
12965
13112
  const entryMemberId = intern(type.entryTypeInfo);
12966
13113
  if (entryMemberId === null) return null;
12967
13114
  return {
@@ -13227,6 +13374,9 @@ function createCanonicalMemberResolver(parentOf) {
13227
13374
  return canonical;
13228
13375
  };
13229
13376
  }
13377
+ function indexedCollectionMemberId(type) {
13378
+ return type.kind === "list" ? type.listMemberId : type.setMemberId;
13379
+ }
13230
13380
  function isNeoScriptConstructionDocumentKind(kind) {
13231
13381
  if (kind === "initializer") return true;
13232
13382
  if (kind === "initializerExpression") return true;
@@ -13414,7 +13564,7 @@ function buildNeoScriptConstructorSignature(classId, members, memberDescriptor)
13414
13564
  }
13415
13565
  function buildNeoScriptConstructionSignatures(classId, members, memberDescriptor, immutableOnly) {
13416
13566
  const descriptors = /* @__PURE__ */ new Map();
13417
- const describe = (memberId) => {
13567
+ const describe2 = (memberId) => {
13418
13568
  let descriptor = descriptors.get(memberId);
13419
13569
  if (descriptor === void 0) {
13420
13570
  descriptor = memberDescriptor(memberId);
@@ -13422,7 +13572,7 @@ function buildNeoScriptConstructionSignatures(classId, members, memberDescriptor
13422
13572
  }
13423
13573
  return descriptor;
13424
13574
  };
13425
- const replay = buildNeoScriptConstructorSignature(classId, members, describe);
13575
+ const replay = buildNeoScriptConstructorSignature(classId, members, describe2);
13426
13576
  if (immutableOnly) {
13427
13577
  return {
13428
13578
  storedConstructionReplaySignature: replay,
@@ -13449,7 +13599,7 @@ function buildNeoScriptConstructionSignatures(classId, members, memberDescriptor
13449
13599
  classId,
13450
13600
  members,
13451
13601
  (memberId) => {
13452
- const descriptor = describe(memberId);
13602
+ const descriptor = describe2(memberId);
13453
13603
  return descriptor?.immutable === true ? null : descriptor;
13454
13604
  }
13455
13605
  ),
@@ -13928,7 +14078,8 @@ var NSGetterRuntimeError = class extends Error {
13928
14078
  node: { writable: true, value: void 0 },
13929
14079
  callerNode: { writable: true, value: void 0 },
13930
14080
  initializerValueId: { writable: true, value: void 0 },
13931
- sourceOwnerId: { writable: true, value: void 0 }
14081
+ sourceOwnerId: { writable: true, value: void 0 },
14082
+ attachedValueId: { writable: true, value: void 0 }
13932
14083
  });
13933
14084
  if (options?.cause instanceof Error && "neoScriptFrames" in options.cause && Array.isArray(options.cause.neoScriptFrames)) {
13934
14085
  const frames = options.cause.neoScriptFrames;
@@ -14115,9 +14266,9 @@ function visitTypedAggregateRowReferences(value, rawType, visitor) {
14115
14266
  visitor.visitLookup?.(item.value, type);
14116
14267
  else if (type.type === 7 /* Class */ || type.type === 22 /* Interface */) {
14117
14268
  if (typeof item.value === "string") visitor.visit(item.value, type);
14118
- } else if (type.type === 6 /* List */ || type.type === 5 /* Dictionary */) {
14269
+ } else if (type.type === 6 /* List */ || type.type === 28 /* Set */ || type.type === 5 /* Dictionary */) {
14119
14270
  if (typeof item.value === "string") visitor.visit(item.value, type);
14120
- else if (typeof item.value === "object" && item.value !== null && (type.type === 6 /* List */ ? Array.isArray(item.value) : !Array.isArray(item.value))) {
14271
+ else if (typeof item.value === "object" && item.value !== null && (type.type === 5 /* Dictionary */ ? !Array.isArray(item.value) : Array.isArray(item.value))) {
14121
14272
  for (const value2 of Object.values(item.value)) {
14122
14273
  visitor.beforeVisit?.();
14123
14274
  pending.push({ value: value2, type: type.entryTypeInfo });
@@ -14127,6 +14278,145 @@ function visitTypedAggregateRowReferences(value, rawType, visitor) {
14127
14278
  }
14128
14279
  }
14129
14280
 
14281
+ // ../packages/neoscript-language/src/set-elements.ts
14282
+ var SET_ELEMENT_NULLABLE_ERROR = "`Set` elements can't be nullable.";
14283
+ var SET_ELEMENT_COLLECTION_ERROR = "`Set` elements can't be collections.";
14284
+ function setElementKindError(noun) {
14285
+ return `\`Set\` elements can't be ${noun}.`;
14286
+ }
14287
+
14288
+ // ../packages/models/src/members/set-entry-keys.ts
14289
+ var SET_ENTRY_MEMBER_KINDS = /* @__PURE__ */ new Set([
14290
+ 1 /* Bool */,
14291
+ 2 /* Int */,
14292
+ 4 /* Float */,
14293
+ 20 /* Decimal */,
14294
+ 3 /* String */,
14295
+ 14 /* Vector2 */,
14296
+ 15 /* Vector2Int */,
14297
+ 16 /* Vector3 */,
14298
+ 17 /* Vector3Int */,
14299
+ 19 /* Color */,
14300
+ 11 /* Sprite */,
14301
+ 12 /* Audio */,
14302
+ 7 /* Class */,
14303
+ 21 /* Generic */
14304
+ ]);
14305
+ function setEntryKey(entryMember, entry) {
14306
+ const value = entry.value;
14307
+ switch (entryMember.kind) {
14308
+ case 7 /* Class */:
14309
+ return entry.id;
14310
+ case 1 /* Bool */:
14311
+ return String(requireBoolean(value, entryMember));
14312
+ case 2 /* Int */:
14313
+ return String(requireNumber(value, entryMember));
14314
+ case 4 /* Float */:
14315
+ return float32Key(requireNumber(value, entryMember));
14316
+ case 20 /* Decimal */:
14317
+ return decimalKey(requireString(value, entryMember));
14318
+ case 3 /* String */:
14319
+ if (isLocalizedStringMember(entryMember)) {
14320
+ throw new Error(
14321
+ `setEntryKey: "${entryMember.name}" is a localized string; Set<string> elements must be @settings(format: .Plain).`
14322
+ );
14323
+ }
14324
+ return requireString(value, entryMember);
14325
+ case 8 /* Enum */:
14326
+ return requireStringArray(value, entryMember).join(",");
14327
+ case 14 /* Vector2 */:
14328
+ return componentsKey(value, ["x", "y"], float32Key, entryMember);
14329
+ case 15 /* Vector2Int */:
14330
+ return componentsKey(value, ["x", "y"], String, entryMember);
14331
+ case 16 /* Vector3 */:
14332
+ return componentsKey(value, ["x", "y", "z"], float32Key, entryMember);
14333
+ case 17 /* Vector3Int */:
14334
+ return componentsKey(value, ["x", "y", "z"], String, entryMember);
14335
+ case 19 /* Color */:
14336
+ return componentsKey(
14337
+ value,
14338
+ ["r", "g", "b", "a"],
14339
+ float32Key,
14340
+ entryMember
14341
+ );
14342
+ case 11 /* Sprite */: {
14343
+ const sprite = requireRecord(value, entryMember);
14344
+ return `${String(sprite.fileId)}:${String(sprite.sliceIndex)}`;
14345
+ }
14346
+ case 12 /* Audio */:
14347
+ return String(requireRecord(value, entryMember).fileId);
14348
+ default:
14349
+ throw new Error(
14350
+ `setEntryKey: "${entryMember.name}" has kind ${MemberKind[entryMember.kind]}, which is not a Set element kind.`
14351
+ );
14352
+ }
14353
+ }
14354
+ var FLOAT32_VIEW = new DataView(new ArrayBuffer(4));
14355
+ function float32Key(value) {
14356
+ FLOAT32_VIEW.setFloat32(0, value === 0 ? 0 : value);
14357
+ return String(FLOAT32_VIEW.getInt32(0));
14358
+ }
14359
+ function decimalKey(value) {
14360
+ let text = value;
14361
+ if (text.includes(".")) text = text.replace(/\.?0+$/, "");
14362
+ return text === "-0" ? "0" : text;
14363
+ }
14364
+ function componentsKey(value, components2, encode, entryMember) {
14365
+ const record4 = requireRecord(value, entryMember);
14366
+ const parts = [];
14367
+ for (const component of components2) {
14368
+ const part = record4[component];
14369
+ if (typeof part !== "number") {
14370
+ throw new Error(
14371
+ `setEntryKey: "${entryMember.name}" entry is missing numeric component "${component}".`
14372
+ );
14373
+ }
14374
+ parts.push(encode(part));
14375
+ }
14376
+ return parts.join(",");
14377
+ }
14378
+ function requireBoolean(value, entryMember) {
14379
+ if (typeof value === "boolean") return value;
14380
+ throw entryTypeError(value, "a boolean", entryMember);
14381
+ }
14382
+ function requireNumber(value, entryMember) {
14383
+ if (typeof value === "number") return value;
14384
+ throw entryTypeError(value, "a number", entryMember);
14385
+ }
14386
+ function requireString(value, entryMember) {
14387
+ if (typeof value === "string") return value;
14388
+ throw entryTypeError(value, "a string", entryMember);
14389
+ }
14390
+ function requireRecord(value, entryMember) {
14391
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
14392
+ throw entryTypeError(value, "an object", entryMember);
14393
+ }
14394
+ return value;
14395
+ }
14396
+ function requireStringArray(value, entryMember) {
14397
+ if (!Array.isArray(value)) {
14398
+ throw entryTypeError(value, "an option id array", entryMember);
14399
+ }
14400
+ for (const optionId of value) {
14401
+ if (typeof optionId !== "string") {
14402
+ throw new Error(
14403
+ `setEntryKey: "${entryMember.name}" entry option ids must be strings; got ${describe(optionId)}.`
14404
+ );
14405
+ }
14406
+ }
14407
+ return value;
14408
+ }
14409
+ function entryTypeError(value, expected, entryMember) {
14410
+ return new Error(
14411
+ `setEntryKey: "${entryMember.name}" entry must be ${expected}; got ${describe(value)}.`
14412
+ );
14413
+ }
14414
+ function describe(value) {
14415
+ if (value === null) return "null";
14416
+ if (Array.isArray(value)) return "an array";
14417
+ return typeof value;
14418
+ }
14419
+
14130
14420
  // ../packages/neoscript-runtime/src/neoscript/initializer-dependencies.ts
14131
14421
  var PendingInitializerDependency = class extends NSGetterRuntimeError {
14132
14422
  constructor(valueId) {
@@ -14198,6 +14488,9 @@ function initializerOwnerContext(document2, valueId, rootOwners, valuesById, rec
14198
14488
  const ownerClass = typeof lexicalRootId === "string" ? findSchemaPlacement(lexicalRootId, document2.classes)?.ownerClass ?? null : null;
14199
14489
  return { ownerClass, lexicalThisClass: ownerClass };
14200
14490
  }
14491
+ function isClassRecordValue(value) {
14492
+ return value !== null && typeof value === "object" && !Array.isArray(value);
14493
+ }
14201
14494
  function isRecordValue(value) {
14202
14495
  if (value === null) return false;
14203
14496
  if (typeof value !== "object") return false;
@@ -14303,7 +14596,7 @@ function resolveOwnerMembersForValues(document2, targetValueIds, additionalRoots
14303
14596
  }
14304
14597
  function searchChildren(member, rootOwner, body, ambientEnv, rootKind) {
14305
14598
  if (isMemberClassBase(member)) {
14306
- if (!isRecordValue(body.value)) return;
14599
+ if (!isClassRecordValue(body.value)) return;
14307
14600
  const effectiveClassId = body.classId ?? member.classId;
14308
14601
  const schemaClass2 = classesById.get(effectiveClassId);
14309
14602
  if (schemaClass2 === void 0) return;
@@ -14318,7 +14611,7 @@ function resolveOwnerMembersForValues(document2, targetValueIds, additionalRoots
14318
14611
  if (complete) break;
14319
14612
  if (entry.memberId === null) continue;
14320
14613
  const childValueId = body.value[entry.schemaKey];
14321
- if (childValueId === void 0) continue;
14614
+ if (typeof childValueId !== "string") continue;
14322
14615
  const childMember = membersById.get(entry.memberId);
14323
14616
  if (childMember === void 0) continue;
14324
14617
  const substituted = trySubstituteMember(childMember, env);
@@ -14340,7 +14633,7 @@ function resolveOwnerMembersForValues(document2, targetValueIds, additionalRoots
14340
14633
  }
14341
14634
  return;
14342
14635
  }
14343
- if (isMemberListBase(member)) {
14636
+ if (isMemberEntryCollectionBase(member)) {
14344
14637
  const entryMemberRecord = membersById.get(member.entryMemberId);
14345
14638
  if (entryMemberRecord === void 0) return;
14346
14639
  const entryEnv = overlayStamp(ambientEnv, body.genericBindings);
@@ -14428,10 +14721,6 @@ function overlayStamp(env, stamp) {
14428
14721
  // ../packages/neoscript-language/src/cell-pattern.ts
14429
14722
  var NEO_CELL_PATTERN_CLASS_ID = "system_fb9c4080-0148-530e-b9c0-8cd1c17ff8e7";
14430
14723
  var NEO_CELL_PATTERN_CONSTRUCTOR_ID = "system_f68684d6-6ea0-5d57-9f96-d544b17bf369";
14431
- var NEO_CELL_PATTERN_EXCLUDING_OPTION_IDS = {
14432
- None: "system_5c30e23b-1767-5e15-b633-40ae182157a7",
14433
- Center: "system_456431b5-aa5b-5ea0-9f72-0e16f7114e09"
14434
- };
14435
14724
  var NEO_CELL_PATTERN_MEMBER_IDS = {
14436
14725
  Count: "system_51d883c9-d451-5747-bcf0-e314e44bffa8",
14437
14726
  Center: "system_d90a6e51-0b1e-5354-b4e2-ad4155a833f1",
@@ -14454,14 +14743,10 @@ var NEO_OBJECT_GRID_MEMBER_IDS = {
14454
14743
  Cell: "system_c609fed3-53e4-5147-b493-e4aa23031d79",
14455
14744
  GetCell: "system_df1c2d06-eeec-5340-addc-740f3668c9e4",
14456
14745
  GetObjects: "system_f5ca386c-990c-54a1-8473-2d49d2cd887d",
14457
- GetTile: "system_593e6208-e2ca-505e-9933-04b17102b6d2"
14746
+ GetTile: "system_593e6208-e2ca-505e-9933-04b17102b6d2",
14747
+ GetTiles: "system_5a41d36a-bcd9-4867-9e46-d743f6e09582"
14458
14748
  };
14459
14749
  var NEO_CELL_PATTERN_PURE_NATIVE_MEMBER_IDS = /* @__PURE__ */ new Set([
14460
- NEO_CELL_PATTERN_MEMBER_IDS.Box,
14461
- NEO_CELL_PATTERN_MEMBER_IDS.Cross,
14462
- NEO_CELL_PATTERN_MEMBER_IDS.Ring,
14463
- NEO_CELL_PATTERN_MEMBER_IDS.Rect,
14464
- NEO_CELL_PATTERN_MEMBER_IDS.Line,
14465
14750
  NEO_CELL_PATTERN_MEMBER_IDS.Contains,
14466
14751
  NEO_CELL_PATTERN_MEMBER_IDS.Cells,
14467
14752
  NEO_CELL_PATTERN_MEMBER_IDS.WithCenter,
@@ -14472,12 +14757,12 @@ var NEO_CELL_PATTERN_PURE_NATIVE_MEMBER_IDS = /* @__PURE__ */ new Set([
14472
14757
  var NEO_OBJECT_CLASS_ID = "system_f671535d-0eb6-4139-9caf-5c5276febd31";
14473
14758
 
14474
14759
  // ../packages/neoscript-runtime/src/neoscript/cell-pattern.ts
14475
- function integer(value, name, minimum = -2147483648) {
14760
+ function integer(value, name) {
14476
14761
  if (typeof value !== "number" || !Number.isInteger(value)) {
14477
14762
  throw new TypeError(`${name} must be an integer.`);
14478
14763
  }
14479
- if (value < minimum) {
14480
- throw new RangeError(`${name} must be at least ${minimum}.`);
14764
+ if (value < -2147483648) {
14765
+ throw new RangeError(`${name} is below the supported integer range.`);
14481
14766
  }
14482
14767
  if (value > 2147483647) {
14483
14768
  throw new RangeError(`${name} exceeds the supported integer range.`);
@@ -14490,61 +14775,7 @@ function vector(value, name) {
14490
14775
  }
14491
14776
  return { x: integer(value.x, `${name}.x`), y: integer(value.y, `${name}.y`) };
14492
14777
  }
14493
- function exclusion(value) {
14494
- if (!Array.isArray(value) || value.length !== 1) {
14495
- throw new TypeError(
14496
- "excluding must select one NeoCellPatternExcluding option."
14497
- );
14498
- }
14499
- if (value[0] === NEO_CELL_PATTERN_EXCLUDING_OPTION_IDS.None) return "none";
14500
- if (value[0] === NEO_CELL_PATTERN_EXCLUDING_OPTION_IDS.Center)
14501
- return "center";
14502
- throw new RangeError("excluding is not a NeoCellPatternExcluding option.");
14503
- }
14504
- function reserve(ctx, count) {
14505
- if (!Number.isSafeInteger(count) || count < 0) {
14506
- throw new RangeError("Cell pattern contains too many offsets.");
14507
- }
14508
- ctx.reserveEntries(count);
14509
- }
14510
- function appendShell(result, radius, minX, maxX, minY, maxY) {
14511
- if (radius === 0) {
14512
- if (minX <= 0 && maxX >= 0 && minY <= 0 && maxY >= 0)
14513
- result.push({ x: 0, y: 0 });
14514
- return;
14515
- }
14516
- const firstY = Math.max(minY, -radius) || 0;
14517
- const lastY = Math.min(maxY, radius);
14518
- if (firstY > lastY) return;
14519
- if (-radius >= minX && -radius <= maxX) {
14520
- for (let y = firstY; y <= lastY; y++) result.push({ x: -radius, y });
14521
- }
14522
- const bottom = -radius >= minY && -radius <= maxY;
14523
- const top = radius !== 0 && radius >= minY && radius <= maxY;
14524
- if (bottom || top) {
14525
- const firstX = Math.max(minX, -radius + 1) || 0;
14526
- const lastX = Math.min(maxX, radius - 1);
14527
- for (let x = firstX; x <= lastX; x++) {
14528
- if (bottom) result.push({ x, y: -radius });
14529
- if (top) result.push({ x, y: radius });
14530
- }
14531
- }
14532
- if (radius !== 0 && radius >= minX && radius <= maxX) {
14533
- for (let y = firstY; y <= lastY; y++) result.push({ x: radius, y });
14534
- }
14535
- }
14536
- function rectangle(ctx, minX, maxX, minY, maxY, excluding) {
14537
- const count = (maxX - minX + 1) * (maxY - minY + 1);
14538
- reserve(ctx, count - (excluding === "center" ? 1 : 0));
14539
- const offsets = [];
14540
- const radius = Math.max(-minX, maxX, -minY, maxY);
14541
- for (let shell = excluding === "center" ? 1 : 0; shell <= radius; shell++) {
14542
- appendShell(offsets, shell, minX, maxX, minY, maxY);
14543
- }
14544
- return offsets;
14545
- }
14546
- function translated(offsets, origin, ctx) {
14547
- reserve(ctx, offsets.length);
14778
+ function translated(offsets, origin) {
14548
14779
  return offsets.map((offset) => ({
14549
14780
  x: integer(offset.x + origin.x, "Translated cell.x"),
14550
14781
  y: integer(offset.y + origin.y, "Translated cell.y")
@@ -14561,57 +14792,7 @@ function evaluateCellPatternNative(memberId, receiver, args, ctx) {
14561
14792
  handled: true,
14562
14793
  value: ctx.constructPattern(offsets2)
14563
14794
  });
14564
- switch (memberId) {
14565
- case NEO_CELL_PATTERN_MEMBER_IDS.Box: {
14566
- const x = integer(args[0], "Box radiusX", 0);
14567
- const y = args[1] === null ? x : integer(args[1], "Box radiusY", 0);
14568
- return pattern(rectangle(ctx, -x, x, -y, y, exclusion(args[2])));
14569
- }
14570
- case NEO_CELL_PATTERN_MEMBER_IDS.Cross: {
14571
- const x = integer(args[0], "Cross radiusX", 0);
14572
- const y = args[1] === null ? x : integer(args[1], "Cross radiusY", 0);
14573
- const excluding = exclusion(args[2]);
14574
- reserve(ctx, 2 * (x + y) + (excluding === "none" ? 1 : 0));
14575
- const offsets2 = excluding === "none" ? [{ x: 0, y: 0 }] : [];
14576
- for (let distance = 1; distance <= Math.max(x, y); distance++) {
14577
- if (distance <= x)
14578
- offsets2.push({ x: -distance, y: 0 }, { x: distance, y: 0 });
14579
- if (distance <= y)
14580
- offsets2.push({ x: 0, y: -distance }, { x: 0, y: distance });
14581
- }
14582
- return pattern(offsets2);
14583
- }
14584
- case NEO_CELL_PATTERN_MEMBER_IDS.Ring: {
14585
- const radius = integer(args[0], "Ring radius", 0);
14586
- reserve(ctx, radius === 0 ? 1 : 8 * radius);
14587
- const offsets2 = [];
14588
- appendShell(offsets2, radius, -radius, radius, -radius, radius);
14589
- return pattern(offsets2);
14590
- }
14591
- case NEO_CELL_PATTERN_MEMBER_IDS.Rect: {
14592
- const size = vector(args[0], "Rect size");
14593
- integer(size.x, "Rect size.x", 1);
14594
- integer(size.y, "Rect size.y", 1);
14595
- return pattern(rectangle(ctx, 0, size.x - 1, 0, size.y - 1, "none"));
14596
- }
14597
- case NEO_CELL_PATTERN_MEMBER_IDS.Line: {
14598
- const direction = vector(args[0], "Line direction");
14599
- if (isCenter(direction))
14600
- throw new RangeError("Line direction must be non-zero.");
14601
- const length = integer(args[1], "Line length", 0);
14602
- const excluding = exclusion(args[2]);
14603
- reserve(ctx, length + (excluding === "none" ? 1 : 0));
14604
- integer(direction.x * length, "Line endpoint.x");
14605
- integer(direction.y * length, "Line endpoint.y");
14606
- const offsets2 = excluding === "none" ? [{ x: 0, y: 0 }] : [];
14607
- for (let step = 1; step <= length; step++) {
14608
- offsets2.push({ x: direction.x * step, y: direction.y * step });
14609
- }
14610
- return pattern(offsets2);
14611
- }
14612
- }
14613
14795
  const offsets = ctx.readPattern(receiver);
14614
- ctx.visitEntries(offsets.length);
14615
14796
  switch (memberId) {
14616
14797
  case NEO_CELL_PATTERN_MEMBER_IDS.Contains: {
14617
14798
  const offset = vector(args[0], "Contains offset");
@@ -14625,34 +14806,27 @@ function evaluateCellPatternNative(memberId, receiver, args, ctx) {
14625
14806
  case NEO_CELL_PATTERN_MEMBER_IDS.Cells:
14626
14807
  return {
14627
14808
  handled: true,
14628
- value: translated(offsets, vector(args[0], "Cells origin"), ctx)
14809
+ value: translated(offsets, vector(args[0], "Cells origin"))
14629
14810
  };
14630
14811
  case NEO_CELL_PATTERN_MEMBER_IDS.WithCenter:
14631
14812
  if (offsets.some(isCenter)) return { handled: true, value: receiver };
14632
- reserve(ctx, offsets.length + 1);
14633
14813
  return pattern([{ x: 0, y: 0 }, ...offsets]);
14634
- case NEO_CELL_PATTERN_MEMBER_IDS.WithoutCenter: {
14635
- let count = 0;
14636
- for (const offset of offsets) if (!isCenter(offset)) count++;
14637
- if (count === offsets.length) return { handled: true, value: receiver };
14638
- reserve(ctx, count);
14814
+ case NEO_CELL_PATTERN_MEMBER_IDS.WithoutCenter:
14815
+ if (!offsets.some(isCenter)) return { handled: true, value: receiver };
14639
14816
  return pattern(offsets.filter((offset) => !isCenter(offset)));
14640
- }
14641
14817
  case NEO_CELL_PATTERN_MEMBER_IDS.Translate: {
14642
14818
  const offset = vector(args[0], "Translate offset");
14643
14819
  if (isCenter(offset)) return { handled: true, value: receiver };
14644
- return pattern(translated(offsets, offset, ctx));
14820
+ return pattern(translated(offsets, offset));
14645
14821
  }
14646
14822
  case NEO_CELL_PATTERN_MEMBER_IDS.Union: {
14647
14823
  const other = ctx.readPattern(args[0]);
14648
- ctx.visitEntries(other.length);
14649
14824
  const seen = /* @__PURE__ */ new Set();
14650
14825
  const result = [];
14651
14826
  for (const source of [offsets, other]) {
14652
14827
  for (const offset of source) {
14653
14828
  const key = `${offset.x},${offset.y}`;
14654
14829
  if (seen.has(key)) continue;
14655
- reserve(ctx, 1);
14656
14830
  seen.add(key);
14657
14831
  result.push(offset);
14658
14832
  }
@@ -15497,29 +15671,44 @@ var WorldGridQueryIndex = class {
15497
15671
  );
15498
15672
  return matches[0];
15499
15673
  }
15500
- objects(placement, offsets, reads, reserveResults) {
15674
+ /** `shift` moves the whole pattern; null queries around the placement cell. */
15675
+ objects(placement, offsets, reads, shift = null) {
15501
15676
  reads?.add({ kind: "placement", valueId: placement.valueId });
15677
+ const origin = shiftedOrigin(placement, shift);
15502
15678
  const result = [];
15503
15679
  for (const offset of offsets) {
15504
- const cell = translated2(placement.cell, offset);
15680
+ const cell = translated2(origin, offset);
15505
15681
  reads?.add({ kind: "objects", gridId: placement.gridId, cell });
15506
15682
  for (const item of this.objectsAt(placement.gridId, cell)) {
15507
- reserveResults?.(1);
15508
15683
  result.push(item.valueId);
15509
15684
  }
15510
15685
  }
15511
15686
  return result;
15512
15687
  }
15513
- tile(placement, offsets, reads) {
15688
+ tile(placement, offsets, reads, shift = null) {
15514
15689
  reads?.add({ kind: "placement", valueId: placement.valueId });
15690
+ const origin = shiftedOrigin(placement, shift);
15515
15691
  let result = null;
15516
15692
  for (const offset of offsets) {
15517
- const cell = translated2(placement.cell, offset);
15693
+ const cell = translated2(origin, offset);
15518
15694
  reads?.add({ kind: "tile", gridId: placement.gridId, cell });
15519
15695
  result ??= this.tileAt(placement.gridId, cell);
15520
15696
  }
15521
15697
  return result;
15522
15698
  }
15699
+ /** One tile per occupied pattern cell, in pattern order. */
15700
+ tiles(placement, offsets, reads, shift = null) {
15701
+ reads?.add({ kind: "placement", valueId: placement.valueId });
15702
+ const origin = shiftedOrigin(placement, shift);
15703
+ const result = [];
15704
+ for (const offset of offsets) {
15705
+ const cell = translated2(origin, offset);
15706
+ reads?.add({ kind: "tile", gridId: placement.gridId, cell });
15707
+ const tile = this.tileAt(placement.gridId, cell);
15708
+ if (tile !== null) result.push(tile.placementValueId);
15709
+ }
15710
+ return result;
15711
+ }
15523
15712
  /** Stable dependency value: unrelated cells and non-geometric payload edits compare equal. */
15524
15713
  signature(read) {
15525
15714
  if (read.kind === "placement") {
@@ -15782,6 +15971,9 @@ function timestamp(value) {
15782
15971
  if (typeof value === "string") return Date.parse(value) || 0;
15783
15972
  return 0;
15784
15973
  }
15974
+ function shiftedOrigin(placement, shift) {
15975
+ return shift === null ? placement.cell : translated2(placement.cell, shift);
15976
+ }
15785
15977
  function translated2(cell, offset) {
15786
15978
  return {
15787
15979
  x: checkedCoordinate(cell.x + offset.x),
@@ -16406,25 +16598,12 @@ var NativeFunctionDelegateUnavailableError = class extends NonCatchableNSGetterR
16406
16598
  };
16407
16599
  var CorruptNeoScriptIRError = class extends NonCatchableNSGetterRuntimeError {
16408
16600
  };
16409
- var NeoScriptResourceLimitError = class extends NonCatchableNSGetterRuntimeError {
16410
- constructor(message) {
16411
- super(message);
16412
- this.name = "NeoScriptResourceLimitError";
16413
- }
16414
- };
16415
- var NeoScriptWallClockTimeoutError = class extends NeoScriptResourceLimitError {
16601
+ var NeoScriptWallClockTimeoutError = class extends NonCatchableNSGetterRuntimeError {
16416
16602
  constructor() {
16417
16603
  super("NeoScript wall-clock timeout exceeded.");
16418
16604
  this.name = "NeoScriptWallClockTimeoutError";
16419
16605
  }
16420
16606
  };
16421
- var DEFAULT_NEO_SCRIPT_EXECUTION_BUDGET_LIMITS = Object.freeze({
16422
- workUnits: 1e5,
16423
- collectionVisits: 1e5,
16424
- producedCollectionEntries: 1e4,
16425
- constructedSessionRows: 4096,
16426
- producedStringCharacters: 1024 * 1024
16427
- });
16428
16607
  function isCatchableNeoScriptRuntimeError(error) {
16429
16608
  return error instanceof NSGetterRuntimeError && !(error instanceof UncompiledInitializerRuntimeError) && !(error instanceof PendingInitializerDependency) && !(error instanceof NonCatchableNSGetterRuntimeError);
16430
16609
  }
@@ -16544,7 +16723,8 @@ function blankEvaluatorIndexes(memberByValueId) {
16544
16723
  indexedVirtualRowSets: /* @__PURE__ */ new WeakSet(),
16545
16724
  ownedValueAttachmentsByValueId: /* @__PURE__ */ new Map(),
16546
16725
  constructorOwnershipDirtyValueIds: /* @__PURE__ */ new Set(),
16547
- memberByRowId: /* @__PURE__ */ new Map()
16726
+ memberByRowId: /* @__PURE__ */ new Map(),
16727
+ invalidated: false
16548
16728
  };
16549
16729
  }
16550
16730
  function createEvaluatorBaseIndexBuild(members, values, valueById) {
@@ -16753,7 +16933,7 @@ function layerEvaluatorLookups(base, overlay) {
16753
16933
  }
16754
16934
  function evaluatorIndexes(ctx) {
16755
16935
  const overlayRevision = ctx.__valueOverlay instanceof LazyValueOverlay ? ctx.__valueOverlay.revision : void 0;
16756
- if (ctx.__indexes !== void 0 && ctx.__indexes.overlayRevision === overlayRevision) {
16936
+ if (ctx.__indexes !== void 0 && !ctx.__indexes.invalidated && ctx.__indexes.overlayRevision === overlayRevision) {
16757
16937
  syncLazyOverlayReferences(ctx.__indexes, ctx.__valueOverlay);
16758
16938
  return ctx.__indexes;
16759
16939
  }
@@ -16788,7 +16968,8 @@ function evaluatorIndexes(ctx) {
16788
16968
  indexedVirtualRowSets: /* @__PURE__ */ new WeakSet(),
16789
16969
  ownedValueAttachmentsByValueId: /* @__PURE__ */ new Map(),
16790
16970
  constructorOwnershipDirtyValueIds: /* @__PURE__ */ new Set(),
16791
- memberByRowId: /* @__PURE__ */ new Map()
16971
+ memberByRowId: /* @__PURE__ */ new Map(),
16972
+ invalidated: false
16792
16973
  };
16793
16974
  if (base === void 0) {
16794
16975
  for (const member of ctx.vm.members) {
@@ -17112,13 +17293,21 @@ function resolveRuntimeReferenceRow(sourceValueId, ctx, withProvenance) {
17112
17293
  );
17113
17294
  }
17114
17295
  function invalidateEvaluatorIndexes(ctx, changedValue) {
17115
- if (ctx.__valueOverlay instanceof LazyValueOverlay) {
17116
- const overlay = ctx.__valueOverlay;
17117
- const constructionLocal = changedValue !== void 0 && (ctx.__executionState?.constructionStack.length ?? 0) > 0 && !overlay.isSourceValueReference(changedValue);
17118
- overlay.markMutated(changedValue !== null && !constructionLocal);
17119
- }
17296
+ markOverlayMutated(ctx, changedValue);
17297
+ if (ctx.__indexes !== void 0) ctx.__indexes.invalidated = true;
17120
17298
  ctx.__indexes = void 0;
17121
17299
  }
17300
+ function markOverlayMutated(ctx, changedValue) {
17301
+ if (!(ctx.__valueOverlay instanceof LazyValueOverlay)) return;
17302
+ const overlay = ctx.__valueOverlay;
17303
+ const constructionLocal = changedValue !== void 0 && (ctx.__executionState?.constructionStack.length ?? 0) > 0 && !overlay.isSourceValueReference(changedValue);
17304
+ overlay.markMutated(changedValue !== null && !constructionLocal);
17305
+ }
17306
+ function forgetLocalListIndexes(ctx, list) {
17307
+ ctx.__setEntryIndexes?.delete(list);
17308
+ ctx.__indexes?.listIdentityByArray.delete(list);
17309
+ ctx.__indexes?.declaredListByArray.delete(list);
17310
+ }
17122
17311
  function trackedRowForValueReference(value, ctx) {
17123
17312
  if (typeof value !== "object" || value === null) return null;
17124
17313
  const indexes3 = evaluatorIndexes(ctx);
@@ -17171,7 +17360,6 @@ function assertStoredReplayMutableValue(value, ctx, label, key) {
17171
17360
  );
17172
17361
  }
17173
17362
  var MAX_CONSTRUCTION_DEPTH = 64;
17174
- var MAX_LOOP_ITERATIONS = 1e4;
17175
17363
  function pushConstructionFrame(ctx, label) {
17176
17364
  const state = ctx.__executionState;
17177
17365
  if (state === void 0) {
@@ -17179,7 +17367,7 @@ function pushConstructionFrame(ctx, label) {
17179
17367
  "Class construction requires an effect-capable evaluator Session scope."
17180
17368
  );
17181
17369
  }
17182
- consumeBudget(ctx, "workUnits", 1, "work unit");
17370
+ checkDeadline(ctx);
17183
17371
  if (state.constructionStack.length >= MAX_CONSTRUCTION_DEPTH) {
17184
17372
  const chain = [...state.constructionStack, label].join(" -> ");
17185
17373
  throw new NSGetterRuntimeError(
@@ -17399,9 +17587,8 @@ function exportInitializerCollections(created, writes, ctx) {
17399
17587
  if (!candidates.has(row.id)) return row;
17400
17588
  const member = memberForValueRow(row, ctx);
17401
17589
  if (member === null) return row;
17402
- if (!isMemberListBase(member) && !isMemberDictionaryBase(member))
17403
- return row;
17404
- if (isMemberListBase(member) && listKindOf(member) === 1 /* Unordered */) {
17590
+ if (!isMemberWithEntries(member)) return row;
17591
+ if (isMemberEntryCollectionBase(member) && listKindOf(member) === 1 /* Unordered */) {
17405
17592
  return { ...row, value: [] };
17406
17593
  }
17407
17594
  if (!assignedValues.has(row.value)) return row;
@@ -17446,12 +17633,6 @@ function exportInitializerCollections(created, writes, ctx) {
17446
17633
  createdValues: [encoded, ...children],
17447
17634
  declarationByValueId: declarations
17448
17635
  });
17449
- consumeBudget(
17450
- ctx,
17451
- "constructedSessionRows",
17452
- children.length,
17453
- "constructed Session row"
17454
- );
17455
17636
  for (const child of children) {
17456
17637
  if (!isLiteralValueContent(child)) {
17457
17638
  throw new NSGetterRuntimeError(
@@ -17498,7 +17679,7 @@ function evaluateNSGetterWithEffects(getter, ctx, argumentValues = [], options =
17498
17679
  const ownsInvocationState = ctx.__executionState === void 0;
17499
17680
  const requestedWrites = [];
17500
17681
  const runtimeCtx = withEvaluationRuntime(ctx, requestedWrites);
17501
- consumeBudget(runtimeCtx, "workUnits", 1, "work unit");
17682
+ checkDeadline(runtimeCtx);
17502
17683
  const writes = runtimeCtx.__executionState?.writes ?? requestedWrites;
17503
17684
  const writeCheckpoint = writes.length;
17504
17685
  const creationCheckpoint = sessionCreationCheckpoint(runtimeCtx);
@@ -17528,7 +17709,7 @@ function evaluateNSGetterWithEffects(getter, ctx, argumentValues = [], options =
17528
17709
  result.value = coerceDecimalOperand(result.value, "return");
17529
17710
  }
17530
17711
  const initializerResult = options.initializerResult;
17531
- if (initializerResult !== void 0 && result.value !== null && (isMemberListBase(initializerResult.member) || isMemberDictionaryBase(initializerResult.member)) && findKnownRowIdByValueReference(result.value, runtimeCtx) === null) {
17712
+ if (initializerResult !== void 0 && result.value !== null && isMemberWithEntries(initializerResult.member) && findKnownRowIdByValueReference(result.value, runtimeCtx) === null) {
17532
17713
  const createdValues = createdSessionValuesSince(runtimeCtx, creationCheckpoint);
17533
17714
  const declarations = /* @__PURE__ */ new Map();
17534
17715
  const root = materializeConstructorArgumentValue({
@@ -17558,6 +17739,13 @@ function evaluateNSGetterWithEffects(getter, ctx, argumentValues = [], options =
17558
17739
  const rootIndex = created.findIndex(
17559
17740
  (row) => row.value === result.value
17560
17741
  );
17742
+ if (initializerResult !== void 0 && rootIndex === -1) {
17743
+ assertExportedPlacement(
17744
+ result.value,
17745
+ initializerResult.member,
17746
+ runtimeCtx
17747
+ );
17748
+ }
17561
17749
  const exported2 = exportInitializerCollections(
17562
17750
  created,
17563
17751
  writes,
@@ -17612,11 +17800,17 @@ function evaluateNSGetterWithEffects(getter, ctx, argumentValues = [], options =
17612
17800
  finalizeConstructorAllocations(runtimeCtx, void 0, ownsInvocationState);
17613
17801
  throw new NSGetterRuntimeError("Function ended without a return statement");
17614
17802
  }
17803
+ function assertExportedPlacement(value, member, ctx) {
17804
+ if (!isMemberClassBase(member) && !isMemberWithEntries(member)) return;
17805
+ const existing = trackedRowForValueReference(value, ctx);
17806
+ if (existing === null) return;
17807
+ assertInitializerPlacement(existing.id, member, ctx);
17808
+ }
17615
17809
  function evaluateNSFunction(action, ctx, args) {
17616
17810
  const ownsInvocationState = ctx.__executionState === void 0;
17617
17811
  const requestedWrites = [];
17618
17812
  const runtimeCtx = withEvaluationRuntime(ctx, requestedWrites);
17619
- consumeBudget(runtimeCtx, "workUnits", 1, "work unit");
17813
+ checkDeadline(runtimeCtx);
17620
17814
  const writes = runtimeCtx.__executionState?.writes ?? requestedWrites;
17621
17815
  const writeCheckpoint = writes.length;
17622
17816
  const creationCheckpoint = sessionCreationCheckpoint(runtimeCtx);
@@ -17696,6 +17890,7 @@ function getterSubscriptionsFor(ctx) {
17696
17890
  function withEvaluationRuntime(ctx, writes) {
17697
17891
  if (ctx.__runtimeSessionValues !== void 0 && ctx.__executionState !== void 0 && ctx.__valueOverlay !== void 0) {
17698
17892
  ctx.__unorderedListProjections ??= createUnorderedListProjectionCache();
17893
+ ctx.__setEntryIndexes ??= /* @__PURE__ */ new WeakMap();
17699
17894
  ctx.__runtimeClassOverrides ??= /* @__PURE__ */ new Map();
17700
17895
  ctx.__getterSubscriptions ??= getterSubscriptionsFor(ctx);
17701
17896
  return ctx;
@@ -17729,6 +17924,7 @@ function withEvaluationRuntime(ctx, writes) {
17729
17924
  __sessionStaticBindings: ctx.__sessionStaticBindings ?? staticBindingMap(ctx.sessionStaticBindings),
17730
17925
  __valueOverlay: overlay,
17731
17926
  __unorderedListProjections: ctx.__unorderedListProjections ?? createUnorderedListProjectionCache(),
17927
+ __setEntryIndexes: ctx.__setEntryIndexes ?? /* @__PURE__ */ new WeakMap(),
17732
17928
  __runtimeReferenceRemap: referenceRemap,
17733
17929
  __executionState: ctx.__executionState ?? {
17734
17930
  writes,
@@ -17743,63 +17939,15 @@ function withEvaluationRuntime(ctx, writes) {
17743
17939
  constructionTimestamp: Date.now(),
17744
17940
  ownedValueAttachments: /* @__PURE__ */ new Map(),
17745
17941
  constructionStack: [],
17746
- openConstructions: /* @__PURE__ */ new Map(),
17747
- loopIterations: 0,
17748
- budgetedConstructedRowIds: /* @__PURE__ */ new Set(),
17749
- budgetedProducedEntriesByRowId: /* @__PURE__ */ new Map(),
17750
- budget: ctx.sharedExecutionBudget ?? createNeoScriptExecutionBudget(ctx.executionBudgetLimits)
17942
+ openConstructions: /* @__PURE__ */ new Map()
17751
17943
  },
17752
17944
  __indexes: ctx.__executionState === void 0 || ctx.__valueOverlay === void 0 ? void 0 : ctx.__indexes
17753
17945
  };
17754
17946
  }
17755
- function createNeoScriptExecutionBudget(requested) {
17756
- const limits = { ...DEFAULT_NEO_SCRIPT_EXECUTION_BUDGET_LIMITS };
17757
- for (const key of Object.keys(limits)) {
17758
- const value = requested?.[key];
17759
- if (value === void 0) continue;
17760
- if (!Number.isSafeInteger(value)) {
17761
- throw new NeoScriptResourceLimitError(
17762
- `NeoScript ${key} limit must be a safe integer.`
17763
- );
17764
- }
17765
- if (value < 0) {
17766
- throw new NeoScriptResourceLimitError(
17767
- `NeoScript ${key} limit must not be negative.`
17768
- );
17769
- }
17770
- if (value > DEFAULT_NEO_SCRIPT_EXECUTION_BUDGET_LIMITS[key]) {
17771
- throw new NeoScriptResourceLimitError(
17772
- `NeoScript ${key} limit cannot exceed the safety ceiling of ${DEFAULT_NEO_SCRIPT_EXECUTION_BUDGET_LIMITS[key]}.`
17773
- );
17774
- }
17775
- limits[key] = value;
17776
- }
17777
- return {
17778
- limits,
17779
- workUnits: 0,
17780
- collectionVisits: 0,
17781
- producedCollectionEntries: 0,
17782
- constructedSessionRows: 0,
17783
- producedStringCharacters: 0
17784
- };
17785
- }
17786
- function consumeBudget(ctx, counter, amount, label) {
17947
+ function checkDeadline(ctx) {
17787
17948
  if (ctx.wallClockDeadlineMs !== void 0 && Date.now() >= ctx.wallClockDeadlineMs) {
17788
17949
  throw new NeoScriptWallClockTimeoutError();
17789
17950
  }
17790
- const budget = ctx.__executionState?.budget;
17791
- if (budget === void 0) {
17792
- throw new NSGetterRuntimeError(
17793
- "NeoScript work executed without a shared execution budget."
17794
- );
17795
- }
17796
- const limit = budget.limits[counter];
17797
- if (amount > limit - budget[counter]) {
17798
- throw new NeoScriptResourceLimitError(
17799
- `NeoScript ${label} limit of ${limit} exceeded.`
17800
- );
17801
- }
17802
- budget[counter] += amount;
17803
17951
  }
17804
17952
  function staticBindingMap(bindings) {
17805
17953
  if (bindings === void 0) return /* @__PURE__ */ new Map();
@@ -17817,7 +17965,7 @@ function ownedConstructorArgumentValues(row, ctx, readRow) {
17817
17965
  const constructor = evaluatorSchemaIndex(ctx).constructorRecord(constructorId);
17818
17966
  if (constructor === void 0 || constructor.classId !== classId) return [];
17819
17967
  if (!constructor.argumentTypes.some(
17820
- (typeInfo) => typeInfo.type === 7 /* Class */ || typeInfo.type === 22 /* Interface */ || typeInfo.type === 6 /* List */ || typeInfo.type === 5 /* Dictionary */ || typeInfo.type === 21 /* Generic */
17968
+ (typeInfo) => typeInfo.type === 7 /* Class */ || typeInfo.type === 22 /* Interface */ || typeInfo.type === 6 /* List */ || typeInfo.type === 28 /* Set */ || typeInfo.type === 5 /* Dictionary */ || typeInfo.type === 21 /* Generic */
17821
17969
  ))
17822
17970
  return [];
17823
17971
  let genericEnv = /* @__PURE__ */ new Map();
@@ -17990,7 +18138,7 @@ function finalizeConstructorAllocations(ctx, returnValue, ownsInvocationState, r
17990
18138
  if (groupByRowId.has(argumentId)) scanOwnedRow(argumentId);
17991
18139
  const argumentRow = rowForCleanup(argumentId);
17992
18140
  if (argumentRow === null) return;
17993
- if (typeInfo.type === 6 /* List */) {
18141
+ if (typeInfo.type === 6 /* List */ || typeInfo.type === 28 /* Set */) {
17994
18142
  if (Array.isArray(argumentRow.value)) {
17995
18143
  for (const childId of argumentRow.value) {
17996
18144
  if (typeof childId === "string") {
@@ -18061,7 +18209,7 @@ function finalizeConstructorAllocations(ctx, returnValue, ownsInvocationState, r
18061
18209
  }
18062
18210
  return;
18063
18211
  }
18064
- if (member !== null && isMemberListBase(member)) {
18212
+ if (member !== null && isMemberEntryCollectionBase(member)) {
18065
18213
  const entryMember = evalMemberById(ctx.vm, member.entryMemberId);
18066
18214
  if (listKindOf(member) === 1 /* Unordered */) {
18067
18215
  ctx.onUnattributableValueRead?.(containerEntriesRead(row.id));
@@ -18100,7 +18248,7 @@ function finalizeConstructorAllocations(ctx, returnValue, ownsInvocationState, r
18100
18248
  scannedReturnReferences.add(value);
18101
18249
  }
18102
18250
  if (typeInfo === void 0) return;
18103
- if (typeInfo.type === 6 /* List */ && Array.isArray(value)) {
18251
+ if ((typeInfo.type === 6 /* List */ || typeInfo.type === 28 /* Set */) && Array.isArray(value)) {
18104
18252
  for (const entry of value) {
18105
18253
  scanReturnedValue(entry, typeInfo.entryTypeInfo);
18106
18254
  }
@@ -18551,21 +18699,6 @@ function createTopLevelScope(ctx) {
18551
18699
  );
18552
18700
  return scope;
18553
18701
  }
18554
- function consumeLoopIteration(ctx) {
18555
- const state = ctx.__executionState;
18556
- if (state === void 0) {
18557
- throw new NSGetterRuntimeError(
18558
- "NeoScript loop executed without a shared execution state."
18559
- );
18560
- }
18561
- if (state.loopIterations >= MAX_LOOP_ITERATIONS) {
18562
- throw new NeoScriptResourceLimitError(
18563
- `NeoScript loop iteration limit of ${MAX_LOOP_ITERATIONS} exceeded.`
18564
- );
18565
- }
18566
- state.loopIterations += 1;
18567
- consumeBudget(ctx, "workUnits", 1, "work unit");
18568
- }
18569
18702
  function synchronizeExistingBindings(parent, child, bindingIds) {
18570
18703
  for (const bindingId of bindingIds) {
18571
18704
  parent.setLocal(bindingId, child.get(bindingId));
@@ -18770,7 +18903,7 @@ function positionNeoScriptFrame(ctx, position) {
18770
18903
  function evalInstructions(instructions, scope, ctx, options) {
18771
18904
  for (const ins of instructions) {
18772
18905
  try {
18773
- consumeBudget(ctx, "workUnits", 1, "work unit");
18906
+ checkDeadline(ctx);
18774
18907
  switch (ins.type) {
18775
18908
  case "debug" /* debug */: {
18776
18909
  const condition = ins.condition === void 0 ? false : evalPointer(ins.condition, scope, ctx);
@@ -18882,7 +19015,7 @@ function evalInstructions(instructions, scope, ctx, options) {
18882
19015
  collectionValueId: member.collectionValueId
18883
19016
  };
18884
19017
  }
18885
- const assignedReferenceValueId = targetTypeInfo.type === 7 /* Class */ || targetTypeInfo.type === 6 /* List */ || targetTypeInfo.type === 5 /* Dictionary */ ? findKnownRowIdByValueReference(value, ctx) : null;
19018
+ const assignedReferenceValueId = targetTypeInfo.type === 7 /* Class */ || targetTypeInfo.type === 6 /* List */ || targetTypeInfo.type === 28 /* Set */ || targetTypeInfo.type === 5 /* Dictionary */ ? findKnownRowIdByValueReference(value, ctx) : null;
18886
19019
  if (!bindOmittedConstantSlot(destination, member, value, ctx)) {
18887
19020
  applyOverlayAssignment(
18888
19021
  ins.target.pointer,
@@ -18893,7 +19026,7 @@ function evalInstructions(instructions, scope, ctx, options) {
18893
19026
  destination
18894
19027
  );
18895
19028
  }
18896
- const unorderedReplacement = assignedReferenceValueId === null && member !== null && isMemberListBase(member) && listKindOf(member) === 1 /* Unordered */ && Array.isArray(value) ? unorderedReplacementProjection(
19029
+ const unorderedReplacement = assignedReferenceValueId === null && member !== null && isMemberEntryCollectionBase(member) && listKindOf(member) === 1 /* Unordered */ && Array.isArray(value) ? unorderedReplacementProjection(
18897
19030
  ins.target.pointer,
18898
19031
  destination,
18899
19032
  scope,
@@ -18903,7 +19036,7 @@ function evalInstructions(instructions, scope, ctx, options) {
18903
19036
  kind: "assign",
18904
19037
  target: targetTypeInfo === ins.target.typeInfo ? ins.target : { ...ins.target, typeInfo: targetTypeInfo },
18905
19038
  value: unorderedReplacement ?? value,
18906
- ...targetTypeInfo.type === 7 /* Class */ || targetTypeInfo.type === 6 /* List */ || targetTypeInfo.type === 5 /* Dictionary */ ? {
19039
+ ...targetTypeInfo.type === 7 /* Class */ || targetTypeInfo.type === 6 /* List */ || targetTypeInfo.type === 28 /* Set */ || targetTypeInfo.type === 5 /* Dictionary */ ? {
18907
19040
  valueId: value === null || value === void 0 ? void 0 : assignedReferenceValueId ?? void 0
18908
19041
  } : {},
18909
19042
  ...resolvedDestinationFieldsForAssign(
@@ -18939,7 +19072,7 @@ function evalInstructions(instructions, scope, ctx, options) {
18939
19072
  let firstIteration = ins.type === "doWhile" /* doWhile */;
18940
19073
  while (firstIteration || evalBooleanExpression(ins.condition, scope, ctx)) {
18941
19074
  firstIteration = false;
18942
- consumeLoopIteration(ctx);
19075
+ checkDeadline(ctx);
18943
19076
  const result = evalInstructionsInChildScope(
18944
19077
  ins.instructions,
18945
19078
  scope,
@@ -18962,7 +19095,7 @@ function evalInstructions(instructions, scope, ctx, options) {
18962
19095
  );
18963
19096
  loopScope.setLocal(ins.initializer.id, initialValue);
18964
19097
  while (evalBooleanExpression(ins.condition, loopScope, ctx)) {
18965
- consumeLoopIteration(ctx);
19098
+ checkDeadline(ctx);
18966
19099
  const result = evalInstructionsInChildScope(
18967
19100
  ins.instructions,
18968
19101
  loopScope,
@@ -18990,7 +19123,7 @@ function evalInstructions(instructions, scope, ctx, options) {
18990
19123
  );
18991
19124
  try {
18992
19125
  for (const rawEntry of membership) {
18993
- consumeLoopIteration(ctx);
19126
+ checkDeadline(ctx);
18994
19127
  loopScope.setLocal(
18995
19128
  ins.binding.id,
18996
19129
  coerceAssignmentValue(
@@ -19193,7 +19326,7 @@ function resolveNeoScriptChangeListenerSlot(ownerId, memberId, ctx) {
19193
19326
  return null;
19194
19327
  if (resolved.kind === 26 /* NSAction */ || resolved.kind === 25 /* NSDelegate */)
19195
19328
  return null;
19196
- const needsGenericEnv = resolved.kind === 21 /* Generic */ || resolved.kind === 7 /* Class */ || resolved.kind === 6 /* List */ || resolved.kind === 5 /* Dictionary */ || resolved.kind === 9 /* Lookup */ || resolved.kind === 27 /* Variant */;
19329
+ const needsGenericEnv = resolved.kind === 21 /* Generic */ || resolved.kind === 7 /* Class */ || resolved.kind === 6 /* List */ || resolved.kind === 28 /* Set */ || resolved.kind === 5 /* Dictionary */ || resolved.kind === 9 /* Lookup */ || resolved.kind === 27 /* Variant */;
19197
19330
  const env = needsGenericEnv ? runtimeGenericEnvForValueRow(owner, ctx, /* @__PURE__ */ new Set()) : /* @__PURE__ */ new Map();
19198
19331
  const member = substituteMember(
19199
19332
  raw,
@@ -19565,7 +19698,7 @@ function applyOverlayAssignment(target, targetTypeInfo, value, scope, ctx, desti
19565
19698
  const receiver = destination === void 0 ? evalPointer(target.keyOf.pointer, scope, ctx) : destination.receiver;
19566
19699
  const key = destination === void 0 ? evalPointer(target.keyOf.key, scope, ctx) : destination.key;
19567
19700
  assertStoredReplayMutableValue(receiver, ctx, "assignment target", key);
19568
- const referenceValueId = targetTypeInfo.type === 7 /* Class */ || targetTypeInfo.type === 6 /* List */ || targetTypeInfo.type === 5 /* Dictionary */ ? findKnownRowIdByValueReference(value, ctx) : null;
19701
+ const referenceValueId = targetTypeInfo.type === 7 /* Class */ || targetTypeInfo.type === 6 /* List */ || targetTypeInfo.type === 28 /* Set */ || targetTypeInfo.type === 5 /* Dictionary */ ? findKnownRowIdByValueReference(value, ctx) : null;
19569
19702
  if (Array.isArray(receiver)) {
19570
19703
  const index = numberArg(key, "List assignment index");
19571
19704
  if (referenceValueId !== null) {
@@ -19603,9 +19736,8 @@ function applyOverlayAssignment(target, targetTypeInfo, value, scope, ctx, desti
19603
19736
  ctx.__valueOverlay
19604
19737
  );
19605
19738
  if (row !== null) {
19606
- row.value = value;
19739
+ replaceRowValue(row, value, receiver, ctx);
19607
19740
  updateUnorderedListProjectionAfterAssignment(row, value, ctx);
19608
- invalidateEvaluatorIndexes(ctx, receiver);
19609
19741
  return;
19610
19742
  }
19611
19743
  }
@@ -19641,15 +19773,28 @@ function applyOverlayAssignment(target, targetTypeInfo, value, scope, ctx, desti
19641
19773
  ctx.__valueOverlay
19642
19774
  );
19643
19775
  if (row !== null) {
19644
- row.value = value;
19776
+ replaceRowValue(row, value, receiver, ctx);
19645
19777
  updateUnorderedListProjectionAfterAssignment(row, value, ctx);
19646
- invalidateEvaluatorIndexes(ctx, receiver);
19647
19778
  return;
19648
19779
  }
19649
19780
  }
19650
19781
  object[stringKey] = value;
19651
19782
  invalidateEvaluatorIndexes(ctx, receiver);
19652
19783
  }
19784
+ function replaceRowValue(row, value, receiver, ctx) {
19785
+ const indexes3 = ctx.__indexes;
19786
+ if (indexes3 === void 0 || ctx.__runtimeSessionValues?.get(row.id) !== row || !indexes3.indexedRowIds.has(row.id)) {
19787
+ row.value = value;
19788
+ invalidateEvaluatorIndexes(ctx, receiver);
19789
+ return;
19790
+ }
19791
+ unindexEvaluatorRow(indexes3, row, true);
19792
+ row.value = value;
19793
+ indexEvaluatorRow(indexes3, row, true);
19794
+ markOverlayMutated(ctx, receiver);
19795
+ if (ctx.__valueOverlay instanceof LazyValueOverlay)
19796
+ indexes3.overlayRevision = ctx.__valueOverlay.revision;
19797
+ }
19653
19798
  function applyOverlayStaticAssignment(memberId, value, ctx) {
19654
19799
  const member = evalMemberById(ctx.vm, memberId);
19655
19800
  if (member === null || !isStaticMember(member)) {
@@ -19670,7 +19815,7 @@ function applyOverlayStaticAssignment(memberId, value, ctx) {
19670
19815
  }
19671
19816
  const currentId = staticBindingTargetId(member, ctx);
19672
19817
  const resolved = resolveMember(member, ctx.vm.members);
19673
- const referenceAssignment = isMemberClassBase(resolved) || isMemberListBase(resolved) || isMemberDictionaryBase(resolved);
19818
+ const referenceAssignment = isMemberClassBase(resolved) || isMemberWithEntries(resolved);
19674
19819
  const trackedId = findKnownRowIdByValueReference(value, ctx);
19675
19820
  if (referenceAssignment && trackedId !== null) {
19676
19821
  assertOwnedValueAttachable(
@@ -19755,8 +19900,7 @@ function bindOmittedConstantSlot(destination, member, value, ctx) {
19755
19900
  if (construction === void 0) return false;
19756
19901
  const key = String(destination.key);
19757
19902
  if (Object.prototype.hasOwnProperty.call(receiver, key)) return false;
19758
- if (isMemberClassBase(member) || isMemberListBase(member) || isMemberDictionaryBase(member))
19759
- return false;
19903
+ if (isMemberClassBase(member) || isMemberWithEntries(member)) return false;
19760
19904
  const resolved = resolveMember(member, ctx.vm.members);
19761
19905
  const decision = constantMemberDecision(
19762
19906
  constructorDefaultValueDocument(ctx, member),
@@ -19864,7 +20008,7 @@ function resolvedDestinationFieldsForAssign(target, scope, ctx, destination) {
19864
20008
  receiver: container,
19865
20009
  key
19866
20010
  });
19867
- const assignsUnorderedList = targetMember !== null && isMemberListBase(targetMember) && listKindOf(targetMember) === 1 /* Unordered */;
20011
+ const assignsUnorderedList = targetMember !== null && isMemberEntryCollectionBase(targetMember) && listKindOf(targetMember) === 1 /* Unordered */;
19868
20012
  return {
19869
20013
  resolvedDestination: {
19870
20014
  containerValueId,
@@ -19890,7 +20034,7 @@ function resolvedDestinationFieldsForContainer(targetValue, ctx) {
19890
20034
  return containerValueId === null ? {} : { resolvedDestination: { containerValueId } };
19891
20035
  }
19892
20036
  function dispatchNSSetter(target, value, scope, ctx, writes) {
19893
- consumeBudget(ctx, "workUnits", 1, "work unit");
20037
+ checkDeadline(ctx);
19894
20038
  if (target.type !== "callGetter" /* callGetter */) {
19895
20039
  throw new NSGetterRuntimeError(
19896
20040
  "Setter write target must be a callGetter pointer."
@@ -20011,14 +20155,12 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
20011
20155
  );
20012
20156
  }
20013
20157
  const args = ins.args.map((arg) => evalPointer(arg, scope, ctx));
20014
- const isLookupSet = ins.target.typeInfo.type === 9 /* Lookup */;
20015
- if (ins.mutation === "Add" /* Add */ || ins.mutation === "Insert" /* Insert */) {
20016
- consumeBudget(
20017
- ctx,
20018
- "producedCollectionEntries",
20019
- 1,
20020
- "produced collection entry"
20021
- );
20158
+ const setEntryMember = mutatesLocalVariable ? null : storedSetEntryMember(targetValue, ctx);
20159
+ const isLookupSet = setEntryMember === null && ins.target.typeInfo.type === 9 /* Lookup */;
20160
+ const setMatch = setEntryMember !== null && Array.isArray(targetValue) && (ins.mutation === "Add" /* Add */ || ins.mutation === "Remove" /* Remove */) ? findStoredSetEntry(targetValue, args[0], setEntryMember, ctx) : null;
20161
+ if (ins.mutation === "Add" /* Add */ && setMatch !== null) return;
20162
+ if (ins.mutation === "Remove" /* Remove */ && setEntryMember !== null && setMatch === null) {
20163
+ return;
20022
20164
  }
20023
20165
  if (mutatesLocalVariable && variablePointer !== null) {
20024
20166
  if (isLookupSet && (ins.mutation === "Add" /* Add */ || ins.mutation === "Remove" /* Remove */)) {
@@ -20039,14 +20181,22 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
20039
20181
  removedIndex2,
20040
20182
  ctx
20041
20183
  );
20042
- invalidateEvaluatorIndexes(ctx, targetValue);
20184
+ if (Array.isArray(targetValue)) forgetLocalListIndexes(ctx, targetValue);
20043
20185
  scope.setLocal(variablePointer.variableId, targetValue);
20044
20186
  return;
20045
20187
  }
20046
20188
  validateCollectionMutation(targetValue, ins.mutation, args);
20047
20189
  const overlayArgs = [...args];
20048
20190
  if ((ins.mutation === "Add" /* Add */ || ins.mutation === "Remove" /* Remove */) && Array.isArray(targetValue)) {
20049
- overlayArgs[0] = isLookupSet ? lookupSetSelectionValue(args[0], ins.target.typeInfo, ctx) : findKnownRowIdByValueReference(args[0], ctx) ?? args[0];
20191
+ if (setMatch !== null) overlayArgs[0] = setMatch.entry;
20192
+ else if (isLookupSet)
20193
+ overlayArgs[0] = lookupSetSelectionValue(
20194
+ args[0],
20195
+ ins.target.typeInfo,
20196
+ ctx
20197
+ );
20198
+ else
20199
+ overlayArgs[0] = findKnownRowIdByValueReference(args[0], ctx) ?? args[0];
20050
20200
  } else if (ins.mutation === "Insert" /* Insert */) {
20051
20201
  overlayArgs[1] = findKnownRowIdByValueReference(args[1], ctx) ?? args[1];
20052
20202
  } else if (ins.mutation === "Add" /* Add */ && !Array.isArray(targetValue)) {
@@ -20056,8 +20206,7 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
20056
20206
  overlayArgs[0] = createUnorderedScalarProjectionEntry(
20057
20207
  unorderedContainerValueId,
20058
20208
  args[0],
20059
- ctx,
20060
- false
20209
+ ctx
20061
20210
  );
20062
20211
  }
20063
20212
  const unorderedEntriesBeforeMutation = unorderedContainerValueId === null || !Array.isArray(targetValue) || ins.mutation === "Add" /* Add */ ? null : [...targetValue];
@@ -20107,6 +20256,15 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
20107
20256
  ctx
20108
20257
  );
20109
20258
  }
20259
+ if (Array.isArray(targetValue)) {
20260
+ syncStoredSetEntries(
20261
+ targetValue,
20262
+ ins.mutation,
20263
+ setMatch,
20264
+ setEntryMember,
20265
+ ctx
20266
+ );
20267
+ }
20110
20268
  invalidateEvaluatorIndexes(ctx, targetValue);
20111
20269
  switch (ins.mutation) {
20112
20270
  case "Insert" /* Insert */:
@@ -20148,7 +20306,7 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
20148
20306
  target: ins.target,
20149
20307
  value: isLookupSet ? overlayArgs[0] : args[0],
20150
20308
  ...!isLookupSet ? {
20151
- valueId: findKnownRowIdByValueReference(args[0], ctx) ?? void 0
20309
+ valueId: setMatch?.valueId ?? findKnownRowIdByValueReference(args[0], ctx) ?? void 0
20152
20310
  } : {},
20153
20311
  ...resolvedDestinationFieldsForContainer(targetValue, ctx)
20154
20312
  });
@@ -20178,18 +20336,83 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
20178
20336
  return;
20179
20337
  }
20180
20338
  }
20339
+ function storedSetEntryMember(collection, ctx) {
20340
+ const containerId = findKnownRowIdByValueReference(collection, ctx);
20341
+ if (containerId === null) return null;
20342
+ const container = evalValueById(
20343
+ ctx,
20344
+ containerId,
20345
+ ctx.__runtimeSessionValues,
20346
+ ctx.__valueOverlay
20347
+ );
20348
+ if (container === null) return null;
20349
+ const member = memberForValueRow(container, ctx);
20350
+ if (member === null || member.kind !== 28 /* Set */) return null;
20351
+ const resolved = resolveMember(member, ctx.vm.members);
20352
+ if (!isMemberSetBase(resolved)) {
20353
+ throw new NSGetterRuntimeError(
20354
+ `Set member '${member.name}' is not a valid Set record.`
20355
+ );
20356
+ }
20357
+ const entry = evalMemberById(ctx.vm, resolved.entryMemberId);
20358
+ if (entry === null) {
20359
+ throw new NSGetterRuntimeError(
20360
+ `Set member '${member.name}' references missing entry member '${resolved.entryMemberId}'.`
20361
+ );
20362
+ }
20363
+ return substituteMember(
20364
+ entry,
20365
+ runtimeGenericEnvForValueRow(container, ctx),
20366
+ ctx.vm.members
20367
+ );
20368
+ }
20369
+ function storedSetEntryMatch(raw, entryMember, ctx) {
20370
+ const byIdentity = entryMember.kind === 7 /* Class */;
20371
+ const row = byIdentity || typeof raw !== "string" ? null : evalValueById(ctx, raw, ctx.__runtimeSessionValues, ctx.__valueOverlay);
20372
+ const valueId = byIdentity && typeof raw === "string" ? raw : row?.id ?? null;
20373
+ const entry = row === null ? { id: "", value: raw } : { id: row.id, value: row.value };
20374
+ const key = byIdentity ? valueId ?? referenceIdOf(raw, ctx) : setEntryKey(entryMember, entry);
20375
+ return key === null ? null : { key, entry: raw, valueId };
20376
+ }
20377
+ function storedSetEntries(set, entryMember, ctx) {
20378
+ const indexes3 = ctx.__setEntryIndexes ??= /* @__PURE__ */ new WeakMap();
20379
+ const existing = indexes3.get(set);
20380
+ if (existing !== void 0) return existing;
20381
+ const entries = /* @__PURE__ */ new Map();
20382
+ for (const raw of set) {
20383
+ const match = storedSetEntryMatch(raw, entryMember, ctx);
20384
+ if (match !== null && !entries.has(match.key)) {
20385
+ entries.set(match.key, match);
20386
+ }
20387
+ }
20388
+ indexes3.set(set, entries);
20389
+ return entries;
20390
+ }
20391
+ function syncStoredSetEntries(set, mutation, removed, entryMember, ctx) {
20392
+ const entries = ctx.__setEntryIndexes?.get(set);
20393
+ if (entries === void 0) return;
20394
+ if (entryMember !== null && mutation === "Add" /* Add */) {
20395
+ const added = storedSetEntryMatch(set[set.length - 1], entryMember, ctx);
20396
+ if (added !== null) entries.set(added.key, added);
20397
+ return;
20398
+ }
20399
+ if (removed !== null && mutation === "Remove" /* Remove */) {
20400
+ entries.delete(removed.key);
20401
+ return;
20402
+ }
20403
+ ctx.__setEntryIndexes?.delete(set);
20404
+ }
20405
+ function findStoredSetEntry(set, value, entryMember, ctx) {
20406
+ const key = entryMember.kind === 7 /* Class */ ? referenceIdOf(value, ctx) : setEntryKey(entryMember, { id: "", value });
20407
+ if (key === null) return null;
20408
+ return storedSetEntries(set, entryMember, ctx).get(key) ?? null;
20409
+ }
20181
20410
  function applyLocalCollectionMutation(targetValue, mutation, args, ctx, unique = false, resolveJoinedRemovalEntries = false, reference = false) {
20182
20411
  validateCollectionMutation(targetValue, mutation, args);
20183
20412
  switch (mutation) {
20184
20413
  case "Insert" /* Insert */: {
20185
20414
  const list = listArg(targetValue, "Insert target");
20186
20415
  const index = numberArg(args[0], "Insert index");
20187
- consumeBudget(
20188
- ctx,
20189
- "collectionVisits",
20190
- list.length - index,
20191
- "collection visit"
20192
- );
20193
20416
  list.splice(index, 0, args[1]);
20194
20417
  return index;
20195
20418
  }
@@ -20198,7 +20421,6 @@ function applyLocalCollectionMutation(targetValue, mutation, args, ctx, unique =
20198
20421
  let alreadyPresent = false;
20199
20422
  if (unique) {
20200
20423
  for (const entry of targetValue) {
20201
- consumeBudget(ctx, "collectionVisits", 1, "collection visit");
20202
20424
  if (reference ? referenceEqual(entry, args[0], ctx) : jsEqual(entry, args[0])) {
20203
20425
  alreadyPresent = true;
20204
20426
  break;
@@ -20216,7 +20438,6 @@ function applyLocalCollectionMutation(targetValue, mutation, args, ctx, unique =
20216
20438
  if (Array.isArray(targetValue)) {
20217
20439
  let index = -1;
20218
20440
  for (let candidate = 0; candidate < targetValue.length; candidate += 1) {
20219
- consumeBudget(ctx, "collectionVisits", 1, "collection visit");
20220
20441
  const entry = targetValue[candidate];
20221
20442
  if (reference) {
20222
20443
  if (referenceEqual(entry, args[0], ctx)) {
@@ -20250,17 +20471,10 @@ function applyLocalCollectionMutation(targetValue, mutation, args, ctx, unique =
20250
20471
  }
20251
20472
  case "Clear" /* Clear */:
20252
20473
  if (Array.isArray(targetValue)) {
20253
- consumeBudget(
20254
- ctx,
20255
- "collectionVisits",
20256
- targetValue.length,
20257
- "collection visit"
20258
- );
20259
20474
  targetValue.length = 0;
20260
20475
  return null;
20261
20476
  }
20262
20477
  const keys = Object.keys(objectArg(targetValue, "Clear target"));
20263
- consumeBudget(ctx, "collectionVisits", keys.length, "collection visit");
20264
20478
  for (const key of keys) {
20265
20479
  delete objectArg(targetValue, "Clear target")[key];
20266
20480
  }
@@ -20547,20 +20761,8 @@ function evalPointerCore(pointer, scope, ctx, resultUsage = "value") {
20547
20761
  case "function" /* function */:
20548
20762
  return evalFunction(pointer.function, scope, ctx);
20549
20763
  case "listLiteral" /* listLiteral */:
20550
- consumeBudget(
20551
- ctx,
20552
- "producedCollectionEntries",
20553
- pointer.entries.length,
20554
- "produced collection entry"
20555
- );
20556
20764
  return pointer.entries.map((e) => evalPointer(e, scope, ctx));
20557
20765
  case "dictLiteral" /* dictLiteral */: {
20558
- consumeBudget(
20559
- ctx,
20560
- "producedCollectionEntries",
20561
- pointer.entries.length,
20562
- "produced collection entry"
20563
- );
20564
20766
  const out = {};
20565
20767
  for (const e of pointer.entries) {
20566
20768
  const k = evalPointer(e.key, scope, ctx);
@@ -20626,7 +20828,7 @@ function evalPointerCore(pointer, scope, ctx, resultUsage = "value") {
20626
20828
  }
20627
20829
  const args = fillCallableCallSiteArguments(suppliedArgs, member, ctx);
20628
20830
  const interceptedMemberId = member?.id ?? pointer.memberId ?? pointer.memberKey ?? pointer.callSiteId;
20629
- consumeBudget(ctx, "workUnits", 1, "work unit");
20831
+ checkDeadline(ctx);
20630
20832
  const intercepted = ctx.callInterceptor?.({
20631
20833
  resultUsage,
20632
20834
  memberId: interceptedMemberId,
@@ -20769,7 +20971,7 @@ function evalPointerCore(pointer, scope, ctx, resultUsage = "value") {
20769
20971
  case "callAction" /* callAction */: {
20770
20972
  const read = readActionWithOwner(pointer.action, scope, ctx);
20771
20973
  const args = pointer.args.map((arg) => evalPointer(arg, scope, ctx));
20772
- consumeBudget(ctx, "workUnits", 1, "work unit");
20974
+ checkDeadline(ctx);
20773
20975
  invokeActionListeners(
20774
20976
  actionListenersOf(
20775
20977
  read.action,
@@ -20827,12 +21029,6 @@ function evalPointerCore(pointer, scope, ctx, resultUsage = "value") {
20827
21029
  case "stringify" /* stringify */: {
20828
21030
  const v = evalPointer(pointer.pointer, scope, ctx);
20829
21031
  const formatted = formatForInterp(v, pointer.sourceType, ctx);
20830
- consumeBudget(
20831
- ctx,
20832
- "producedStringCharacters",
20833
- formatted.length,
20834
- "produced string character"
20835
- );
20836
21032
  return formatted;
20837
21033
  }
20838
21034
  }
@@ -20960,7 +21156,7 @@ function invokeDelegateValue(value, args, ctx, callSiteId, ownerReceiver, result
20960
21156
  ].join(" -> ")}.`
20961
21157
  );
20962
21158
  }
20963
- consumeBudget(ctx, "workUnits", 1, "work unit");
21159
+ checkDeadline(ctx);
20964
21160
  const intercept = () => ctx.callInterceptor?.({
20965
21161
  resultUsage,
20966
21162
  memberId: member.id,
@@ -21085,17 +21281,17 @@ function invokeDelegateValue(value, args, ctx, callSiteId, ownerReceiver, result
21085
21281
  state.delegateStack.pop();
21086
21282
  }
21087
21283
  }
21088
- function actionListenersOf(value, describe) {
21284
+ function actionListenersOf(value, describe2) {
21089
21285
  if (value === null || value === void 0) return [];
21090
21286
  if (!isNSActionValue(value)) {
21091
21287
  throw new NSGetterRuntimeError(
21092
- `NeoAction ${describe()} holds a value that is not a valid listener set \u2014 every entry must be a distinct member target.`
21288
+ `NeoAction ${describe2()} holds a value that is not a valid listener set \u2014 every entry must be a distinct member target.`
21093
21289
  );
21094
21290
  }
21095
21291
  return value.listeners;
21096
21292
  }
21097
21293
  function storedActionListeners(member, receiver, ctx) {
21098
- const describe = () => `target '${member.name}'`;
21294
+ const describe2 = () => `target '${member.name}'`;
21099
21295
  if (receiver !== null) {
21100
21296
  const schemaKey = cachedSchemaKeyForMember(member.id, ctx);
21101
21297
  if (schemaKey === null) {
@@ -21115,11 +21311,11 @@ function storedActionListeners(member, receiver, ctx) {
21115
21311
  member,
21116
21312
  ctx
21117
21313
  ),
21118
- describe
21314
+ describe2
21119
21315
  );
21120
21316
  }
21121
21317
  if (isStaticMember(member) === true) {
21122
- return actionListenersOf(evalStaticMember(member.id, ctx), describe);
21318
+ return actionListenersOf(evalStaticMember(member.id, ctx), describe2);
21123
21319
  }
21124
21320
  if (member.defaultValue === void 0 || member.defaultValue === null) {
21125
21321
  return [];
@@ -21129,7 +21325,7 @@ function storedActionListeners(member, receiver, ctx) {
21129
21325
  `NeoAction target '${member.name}' has an unevaluated initializer instead of a declaration default listener set.`
21130
21326
  );
21131
21327
  }
21132
- return actionListenersOf(member.defaultValue.value, describe);
21328
+ return actionListenersOf(member.defaultValue.value, describe2);
21133
21329
  }
21134
21330
  function listenerReceiverOnOwner(memberId, ownerReceiver, ctx) {
21135
21331
  const schemaKey = cachedSchemaKeyForMember(memberId, ctx);
@@ -21337,7 +21533,7 @@ function typeInfoContainsGeneric(typeInfo, visited = /* @__PURE__ */ new Set())
21337
21533
  const nextVisited = new Set(visited);
21338
21534
  nextVisited.add(typeInfo);
21339
21535
  if (typeInfo.type === 21 /* Generic */) return true;
21340
- if (typeInfo.type === 6 /* List */ || typeInfo.type === 5 /* Dictionary */ || typeInfo.type === 9 /* Lookup */) {
21536
+ if (typeInfo.type === 6 /* List */ || typeInfo.type === 28 /* Set */ || typeInfo.type === 5 /* Dictionary */ || typeInfo.type === 9 /* Lookup */) {
21341
21537
  return typeInfoContainsGeneric(typeInfo.entryTypeInfo, nextVisited);
21342
21538
  }
21343
21539
  if (typeInfo.type !== 7 /* Class */) return false;
@@ -21408,7 +21604,7 @@ function genericParametersConcretelyBound(typeInfo, env) {
21408
21604
  if (typeInfo.type === 21 /* Generic */) {
21409
21605
  return env.get(typeInfo.genericParamId)?.kind === "member";
21410
21606
  }
21411
- if (typeInfo.type === 6 /* List */ || typeInfo.type === 5 /* Dictionary */ || typeInfo.type === 9 /* Lookup */) {
21607
+ if (typeInfo.type === 6 /* List */ || typeInfo.type === 28 /* Set */ || typeInfo.type === 5 /* Dictionary */ || typeInfo.type === 9 /* Lookup */) {
21412
21608
  return genericParametersConcretelyBound(typeInfo.entryTypeInfo, env);
21413
21609
  }
21414
21610
  if (typeInfo.type === 25 /* NSDelegate */) {
@@ -21439,7 +21635,7 @@ function substituteRuntimeTypeInfo(typeInfo, env, ctx) {
21439
21635
  const boundType = runtimeTypeInfoForMember(member, env, ctx, /* @__PURE__ */ new Set());
21440
21636
  return { ...boundType, required: boundType.required && typeInfo.required };
21441
21637
  }
21442
- if (typeInfo.type === 6 /* List */ || typeInfo.type === 5 /* Dictionary */ || typeInfo.type === 9 /* Lookup */) {
21638
+ if (typeInfo.type === 6 /* List */ || typeInfo.type === 28 /* Set */ || typeInfo.type === 5 /* Dictionary */ || typeInfo.type === 9 /* Lookup */) {
21443
21639
  return {
21444
21640
  ...typeInfo,
21445
21641
  entryTypeInfo: substituteRuntimeTypeInfo(
@@ -21539,7 +21735,7 @@ function runtimeTypeInfoForMember(rawMember, env, ctx, seen) {
21539
21735
  enumId: member.enumId
21540
21736
  };
21541
21737
  }
21542
- if (isMemberList(member) || isMemberDictionary(member)) {
21738
+ if (isMemberList(member) || isMemberSet(member) || isMemberDictionary(member)) {
21543
21739
  const entryMember = evalMemberById(ctx.vm, member.entryMemberId);
21544
21740
  if (entryMember === null) {
21545
21741
  throw new NSGetterRuntimeError(
@@ -21579,7 +21775,7 @@ function runtimeTypeInfoForMember(rawMember, env, ctx, seen) {
21579
21775
  ctx,
21580
21776
  new Set(seen)
21581
21777
  );
21582
- if (collectionTypeInfo.type !== 6 /* List */ && collectionTypeInfo.type !== 5 /* Dictionary */) {
21778
+ if (collectionTypeInfo.type !== 6 /* List */ && collectionTypeInfo.type !== 28 /* Set */ && collectionTypeInfo.type !== 5 /* Dictionary */) {
21583
21779
  throw new NSGetterRuntimeError(
21584
21780
  `Lookup binding '${member.id}' does not target a collection.`
21585
21781
  );
@@ -21664,7 +21860,7 @@ function formatDebugValue(value, type, ctx) {
21664
21860
  );
21665
21861
  if (type.type === 9 /* Lookup */ && type.entryTypeInfo.type === 8 /* Enum */)
21666
21862
  type = type.entryTypeInfo;
21667
- if (value !== null && value !== void 0 && (type.type === 7 /* Class */ || type.type === 6 /* List */ || type.type === 5 /* Dictionary */ || type.type === 9 /* Lookup */)) {
21863
+ if (value !== null && value !== void 0 && (type.type === 7 /* Class */ || type.type === 6 /* List */ || type.type === 28 /* Set */ || type.type === 5 /* Dictionary */ || type.type === 9 /* Lookup */)) {
21668
21864
  return formatNeoScriptDebugValue(
21669
21865
  formatForInterp(value, type, ctx),
21670
21866
  3 /* String */
@@ -21706,13 +21902,14 @@ function formatForInterp(value, sourceType, ctx) {
21706
21902
  const rowId = findRowIdByValueReference(value, ctx);
21707
21903
  return `(Class<${typeName}>, Value<${rowId}>)`;
21708
21904
  }
21709
- case 6 /* List */: {
21905
+ case 6 /* List */:
21906
+ case 28 /* Set */: {
21710
21907
  const entryName = describeRuntimeType(
21711
21908
  sourceType.entryTypeInfo,
21712
21909
  ctx
21713
21910
  );
21714
21911
  const rowId = findRowIdByValueReference(value, ctx);
21715
- return `(List<${entryName}>, Value<${rowId}>)`;
21912
+ return `(${MemberKind[sourceType.type]}<${entryName}>, Value<${rowId}>)`;
21716
21913
  }
21717
21914
  case 5 /* Dictionary */: {
21718
21915
  const entryName = describeRuntimeType(
@@ -21774,6 +21971,8 @@ function describeRuntimeType(t, ctx) {
21774
21971
  }
21775
21972
  case 6 /* List */:
21776
21973
  return `List<${describeRuntimeType(t.entryTypeInfo, ctx)}>`;
21974
+ case 28 /* Set */:
21975
+ return `Set<${describeRuntimeType(t.entryTypeInfo, ctx)}>`;
21777
21976
  case 5 /* Dictionary */:
21778
21977
  return `Dictionary<${describeRuntimeType(t.entryTypeInfo, ctx)}>`;
21779
21978
  case 9 /* Lookup */:
@@ -21873,6 +22072,7 @@ function runtimeTypeCheck(value, checkType, ctx, seenCollections = /* @__PURE__
21873
22072
  case 18 /* DialogueLookup */:
21874
22073
  return Array.isArray(value) && value.length === 1 && typeof value[0] === "string";
21875
22074
  case 6 /* List */:
22075
+ case 28 /* Set */:
21876
22076
  case 9 /* Lookup */: {
21877
22077
  if (!Array.isArray(value)) return false;
21878
22078
  if (seenCollections.has(value)) return false;
@@ -22190,7 +22390,7 @@ function readDeclarationDefault(member, ctx) {
22190
22390
  if (member?.defaultValue === void 0 || member.defaultValue === null) {
22191
22391
  return { matched: false };
22192
22392
  }
22193
- if (isInitValueContent(member.defaultValue) || isMemberClassBase(member) || isMemberListBase(member) || isMemberDictionaryBase(member)) {
22393
+ if (isInitValueContent(member.defaultValue) || isMemberClassBase(member) || isMemberWithEntries(member)) {
22194
22394
  const session = ctx.__runtimeSessionValues;
22195
22395
  let shared;
22196
22396
  if (session !== void 0) {
@@ -22319,7 +22519,7 @@ function resolveValueIfId(at2, ctx) {
22319
22519
  );
22320
22520
  if (!row) return at2;
22321
22521
  const member = memberForValueRow(row, ctx);
22322
- if (member !== null && isMemberListBase(member) && listKindOf(member) === 1 /* Unordered */ && Array.isArray(row.value)) {
22522
+ if (member !== null && isMemberEntryCollectionBase(member) && listKindOf(member) === 1 /* Unordered */ && Array.isArray(row.value)) {
22323
22523
  return evaluatorUnorderedListEntryIds(row.id, ctx);
22324
22524
  }
22325
22525
  const value = member === null ? resolveLocalizedRowValue(row, ctx) : resolveLocalizedRowValueForMember(row, member, ctx);
@@ -22336,7 +22536,7 @@ function resolveValueIfIdForMember(at2, member, ctx) {
22336
22536
  ctx.__valueOverlay
22337
22537
  );
22338
22538
  if (!row) return at2;
22339
- if (isMemberListBase(member) && listKindOf(member) === 1 /* Unordered */ && Array.isArray(row.value)) {
22539
+ if (isMemberEntryCollectionBase(member) && listKindOf(member) === 1 /* Unordered */ && Array.isArray(row.value)) {
22340
22540
  return evaluatorUnorderedListEntryIds(row.id, ctx);
22341
22541
  }
22342
22542
  const value = resolveLocalizedRowValueForMember(row, member, ctx);
@@ -22351,7 +22551,7 @@ function createUnorderedListProjectionCache() {
22351
22551
  referenceEntryKeysByRecord: /* @__PURE__ */ new WeakMap()
22352
22552
  };
22353
22553
  }
22354
- function createUnorderedScalarProjectionEntry(containerValueId, value, ctx, consumeEntryBudget = true) {
22554
+ function createUnorderedScalarProjectionEntry(containerValueId, value, ctx) {
22355
22555
  const container = evalValueById(
22356
22556
  ctx,
22357
22557
  containerValueId,
@@ -22363,14 +22563,6 @@ function createUnorderedScalarProjectionEntry(containerValueId, value, ctx, cons
22363
22563
  `Unordered List container '${containerValueId}' is missing.`
22364
22564
  );
22365
22565
  }
22366
- if (consumeEntryBudget) {
22367
- consumeBudget(
22368
- ctx,
22369
- "producedCollectionEntries",
22370
- 1,
22371
- "produced collection entry"
22372
- );
22373
- }
22374
22566
  ctx.beforeValueAllocation?.();
22375
22567
  const now = Date.now();
22376
22568
  const row = {
@@ -22420,7 +22612,7 @@ function invalidateUnorderedListProjection(containerValueId, ctx) {
22420
22612
  function updateUnorderedListProjectionAfterAssignment(row, value, ctx) {
22421
22613
  invalidateUnorderedListProjection(row.id, ctx);
22422
22614
  const member = memberForValueRow(row, ctx);
22423
- if (member === null || !isMemberListBase(member) || listKindOf(member) !== 1 /* Unordered */ || !Array.isArray(value)) {
22615
+ if (member === null || !isMemberEntryCollectionBase(member) || listKindOf(member) !== 1 /* Unordered */ || !Array.isArray(value)) {
22424
22616
  return;
22425
22617
  }
22426
22618
  const referenceIndexes = ctx.__unorderedListProjections?.referenceEntryIndexesByArray.get(value);
@@ -22547,10 +22739,7 @@ function resolveMemberForValueRow(row, ctx, visited) {
22547
22739
  ctx,
22548
22740
  new Set(visited)
22549
22741
  );
22550
- if (parentMember !== null && isMemberList(parentMember)) {
22551
- return evalMemberById(ctx.vm, parentMember.entryMemberId);
22552
- }
22553
- if (parentMember !== null && isMemberDictionary(parentMember)) {
22742
+ if (parentMember !== null && isMemberWithEntries(parentMember)) {
22554
22743
  return evalMemberById(ctx.vm, parentMember.entryMemberId);
22555
22744
  }
22556
22745
  const classId = parent.classId ?? (parentMember !== null && isMemberClass(parentMember) ? parentMember.classId : void 0);
@@ -22761,9 +22950,16 @@ function readCellPattern(value, ctx) {
22761
22950
  }
22762
22951
  return offsets;
22763
22952
  }
22953
+ function readGridQueryOffset(value) {
22954
+ if (value === void 0 || value === null) return null;
22955
+ if (!isVector2IntValue(value)) {
22956
+ throw new NSGetterRuntimeError("Grid query offset must be a Vector2Int.");
22957
+ }
22958
+ return value;
22959
+ }
22764
22960
  function evaluateSystemNative(memberId, receiver, args, ctx) {
22765
22961
  try {
22766
- if (memberId === NEO_OBJECT_GRID_MEMBER_IDS.GetCell || memberId === NEO_OBJECT_GRID_MEMBER_IDS.GetObjects || memberId === NEO_OBJECT_GRID_MEMBER_IDS.GetTile) {
22962
+ if (memberId === NEO_OBJECT_GRID_MEMBER_IDS.GetCell || memberId === NEO_OBJECT_GRID_MEMBER_IDS.GetObjects || memberId === NEO_OBJECT_GRID_MEMBER_IDS.GetTile || memberId === NEO_OBJECT_GRID_MEMBER_IDS.GetTiles) {
22767
22963
  const receiverRow = trackedRowForValueReference(receiver, ctx);
22768
22964
  if (receiverRow === null) {
22769
22965
  throw new NSGetterRuntimeError(
@@ -22778,21 +22974,31 @@ function evaluateSystemNative(memberId, receiver, args, ctx) {
22778
22974
  if (memberId === NEO_OBJECT_GRID_MEMBER_IDS.GetCell)
22779
22975
  return { handled: true, value: { ...placement.cell } };
22780
22976
  const offsets = readCellPattern(args[0], ctx);
22977
+ const shift = readGridQueryOffset(args[1]);
22781
22978
  if (memberId === NEO_OBJECT_GRID_MEMBER_IDS.GetObjects) {
22782
22979
  const value = index.objects(
22783
22980
  placement,
22784
22981
  offsets,
22785
22982
  ctx.worldQueryDependencies,
22786
- (count) => consumeBudget(
22787
- ctx,
22788
- "producedCollectionEntries",
22789
- count,
22790
- "collection entry"
22791
- )
22983
+ shift
22984
+ );
22985
+ return { handled: true, value };
22986
+ }
22987
+ if (memberId === NEO_OBJECT_GRID_MEMBER_IDS.GetTiles) {
22988
+ const value = index.tiles(
22989
+ placement,
22990
+ offsets,
22991
+ ctx.worldQueryDependencies,
22992
+ shift
22792
22993
  );
22793
22994
  return { handled: true, value };
22794
22995
  }
22795
- const tile = index.tile(placement, offsets, ctx.worldQueryDependencies);
22996
+ const tile = index.tile(
22997
+ placement,
22998
+ offsets,
22999
+ ctx.worldQueryDependencies,
23000
+ shift
23001
+ );
22796
23002
  if (tile === null) return { handled: true, value: null };
22797
23003
  const row = evalValueById(
22798
23004
  ctx,
@@ -22840,14 +23046,7 @@ function evaluateSystemNative(memberId, receiver, args, ctx) {
22840
23046
  },
22841
23047
  createTopLevelScope(ctx),
22842
23048
  ctx
22843
- ),
22844
- reserveEntries: (count) => consumeBudget(
22845
- ctx,
22846
- "producedCollectionEntries",
22847
- count,
22848
- "collection entry"
22849
- ),
22850
- visitEntries: (count) => consumeBudget(ctx, "collectionVisits", count, "collection visit")
23049
+ )
22851
23050
  });
22852
23051
  } catch (error) {
22853
23052
  if (error instanceof RangeError || error instanceof TypeError || error instanceof WorldGridQueryError) {
@@ -22919,22 +23118,10 @@ function applyArithmetic(op, operands, decimal, ctx, numeric) {
22919
23118
  }
22920
23119
  if (op === "+" /* addition */ && operands.every((o) => typeof o === "string")) {
22921
23120
  const result = operands.join("");
22922
- consumeBudget(
22923
- ctx,
22924
- "producedStringCharacters",
22925
- result.length,
22926
- "produced string character"
22927
- );
22928
23121
  return result;
22929
23122
  }
22930
23123
  if (op === "+" /* addition */ && operands.some((o) => typeof o === "string")) {
22931
23124
  const result = operands.map((o) => stringifyForInterp(o)).join("");
22932
- consumeBudget(
22933
- ctx,
22934
- "producedStringCharacters",
22935
- result.length,
22936
- "produced string character"
22937
- );
22938
23125
  return result;
22939
23126
  }
22940
23127
  const numbers = operands.map((o) => {
@@ -23212,12 +23399,6 @@ function evalListRepeat(info, scope, ctx) {
23212
23399
  `List.Repeat count must be non-negative; got ${count}.`
23213
23400
  );
23214
23401
  }
23215
- consumeBudget(
23216
- ctx,
23217
- "producedCollectionEntries",
23218
- count,
23219
- "produced collection entry"
23220
- );
23221
23402
  return new Array(count).fill(value);
23222
23403
  }
23223
23404
  function stringifyForInterp(v) {
@@ -23339,16 +23520,19 @@ function evalDeclaredListIndex(info, scope, ctx) {
23339
23520
  const collection = evalPointer(info.collectionPointer, scope, ctx);
23340
23521
  if (!Array.isArray(collection)) {
23341
23522
  throw new NSGetterRuntimeError(
23342
- `List index '${info.schemaKey}' requires a present List value.`
23523
+ `List index '${info.schemaKey}' requires a present List or Set value.`
23343
23524
  );
23344
23525
  }
23345
23526
  const rawMember = evalMemberById(ctx.vm, info.listMemberId);
23346
- if (!rawMember || !isMemberListBase(rawMember)) {
23527
+ if (!rawMember || !isMemberEntryCollectionBase(rawMember)) {
23347
23528
  throw new NSGetterRuntimeError(
23348
- `List index contract references missing List member '${info.listMemberId}'.`
23529
+ `List index contract references missing List or Set member '${info.listMemberId}'.`
23349
23530
  );
23350
23531
  }
23351
- const member = resolveMember(rawMember, ctx.vm.members);
23532
+ const member = resolveMember(
23533
+ rawMember,
23534
+ ctx.vm.members
23535
+ );
23352
23536
  const definition = member.indexes?.find(
23353
23537
  (candidate) => candidate.schemaKey === info.schemaKey
23354
23538
  );
@@ -23522,7 +23706,7 @@ function prepareCollectionCallback(callback, parentScope, ctx, isList, returnCon
23522
23706
  if (ctx.__collectionCallbackStrategy === "fresh" || ctx.__collectionCallbackStrategy === "prepared") {
23523
23707
  return (entry, key, valueId) => {
23524
23708
  if (onPredicateMatch !== void 0) {
23525
- consumeBudget(ctx, "workUnits", 1, "work unit");
23709
+ checkDeadline(ctx);
23526
23710
  }
23527
23711
  const boundEntry = coerceAssignmentValue(
23528
23712
  entry,
@@ -23585,14 +23769,14 @@ function prepareCollectionCallback(callback, parentScope, ctx, isList, returnCon
23585
23769
  }
23586
23770
  if (requiresInvocationReset) {
23587
23771
  return (entry, key, valueId) => {
23588
- consumeBudget(ctx, "workUnits", 1, "work unit");
23772
+ checkDeadline(ctx);
23589
23773
  innerScope.resetInvocationLocals(parameterCount);
23590
23774
  bindValues(entry, key);
23591
23775
  return finishBody(innerScope) === true ? onPredicateMatch(entry, key, valueId) : 0 /* Continue */;
23592
23776
  };
23593
23777
  }
23594
23778
  return (entry, key, valueId) => {
23595
- consumeBudget(ctx, "workUnits", 1, "work unit");
23779
+ checkDeadline(ctx);
23596
23780
  bindValues(entry, key);
23597
23781
  return finishBody(innerScope) === true ? onPredicateMatch(entry, key, valueId) : 0 /* Continue */;
23598
23782
  };
@@ -23661,7 +23845,7 @@ function evalCollectionQuery(info, scope, ctx) {
23661
23845
  ) : null;
23662
23846
  const invoke = (entry, key, valueId) => {
23663
23847
  if (!callback) return true;
23664
- consumeBudget(ctx, "workUnits", 1, "work unit");
23848
+ checkDeadline(ctx);
23665
23849
  return callback(entry, key, valueId);
23666
23850
  };
23667
23851
  if (info.op === "Any" || info.op === "All" || info.op === "Last" || info.op === "LastOrDefault" || info.op === "Single" || info.op === "SingleOrDefault") {
@@ -23697,12 +23881,6 @@ function evalCollectionQuery(info, scope, ctx) {
23697
23881
  const output = [];
23698
23882
  let references = /* @__PURE__ */ new Set();
23699
23883
  const append2 = (entry, _key, valueId) => {
23700
- consumeBudget(
23701
- ctx,
23702
- "producedCollectionEntries",
23703
- 1,
23704
- "produced collection entry"
23705
- );
23706
23884
  if (valueId !== null && !info.enumEntries) references.add(output.length);
23707
23885
  output.push(collectionQueryEntry(entry, valueId, info.enumEntries));
23708
23886
  return 0 /* Continue */;
@@ -23719,12 +23897,6 @@ function evalCollectionQuery(info, scope, ctx) {
23719
23897
  let entries = [];
23720
23898
  iterateCollection(collection, ctx, (entry, key, valueId) => {
23721
23899
  const sortKey = invoke(entry, key, valueId);
23722
- consumeBudget(
23723
- ctx,
23724
- "producedCollectionEntries",
23725
- 1,
23726
- "produced collection entry"
23727
- );
23728
23900
  entries.push({ entry, valueId, key: sortKey });
23729
23901
  return 0 /* Continue */;
23730
23902
  });
@@ -23738,7 +23910,6 @@ function evalCollectionQuery(info, scope, ctx) {
23738
23910
  for (let destination = start; destination < end; destination++) {
23739
23911
  let useLeft = right >= end;
23740
23912
  if (left < middle && right < end) {
23741
- consumeBudget(ctx, "workUnits", 1, "work unit");
23742
23913
  const order = compareCollectionKeys(
23743
23914
  entries[left].key,
23744
23915
  entries[right].key,
@@ -23763,8 +23934,20 @@ function evalCollectionQuery(info, scope, ctx) {
23763
23934
  }
23764
23935
  let visited = 0;
23765
23936
  let skipping = true;
23937
+ const seenSetKeys = /* @__PURE__ */ new Set();
23766
23938
  iterateCollection(collection, ctx, (entry, key, valueId) => {
23767
23939
  switch (info.op) {
23940
+ case "ToSet": {
23941
+ const setKey = toSetEntryKey(
23942
+ entry,
23943
+ valueId,
23944
+ info.reference === true,
23945
+ ctx
23946
+ );
23947
+ if (seenSetKeys.has(setKey)) return 0 /* Continue */;
23948
+ seenSetKeys.add(setKey);
23949
+ return append2(entry, key, valueId);
23950
+ }
23768
23951
  case "SelectMany": {
23769
23952
  const inner = invoke(entry, key, valueId);
23770
23953
  isListCollection(inner);
@@ -23814,6 +23997,10 @@ function evalCollectionQuery(info, scope, ctx) {
23814
23997
  }
23815
23998
  return finish();
23816
23999
  }
24000
+ function toSetEntryKey(entry, valueId, reference, ctx) {
24001
+ if (reference) return valueId ?? referenceIdOf(entry, ctx) ?? entry;
24002
+ return typeof entry === "object" && entry !== null ? canonicalJsonStringify(entry) : entry;
24003
+ }
23817
24004
  function compareCollectionKeys(left, right, keyType) {
23818
24005
  if (left === null) return right === null ? 0 : -1;
23819
24006
  if (right === null) return 1;
@@ -23944,6 +24131,15 @@ function evalFunction(fn, scope, ctx) {
23944
24131
  }
23945
24132
  return c.includes(target);
23946
24133
  }
24134
+ const setEntryMember = storedSetEntryMember(c, ctx);
24135
+ if (setEntryMember !== null) {
24136
+ return findStoredSetEntry(
24137
+ listArg(c, "Set Contains receiver"),
24138
+ target,
24139
+ setEntryMember,
24140
+ ctx
24141
+ ) !== null;
24142
+ }
23947
24143
  if (fn.info.reference === true) {
23948
24144
  return referenceIndexOf(c, target, ctx) !== null;
23949
24145
  }
@@ -24056,32 +24252,14 @@ function evalFunction(fn, scope, ctx) {
24056
24252
  switch (fn.info.op) {
24057
24253
  case "toLower": {
24058
24254
  const result = receiver.toLowerCase();
24059
- consumeBudget(
24060
- ctx,
24061
- "producedStringCharacters",
24062
- result.length,
24063
- "produced string character"
24064
- );
24065
24255
  return result;
24066
24256
  }
24067
24257
  case "toUpper": {
24068
24258
  const result = receiver.toUpperCase();
24069
- consumeBudget(
24070
- ctx,
24071
- "producedStringCharacters",
24072
- result.length,
24073
- "produced string character"
24074
- );
24075
24259
  return result;
24076
24260
  }
24077
24261
  case "trim": {
24078
24262
  const result = receiver.trim();
24079
- consumeBudget(
24080
- ctx,
24081
- "producedStringCharacters",
24082
- result.length,
24083
- "produced string character"
24084
- );
24085
24263
  return result;
24086
24264
  }
24087
24265
  case "replace": {
@@ -24111,32 +24289,7 @@ function evalFunction(fn, scope, ctx) {
24111
24289
  throw new NSGetterRuntimeError(
24112
24290
  "string.Replace search must not be empty."
24113
24291
  );
24114
- let count = 0;
24115
- let offset = 0;
24116
- let match = receiver.indexOf(search, offset);
24117
- while (match !== -1) {
24118
- consumeBudget(ctx, "workUnits", 1, "work unit");
24119
- count++;
24120
- offset = match + search.length;
24121
- match = receiver.indexOf(search, offset);
24122
- }
24123
- consumeBudget(
24124
- ctx,
24125
- "producedStringCharacters",
24126
- receiver.length + count * (replacement.length - search.length),
24127
- "produced string character"
24128
- );
24129
- if (count === 0) return receiver;
24130
- const parts = [];
24131
- offset = 0;
24132
- match = receiver.indexOf(search, offset);
24133
- while (match !== -1) {
24134
- parts.push(receiver.slice(offset, match), replacement);
24135
- offset = match + search.length;
24136
- match = receiver.indexOf(search, offset);
24137
- }
24138
- parts.push(receiver.slice(offset));
24139
- return parts.join("");
24292
+ return receiver.split(search).join(replacement);
24140
24293
  }
24141
24294
  case "startsWith":
24142
24295
  case "endsWith": {
@@ -24170,12 +24323,6 @@ function evalFunction(fn, scope, ctx) {
24170
24323
  isList,
24171
24324
  "predicate",
24172
24325
  (entry, key, valueId) => {
24173
- consumeBudget(
24174
- ctx,
24175
- "producedCollectionEntries",
24176
- 1,
24177
- "produced collection entry"
24178
- );
24179
24326
  if (isList) {
24180
24327
  if (valueId !== null) {
24181
24328
  referenceEntryIndexes.add(out.length);
@@ -24249,14 +24396,8 @@ function evalFunction(fn, scope, ctx) {
24249
24396
  );
24250
24397
  const out = [];
24251
24398
  iterateCollection(c, ctx, (entry, key, valueId) => {
24252
- consumeBudget(ctx, "workUnits", 1, "work unit");
24399
+ checkDeadline(ctx);
24253
24400
  const value = callback(entry, key, valueId);
24254
- consumeBudget(
24255
- ctx,
24256
- "producedCollectionEntries",
24257
- 1,
24258
- "produced collection entry"
24259
- );
24260
24401
  out.push(value);
24261
24402
  return 0 /* Continue */;
24262
24403
  });
@@ -24497,7 +24638,7 @@ function constructionGenericSlotsForMember(rawMember, ctx, instanceEnv, visitedM
24497
24638
  const classArguments2 = member.classArguments ?? {};
24498
24639
  return Object.keys(classArguments2).length === 0 ? [] : [{ classId: member.classId, classArguments: classArguments2 }];
24499
24640
  }
24500
- if (!isMemberListBase(member) && !isMemberDictionaryBase(member)) return [];
24641
+ if (!isMemberWithEntries(member)) return [];
24501
24642
  const entryMember = evalMemberById(ctx.vm, member.entryMemberId);
24502
24643
  if (entryMember === null) return [];
24503
24644
  return constructionGenericSlotsForMember(
@@ -24667,7 +24808,7 @@ function applyConstructorFields(args) {
24667
24808
  }
24668
24809
  const existingId = rootRecord[schemaKey];
24669
24810
  const existing = typeof existingId === "string" ? createdById.get(existingId) : void 0;
24670
- if (existing !== void 0 && isLiteralValueContent(existing) && !isMemberClassBase(member) && !isMemberListBase(member) && !isMemberDictionaryBase(member)) {
24811
+ if (existing !== void 0 && isLiteralValueContent(existing) && !isMemberClassBase(member) && !isMemberWithEntries(member)) {
24671
24812
  overwriteConstructedLiteral(existing, value, ctx);
24672
24813
  continue;
24673
24814
  }
@@ -24700,7 +24841,7 @@ function applyExplicitNullConstructorField(args) {
24700
24841
  }
24701
24842
  const existingId = args.rootRecord[schemaKey];
24702
24843
  const existing = typeof existingId === "string" ? args.createdById.get(existingId) : void 0;
24703
- if (existing !== void 0 && isLiteralValueContent(existing) && !isMemberClassBase(member) && !isMemberListBase(member) && !isMemberDictionaryBase(member)) {
24844
+ if (existing !== void 0 && isLiteralValueContent(existing) && !isMemberClassBase(member) && !isMemberWithEntries(member)) {
24704
24845
  overwriteConstructedLiteral(existing, null, args.ctx);
24705
24846
  return;
24706
24847
  }
@@ -24809,31 +24950,6 @@ function publishConstructedRows(args) {
24809
24950
  "Class construction requires an effect-capable evaluator Session scope."
24810
24951
  );
24811
24952
  }
24812
- let newlyConstructedRows = 0;
24813
- let newlyProducedEntries = 0;
24814
- for (const row of createdValues) {
24815
- if (!state.budgetedConstructedRowIds.has(row.id)) {
24816
- state.budgetedConstructedRowIds.add(row.id);
24817
- newlyConstructedRows += 1;
24818
- }
24819
- const currentEntries = Array.isArray(row.value) ? row.value.length : typeof row.value === "object" && row.value !== null ? Object.keys(row.value).length : 0;
24820
- const priorEntries = state.budgetedProducedEntriesByRowId.get(row.id) ?? 0;
24821
- if (currentEntries <= priorEntries) continue;
24822
- newlyProducedEntries += currentEntries - priorEntries;
24823
- state.budgetedProducedEntriesByRowId.set(row.id, currentEntries);
24824
- }
24825
- consumeBudget(
24826
- ctx,
24827
- "constructedSessionRows",
24828
- newlyConstructedRows,
24829
- "constructed Session row"
24830
- );
24831
- consumeBudget(
24832
- ctx,
24833
- "producedCollectionEntries",
24834
- newlyProducedEntries,
24835
- "produced collection entry"
24836
- );
24837
24953
  const retained = retainedIds;
24838
24954
  if (beforeRetain !== null) {
24839
24955
  for (const rowId of beforeRetain) {
@@ -25650,6 +25766,11 @@ function evaluateInitializerInContext(init, member, ctx, createdValues, argument
25650
25766
  existingValueRow
25651
25767
  };
25652
25768
  }
25769
+ if (existingValueRow !== null && (isMemberClassBase(member) || isMemberWithEntries(member)) && argumentValues.some(
25770
+ (argument2) => trackedRowForValueReference(argument2, ctx)?.id === existingValueRow.id
25771
+ )) {
25772
+ assertInitializerPlacement(existingValueRow.id, member, ctx);
25773
+ }
25653
25774
  if (existingValueRow !== null && existingRuntimeClassId !== null && isMemberClassBase(member)) {
25654
25775
  const storage = constructorArgumentStorage(existingValueRow.id, ctx);
25655
25776
  if (storage !== 3 /* Session */) {
@@ -25880,7 +26001,7 @@ function encodeRequiredConstructorArgument(args) {
25880
26001
  }
25881
26002
  return adoptTracked(aggregateId2, "root");
25882
26003
  }
25883
- if (args.typeInfo.type !== 6 /* List */ && args.typeInfo.type !== 5 /* Dictionary */) {
26004
+ if (args.typeInfo.type !== 6 /* List */ && args.typeInfo.type !== 28 /* Set */ && args.typeInfo.type !== 5 /* Dictionary */) {
25884
26005
  return cloneConstructorLiteralValue(args.value);
25885
26006
  }
25886
26007
  if (args.value === null || args.value === void 0) return null;
@@ -25894,7 +26015,7 @@ function encodeRequiredConstructorArgument(args) {
25894
26015
  if (genericBindings !== void 0) row2.genericBindings = genericBindings;
25895
26016
  return row2;
25896
26017
  };
25897
- const entryMember = settled !== void 0 && (isMemberListBase(settled) || isMemberDictionaryBase(settled)) ? evalMemberById(args.ctx.vm, settled.entryMemberId) ?? void 0 : void 0;
26018
+ const entryMember = settled !== void 0 && isMemberWithEntries(settled) ? evalMemberById(args.ctx.vm, settled.entryMemberId) ?? void 0 : void 0;
25898
26019
  const registerRow = (value, containerId) => {
25899
26020
  args.ctx.beforeValueAllocation?.();
25900
26021
  const row2 = buildNewValue(args.ctx.vm.project.id, { value });
@@ -25921,7 +26042,7 @@ function encodeRequiredConstructorArgument(args) {
25921
26042
  }
25922
26043
  return adoptTracked(id, suffix);
25923
26044
  }
25924
- if (entryType.type === 6 /* List */ || entryType.type === 5 /* Dictionary */) {
26045
+ if (entryType.type === 6 /* List */ || entryType.type === 28 /* Set */ || entryType.type === 5 /* Dictionary */) {
25925
26046
  const nested = encodeRequiredConstructorArgument({
25926
26047
  ...args,
25927
26048
  value,
@@ -25938,10 +26059,10 @@ function encodeRequiredConstructorArgument(args) {
25938
26059
  }
25939
26060
  return registerRow(cloneConstructorLiteralValue(value)).id;
25940
26061
  };
25941
- if (collectionType.type === 6 /* List */) {
26062
+ if (collectionType.type === 6 /* List */ || collectionType.type === 28 /* Set */) {
25942
26063
  if (!Array.isArray(args.value)) {
25943
26064
  throw new NSGetterRuntimeError(
25944
- `Constructor argument '${args.parameterId}' must be a List.`
26065
+ `Constructor argument '${args.parameterId}' must be a ${MemberKind[collectionType.type]}.`
25945
26066
  );
25946
26067
  }
25947
26068
  const row2 = registerCollectionRow([]);
@@ -26354,7 +26475,6 @@ function applyVariantDeclarativeHalves(instance, graph, ctx, answeredValueIds) {
26354
26475
  }
26355
26476
  const entries = listRow.value;
26356
26477
  if (!Array.isArray(entries)) return;
26357
- consumeBudget(ctx, "workUnits", entries.length, "work unit");
26358
26478
  for (const entryId of entries) {
26359
26479
  if (typeof entryId !== "string") continue;
26360
26480
  const entryRow = evalValueById(
@@ -26495,7 +26615,6 @@ function collectVariantDeclarativeAnsweredSlots(instance, graph, ctx) {
26495
26615
  );
26496
26616
  }
26497
26617
  if (!Array.isArray(listRow.value)) return slots;
26498
- consumeBudget(ctx, "workUnits", listRow.value.length, "work unit");
26499
26618
  for (const entryId of listRow.value) {
26500
26619
  if (typeof entryId !== "string") continue;
26501
26620
  const entryRow = evalValueById(
@@ -26533,7 +26652,6 @@ function collectVariantDeclarativeAnsweredSlots(instance, graph, ctx) {
26533
26652
  return slots;
26534
26653
  }
26535
26654
  function evalVariantInitialize(info, scope, ctx) {
26536
- consumeBudget(ctx, "workUnits", 1, "work unit");
26537
26655
  const selection = readVariantSelection(
26538
26656
  evalPointer(info.variantPointer, scope, ctx),
26539
26657
  "Variant.Initialize receiver"
@@ -26590,7 +26708,6 @@ function evalVariantInitialize(info, scope, ctx) {
26590
26708
  }
26591
26709
  }
26592
26710
  function evalVariantApply(info, scope, ctx) {
26593
- consumeBudget(ctx, "workUnits", 1, "work unit");
26594
26711
  const receiver = evalPointer(info.receiverPointer, scope, ctx);
26595
26712
  if (receiver === null || receiver === void 0) {
26596
26713
  throw new NSGetterRuntimeError(
@@ -26708,6 +26825,15 @@ function constructDeclaredClassValue(info, scope, ctx) {
26708
26825
  closeFrame();
26709
26826
  }
26710
26827
  }
26828
+ function positionAtPassingArgument(error, info, record4, argumentValues, ctx) {
26829
+ if (error.attachedValueId === void 0 || record4 === null) return;
26830
+ const index = argumentValues.findIndex(
26831
+ (value) => findKnownRowIdByValueReference(value, ctx) === error.attachedValueId
26832
+ );
26833
+ const name = record4.argumentTypes[index]?.name;
26834
+ const argument2 = info.args.find((candidate) => candidate.name === name);
26835
+ if (argument2 !== void 0) error.at(argument2.valuePointer);
26836
+ }
26711
26837
  function constructDeclaredClassValueWithinFrame(descriptor, record4, info, scope, ctx) {
26712
26838
  const schemaClass2 = descriptor.schemaClass;
26713
26839
  const classId = schemaClass2.id;
@@ -26750,7 +26876,10 @@ function constructDeclaredClassValueWithinFrame(descriptor, record4, info, scope
26750
26876
  root.classId = classId;
26751
26877
  stampConstructedRootGenericBindings(root, descriptor);
26752
26878
  } catch (error) {
26753
- if (error instanceof NSGetterRuntimeError) throw error;
26879
+ if (error instanceof NSGetterRuntimeError) {
26880
+ positionAtPassingArgument(error, info, record4, argumentValues, ctx);
26881
+ throw error;
26882
+ }
26754
26883
  throw new NSGetterRuntimeError(
26755
26884
  `Failed to construct '${schemaClass2.name}': ${error instanceof Error ? error.message : String(error)}`
26756
26885
  );
@@ -26789,7 +26918,7 @@ function constructDeclaredClassValueWithinFrame(descriptor, record4, info, scope
26789
26918
  createdValues,
26790
26919
  storageKeyDeclarations,
26791
26920
  // Only collection rows carry a stamp from the settled member.
26792
- member: resolvedArgumentType.type === 6 /* List */ || resolvedArgumentType.type === 5 /* Dictionary */ ? settledConstructorParameterMember(
26921
+ member: resolvedArgumentType.type === 6 /* List */ || resolvedArgumentType.type === 28 /* Set */ || resolvedArgumentType.type === 5 /* Dictionary */ ? settledConstructorParameterMember(
26793
26922
  classId,
26794
26923
  argumentType.name,
26795
26924
  record4.id,
@@ -26913,9 +27042,11 @@ function assertOwnedValueAttachable(valueId, destination, destinationName, ctx,
26913
27042
  }
26914
27043
  for (const owner of currentOwnedValueAttachments(valueId, ctx)) {
26915
27044
  if (mode === "assign" && owner.identity === destination.identity) continue;
26916
- throw new NSGetterRuntimeError(
27045
+ const error = new NSGetterRuntimeError(
26917
27046
  `Aggregate value '${valueId}' is already owned by parent value '${owner.label}' and cannot be attached to '${destinationName}'. Call Clone() explicitly.`
26918
27047
  );
27048
+ error.attachedValueId = valueId;
27049
+ throw error;
26919
27050
  }
26920
27051
  const reserved = ctx.__executionState?.ownedValueAttachments.get(valueId);
26921
27052
  if (reserved !== void 0 && (mode === "insert" || reserved.identity !== destination.identity)) {
@@ -26940,6 +27071,16 @@ function assertOwnedValueAttachable(valueId, destination, destinationName, ctx,
26940
27071
  }
26941
27072
  recordConstructorGroupDependency(valueId, destination, ctx);
26942
27073
  }
27074
+ function assertInitializerPlacement(valueId, member, ctx) {
27075
+ const replayRowId = ctx.__storedConstructionReplayRowId;
27076
+ const memberId = Reflect.get(member, "id");
27077
+ const schemaKey = replayRowId === void 0 || typeof memberId !== "string" ? null : cachedSchemaKeyForMember(memberId, ctx);
27078
+ const destination = schemaKey === null ? { identity: `initializer:${member.name}`, label: member.name } : {
27079
+ identity: `value:${replayRowId}:slot:${schemaKey}`,
27080
+ label: member.name
27081
+ };
27082
+ assertOwnedValueAttachable(valueId, destination, member.name, ctx);
27083
+ }
26943
27084
  function currentOwnedValueAttachments(valueId, ctx) {
26944
27085
  const indexes3 = evaluatorIndexes(ctx);
26945
27086
  const cached = indexes3.ownedValueAttachmentsByValueId.get(valueId);
@@ -27001,7 +27142,7 @@ function currentOwnedValueAttachments(valueId, ctx) {
27001
27142
  if (parent.id === valueId) continue;
27002
27143
  let member = null;
27003
27144
  let classId = parent.classId;
27004
- if (classId === void 0) {
27145
+ if (classId === void 0 || classId === null) {
27005
27146
  member = activeStaticBindingRoot(parent.id, ctx)?.member ?? memberForValueRow(parent, ctx);
27006
27147
  if (member !== null) {
27007
27148
  try {
@@ -27028,7 +27169,7 @@ function currentOwnedValueAttachments(valueId, ctx) {
27028
27169
  }
27029
27170
  continue;
27030
27171
  }
27031
- if (member !== null && isMemberListBase(member) && Array.isArray(parent.value)) {
27172
+ if (member !== null && isMemberEntryCollectionBase(member) && Array.isArray(parent.value)) {
27032
27173
  for (const [index, childId] of parent.value.entries()) {
27033
27174
  if (childId !== valueId) continue;
27034
27175
  add({
@@ -27146,7 +27287,7 @@ function cloneConstructorArgumentGraph(args) {
27146
27287
  ...isLiteralValueContent(source) ? clonedConstructorProvenance(source) : {}
27147
27288
  });
27148
27289
  if (clonedContainerId !== void 0) clone.containerId = clonedContainerId;
27149
- if (isMemberListBase(member) || isMemberDictionaryBase(member)) {
27290
+ if (isMemberWithEntries(member)) {
27150
27291
  const stamp = computeGenericBindingsStamp(
27151
27292
  member,
27152
27293
  genericEnv,
@@ -27250,7 +27391,7 @@ function cloneConstructorArgumentGraph(args) {
27250
27391
  }
27251
27392
  return clone;
27252
27393
  }
27253
- if (isMemberListBase(member)) {
27394
+ if (isMemberEntryCollectionBase(member)) {
27254
27395
  if (source.value === null) {
27255
27396
  clone.value = null;
27256
27397
  return clone;
@@ -27326,7 +27467,7 @@ function cloneConstructorLiteralValue(value) {
27326
27467
  }
27327
27468
  function materializeConstructorArgumentValue(args) {
27328
27469
  const trackedValueId = findKnownRowIdByValueReference(args.value, args.ctx);
27329
- if (args.value === null && !isRequiredMember(args.member) && (isMemberListBase(args.member) || isMemberDictionaryBase(args.member))) {
27470
+ if (args.value === null && !isRequiredMember(args.member) && isMemberWithEntries(args.member)) {
27330
27471
  return registerConstructorArgumentRow(args, null);
27331
27472
  }
27332
27473
  if (isMemberClassBase(args.member)) {
@@ -27384,7 +27525,7 @@ function materializeConstructorArgumentValue(args) {
27384
27525
  `Constructor argument for Class field '${args.member.name}' has no backing value row.`
27385
27526
  );
27386
27527
  }
27387
- if (isMemberListBase(args.member)) {
27528
+ if (isMemberEntryCollectionBase(args.member)) {
27388
27529
  if (!Array.isArray(args.value)) {
27389
27530
  throw new NSGetterRuntimeError(
27390
27531
  `Constructor argument for List field '${args.member.name}' must be a list.`
@@ -27424,7 +27565,7 @@ function materializeConstructorArgumentValue(args) {
27424
27565
  const entryValue = constructorCollectionEntryValue(
27425
27566
  rawEntry,
27426
27567
  args.ctx,
27427
- isMemberClassBase(resolvedEntry) || isMemberListBase(resolvedEntry) || isMemberDictionaryBase(resolvedEntry) || (referenceIndexes?.has(index) ?? args.collectionEntriesAreReferences ?? trackedValueId !== null)
27568
+ isMemberClassBase(resolvedEntry) || isMemberWithEntries(resolvedEntry) || (referenceIndexes?.has(index) ?? args.collectionEntriesAreReferences ?? trackedValueId !== null)
27428
27569
  );
27429
27570
  const child = materializeConstructorArgumentValue({
27430
27571
  ...args,
@@ -27472,7 +27613,7 @@ function materializeConstructorArgumentValue(args) {
27472
27613
  const entry = constructorCollectionEntryValue(
27473
27614
  rawEntry,
27474
27615
  args.ctx,
27475
- isMemberClassBase(resolvedEntry) || isMemberListBase(resolvedEntry) || isMemberDictionaryBase(resolvedEntry) || (args.collectionEntriesAreReferences ?? trackedValueId !== null)
27616
+ isMemberClassBase(resolvedEntry) || isMemberWithEntries(resolvedEntry) || (args.collectionEntriesAreReferences ?? trackedValueId !== null)
27476
27617
  );
27477
27618
  record4[key] = materializeConstructorArgumentValue({
27478
27619
  ...args,
@@ -27507,7 +27648,7 @@ function registerConstructorArgumentRow(args, value) {
27507
27648
  return row;
27508
27649
  }
27509
27650
  function rowGenericBindings(args) {
27510
- if (!isMemberListBase(args.member) && !isMemberDictionaryBase(args.member)) {
27651
+ if (!isMemberWithEntries(args.member)) {
27511
27652
  return void 0;
27512
27653
  }
27513
27654
  return computeGenericBindingsStamp(
@@ -27686,7 +27827,7 @@ function cloneClassValueGraph(receiver, expectedClassId, ctx) {
27686
27827
  argumentValues,
27687
27828
  sourceRow.id,
27688
27829
  compileMemberId,
27689
- isMemberListBase(sourceMember) || isMemberDictionaryBase(sourceMember) ? runtimeGenericEnvForValueRow(sourceRow, ctx, /* @__PURE__ */ new Set()) : void 0
27830
+ isMemberWithEntries(sourceMember) ? runtimeGenericEnvForValueRow(sourceRow, ctx, /* @__PURE__ */ new Set()) : void 0
27690
27831
  );
27691
27832
  if (evaluated.existingValueRow !== void 0) {
27692
27833
  const adoptedClone = cloneRow2(
@@ -27803,9 +27944,9 @@ function cloneClassValueGraph(receiver, expectedClassId, ctx) {
27803
27944
  );
27804
27945
  clonedRecord[key] = clonedChild.id;
27805
27946
  }
27806
- } else if (Array.isArray(sourceRow.value) && (isMemberList(sourceMember) || sourceTypeInfo?.type === 6 /* List */)) {
27807
- const entryMember = isMemberList(sourceMember) ? evalMemberById(ctx.vm, sourceMember.entryMemberId) : null;
27808
- const entryTypeInfo = sourceTypeInfo?.type === 6 /* List */ ? sourceTypeInfo.entryTypeInfo : void 0;
27947
+ } else if (Array.isArray(sourceRow.value) && (isMemberEntryCollectionBase(sourceMember) || sourceTypeInfo?.type === 6 /* List */ || sourceTypeInfo?.type === 28 /* Set */)) {
27948
+ const entryMember = isMemberEntryCollectionBase(sourceMember) ? evalMemberById(ctx.vm, sourceMember.entryMemberId) : null;
27949
+ const entryTypeInfo = sourceTypeInfo?.type === 6 /* List */ || sourceTypeInfo?.type === 28 /* Set */ ? sourceTypeInfo.entryTypeInfo : void 0;
27809
27950
  if (entryMember !== null || entryTypeInfo !== void 0) {
27810
27951
  clone.value = sourceRow.value.map((childId) => {
27811
27952
  if (typeof childId !== "string") return childId;
@@ -28047,7 +28188,6 @@ function collectionLength(c) {
28047
28188
  function snapshotCollectionMembership(collection, ctx) {
28048
28189
  const membership = [];
28049
28190
  const valid = forEachRawCollectionEntry(collection, (entry) => {
28050
- consumeBudget(ctx, "collectionVisits", 1, "collection visit");
28051
28191
  membership.push({
28052
28192
  raw: entry.raw,
28053
28193
  resolveAsReference: collectionEntryUsesReferenceResolution(
@@ -28092,7 +28232,6 @@ function forEachRawCollectionEntry(c, callback) {
28092
28232
  function collectionEntries(c, ctx) {
28093
28233
  const entries = [];
28094
28234
  forEachRawCollectionEntry(c, ({ raw, key }) => {
28095
- consumeBudget(ctx, "collectionVisits", 1, "collection visit");
28096
28235
  entries.push(resolveCollectionEntry(c, raw, key, ctx));
28097
28236
  return 0 /* Continue */;
28098
28237
  });
@@ -28102,7 +28241,6 @@ function referenceIndexOf(c, target, ctx) {
28102
28241
  const targetId = target === null || target === void 0 ? null : referenceIdOf(target, ctx);
28103
28242
  let found = null;
28104
28243
  forEachRawCollectionEntry(c, ({ raw, key }) => {
28105
- consumeBudget(ctx, "collectionVisits", 1, "collection visit");
28106
28244
  if (raw === target || targetId !== null && raw !== null && raw !== void 0 && referenceIdOf(raw, ctx) === targetId) {
28107
28245
  found = key;
28108
28246
  return 1 /* Break */;
@@ -28113,7 +28251,6 @@ function referenceIndexOf(c, target, ctx) {
28113
28251
  }
28114
28252
  function iterateCollection(c, ctx, callback) {
28115
28253
  forEachRawCollectionEntry(c, ({ raw, key, valueId }) => {
28116
- consumeBudget(ctx, "collectionVisits", 1, "collection visit");
28117
28254
  const effectiveValueId = collectionEntryUsesReferenceResolution(c, key, ctx) ? valueId : null;
28118
28255
  return callback(
28119
28256
  resolveCollectionEntry(c, raw, key, ctx),
@@ -28287,7 +28424,7 @@ function createStoredValuePlacementTraversal(args, trackReferences = false) {
28287
28424
  }
28288
28425
  continue;
28289
28426
  }
28290
- if (!isMemberListBase(member) && !isMemberDictionaryBase(member)) {
28427
+ if (!isMemberWithEntries(member)) {
28291
28428
  continue;
28292
28429
  }
28293
28430
  const entryMember = membersById.get(member.entryMemberId);
@@ -28418,7 +28555,7 @@ function lookupEntryTypeInfo(member, collectionTypeInfo) {
28418
28555
  if (member.collectionMemberId === void 0) return member.declaredTypeInfo;
28419
28556
  const collection = collectionTypeInfo(member.collectionMemberId);
28420
28557
  if (collection === null) return null;
28421
- if (collection.type !== 6 /* List */ && collection.type !== 5 /* Dictionary */) {
28558
+ if (collection.type !== 6 /* List */ && collection.type !== 28 /* Set */ && collection.type !== 5 /* Dictionary */) {
28422
28559
  return null;
28423
28560
  }
28424
28561
  return member.declaredTypeInfo ?? collection.entryTypeInfo;
@@ -28511,10 +28648,13 @@ function resolveMemberDeclaredTypeInfoInternal(member, members, seen, ownerClass
28511
28648
  argumentTypes: unnamedArgumentTypes(resolved.argumentTypes)
28512
28649
  };
28513
28650
  }
28514
- if (isMemberListBase(resolved) || isMemberDictionaryBase(resolved)) {
28515
- const entry = members.find(
28516
- (candidate) => candidate.id === resolved.entryMemberId
28517
- );
28651
+ const collectionKind = resolved.kind;
28652
+ if (collectionKind === 5 /* Dictionary */ && !isMemberDictionaryBase(resolved)) {
28653
+ return null;
28654
+ }
28655
+ if (collectionKind === 6 /* List */ || collectionKind === 28 /* Set */ || collectionKind === 5 /* Dictionary */) {
28656
+ const entryMemberId = getField(resolved, "entryMemberId");
28657
+ const entry = members.find((candidate) => candidate.id === entryMemberId);
28518
28658
  if (entry === void 0) return null;
28519
28659
  const entryTypeInfo = resolveMemberDeclaredTypeInfoInternal(
28520
28660
  entry,
@@ -28525,7 +28665,7 @@ function resolveMemberDeclaredTypeInfoInternal(member, members, seen, ownerClass
28525
28665
  );
28526
28666
  if (entryTypeInfo === null) return null;
28527
28667
  return {
28528
- type: resolved.kind,
28668
+ type: collectionKind,
28529
28669
  required: isRequiredMember(resolved),
28530
28670
  entryTypeInfo,
28531
28671
  ...isMemberDictionaryBase(resolved) && resolved.keyEnumId ? { keyEnumId: resolved.keyEnumId } : {}
@@ -28575,6 +28715,10 @@ function genericParamTypeInfo(ownerClass, genericParamId, required) {
28575
28715
  }
28576
28716
 
28577
28717
  // ../packages/neoscript-runtime/src/values/constructor-argument-ownership.ts
28718
+ function recordEntries(value) {
28719
+ if (typeof value !== "object" || value === null) return [];
28720
+ return Object.values(value);
28721
+ }
28578
28722
  var MaterializedValueGraphContext = class {
28579
28723
  /**
28580
28724
  * P79 §7a. Generic in the caller's document view so a pass typed against a
@@ -28590,6 +28734,7 @@ var MaterializedValueGraphContext = class {
28590
28734
  constructorsById;
28591
28735
  contextualRootMembersByValueId;
28592
28736
  parameterTypesByRow = /* @__PURE__ */ new WeakMap();
28737
+ argumentInteriorTypesById;
28593
28738
  settleConstructorParameter;
28594
28739
  aggregateTypeByTargetValueId = /* @__PURE__ */ new Map();
28595
28740
  ownership;
@@ -28666,13 +28811,16 @@ var MaterializedValueGraphContext = class {
28666
28811
  }
28667
28812
  return result;
28668
28813
  }
28669
- constructorEdges(row) {
28814
+ constructorEdges(row, contextualMember) {
28670
28815
  if (!isLiteralValueContent(row)) return [];
28671
28816
  if (row.constructorArgs === void 0 || row.constructorArgs === null) {
28672
28817
  return [];
28673
28818
  }
28674
28819
  const edges = [];
28675
- for (const [parameterId, typeInfo] of this.constructorParameterTypes(row)) {
28820
+ for (const [parameterId, typeInfo] of this.constructorParameterTypes(
28821
+ row,
28822
+ contextualMember
28823
+ )) {
28676
28824
  const targetValueId = row.constructorArgs[parameterId];
28677
28825
  if (typeof targetValueId !== "string") continue;
28678
28826
  if (!isAggregateTypeInfo(typeInfo)) continue;
@@ -28751,28 +28899,24 @@ var MaterializedValueGraphContext = class {
28751
28899
  if (!isLiteralValueContent(row)) {
28752
28900
  return { ...row, id: replacements.get(row.id) ?? row.id };
28753
28901
  }
28754
- const ownerId = args.ownerValueId ?? row.id;
28755
- const owner = args.owner ?? this.ownerForValue(ownerId);
28756
- const aggregateType = owner === void 0 ? this.aggregateTypeForRow(ownerId) : void 0;
28757
28902
  const rewriteId = (value2) => replacements.get(value2) ?? value2;
28758
28903
  let value = row.value;
28759
- if (owner !== void 0 || aggregateType !== void 0) {
28760
- if ((owner !== void 0 ? isMemberListBase(owner) : aggregateType === 6 /* List */) && Array.isArray(value)) {
28761
- value = value.map(
28762
- (entry) => typeof entry === "string" ? rewriteId(entry) : entry
28763
- );
28764
- } else if ((owner !== void 0 && (isMemberClassBase(owner) || isMemberDictionaryBase(owner)) || aggregateType === 7 /* Class */ || aggregateType === 22 /* Interface */ || aggregateType === 5 /* Dictionary */) && value !== null && typeof value === "object" && !Array.isArray(value)) {
28765
- value = Object.fromEntries(
28766
- Object.entries(value).map(([key, entry]) => [
28767
- key,
28768
- typeof entry === "string" ? rewriteId(entry) : entry
28769
- ])
28770
- );
28771
- } else if (owner?.kind === 9 /* Lookup */ && Array.isArray(value)) {
28772
- value = value.map(
28773
- (entry) => typeof entry === "string" ? rewriteId(entry) : entry
28774
- );
28775
- }
28904
+ const slots = this.referenceSlots(
28905
+ args.ownerValueId ?? row.id,
28906
+ args.owner,
28907
+ value
28908
+ );
28909
+ if (slots === 1 /* Entries */ && Array.isArray(value)) {
28910
+ value = value.map(
28911
+ (entry) => typeof entry === "string" ? rewriteId(entry) : entry
28912
+ );
28913
+ } else if (slots === 2 /* Fields */) {
28914
+ value = Object.fromEntries(
28915
+ Object.entries(value).map(([key, entry]) => [
28916
+ key,
28917
+ typeof entry === "string" ? rewriteId(entry) : entry
28918
+ ])
28919
+ );
28776
28920
  }
28777
28921
  const parameterTypes = this.constructorParameterTypes(row);
28778
28922
  const constructorArgs = row.constructorArgs === void 0 || row.constructorArgs === null ? row.constructorArgs : Object.fromEntries(
@@ -28802,11 +28946,101 @@ var MaterializedValueGraphContext = class {
28802
28946
  preservedValueIds
28803
28947
  );
28804
28948
  }
28949
+ /**
28950
+ * Row ids an indexed row names through its typed slots: body entries or
28951
+ * fields and aggregate constructor arguments. Leaf text that happens to
28952
+ * equal an id is not a reference.
28953
+ */
28954
+ referencedValueIds(row) {
28955
+ if (!isLiteralValueContent(row)) return [];
28956
+ const ids = [];
28957
+ for (const entry of this.slotEntries(row)) {
28958
+ if (typeof entry === "string") ids.push(entry);
28959
+ }
28960
+ for (const edge of this.edgesByOwnerValueId.get(row.id) ?? [])
28961
+ ids.push(edge.targetValueId);
28962
+ return ids;
28963
+ }
28964
+ slotEntries(row) {
28965
+ const value = row.value;
28966
+ switch (this.referenceSlots(row.id, void 0, value)) {
28967
+ case 1 /* Entries */:
28968
+ return Array.isArray(value) ? value : [];
28969
+ case 2 /* Fields */:
28970
+ return recordEntries(value);
28971
+ case 0 /* None */:
28972
+ return [];
28973
+ }
28974
+ }
28975
+ referenceSlots(ownerId, explicitOwner, value) {
28976
+ const owner = explicitOwner ?? this.ownerForValue(ownerId);
28977
+ const aggregateType = owner === void 0 ? this.aggregateTypeForRow(ownerId) : void 0;
28978
+ if (owner === void 0 && aggregateType === void 0)
28979
+ return 0 /* None */;
28980
+ if (Array.isArray(value)) {
28981
+ const entries = owner !== void 0 ? isMemberEntryCollectionBase(owner) || owner.kind === 9 /* Lookup */ : aggregateType === 6 /* List */ || aggregateType === 28 /* Set */;
28982
+ return entries ? 1 /* Entries */ : 0 /* None */;
28983
+ }
28984
+ if (typeof value !== "object" || value === null) return 0 /* None */;
28985
+ const fields = owner !== void 0 ? isMemberClassBase(owner) || isMemberDictionaryBase(owner) : aggregateType === 7 /* Class */ || aggregateType === 22 /* Interface */ || aggregateType === 5 /* Dictionary */;
28986
+ return fields ? 2 /* Fields */ : 0 /* None */;
28987
+ }
28805
28988
  aggregateTypeForRow(valueId) {
28806
28989
  if (typeof this.valuesById.get(valueId)?.classId === "string") {
28807
28990
  return 7 /* Class */;
28808
28991
  }
28809
- return this.aggregateTypeByTargetValueId.get(valueId);
28992
+ return this.aggregateTypeByTargetValueId.get(valueId) ?? this.argumentInteriorTypes().get(valueId);
28993
+ }
28994
+ /**
28995
+ * Aggregate kinds of rows nested inside constructor arguments, typed by the
28996
+ * declared argument type. A row two edges name is typed by the first: both
28997
+ * must agree on it.
28998
+ */
28999
+ argumentInteriorTypes() {
29000
+ if (this.argumentInteriorTypesById !== void 0)
29001
+ return this.argumentInteriorTypesById;
29002
+ const types = /* @__PURE__ */ new Map();
29003
+ const visit = (valueId, type) => {
29004
+ if (type === null || !isAggregateTypeInfo(type)) return;
29005
+ if (types.has(valueId)) return;
29006
+ types.set(valueId, type.type);
29007
+ const row = this.valuesById.get(valueId);
29008
+ if (row === void 0 || !isLiteralValueContent(row)) return;
29009
+ if (typeof row.classId === "string") {
29010
+ if (typeof row.value !== "object" || row.value === null) return;
29011
+ const body = row.value;
29012
+ const env = this.genericEnvironmentForRow(row);
29013
+ for (const entry of mergeInstanceSurfaceSchema(
29014
+ row.classId,
29015
+ this.document.classes,
29016
+ this.document.members
29017
+ )) {
29018
+ const childId = body[entry.schemaKey];
29019
+ const member = this.membersById.get(entry.memberId);
29020
+ if (typeof childId !== "string" || member === void 0) continue;
29021
+ visit(childId, this.memberTypeInfo(member, env));
29022
+ }
29023
+ return;
29024
+ }
29025
+ if (type.type === 7 /* Class */ || type.type === 22 /* Interface */)
29026
+ return;
29027
+ for (const entryId of this.collectionEntryIds(row, type.type)) {
29028
+ if (typeof entryId === "string") visit(entryId, type.entryTypeInfo);
29029
+ }
29030
+ };
29031
+ for (const edges of this.edgesByOwnerValueId.values())
29032
+ for (const edge of edges) visit(edge.targetValueId, edge.typeInfo);
29033
+ this.argumentInteriorTypesById = types;
29034
+ return types;
29035
+ }
29036
+ /** A collection row's entry ids: dictionary values, contained or listed. */
29037
+ collectionEntryIds(row, kind) {
29038
+ if (kind === 5 /* Dictionary */) {
29039
+ return recordEntries(row.value);
29040
+ }
29041
+ const contained = this.childrenByContainerId.get(row.id);
29042
+ if (contained !== void 0) return contained.map((entry) => entry.id);
29043
+ return Array.isArray(row.value) ? row.value : [];
28810
29044
  }
28811
29045
  resolveTypeInfo(rawTypeInfo, env) {
28812
29046
  if (rawTypeInfo.type === 21 /* Generic */) {
@@ -28816,7 +29050,7 @@ var MaterializedValueGraphContext = class {
28816
29050
  if (member === void 0) return null;
28817
29051
  return this.memberTypeInfo(member, env);
28818
29052
  }
28819
- if (rawTypeInfo.type === 6 /* List */ || rawTypeInfo.type === 5 /* Dictionary */) {
29053
+ if (rawTypeInfo.type === 6 /* List */ || rawTypeInfo.type === 28 /* Set */ || rawTypeInfo.type === 5 /* Dictionary */) {
28820
29054
  const entryTypeInfo = this.resolveTypeInfo(
28821
29055
  rawTypeInfo.entryTypeInfo,
28822
29056
  env
@@ -28886,7 +29120,7 @@ function collectSoftOwnedConstructorArgumentValueIds(index, ownerValueId, preser
28886
29120
  collectNestedConstructorArguments(valueId);
28887
29121
  if (typeInfo.type === 7 /* Class */ || typeInfo.type === 22 /* Interface */) {
28888
29122
  collectClassChildren(row, typeInfo);
28889
- } else if (typeInfo.type === 6 /* List */) {
29123
+ } else if (typeInfo.type === 6 /* List */ || typeInfo.type === 28 /* Set */) {
28890
29124
  const unorderedChildren = childrenByContainerId.get(row.id) ?? [];
28891
29125
  if (unorderedChildren.length > 0) {
28892
29126
  for (const child of unorderedChildren) {
@@ -28971,7 +29205,7 @@ function tryResolveTypeInfo(document2, rawTypeInfo, env) {
28971
29205
  if (member === void 0) return null;
28972
29206
  return tryMemberTypeInfo(document2, member, env);
28973
29207
  }
28974
- if (rawTypeInfo.type === 6 /* List */ || rawTypeInfo.type === 5 /* Dictionary */) {
29208
+ if (rawTypeInfo.type === 6 /* List */ || rawTypeInfo.type === 28 /* Set */ || rawTypeInfo.type === 5 /* Dictionary */) {
28975
29209
  const entryTypeInfo = tryResolveTypeInfo(
28976
29210
  document2,
28977
29211
  rawTypeInfo.entryTypeInfo,
@@ -28993,7 +29227,7 @@ function tryMemberTypeInfo(document2, rawMember, env) {
28993
29227
  }
28994
29228
  }
28995
29229
  function isAggregateTypeInfo(typeInfo) {
28996
- return typeInfo.type === 7 /* Class */ || typeInfo.type === 22 /* Interface */ || typeInfo.type === 6 /* List */ || typeInfo.type === 5 /* Dictionary */;
29230
+ return typeInfo.type === 7 /* Class */ || typeInfo.type === 22 /* Interface */ || typeInfo.type === 6 /* List */ || typeInfo.type === 28 /* Set */ || typeInfo.type === 5 /* Dictionary */;
28997
29231
  }
28998
29232
  function isStringRecord3(value) {
28999
29233
  if (value === null || typeof value !== "object" || Array.isArray(value)) {
@@ -31581,7 +31815,7 @@ function claimVirtualIdentity(args) {
31581
31815
  virtualId: args.fixedVirtualId
31582
31816
  };
31583
31817
  }
31584
- const valueId = (sourceIdentity3) => args.instanceRootId.startsWith("__pending__:") || hasPendingVirtualSourceIdentity(sourceIdentity3) ? pendingVirtualValueId(args.instanceRootId, sourceIdentity3) : virtualValueId(args.instanceRootId, sourceIdentity3);
31818
+ const valueId = (sourceIdentity3) => derivedVirtualValueId(args.instanceRootId, sourceIdentity3);
31585
31819
  const derivedId = valueId(args.rawSourceIdentity);
31586
31820
  const claimedPath = args.claimedVirtualIds.get(derivedId);
31587
31821
  if (claimedPath === void 0 || claimedPath === args.pathKey) {
@@ -31593,6 +31827,9 @@ function claimVirtualIdentity(args) {
31593
31827
  args.claimedVirtualIds.set(virtualId, args.pathKey);
31594
31828
  return { sourceIdentity: sourceIdentity2, virtualId };
31595
31829
  }
31830
+ function derivedVirtualValueId(instanceRootId, sourceIdentity2) {
31831
+ return instanceRootId.startsWith("__pending__:") || hasPendingVirtualSourceIdentity(sourceIdentity2) ? pendingVirtualValueId(instanceRootId, sourceIdentity2) : virtualValueId(instanceRootId, sourceIdentity2);
31832
+ }
31596
31833
  var VirtualExpansionUnsupportedError = class extends Error {
31597
31834
  constructor(message) {
31598
31835
  super(message);
@@ -31841,7 +32078,7 @@ function resolveVirtualInstanceGraph(args) {
31841
32078
  schemaKey: settled2.schemaKey
31842
32079
  })
31843
32080
  )?.member;
31844
- if (destination === void 0 || !(isMemberClassBase(destination) || isMemberListBase(destination) || isMemberDictionaryBase(destination)))
32081
+ if (destination === void 0 || !(isMemberClassBase(destination) || isMemberWithEntries(destination)))
31845
32082
  continue;
31846
32083
  result.set(settled2.schemaKey, edge.targetValueId);
31847
32084
  }
@@ -31891,7 +32128,7 @@ function resolveVirtualInstanceGraph(args) {
31891
32128
  };
31892
32129
  if (indexed.parentSegment?.kind === "list" && parentId !== null) {
31893
32130
  const parent = indexed.parentPathKey === null ? void 0 : expansion.nodesByPath.get(indexed.parentPathKey);
31894
- if (parent !== void 0 && isMemberListBase(parent.member) && listKindOf(parent.member) === 1 /* Unordered */)
32131
+ if (parent !== void 0 && isMemberEntryCollectionBase(parent.member) && listKindOf(parent.member) === 1 /* Unordered */)
31895
32132
  effective.containerId = parentId;
31896
32133
  }
31897
32134
  if (isMemberClassBase(indexed.member) && effective.value !== null) {
@@ -31911,7 +32148,7 @@ function resolveVirtualInstanceGraph(args) {
31911
32148
  });
31912
32149
  if (!expansion.nodesByPath.has(childPath)) continue;
31913
32150
  const storedChildId = storedRecord[entry.schemaKey] ?? constructedChildren.get(entry.schemaKey) ?? null;
31914
- if (args.preserveUnloadedStoredChildren && storedChildId !== null && !materializedById.has(storedChildId)) {
32151
+ if (storedChildId !== null && !materializedById.has(storedChildId) && (typeof args.preserveUnloadedStoredChildren === "function" ? args.preserveUnloadedStoredChildren(storedChildId) : args.preserveUnloadedStoredChildren)) {
31915
32152
  effectiveRecord[entry.schemaKey] = storedChildId;
31916
32153
  continue;
31917
32154
  }
@@ -31922,7 +32159,7 @@ function resolveVirtualInstanceGraph(args) {
31922
32159
  if (effectiveRecord[key] === void 0) effectiveRecord[key] = childId;
31923
32160
  }
31924
32161
  effective.value = effectiveRecord;
31925
- } else if (isMemberListBase(indexed.member)) {
32162
+ } else if (isMemberEntryCollectionBase(indexed.member)) {
31926
32163
  const effectiveListValue = materialized === null ? indexed.expandedRow.value : materialized.value;
31927
32164
  if (effectiveListValue === null) {
31928
32165
  effective.value = null;
@@ -32322,12 +32559,149 @@ function resolveVirtualInstanceGraph(args) {
32322
32559
  ),
32323
32560
  normalizeLeafPayload(location.virtualRow, location.member)
32324
32561
  );
32562
+ let expandedEntryIdsByContainerId;
32563
+ const argumentChildren = (row, type) => {
32564
+ if (typeof row.classId === "string") {
32565
+ const body = stringRecord(row.value);
32566
+ const env = materializedGraph.genericEnvironmentForRow(row);
32567
+ return resolvedClassSchema(
32568
+ row.classId,
32569
+ args.document.classes,
32570
+ args.document.members
32571
+ ).surface.flatMap((entry) => {
32572
+ const id = body[entry.schemaKey];
32573
+ const member = materializedGraph.memberForId(entry.memberId);
32574
+ if (id === void 0 || member === void 0) return [];
32575
+ return [
32576
+ {
32577
+ id,
32578
+ segment: { kind: "class", schemaKey: entry.schemaKey },
32579
+ type: materializedGraph.typeInfoForMember(member, env)
32580
+ }
32581
+ ];
32582
+ });
32583
+ }
32584
+ if (type?.type === 5 /* Dictionary */) {
32585
+ const entryType2 = type.entryTypeInfo;
32586
+ return Object.entries(stringRecord(row.value)).map(([key, id]) => ({
32587
+ id,
32588
+ segment: { kind: "dictionary", key },
32589
+ type: entryType2
32590
+ }));
32591
+ }
32592
+ if (type?.type !== 6 /* List */ && type?.type !== 28 /* Set */)
32593
+ return [];
32594
+ const entryType = type.entryTypeInfo;
32595
+ expandedEntryIdsByContainerId ??= buildUnorderedListMembershipIndex(
32596
+ args.expandedRows
32597
+ );
32598
+ const entries = expandedEntryIdsByContainerId.get(row.id) ?? (Array.isArray(row.value) ? row.value : []);
32599
+ return entries.flatMap(
32600
+ (id, index) => typeof id === "string" ? [{ id, segment: { kind: "list", index }, type: entryType }] : []
32601
+ );
32602
+ };
32603
+ const constructionArguments = (location) => {
32604
+ const node = expansion.nodesByPath.get(location.pathKey);
32605
+ if (node === void 0) return null;
32606
+ const owner = node.expandedRow;
32607
+ const pending = [];
32608
+ const enqueueArguments = (row, path, member) => {
32609
+ const edges = materializedGraph.constructorEdges(row, member);
32610
+ for (const edge of edges)
32611
+ pending.push({
32612
+ id: edge.targetValueId,
32613
+ path: appendVirtualValuePath(path, {
32614
+ kind: "class",
32615
+ schemaKey: `@constructor:${edge.parameterId}`
32616
+ }),
32617
+ type: edge.typeInfo
32618
+ });
32619
+ return edges;
32620
+ };
32621
+ const ownerEdges = enqueueArguments(owner, ROOT_PATH, node.member);
32622
+ if (ownerEdges.length === 0) return null;
32623
+ const ids = /* @__PURE__ */ new Map();
32624
+ const aliasedValueIds = [];
32625
+ const argumentRows = [];
32626
+ for (let index = 0; index < pending.length; index += 1) {
32627
+ const { id, path, type } = pending[index];
32628
+ if (ids.has(id)) continue;
32629
+ const aliased = expansion.nodesByExpandedId.get(id);
32630
+ if (aliased !== void 0) {
32631
+ const target = locationsByPath.get(aliased.pathKey);
32632
+ if (target === void 0) continue;
32633
+ ids.set(id, target.id);
32634
+ aliasedValueIds.push(target.id);
32635
+ continue;
32636
+ }
32637
+ const row = expansion.rowsByExpandedId.get(id);
32638
+ if (row === void 0) continue;
32639
+ const argumentId = derivedVirtualValueId(
32640
+ location.instanceRootId,
32641
+ `${location.sourceIdentity}:${path}`
32642
+ );
32643
+ ids.set(id, argumentId);
32644
+ const bodyIds = /* @__PURE__ */ new Set();
32645
+ for (const child of argumentChildren(row, type)) {
32646
+ bodyIds.add(child.id);
32647
+ pending.push({
32648
+ id: child.id,
32649
+ path: appendVirtualValuePath(path, child.segment),
32650
+ type: child.type
32651
+ });
32652
+ }
32653
+ argumentRows.push({
32654
+ row,
32655
+ id: argumentId,
32656
+ edges: enqueueArguments(row, path),
32657
+ bodyIds
32658
+ });
32659
+ }
32660
+ const retargetArguments = (row, edges) => {
32661
+ const stored = literalRow(row).constructorArgs;
32662
+ if (stored == null || edges.length === 0) return stored;
32663
+ const next = { ...stored };
32664
+ for (const edge of edges)
32665
+ next[edge.parameterId] = ids.get(edge.targetValueId) ?? edge.targetValueId;
32666
+ return next;
32667
+ };
32668
+ const retargetBody = (value, bodyIds) => {
32669
+ if (bodyIds.size === 0) return value;
32670
+ const retarget = (entry) => typeof entry === "string" && bodyIds.has(entry) ? ids.get(entry) ?? entry : entry;
32671
+ if (Array.isArray(value)) return value.map(retarget);
32672
+ return Object.fromEntries(
32673
+ Object.entries(value).map(
32674
+ ([key, entry]) => [key, retarget(entry)]
32675
+ )
32676
+ );
32677
+ };
32678
+ return {
32679
+ constructorArgs: retargetArguments(owner, ownerEdges) ?? {},
32680
+ rows: argumentRows.map(({ row, id, edges, bodyIds }) => {
32681
+ const create = createFromRow(
32682
+ literalRow(row),
32683
+ id,
32684
+ retargetBody(row.value, bodyIds)
32685
+ );
32686
+ const constructorArgs = retargetArguments(row, edges);
32687
+ return {
32688
+ ...create,
32689
+ ...constructorArgs === void 0 ? {} : { constructorArgs },
32690
+ ...create.containerId === void 0 ? {} : {
32691
+ containerId: ids.get(create.containerId) ?? create.containerId
32692
+ }
32693
+ };
32694
+ }),
32695
+ aliasedValueIds
32696
+ };
32697
+ };
32325
32698
  return {
32326
32699
  instanceRootId: args.instanceRoot.id,
32327
32700
  ...listenerDefaultsByOwner === void 0 ? {} : { listenerDefaultsByOwner },
32328
32701
  pinnedRootSchemaKeys: args.pinnedRootSchemaKeys,
32329
32702
  compareCreationProvenance,
32330
32703
  compareLeafContent,
32704
+ constructionArguments,
32331
32705
  rowsById,
32332
32706
  locationsById,
32333
32707
  locationsByPath,
@@ -32401,6 +32775,7 @@ function prepareStoredClassValueResolution(args) {
32401
32775
  expandedRows: expanded.rows,
32402
32776
  pinnedRootSchemaKeys: expanded.pinnedRootSchemaKeys,
32403
32777
  materializedIndex: args.materializedIndex,
32778
+ preserveUnloadedStoredChildren: args.preserveUnloadedStoredChildren,
32404
32779
  readRecorder: args.readRecorder
32405
32780
  };
32406
32781
  }
@@ -32671,7 +33046,7 @@ function indexExpansion(args) {
32671
33046
  }
32672
33047
  return;
32673
33048
  }
32674
- if (isMemberListBase(member)) {
33049
+ if (isMemberEntryCollectionBase(member)) {
32675
33050
  if (listKindOf(member) === 1 /* Unordered */) {
32676
33051
  const entryMember3 = membersById.get(member.entryMemberId);
32677
33052
  if (entryMember3 === void 0) return;
@@ -32788,7 +33163,7 @@ function rewriteExpandedRow(node, expansion) {
32788
33163
  rewrite(childId)
32789
33164
  ])
32790
33165
  );
32791
- } else if (isMemberListBase(node.member) && Array.isArray(row.value)) {
33166
+ } else if (isMemberEntryCollectionBase(node.member) && Array.isArray(row.value)) {
32792
33167
  row.value = row.value.map(
32793
33168
  (childId) => typeof childId === "string" ? rewrite(childId) : childId
32794
33169
  );
@@ -32801,6 +33176,21 @@ function rewriteExpandedRow(node, expansion) {
32801
33176
  }
32802
33177
  return row;
32803
33178
  }
33179
+ function createFromRow(prior, id, value, update) {
33180
+ const row = update?.classId !== void 0 && update.classId !== prior.classId ? replaceLiteralValueClass(prior, update.classId) : prior;
33181
+ const create = {
33182
+ id,
33183
+ value,
33184
+ ...typeof row.classId !== "string" ? {} : { classId: row.classId },
33185
+ ...pickInstanceProvenance(row),
33186
+ ...update === void 0 ? {} : pickInstanceProvenance(update),
33187
+ ...row.containerId === void 0 ? {} : { containerId: row.containerId },
33188
+ ...row.mapKey === void 0 ? {} : { mapKey: row.mapKey },
33189
+ ...row.genericBindings === void 0 ? {} : { genericBindings: { ...row.genericBindings } },
33190
+ ...row.sourceValueId === void 0 ? {} : { sourceValueId: row.sourceValueId }
33191
+ };
33192
+ return create;
33193
+ }
32804
33194
  function remapMemberDelegateReceiver(value, remap) {
32805
33195
  if (!isMemberDelegateTarget(value) || value.valueId === null) return value;
32806
33196
  const valueId = remap(value.valueId);
@@ -32808,7 +33198,7 @@ function remapMemberDelegateReceiver(value, remap) {
32808
33198
  }
32809
33199
  function normalizeLeafPayload(row, member, remapReceiver = (id) => id) {
32810
33200
  const literal3 = literalRow(row);
32811
- if (isMemberListBase(member) || isMemberDictionaryBase(member)) {
33201
+ if (isMemberWithEntries(member)) {
32812
33202
  return {
32813
33203
  value: literal3.value,
32814
33204
  classId: literal3.classId ?? null,
@@ -32841,7 +33231,7 @@ function compareContextualCreationProvenance(left, right, context) {
32841
33231
  member.classArguments,
32842
33232
  context.document.classes
32843
33233
  ) : /* @__PURE__ */ new Map();
32844
- if (isMemberListBase(member) || isMemberDictionaryBase(member)) {
33234
+ if (isMemberWithEntries(member)) {
32845
33235
  for (const paramId of referencedGenericParams(
32846
33236
  member,
32847
33237
  context.document.members
@@ -33033,7 +33423,7 @@ function storedConstructorReplayInitializer(args) {
33033
33423
  };
33034
33424
  }
33035
33425
  function storedArgumentPointer(value, typeInfo) {
33036
- if ((typeInfo.type === 7 /* Class */ || typeInfo.type === 22 /* Interface */ || typeInfo.type === 6 /* List */ || typeInfo.type === 5 /* Dictionary */) && typeof value === "string") {
33426
+ if ((typeInfo.type === 7 /* Class */ || typeInfo.type === 22 /* Interface */ || typeInfo.type === 6 /* List */ || typeInfo.type === 28 /* Set */ || typeInfo.type === 5 /* Dictionary */) && typeof value === "string") {
33037
33427
  return { type: "reference" /* reference */, valueId: value };
33038
33428
  }
33039
33429
  return {
@@ -33764,7 +34154,6 @@ function evaluateMemberInitializer(args) {
33764
34154
  );
33765
34155
  const compiled = compileMemberInitializer(args, databaseVM);
33766
34156
  const ctx = {
33767
- ...args.document.evaluationLimits,
33768
34157
  debugSink: args.document.debugSink,
33769
34158
  beforeValueAllocation: args.document.beforeValueAllocation,
33770
34159
  listenerDefaultCapture: args.document.listenerDefaultCapture,
@@ -33811,6 +34200,7 @@ function evaluateMemberInitializer(args) {
33811
34200
  sessionStaticBindings: args.sessionStaticBindings,
33812
34201
  ...args.storedConstructionReplay === true ? {
33813
34202
  storedConstructionReplay: true,
34203
+ ...args.sourceValueId == null ? {} : { __storedConstructionReplayRowId: args.sourceValueId },
33814
34204
  ...isMemberClassBase(args.member) ? {
33815
34205
  __storedConstructionReplaySlot: {
33816
34206
  classId: args.member.classId,
@@ -35426,7 +35816,8 @@ var COLLECTION_QUERY_METHODS = {
35426
35816
  SkipWhile: "predicate",
35427
35817
  TakeWhile: "predicate",
35428
35818
  Reverse: "none",
35429
- Concat: "collection"
35819
+ Concat: "collection",
35820
+ ToSet: "none"
35430
35821
  };
35431
35822
  var COLLECTION_FUNCTION_ARGUMENTS = {
35432
35823
  Where: "predicate",
@@ -35445,6 +35836,19 @@ function collectionFunctionContract(name) {
35445
35836
  return COLLECTION_FUNCTION_ALIASES[name];
35446
35837
  return isCollectionFunctionName(name) ? name : null;
35447
35838
  }
35839
+ var SET_PRESERVING_COLLECTION_QUERIES = /* @__PURE__ */ new Set([
35840
+ "Where",
35841
+ "Skip",
35842
+ "Take",
35843
+ "SkipWhile",
35844
+ "TakeWhile",
35845
+ "OrderBy",
35846
+ "OrderByDescending",
35847
+ "Reverse"
35848
+ ]);
35849
+ function isSetPreservingCollectionQuery(name) {
35850
+ return SET_PRESERVING_COLLECTION_QUERIES.has(name);
35851
+ }
35448
35852
  function isCollectionQueryName(name) {
35449
35853
  return Object.hasOwn(COLLECTION_QUERY_METHODS, name);
35450
35854
  }
@@ -39727,7 +40131,7 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
39727
40131
  indexCollectionPointer: receiver.pointer
39728
40132
  };
39729
40133
  }
39730
- if (receiver.type.kind === "list" && name === "Index" && this.indexesFor(receiver.type).length > 0) {
40134
+ if ((receiver.type.kind === "list" || receiver.type.kind === "set") && name === "Index" && this.indexesFor(receiver.type).length > 0) {
39731
40135
  return {
39732
40136
  pointer: receiver.pointer,
39733
40137
  type: { kind: "primitive", name: "unknown" },
@@ -39908,10 +40312,11 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
39908
40312
  declaring
39909
40313
  );
39910
40314
  }
39911
- /** The indexes declared on a schema-backed List, keyed by its member. */
40315
+ /** The indexes declared on a schema-backed List or Set, keyed by its member. */
39912
40316
  indexesFor(type) {
39913
- if (type.listMemberId === void 0) return [];
39914
- return this.project.indexesByListMemberId.get(type.listMemberId) ?? [];
40317
+ const memberId = indexedCollectionMemberId(type);
40318
+ if (memberId === void 0) return [];
40319
+ return this.project.indexesByListMemberId.get(memberId) ?? [];
39915
40320
  }
39916
40321
  /**
39917
40322
  * P42 §2.3. `Images.<Name>` / `AudioClips.<Name>`.
@@ -42469,6 +42874,33 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
42469
42874
  case "Reverse":
42470
42875
  info = { ...base, op: name };
42471
42876
  break;
42877
+ case "ToSet": {
42878
+ if (collection.kind === "dictionary")
42879
+ throw new CompileError("ToSet requires a List or Set receiver.", pos);
42880
+ const elementError = setElementTypeError(
42881
+ collection.valueType,
42882
+ this.project
42883
+ );
42884
+ if (elementError !== null) throw new CompileError(elementError, pos);
42885
+ info = {
42886
+ ...base,
42887
+ op: name,
42888
+ ...hasReferenceEquality(collection.valueType, this.project) ? { reference: true } : {}
42889
+ };
42890
+ resultType = {
42891
+ kind: "set",
42892
+ elementType: collection.valueType,
42893
+ readOnly: true
42894
+ };
42895
+ break;
42896
+ }
42897
+ }
42898
+ if (collection.kind === "set" && isSetPreservingCollectionQuery(name)) {
42899
+ resultType = {
42900
+ kind: "set",
42901
+ elementType: collection.valueType,
42902
+ readOnly: true
42903
+ };
42472
42904
  }
42473
42905
  return {
42474
42906
  ...intrinsic(
@@ -42476,7 +42908,7 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
42476
42908
  {
42477
42909
  ...info,
42478
42910
  ...toWireType(
42479
- resultType.kind === "list" ? resultType.elementType : resultType,
42911
+ resultType.kind === "list" || resultType.kind === "set" ? resultType.elementType : resultType,
42480
42912
  this.project
42481
42913
  ).type === 8 /* Enum */ ? { enumEntries: true } : {}
42482
42914
  },
@@ -44809,10 +45241,16 @@ function toWireType(type, project) {
44809
45241
  ...type.readOnly ? { readOnly: true } : {}
44810
45242
  };
44811
45243
  case "set": {
45244
+ const entryTypeInfo = toWireType(type.elementType, project);
45245
+ if (type.setMemberId === void 0) {
45246
+ return { type: 9 /* Lookup */, required, entryTypeInfo };
45247
+ }
44812
45248
  return {
44813
- type: 9 /* Lookup */,
45249
+ type: 28 /* Set */,
44814
45250
  required,
44815
- entryTypeInfo: toWireType(type.elementType, project)
45251
+ entryTypeInfo,
45252
+ setMemberId: type.setMemberId,
45253
+ ...type.readOnly ? { readOnly: true } : {}
44816
45254
  };
44817
45255
  }
44818
45256
  case "dictionary": {
@@ -44895,6 +45333,15 @@ function fromWireType(type) {
44895
45333
  nullable: nullable2
44896
45334
  };
44897
45335
  }
45336
+ if (type.type === 28 /* Set */) {
45337
+ return {
45338
+ kind: "set",
45339
+ elementType: fromWireType(type.entryTypeInfo),
45340
+ nullable: nullable2,
45341
+ ...type.setMemberId ? { setMemberId: type.setMemberId } : {},
45342
+ ...type.readOnly ? { readOnly: true } : {}
45343
+ };
45344
+ }
44898
45345
  if (type.type === 25 /* Delegate */) {
44899
45346
  return {
44900
45347
  kind: "delegate",
@@ -44992,6 +45439,23 @@ function valueKindPrimitive(kind) {
44992
45439
  return "Color";
44993
45440
  }
44994
45441
  }
45442
+ function setElementTypeError(type, project) {
45443
+ if (type.nullable === true) return SET_ELEMENT_NULLABLE_ERROR;
45444
+ switch (type.kind) {
45445
+ case "list":
45446
+ case "set":
45447
+ case "dictionary":
45448
+ return SET_ELEMENT_COLLECTION_ERROR;
45449
+ case "delegate":
45450
+ return setElementKindError("delegates");
45451
+ case "action":
45452
+ return setElementKindError("actions");
45453
+ case "named":
45454
+ return project.typeById.get(type.typeId)?.kind === "interface" ? setElementKindError("interfaces") : null;
45455
+ default:
45456
+ return null;
45457
+ }
45458
+ }
44995
45459
  function hasReferenceEquality(type, project) {
44996
45460
  const lookup = neoScriptMemberLookupType(type);
44997
45461
  switch (lookup.kind) {
@@ -46731,7 +47195,7 @@ function orderMergedMembers(type, members, environment) {
46731
47195
  return ordered;
46732
47196
  }
46733
47197
  function listIndexes(member, environment, field) {
46734
- if (member.kind !== "list") return [];
47198
+ if (member.kind !== "list" && member.kind !== "set") return [];
46735
47199
  const id = string(member.id, `${field}.id`);
46736
47200
  const entryId = string(member.entryMemberId, `${field}.entryMemberId`);
46737
47201
  const entry = environment.members.get(entryId);
@@ -46810,7 +47274,7 @@ function memberType(member, environment, visiting, field) {
46810
47274
  };
46811
47275
  return member.multiselect === true ? { kind: "set", elementType: enumType2, nullable: nullable2 } : { ...enumType2, nullable: nullable2 };
46812
47276
  }
46813
- if (kind === "list" || kind === "dictionary") {
47277
+ if (kind === "list" || kind === "set" || kind === "dictionary") {
46814
47278
  const entry = environment.members.get(
46815
47279
  string(member.entryMemberId, `${field}.entryMemberId`)
46816
47280
  );
@@ -46824,6 +47288,9 @@ function memberType(member, environment, visiting, field) {
46824
47288
  readOnly: false
46825
47289
  };
46826
47290
  }
47291
+ if (kind === "set") {
47292
+ return { kind: "set", elementType: entryType, nullable: nullable2, setMemberId: id };
47293
+ }
46827
47294
  const key = optionalRecord(member.key);
46828
47295
  return {
46829
47296
  kind: "dictionary",
@@ -46968,6 +47435,18 @@ function manifestType(value, environment, field) {
46968
47435
  readOnly: boolean(type.readOnly, `${field}.readOnly`)
46969
47436
  };
46970
47437
  }
47438
+ if (kind === "set") {
47439
+ return {
47440
+ kind: "set",
47441
+ elementType: manifestType(
47442
+ type.entryType,
47443
+ environment,
47444
+ `${field}.entryType`
47445
+ ),
47446
+ nullable: nullable2,
47447
+ setMemberId: string(type.setMemberId, `${field}.setMemberId`)
47448
+ };
47449
+ }
46971
47450
  if (kind === "dictionary") {
46972
47451
  const keyEnumId = nullableString(type.keyEnumId, `${field}.keyEnumId`);
46973
47452
  return {
@@ -47481,7 +47960,7 @@ function interfacePropertyIsSettable(member) {
47481
47960
  function containsForbiddenMemberTypeInfo(typeInfo) {
47482
47961
  if (typeInfo.type === NS_TYPE_UNKNOWN) return true;
47483
47962
  if (typeInfo.type === 21 /* Generic */) return true;
47484
- if (typeInfo.type === 6 /* List */ || typeInfo.type === 5 /* Dictionary */ || typeInfo.type === 9 /* Lookup */) {
47963
+ if (typeInfo.type === 6 /* List */ || typeInfo.type === 28 /* Set */ || typeInfo.type === 5 /* Dictionary */ || typeInfo.type === 9 /* Lookup */) {
47485
47964
  return containsForbiddenMemberTypeInfo(typeInfo.entryTypeInfo);
47486
47965
  }
47487
47966
  if (typeInfo.type === 7 /* Class */ && typeInfo.typeArguments) {
@@ -47866,8 +48345,7 @@ function storedDialogueGroupSources(groups, memberById, classById) {
47866
48345
  }
47867
48346
  function lookupEntry(collectionMemberId, memberById, classById) {
47868
48347
  const collection = memberById(collectionMemberId);
47869
- if (!isMemberListBase(collection) && !isMemberDictionaryBase(collection))
47870
- return void 0;
48348
+ if (!isMemberWithEntries(collection)) return void 0;
47871
48349
  const entry = memberById(collection.entryMemberId);
47872
48350
  if (!isMemberClassBase(entry)) return void 0;
47873
48351
  const entryClass = classById(entry.classId);
@@ -48691,7 +49169,7 @@ function createListIndexes(context) {
48691
49169
  } catch {
48692
49170
  continue;
48693
49171
  }
48694
- if (!isMemberListBase(resolved)) continue;
49172
+ if (!isMemberEntryCollectionBase(resolved)) continue;
48695
49173
  const definitions = resolveListIndexDefinitions(
48696
49174
  {
48697
49175
  members: context.vm.members,
@@ -48701,7 +49179,7 @@ function createListIndexes(context) {
48701
49179
  record4
48702
49180
  );
48703
49181
  const listType = memberRuntimeType(record4, context);
48704
- if (listType.kind !== "list") continue;
49182
+ if (listType.kind !== "list" && listType.kind !== "set") continue;
48705
49183
  for (const definition of definitions) {
48706
49184
  result.push({
48707
49185
  id: `${record4.id}:index:${definition.schemaKey}`,
@@ -48797,6 +49275,22 @@ function memberRuntimeType(record4, context, seen = /* @__PURE__ */ new Set(), g
48797
49275
  nullable: !required
48798
49276
  };
48799
49277
  }
49278
+ case 28 /* Set */: {
49279
+ if (!isMemberSetBase(member)) return UNKNOWN_TYPE;
49280
+ const entry = analyzerMemberById(context, member.entryMemberId);
49281
+ const projectedEntry = entry ? substituteForGenericEnvironment(entry, genericEnvironment, context) : null;
49282
+ return {
49283
+ kind: "set",
49284
+ elementType: projectedEntry ? memberRuntimeType(
49285
+ projectedEntry,
49286
+ context,
49287
+ nextSeen,
49288
+ genericEnvironment
49289
+ ) : UNKNOWN_TYPE,
49290
+ setMemberId: record4.id,
49291
+ nullable: !required
49292
+ };
49293
+ }
48800
49294
  case 5 /* Dictionary */: {
48801
49295
  if (!isMemberDictionaryBase(member)) return UNKNOWN_TYPE;
48802
49296
  const entry = analyzerMemberById(context, member.entryMemberId);
@@ -49041,6 +49535,18 @@ function toLanguageType(type, context, genericEnvironment) {
49041
49535
  ...type.listMemberId ? { listMemberId: type.listMemberId } : {},
49042
49536
  ...type.readOnly ? { readOnly: true } : {}
49043
49537
  };
49538
+ case 28 /* Set */:
49539
+ return {
49540
+ kind: "set",
49541
+ elementType: toLanguageType(
49542
+ type.entryTypeInfo,
49543
+ context,
49544
+ genericEnvironment
49545
+ ),
49546
+ nullable: !required,
49547
+ ...type.setMemberId ? { setMemberId: type.setMemberId } : {},
49548
+ ...type.readOnly ? { readOnly: true } : {}
49549
+ };
49044
49550
  case 5 /* Dictionary */:
49045
49551
  return {
49046
49552
  kind: "dictionary",
@@ -52034,7 +52540,7 @@ var PROJECT_TRANSACTION_IMMEDIATE_BUDGET = {
52034
52540
  bytesRead: 6 * MIB,
52035
52541
  bytesWritten: 4 * MIB,
52036
52542
  documentsRead: 4e3,
52037
- documentsWritten: 1800,
52543
+ documentsWritten: 2100,
52038
52544
  databaseQueries: 1140,
52039
52545
  indexRanges: 1140,
52040
52546
  functionsScheduled: 24,
@@ -52325,11 +52831,6 @@ var STRING_TYPE_INFO = {
52325
52831
  // ../src/database/project-version-whole-graph-validation.ts
52326
52832
  import { ConvexError as ConvexError3 } from "convex/values";
52327
52833
 
52328
- // ../src/models/exports/unity-static-members.ts
52329
- var nativePatternMembers = new Set(
52330
- Object.values(NEO_CELL_PATTERN_MEMBER_IDS)
52331
- );
52332
-
52333
52834
  // ../convex/projectInterfaceValidation.ts
52334
52835
  var MEMBER_REQUIREMENT_KINDS = [
52335
52836
  0 /* Optional */,
@@ -53126,6 +53627,15 @@ var SYSTEM_PROTECTION_RULES = {
53126
53627
  ],
53127
53628
  reasonKey: "systemProtection.reasons.scriptRuntime",
53128
53629
  serverReason: "Lifecycle interface the Neo Compose script runtime calls."
53630
+ },
53631
+ [SystemProtectionKind.SystemPreset]: {
53632
+ disallow: [
53633
+ SystemDisallowedOperation.EditRecord,
53634
+ SystemDisallowedOperation.DeleteRecord,
53635
+ SystemDisallowedOperation.ReplaceValue
53636
+ ],
53637
+ reasonKey: "systemProtection.reasons.systemPreset",
53638
+ serverReason: "Built-in preset value shared by every Neo Compose project."
53129
53639
  }
53130
53640
  };
53131
53641
 
@@ -54060,7 +54570,8 @@ var systemProtectionKindSchema = picklist([
54060
54570
  "dialoguePriorityDefault",
54061
54571
  "policyImmutable",
54062
54572
  "policyDeleteBlocked",
54063
- "scriptRuntime"
54573
+ "scriptRuntime",
54574
+ "systemPreset"
54064
54575
  ]);
54065
54576
  var worldSystemClassKindSchema = picklist([
54066
54577
  "cellPattern",
@@ -54187,6 +54698,10 @@ function schemaTypeOptionsAtDepth(depth) {
54187
54698
  listMemberId: nullableId,
54188
54699
  readOnly: boolean2()
54189
54700
  }),
54701
+ nullableTypeSchema("set", {
54702
+ entryType: schemaTypeAtDepth(depth + 1),
54703
+ setMemberId: nonEmptyString
54704
+ }),
54190
54705
  nullableTypeSchema("dictionary", {
54191
54706
  entryType: schemaTypeAtDepth(depth + 1),
54192
54707
  keyEnumId: nullableId,
@@ -54455,6 +54970,12 @@ var schemaMemberSchema = variant("kind", [
54455
54970
  indexes: array(schemaListIndexSchema),
54456
54971
  columns: array(schemaListColumnSchema)
54457
54972
  }),
54973
+ /** P108 §2: insertion-ordered owned entries, no two equal. */
54974
+ memberSchema("set", {
54975
+ entryMemberId: nonEmptyString,
54976
+ indexes: array(schemaListIndexSchema),
54977
+ columns: array(schemaListColumnSchema)
54978
+ }),
54458
54979
  memberSchema("class", {
54459
54980
  classId: nonEmptyString,
54460
54981
  partial: optional(boolean2()),
@@ -54531,6 +55052,9 @@ var schemaMemberSchema = variant("kind", [
54531
55052
  partial: optional(boolean2())
54532
55053
  })
54533
55054
  ]);
55055
+ function isSchemaEntryCollectionMember(member) {
55056
+ return member.kind === "list" || member.kind === "set";
55057
+ }
54534
55058
 
54535
55059
  // node_modules/valibot/dist/index.mjs
54536
55060
  var store$42;
@@ -54598,7 +55122,8 @@ var MEMBER_KIND = {
54598
55122
  FunctionRef: 24,
54599
55123
  NSDelegate: 25,
54600
55124
  NSAction: 26,
54601
- Variant: 27
55125
+ Variant: 27,
55126
+ Set: 28
54602
55127
  };
54603
55128
  var MEMBER_MODIFIERS = ["virtual", "sealed", "abstract", "static"];
54604
55129
  var MEMBER_ACCESS = ["public", "protected", "private"];
@@ -54658,6 +55183,7 @@ var MEMBER_KIND_BY_KIND = /* @__PURE__ */ new Map([
54658
55183
  ["float", MEMBER_KIND.Float],
54659
55184
  ["dictionary", MEMBER_KIND.Dictionary],
54660
55185
  ["list", MEMBER_KIND.List],
55186
+ ["set", MEMBER_KIND.Set],
54661
55187
  ["class", MEMBER_KIND.Class],
54662
55188
  ["enum", MEMBER_KIND.Enum],
54663
55189
  ["lookup", MEMBER_KIND.Lookup],
@@ -54844,6 +55370,19 @@ function memberFromDocument(record4, members, owners, classNames, context) {
54844
55370
  columns: listColumnsFromDocument(field("columnSettings", []), record4)
54845
55371
  };
54846
55372
  }
55373
+ if (kind === MEMBER_KIND.Set) {
55374
+ return {
55375
+ ...common,
55376
+ kind: "set",
55377
+ entryMemberId: requiredStringValue(
55378
+ field("entryMemberId", void 0),
55379
+ record4,
55380
+ "entryMemberId"
55381
+ ),
55382
+ indexes: listIndexesFromDocument(field("indexes", []), record4),
55383
+ columns: listColumnsFromDocument(field("columnSettings", []), record4)
55384
+ };
55385
+ }
54847
55386
  if (kind === MEMBER_KIND.Class) {
54848
55387
  return {
54849
55388
  ...common,
@@ -55097,10 +55636,13 @@ var INHERITED_MEMBER_ORDINAL_FIELDS = /* @__PURE__ */ new Set([
55097
55636
  "dispatch",
55098
55637
  "bodyMode"
55099
55638
  ]);
55639
+ function schemaMemberKindOrdinal(kind) {
55640
+ const ordinal = MEMBER_KIND_BY_KIND.get(kind);
55641
+ if (ordinal === void 0) throw new Error(`No document kind for ${kind}.`);
55642
+ return ordinal;
55643
+ }
55100
55644
  function memberToDocumentFields(member, baseData) {
55101
- const kind = MEMBER_KIND_BY_KIND.get(member.kind);
55102
- if (kind === void 0)
55103
- throw new Error(`No document kind for ${member.kind}.`);
55645
+ const kind = schemaMemberKindOrdinal(member.kind);
55104
55646
  const isOverride = member.overrideOf !== null;
55105
55647
  const fields = {
55106
55648
  id: member.id,
@@ -55158,9 +55700,9 @@ function memberToDocumentFields(member, baseData) {
55158
55700
  }
55159
55701
  if (member.key.kind === "enum") fields.keyEnumId = member.key.enumId;
55160
55702
  }
55161
- if (member.kind === "list") {
55703
+ if (isSchemaEntryCollectionMember(member)) {
55162
55704
  fields.entryMemberId = member.entryMemberId;
55163
- if (member.listKind === "unordered" || isOverride) {
55705
+ if (member.kind === "list" && (member.listKind === "unordered" || isOverride)) {
55164
55706
  fields.listKind = member.listKind === "unordered" ? 1 : 0;
55165
55707
  }
55166
55708
  if (!isOverride) {
@@ -55472,6 +56014,22 @@ function documentTypeToManifest(value, record4, path) {
55472
56014
  readOnly: typeInfo.readOnly === true
55473
56015
  };
55474
56016
  }
56017
+ if (kind === MEMBER_KIND.Set) {
56018
+ return {
56019
+ kind: "set",
56020
+ nullable: nullable2,
56021
+ entryType: documentTypeToManifest(
56022
+ typeInfo.entryTypeInfo,
56023
+ record4,
56024
+ `${path}.entryTypeInfo`
56025
+ ),
56026
+ setMemberId: requiredStringValue(
56027
+ typeInfo.setMemberId,
56028
+ record4,
56029
+ `${path}.setMemberId`
56030
+ )
56031
+ };
56032
+ }
55475
56033
  if (kind === MEMBER_KIND.Lookup) {
55476
56034
  const collectionValueId = optionalStringOrNull(typeInfo.collectionValueId);
55477
56035
  const collectionMemberId = optionalStringOrNull(
@@ -55595,6 +56153,14 @@ function manifestTypeToDocument(type) {
55595
56153
  readOnly: type.readOnly || void 0
55596
56154
  });
55597
56155
  }
56156
+ if (type.kind === "set") {
56157
+ return {
56158
+ type: MEMBER_KIND.Set,
56159
+ required,
56160
+ entryTypeInfo: manifestTypeToDocument(type.entryType),
56161
+ setMemberId: type.setMemberId
56162
+ };
56163
+ }
55598
56164
  if (type.kind === "dictionary") {
55599
56165
  return omitUndefined({
55600
56166
  type: MEMBER_KIND.Dictionary,
@@ -55810,7 +56376,8 @@ function isSchemaSystemMetadata(value) {
55810
56376
  "dialoguePriorityDefault",
55811
56377
  "policyImmutable",
55812
56378
  "policyDeleteBlocked",
55813
- "scriptRuntime"
56379
+ "scriptRuntime",
56380
+ "systemPreset"
55814
56381
  ]);
55815
56382
  const worlds = /* @__PURE__ */ new Set([
55816
56383
  "cellPattern",
@@ -57189,7 +57756,7 @@ var INITIALIZER_KEY_PLACEHOLDER = new RegExp(
57189
57756
 
57190
57757
  // ../packages/manifest/schema-contract/registry.mjs
57191
57758
  var PROJECT_SCHEMA_CONTRACT = Object.freeze({
57192
- cliVersion: "0.77.1",
57759
+ cliVersion: "0.79.0",
57193
57760
  projectFileUploadBatchSize: 32,
57194
57761
  documentRecords: {
57195
57762
  member: {
@@ -57909,7 +58476,8 @@ var PROJECT_SCHEMA_CONTRACT = Object.freeze({
57909
58476
  "DialoguePriorityDefault",
57910
58477
  "PolicyImmutable",
57911
58478
  "PolicyDeleteBlocked",
57912
- "ScriptRuntime"
58479
+ "ScriptRuntime",
58480
+ "SystemPreset"
57913
58481
  ],
57914
58482
  NeoMemberRequirement: ["Optional", "Required"],
57915
58483
  NeoMemberMutability: ["Mutable", "ReadOnly"],
@@ -59019,9 +59587,15 @@ var WORLD_OBJECT_CONTRACT_WORLD_KINDS = /* @__PURE__ */ new Set([
59019
59587
  NeoWorldSystemClassKind.SortingGroup,
59020
59588
  NeoWorldSystemClassKind.SpriteObject
59021
59589
  ]);
59590
+ var SCRIPT_COLLECTION_READERS = {
59591
+ [6 /* List */]: "ReadScriptList",
59592
+ [28 /* Set */]: "ReadScriptSet",
59593
+ [9 /* Lookup */]: "ReadScriptSet",
59594
+ [5 /* Dictionary */]: "ReadScriptDictionary"
59595
+ };
59022
59596
 
59023
59597
  // ../src/models/exports/unity-codegen-revision.ts
59024
- var UNITY_CODEGEN_REVISION = "ac7f9812e3b16cc37d09ba5006316dda6bac23884c83b368a10880bc3f2c765b";
59598
+ var UNITY_CODEGEN_REVISION = "bac1e765b6731dfd0abb8404c7b4c2b65f161f2a539cc485ee297e555852f3ab";
59025
59599
 
59026
59600
  // src/export-cache.ts
59027
59601
  var CACHE_BUILD = JSON.stringify([