@outbuild-company/schedule-core 1.8.0 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -399,16 +399,10 @@ var FIELD_REGISTRY = {
399
399
  valueKind: "reference",
400
400
  extract: (activity) => activity.calendarId === null ? null : String(activity.calendarId)
401
401
  },
402
- // Normalized to string like calendarId. It is stored as a number, so it used
403
- // to reach compareValues through the numeric branch while its sibling
404
- // reference went through the string one — the same field kind comparing two
405
- // different ways. localeCompare with numeric:true keeps the digit ordering.
406
402
  subcontractId: {
407
403
  valueKind: "reference",
408
404
  extract: (activity) => activity.subcontractId === null ? null : String(activity.subcontractId)
409
405
  },
410
- // Declared boolean, not enum: it is one, and saying so is what lets the enum
411
- // branch demand an order without inventing one for true/false.
412
406
  isCritical: {
413
407
  valueKind: "boolean",
414
408
  extract: (activity) => activity.isCritical
@@ -544,7 +538,6 @@ function evaluateVisibleIds(input) {
544
538
  function seedFilterProjection(input) {
545
539
  const { activities, parentOf, filter, context } = input;
546
540
  const matchedIds = /* @__PURE__ */ new Set();
547
- const pinnedVisibleIds = /* @__PURE__ */ new Set();
548
541
  const visibleReferenceCounts = /* @__PURE__ */ new Map();
549
542
  const parentIds = /* @__PURE__ */ new Map();
550
543
  const remainingChildren = /* @__PURE__ */ new Map();
@@ -560,17 +553,11 @@ function seedFilterProjection(input) {
560
553
  );
561
554
  }
562
555
  const isMatch = matchesFilter(activity, filter, context);
563
- const isPinned = input.pinnedVisibleIds?.has(activityId) === true;
564
- visibleReferenceCounts.set(
565
- activityId,
566
- (isMatch ? 1 : 0) + (isPinned ? 1 : 0)
567
- );
556
+ visibleReferenceCounts.set(activityId, isMatch ? 1 : 0);
568
557
  if (isMatch) matchedIds.add(activityId);
569
- if (isPinned) pinnedVisibleIds.add(activityId);
570
558
  }
571
559
  return {
572
560
  matchedIds,
573
- pinnedVisibleIds,
574
561
  visibleReferenceCounts,
575
562
  parentIds,
576
563
  remainingChildren
@@ -612,7 +599,6 @@ function buildFilterProjection(input) {
612
599
  filter: input.filter,
613
600
  context: input.context,
614
601
  matchedIds: seed2.matchedIds,
615
- pinnedVisibleIds: seed2.pinnedVisibleIds,
616
602
  visibleIds,
617
603
  visibleReferenceCounts: seed2.visibleReferenceCounts
618
604
  };
@@ -670,8 +656,6 @@ var OPERATORS_BY_KIND = {
670
656
  date: /* @__PURE__ */ new Set(["after", "before"]),
671
657
  "id-array": /* @__PURE__ */ new Set(["someOf", "notSomeOf"]),
672
658
  enum: /* @__PURE__ */ new Set(["someOf", "notSomeOf"]),
673
- // Same membership operators as enum: splitting the kinds was about ordering,
674
- // not about filtering, and these two filter exactly like an enum.
675
659
  boolean: /* @__PURE__ */ new Set(["someOf", "notSomeOf"]),
676
660
  reference: /* @__PURE__ */ new Set(["someOf", "notSomeOf"])
677
661
  };
@@ -851,7 +835,7 @@ function getChildrenInVisualOrder(parentId, adapter) {
851
835
  children.sort(
852
836
  userOrder === null ? compareActivitiesInVisualOrder : (a, b) => userOrder(a, b) || compareActivitiesInVisualOrder(a, b)
853
837
  );
854
- return children.map((a) => String(a.id));
838
+ return children.map((activity) => String(activity.id));
855
839
  }
856
840
  function iterateInVisualOrder(adapter) {
857
841
  const result = [];
@@ -972,107 +956,61 @@ function dispatchSortSet(action, deps) {
972
956
  return { ok: true, changes };
973
957
  }
974
958
 
975
- // src/columns/text/constants.ts
976
- var TEXT = "text";
977
-
978
- // src/columns/description/constants.ts
979
- var DESCRIPTION = "description";
980
-
981
- // src/columns/duration/constants.ts
982
- var DURATION = "duration";
983
-
984
- // src/columns/progress/constants.ts
985
- var PROGRESS = "progress";
986
-
987
- // src/columns/cost/constants.ts
988
- var COST = "cost";
989
-
990
- // src/columns/used-cost/constants.ts
991
- var USED_COST = "used_cost";
992
-
993
- // src/columns/hh-work-time/constants.ts
994
- var HH_WORK_TIME = "hhWorkTime";
995
-
996
- // src/columns/start-date/constants.ts
997
- var START_DATE = "start_date";
998
-
999
- // src/columns/end-date/constants.ts
1000
- var END_DATE = "end_date";
1001
-
1002
- // src/columns/constraint-type/constants.ts
1003
- var CONSTRAINT_TYPE = "constraint_type";
1004
-
1005
- // src/columns/constraint-date/constants.ts
1006
- var CONSTRAINT_DATE = "constraint_date";
1007
-
1008
- // src/columns/calendar-id/constants.ts
1009
- var CALENDAR_ID = "calendar_id";
1010
-
1011
- // src/columns/custom-id/constants.ts
1012
- var CUSTOM_ID = "custom_id";
1013
-
1014
- // src/columns/subcontract-id/constants.ts
1015
- var SUBCONTRACT_ID = "subcontractId";
1016
-
1017
- // src/columns/responsables/constants.ts
1018
- var RESPONSABLES = "responsables";
1019
-
1020
- // src/columns/tags/constants.ts
1021
- var TAGS = "tags";
1022
-
1023
- // src/columns/predecessors/constants.ts
1024
- var CUSTOM_PREDECESSORS = "custom_predecessors";
1025
-
1026
- // src/columns/successors/constants.ts
1027
- var CUSTOM_SUCESSORS = "custom_sucessors";
1028
-
1029
- // src/columns/real-work/constants.ts
1030
- var REAL_WORK = "real_work";
1031
-
1032
- // src/columns/real-cost/constants.ts
1033
- var REAL_COST = "real_cost";
1034
-
1035
- // src/columns/expected-progress/constants.ts
1036
- var EXPECTED_PROGRESS = "expected_progress";
1037
-
1038
- // src/columns/expected-progress-base/constants.ts
1039
- var EXPECTED_PROGRESS_BASE = "expected_progress_base";
1040
-
1041
- // src/columns/start-base/constants.ts
1042
- var START_BASE = "start_base";
1043
-
1044
- // src/columns/end-base/constants.ts
1045
- var END_BASE = "end_base";
1046
-
1047
- // src/columns/duration-base/constants.ts
1048
- var DURATION_BASE = "duration_base";
1049
-
1050
- // src/columns/cost-base/constants.ts
1051
- var COST_BASE = "cost_base";
1052
-
1053
- // src/columns/work-base/constants.ts
1054
- var WORK_BASE = "work_base";
1055
-
1056
- // src/columns/calendar-duration/constants.ts
1057
- var CALENDAR_DURATION = "calendarDuration";
1058
-
1059
- // src/columns/critical-path/constants.ts
1060
- var IS_CRITICAL = "is_critical";
1061
- var EARLY_START = "earlyStart";
1062
- var EARLY_FINISH = "earlyFinish";
1063
- var LATE_START = "lateStart";
1064
- var LATE_FINISH = "lateFinish";
1065
- var FREE_SLACK = "freeSlack";
1066
- var TOTAL_SLACK = "totalSlack";
1067
-
1068
- // src/columns/correlative-id/constants.ts
1069
- var CORRELATIVE_ID = "correlative_id";
959
+ // src/constants/columns.ts
960
+ var EDITABLE = {
961
+ TEXT: "text",
962
+ DESCRIPTION: "description",
963
+ DURATION: "duration",
964
+ PROGRESS: "progress",
965
+ COST: "cost",
966
+ USED_COST: "used_cost",
967
+ HH_WORK_TIME: "hhWorkTime",
968
+ START_DATE: "start_date",
969
+ END_DATE: "end_date",
970
+ CONSTRAINT_TYPE: "constraint_type",
971
+ CONSTRAINT_DATE: "constraint_date",
972
+ CALENDAR_ID: "calendar_id",
973
+ CUSTOM_ID: "custom_id",
974
+ SUBCONTRACT_ID: "subcontractId",
975
+ RESPONSABLES: "responsables",
976
+ TAGS: "tags",
977
+ CUSTOM_PREDECESSORS: "custom_predecessors",
978
+ CUSTOM_SUCESSORS: "custom_sucessors"
979
+ };
980
+ var READ_ONLY = {
981
+ REAL_WORK: "real_work",
982
+ REAL_COST: "real_cost",
983
+ EXPECTED_PROGRESS: "expected_progress",
984
+ EXPECTED_PROGRESS_BASE: "expected_progress_base",
985
+ START_BASE: "start_base",
986
+ END_BASE: "end_base",
987
+ DURATION_BASE: "duration_base",
988
+ COST_BASE: "cost_base",
989
+ WORK_BASE: "work_base",
990
+ CALENDAR_DURATION: "calendarDuration",
991
+ IS_CRITICAL: "is_critical",
992
+ EARLY_START: "earlyStart",
993
+ EARLY_FINISH: "earlyFinish",
994
+ LATE_START: "lateStart",
995
+ LATE_FINISH: "lateFinish",
996
+ FREE_SLACK: "freeSlack",
997
+ TOTAL_SLACK: "totalSlack",
998
+ CORRELATIVE_ID: "correlative_id",
999
+ UNIQUE_CORRELATIVE_ID: "unique_correlative_id",
1000
+ PONDERATOR: "ponderator",
1001
+ STATUS: "status"
1002
+ };
1003
+ var COLUMN = { ...EDITABLE, ...READ_ONLY };
1070
1004
 
1071
- // src/columns/unique-correlative-id/constants.ts
1072
- var UNIQUE_CORRELATIVE_ID = "unique_correlative_id";
1005
+ // src/shared/assert-never.ts
1006
+ function assertNever(value, message) {
1007
+ throw new Error(message);
1008
+ }
1073
1009
 
1074
- // src/columns/ponderator/constants.ts
1075
- var PONDERATOR = "ponderator";
1010
+ // src/autoscheduler/utils/cancellation.ts
1011
+ function createIsCurrent(id, getCurrentId) {
1012
+ return () => getCurrentId() === id;
1013
+ }
1076
1014
 
1077
1015
  // src/types.ts
1078
1016
  var WORK_TIME_DIRECTION = {
@@ -1091,71 +1029,8 @@ var STATUS = {
1091
1029
  DOING: "Doing"
1092
1030
  };
1093
1031
 
1094
- // src/columns/status/constants.ts
1095
- var STATUS_COLUMN = "status";
1096
- var DEFAULT_STATUS_CRITERIA = "Baseline";
1097
- function resolveStatusCriteria(value) {
1098
- return value === "Actual" ? "Actual" : DEFAULT_STATUS_CRITERIA;
1099
- }
1100
-
1101
- // src/constants/columns.ts
1102
- var EDITABLE = {
1103
- TEXT,
1104
- DESCRIPTION,
1105
- DURATION,
1106
- PROGRESS,
1107
- COST,
1108
- USED_COST,
1109
- HH_WORK_TIME,
1110
- START_DATE,
1111
- END_DATE,
1112
- CONSTRAINT_TYPE,
1113
- CONSTRAINT_DATE,
1114
- CALENDAR_ID,
1115
- CUSTOM_ID,
1116
- SUBCONTRACT_ID,
1117
- RESPONSABLES,
1118
- TAGS,
1119
- CUSTOM_PREDECESSORS,
1120
- CUSTOM_SUCESSORS
1121
- };
1122
- var READ_ONLY = {
1123
- REAL_WORK,
1124
- REAL_COST,
1125
- EXPECTED_PROGRESS,
1126
- EXPECTED_PROGRESS_BASE,
1127
- START_BASE,
1128
- END_BASE,
1129
- DURATION_BASE,
1130
- COST_BASE,
1131
- WORK_BASE,
1132
- CALENDAR_DURATION,
1133
- IS_CRITICAL,
1134
- EARLY_START,
1135
- EARLY_FINISH,
1136
- LATE_START,
1137
- LATE_FINISH,
1138
- FREE_SLACK,
1139
- TOTAL_SLACK,
1140
- CORRELATIVE_ID,
1141
- UNIQUE_CORRELATIVE_ID,
1142
- PONDERATOR,
1143
- STATUS: STATUS_COLUMN
1144
- };
1145
- var COLUMN = { ...EDITABLE, ...READ_ONLY };
1146
-
1147
- // src/shared/assert-never.ts
1148
- function assertNever(value, message) {
1149
- throw new Error(message);
1150
- }
1151
-
1152
- // src/autoscheduler/utils/cancellation.ts
1153
- function createIsCurrent(id, getCurrentId) {
1154
- return () => getCurrentId() === id;
1155
- }
1156
-
1157
1032
  // src/constraints/index.ts
1158
- var CONSTRAINT_TYPE2 = {
1033
+ var CONSTRAINT_TYPE = {
1159
1034
  ASAP: "asap",
1160
1035
  ALAP: "alap",
1161
1036
  SNET: "snet",
@@ -2072,7 +1947,7 @@ function processConstraints(activityIds, adapter, plans) {
2072
1947
  const activity = adapter.getActivity(id);
2073
1948
  if (!activity) continue;
2074
1949
  const type = activity.constraintType;
2075
- if (!type || type === CONSTRAINT_TYPE2.ASAP || type === CONSTRAINT_TYPE2.ALAP) {
1950
+ if (!type || type === CONSTRAINT_TYPE.ASAP || type === CONSTRAINT_TYPE.ALAP) {
2076
1951
  continue;
2077
1952
  }
2078
1953
  const bounds = computeConstraintBounds(activity, adapter);
@@ -2121,14 +1996,14 @@ function validateMilestoneConstraint(activity, successorStart) {
2121
1996
  const { constraintType, constraintDate } = activity;
2122
1997
  if (!constraintType || !constraintDate) return successorStart;
2123
1998
  switch (constraintType) {
2124
- case CONSTRAINT_TYPE2.MSO:
2125
- case CONSTRAINT_TYPE2.MFO:
1999
+ case CONSTRAINT_TYPE.MSO:
2000
+ case CONSTRAINT_TYPE.MFO:
2126
2001
  return new Date(constraintDate);
2127
- case CONSTRAINT_TYPE2.SNET:
2128
- case CONSTRAINT_TYPE2.FNET:
2002
+ case CONSTRAINT_TYPE.SNET:
2003
+ case CONSTRAINT_TYPE.FNET:
2129
2004
  return constraintDate > successorStart ? new Date(constraintDate) : successorStart;
2130
- case CONSTRAINT_TYPE2.SNLT:
2131
- case CONSTRAINT_TYPE2.FNLT:
2005
+ case CONSTRAINT_TYPE.SNLT:
2006
+ case CONSTRAINT_TYPE.FNLT:
2132
2007
  return constraintDate < successorStart ? new Date(constraintDate) : successorStart;
2133
2008
  default:
2134
2009
  return successorStart;
@@ -2257,7 +2132,7 @@ async function asapPass(orderedIds, links, adapter, options, isCurrent, plans) {
2257
2132
  });
2258
2133
  plan.earliestSchedulingStart = linkStart;
2259
2134
  plan.earliestSchedulingEnd = plan.endDate;
2260
- } else if (activity.constraintType === CONSTRAINT_TYPE2.MSO) {
2135
+ } else if (activity.constraintType === CONSTRAINT_TYPE.MSO) {
2261
2136
  if (plan.earliestStart) {
2262
2137
  plan.startDate = plan.earliestStart;
2263
2138
  plan.endDate = plan.earliestEnd ?? adapter.calculateEndDate({
@@ -2266,7 +2141,7 @@ async function asapPass(orderedIds, links, adapter, options, isCurrent, plans) {
2266
2141
  task: activity
2267
2142
  });
2268
2143
  }
2269
- } else if (activity.constraintType === CONSTRAINT_TYPE2.MFO) {
2144
+ } else if (activity.constraintType === CONSTRAINT_TYPE.MFO) {
2270
2145
  if (plan.latestStart) {
2271
2146
  plan.startDate = plan.latestStart;
2272
2147
  plan.endDate = plan.latestEnd ?? adapter.calculateEndDate({
@@ -2292,7 +2167,7 @@ async function alapPass(reversedIds, links, asapPlans, adapter, _options, isCurr
2292
2167
  const activityCount = allActivities.length;
2293
2168
  const alapActivityIds = [];
2294
2169
  for (const activity of allActivities) {
2295
- if (activity.constraintType === CONSTRAINT_TYPE2.ALAP) {
2170
+ if (activity.constraintType === CONSTRAINT_TYPE.ALAP) {
2296
2171
  alapActivityIds.push(activity.id);
2297
2172
  }
2298
2173
  }
@@ -2339,7 +2214,7 @@ async function alapPass(reversedIds, links, asapPlans, adapter, _options, isCurr
2339
2214
  sliceStart = yieldResult.newSliceStart;
2340
2215
  const activity = adapter.getActivity(activityId);
2341
2216
  if (!activity) continue;
2342
- if (activity.constraintType !== CONSTRAINT_TYPE2.ALAP) continue;
2217
+ if (activity.constraintType !== CONSTRAINT_TYPE.ALAP) continue;
2343
2218
  if (!activity.autoScheduling) continue;
2344
2219
  if (activity.progress === COMPLETED_PROGRESS) continue;
2345
2220
  if (isSummary(activity.type, adapter.getChildren(activityId).length > 0))
@@ -2848,9 +2723,7 @@ function applyLinkCreates(links, deps) {
2848
2723
  break;
2849
2724
  }
2850
2725
  duplicateKeys.set(key, linkId);
2851
- if (existingGraphHasCycle && // ponytail: preserve legacy sequential semantics; optimize with dynamic
2852
- // SCC reachability only if corrupt cyclic schedules become measurable.
2853
- wouldIntroduceCycle(edges, {
2726
+ if (existingGraphHasCycle && wouldIntroduceCycle(edges, {
2854
2727
  source: operation.source,
2855
2728
  target: operation.target
2856
2729
  })) {
@@ -3328,7 +3201,7 @@ function widenScopeToAlapActivities(group, allLinks, adapter) {
3328
3201
  const widenedAlapKeys = /* @__PURE__ */ new Set();
3329
3202
  for (const activity of adapter.getAllActivities()) {
3330
3203
  const activityKey = String(activity.id);
3331
- const isOutOfComponentAlap = activity.constraintType === CONSTRAINT_TYPE2.ALAP && !idSet.has(activityKey);
3204
+ const isOutOfComponentAlap = activity.constraintType === CONSTRAINT_TYPE.ALAP && !idSet.has(activityKey);
3332
3205
  if (!isOutOfComponentAlap) continue;
3333
3206
  widenedAlapKeys.add(activityKey);
3334
3207
  idSet.add(activityKey);
@@ -3690,7 +3563,7 @@ var descriptionPipeline = {
3690
3563
 
3691
3564
  // src/columns/shared/activity-predicates.ts
3692
3565
  function effectiveConstraintType(activity) {
3693
- return activity.constraintType ?? CONSTRAINT_TYPE2.ASAP;
3566
+ return activity.constraintType ?? CONSTRAINT_TYPE.ASAP;
3694
3567
  }
3695
3568
  var PROGRESS_COMPLETE = COMPLETED_PROGRESS;
3696
3569
  function isCompletedActivity(activity) {
@@ -4084,8 +3957,8 @@ var costPipeline = {
4084
3957
  }
4085
3958
  return canEdit();
4086
3959
  },
4087
- parseInput(rawValue, activity) {
4088
- if (String(rawValue).trim() === "") return parsed(activity.cost);
3960
+ parseInput(rawValue) {
3961
+ if (String(rawValue).trim() === "") return parsed(0);
4089
3962
  const numericValue = parseFloat(String(rawValue));
4090
3963
  if (Number.isNaN(numericValue)) return parseError("not_a_number");
4091
3964
  return parsed(numericValue);
@@ -4134,8 +4007,8 @@ var usedCostPipeline = {
4134
4007
  }
4135
4008
  return canEdit();
4136
4009
  },
4137
- parseInput(rawValue, activity) {
4138
- if (String(rawValue).trim() === "") return parsed(activity.usedCost);
4010
+ parseInput(rawValue) {
4011
+ if (String(rawValue).trim() === "") return parsed(0);
4139
4012
  const numericValue = parseFloat(String(rawValue));
4140
4013
  if (Number.isNaN(numericValue)) return parseError("not_a_number");
4141
4014
  return parsed(numericValue);
@@ -4428,7 +4301,7 @@ function checkIsWorkingDay(newDate, activity, ctx) {
4428
4301
  return null;
4429
4302
  }
4430
4303
  function detectEndDateConstraintWarning(activity, newEndDate) {
4431
- const cannotViolateStartPin = effectiveConstraintType(activity) === CONSTRAINT_TYPE2.MSO;
4304
+ const cannotViolateStartPin = effectiveConstraintType(activity) === CONSTRAINT_TYPE.MSO;
4432
4305
  if (cannotViolateStartPin) return void 0;
4433
4306
  const projectedDate = pickProjectedDateForConstraint(
4434
4307
  effectiveConstraintType(activity),
@@ -4478,7 +4351,7 @@ function calculateNewDuration(activity, newEndDate, ctx) {
4478
4351
 
4479
4352
  // src/columns/constraint-type/constraint-type-pipeline.ts
4480
4353
  var VALID_CONSTRAINT_TYPES = new Set(
4481
- Object.values(CONSTRAINT_TYPE2)
4354
+ Object.values(CONSTRAINT_TYPE)
4482
4355
  );
4483
4356
  var constraintTypePipeline = {
4484
4357
  targetField: "constraintType",
@@ -5259,6 +5132,12 @@ function runExpectedProgressBase(state, now, defaultBaseCalendarId = null) {
5259
5132
  return computeExpectedProgress(rootIds, now, adapter, defaultBaseCalendarId);
5260
5133
  }
5261
5134
 
5135
+ // src/columns/status/constants.ts
5136
+ var DEFAULT_STATUS_CRITERIA = "Baseline";
5137
+ function resolveStatusCriteria(value) {
5138
+ return value === "Actual" ? "Actual" : DEFAULT_STATUS_CRITERIA;
5139
+ }
5140
+
5262
5141
  // src/columns/status/compute.ts
5263
5142
  var roundToTwoDecimals = (value) => Math.round(value * 100) / 100;
5264
5143
  function resolveExpectedForStatus(activity, criteria) {
@@ -5286,7 +5165,7 @@ function applyStatusPass(state, criteria) {
5286
5165
  resolveExpectedForStatus(activity, criteria)
5287
5166
  );
5288
5167
  if (activity.status !== status) {
5289
- setActivityFieldDynamic(state, id, STATUS_COLUMN, status);
5168
+ setActivityFieldDynamic(state, id, COLUMN.STATUS, status);
5290
5169
  changed.push(id);
5291
5170
  }
5292
5171
  });
@@ -9059,10 +8938,10 @@ var FreeFloat = class {
9059
8938
  this.durationCache = /* @__PURE__ */ new Map();
9060
8939
  }
9061
8940
  getFreeFloat() {
9062
- const PROGRESS2 = Number(this.activity.progress);
8941
+ const PROGRESS = Number(this.activity.progress);
9063
8942
  const CONSTRAINT = this.getConstraintType();
9064
8943
  this.calculateFreeFloatOfLink(CONSTRAINT);
9065
- const activityFreeFloat = PROGRESS2 === 100 ? 0 : this.getFreeFloatBaseConstraint(CONSTRAINT);
8944
+ const activityFreeFloat = PROGRESS === 100 ? 0 : this.getFreeFloatBaseConstraint(CONSTRAINT);
9066
8945
  return {
9067
8946
  activityFreeFloat,
9068
8947
  linksFreeFloat: this.linksFreeFloatObject
@@ -9221,11 +9100,11 @@ var FreeFloat = class {
9221
9100
  };
9222
9101
  }
9223
9102
  calculateMsoMfo(constraint) {
9224
- const CONSTRAINT_DATE2 = this.activity.constraint_date || /* @__PURE__ */ new Date();
9103
+ const CONSTRAINT_DATE = this.activity.constraint_date || /* @__PURE__ */ new Date();
9225
9104
  const calculation = this.forwardMap.get(this.activity.id);
9226
9105
  const DATE_TO_CALCULATE = constraint === CONSTRAINT_TYPES.MSO ? calculation?.es : calculation?.ef;
9227
9106
  const freeSlack = this.calculationWithCalendar(
9228
- CONSTRAINT_DATE2,
9107
+ CONSTRAINT_DATE,
9229
9108
  DATE_TO_CALCULATE
9230
9109
  );
9231
9110
  return Math.max(0, this.parseHoursToDays(freeSlack));
@@ -11288,7 +11167,7 @@ function buildParentMutations(input) {
11288
11167
  if (wasPromotableLeaf) {
11289
11168
  fields.type = PROMOTION_TARGET_TYPE;
11290
11169
  if ((input.promotionSource ?? "create") === "create") {
11291
- fields.constraintType = CONSTRAINT_TYPE2.ASAP;
11170
+ fields.constraintType = CONSTRAINT_TYPE.ASAP;
11292
11171
  fields.constraintDate = null;
11293
11172
  fields.progress = 0;
11294
11173
  }
@@ -12429,8 +12308,6 @@ function dispatchSirSync(action, deps) {
12429
12308
  id,
12430
12309
  kind: "updated",
12431
12310
  fields: { pendingRequestIds: { before, after } },
12432
- // ISSUE-025: `after` must be the COMPLETE post-change entity; a partial
12433
- // object crashes any consumer that projects the full snapshot.
12434
12311
  after: structuredCloneActivity(updated)
12435
12312
  };
12436
12313
  return {
@@ -17909,16 +17786,6 @@ var ScheduleState = class _ScheduleState {
17909
17786
  this._viewState.setActiveOrder(nextOrder);
17910
17787
  this.invalidateDerivedOrder();
17911
17788
  }
17912
- /**
17913
- * Rebuild-on-demand, memoized: at most one build per invalidation, never one
17914
- * per comparison. getChildrenInVisualOrder asks for this once and then sorts a
17915
- * whole sibling group with it, and collectBranchOrder walks every branch, so a
17916
- * build per read would be thousands per dispatch.
17917
- *
17918
- * The factory reads hoursPerDay and the collation locale at build time, so a
17919
- * rebuilt comparator always reflects the current context — that is what keeps
17920
- * ordering and filtering from seeing two different hoursPerDay.
17921
- */
17922
17789
  getOrderComparator() {
17923
17790
  const activeOrder = this._viewState.getActiveOrder();
17924
17791
  if (activeOrder === null) {
@@ -17929,12 +17796,6 @@ var ScheduleState = class _ScheduleState {
17929
17796
  this._cache.orderComparator = this._buildOrderComparator(activeOrder);
17930
17797
  return this._cache.orderComparator;
17931
17798
  }
17932
- /**
17933
- * Both order caches, always together. The comparator decides the sequence, so
17934
- * a rebuilt comparator with a surviving sequence would paint the old order.
17935
- * invalidateVisualOrderIds stays separate on purpose: a structural change
17936
- * moves rows without touching the rules, so the comparator is still valid.
17937
- */
17938
17799
  invalidateDerivedOrder() {
17939
17800
  this._cache.orderComparator = null;
17940
17801
  this._cache.visualOrderIds = null;
@@ -18117,8 +17978,8 @@ var ScheduleState = class _ScheduleState {
18117
17978
  const key = String(activityId);
18118
17979
  if (this._viewState.isChecked(key) || !this._viewState.isVisible(key)) {
18119
17980
  this._captureViewStateOnce();
18120
- this._viewState.forget(key);
18121
17981
  }
17982
+ this._viewState.forget(key);
18122
17983
  this._activities.delete(activityId);
18123
17984
  if (this._lastStartDate.has(String(activityId))) {
18124
17985
  this._captureLastStartDateOnce();
@@ -21043,29 +20904,6 @@ var ScheduleCore = class _ScheduleCore {
21043
20904
  _undo = new UndoRecorder();
21044
20905
  _opQueue = Promise.resolve();
21045
20906
  _scheduleRevision = 0;
21046
- /**
21047
- * Revision counting mutations that have been ADMITTED, whether or not they
21048
- * have changed anything yet. `_scheduleRevision` counts the ones that
21049
- * actually did.
21050
- *
21051
- * INVARIANT: `_pendingScheduleRevision >= _scheduleRevision`, and equality
21052
- * means no mutation is in flight.
21053
- *
21054
- * The two exist separately because the useful instant and the knowable
21055
- * instant are not the same one. A critical-path calculation becomes garbage
21056
- * the moment the next mutation is admitted, but whether that mutation is
21057
- * substantive is only knowable once its ChangeSet exists, which is hundreds
21058
- * of milliseconds later at project scale. Measured live on a 12268-activity
21059
- * project: the cancellation flag flipped 929 ms into a 930 ms calculation,
21060
- * 812 into 812 and 785 into 785, because the job's apply block queues behind
21061
- * the very dispatch whose completion cancels it. Cancellation and job end
21062
- * were the same event, so every discarded job ran the whole calculation.
21063
- *
21064
- * Splitting the counter buys the early signal without moving the meaning of
21065
- * `_scheduleRevision`, whose three readers (`isCriticalPathSettled`,
21066
- * `createDateGesturePreview` and the job's own `isCurrent`) are all written
21067
- * against "the state actually changed".
21068
- */
21069
20907
  _pendingScheduleRevision = 0;
21070
20908
  _criticalPathRevision = -1;
21071
20909
  _activeCriticalPath = null;
@@ -21178,13 +21016,6 @@ var ScheduleCore = class _ScheduleCore {
21178
21016
  this.assertReady();
21179
21017
  return readAllActivities(this.coreRuntime.state);
21180
21018
  }
21181
- /**
21182
- * Read del plan de indent (ISSUE-080): los padres destino DISTINTOS bajo los
21183
- * que quedarían las actividades si se indentaran ahora. Es exactamente la
21184
- * planificación que ejecuta el handler (`planIndentMoves`, autoridad única),
21185
- * expuesta para que la frontera pueda correr el protocolo de conversión a
21186
- * madre (chequeo backend + modal) ANTES de despachar. Solo lecturas.
21187
- */
21188
21019
  getIndentTargetParentIds(activityIds) {
21189
21020
  this.assertReady();
21190
21021
  const plan = planIndentMoves(
@@ -21337,7 +21168,6 @@ var ScheduleCore = class _ScheduleCore {
21337
21168
  this.assertReady();
21338
21169
  return this._saveTracker.hasUnsavedChanges();
21339
21170
  }
21340
- /** Read-only revision; moves once per substantive mutation. */
21341
21171
  getScheduleRevision() {
21342
21172
  return this._scheduleRevision;
21343
21173
  }
@@ -21383,24 +21213,10 @@ var ScheduleCore = class _ScheduleCore {
21383
21213
  );
21384
21214
  return workPromise;
21385
21215
  }
21386
- /**
21387
- * Marks a mutation as admitted and invalidates the calculation in flight.
21388
- *
21389
- * Called BEFORE `_enqueue`, which is the point of the whole thing: the wait
21390
- * in the operation queue is part of the window a running calculation wastes,
21391
- * and it is the longest part of it when several mutations are already
21392
- * queued.
21393
- *
21394
- * `dispatchChangesSchedulingState` is a pure function of the action, so this
21395
- * decision needs no state and cannot be wrong about the action's nature. What
21396
- * it cannot know yet is whether the mutation will produce anything, which is
21397
- * what `_settleScheduleMutation` reconciles afterwards.
21398
- */
21399
21216
  _beginScheduleMutation(action) {
21400
21217
  if (!dispatchChangesSchedulingState(action)) return false;
21401
21218
  return this._admitScheduleMutation();
21402
21219
  }
21403
- /** Undo and redo have no action to classify: reaching them IS the mutation. */
21404
21220
  _admitScheduleMutation() {
21405
21221
  this._pendingScheduleRevision++;
21406
21222
  if (this._activeCriticalPath) {
@@ -21408,30 +21224,6 @@ var ScheduleCore = class _ScheduleCore {
21408
21224
  }
21409
21225
  return true;
21410
21226
  }
21411
- /**
21412
- * Closes a mutation admitted by `_beginScheduleMutation`, on EVERY exit path.
21413
- *
21414
- * `changedState` false means the mutation was admitted and produced nothing
21415
- * (rejected, non-substantive, or rolled back). The pending revision walks
21416
- * back so the invariant holds and `isCriticalPathSettled` keeps telling the
21417
- * truth, and the calculation this mutation killed for nothing is re-armed.
21418
- *
21419
- * The re-arm goes through the queue and that is not incidental. Started
21420
- * outside it, the calculation would run immediately while the next queued
21421
- * mutation is still waiting, and that mutation would kill it again on
21422
- * admission: a cancel-and-restart treadmill burning a fresh project-wide deep
21423
- * copy per lap. Inside the queue the restart cannot happen until the queue
21424
- * drains, so at most one calculation is armed per settled mutation. The burst
21425
- * scenario will NOT catch a regression here, because there every dispatch
21426
- * succeeds and this path is never taken.
21427
- *
21428
- * It re-arms through `recomputeCriticalPath` rather than enqueueing the job
21429
- * directly, because the queue slot must NOT await the job: the job's own
21430
- * apply block needs a later slot on this same queue, so awaiting it from
21431
- * inside a slot deadlocks the core. `recomputeCriticalPath` already has the
21432
- * shape that returns the job's promise out of the slot instead of awaiting
21433
- * it, and it keeps `_criticalPathReady` pointing at the live calculation.
21434
- */
21435
21227
  _settleScheduleMutation(admitted, changedState) {
21436
21228
  if (!admitted) return;
21437
21229
  if (changedState) return;
@@ -21577,11 +21369,7 @@ var ScheduleCore = class _ScheduleCore {
21577
21369
  return operation;
21578
21370
  }
21579
21371
  isCriticalPathSettled() {
21580
- return this._criticalPathRevision === this._scheduleRevision && // An admitted mutation has not landed yet, so whatever is applied now is
21581
- // about to be stale. Without this term `whenCriticalPathSettled` would
21582
- // spin: it would keep arming calculations that `isCurrent` kills on their
21583
- // first check, each one paying the project-wide deep copy first.
21584
- this._pendingScheduleRevision === this._scheduleRevision && this._activeCriticalPath === null;
21372
+ return this._criticalPathRevision === this._scheduleRevision && this._pendingScheduleRevision === this._scheduleRevision && this._activeCriticalPath === null;
21585
21373
  }
21586
21374
  async whenCriticalPathSettled() {
21587
21375
  while (!this.isCriticalPathSettled()) {
@@ -21597,21 +21385,6 @@ var ScheduleCore = class _ScheduleCore {
21597
21385
  const merged = this._reapplyViewState(result.changes);
21598
21386
  return merged === null ? result : { ...result, changes: merged };
21599
21387
  }
21600
- /**
21601
- * The single place the two view-state passes are chained. Dispatch, undo and
21602
- * redo all route through here: when this existed only inside the dispatch
21603
- * path, undo and redo reapplied the filter and forgot the order, so an edit
21604
- * that moved a row and was then undone left the row in its new position.
21605
- *
21606
- * The sequence between the passes is indifferent. Filter and order are
21607
- * orthogonal projections over the same tree — the filter decides which rows
21608
- * exist on screen and never reads the order; the order sequences every
21609
- * sibling group from the hierarchy index and never reads visibility. Either
21610
- * sequence produces the same ChangeSet.
21611
- *
21612
- * Both passes answer null while their state is inactive, so an unfiltered,
21613
- * unsorted schedule pays two property reads.
21614
- */
21615
21388
  _reapplyViewState(changes) {
21616
21389
  const withFilter = this._reapplyActiveFilter(changes);
21617
21390
  const sequenced = this._emitTouchedBranchOrder(withFilter ?? changes);
@@ -21619,58 +21392,8 @@ var ScheduleCore = class _ScheduleCore {
21619
21392
  sequenced.changes ?? withFilter ?? changes,
21620
21393
  sequenced.touchedParents
21621
21394
  );
21622
- const reapplied = withOrder ?? sequenced.changes ?? withFilter;
21623
- const finalChanges = reapplied ?? changes;
21624
- const createdIds = finalChanges.activities.filter((change) => change.kind === "created").map((change) => String(change.id));
21625
- if (createdIds.length === 0) return reapplied;
21626
- const createdAndAncestors = new Set(createdIds);
21627
- const filterProjection = this.coreRuntime.state.getFilterProjection();
21628
- for (const createdId of createdIds) {
21629
- if (filterProjection !== null) {
21630
- filterProjection.pinnedVisibleIds.add(createdId);
21631
- }
21632
- let activityId = createdId;
21633
- while (activityId !== null && activityId !== ROOT_PARENT_ID) {
21634
- createdAndAncestors.add(activityId);
21635
- if (filterProjection !== null) {
21636
- filterProjection.visibleIds.add(activityId);
21637
- filterProjection.visibleReferenceCounts.set(
21638
- activityId,
21639
- (filterProjection.visibleReferenceCounts.get(activityId) ?? 0) + 1
21640
- );
21641
- }
21642
- activityId = this.coreRuntime.state.getParentId(activityId);
21643
- }
21644
- }
21645
- const createdVisibility = applyVisibleSet(
21646
- this.coreRuntime.state,
21647
- createdAndAncestors,
21648
- createdAndAncestors
21649
- );
21650
- if (createdVisibility.length === 0) return reapplied;
21651
- return {
21652
- ...finalChanges,
21653
- viewState: [...finalChanges.viewState ?? [], ...createdVisibility]
21654
- };
21395
+ return withOrder ?? sequenced.changes ?? withFilter;
21655
21396
  }
21656
- /**
21657
- * Emits `order` for the branches this mutation resequenced, when no user order
21658
- * is active.
21659
- *
21660
- * The contract is that `order` reports a CHANGED SEQUENCE, not the presence of
21661
- * a sort. Tying emission to the cause instead of the effect is what produced
21662
- * the undo bug and, later, the reparent ones: without an active order a move,
21663
- * an indent, an outdent or the undo of any of them rearranged rows and said
21664
- * nothing, so an incremental consumer kept the old sequence. The undo of a
21665
- * reparent was the worst of them — it carried neither `order` nor a single
21666
- * correlativeId, so the position was not recoverable by any consumer.
21667
- *
21668
- * The touched branches are derived from the ChangeSet rather than accumulated
21669
- * in the state: an entity whose parentId or correlativeId moved, plus the
21670
- * parents of created and deleted rows, is exactly the set of branches whose
21671
- * sequence can differ. That keeps this linear in the blast radius, adds
21672
- * nothing to the write path, and cannot leak across dispatches.
21673
- */
21674
21397
  _emitTouchedBranchOrder(changes) {
21675
21398
  const adapter = this.coreRuntime.state;
21676
21399
  const touchedParents = collectResequencedParents(
@@ -21687,15 +21410,6 @@ var ScheduleCore = class _ScheduleCore {
21687
21410
  if (order.length === 0) return { changes: null, touchedParents };
21688
21411
  return { changes: { ...changes, order }, touchedParents };
21689
21412
  }
21690
- /**
21691
- * Re-sequences the grid after any mutation that could have changed a value the
21692
- * active order sorts by. Ordering is a view over the data, so an edit that
21693
- * moves a row past its sibling must move the row, exactly as the filter makes
21694
- * a no-longer-matching row disappear.
21695
- *
21696
- * Production only re-sorts after a bar drag; diverging from that is a
21697
- * deliberate product decision, not an oversight.
21698
- */
21699
21413
  _reapplyActiveOrder(changes, resequencedParents) {
21700
21414
  const adapter = this.coreRuntime.state;
21701
21415
  if (adapter.getActiveOrder() === null) return null;
@@ -21738,8 +21452,7 @@ var ScheduleCore = class _ScheduleCore {
21738
21452
  activities: adapter.getAllActivities(),
21739
21453
  parentOf: (activityId) => adapter.getParentId(activityId),
21740
21454
  filter,
21741
- context,
21742
- ...projectionIsCurrent ? { pinnedVisibleIds: projection.pinnedVisibleIds } : {}
21455
+ context
21743
21456
  });
21744
21457
  adapter.setFilterProjection(rebuiltProjection);
21745
21458
  visibleIds = rebuiltProjection.visibleIds;
@@ -21795,11 +21508,7 @@ var ScheduleCore = class _ScheduleCore {
21795
21508
  this.coreRuntime.baseCalendars
21796
21509
  )
21797
21510
  );
21798
- const isCurrent = () => !cancellation.cancelled && this._status !== SCHEDULE_CORE_STATUS.DESTROYED && this._scheduleRevision === revision && // A mutation admitted but not yet settled is enough to make this result
21799
- // garbage. Without this term the calculation only learns it is obsolete
21800
- // when the mutation finishes, which measured live is the same instant the
21801
- // job itself ends.
21802
- this._pendingScheduleRevision === this._scheduleRevision;
21511
+ const isCurrent = () => !cancellation.cancelled && this._status !== SCHEDULE_CORE_STATUS.DESTROYED && this._scheduleRevision === revision && this._pendingScheduleRevision === this._scheduleRevision;
21803
21512
  const promise = (async () => {
21804
21513
  const calculatedFields = await computeCriticalPathFields(
21805
21514
  isolatedState,
@@ -22149,6 +21858,6 @@ var CREATION_KIND = {
22149
21858
  ROOT: "root"
22150
21859
  };
22151
21860
 
22152
- export { ACTIVITY_TYPE, CALENDAR_UNIT, COLUMN, CONSTRAINT_TYPE2 as CONSTRAINT_TYPE, CONSTRAINT_TYPE_TO_LABEL, CREATION_KIND, DEFAULT_HOURS_PER_DAY, DISPATCH_ACTION_KIND, DISPATCH_ACTION_KINDS, DISPATCH_TRACK_EVENT, LINK_CODE_TO_TYPE, LINK_TYPE, LINK_TYPE_CODE, NEW_ACTIVITY_DEFAULTS, REJECTION_REASON, ROOT_PARENT_ID, SCHEDULE_CORE_STATUS, STATUS, ScheduleCore, WORK_TIME_DIRECTION, checkNoUpdatedLinks, computeExpectedProgress, expectedProgressFromBaseline, getActiveBaseline, getUnsavedActivities, isRootParent, normalizeParentKey, parseFromBackend, willRunCriticalPath, yieldToBrowser };
21861
+ export { ACTIVITY_TYPE, CALENDAR_UNIT, COLUMN, CONSTRAINT_TYPE, CONSTRAINT_TYPE_TO_LABEL, CREATION_KIND, DEFAULT_HOURS_PER_DAY, DISPATCH_ACTION_KIND, DISPATCH_ACTION_KINDS, DISPATCH_TRACK_EVENT, LINK_CODE_TO_TYPE, LINK_TYPE, LINK_TYPE_CODE, NEW_ACTIVITY_DEFAULTS, REJECTION_REASON, ROOT_PARENT_ID, SCHEDULE_CORE_STATUS, STATUS, ScheduleCore, WORK_TIME_DIRECTION, checkNoUpdatedLinks, computeExpectedProgress, expectedProgressFromBaseline, getActiveBaseline, getUnsavedActivities, isRootParent, normalizeParentKey, parseFromBackend, willRunCriticalPath, yieldToBrowser };
22153
21862
  //# sourceMappingURL=index.js.map
22154
21863
  //# sourceMappingURL=index.js.map