@elyx-code/project-logic-tree 0.0.6256 → 0.0.6258

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
@@ -24978,8 +24978,8 @@ var Tm = { exports: {} };
24978
24978
  return ye.clone();
24979
24979
  var z = typeof te == "object" ? te : {};
24980
24980
  return z.date = ye, z.args = arguments, new Jt(z);
24981
- }, ae = $;
24982
- ae.l = me, ae.i = ue, ae.w = function(ye, te) {
24981
+ }, oe = $;
24982
+ oe.l = me, oe.i = ue, oe.w = function(ye, te) {
24983
24983
  return X(ye, { locale: te.$L, utc: te.$u, x: te.$x, $offset: te.$offset });
24984
24984
  };
24985
24985
  var Jt = function() {
@@ -24992,7 +24992,7 @@ var Tm = { exports: {} };
24992
24992
  var Q = le.date, Ee = le.utc;
24993
24993
  if (Q === null)
24994
24994
  return /* @__PURE__ */ new Date(NaN);
24995
- if (ae.u(Q))
24995
+ if (oe.u(Q))
24996
24996
  return /* @__PURE__ */ new Date();
24997
24997
  if (Q instanceof Date)
24998
24998
  return new Date(Q);
@@ -25009,7 +25009,7 @@ var Tm = { exports: {} };
25009
25009
  var z = this.$d;
25010
25010
  this.$y = z.getFullYear(), this.$M = z.getMonth(), this.$D = z.getDate(), this.$W = z.getDay(), this.$H = z.getHours(), this.$m = z.getMinutes(), this.$s = z.getSeconds(), this.$ms = z.getMilliseconds();
25011
25011
  }, te.$utils = function() {
25012
- return ae;
25012
+ return oe;
25013
25013
  }, te.isValid = function() {
25014
25014
  return this.$d.toString() !== O;
25015
25015
  }, te.isSame = function(z, le) {
@@ -25020,17 +25020,17 @@ var Tm = { exports: {} };
25020
25020
  }, te.isBefore = function(z, le) {
25021
25021
  return this.endOf(le) < X(z);
25022
25022
  }, te.$g = function(z, le, Q) {
25023
- return ae.u(z) ? this[le] : this.set(Q, z);
25023
+ return oe.u(z) ? this[le] : this.set(Q, z);
25024
25024
  }, te.unix = function() {
25025
25025
  return Math.floor(this.valueOf() / 1e3);
25026
25026
  }, te.valueOf = function() {
25027
25027
  return this.$d.getTime();
25028
25028
  }, te.startOf = function(z, le) {
25029
- var Q = this, Ee = !!ae.u(le) || le, Ie = ae.p(z), ot = function(Lr, ei) {
25030
- var cr = ae.w(Q.$u ? Date.UTC(Q.$y, ei, Lr) : new Date(Q.$y, ei, Lr), Q);
25029
+ var Q = this, Ee = !!oe.u(le) || le, Ie = oe.p(z), ot = function(Lr, ei) {
25030
+ var cr = oe.w(Q.$u ? Date.UTC(Q.$y, ei, Lr) : new Date(Q.$y, ei, Lr), Q);
25031
25031
  return Ee ? cr : cr.endOf(u);
25032
25032
  }, At = function(Lr, ei) {
25033
- return ae.w(Q.toDate()[Lr].apply(Q.toDate("s"), (Ee ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(ei)), Q);
25033
+ return oe.w(Q.toDate()[Lr].apply(Q.toDate("s"), (Ee ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(ei)), Q);
25034
25034
  }, Ot = this.$W, Ut = this.$M, Ti = this.$D, Bn = "set" + (this.$u ? "UTC" : "");
25035
25035
  switch (Ie) {
25036
25036
  case E:
@@ -25055,7 +25055,7 @@ var Tm = { exports: {} };
25055
25055
  }, te.endOf = function(z) {
25056
25056
  return this.startOf(z, !1);
25057
25057
  }, te.$set = function(z, le) {
25058
- var Q, Ee = ae.p(z), Ie = "set" + (this.$u ? "UTC" : ""), ot = (Q = {}, Q[u] = Ie + "Date", Q[R] = Ie + "Date", Q[c] = Ie + "Month", Q[E] = Ie + "FullYear", Q[d] = Ie + "Hours", Q[o] = Ie + "Minutes", Q[l] = Ie + "Seconds", Q[s] = Ie + "Milliseconds", Q)[Ee], At = Ee === u ? this.$D + (le - this.$W) : le;
25058
+ var Q, Ee = oe.p(z), Ie = "set" + (this.$u ? "UTC" : ""), ot = (Q = {}, Q[u] = Ie + "Date", Q[R] = Ie + "Date", Q[c] = Ie + "Month", Q[E] = Ie + "FullYear", Q[d] = Ie + "Hours", Q[o] = Ie + "Minutes", Q[l] = Ie + "Seconds", Q[s] = Ie + "Milliseconds", Q)[Ee], At = Ee === u ? this.$D + (le - this.$W) : le;
25059
25059
  if (Ee === c || Ee === E) {
25060
25060
  var Ot = this.clone().set(R, 1);
25061
25061
  Ot.$d[ot](At), Ot.init(), this.$d = Ot.set(R, Math.min(this.$D, Ot.daysInMonth())).$d;
@@ -25065,13 +25065,13 @@ var Tm = { exports: {} };
25065
25065
  }, te.set = function(z, le) {
25066
25066
  return this.clone().$set(z, le);
25067
25067
  }, te.get = function(z) {
25068
- return this[ae.p(z)]();
25068
+ return this[oe.p(z)]();
25069
25069
  }, te.add = function(z, le) {
25070
25070
  var Q, Ee = this;
25071
25071
  z = Number(z);
25072
- var Ie = ae.p(le), ot = function(Ut) {
25072
+ var Ie = oe.p(le), ot = function(Ut) {
25073
25073
  var Ti = X(Ee);
25074
- return ae.w(Ti.date(Ti.date() + Math.round(Ut * z)), Ee);
25074
+ return oe.w(Ti.date(Ti.date() + Math.round(Ut * z)), Ee);
25075
25075
  };
25076
25076
  if (Ie === c)
25077
25077
  return this.set(c, this.$M + z);
@@ -25082,17 +25082,17 @@ var Tm = { exports: {} };
25082
25082
  if (Ie === h)
25083
25083
  return ot(7);
25084
25084
  var At = (Q = {}, Q[o] = t, Q[d] = i, Q[l] = e, Q)[Ie] || 1, Ot = this.$d.getTime() + z * At;
25085
- return ae.w(Ot, this);
25085
+ return oe.w(Ot, this);
25086
25086
  }, te.subtract = function(z, le) {
25087
25087
  return this.add(-1 * z, le);
25088
25088
  }, te.format = function(z) {
25089
25089
  var le = this, Q = this.$locale();
25090
25090
  if (!this.isValid())
25091
25091
  return Q.invalidDate || O;
25092
- var Ee = z || "YYYY-MM-DDTHH:mm:ssZ", Ie = ae.z(this), ot = this.$H, At = this.$m, Ot = this.$M, Ut = Q.weekdays, Ti = Q.months, Bn = Q.meridiem, jr = function(ei, cr, Es, Da) {
25092
+ var Ee = z || "YYYY-MM-DDTHH:mm:ssZ", Ie = oe.z(this), ot = this.$H, At = this.$m, Ot = this.$M, Ut = Q.weekdays, Ti = Q.months, Bn = Q.meridiem, jr = function(ei, cr, Es, Da) {
25093
25093
  return ei && (ei[cr] || ei(le, Ee)) || Es[cr].slice(0, Da);
25094
25094
  }, Ts = function(ei) {
25095
- return ae.s(ot % 12 || 12, ei, "0");
25095
+ return oe.s(ot % 12 || 12, ei, "0");
25096
25096
  }, Lr = Bn || function(ei, cr, Es) {
25097
25097
  var Da = ei < 12 ? "AM" : "PM";
25098
25098
  return Es ? Da.toLowerCase() : Da;
@@ -25103,11 +25103,11 @@ var Tm = { exports: {} };
25103
25103
  case "YY":
25104
25104
  return String(le.$y).slice(-2);
25105
25105
  case "YYYY":
25106
- return ae.s(le.$y, 4, "0");
25106
+ return oe.s(le.$y, 4, "0");
25107
25107
  case "M":
25108
25108
  return Ot + 1;
25109
25109
  case "MM":
25110
- return ae.s(Ot + 1, 2, "0");
25110
+ return oe.s(Ot + 1, 2, "0");
25111
25111
  case "MMM":
25112
25112
  return jr(Q.monthsShort, Ot, Ti, 3);
25113
25113
  case "MMMM":
@@ -25115,7 +25115,7 @@ var Tm = { exports: {} };
25115
25115
  case "D":
25116
25116
  return le.$D;
25117
25117
  case "DD":
25118
- return ae.s(le.$D, 2, "0");
25118
+ return oe.s(le.$D, 2, "0");
25119
25119
  case "d":
25120
25120
  return String(le.$W);
25121
25121
  case "dd":
@@ -25127,7 +25127,7 @@ var Tm = { exports: {} };
25127
25127
  case "H":
25128
25128
  return String(ot);
25129
25129
  case "HH":
25130
- return ae.s(ot, 2, "0");
25130
+ return oe.s(ot, 2, "0");
25131
25131
  case "h":
25132
25132
  return Ts(1);
25133
25133
  case "hh":
@@ -25139,13 +25139,13 @@ var Tm = { exports: {} };
25139
25139
  case "m":
25140
25140
  return String(At);
25141
25141
  case "mm":
25142
- return ae.s(At, 2, "0");
25142
+ return oe.s(At, 2, "0");
25143
25143
  case "s":
25144
25144
  return String(le.$s);
25145
25145
  case "ss":
25146
- return ae.s(le.$s, 2, "0");
25146
+ return oe.s(le.$s, 2, "0");
25147
25147
  case "SSS":
25148
- return ae.s(le.$ms, 3, "0");
25148
+ return oe.s(le.$ms, 3, "0");
25149
25149
  case "Z":
25150
25150
  return Ie;
25151
25151
  }
@@ -25155,8 +25155,8 @@ var Tm = { exports: {} };
25155
25155
  }, te.utcOffset = function() {
25156
25156
  return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
25157
25157
  }, te.diff = function(z, le, Q) {
25158
- var Ee, Ie = this, ot = ae.p(le), At = X(z), Ot = (At.utcOffset() - this.utcOffset()) * t, Ut = this - At, Ti = function() {
25159
- return ae.m(Ie, At);
25158
+ var Ee, Ie = this, ot = oe.p(le), At = X(z), Ot = (At.utcOffset() - this.utcOffset()) * t, Ut = this - At, Ti = function() {
25159
+ return oe.m(Ie, At);
25160
25160
  };
25161
25161
  switch (ot) {
25162
25162
  case E:
@@ -25186,7 +25186,7 @@ var Tm = { exports: {} };
25186
25186
  default:
25187
25187
  Ee = Ut;
25188
25188
  }
25189
- return Q ? Ee : ae.a(Ee);
25189
+ return Q ? Ee : oe.a(Ee);
25190
25190
  }, te.daysInMonth = function() {
25191
25191
  return this.endOf(c).$D;
25192
25192
  }, te.$locale = function() {
@@ -25197,7 +25197,7 @@ var Tm = { exports: {} };
25197
25197
  var Q = this.clone(), Ee = me(z, le, !0);
25198
25198
  return Ee && (Q.$L = Ee), Q;
25199
25199
  }, te.clone = function() {
25200
- return ae.w(this.$d, this);
25200
+ return oe.w(this.$d, this);
25201
25201
  }, te.toDate = function() {
25202
25202
  return new Date(this.valueOf());
25203
25203
  }, te.toJSON = function() {
@@ -42491,7 +42491,7 @@ f(Pe, "MUTABLE_DOWNSTREAM_PROPERTIES", ["inputs", "outputs"]), f(Pe, "INMUTABLE_
42491
42491
  ]);
42492
42492
  let We = Pe;
42493
42493
  var f7 = /* @__PURE__ */ ((r) => (r.Parent = "parent", r))(f7 || {});
42494
- const oe = class oe extends at {
42494
+ const ae = class ae extends at {
42495
42495
  constructor(e, t) {
42496
42496
  super(e);
42497
42497
  f(this, "initialData");
@@ -42860,7 +42860,7 @@ You shouldn't have to manually update a 'parent' property. The equivalent result
42860
42860
  // And adds it to the 'knownVersions' map
42861
42861
  captureVersion() {
42862
42862
  var t;
42863
- const e = ((t = this.knownVersions) == null ? void 0 : t.get(this.version)) || new oe(this, this.project);
42863
+ const e = ((t = this.knownVersions) == null ? void 0 : t.get(this.version)) || new ae(this, this.project);
42864
42864
  return e.metaSync(this.toMeta(), null), this.knownVersions = this.knownVersions ? this.knownVersions.set(this.version, e) : /* @__PURE__ */ new Map([[this.version, e]]), e.inputs = this.inputs, e.outputs = this.outputs, e.error = this.error, e.successCalls = this.successCalls, e.errorCalls = this.errorCalls, e.declaration = this.declaration, e.outputsDeclarations = this.outputsDeclarations, e.body = this.body, e.calledByEntry = this.calledByEntry, e.calledBySuccess = this.calledBySuccess, e.calledByError = this.calledByError, e.process = this.process, e.parent = this.parent, this;
42865
42865
  }
42866
42866
  // Traverses upstream entities and captures their versions as well
@@ -42925,7 +42925,7 @@ You shouldn't have to manually update a 'parent' property. The equivalent result
42925
42925
  throw new Error(
42926
42926
  `Version with id '${e}' for entity with id '${this.id}' not found.`
42927
42927
  );
42928
- o = new oe(u, this.project);
42928
+ o = new ae(u, this.project);
42929
42929
  }
42930
42930
  return this.metaSync(o.toShallowJSON(), null), this.inputs = o.inputs, this.outputs = o.outputs, this.error = o.error, this.successCalls = o.successCalls, this.errorCalls = o.errorCalls, this.declaration = o.declaration, this.outputsDeclarations = o.outputsDeclarations, this.body = o.body, this.calledByEntry = o.calledByEntry, this.calledBySuccess = o.calledBySuccess, this.calledByError = o.calledByError, this.process = o.process, this.parent = o.parent, {
42931
42931
  updated: p(t),
@@ -43342,22 +43342,22 @@ You shouldn't have to manually update a 'parent' property. The equivalent result
43342
43342
  return this.x = e.x || s.x, this.y = e.y || s.y, super.metaSync(e), e.deleted === !0 && !s.deleted ? t == null || t.add(this, I.Removed) : e.deleted === !1 && s.deleted ? t == null || t.add(this, I.Added) : i && (t == null || t.add(this, I.Updated)), t == null || t.attemptAutoclose("meta-sync", this.id), this;
43343
43343
  }
43344
43344
  async APILoad(e = j, ...t) {
43345
- return await oe.repository.APILoad(this.id, ...t), this;
43345
+ return await ae.repository.APILoad(this.id, ...t), this;
43346
43346
  }
43347
43347
  async APICreate(e = j, ...t) {
43348
- return await oe.repository.APICreate(this.toShallowJSON(), ...t), this;
43348
+ return await ae.repository.APICreate(this.toShallowJSON(), ...t), this;
43349
43349
  }
43350
43350
  async APIUpdate(e = j, ...t) {
43351
- return await oe.repository.APIUpdate(this.toShallowJSON(), ...t), this;
43351
+ return await ae.repository.APIUpdate(this.toShallowJSON(), ...t), this;
43352
43352
  }
43353
43353
  async APIDelete(e = j, ...t) {
43354
- return await oe.repository.APIDelete(this.toShallowJSON(), ...t), this;
43354
+ return await ae.repository.APIDelete(this.toShallowJSON(), ...t), this;
43355
43355
  }
43356
43356
  async APIClone(e = j, ...t) {
43357
- return await oe.repository.APIClone(this.id, ...t), this;
43357
+ return await ae.repository.APIClone(this.id, ...t), this;
43358
43358
  }
43359
43359
  async APILoadVersion(e = j, t, ...i) {
43360
- return await oe.repository.APILoadVersion(
43360
+ return await ae.repository.APILoadVersion(
43361
43361
  this.id,
43362
43362
  t,
43363
43363
  ...i
@@ -43956,12 +43956,12 @@ You shouldn't have to manually update a 'parent' property. The equivalent result
43956
43956
  h.sort((O, V) => O.index - V.index), h.forEach((O) => {
43957
43957
  const V = O.getDataType(e);
43958
43958
  let x = c.find(
43959
- (ue) => F(ue, this.project) === oe.fromReturnDeclarationToBodyArgumentDeclarationName(
43959
+ (ue) => F(ue, this.project) === ae.fromReturnDeclarationToBodyArgumentDeclarationName(
43960
43960
  O
43961
43961
  ) && wi(ue.dataType, O.dataType)
43962
43962
  );
43963
43963
  if (!x) {
43964
- const ue = oe.fromReturnDeclarationToBodyArgumentDeclarationName(
43964
+ const ue = ae.fromReturnDeclarationToBodyArgumentDeclarationName(
43965
43965
  O
43966
43966
  ), me = {
43967
43967
  id: y.UUID.uuid(),
@@ -44091,17 +44091,17 @@ You shouldn't have to manually update a 'parent' property. The equivalent result
44091
44091
  )
44092
44092
  )) {
44093
44093
  const t = [], i = [], s = [], l = [], o = this.getUniqueReturnDeclarations(), d = this.outputsDeclarations;
44094
- return o.forEach((h, c) => {
44094
+ o.forEach((h, c) => {
44095
44095
  h.index !== c && (h.metaSync({ index: c }, e), t.push(h));
44096
44096
  }), o.forEach((h) => {
44097
44097
  const c = h.getDataType(e);
44098
44098
  let E = d.find(
44099
- (V) => F(V, this.project) === oe.fromReturnDeclarationToLoopOutputDeclarationName(
44099
+ (V) => F(V, this.project) === ae.fromReturnDeclarationToLoopOutputDeclarationName(
44100
44100
  h
44101
44101
  ) && wi(V.dataType, h.dataType)
44102
44102
  );
44103
44103
  if (!E) {
44104
- const V = oe.fromReturnDeclarationToLoopOutputDeclarationName(
44104
+ const V = ae.fromReturnDeclarationToLoopOutputDeclarationName(
44105
44105
  h
44106
44106
  ), M = {
44107
44107
  id: y.UUID.uuid(),
@@ -44190,18 +44190,30 @@ You shouldn't have to manually update a 'parent' property. The equivalent result
44190
44190
  );
44191
44191
  M.metaSync({ isList: !0 }, e), M.setParent(E, e), M.initChildren(e), e == null || e.add(M, I.Added), M.addSelfToProject(e), i.push(M);
44192
44192
  }
44193
- }), d.filter(
44194
- (h) => !o.find(
44195
- (T) => F(h, this.project) === oe.fromReturnDeclarationToLoopOutputDeclarationName(T)
44196
- )
44197
- ).forEach((h) => {
44198
- const { updated: c, removed: T } = h.remove(
44199
- {
44200
- ignoreUpstream: !1
44201
- },
44202
- e
44203
- );
44204
- t.push(...c), s.push(...T);
44193
+ }), console.log("uniqueReturnDeclarations: ", o);
44194
+ const u = d.filter(
44195
+ (h) => {
44196
+ const c = o.find(
44197
+ (T) => {
44198
+ const E = F(T, this.project), R = ae.fromReturnDeclarationToLoopOutputDeclarationName(
44199
+ T
44200
+ );
44201
+ return console.log("resolvedName", E), console.log("nameToMatch", R), F(h, this.project) === ae.fromReturnDeclarationToLoopOutputDeclarationName(T);
44202
+ }
44203
+ );
44204
+ return console.log("foundMatchingReturn", c), !c;
44205
+ }
44206
+ );
44207
+ return console.log("outputDeclarationsToRemove", u), u.forEach((h) => {
44208
+ if (!(e != null && e.hasRemoved(h.id)) && !h.deleted) {
44209
+ const { updated: c, removed: T } = h.remove(
44210
+ {
44211
+ ignoreUpstream: !1
44212
+ },
44213
+ e
44214
+ );
44215
+ t.push(...c), s.push(...T);
44216
+ }
44205
44217
  }), e == null || e.attemptAutoclose("sync-outputs-declarations", this.id), {
44206
44218
  updated: p(t),
44207
44219
  added: p(i),
@@ -44302,7 +44314,7 @@ You shouldn't have to manually update a 'parent' property. The equivalent result
44302
44314
  let d = this.body.inputs.find(
44303
44315
  (T) => {
44304
44316
  var E;
44305
- return T.name === oe.CURRENT_ITERATION_NUMBER_ARG_NAME || T.id === ((E = this.currentIterationNumberArgumentDeclaration) == null ? void 0 : E.id);
44317
+ return T.name === ae.CURRENT_ITERATION_NUMBER_ARG_NAME || T.id === ((E = this.currentIterationNumberArgumentDeclaration) == null ? void 0 : E.id);
44306
44318
  }
44307
44319
  );
44308
44320
  const u = this.getCurrentIterationNumberBuiltInValueDescriptor();
@@ -44315,7 +44327,7 @@ You shouldn't have to manually update a 'parent' property. The equivalent result
44315
44327
  previousVersion: null,
44316
44328
  deleted: !1,
44317
44329
  type: n.ArgumentDeclaration,
44318
- name: oe.CURRENT_ITERATION_NUMBER_ARG_NAME,
44330
+ name: ae.CURRENT_ITERATION_NUMBER_ARG_NAME,
44319
44331
  description: "The number of the current iteration",
44320
44332
  defaultValue: null,
44321
44333
  constant: !0,
@@ -44401,7 +44413,7 @@ You shouldn't have to manually update a 'parent' property. The equivalent result
44401
44413
  )) {
44402
44414
  const t = [], i = [], s = [], l = [], o = this.body.inputs, d = this.getUniqueReturnDeclarations();
44403
44415
  return o.filter((h) => h === this.currentIterationNumberArgumentDeclaration || h === this.currentValueArgumentDeclaration ? !1 : !d.find(
44404
- (T) => F(h, this.project) === oe.fromReturnDeclarationToBodyArgumentDeclarationName(T)
44416
+ (T) => F(h, this.project) === ae.fromReturnDeclarationToBodyArgumentDeclarationName(T)
44405
44417
  )).forEach((h) => {
44406
44418
  const { updated: c, removed: T } = h.remove(
44407
44419
  {
@@ -44463,7 +44475,10 @@ You shouldn't have to manually update a 'parent' property. The equivalent result
44463
44475
  const x = this.project.get(
44464
44476
  g[n.Loop][ee.List].inputs.list.id
44465
44477
  );
44466
- M && (!O.implements || O.implements.id !== M.id) && (O.setImplements(M, e), t.push(O));
44478
+ M && (!O.implements || O.implements.id !== M.id) && (O.setImplements(
44479
+ M,
44480
+ e
44481
+ ), t.push(O));
44467
44482
  let $ = O.getDataType(e);
44468
44483
  if (!$) {
44469
44484
  const q = {
@@ -44510,7 +44525,7 @@ You shouldn't have to manually update a 'parent' property. The equivalent result
44510
44525
  previousVersion: null,
44511
44526
  deleted: !1,
44512
44527
  type: n.ArgumentDeclaration,
44513
- name: oe.CURRENT_VALUE_ARG_NAME,
44528
+ name: ae.CURRENT_VALUE_ARG_NAME,
44514
44529
  description: null,
44515
44530
  defaultValue: null,
44516
44531
  index: this.body.inputs.length,
@@ -44606,7 +44621,7 @@ You shouldn't have to manually update a 'parent' property. The equivalent result
44606
44621
  previousVersion: null,
44607
44622
  deleted: !1,
44608
44623
  type: n.ArgumentDeclaration,
44609
- name: oe.CURRENT_VALUE_ARG_NAME,
44624
+ name: ae.CURRENT_VALUE_ARG_NAME,
44610
44625
  description: null,
44611
44626
  defaultValue: null,
44612
44627
  index: this.body.inputs.length,
@@ -44732,7 +44747,7 @@ You shouldn't have to manually update a 'parent' property. The equivalent result
44732
44747
  const S = V.getDataType(e);
44733
44748
  (((c = S == null ? void 0 : S.entity) == null ? void 0 : c.properties) || []).forEach((me) => {
44734
44749
  if (!me.getDataType(e)) {
44735
- const ae = {
44750
+ const oe = {
44736
44751
  id: y.UUID.uuid(),
44737
44752
  version: y.UUID.uuid(),
44738
44753
  createdAt: (e == null ? void 0 : e.timestamp) || v().toISOString(),
@@ -44755,7 +44770,7 @@ You shouldn't have to manually update a 'parent' property. The equivalent result
44755
44770
  parentRelationType: wt.OrDataTypeGroup,
44756
44771
  parent: q.toReference()
44757
44772
  }, Jt = P(
44758
- ae,
44773
+ oe,
44759
44774
  this.project
44760
44775
  );
44761
44776
  Jt.setParent(
@@ -44777,7 +44792,7 @@ You shouldn't have to manually update a 'parent' property. The equivalent result
44777
44792
  previousVersion: null,
44778
44793
  deleted: !1,
44779
44794
  type: n.ArgumentDeclaration,
44780
- name: oe.CURRENT_VALUE_ARG_NAME,
44795
+ name: ae.CURRENT_VALUE_ARG_NAME,
44781
44796
  description: null,
44782
44797
  constant: !0,
44783
44798
  defaultValue: null,
@@ -44868,7 +44883,7 @@ You shouldn't have to manually update a 'parent' property. The equivalent result
44868
44883
  previousVersion: null,
44869
44884
  deleted: !1,
44870
44885
  type: n.ArgumentDeclaration,
44871
- name: oe.CURRENT_VALUE_ARG_NAME,
44886
+ name: ae.CURRENT_VALUE_ARG_NAME,
44872
44887
  description: null,
44873
44888
  index: this.body.inputs.length,
44874
44889
  required: !0,
@@ -45305,9 +45320,9 @@ You shouldn't have to manually update a 'parent' property. The equivalent result
45305
45320
  const {
45306
45321
  updated: me,
45307
45322
  added: X,
45308
- removed: ae
45323
+ removed: oe
45309
45324
  } = this.syncOutputMaps(e);
45310
- return t.push(...me), i.push(...X), s.push(...ae), e == null || e.attemptAutoclose("sync-children", this.id), {
45325
+ return t.push(...me), i.push(...X), s.push(...oe), e == null || e.attemptAutoclose("sync-children", this.id), {
45311
45326
  self: this,
45312
45327
  updated: p(t),
45313
45328
  added: p(i),
@@ -45318,7 +45333,7 @@ You shouldn't have to manually update a 'parent' property. The equivalent result
45318
45333
  };
45319
45334
  }
45320
45335
  };
45321
- f(oe, "repository", {
45336
+ f(ae, "repository", {
45322
45337
  APICreate: async (e, ...t) => e,
45323
45338
  APIUpdate: async (e, ...t) => e,
45324
45339
  APIDelete: async (e, ...t) => e,
@@ -45326,40 +45341,40 @@ f(oe, "repository", {
45326
45341
  },
45327
45342
  APILoad: async (e, ...t) => null,
45328
45343
  APILoadVersion: async (e, t, ...i) => null
45329
- }), f(oe, "type", n.Loop), f(oe, "USER_MANAGED_PARENT_TYPES", [
45344
+ }), f(ae, "type", n.Loop), f(ae, "USER_MANAGED_PARENT_TYPES", [
45330
45345
  ...ft,
45331
45346
  n.Project
45332
- ]), f(oe, "PARENT_TYPES", [
45347
+ ]), f(ae, "PARENT_TYPES", [
45333
45348
  ...We.USER_MANAGED_PARENT_TYPES
45334
- ]), f(oe, "CURRENT_ITERATION_NUMBER_ARG_NAME", "Current iteration number"), f(oe, "CURRENT_VALUE_ARG_NAME", "Current value"), f(oe, "MUTABLE_BASE_PROPERTIES", []), f(oe, "INMUTABLE_BASE_PROPERTIES", [
45349
+ ]), f(ae, "CURRENT_ITERATION_NUMBER_ARG_NAME", "Current iteration number"), f(ae, "CURRENT_VALUE_ARG_NAME", "Current value"), f(ae, "MUTABLE_BASE_PROPERTIES", []), f(ae, "INMUTABLE_BASE_PROPERTIES", [
45335
45350
  "id",
45336
45351
  "type",
45337
45352
  "version",
45338
45353
  "createdAt",
45339
45354
  "author",
45340
45355
  "previousVersion"
45341
- ]), f(oe, "BASE_PROPERTIES", [
45342
- ...oe.MUTABLE_BASE_PROPERTIES,
45343
- ...oe.INMUTABLE_BASE_PROPERTIES
45356
+ ]), f(ae, "BASE_PROPERTIES", [
45357
+ ...ae.MUTABLE_BASE_PROPERTIES,
45358
+ ...ae.INMUTABLE_BASE_PROPERTIES
45344
45359
  ]), // Includes the base properties and the meta properties
45345
45360
  // Often contains properties related to UX, not necessary for the logic
45346
- f(oe, "MUTABLE_META_PROPERTIES", [
45347
- ...oe.MUTABLE_BASE_PROPERTIES,
45361
+ f(ae, "MUTABLE_META_PROPERTIES", [
45362
+ ...ae.MUTABLE_BASE_PROPERTIES,
45348
45363
  "x",
45349
45364
  "y"
45350
- ]), f(oe, "INMUTABLE_META_PROPERTIES", [...oe.INMUTABLE_BASE_PROPERTIES]), f(oe, "META_PROPERTIES", [
45351
- ...oe.MUTABLE_META_PROPERTIES,
45352
- ...oe.INMUTABLE_META_PROPERTIES
45365
+ ]), f(ae, "INMUTABLE_META_PROPERTIES", [...ae.INMUTABLE_BASE_PROPERTIES]), f(ae, "META_PROPERTIES", [
45366
+ ...ae.MUTABLE_META_PROPERTIES,
45367
+ ...ae.INMUTABLE_META_PROPERTIES
45353
45368
  ]), // Properties pointing to nested entities that are declared before the entity itself
45354
- f(oe, "MUTABLE_UPSTREAM_PROPERTIES", [
45369
+ f(ae, "MUTABLE_UPSTREAM_PROPERTIES", [
45355
45370
  "calledBySuccess",
45356
45371
  "calledByError",
45357
45372
  "calledByEntry"
45358
- ]), f(oe, "INMUTABLE_UPSTREAM_PROPERTIES", ["parent", "declaration"]), f(oe, "UPSTREAM_PROPERTIES", [
45359
- ...oe.MUTABLE_UPSTREAM_PROPERTIES,
45360
- ...oe.INMUTABLE_UPSTREAM_PROPERTIES
45373
+ ]), f(ae, "INMUTABLE_UPSTREAM_PROPERTIES", ["parent", "declaration"]), f(ae, "UPSTREAM_PROPERTIES", [
45374
+ ...ae.MUTABLE_UPSTREAM_PROPERTIES,
45375
+ ...ae.INMUTABLE_UPSTREAM_PROPERTIES
45361
45376
  ]), // Properties pointing to nested entities that are declared after the entity itself or are direct children
45362
- f(oe, "MUTABLE_DOWNSTREAM_PROPERTIES", [
45377
+ f(ae, "MUTABLE_DOWNSTREAM_PROPERTIES", [
45363
45378
  "body",
45364
45379
  "inputs",
45365
45380
  "outputs",
@@ -45369,15 +45384,15 @@ f(oe, "MUTABLE_DOWNSTREAM_PROPERTIES", [
45369
45384
  "error",
45370
45385
  "breakStatements",
45371
45386
  "continueStatements"
45372
- ]), f(oe, "INMUTABLE_DOWNSTREAM_PROPERTIES", []), f(oe, "DOWNSTREAM_PROPERTIES", [
45373
- ...oe.MUTABLE_DOWNSTREAM_PROPERTIES,
45374
- ...oe.INMUTABLE_DOWNSTREAM_PROPERTIES
45375
- ]), f(oe, "PROPERTIES", [
45376
- ...oe.META_PROPERTIES,
45377
- ...oe.UPSTREAM_PROPERTIES,
45378
- ...oe.DOWNSTREAM_PROPERTIES
45387
+ ]), f(ae, "INMUTABLE_DOWNSTREAM_PROPERTIES", []), f(ae, "DOWNSTREAM_PROPERTIES", [
45388
+ ...ae.MUTABLE_DOWNSTREAM_PROPERTIES,
45389
+ ...ae.INMUTABLE_DOWNSTREAM_PROPERTIES
45390
+ ]), f(ae, "PROPERTIES", [
45391
+ ...ae.META_PROPERTIES,
45392
+ ...ae.UPSTREAM_PROPERTIES,
45393
+ ...ae.DOWNSTREAM_PROPERTIES
45379
45394
  ]);
45380
- let Xr = oe;
45395
+ let Xr = ae;
45381
45396
  function rv(r) {
45382
45397
  const a = w6(), e = r.toJSON();
45383
45398
  a.safeParse(e).success, r.inputs.forEach((l) => l.validate());
@@ -49518,11 +49533,11 @@ You shouldn't have to manually update a 'parent' property. The equivalent result
49518
49533
  t.push(...S), i.push(...q), s.push(...ue), l.push(...me);
49519
49534
  const {
49520
49535
  updated: X,
49521
- added: ae,
49536
+ added: oe,
49522
49537
  removed: Jt,
49523
49538
  affected: Ui
49524
49539
  } = Z.generateUnusedOutputs(e);
49525
- t.push(...ae), i.push(...X), s.push(...Jt), l.push(...Ui);
49540
+ t.push(...oe), i.push(...X), s.push(...Jt), l.push(...Ui);
49526
49541
  }), e == null || e.attemptAutoclose(
49527
49542
  "infer-data-type-and-sync-instances-inputs-and-outputs",
49528
49543
  this.id
@@ -64175,7 +64190,7 @@ function Dv(r, a, e, t, i) {
64175
64190
  const Z = [];
64176
64191
  let q = !1;
64177
64192
  C.forEach((ue) => {
64178
- var me, X, ae, Jt;
64193
+ var me, X, oe, Jt;
64179
64194
  if (Array.isArray(ue) && (q = !0), typeof ue == "object" && !Array.isArray(ue) && ue !== null) {
64180
64195
  const Ui = Il(
64181
64196
  ue,
@@ -64187,7 +64202,7 @@ function Dv(r, a, e, t, i) {
64187
64202
  t,
64188
64203
  i
64189
64204
  );
64190
- Ui.hasCreated && Z.push((me = Ui.changeSet) == null ? void 0 : me.self), s.push(...(X = Ui.changeSet) == null ? void 0 : X.updated), l.push(...(ae = Ui.changeSet) == null ? void 0 : ae.added), o.push(...(Jt = Ui.changeSet) == null ? void 0 : Jt.removed);
64205
+ Ui.hasCreated && Z.push((me = Ui.changeSet) == null ? void 0 : me.self), s.push(...(X = Ui.changeSet) == null ? void 0 : X.updated), l.push(...(oe = Ui.changeSet) == null ? void 0 : oe.added), o.push(...(Jt = Ui.changeSet) == null ? void 0 : Jt.removed);
64191
64206
  }
64192
64207
  });
64193
64208
  const S = p(
@@ -64303,7 +64318,7 @@ function Dv(r, a, e, t, i) {
64303
64318
  X,
64304
64319
  I.Added
64305
64320
  ), X.addSelfToProject(t);
64306
- const ae = Dv(
64321
+ const oe = Dv(
64307
64322
  ue,
64308
64323
  X,
64309
64324
  {
@@ -64313,7 +64328,7 @@ function Dv(r, a, e, t, i) {
64313
64328
  t,
64314
64329
  i
64315
64330
  );
64316
- s.push(...ae.updated), l.push(...ae.added), o.push(...ae.removed);
64331
+ s.push(...oe.updated), l.push(...oe.added), o.push(...oe.removed);
64317
64332
  }
64318
64333
  });
64319
64334
  }
@@ -69243,20 +69258,20 @@ Alternatively you can update the parent data-type entity with 'update' action to
69243
69258
  !0
69244
69259
  );
69245
69260
  if (X) {
69246
- const ae = (C = T.dataType) == null ? void 0 : C.merge(X, t);
69247
- T.dataType && (ae == null ? void 0 : ae.self.id) !== T.dataType.id && T.dataType.remove(
69261
+ const oe = (C = T.dataType) == null ? void 0 : C.merge(X, t);
69262
+ T.dataType && (oe == null ? void 0 : oe.self.id) !== T.dataType.id && T.dataType.remove(
69248
69263
  { ignoreUpstream: !1 },
69249
69264
  t
69250
- ), X.id !== (($ = ae == null ? void 0 : ae.self) == null ? void 0 : $.id) && X.remove({ ignoreUpstream: !1 }, t), ae != null && ae.self && (ae.self.metaSync(
69265
+ ), X.id !== (($ = oe == null ? void 0 : oe.self) == null ? void 0 : $.id) && X.remove({ ignoreUpstream: !1 }, t), oe != null && oe.self && (oe.self.metaSync(
69251
69266
  {
69252
69267
  inferred: !0,
69253
69268
  like: !0
69254
69269
  },
69255
69270
  t
69256
69271
  ), t == null || t.add(
69257
- ae.self,
69272
+ oe.self,
69258
69273
  I.Added
69259
- ), T.setDataType(ae.self), t == null || t.add(
69274
+ ), T.setDataType(oe.self), t == null || t.add(
69260
69275
  T,
69261
69276
  I.Updated
69262
69277
  ));
@@ -96,7 +96,7 @@ ${Wl(t)}`,issue:null})):s.push(new w({id:`${e.id}--${R.ReferencedEntityNotFound}
96
96
  ${Wl(t)}`,issue:null})):s.push(new w({id:`${e.id}--${$.InvalidObjectStructure}`,code:$.InvalidObjectStructure,severity:O.Error,message:`Entity of type '${e.type}' with id '${e.id}' is missing the 'declaration' property. This property is required for a '${e.type}' entity and must point to one of the built-in action descriptors reserved for '${n.Condition}' entities.
97
97
  ${Wl(t)}`,issue:null})),{errors:s,modifiedData:i}}static fromReturnDeclarationToBodyArgumentDeclarationName(e){return`Previous iteration results of '${x(e,e.project)}'`}static fromBodyArgumentDeclarationToReturnDeclarationName(e){const t=e.name.replace("Previous iteration results of '","");return t.slice(0,t.length-1)}static fromReturnDeclarationToLoopOutputDeclarationName(e){return`Result list of '${x(e,e.project)}'`}static fromLoopOutputDeclarationToReturnDeclarationName(e){const t=e.name.replace("Result list of '","");return t.slice(0,t.length-1)}static fromLoopOutputDeclarationToBodyArgumentDeclarationName(e){return e.name.replace("Result list of '","Previous iteration results of '")}static fromBodyArgumentDeclarationToLoopOutputDeclarationName(e){return e.name.replace("Previous iteration results of '","Result list of '")}get continueStatements(){const e=[];return Object.values(this.detachedDependents).forEach(t=>{t.field===_c.Parent&&t.entity.type===n.ContinueStatement&&!e.includes(t.entity)&&e.push(t.entity)}),e}get breakStatements(){const e=[];return Object.values(this.detachedDependents).forEach(t=>{t.field===Nc.Parent&&t.entity.type===n.BreakStatement&&!e.includes(t.entity)&&e.push(t.entity)}),e}validateGeneratedUpdate(e){const t=[];return e.parent&&t.push(new w({id:`${this.id}--${R.InvalidParentUpdate}`,code:R.InvalidParentUpdate,severity:O.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
98
98
  If an entity is called by another, they must be in the same scope, which means they have the same parent.
99
- You shouldn't have to manually update a 'parent' property. The equivalent result is to change its callers, the value writters of its inputs, or the value readers of its outputs.`,issue:null})),{errors:t,modifiedData:e}}subscribeDependents(e){return e.forEach(t=>{this.detachedDependents[t.entity.id]||(this.detachedDependents[t.entity.id]=t)}),this}unsubscribeDependents(e){return e.forEach(t=>{this.detachedDependents[t.entity.id]&&delete this.detachedDependents[t.entity.id]}),this}syncDependents(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"sync-dependents"))){const t=[],i=[],s=[],l=[];return Object.values(this.detachedDependents).forEach(o=>{const d=o.entity.afterAllChildrenInitialized(e);t.push(...d.updated),i.push(...d.added),s.push(...d.removed),l.push(...d.affected)}),e==null||e.attemptAutoclose("sync-dependents",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}onDetachedDependencyRemoved(e,t,i){const s=[],l=[],o=[],d=[];if(t==="parent"){const{updated:u,added:h,removed:c}=this.remove({ignoreUpstream:!1},i);s.push(...u),l.push(...h),o.push(...c)}return{updated:p(s),added:p(l),removed:p(o),affected:p(d),self:this}}onDetachedDependencyRestored(e,t,i){const s=[],l=[],o=[],d=[];if(t==="parent"){const{updated:u,added:h,removed:c}=this.restore({},i);s.push(...u),l.push(...h),o.push(...c)}return{updated:p(s),added:p(l),removed:p(o),affected:p(d),self:this}}unsubscribeFromDependencies(){var e;return(e=this.parent)==null||e.unsubscribeDependents([{entity:this,field:"parent"}]),this}subscribeToDependencies(){var e;return(e=this.parent)==null||e.subscribeDependents([{entity:this,field:"parent"}]),this}increaseVersion(e){if(e&&!T(e).isValid())throw new Error(`The shared timestamp '${e}' is not a valid ISO 8601 date string.`);return e&&T(e).isSame(T(this.createdAt))?this:(this.previousVersion=this.version,this.version=m.UUID.uuid(),this.createdAt=T(e).toISOString()||T().toISOString(),this)}captureVersion(){var t;const e=((t=this.knownVersions)==null?void 0:t.get(this.version))||new oe(this,this.project);return e.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,e):new Map([[this.version,e]]),e.inputs=this.inputs,e.outputs=this.outputs,e.error=this.error,e.successCalls=this.successCalls,e.errorCalls=this.errorCalls,e.declaration=this.declaration,e.outputsDeclarations=this.outputsDeclarations,e.body=this.body,e.calledByEntry=this.calledByEntry,e.calledBySuccess=this.calledBySuccess,e.calledByError=this.calledByError,e.process=this.process,e.parent=this.parent,this}recursiveCaptureUpstreamVersions(e){const t=[],i=[],s=[],l=[];if(this.parent){this.parent.increaseVersion(e);const o=this.parent.recursiveCaptureUpstreamVersions(e);t.push(this.parent,...o.updated),i.push(...o.added),s.push(...o.removed)}return{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}async restoreVersion(e){var d;const t=[],i=[],s=[],l=[];if(this.version===e)return{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this};if(!this.knownVersions){const u=new Map;for(const[h,c]of this.knownVersions||new Map){if(u.set(h,c),c.activeVersion=!1,c.knownVersions)for(const[E,I]of c.knownVersions)u.set(E,I);c.knownVersions=null}}let o=(d=this.knownVersions)==null?void 0:d.get(e);if(!o){const u=await this.APILoadVersion({},e);if(!u)throw new Error(`Version with id '${e}' for entity with id '${this.id}' not found.`);o=new oe(u,this.project)}return this.metaSync(o.toShallowJSON(),null),this.inputs=o.inputs,this.outputs=o.outputs,this.error=o.error,this.successCalls=o.successCalls,this.errorCalls=o.errorCalls,this.declaration=o.declaration,this.outputsDeclarations=o.outputsDeclarations,this.body=o.body,this.calledByEntry=o.calledByEntry,this.calledBySuccess=o.calledBySuccess,this.calledByError=o.calledByError,this.process=o.process,this.parent=o.parent,{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}hydrateAncestors(){const e=[],t=[],i=[],s=[];if(this.initialData.parent){const l=_(this.initialData.parent),o=this.project.get(l);if(o)this.setParent(o,null),e.push(o);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${l}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(this.initialData.declaration){const l=_(this.initialData.declaration),o=this.project.get(l);o&&(this.setDeclaration(o),e.push(o))}return this.initialData.calledByEntry.forEach(l=>{const o=_(l),d=this.project.get(o);d&&(this.addEntryCaller(d,null),d.addCall(this,null),e.push(d))}),this.initialData.calledBySuccess.forEach(l=>{const o=_(l),d=this.project.get(o);d&&(this.addSuccessCaller(d,null),d.addSuccessCall(this,null),e.push(d))}),this.initialData.calledByError.forEach(l=>{const o=_(l),d=this.project.get(o);d&&(this.addErrorCaller(d,null),d.addErrorCall(this,null),e.push(d))}),{updated:p(e),added:p(t),removed:p(i),affected:p(s),self:this}}afterAllChildrenInitialized(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"after-all-children-initialized"))){const t=[],i=[],s=[],l=[];this.initialized=!0;const{updated:o,added:d,removed:u}=this.syncChildren(e);return t.push(...o),i.push(...d),s.push(...u),this.captureVersion(),e==null||e.attemptAutoclose("after-all-children-initialized",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}addSelfToProject(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"add-self-to-project"))){const t=[this],i=[],s=[],l=[];return this.parent===this.project&&this.project.addLoop(this),this.successCalls.forEach(o=>{o.addSuccessCaller(this,e),t.push(o)}),this.errorCalls.forEach(o=>{o.addErrorCaller(this,e),t.push(o)}),this.calledByEntry.forEach(o=>{o.addCall(this,e),t.push(o)}),this.calledBySuccess.forEach(o=>{o.addSuccessCall(this,e),t.push(o)}),this.calledByError.forEach(o=>{o.addErrorCall(this,e),t.push(o)}),this.subscribe(),this.subscribeToDependencies(),e==null||e.attemptAutoclose("add-self-to-project",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}removeInput(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"remove-input"))){const i=this.inputs.findIndex(s=>s.id===e.id);return i>-1&&(this.inputs.splice(i,1),t&&(t==null||t.add(this,A.Affected))),t==null||t.attemptAutoclose("remove-input",this.id),this}addInput(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"add-input"))){return this.inputs.includes(e)?(t==null||t.attemptAutoclose("add-input",this.id),this):(this.inputs.push(e),t==null||t.add(this,A.Affected),t==null||t.attemptAutoclose("add-input",this.id),this)}addOutputDeclaration(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"add-output-declaration"))){return this.outputsDeclarations.includes(e)?(t==null||t.attemptAutoclose("add-output-declaration",this.id),this):(this.outputsDeclarations.push(e),t==null||t.add(this,A.Affected),t==null||t.attemptAutoclose("add-output-declaration",this.id),this)}removeOutputDeclaration(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"remove-output-declaration"))){const i=this.outputsDeclarations.findIndex(s=>s.id===e.id);return i>-1&&(this.outputsDeclarations.splice(i,1),t==null||t.add(this,A.Affected)),t==null||t.attemptAutoclose("remove-output-declaration",this.id),this}addOutput(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"add-output"))){return this.outputs.includes(e)?(t==null||t.attemptAutoclose("add-output",this.id),this):(this.outputs.push(e),t==null||t.add(this,A.Affected),t==null||t.attemptAutoclose("add-output",this.id),this)}removeOutput(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"remove-output"))){const i=this.outputs.findIndex(s=>s.id===e.id);return i>-1&&(this.outputs.splice(i,1),t&&(t==null||t.add(this,A.Affected))),t==null||t.attemptAutoclose("remove-output",this.id),this}setBody(e){return this.body=e,this}addSuccessCaller(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"add-success-caller")),i=!1){return this.calledBySuccess.find(s=>s.id===e.id)||(this.calledBySuccess.push(e),t==null||t.add(this,A.Updated),i&&K(this,t)),t==null||t.attemptAutoclose("add-success-caller",this.id),this}addErrorCaller(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"add-error-caller")),i=!1){return this.calledByError.find(s=>s.id===e.id)||(this.calledByError.push(e),t==null||t.add(this,A.Updated),i&&K(this,t)),t==null||t.attemptAutoclose("add-error-caller",this.id),this}addEntryCaller(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"add-entry-caller")),i=!1){return this.calledByEntry.find(s=>s.id===e.id)||(this.calledByEntry.push(e),t==null||t.add(this,A.Updated),i&&K(this,t)),t==null||t.attemptAutoclose("add-entry-caller",this.id),this}addErrorCall(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"add-error-call")),i=!1){return this.errorCalls.find(s=>s.id===e.id)||(this.errorCalls.push(e),i&&K(this,t),t==null||t.add(this,A.Affected)),t==null||t.attemptAutoclose("add-error-call",this.id),this}addSuccessCall(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"add-success-call")),i=!1){return this.successCalls.find(s=>s.id===e.id)||(this.successCalls.push(e),i&&K(this,t),t==null||t.add(this,A.Affected)),t==null||t.attemptAutoclose("add-success-call",this.id),this}removeCall(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"remove-call")),i=!1){const s=this.successCalls.findIndex(o=>o.id===e.id);s>-1&&(this.successCalls.splice(s,1),t==null||t.add(this,A.Affected));const l=this.errorCalls.findIndex(o=>o.id===e.id);return l>-1&&(this.errorCalls.splice(l,1),t==null||t.add(this,A.Affected)),i&&K(this,t),t==null||t.attemptAutoclose("remove-call",this.id),this}removeCaller(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"remove-caller")),i=!1){return this.calledBySuccess=this.calledBySuccess.filter(s=>s.id!==e.id?!0:(t==null||t.add(this,A.Updated),t==null||t.add(s,A.Affected),!1)),this.calledByError=this.calledByError.filter(s=>s.id!==e.id?!0:(t==null||t.add(this,A.Updated),t==null||t.add(s,A.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(s=>s.id!==e.id?!0:(t==null||t.add(this,A.Updated),t==null||t.add(s,A.Affected),!1)),i&&K(this,t),t==null||t.attemptAutoclose("remove-caller",this.id),this}replaceDetachedChild(e,t){const i=this.detachedChildren.indexOf(e);return i!==-1&&(this.detachedChildren[i]=t),this}subscribeDetachedChild(e){return this.detachedChildren.includes(e)||this.detachedChildren.push(e),this}setParent(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"set-parent"))){var i;return((i=this.parent)==null?void 0:i.id)!==(e==null?void 0:e.id)&&(this.parent=e,t&&(t==null||t.add(this,A.Updated),t==null||t.attemptAutoclose("set-parent",this.id))),this}setDeclaration(e){return this.declaration=e,this}initChildren(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.declaration=C(this.initialData.declaration,this.project),this.successCalls=this.initialData.successCalls.map(t=>{const i=C(t,this.project);if(i.addSuccessCaller(this),[n.BreakStatement,n.ContinueStatement].includes(i.type))i.setParent(this.parent.parent,null),i.initChildren(e);else if(i.type===n.ReturnStatement){const s=It(this,this.project);i.setParent(s,null),i.initChildren(e)}else i.type!==n.InternalCall&&(i.setParent(this.parent,null),i.initChildren(e));return i}),this.errorCalls=this.initialData.errorCalls.map(t=>{const i=C(t,this.project);if(i.addErrorCaller(this),[n.BreakStatement,n.ContinueStatement].includes(i.type))i.setParent(this.parent.parent,null),i.initChildren(e);else if(i.type===n.ReturnStatement){const s=It(this,this.project);i.setParent(s,null),i.initChildren(e)}else i.type!==n.InternalCall&&(i.setParent(this.parent,null),i.initChildren(e));return i}),this.inputs=this.initialData.inputs.map(t=>{const i=C(t,this.project);return i.setParent(this,null),i.initChildren(e),i}),this.outputs=this.initialData.outputs.map(t=>{const i=C(t,this.project);return i.setParent(this,null),i.initChildren(e),i}),this.initialData.process&&(this.process=C(this.initialData.process,this.project),this.process.setParent(this,null),this.process.initChildren(e)),this.initialData.body&&(this.body=C(this.initialData.body,this.project),this.body.setParent(this,null),this.body.initChildren(e)),this.initialData.error&&(this.error=C(this.initialData.error,this.project),this.error.setParent(this,null),this.error.initChildren(e)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(e),e==null||e.attemptAutoclose("init-children",this.id),this)}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"meta-sync"))){const i=pt(this,e),s=this.toMeta();return this.x=e.x||s.x,this.y=e.y||s.y,super.metaSync(e),e.deleted===!0&&!s.deleted?t==null||t.add(this,A.Removed):e.deleted===!1&&s.deleted?t==null||t.add(this,A.Added):i&&(t==null||t.add(this,A.Updated)),t==null||t.attemptAutoclose("meta-sync",this.id),this}async APILoad(e=U,...t){return await oe.repository.APILoad(this.id,...t),this}async APICreate(e=U,...t){return await oe.repository.APICreate(this.toShallowJSON(),...t),this}async APIUpdate(e=U,...t){return await oe.repository.APIUpdate(this.toShallowJSON(),...t),this}async APIDelete(e=U,...t){return await oe.repository.APIDelete(this.toShallowJSON(),...t),this}async APIClone(e=U,...t){return await oe.repository.APIClone(this.id,...t),this}async APILoadVersion(e=U,t,...i){return await oe.repository.APILoadVersion(this.id,t,...i)}remove({ignoreUpstream:e}={ignoreUpstream:!1},t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"remove-entity"))){const i=[],s=[],l=[],o=[];if(t!=null&&t.hasRemoved(this.id))return t==null||t.attemptAutoclose("remove-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(s.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},t),Object.values(this.detachedDependents).forEach(d=>{const{updated:u,removed:h,added:c}=d.entity.onDetachedDependencyRemoved(this,d.field,t);i.push(...u),s.push(...h),l.push(...c)}),this.inputs.forEach(d=>{const{updated:u,removed:h}=d.remove({ignoreUpstream:!0},t);i.push(...u),s.push(...h)}),this.outputs.forEach(d=>{const{updated:u,removed:h}=d.remove({ignoreUpstream:!0},t);i.push(...u),s.push(...h)}),this.body.remove({ignoreUpstream:!0},t),this.error){const{updated:d,removed:u}=this.error.remove({ignoreUpstream:!0},t);i.push(...d),s.push(...u)}return this.successCalls.forEach(d=>{i.push(d),d.removeCaller(this,t)}),this.errorCalls.forEach(d=>{i.push(d),d.removeCaller(this,t)}),e||this.calledBy.forEach(d=>{i.push(d),d.removeCall(this,t)}),t==null||t.attemptAutoclose("remove-entity",this.id),{added:p(l),updated:p(i),removed:p(s),affected:p(o),self:this}}restore({}={},e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"restore-entity"))){const t=[],i=[],s=[],l=[];return e!=null&&e.hasAdded(this.id)?(e==null||e.attemptAutoclose("restore-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this}):(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},e),this.inputs.forEach(o=>{const{updated:d}=o.restore({},e);i.push(...d)}),this.outputs.forEach(o=>{const{updated:d}=o.restore({},e);i.push(...d)}),this.body.restore({},e),this.successCalls.forEach(o=>{i.push(o),o.addSuccessCaller(this,e)}),this.errorCalls.forEach(o=>{i.push(o),o.addErrorCaller(this,e)}),this.calledBySuccess.forEach(o=>{i.push(o),o.addSuccessCall(this,e)}),this.calledByError.forEach(o=>{i.push(o),o.addErrorCall(this,e)}),this.calledByEntry.forEach(o=>{i.push(o),o.addCall(this,e)}),e==null||e.attemptAutoclose("restore-entity",this.id),{added:p(t),updated:p(i),removed:p(s),affected:p(l),self:this})}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.inputs.flatMap(i=>i.toFlat(e)),...this.outputs.flatMap(i=>i.toFlat(e)),...this.outputsDeclarations.flatMap(i=>i.toFlat(e)),...this.process?this.process.toFlat(e):[],...this.successCalls.flatMap(i=>i.toFlat(e)),...this.errorCalls.flatMap(i=>i.toFlat(e)),...this.error?this.error.toFlat(e):[],...this.body?this.body.toFlat(e):[],...this.continueStatements.flatMap(i=>i.toFlat(e)),...this.breakStatements.flatMap(i=>i.toFlat(e))])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.inputs.flatMap(i=>i.toFlatIds(e)),...this.outputs.flatMap(i=>i.toFlatIds(e)),...this.process?this.process.toFlatIds(e):[],...this.successCalls.flatMap(i=>i.toFlatIds(e)),...this.errorCalls.flatMap(i=>i.toFlatIds(e)),...this.error?this.error.toFlatIds(e):[],...this.body?this.body.toFlatIds(e):[],...this.continueStatements.flatMap(i=>i.toFlatIds(e)),...this.breakStatements.flatMap(i=>i.toFlatIds(e))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,x:this.x,y:this.y,type:this.type}}toJSON(e=new Set){var t,i;return e.has(this.id)?this.toReference():(e.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,x:this.x,y:this.y,calledBySuccess:this.calledBySuccess.map(s=>s.toReference()),calledByError:this.calledByError.map(s=>s.toReference()),calledByEntry:this.calledByEntry.map(s=>s.toReference()),process:((t=this.process)==null?void 0:t.toJSON(e))||null,declaration:this.declaration.toJSON(e),inputs:this.inputs.map(s=>s.toJSON(e)),outputs:this.outputs.map(s=>s.toJSON(e)),outputsDeclarations:this.outputsDeclarations.map(s=>s.toJSON(e)),successCalls:this.successCalls.map(s=>s.toJSON(e)),errorCalls:this.errorCalls.map(s=>s.toJSON(e)),error:((i=this.error)==null?void 0:i.toJSON(e))||null,body:this.body.toJSON(e),parent:this.parent.toReference()})}toJSONClone(e=J){var i,s,l,o,d,u,h;let t;return(i=e.seenEntityMaps)!=null&&i.has(this.id)?t=e.seenEntityMaps.get(this.id):(t=e.newId||yt(this,this.project,e.uuidStrategy),e.seenEntityMaps&&e.seenEntityMaps.set(this.id,t)),(s=e.seenEntities)!=null&&s.has(t)||(l=e.seenEntities)!=null&&l.has(this.id)?this.toReference({seenEntityMaps:e.seenEntityMaps}):((o=e.seenEntities)==null||o.add(t),(d=e.seenEntities)==null||d.add(this.id),{id:t,version:m.UUID.uuid(),createdAt:e.timestamp||T().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,x:this.x,y:this.y,calledBySuccess:this.calledBySuccess.map(c=>c.toReference({seenEntityMaps:e.seenEntityMaps})),calledByError:this.calledByError.map(c=>c.toReference({seenEntityMaps:e.seenEntityMaps})),calledByEntry:this.calledByEntry.map(c=>c.toReference({seenEntityMaps:e.seenEntityMaps})),process:((u=this.process)==null?void 0:u.toJSONClone({...e,newId:null}))||null,declaration:this.declaration.toJSON(),inputs:this.inputs.map(c=>c.toJSONClone({...e,newId:null})),outputs:this.outputs.map(c=>c.toJSONClone({...e,newId:null})),outputsDeclarations:this.outputsDeclarations.map(c=>c.toJSONClone({...e,newId:null})),successCalls:this.successCalls.map(c=>c.toJSONClone({...e,newId:null})),errorCalls:this.errorCalls.map(c=>c.toJSONClone({...e,newId:null})),error:((h=this.error)==null?void 0:h.toJSONClone({...e,newId:null}))||null,body:this.body.toJSONClone({...e,newId:null}),parent:this.parent.toReference({seenEntityMaps:e.seenEntityMaps})})}toReference(e=J){var i;let t=this.id;return(i=e.seenEntityMaps)!=null&&i.has(this.id)&&(t=e.seenEntityMaps.get(this.id)),{id:t+"--"+m.UUID.uuid()+"--ref",type:n.GenericReference,entityId:t,version:this.version,entityType:this.type}}toShallowJSON(e=J){var i,s,l,o,d;let t=this.id;return(i=e.seenEntityMaps)!=null&&i.has(this.id)&&(t=e.seenEntityMaps.get(this.id)),{id:t,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,x:this.x,y:this.y,declaration:((s=this.declaration)==null?void 0:s.toReference(e))||null,body:((l=this.body)==null?void 0:l.toReference(e))||null,inputs:this.inputs.map(u=>u.toReference(e)),outputs:this.outputs.map(u=>u.toReference(e)),outputsDeclarations:this.outputsDeclarations.map(u=>u.toReference(e)),successCalls:this.successCalls.map(u=>u.toReference(e)),errorCalls:this.errorCalls.map(u=>u.toReference(e)),process:((o=this.process)==null?void 0:o.toReference(e))||null,calledBySuccess:this.calledBySuccess.map(u=>u.toReference(e)),calledByError:this.calledByError.map(u=>u.toReference(e)),calledByEntry:this.calledByEntry.map(u=>u.toReference(e)),error:((d=this.error)==null?void 0:d.toReference(e))||null,parent:this.parent.toReference(e)}}toFlatJSON(e=new Set){var i;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((i=this.body)==null?void 0:i.toFlatJSON(e))||[],...this.successCalls.flatMap(s=>s.toFlatJSON(e)),...this.errorCalls.flatMap(s=>s.toFlatJSON(e)),...this.inputs.flatMap(s=>s.toFlatJSON(e)),...this.outputs.flatMap(s=>s.toFlatJSON(e)),...this.continueStatements.flatMap(s=>s.toFlatJSON(e)),...this.breakStatements.flatMap(s=>s.toFlatJSON(e)),...this.error?this.error.toFlatJSON(e):[],...this.process?this.process.toFlatJSON(e):[]])}toGenerationTarget(){const e=this.parent.type===n.Project?void 0:this.parent.id;return{id:this.id,type:this.type,calledByEntry:this.calledByEntry.map(t=>t.id),calledBySuccess:this.calledBySuccess.map(t=>t.id),calledByError:this.calledByError.map(t=>t.id),declaration:this.declaration.id,parent:e}}toFlatGenerationTarget(e=new Set){var i;return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...((i=this.body)==null?void 0:i.toFlatGenerationTarget(e))||[],...this.successCalls.flatMap(s=>s.toFlatGenerationTarget(e)),...this.errorCalls.flatMap(s=>s.toFlatGenerationTarget(e)),...this.inputs.flatMap(s=>s.toFlatGenerationTarget(e)),...this.outputs.flatMap(s=>s.toFlatGenerationTarget(e)),...this.continueStatements.flatMap(s=>s.toFlatGenerationTarget(e)),...this.breakStatements.flatMap(s=>s.toFlatGenerationTarget(e)),...this.error?this.error.toFlatGenerationTarget(e):[],...this.process?this.process.toFlatGenerationTarget(e):[]])}clearErrors(){var e,t;return this.errors=[],this.inputs.forEach(i=>i.clearErrors()),this.outputs.forEach(i=>i.clearErrors()),this.successCalls.forEach(i=>i.clearErrors()),this.errorCalls.forEach(i=>i.clearErrors()),this.continueStatements.forEach(i=>i.clearErrors()),this.breakStatements.forEach(i=>i.clearErrors()),(e=this.process)==null||e.clearErrors(),(t=this.error)==null||t.clearErrors(),this}validate(){const e=Lc(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.inputs.flatMap(t=>t.getErrors()),...this.outputs.flatMap(t=>t.getErrors()),...this.body?this.body.getErrors():[],...this.error?this.error.getErrors():[],...this.process?this.process.getErrors():[]]}getShallowErrors(){return this.errors}clone(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"clone-entity")),t=null,i=null,s=!0){var D,P;let l=mt(t,this);const o=this.toJSON(),d=i||m.UUID.uuid();o.inputs=[];const u=d.split("-id"),h=u[u.length-1||0]||d;o.id=d,o.version=m.UUID.uuid(),o.createdAt=(e==null?void 0:e.timestamp)||T().toISOString(),o.author=(e==null?void 0:e.author)||"1",o.previousVersion=null,o.deleted=!1;const c=st(o,l);t?c.setParent(t,null):c.setParent(this.parent,null),s&&c.subscribe(),c.initChildren(e),e==null||e.add(c,A.Added);const E=(D=this.inputs)==null?void 0:D.map((V,M)=>V.clone(e,c,h+"-input-map-"+M+"-id",s));c.inputs=E;const I=(P=this.outputs)==null?void 0:P.map((V,M)=>V.clone(e,c,h+"-output-map-"+M+"-id",s));return c.outputs=I,this.body&&(c.body=this.body.clone(e,c,h+"-body-id",s,!0)),this.error&&(c.error=this.error.clone(e,c,h+"-error-map-id",s)),this.process&&(c.process=this.process.clone(e,c,h+"-process-id",s)),e==null||e.attemptAutoclose("clone-entity",this.id),c}getVariableInstances(){return this.body?He(this.body).filter(i=>i.type===n.VariableInstance):[]}addReturnStatement(e){return rt.includes(this.parent.type)&&this.parent.addReturnStatement(e),this}removeReturnStatement(e){return rt.includes(this.parent.type)&&this.parent.removeReturnStatement(e),this}addBreakStatement(e){return this.breakStatements.includes(e)||this.breakStatements.push(e),this}removeBreakStatement(e){const t=this.breakStatements.indexOf(e);return t!==-1&&this.breakStatements.splice(t,1),this}addContinueStatement(e){return this.continueStatements.includes(e)||this.continueStatements.push(e),this}removeContinueStatement(e){const t=this.continueStatements.indexOf(e);return t!==-1&&this.continueStatements.splice(t,1),this}getUniqueReturnDeclarations(){const e=[];return[...this.breakStatements,...this.continueStatements].forEach(i=>{i.outputs.forEach(l=>{e.find(d=>d===l||x(d,this.project)===x(l,this.project)&&wi(d.dataType,l.dataType))||e.push(l)})}),p(e)}syncTerminationStatements(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"sync-termination-statements"))){const t=[],i=[],s=[],l=[],o=this.getUniqueReturnDeclarations();return[...this.breakStatements,...this.continueStatements].forEach(u=>{const h=u.outputs,c=o.filter(E=>!h.find(I=>x(E,this.project)===x(I,this.project)&&wi(E.dataType,I.dataType)));c.length&&(t.push(u),e==null||e.add(u,A.Updated)),c.forEach(E=>{const I=E.clone(e,u);e==null||e.add(I,A.Added),I.addSelfToProject(e),i.push(I)})}),e==null||e.attemptAutoclose("sync-termination-statements",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}syncBodyInputIndexes(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"sync-body-input-indexes"))){const t=[],i=[],s=[],l=[];return this.body.inputs.sort((d,u)=>d.index-u.index),this.body.inputs.forEach((d,u)=>{d.index!==u&&(d.metaSync({index:u},e),t.push(d))}),e==null||e.attemptAutoclose("sync-body-input-indexes",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}syncBodyArgumentsDeclarations(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"sync-body-arguments-declarations"))){const t=[],i=[],s=[],l=[],{updated:o,added:d,removed:u}=this.syncFixedBodyArgumentDeclarations(e);t.push(...o),i.push(...d),s.push(...u);const h=this.getUniqueReturnDeclarations(),c=this.body.inputs;h.sort((P,V)=>P.index-V.index),h.forEach(P=>{const V=P.getDataType(e);let g=c.find(pe=>x(pe,this.project)===oe.fromReturnDeclarationToBodyArgumentDeclarationName(P)&&wi(pe.dataType,P.dataType));if(!g){const pe=oe.fromReturnDeclarationToBodyArgumentDeclarationName(P),Ee={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.ArgumentDeclaration,name:pe,description:`Aggretated list of all previously outputted values from each iteration by the output '${x(P,this.project)}'`,defaultValue:null,constant:!0,dataType:null,implements:null,index:P.index,required:P.required,parent:this.body.toReference(),writesValues:[]},Q=C(Ee,this.project);Q.setParent(this.body,e),Q.initChildren(e),e==null||e.add(Q,A.Added),Q.addSelfToProject(e),i.push(Q),g=Q}const B=this.body.inputs.find(pe=>pe.index===g.index&&pe!==g),G=this.body.inputs.filter(pe=>pe!==g);let q=g.index;B&&(q=Math.max(...G.map(pe=>pe.index))+1),g.index!==q&&(g.metaSync({index:q},e),t.push(g));const S=g.getDataType(e);let X=S;if(V)if(!S||!wi(S,V)){if(!X){const Ee=V.clone(e,g);e==null||e.add(Ee,A.Added),Ee.addSelfToProject(e),X=Ee,i.push(Ee),t.push(g)}const pe=X.merge(V,e);pe.self===X?V.remove({ignoreUpstream:!1},e):pe.self===V&&(X.remove({ignoreUpstream:!1},e),X=V),X.metaSync({isList:!0},e)}else X.isList||(X.metaSync({isList:!0},e),t.push(X));if(!V&&!X){const pe={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.DataType,options:[],implementationChooseOne:!1,parentRelationType:null,staticEntities:null,interactiveEntities:null,actionEntities:null,isList:!0,entity:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:g.toReference()},Ee=C(pe,this.project);Ee.metaSync({isList:!0},e),Ee.setParent(g,e),Ee.initChildren(e),e==null||e.add(Ee,A.Added),Ee.addSelfToProject(e),i.push(Ee)}});const{updated:E,added:I,removed:D}=this.removeExtraBodyArgumentDeclarations(e);return t.push(...E),i.push(...I),s.push(...D),e==null||e.attemptAutoclose("sync-body-arguments-declarations",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}syncOutputsDeclarations(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"sync-outputs-declarations"))){const t=[],i=[],s=[],l=[],o=this.getUniqueReturnDeclarations(),d=this.outputsDeclarations;return o.forEach((h,c)=>{h.index!==c&&(h.metaSync({index:c},e),t.push(h))}),o.forEach(h=>{const c=h.getDataType(e);let I=d.find(V=>x(V,this.project)===oe.fromReturnDeclarationToLoopOutputDeclarationName(h)&&wi(V.dataType,h.dataType));if(!I){const V=oe.fromReturnDeclarationToLoopOutputDeclarationName(h),M={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.ValueDescriptor,name:V,description:`Aggretated list of all previously outputted values from each iteration by the output '${x(h,this.project)}'`,defaultValue:null,dataType:null,index:h.index,required:h.required,parentRelationType:L.FixedReturns,parent:this.toReference()},g=C(M,this.project);g.setParent(this,e),g.initChildren(e),e==null||e.add(g,A.Added),g.addSelfToProject(e),i.push(g),I=g}I.index!==h.index&&(I.metaSync({index:h.index},e),t.push(I));let P=I.getDataType(e);if(c)if(!P||!wi(P,c)){if(!P){const M=c.clone(e,I);e==null||e.add(M,A.Added),M.addSelfToProject(e),P=M,i.push(M),t.push(I)}const V=P.merge(c,e);V.self===P?c.remove({ignoreUpstream:!1},e):V.self===c&&(P.remove({ignoreUpstream:!1},e),P=c),P.metaSync({isList:!0},e)}else P.isList||(P.metaSync({isList:!0},e),t.push(P));if(!c&&!P){const V={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.DataType,options:[],implementationChooseOne:!1,staticEntities:null,interactiveEntities:null,actionEntities:null,parentRelationType:null,isList:!0,entity:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:I.toReference()},M=C(V,this.project);M.metaSync({isList:!0},e),M.setParent(I,e),M.initChildren(e),e==null||e.add(M,A.Added),M.addSelfToProject(e),i.push(M)}}),d.filter(h=>!o.find(E=>x(h,this.project)===oe.fromReturnDeclarationToLoopOutputDeclarationName(E))).forEach(h=>{const{updated:c,removed:E}=h.remove({ignoreUpstream:!1},e);t.push(...c),s.push(...E)}),e==null||e.attemptAutoclose("sync-outputs-declarations",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}syncOutputMaps(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"add-extended-properties"))){const t=[],i=[],s=[],l=[],o=this.outputsDeclarations,d=this.outputs;return o.forEach(h=>{var I;let E=d.find(D=>{var P,V;return((P=D.declaration)==null?void 0:P.id)===h.id&&wi((V=D.declaration)==null?void 0:V.dataType,h.dataType)});if(E)((I=E.declaration)==null?void 0:I.id)!==h.id&&(E.setDeclaration(h),t.push(E));else{const D={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.OutputMap,defaultValue:null,index:h.index,declaration:h.toJSON(),writesValues:[],parent:this.toReference()},P=C(D,this.project);P.setParent(this,e),P.initChildren(e),e==null||e.add(P,A.Added),P.addSelfToProject(e),i.push(P),E=P}E.index!==h.index&&(E.metaSync({index:h.index},e),t.push(E))}),d.filter(h=>!o.find(E=>{var I;return((I=h.declaration)==null?void 0:I.id)===E.id})).forEach(h=>{const{updated:c,removed:E}=h.remove({ignoreUpstream:!1},e);t.push(...c),s.push(...E)}),e==null||e.attemptAutoclose("add-extended-properties",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}createCurrentIterationNumberArgumentDeclaration(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"create-current-iteration-number-argument-declaration"))){const t=[],i=[],s=[],l=[];let d=this.body.inputs.find(E=>{var I;return E.name===oe.CURRENT_ITERATION_NUMBER_ARG_NAME||E.id===((I=this.currentIterationNumberArgumentDeclaration)==null?void 0:I.id)});const u=this.getCurrentIterationNumberBuiltInValueDescriptor();if(!d){const E={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.ArgumentDeclaration,name:oe.CURRENT_ITERATION_NUMBER_ARG_NAME,description:"The number of the current iteration",defaultValue:null,constant:!0,dataType:null,implements:u==null?void 0:u.toJSON(),index:this.body.inputs.length,required:!0,parent:this.body.toReference(),writesValues:[]},I=C(E,this.project);I.setParent(this.body,e),I.initChildren(e),e==null||e.add(I,A.Added),I.addSelfToProject(e),i.push(I),d=I}!d.index&&d.index!==0&&(d.metaSync({index:0},e),t.push(d)),(!d.implements||d.implements.id!==u.id)&&(d.setImplements(u,e),t.push(d));let c=d.getDataType(e);if(!c){const E={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.DataType,options:[],implementationChooseOne:!1,staticEntities:null,interactiveEntities:null,actionEntities:null,parentRelationType:null,isList:!1,entity:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:d.toReference()},I=C(E,this.project);I.setParent(d,e),I.initChildren(e),e==null||e.add(I,A.Added),I.addSelfToProject(e),i.push(I),c=I}if(!c.entity||c.entity.type!==n.PrimitiveEntity||c.entity.name!==N.Number||c.entity.id!==k["primitive-entity"].number.id){const E=this.project.getBuiltIn(k["primitive-entity"].number.id);c.setEntity(E),t.push(c)}return this.currentIterationNumberArgumentDeclaration=d,e==null||e.attemptAutoclose("create-current-iteration-number-argument-declaration",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}removeExtraBodyArgumentDeclarations(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"remove-extra-body-argument-declarations"))){const t=[],i=[],s=[],l=[],o=this.body.inputs,d=this.getUniqueReturnDeclarations();return o.filter(h=>h===this.currentIterationNumberArgumentDeclaration||h===this.currentValueArgumentDeclaration?!1:!d.find(E=>x(h,this.project)===oe.fromReturnDeclarationToBodyArgumentDeclarationName(E))).forEach(h=>{const{updated:c,removed:E}=h.remove({ignoreUpstream:!1},e);t.push(...c),s.push(...E)}),e==null||e.attemptAutoclose("remove-extra-body-argument-declarations",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}createCurrentValueInputBasedOnInputMap(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"create-current-value-input-based-on-input-map"))){var h,c,E,I,D;const t=[],i=[],s=[],l=[];switch(this.declaration.id){case ee.List:{const P=this.body.inputs.find(g=>{var B;return((B=g.implements)==null?void 0:B.id)===k[n.Loop][ee.List].body.inputs.currentValue.id}),V=this.inputs.find(g=>{var B;return((B=g.declaration)==null?void 0:B.id)===k[n.Loop][ee.List].inputs.list.id});if(!V)break;const M=this.getCurrentValueBuiltInValueDescriptor();if(P){this.currentValueArgumentDeclaration=P;const g=this.project.get(k[n.Loop][ee.List].inputs.list.id);M&&(!P.implements||P.implements.id!==M.id)&&(P.setImplements(M,e),t.push(P));let G=P.getDataType(e);if(!G){const S={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.DataType,options:[],implementationChooseOne:!1,parentRelationType:null,staticEntities:null,interactiveEntities:null,actionEntities:null,isList:!1,entity:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:g.toReference()},X=C(S,this.project);X.setParent(g,e),X.initChildren(e),e==null||e.add(X,A.Added),X.addSelfToProject(e),i.push(X),G=X}const q=V.getDataType(e);G.merge(q,e),G.metaSync({isList:!1},e)}else{const g={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.ArgumentDeclaration,name:oe.CURRENT_VALUE_ARG_NAME,description:null,defaultValue:null,index:this.body.inputs.length,constant:!0,required:!0,implements:M,writesValues:[],dataType:null,parent:this.body.toReference()},B=C(g,this.project);B.setParent(this.body,e),B.initChildren(e),e==null||e.add(B,A.Added),B.addSelfToProject(e),M&&(!B.implements||B.implements.id!==M.id)&&(B.setImplements(M,e),t.push(B)),i.push(B),this.currentValueArgumentDeclaration=B}break}case ee.ManualFlow:{this.currentValueArgumentDeclaration=null;break}case ee.Counted:{this.currentValueArgumentDeclaration=null;break}case ee.ObjectKeys:{const P=this.body.inputs.find(g=>{var B;return((B=g.implements)==null?void 0:B.id)===k[n.Loop][ee.ObjectKeys].body.inputs.currentValue.id});if(!this.inputs.find(g=>{var B;return((B=g.declaration)==null?void 0:B.id)===k[n.Loop][ee.ObjectKeys].inputs.object.id}))break;const M=this.getCurrentValueBuiltInValueDescriptor();if(P){this.currentValueArgumentDeclaration=P;const g=this.project.get(k[n.Loop][ee.ObjectKeys].inputs.object.id);M&&(!P.implements||P.implements.id!==M.id)&&(P.setImplements(M),t.push(P));let G=P.getDataType(e);if(G){const q=this.project.getBuiltIn(k["primitive-entity"].string.id);((h=G.entity)==null?void 0:h.id)!==q.id&&(G.setEntity(q),t.push(G))}else{const q={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.DataType,options:[],implementationChooseOne:!1,parentRelationType:null,staticEntities:null,interactiveEntities:null,actionEntities:null,isList:!1,entity:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:g.toReference()},S=C(q,this.project);S.setParent(g,e),S.initChildren(e),e==null||e.add(S,A.Added),S.addSelfToProject(e),G=S}}else{const g={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.ArgumentDeclaration,name:oe.CURRENT_VALUE_ARG_NAME,description:null,defaultValue:null,index:this.body.inputs.length,constant:!0,required:!0,implements:M,writesValues:[],dataType:null,parent:this.body.toReference()},B=C(g,this.project);B.setParent(this.body,e),B.initChildren(e),e==null||e.add(B,A.Added),B.addSelfToProject(e),M&&(!B.implements||B.implements.id!==M.id)&&(B.setImplements(M,e),t.push(B)),i.push(B),this.currentValueArgumentDeclaration=B}break}case ee.ObjectValues:{const P=this.body.inputs.find(g=>{var B;return((B=g.implements)==null?void 0:B.id)===k[n.Loop][ee.ObjectValues].body.inputs.currentValue.id}),V=this.inputs.find(g=>{var B;return((B=g.declaration)==null?void 0:B.id)===k[n.Loop][ee.ObjectValues].inputs.object.id});if(!V)break;const M=this.getCurrentValueBuiltInValueDescriptor();if(P){this.currentValueArgumentDeclaration=P;const g=this.project.get(k[n.Loop][ee.ObjectValues].inputs.object.id);M&&(!P.implements||P.implements.id!==M.id)&&(P.setImplements(M,e),t.push(P));let G=P.getDataType(e);if(G){const q=V.getDataType(e),S=((E=q==null?void 0:q.entity)==null?void 0:E.properties)||[];(I=G.orChildrenGroup)==null||I.forEach(X=>{const{updated:pe,removed:Ee}=X.remove({ignoreUpstream:!1},e);t.push(...pe),s.push(...Ee)}),S.forEach(X=>{if(!X.getDataType(e)){const Ee={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.DataType,options:[],implementationChooseOne:!1,staticEntities:null,interactiveEntities:null,actionEntities:null,isList:!1,entity:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parentRelationType:Pt.OrDataTypeGroup,parent:G.toReference()},Q=C(Ee,this.project);Q.setParent(G,e),Q.initChildren(e),e==null||e.add(Q,A.Added),Q.addSelfToProject(e),i.push(Q)}})}else{const q={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.DataType,options:[],implementationChooseOne:!1,parentRelationType:null,staticEntities:null,interactiveEntities:null,actionEntities:null,isList:!1,entity:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:g.toReference()},S=C(q,this.project);S.setParent(g,e),S.initChildren(e),e==null||e.add(S,A.Added),S.addSelfToProject(e),G=S;const X=V.getDataType(e);(((c=X==null?void 0:X.entity)==null?void 0:c.properties)||[]).forEach(Ee=>{if(!Ee.getDataType(e)){const le={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.DataType,options:[],implementationChooseOne:!1,staticEntities:null,interactiveEntities:null,actionEntities:null,isList:!1,entity:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parentRelationType:Pt.OrDataTypeGroup,parent:S.toReference()},ri=C(le,this.project);ri.setParent(S,e),ri.initChildren(e),e==null||e.add(ri,A.Added),ri.addSelfToProject(e),i.push(ri)}})}}else{const g={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.ArgumentDeclaration,name:oe.CURRENT_VALUE_ARG_NAME,description:null,constant:!0,defaultValue:null,index:this.body.inputs.length,required:!0,implements:M,writesValues:[],dataType:null,parent:this.body.toReference()},B=C(g,this.project);B.setParent(this.body,e),B.initChildren(e),e==null||e.add(B,A.Added),B.addSelfToProject(e),M&&(!B.implements||B.implements.id!==M.id)&&(B.setImplements(M,e),t.push(B)),i.push(B),this.currentValueArgumentDeclaration=B}break}case ee.String:{const P=this.body.inputs.find(g=>{var B;return((B=g.implements)==null?void 0:B.id)===k[n.Loop][ee.String].body.inputs.currentValue.id});if(!this.inputs.find(g=>{var B;return((B=g.declaration)==null?void 0:B.id)===k[n.Loop][ee.String].inputs.string.id}))break;const M=this.getCurrentValueBuiltInValueDescriptor();if(P){this.currentValueArgumentDeclaration=P;const g=this.project.get(k[n.Loop]["string-loop"].inputs.string.id);M&&(!P.implements||P.implements.id!==M.id)&&(P.setImplements(M,e),t.push(P));let G=P.getDataType(e);if(G){const q=this.project.getBuiltIn(k["primitive-entity"].string.id);((D=G.entity)==null?void 0:D.id)!==q.id&&(G.setEntity(q),t.push(G))}else{const q={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.DataType,options:[],implementationChooseOne:!1,parentRelationType:null,staticEntities:null,interactiveEntities:null,actionEntities:null,isList:!1,entity:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:g.toReference()},S=C(q,this.project);S.setParent(g,e),S.initChildren(e),e==null||e.add(S,A.Added),S.addSelfToProject(e),i.push(S),G=S}}else{const g={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.ArgumentDeclaration,name:oe.CURRENT_VALUE_ARG_NAME,description:null,index:this.body.inputs.length,required:!0,constant:!0,defaultValue:null,implements:M,writesValues:[],dataType:null,parent:this.body.toReference()},B=C(g,this.project);B.setParent(this.body,e),B.initChildren(e),e==null||e.add(B,A.Added),B.addSelfToProject(e),M&&(!B.implements||B.implements.id!==M.id)&&(B.setImplements(M,e),t.push(B)),i.push(B),this.currentValueArgumentDeclaration=B}break}}const{updated:o,added:d,removed:u}=this.removeExtraBodyArgumentDeclarations(e);return t.push(...o),i.push(...d),s.push(...u),e==null||e.attemptAutoclose("create-current-value-input-based-on-input-map",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}syncFixedBodyArgumentDeclarations(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"sync-fixed-body-argument-declarations"))){const t=[],i=[],s=[],l=[],{updated:o,added:d,removed:u}=this.createCurrentIterationNumberArgumentDeclaration(e);t.push(...o),i.push(...d),s.push(...u);const{updated:h,added:c,removed:E}=this.createCurrentValueInputBasedOnInputMap(e);return t.push(...h),i.push(...c),s.push(...E),e==null||e.attemptAutoclose("sync-fixed-body-argument-declarations",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}syncInputMaps(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"sync-input-maps"))){const t=[],i=[],s=[],l=[];switch(this.declaration.id){case ee.List:{let o=null;if(this.inputs.forEach(d=>{var u;((u=d.declaration)==null?void 0:u.id)===k[n.Loop]["list-loop"].inputs.list.id?o=d:(d.remove({ignoreUpstream:!1},e),s.push(d))}),o){if(o.declaration.id!==k[n.Loop]["list-loop"].inputs.list.id){const d=this.project.get(k[n.Loop]["list-loop"].inputs.list.id);o.setDeclaration(d),t.push(o)}}else{const d=this.project.get(k[n.Loop]["list-loop"].inputs.list.id),u={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.InputMap,name:null,description:null,index:0,declaration:d.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},h=C(u,this.project);h.setParent(this,e),h.initChildren(e),e==null||e.add(h,A.Added),h.addSelfToProject(e),i.push(h)}break}case ee.ManualFlow:{this.inputs.forEach(o=>{o.remove({ignoreUpstream:!1},e),s.push(o)});break}case ee.Counted:{let o=null;if(this.inputs.forEach(d=>{var u;((u=d.declaration)==null?void 0:u.id)===k[n.Loop]["counted-loop"].inputs.number.id?o=d:(d.remove({ignoreUpstream:!1},e),s.push(d))}),o){if(o.declaration.id!==k[n.Loop]["counted-loop"].inputs.number.id){const d=this.project.get(k[n.Loop]["counted-loop"].inputs.number.id);o.setDeclaration(d),t.push(o)}}else{const d=this.project.get(k[n.Loop]["counted-loop"].inputs.number.id),u={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.InputMap,name:null,description:null,index:0,declaration:d.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},h=C(u,this.project);h.setParent(this,e),h.initChildren(e),e==null||e.add(h,A.Added),h.addSelfToProject(e),i.push(h)}break}case ee.ObjectKeys:{let o=null;if(this.inputs.forEach(d=>{var u;((u=d.declaration)==null?void 0:u.id)===k[n.Loop]["object-keys-loop"].inputs.object.id?o=d:(d.remove({ignoreUpstream:!1},e),s.push(d))}),o){if(o.declaration.id!==k[n.Loop]["object-keys-loop"].inputs.object.id){const d=this.project.get(k[n.Loop]["object-keys-loop"].inputs.object.id);o.setDeclaration(d),t.push(o)}}else{const d=this.project.get(k[n.Loop]["object-keys-loop"].inputs.object.id),u={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.InputMap,name:null,description:null,index:0,declaration:d.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},h=C(u,this.project);h.setParent(this,e),h.initChildren(e),e==null||e.add(h,A.Added),h.addSelfToProject(e),i.push(h)}break}case ee.ObjectValues:{let o=null;if(this.inputs.forEach(d=>{var u;((u=d.declaration)==null?void 0:u.id)===k[n.Loop]["object-values-loop"].inputs.object.id?o=d:(d.remove({ignoreUpstream:!1},e),s.push(d))}),o){if(o.declaration.id!==k[n.Loop]["object-values-loop"].inputs.object.id){const d=this.project.get(k[n.Loop]["object-values-loop"].inputs.object.id);o.setDeclaration(d),t.push(o)}}else{const d=this.project.get(k[n.Loop]["object-values-loop"].inputs.object.id),u={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.InputMap,name:null,description:null,index:0,declaration:d.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},h=C(u,this.project);h.setParent(this,e),h.initChildren(e),e==null||e.add(h,A.Added),h.addSelfToProject(e),i.push(h)}break}case ee.String:{let o=null;if(this.inputs.forEach(d=>{var u;((u=d.declaration)==null?void 0:u.id)===k[n.Loop]["string-loop"].inputs.string.id?o=d:(d.remove({ignoreUpstream:!1},e),s.push(d))}),o){if(o.declaration.id!==k[n.Loop]["string-loop"].inputs.string.id){const d=this.project.get(k[n.Loop]["string-loop"].inputs.string.id);o.setDeclaration(d),t.push(o)}}else{const d=this.project.get(k[n.Loop]["string-loop"].inputs.string.id),u={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.InputMap,name:null,description:null,index:0,declaration:d.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},h=C(u,this.project);h.setParent(this,e),h.initChildren(e),e==null||e.add(h,A.Added),h.addSelfToProject(e),i.push(h)}break}}return e==null||e.attemptAutoclose("sync-input-maps",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}getCurrentValueBuiltInValueDescriptor(){var t;const e=(t=k[n.Loop][this.declaration.id].body.inputs.currentValue)==null?void 0:t.id;return e?this.project.get(e):null}getCurrentIterationNumberBuiltInValueDescriptor(){const e=k[n.Loop][this.declaration.id].body.inputs.iterationNumber.id;return this.project.get(e)}syncBody(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"sync-body"))){var u;const t=[],i=[],s=[],l=[],o=k[n.Loop][this.declaration.id].body.id,d=this.project.getBuiltIn(o);if(this.body)((u=this.body.implements)==null?void 0:u.id)!==d.id&&(this.body.setImplements(d,e),this.body.setParent(this,e),t.push(this.body));else{const h={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.FunctionDeclaration,name:d.name,description:null,inputs:[],index:null,calls:[],collapsed:!1,private:!1,implements:d.toJSON(),x:0,y:0,parent:this.toReference()},c=C(h,this.project);c.setParent(this,e),c.initChildren(e),e==null||e.add(c,A.Added),c.addSelfToProject(e),i.push(c)}return e==null||e.attemptAutoclose("sync-body",this.id),{self:this,updated:p(t),added:p(i),removed:p(s),affected:p(l)}}syncChildren(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"sync-children"))){const t=[],i=[],s=[],l=[],{updated:o,added:d,removed:u}=this.syncBody(e);t.push(...o),i.push(...d),s.push(...u);const{updated:h,added:c,removed:E}=this.syncInputMaps(e);t.push(...h),i.push(...c),s.push(...E);const{updated:I,added:D,removed:P}=this.syncTerminationStatements(e);t.push(...I),i.push(...D),s.push(...P);const{updated:V,added:M,removed:g}=this.syncBodyArgumentsDeclarations(e);t.push(...V),i.push(...M),s.push(...g);const{updated:B,added:G,removed:q}=this.syncBodyInputIndexes(e);t.push(...B),i.push(...G),s.push(...q);const{updated:S,added:X,removed:pe}=this.syncOutputsDeclarations(e);t.push(...S),i.push(...X),s.push(...pe);const{updated:Ee,added:Q,removed:le}=this.syncOutputMaps(e);return t.push(...Ee),i.push(...Q),s.push(...le),e==null||e.attemptAutoclose("sync-children",this.id),{self:this,updated:p(t),added:p(i),removed:p(s),affected:p(l)}}};f(oe,"repository",{APICreate:async(e,...t)=>e,APIUpdate:async(e,...t)=>e,APIDelete:async(e,...t)=>e,APIClone:async(e,...t)=>{},APILoad:async(e,...t)=>null,APILoadVersion:async(e,t,...i)=>null}),f(oe,"type",n.Loop),f(oe,"USER_MANAGED_PARENT_TYPES",[...ht,n.Project]),f(oe,"PARENT_TYPES",[...We.USER_MANAGED_PARENT_TYPES]),f(oe,"CURRENT_ITERATION_NUMBER_ARG_NAME","Current iteration number"),f(oe,"CURRENT_VALUE_ARG_NAME","Current value"),f(oe,"MUTABLE_BASE_PROPERTIES",[]),f(oe,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),f(oe,"BASE_PROPERTIES",[...oe.MUTABLE_BASE_PROPERTIES,...oe.INMUTABLE_BASE_PROPERTIES]),f(oe,"MUTABLE_META_PROPERTIES",[...oe.MUTABLE_BASE_PROPERTIES,"x","y"]),f(oe,"INMUTABLE_META_PROPERTIES",[...oe.INMUTABLE_BASE_PROPERTIES]),f(oe,"META_PROPERTIES",[...oe.MUTABLE_META_PROPERTIES,...oe.INMUTABLE_META_PROPERTIES]),f(oe,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry"]),f(oe,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","declaration"]),f(oe,"UPSTREAM_PROPERTIES",[...oe.MUTABLE_UPSTREAM_PROPERTIES,...oe.INMUTABLE_UPSTREAM_PROPERTIES]),f(oe,"MUTABLE_DOWNSTREAM_PROPERTIES",["body","inputs","outputs","outputsDeclarations","successCalls","errorCalls","error","breakStatements","continueStatements"]),f(oe,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),f(oe,"DOWNSTREAM_PROPERTIES",[...oe.MUTABLE_DOWNSTREAM_PROPERTIES,...oe.INMUTABLE_DOWNSTREAM_PROPERTIES]),f(oe,"PROPERTIES",[...oe.META_PROPERTIES,...oe.UPSTREAM_PROPERTIES,...oe.DOWNSTREAM_PROPERTIES]);let Wr=oe;function R1(r){const a=J5(),e=r.toJSON();a.safeParse(e).success,r.inputs.forEach(l=>l.validate());const s=[...Ar(r)];return Ke(r.errors,s)}const SJ=Object.freeze(Object.defineProperty({__proto__:null,validate:R1},Symbol.toStringTag,{value:"Module"}));var D1=(r=>(r.Parent="parent",r))(D1||{});const Ze=class Ze extends lt{constructor(e,t){super(e);f(this,"initialData");f(this,"id");f(this,"x");f(this,"y");f(this,"type",n.Condition);f(this,"successCalls",[]);f(this,"errorCalls",[]);f(this,"declaration");f(this,"inputs",[]);f(this,"calledBySuccess",[]);f(this,"calledByError",[]);f(this,"calledByEntry",[]);f(this,"project");f(this,"errors",[]);f(this,"parent");f(this,"detachedDependents",{});f(this,"knownVersions",null);f(this,"activeVersion",!1);f(this,"initialized",!1);f(this,"startedInitialization",!1);this.initialData=e,this.project=t,this.id=e.id,this.x=e.x,this.y=e.y}static new(e=null){return{id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:(e==null?void 0:e.author)||m.sessionAuthor,previousVersion:null,deleted:!1,type:n.Condition,declaration:null,inputs:[],parent:null,calledByEntry:[],calledBySuccess:[],calledByError:[],errorCalls:[],successCalls:[],x:0,y:0}}static fromGenerationTarget(e,t){let i=t;if(e.parent){const c=_(e.parent);i=t.get(c)}const s=e.calledByEntry.map(c=>{const E=_(c);return t.get(E)}),l=e.calledBySuccess.map(c=>{const E=_(c);return t.get(E)}),o=e.calledByError.map(c=>{const E=_(c);return t.get(E)});let d;if(e.declaration){const c=_(e.declaration);d=t.get(c)}const u={id:e.id,version:m.UUID.uuid(),createdAt:T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.Condition,declaration:d,calledByEntry:s,calledBySuccess:l,calledByError:o,errorCalls:[],successCalls:[],inputs:[],x:0,y:0,parent:i},h=C(u,t);return h.setParent(i,null),h.initChildren(null),h}static validateGenerationTarget(e,t){let i=JSON.parse(JSON.stringify(e));const s=[],l=bt(i,{parent:{list:!1,types:[...ht,n.Project],optional:!0}},t);return i=l.modifiedData,s.push(...l.errors,...ut(i)),e.declaration?t.get(e.declaration)?t.conditionDeclarations.find(u=>u.id===e.declaration)||s.push(new w({id:`${e.id}--${R.InvalidImplementsReference}`,code:R.InvalidImplementsReference,severity:O.Error,message:`Entity of type '${e.type}' with id '${e.id}' has an 'declaration' property that isn't pointing to an action descriptor reserved for '${n.Condition}' entities.
99
+ You shouldn't have to manually update a 'parent' property. The equivalent result is to change its callers, the value writters of its inputs, or the value readers of its outputs.`,issue:null})),{errors:t,modifiedData:e}}subscribeDependents(e){return e.forEach(t=>{this.detachedDependents[t.entity.id]||(this.detachedDependents[t.entity.id]=t)}),this}unsubscribeDependents(e){return e.forEach(t=>{this.detachedDependents[t.entity.id]&&delete this.detachedDependents[t.entity.id]}),this}syncDependents(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"sync-dependents"))){const t=[],i=[],s=[],l=[];return Object.values(this.detachedDependents).forEach(o=>{const d=o.entity.afterAllChildrenInitialized(e);t.push(...d.updated),i.push(...d.added),s.push(...d.removed),l.push(...d.affected)}),e==null||e.attemptAutoclose("sync-dependents",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}onDetachedDependencyRemoved(e,t,i){const s=[],l=[],o=[],d=[];if(t==="parent"){const{updated:u,added:h,removed:c}=this.remove({ignoreUpstream:!1},i);s.push(...u),l.push(...h),o.push(...c)}return{updated:p(s),added:p(l),removed:p(o),affected:p(d),self:this}}onDetachedDependencyRestored(e,t,i){const s=[],l=[],o=[],d=[];if(t==="parent"){const{updated:u,added:h,removed:c}=this.restore({},i);s.push(...u),l.push(...h),o.push(...c)}return{updated:p(s),added:p(l),removed:p(o),affected:p(d),self:this}}unsubscribeFromDependencies(){var e;return(e=this.parent)==null||e.unsubscribeDependents([{entity:this,field:"parent"}]),this}subscribeToDependencies(){var e;return(e=this.parent)==null||e.subscribeDependents([{entity:this,field:"parent"}]),this}increaseVersion(e){if(e&&!T(e).isValid())throw new Error(`The shared timestamp '${e}' is not a valid ISO 8601 date string.`);return e&&T(e).isSame(T(this.createdAt))?this:(this.previousVersion=this.version,this.version=m.UUID.uuid(),this.createdAt=T(e).toISOString()||T().toISOString(),this)}captureVersion(){var t;const e=((t=this.knownVersions)==null?void 0:t.get(this.version))||new oe(this,this.project);return e.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,e):new Map([[this.version,e]]),e.inputs=this.inputs,e.outputs=this.outputs,e.error=this.error,e.successCalls=this.successCalls,e.errorCalls=this.errorCalls,e.declaration=this.declaration,e.outputsDeclarations=this.outputsDeclarations,e.body=this.body,e.calledByEntry=this.calledByEntry,e.calledBySuccess=this.calledBySuccess,e.calledByError=this.calledByError,e.process=this.process,e.parent=this.parent,this}recursiveCaptureUpstreamVersions(e){const t=[],i=[],s=[],l=[];if(this.parent){this.parent.increaseVersion(e);const o=this.parent.recursiveCaptureUpstreamVersions(e);t.push(this.parent,...o.updated),i.push(...o.added),s.push(...o.removed)}return{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}async restoreVersion(e){var d;const t=[],i=[],s=[],l=[];if(this.version===e)return{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this};if(!this.knownVersions){const u=new Map;for(const[h,c]of this.knownVersions||new Map){if(u.set(h,c),c.activeVersion=!1,c.knownVersions)for(const[E,I]of c.knownVersions)u.set(E,I);c.knownVersions=null}}let o=(d=this.knownVersions)==null?void 0:d.get(e);if(!o){const u=await this.APILoadVersion({},e);if(!u)throw new Error(`Version with id '${e}' for entity with id '${this.id}' not found.`);o=new oe(u,this.project)}return this.metaSync(o.toShallowJSON(),null),this.inputs=o.inputs,this.outputs=o.outputs,this.error=o.error,this.successCalls=o.successCalls,this.errorCalls=o.errorCalls,this.declaration=o.declaration,this.outputsDeclarations=o.outputsDeclarations,this.body=o.body,this.calledByEntry=o.calledByEntry,this.calledBySuccess=o.calledBySuccess,this.calledByError=o.calledByError,this.process=o.process,this.parent=o.parent,{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}hydrateAncestors(){const e=[],t=[],i=[],s=[];if(this.initialData.parent){const l=_(this.initialData.parent),o=this.project.get(l);if(o)this.setParent(o,null),e.push(o);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${l}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(this.initialData.declaration){const l=_(this.initialData.declaration),o=this.project.get(l);o&&(this.setDeclaration(o),e.push(o))}return this.initialData.calledByEntry.forEach(l=>{const o=_(l),d=this.project.get(o);d&&(this.addEntryCaller(d,null),d.addCall(this,null),e.push(d))}),this.initialData.calledBySuccess.forEach(l=>{const o=_(l),d=this.project.get(o);d&&(this.addSuccessCaller(d,null),d.addSuccessCall(this,null),e.push(d))}),this.initialData.calledByError.forEach(l=>{const o=_(l),d=this.project.get(o);d&&(this.addErrorCaller(d,null),d.addErrorCall(this,null),e.push(d))}),{updated:p(e),added:p(t),removed:p(i),affected:p(s),self:this}}afterAllChildrenInitialized(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"after-all-children-initialized"))){const t=[],i=[],s=[],l=[];this.initialized=!0;const{updated:o,added:d,removed:u}=this.syncChildren(e);return t.push(...o),i.push(...d),s.push(...u),this.captureVersion(),e==null||e.attemptAutoclose("after-all-children-initialized",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}addSelfToProject(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"add-self-to-project"))){const t=[this],i=[],s=[],l=[];return this.parent===this.project&&this.project.addLoop(this),this.successCalls.forEach(o=>{o.addSuccessCaller(this,e),t.push(o)}),this.errorCalls.forEach(o=>{o.addErrorCaller(this,e),t.push(o)}),this.calledByEntry.forEach(o=>{o.addCall(this,e),t.push(o)}),this.calledBySuccess.forEach(o=>{o.addSuccessCall(this,e),t.push(o)}),this.calledByError.forEach(o=>{o.addErrorCall(this,e),t.push(o)}),this.subscribe(),this.subscribeToDependencies(),e==null||e.attemptAutoclose("add-self-to-project",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}removeInput(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"remove-input"))){const i=this.inputs.findIndex(s=>s.id===e.id);return i>-1&&(this.inputs.splice(i,1),t&&(t==null||t.add(this,A.Affected))),t==null||t.attemptAutoclose("remove-input",this.id),this}addInput(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"add-input"))){return this.inputs.includes(e)?(t==null||t.attemptAutoclose("add-input",this.id),this):(this.inputs.push(e),t==null||t.add(this,A.Affected),t==null||t.attemptAutoclose("add-input",this.id),this)}addOutputDeclaration(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"add-output-declaration"))){return this.outputsDeclarations.includes(e)?(t==null||t.attemptAutoclose("add-output-declaration",this.id),this):(this.outputsDeclarations.push(e),t==null||t.add(this,A.Affected),t==null||t.attemptAutoclose("add-output-declaration",this.id),this)}removeOutputDeclaration(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"remove-output-declaration"))){const i=this.outputsDeclarations.findIndex(s=>s.id===e.id);return i>-1&&(this.outputsDeclarations.splice(i,1),t==null||t.add(this,A.Affected)),t==null||t.attemptAutoclose("remove-output-declaration",this.id),this}addOutput(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"add-output"))){return this.outputs.includes(e)?(t==null||t.attemptAutoclose("add-output",this.id),this):(this.outputs.push(e),t==null||t.add(this,A.Affected),t==null||t.attemptAutoclose("add-output",this.id),this)}removeOutput(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"remove-output"))){const i=this.outputs.findIndex(s=>s.id===e.id);return i>-1&&(this.outputs.splice(i,1),t&&(t==null||t.add(this,A.Affected))),t==null||t.attemptAutoclose("remove-output",this.id),this}setBody(e){return this.body=e,this}addSuccessCaller(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"add-success-caller")),i=!1){return this.calledBySuccess.find(s=>s.id===e.id)||(this.calledBySuccess.push(e),t==null||t.add(this,A.Updated),i&&K(this,t)),t==null||t.attemptAutoclose("add-success-caller",this.id),this}addErrorCaller(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"add-error-caller")),i=!1){return this.calledByError.find(s=>s.id===e.id)||(this.calledByError.push(e),t==null||t.add(this,A.Updated),i&&K(this,t)),t==null||t.attemptAutoclose("add-error-caller",this.id),this}addEntryCaller(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"add-entry-caller")),i=!1){return this.calledByEntry.find(s=>s.id===e.id)||(this.calledByEntry.push(e),t==null||t.add(this,A.Updated),i&&K(this,t)),t==null||t.attemptAutoclose("add-entry-caller",this.id),this}addErrorCall(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"add-error-call")),i=!1){return this.errorCalls.find(s=>s.id===e.id)||(this.errorCalls.push(e),i&&K(this,t),t==null||t.add(this,A.Affected)),t==null||t.attemptAutoclose("add-error-call",this.id),this}addSuccessCall(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"add-success-call")),i=!1){return this.successCalls.find(s=>s.id===e.id)||(this.successCalls.push(e),i&&K(this,t),t==null||t.add(this,A.Affected)),t==null||t.attemptAutoclose("add-success-call",this.id),this}removeCall(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"remove-call")),i=!1){const s=this.successCalls.findIndex(o=>o.id===e.id);s>-1&&(this.successCalls.splice(s,1),t==null||t.add(this,A.Affected));const l=this.errorCalls.findIndex(o=>o.id===e.id);return l>-1&&(this.errorCalls.splice(l,1),t==null||t.add(this,A.Affected)),i&&K(this,t),t==null||t.attemptAutoclose("remove-call",this.id),this}removeCaller(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"remove-caller")),i=!1){return this.calledBySuccess=this.calledBySuccess.filter(s=>s.id!==e.id?!0:(t==null||t.add(this,A.Updated),t==null||t.add(s,A.Affected),!1)),this.calledByError=this.calledByError.filter(s=>s.id!==e.id?!0:(t==null||t.add(this,A.Updated),t==null||t.add(s,A.Affected),!1)),this.calledByEntry=this.calledByEntry.filter(s=>s.id!==e.id?!0:(t==null||t.add(this,A.Updated),t==null||t.add(s,A.Affected),!1)),i&&K(this,t),t==null||t.attemptAutoclose("remove-caller",this.id),this}replaceDetachedChild(e,t){const i=this.detachedChildren.indexOf(e);return i!==-1&&(this.detachedChildren[i]=t),this}subscribeDetachedChild(e){return this.detachedChildren.includes(e)||this.detachedChildren.push(e),this}setParent(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"set-parent"))){var i;return((i=this.parent)==null?void 0:i.id)!==(e==null?void 0:e.id)&&(this.parent=e,t&&(t==null||t.add(this,A.Updated),t==null||t.attemptAutoclose("set-parent",this.id))),this}setDeclaration(e){return this.declaration=e,this}initChildren(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.declaration=C(this.initialData.declaration,this.project),this.successCalls=this.initialData.successCalls.map(t=>{const i=C(t,this.project);if(i.addSuccessCaller(this),[n.BreakStatement,n.ContinueStatement].includes(i.type))i.setParent(this.parent.parent,null),i.initChildren(e);else if(i.type===n.ReturnStatement){const s=It(this,this.project);i.setParent(s,null),i.initChildren(e)}else i.type!==n.InternalCall&&(i.setParent(this.parent,null),i.initChildren(e));return i}),this.errorCalls=this.initialData.errorCalls.map(t=>{const i=C(t,this.project);if(i.addErrorCaller(this),[n.BreakStatement,n.ContinueStatement].includes(i.type))i.setParent(this.parent.parent,null),i.initChildren(e);else if(i.type===n.ReturnStatement){const s=It(this,this.project);i.setParent(s,null),i.initChildren(e)}else i.type!==n.InternalCall&&(i.setParent(this.parent,null),i.initChildren(e));return i}),this.inputs=this.initialData.inputs.map(t=>{const i=C(t,this.project);return i.setParent(this,null),i.initChildren(e),i}),this.outputs=this.initialData.outputs.map(t=>{const i=C(t,this.project);return i.setParent(this,null),i.initChildren(e),i}),this.initialData.process&&(this.process=C(this.initialData.process,this.project),this.process.setParent(this,null),this.process.initChildren(e)),this.initialData.body&&(this.body=C(this.initialData.body,this.project),this.body.setParent(this,null),this.body.initChildren(e)),this.initialData.error&&(this.error=C(this.initialData.error,this.project),this.error.setParent(this,null),this.error.initChildren(e)),this.subscribeToDependencies(),this.afterAllChildrenInitialized(e),e==null||e.attemptAutoclose("init-children",this.id),this)}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(e,t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"meta-sync"))){const i=pt(this,e),s=this.toMeta();return this.x=e.x||s.x,this.y=e.y||s.y,super.metaSync(e),e.deleted===!0&&!s.deleted?t==null||t.add(this,A.Removed):e.deleted===!1&&s.deleted?t==null||t.add(this,A.Added):i&&(t==null||t.add(this,A.Updated)),t==null||t.attemptAutoclose("meta-sync",this.id),this}async APILoad(e=U,...t){return await oe.repository.APILoad(this.id,...t),this}async APICreate(e=U,...t){return await oe.repository.APICreate(this.toShallowJSON(),...t),this}async APIUpdate(e=U,...t){return await oe.repository.APIUpdate(this.toShallowJSON(),...t),this}async APIDelete(e=U,...t){return await oe.repository.APIDelete(this.toShallowJSON(),...t),this}async APIClone(e=U,...t){return await oe.repository.APIClone(this.id,...t),this}async APILoadVersion(e=U,t,...i){return await oe.repository.APILoadVersion(this.id,t,...i)}remove({ignoreUpstream:e}={ignoreUpstream:!1},t=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"remove-entity"))){const i=[],s=[],l=[],o=[];if(t!=null&&t.hasRemoved(this.id))return t==null||t.attemptAutoclose("remove-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(s.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},t),Object.values(this.detachedDependents).forEach(d=>{const{updated:u,removed:h,added:c}=d.entity.onDetachedDependencyRemoved(this,d.field,t);i.push(...u),s.push(...h),l.push(...c)}),this.inputs.forEach(d=>{const{updated:u,removed:h}=d.remove({ignoreUpstream:!0},t);i.push(...u),s.push(...h)}),this.outputs.forEach(d=>{const{updated:u,removed:h}=d.remove({ignoreUpstream:!0},t);i.push(...u),s.push(...h)}),this.body.remove({ignoreUpstream:!0},t),this.error){const{updated:d,removed:u}=this.error.remove({ignoreUpstream:!0},t);i.push(...d),s.push(...u)}return this.successCalls.forEach(d=>{i.push(d),d.removeCaller(this,t)}),this.errorCalls.forEach(d=>{i.push(d),d.removeCaller(this,t)}),e||this.calledBy.forEach(d=>{i.push(d),d.removeCall(this,t)}),t==null||t.attemptAutoclose("remove-entity",this.id),{added:p(l),updated:p(i),removed:p(s),affected:p(o),self:this}}restore({}={},e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"restore-entity"))){const t=[],i=[],s=[],l=[];return e!=null&&e.hasAdded(this.id)?(e==null||e.attemptAutoclose("restore-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this}):(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},e),this.inputs.forEach(o=>{const{updated:d}=o.restore({},e);i.push(...d)}),this.outputs.forEach(o=>{const{updated:d}=o.restore({},e);i.push(...d)}),this.body.restore({},e),this.successCalls.forEach(o=>{i.push(o),o.addSuccessCaller(this,e)}),this.errorCalls.forEach(o=>{i.push(o),o.addErrorCaller(this,e)}),this.calledBySuccess.forEach(o=>{i.push(o),o.addSuccessCall(this,e)}),this.calledByError.forEach(o=>{i.push(o),o.addErrorCall(this,e)}),this.calledByEntry.forEach(o=>{i.push(o),o.addCall(this,e)}),e==null||e.attemptAutoclose("restore-entity",this.id),{added:p(t),updated:p(i),removed:p(s),affected:p(l),self:this})}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.inputs.flatMap(i=>i.toFlat(e)),...this.outputs.flatMap(i=>i.toFlat(e)),...this.outputsDeclarations.flatMap(i=>i.toFlat(e)),...this.process?this.process.toFlat(e):[],...this.successCalls.flatMap(i=>i.toFlat(e)),...this.errorCalls.flatMap(i=>i.toFlat(e)),...this.error?this.error.toFlat(e):[],...this.body?this.body.toFlat(e):[],...this.continueStatements.flatMap(i=>i.toFlat(e)),...this.breakStatements.flatMap(i=>i.toFlat(e))])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.inputs.flatMap(i=>i.toFlatIds(e)),...this.outputs.flatMap(i=>i.toFlatIds(e)),...this.process?this.process.toFlatIds(e):[],...this.successCalls.flatMap(i=>i.toFlatIds(e)),...this.errorCalls.flatMap(i=>i.toFlatIds(e)),...this.error?this.error.toFlatIds(e):[],...this.body?this.body.toFlatIds(e):[],...this.continueStatements.flatMap(i=>i.toFlatIds(e)),...this.breakStatements.flatMap(i=>i.toFlatIds(e))])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,x:this.x,y:this.y,type:this.type}}toJSON(e=new Set){var t,i;return e.has(this.id)?this.toReference():(e.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,x:this.x,y:this.y,calledBySuccess:this.calledBySuccess.map(s=>s.toReference()),calledByError:this.calledByError.map(s=>s.toReference()),calledByEntry:this.calledByEntry.map(s=>s.toReference()),process:((t=this.process)==null?void 0:t.toJSON(e))||null,declaration:this.declaration.toJSON(e),inputs:this.inputs.map(s=>s.toJSON(e)),outputs:this.outputs.map(s=>s.toJSON(e)),outputsDeclarations:this.outputsDeclarations.map(s=>s.toJSON(e)),successCalls:this.successCalls.map(s=>s.toJSON(e)),errorCalls:this.errorCalls.map(s=>s.toJSON(e)),error:((i=this.error)==null?void 0:i.toJSON(e))||null,body:this.body.toJSON(e),parent:this.parent.toReference()})}toJSONClone(e=J){var i,s,l,o,d,u,h;let t;return(i=e.seenEntityMaps)!=null&&i.has(this.id)?t=e.seenEntityMaps.get(this.id):(t=e.newId||yt(this,this.project,e.uuidStrategy),e.seenEntityMaps&&e.seenEntityMaps.set(this.id,t)),(s=e.seenEntities)!=null&&s.has(t)||(l=e.seenEntities)!=null&&l.has(this.id)?this.toReference({seenEntityMaps:e.seenEntityMaps}):((o=e.seenEntities)==null||o.add(t),(d=e.seenEntities)==null||d.add(this.id),{id:t,version:m.UUID.uuid(),createdAt:e.timestamp||T().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,x:this.x,y:this.y,calledBySuccess:this.calledBySuccess.map(c=>c.toReference({seenEntityMaps:e.seenEntityMaps})),calledByError:this.calledByError.map(c=>c.toReference({seenEntityMaps:e.seenEntityMaps})),calledByEntry:this.calledByEntry.map(c=>c.toReference({seenEntityMaps:e.seenEntityMaps})),process:((u=this.process)==null?void 0:u.toJSONClone({...e,newId:null}))||null,declaration:this.declaration.toJSON(),inputs:this.inputs.map(c=>c.toJSONClone({...e,newId:null})),outputs:this.outputs.map(c=>c.toJSONClone({...e,newId:null})),outputsDeclarations:this.outputsDeclarations.map(c=>c.toJSONClone({...e,newId:null})),successCalls:this.successCalls.map(c=>c.toJSONClone({...e,newId:null})),errorCalls:this.errorCalls.map(c=>c.toJSONClone({...e,newId:null})),error:((h=this.error)==null?void 0:h.toJSONClone({...e,newId:null}))||null,body:this.body.toJSONClone({...e,newId:null}),parent:this.parent.toReference({seenEntityMaps:e.seenEntityMaps})})}toReference(e=J){var i;let t=this.id;return(i=e.seenEntityMaps)!=null&&i.has(this.id)&&(t=e.seenEntityMaps.get(this.id)),{id:t+"--"+m.UUID.uuid()+"--ref",type:n.GenericReference,entityId:t,version:this.version,entityType:this.type}}toShallowJSON(e=J){var i,s,l,o,d;let t=this.id;return(i=e.seenEntityMaps)!=null&&i.has(this.id)&&(t=e.seenEntityMaps.get(this.id)),{id:t,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,x:this.x,y:this.y,declaration:((s=this.declaration)==null?void 0:s.toReference(e))||null,body:((l=this.body)==null?void 0:l.toReference(e))||null,inputs:this.inputs.map(u=>u.toReference(e)),outputs:this.outputs.map(u=>u.toReference(e)),outputsDeclarations:this.outputsDeclarations.map(u=>u.toReference(e)),successCalls:this.successCalls.map(u=>u.toReference(e)),errorCalls:this.errorCalls.map(u=>u.toReference(e)),process:((o=this.process)==null?void 0:o.toReference(e))||null,calledBySuccess:this.calledBySuccess.map(u=>u.toReference(e)),calledByError:this.calledByError.map(u=>u.toReference(e)),calledByEntry:this.calledByEntry.map(u=>u.toReference(e)),error:((d=this.error)==null?void 0:d.toReference(e))||null,parent:this.parent.toReference(e)}}toFlatJSON(e=new Set){var i;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((i=this.body)==null?void 0:i.toFlatJSON(e))||[],...this.successCalls.flatMap(s=>s.toFlatJSON(e)),...this.errorCalls.flatMap(s=>s.toFlatJSON(e)),...this.inputs.flatMap(s=>s.toFlatJSON(e)),...this.outputs.flatMap(s=>s.toFlatJSON(e)),...this.continueStatements.flatMap(s=>s.toFlatJSON(e)),...this.breakStatements.flatMap(s=>s.toFlatJSON(e)),...this.error?this.error.toFlatJSON(e):[],...this.process?this.process.toFlatJSON(e):[]])}toGenerationTarget(){const e=this.parent.type===n.Project?void 0:this.parent.id;return{id:this.id,type:this.type,calledByEntry:this.calledByEntry.map(t=>t.id),calledBySuccess:this.calledBySuccess.map(t=>t.id),calledByError:this.calledByError.map(t=>t.id),declaration:this.declaration.id,parent:e}}toFlatGenerationTarget(e=new Set){var i;return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...((i=this.body)==null?void 0:i.toFlatGenerationTarget(e))||[],...this.successCalls.flatMap(s=>s.toFlatGenerationTarget(e)),...this.errorCalls.flatMap(s=>s.toFlatGenerationTarget(e)),...this.inputs.flatMap(s=>s.toFlatGenerationTarget(e)),...this.outputs.flatMap(s=>s.toFlatGenerationTarget(e)),...this.continueStatements.flatMap(s=>s.toFlatGenerationTarget(e)),...this.breakStatements.flatMap(s=>s.toFlatGenerationTarget(e)),...this.error?this.error.toFlatGenerationTarget(e):[],...this.process?this.process.toFlatGenerationTarget(e):[]])}clearErrors(){var e,t;return this.errors=[],this.inputs.forEach(i=>i.clearErrors()),this.outputs.forEach(i=>i.clearErrors()),this.successCalls.forEach(i=>i.clearErrors()),this.errorCalls.forEach(i=>i.clearErrors()),this.continueStatements.forEach(i=>i.clearErrors()),this.breakStatements.forEach(i=>i.clearErrors()),(e=this.process)==null||e.clearErrors(),(t=this.error)==null||t.clearErrors(),this}validate(){const e=Lc(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.inputs.flatMap(t=>t.getErrors()),...this.outputs.flatMap(t=>t.getErrors()),...this.body?this.body.getErrors():[],...this.error?this.error.getErrors():[],...this.process?this.process.getErrors():[]]}getShallowErrors(){return this.errors}clone(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"clone-entity")),t=null,i=null,s=!0){var D,P;let l=mt(t,this);const o=this.toJSON(),d=i||m.UUID.uuid();o.inputs=[];const u=d.split("-id"),h=u[u.length-1||0]||d;o.id=d,o.version=m.UUID.uuid(),o.createdAt=(e==null?void 0:e.timestamp)||T().toISOString(),o.author=(e==null?void 0:e.author)||"1",o.previousVersion=null,o.deleted=!1;const c=st(o,l);t?c.setParent(t,null):c.setParent(this.parent,null),s&&c.subscribe(),c.initChildren(e),e==null||e.add(c,A.Added);const E=(D=this.inputs)==null?void 0:D.map((V,M)=>V.clone(e,c,h+"-input-map-"+M+"-id",s));c.inputs=E;const I=(P=this.outputs)==null?void 0:P.map((V,M)=>V.clone(e,c,h+"-output-map-"+M+"-id",s));return c.outputs=I,this.body&&(c.body=this.body.clone(e,c,h+"-body-id",s,!0)),this.error&&(c.error=this.error.clone(e,c,h+"-error-map-id",s)),this.process&&(c.process=this.process.clone(e,c,h+"-process-id",s)),e==null||e.attemptAutoclose("clone-entity",this.id),c}getVariableInstances(){return this.body?He(this.body).filter(i=>i.type===n.VariableInstance):[]}addReturnStatement(e){return rt.includes(this.parent.type)&&this.parent.addReturnStatement(e),this}removeReturnStatement(e){return rt.includes(this.parent.type)&&this.parent.removeReturnStatement(e),this}addBreakStatement(e){return this.breakStatements.includes(e)||this.breakStatements.push(e),this}removeBreakStatement(e){const t=this.breakStatements.indexOf(e);return t!==-1&&this.breakStatements.splice(t,1),this}addContinueStatement(e){return this.continueStatements.includes(e)||this.continueStatements.push(e),this}removeContinueStatement(e){const t=this.continueStatements.indexOf(e);return t!==-1&&this.continueStatements.splice(t,1),this}getUniqueReturnDeclarations(){const e=[];return[...this.breakStatements,...this.continueStatements].forEach(i=>{i.outputs.forEach(l=>{e.find(d=>d===l||x(d,this.project)===x(l,this.project)&&wi(d.dataType,l.dataType))||e.push(l)})}),p(e)}syncTerminationStatements(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"sync-termination-statements"))){const t=[],i=[],s=[],l=[],o=this.getUniqueReturnDeclarations();return[...this.breakStatements,...this.continueStatements].forEach(u=>{const h=u.outputs,c=o.filter(E=>!h.find(I=>x(E,this.project)===x(I,this.project)&&wi(E.dataType,I.dataType)));c.length&&(t.push(u),e==null||e.add(u,A.Updated)),c.forEach(E=>{const I=E.clone(e,u);e==null||e.add(I,A.Added),I.addSelfToProject(e),i.push(I)})}),e==null||e.attemptAutoclose("sync-termination-statements",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}syncBodyInputIndexes(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"sync-body-input-indexes"))){const t=[],i=[],s=[],l=[];return this.body.inputs.sort((d,u)=>d.index-u.index),this.body.inputs.forEach((d,u)=>{d.index!==u&&(d.metaSync({index:u},e),t.push(d))}),e==null||e.attemptAutoclose("sync-body-input-indexes",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}syncBodyArgumentsDeclarations(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"sync-body-arguments-declarations"))){const t=[],i=[],s=[],l=[],{updated:o,added:d,removed:u}=this.syncFixedBodyArgumentDeclarations(e);t.push(...o),i.push(...d),s.push(...u);const h=this.getUniqueReturnDeclarations(),c=this.body.inputs;h.sort((P,V)=>P.index-V.index),h.forEach(P=>{const V=P.getDataType(e);let g=c.find(pe=>x(pe,this.project)===oe.fromReturnDeclarationToBodyArgumentDeclarationName(P)&&wi(pe.dataType,P.dataType));if(!g){const pe=oe.fromReturnDeclarationToBodyArgumentDeclarationName(P),Ee={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.ArgumentDeclaration,name:pe,description:`Aggretated list of all previously outputted values from each iteration by the output '${x(P,this.project)}'`,defaultValue:null,constant:!0,dataType:null,implements:null,index:P.index,required:P.required,parent:this.body.toReference(),writesValues:[]},Q=C(Ee,this.project);Q.setParent(this.body,e),Q.initChildren(e),e==null||e.add(Q,A.Added),Q.addSelfToProject(e),i.push(Q),g=Q}const B=this.body.inputs.find(pe=>pe.index===g.index&&pe!==g),G=this.body.inputs.filter(pe=>pe!==g);let q=g.index;B&&(q=Math.max(...G.map(pe=>pe.index))+1),g.index!==q&&(g.metaSync({index:q},e),t.push(g));const S=g.getDataType(e);let X=S;if(V)if(!S||!wi(S,V)){if(!X){const Ee=V.clone(e,g);e==null||e.add(Ee,A.Added),Ee.addSelfToProject(e),X=Ee,i.push(Ee),t.push(g)}const pe=X.merge(V,e);pe.self===X?V.remove({ignoreUpstream:!1},e):pe.self===V&&(X.remove({ignoreUpstream:!1},e),X=V),X.metaSync({isList:!0},e)}else X.isList||(X.metaSync({isList:!0},e),t.push(X));if(!V&&!X){const pe={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.DataType,options:[],implementationChooseOne:!1,parentRelationType:null,staticEntities:null,interactiveEntities:null,actionEntities:null,isList:!0,entity:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:g.toReference()},Ee=C(pe,this.project);Ee.metaSync({isList:!0},e),Ee.setParent(g,e),Ee.initChildren(e),e==null||e.add(Ee,A.Added),Ee.addSelfToProject(e),i.push(Ee)}});const{updated:E,added:I,removed:D}=this.removeExtraBodyArgumentDeclarations(e);return t.push(...E),i.push(...I),s.push(...D),e==null||e.attemptAutoclose("sync-body-arguments-declarations",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}syncOutputsDeclarations(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"sync-outputs-declarations"))){const t=[],i=[],s=[],l=[],o=this.getUniqueReturnDeclarations(),d=this.outputsDeclarations;o.forEach((h,c)=>{h.index!==c&&(h.metaSync({index:c},e),t.push(h))}),o.forEach(h=>{const c=h.getDataType(e);let I=d.find(V=>x(V,this.project)===oe.fromReturnDeclarationToLoopOutputDeclarationName(h)&&wi(V.dataType,h.dataType));if(!I){const V=oe.fromReturnDeclarationToLoopOutputDeclarationName(h),M={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.ValueDescriptor,name:V,description:`Aggretated list of all previously outputted values from each iteration by the output '${x(h,this.project)}'`,defaultValue:null,dataType:null,index:h.index,required:h.required,parentRelationType:L.FixedReturns,parent:this.toReference()},g=C(M,this.project);g.setParent(this,e),g.initChildren(e),e==null||e.add(g,A.Added),g.addSelfToProject(e),i.push(g),I=g}I.index!==h.index&&(I.metaSync({index:h.index},e),t.push(I));let P=I.getDataType(e);if(c)if(!P||!wi(P,c)){if(!P){const M=c.clone(e,I);e==null||e.add(M,A.Added),M.addSelfToProject(e),P=M,i.push(M),t.push(I)}const V=P.merge(c,e);V.self===P?c.remove({ignoreUpstream:!1},e):V.self===c&&(P.remove({ignoreUpstream:!1},e),P=c),P.metaSync({isList:!0},e)}else P.isList||(P.metaSync({isList:!0},e),t.push(P));if(!c&&!P){const V={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.DataType,options:[],implementationChooseOne:!1,staticEntities:null,interactiveEntities:null,actionEntities:null,parentRelationType:null,isList:!0,entity:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:I.toReference()},M=C(V,this.project);M.metaSync({isList:!0},e),M.setParent(I,e),M.initChildren(e),e==null||e.add(M,A.Added),M.addSelfToProject(e),i.push(M)}}),console.log("uniqueReturnDeclarations: ",o);const u=d.filter(h=>{const c=o.find(E=>{const I=x(E,this.project),D=oe.fromReturnDeclarationToLoopOutputDeclarationName(E);return console.log("resolvedName",I),console.log("nameToMatch",D),x(h,this.project)===oe.fromReturnDeclarationToLoopOutputDeclarationName(E)});return console.log("foundMatchingReturn",c),!c});return console.log("outputDeclarationsToRemove",u),u.forEach(h=>{if(!(e!=null&&e.hasRemoved(h.id))&&!h.deleted){const{updated:c,removed:E}=h.remove({ignoreUpstream:!1},e);t.push(...c),s.push(...E)}}),e==null||e.attemptAutoclose("sync-outputs-declarations",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}syncOutputMaps(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"add-extended-properties"))){const t=[],i=[],s=[],l=[],o=this.outputsDeclarations,d=this.outputs;return o.forEach(h=>{var I;let E=d.find(D=>{var P,V;return((P=D.declaration)==null?void 0:P.id)===h.id&&wi((V=D.declaration)==null?void 0:V.dataType,h.dataType)});if(E)((I=E.declaration)==null?void 0:I.id)!==h.id&&(E.setDeclaration(h),t.push(E));else{const D={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.OutputMap,defaultValue:null,index:h.index,declaration:h.toJSON(),writesValues:[],parent:this.toReference()},P=C(D,this.project);P.setParent(this,e),P.initChildren(e),e==null||e.add(P,A.Added),P.addSelfToProject(e),i.push(P),E=P}E.index!==h.index&&(E.metaSync({index:h.index},e),t.push(E))}),d.filter(h=>!o.find(E=>{var I;return((I=h.declaration)==null?void 0:I.id)===E.id})).forEach(h=>{const{updated:c,removed:E}=h.remove({ignoreUpstream:!1},e);t.push(...c),s.push(...E)}),e==null||e.attemptAutoclose("add-extended-properties",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}createCurrentIterationNumberArgumentDeclaration(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"create-current-iteration-number-argument-declaration"))){const t=[],i=[],s=[],l=[];let d=this.body.inputs.find(E=>{var I;return E.name===oe.CURRENT_ITERATION_NUMBER_ARG_NAME||E.id===((I=this.currentIterationNumberArgumentDeclaration)==null?void 0:I.id)});const u=this.getCurrentIterationNumberBuiltInValueDescriptor();if(!d){const E={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.ArgumentDeclaration,name:oe.CURRENT_ITERATION_NUMBER_ARG_NAME,description:"The number of the current iteration",defaultValue:null,constant:!0,dataType:null,implements:u==null?void 0:u.toJSON(),index:this.body.inputs.length,required:!0,parent:this.body.toReference(),writesValues:[]},I=C(E,this.project);I.setParent(this.body,e),I.initChildren(e),e==null||e.add(I,A.Added),I.addSelfToProject(e),i.push(I),d=I}!d.index&&d.index!==0&&(d.metaSync({index:0},e),t.push(d)),(!d.implements||d.implements.id!==u.id)&&(d.setImplements(u,e),t.push(d));let c=d.getDataType(e);if(!c){const E={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.DataType,options:[],implementationChooseOne:!1,staticEntities:null,interactiveEntities:null,actionEntities:null,parentRelationType:null,isList:!1,entity:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:d.toReference()},I=C(E,this.project);I.setParent(d,e),I.initChildren(e),e==null||e.add(I,A.Added),I.addSelfToProject(e),i.push(I),c=I}if(!c.entity||c.entity.type!==n.PrimitiveEntity||c.entity.name!==N.Number||c.entity.id!==k["primitive-entity"].number.id){const E=this.project.getBuiltIn(k["primitive-entity"].number.id);c.setEntity(E),t.push(c)}return this.currentIterationNumberArgumentDeclaration=d,e==null||e.attemptAutoclose("create-current-iteration-number-argument-declaration",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}removeExtraBodyArgumentDeclarations(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"remove-extra-body-argument-declarations"))){const t=[],i=[],s=[],l=[],o=this.body.inputs,d=this.getUniqueReturnDeclarations();return o.filter(h=>h===this.currentIterationNumberArgumentDeclaration||h===this.currentValueArgumentDeclaration?!1:!d.find(E=>x(h,this.project)===oe.fromReturnDeclarationToBodyArgumentDeclarationName(E))).forEach(h=>{const{updated:c,removed:E}=h.remove({ignoreUpstream:!1},e);t.push(...c),s.push(...E)}),e==null||e.attemptAutoclose("remove-extra-body-argument-declarations",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}createCurrentValueInputBasedOnInputMap(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"create-current-value-input-based-on-input-map"))){var h,c,E,I,D;const t=[],i=[],s=[],l=[];switch(this.declaration.id){case ee.List:{const P=this.body.inputs.find(g=>{var B;return((B=g.implements)==null?void 0:B.id)===k[n.Loop][ee.List].body.inputs.currentValue.id}),V=this.inputs.find(g=>{var B;return((B=g.declaration)==null?void 0:B.id)===k[n.Loop][ee.List].inputs.list.id});if(!V)break;const M=this.getCurrentValueBuiltInValueDescriptor();if(P){this.currentValueArgumentDeclaration=P;const g=this.project.get(k[n.Loop][ee.List].inputs.list.id);M&&(!P.implements||P.implements.id!==M.id)&&(P.setImplements(M,e),t.push(P));let G=P.getDataType(e);if(!G){const S={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.DataType,options:[],implementationChooseOne:!1,parentRelationType:null,staticEntities:null,interactiveEntities:null,actionEntities:null,isList:!1,entity:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:g.toReference()},X=C(S,this.project);X.setParent(g,e),X.initChildren(e),e==null||e.add(X,A.Added),X.addSelfToProject(e),i.push(X),G=X}const q=V.getDataType(e);G.merge(q,e),G.metaSync({isList:!1},e)}else{const g={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.ArgumentDeclaration,name:oe.CURRENT_VALUE_ARG_NAME,description:null,defaultValue:null,index:this.body.inputs.length,constant:!0,required:!0,implements:M,writesValues:[],dataType:null,parent:this.body.toReference()},B=C(g,this.project);B.setParent(this.body,e),B.initChildren(e),e==null||e.add(B,A.Added),B.addSelfToProject(e),M&&(!B.implements||B.implements.id!==M.id)&&(B.setImplements(M,e),t.push(B)),i.push(B),this.currentValueArgumentDeclaration=B}break}case ee.ManualFlow:{this.currentValueArgumentDeclaration=null;break}case ee.Counted:{this.currentValueArgumentDeclaration=null;break}case ee.ObjectKeys:{const P=this.body.inputs.find(g=>{var B;return((B=g.implements)==null?void 0:B.id)===k[n.Loop][ee.ObjectKeys].body.inputs.currentValue.id});if(!this.inputs.find(g=>{var B;return((B=g.declaration)==null?void 0:B.id)===k[n.Loop][ee.ObjectKeys].inputs.object.id}))break;const M=this.getCurrentValueBuiltInValueDescriptor();if(P){this.currentValueArgumentDeclaration=P;const g=this.project.get(k[n.Loop][ee.ObjectKeys].inputs.object.id);M&&(!P.implements||P.implements.id!==M.id)&&(P.setImplements(M),t.push(P));let G=P.getDataType(e);if(G){const q=this.project.getBuiltIn(k["primitive-entity"].string.id);((h=G.entity)==null?void 0:h.id)!==q.id&&(G.setEntity(q),t.push(G))}else{const q={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.DataType,options:[],implementationChooseOne:!1,parentRelationType:null,staticEntities:null,interactiveEntities:null,actionEntities:null,isList:!1,entity:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:g.toReference()},S=C(q,this.project);S.setParent(g,e),S.initChildren(e),e==null||e.add(S,A.Added),S.addSelfToProject(e),G=S}}else{const g={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.ArgumentDeclaration,name:oe.CURRENT_VALUE_ARG_NAME,description:null,defaultValue:null,index:this.body.inputs.length,constant:!0,required:!0,implements:M,writesValues:[],dataType:null,parent:this.body.toReference()},B=C(g,this.project);B.setParent(this.body,e),B.initChildren(e),e==null||e.add(B,A.Added),B.addSelfToProject(e),M&&(!B.implements||B.implements.id!==M.id)&&(B.setImplements(M,e),t.push(B)),i.push(B),this.currentValueArgumentDeclaration=B}break}case ee.ObjectValues:{const P=this.body.inputs.find(g=>{var B;return((B=g.implements)==null?void 0:B.id)===k[n.Loop][ee.ObjectValues].body.inputs.currentValue.id}),V=this.inputs.find(g=>{var B;return((B=g.declaration)==null?void 0:B.id)===k[n.Loop][ee.ObjectValues].inputs.object.id});if(!V)break;const M=this.getCurrentValueBuiltInValueDescriptor();if(P){this.currentValueArgumentDeclaration=P;const g=this.project.get(k[n.Loop][ee.ObjectValues].inputs.object.id);M&&(!P.implements||P.implements.id!==M.id)&&(P.setImplements(M,e),t.push(P));let G=P.getDataType(e);if(G){const q=V.getDataType(e),S=((E=q==null?void 0:q.entity)==null?void 0:E.properties)||[];(I=G.orChildrenGroup)==null||I.forEach(X=>{const{updated:pe,removed:Ee}=X.remove({ignoreUpstream:!1},e);t.push(...pe),s.push(...Ee)}),S.forEach(X=>{if(!X.getDataType(e)){const Ee={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.DataType,options:[],implementationChooseOne:!1,staticEntities:null,interactiveEntities:null,actionEntities:null,isList:!1,entity:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parentRelationType:Pt.OrDataTypeGroup,parent:G.toReference()},Q=C(Ee,this.project);Q.setParent(G,e),Q.initChildren(e),e==null||e.add(Q,A.Added),Q.addSelfToProject(e),i.push(Q)}})}else{const q={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.DataType,options:[],implementationChooseOne:!1,parentRelationType:null,staticEntities:null,interactiveEntities:null,actionEntities:null,isList:!1,entity:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:g.toReference()},S=C(q,this.project);S.setParent(g,e),S.initChildren(e),e==null||e.add(S,A.Added),S.addSelfToProject(e),G=S;const X=V.getDataType(e);(((c=X==null?void 0:X.entity)==null?void 0:c.properties)||[]).forEach(Ee=>{if(!Ee.getDataType(e)){const le={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.DataType,options:[],implementationChooseOne:!1,staticEntities:null,interactiveEntities:null,actionEntities:null,isList:!1,entity:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parentRelationType:Pt.OrDataTypeGroup,parent:S.toReference()},ri=C(le,this.project);ri.setParent(S,e),ri.initChildren(e),e==null||e.add(ri,A.Added),ri.addSelfToProject(e),i.push(ri)}})}}else{const g={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.ArgumentDeclaration,name:oe.CURRENT_VALUE_ARG_NAME,description:null,constant:!0,defaultValue:null,index:this.body.inputs.length,required:!0,implements:M,writesValues:[],dataType:null,parent:this.body.toReference()},B=C(g,this.project);B.setParent(this.body,e),B.initChildren(e),e==null||e.add(B,A.Added),B.addSelfToProject(e),M&&(!B.implements||B.implements.id!==M.id)&&(B.setImplements(M,e),t.push(B)),i.push(B),this.currentValueArgumentDeclaration=B}break}case ee.String:{const P=this.body.inputs.find(g=>{var B;return((B=g.implements)==null?void 0:B.id)===k[n.Loop][ee.String].body.inputs.currentValue.id});if(!this.inputs.find(g=>{var B;return((B=g.declaration)==null?void 0:B.id)===k[n.Loop][ee.String].inputs.string.id}))break;const M=this.getCurrentValueBuiltInValueDescriptor();if(P){this.currentValueArgumentDeclaration=P;const g=this.project.get(k[n.Loop]["string-loop"].inputs.string.id);M&&(!P.implements||P.implements.id!==M.id)&&(P.setImplements(M,e),t.push(P));let G=P.getDataType(e);if(G){const q=this.project.getBuiltIn(k["primitive-entity"].string.id);((D=G.entity)==null?void 0:D.id)!==q.id&&(G.setEntity(q),t.push(G))}else{const q={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.DataType,options:[],implementationChooseOne:!1,parentRelationType:null,staticEntities:null,interactiveEntities:null,actionEntities:null,isList:!1,entity:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:g.toReference()},S=C(q,this.project);S.setParent(g,e),S.initChildren(e),e==null||e.add(S,A.Added),S.addSelfToProject(e),i.push(S),G=S}}else{const g={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.ArgumentDeclaration,name:oe.CURRENT_VALUE_ARG_NAME,description:null,index:this.body.inputs.length,required:!0,constant:!0,defaultValue:null,implements:M,writesValues:[],dataType:null,parent:this.body.toReference()},B=C(g,this.project);B.setParent(this.body,e),B.initChildren(e),e==null||e.add(B,A.Added),B.addSelfToProject(e),M&&(!B.implements||B.implements.id!==M.id)&&(B.setImplements(M,e),t.push(B)),i.push(B),this.currentValueArgumentDeclaration=B}break}}const{updated:o,added:d,removed:u}=this.removeExtraBodyArgumentDeclarations(e);return t.push(...o),i.push(...d),s.push(...u),e==null||e.attemptAutoclose("create-current-value-input-based-on-input-map",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}syncFixedBodyArgumentDeclarations(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"sync-fixed-body-argument-declarations"))){const t=[],i=[],s=[],l=[],{updated:o,added:d,removed:u}=this.createCurrentIterationNumberArgumentDeclaration(e);t.push(...o),i.push(...d),s.push(...u);const{updated:h,added:c,removed:E}=this.createCurrentValueInputBasedOnInputMap(e);return t.push(...h),i.push(...c),s.push(...E),e==null||e.attemptAutoclose("sync-fixed-body-argument-declarations",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}syncInputMaps(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"sync-input-maps"))){const t=[],i=[],s=[],l=[];switch(this.declaration.id){case ee.List:{let o=null;if(this.inputs.forEach(d=>{var u;((u=d.declaration)==null?void 0:u.id)===k[n.Loop]["list-loop"].inputs.list.id?o=d:(d.remove({ignoreUpstream:!1},e),s.push(d))}),o){if(o.declaration.id!==k[n.Loop]["list-loop"].inputs.list.id){const d=this.project.get(k[n.Loop]["list-loop"].inputs.list.id);o.setDeclaration(d),t.push(o)}}else{const d=this.project.get(k[n.Loop]["list-loop"].inputs.list.id),u={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.InputMap,name:null,description:null,index:0,declaration:d.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},h=C(u,this.project);h.setParent(this,e),h.initChildren(e),e==null||e.add(h,A.Added),h.addSelfToProject(e),i.push(h)}break}case ee.ManualFlow:{this.inputs.forEach(o=>{o.remove({ignoreUpstream:!1},e),s.push(o)});break}case ee.Counted:{let o=null;if(this.inputs.forEach(d=>{var u;((u=d.declaration)==null?void 0:u.id)===k[n.Loop]["counted-loop"].inputs.number.id?o=d:(d.remove({ignoreUpstream:!1},e),s.push(d))}),o){if(o.declaration.id!==k[n.Loop]["counted-loop"].inputs.number.id){const d=this.project.get(k[n.Loop]["counted-loop"].inputs.number.id);o.setDeclaration(d),t.push(o)}}else{const d=this.project.get(k[n.Loop]["counted-loop"].inputs.number.id),u={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.InputMap,name:null,description:null,index:0,declaration:d.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},h=C(u,this.project);h.setParent(this,e),h.initChildren(e),e==null||e.add(h,A.Added),h.addSelfToProject(e),i.push(h)}break}case ee.ObjectKeys:{let o=null;if(this.inputs.forEach(d=>{var u;((u=d.declaration)==null?void 0:u.id)===k[n.Loop]["object-keys-loop"].inputs.object.id?o=d:(d.remove({ignoreUpstream:!1},e),s.push(d))}),o){if(o.declaration.id!==k[n.Loop]["object-keys-loop"].inputs.object.id){const d=this.project.get(k[n.Loop]["object-keys-loop"].inputs.object.id);o.setDeclaration(d),t.push(o)}}else{const d=this.project.get(k[n.Loop]["object-keys-loop"].inputs.object.id),u={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.InputMap,name:null,description:null,index:0,declaration:d.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},h=C(u,this.project);h.setParent(this,e),h.initChildren(e),e==null||e.add(h,A.Added),h.addSelfToProject(e),i.push(h)}break}case ee.ObjectValues:{let o=null;if(this.inputs.forEach(d=>{var u;((u=d.declaration)==null?void 0:u.id)===k[n.Loop]["object-values-loop"].inputs.object.id?o=d:(d.remove({ignoreUpstream:!1},e),s.push(d))}),o){if(o.declaration.id!==k[n.Loop]["object-values-loop"].inputs.object.id){const d=this.project.get(k[n.Loop]["object-values-loop"].inputs.object.id);o.setDeclaration(d),t.push(o)}}else{const d=this.project.get(k[n.Loop]["object-values-loop"].inputs.object.id),u={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.InputMap,name:null,description:null,index:0,declaration:d.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},h=C(u,this.project);h.setParent(this,e),h.initChildren(e),e==null||e.add(h,A.Added),h.addSelfToProject(e),i.push(h)}break}case ee.String:{let o=null;if(this.inputs.forEach(d=>{var u;((u=d.declaration)==null?void 0:u.id)===k[n.Loop]["string-loop"].inputs.string.id?o=d:(d.remove({ignoreUpstream:!1},e),s.push(d))}),o){if(o.declaration.id!==k[n.Loop]["string-loop"].inputs.string.id){const d=this.project.get(k[n.Loop]["string-loop"].inputs.string.id);o.setDeclaration(d),t.push(o)}}else{const d=this.project.get(k[n.Loop]["string-loop"].inputs.string.id),u={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.InputMap,name:null,description:null,index:0,declaration:d.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},h=C(u,this.project);h.setParent(this,e),h.initChildren(e),e==null||e.add(h,A.Added),h.addSelfToProject(e),i.push(h)}break}}return e==null||e.attemptAutoclose("sync-input-maps",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(l),self:this}}getCurrentValueBuiltInValueDescriptor(){var t;const e=(t=k[n.Loop][this.declaration.id].body.inputs.currentValue)==null?void 0:t.id;return e?this.project.get(e):null}getCurrentIterationNumberBuiltInValueDescriptor(){const e=k[n.Loop][this.declaration.id].body.inputs.iterationNumber.id;return this.project.get(e)}syncBody(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"sync-body"))){var u;const t=[],i=[],s=[],l=[],o=k[n.Loop][this.declaration.id].body.id,d=this.project.getBuiltIn(o);if(this.body)((u=this.body.implements)==null?void 0:u.id)!==d.id&&(this.body.setImplements(d,e),this.body.setParent(this,e),t.push(this.body));else{const h={id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.FunctionDeclaration,name:d.name,description:null,inputs:[],index:null,calls:[],collapsed:!1,private:!1,implements:d.toJSON(),x:0,y:0,parent:this.toReference()},c=C(h,this.project);c.setParent(this,e),c.initChildren(e),e==null||e.add(c,A.Added),c.addSelfToProject(e),i.push(c)}return e==null||e.attemptAutoclose("sync-body",this.id),{self:this,updated:p(t),added:p(i),removed:p(s),affected:p(l)}}syncChildren(e=this.project.addChangeSet(new b(this.project,m.sessionAuthor,T().toISOString(),this,!0,"sync-children"))){const t=[],i=[],s=[],l=[],{updated:o,added:d,removed:u}=this.syncBody(e);t.push(...o),i.push(...d),s.push(...u);const{updated:h,added:c,removed:E}=this.syncInputMaps(e);t.push(...h),i.push(...c),s.push(...E);const{updated:I,added:D,removed:P}=this.syncTerminationStatements(e);t.push(...I),i.push(...D),s.push(...P);const{updated:V,added:M,removed:g}=this.syncBodyArgumentsDeclarations(e);t.push(...V),i.push(...M),s.push(...g);const{updated:B,added:G,removed:q}=this.syncBodyInputIndexes(e);t.push(...B),i.push(...G),s.push(...q);const{updated:S,added:X,removed:pe}=this.syncOutputsDeclarations(e);t.push(...S),i.push(...X),s.push(...pe);const{updated:Ee,added:Q,removed:le}=this.syncOutputMaps(e);return t.push(...Ee),i.push(...Q),s.push(...le),e==null||e.attemptAutoclose("sync-children",this.id),{self:this,updated:p(t),added:p(i),removed:p(s),affected:p(l)}}};f(oe,"repository",{APICreate:async(e,...t)=>e,APIUpdate:async(e,...t)=>e,APIDelete:async(e,...t)=>e,APIClone:async(e,...t)=>{},APILoad:async(e,...t)=>null,APILoadVersion:async(e,t,...i)=>null}),f(oe,"type",n.Loop),f(oe,"USER_MANAGED_PARENT_TYPES",[...ht,n.Project]),f(oe,"PARENT_TYPES",[...We.USER_MANAGED_PARENT_TYPES]),f(oe,"CURRENT_ITERATION_NUMBER_ARG_NAME","Current iteration number"),f(oe,"CURRENT_VALUE_ARG_NAME","Current value"),f(oe,"MUTABLE_BASE_PROPERTIES",[]),f(oe,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),f(oe,"BASE_PROPERTIES",[...oe.MUTABLE_BASE_PROPERTIES,...oe.INMUTABLE_BASE_PROPERTIES]),f(oe,"MUTABLE_META_PROPERTIES",[...oe.MUTABLE_BASE_PROPERTIES,"x","y"]),f(oe,"INMUTABLE_META_PROPERTIES",[...oe.INMUTABLE_BASE_PROPERTIES]),f(oe,"META_PROPERTIES",[...oe.MUTABLE_META_PROPERTIES,...oe.INMUTABLE_META_PROPERTIES]),f(oe,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry"]),f(oe,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","declaration"]),f(oe,"UPSTREAM_PROPERTIES",[...oe.MUTABLE_UPSTREAM_PROPERTIES,...oe.INMUTABLE_UPSTREAM_PROPERTIES]),f(oe,"MUTABLE_DOWNSTREAM_PROPERTIES",["body","inputs","outputs","outputsDeclarations","successCalls","errorCalls","error","breakStatements","continueStatements"]),f(oe,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),f(oe,"DOWNSTREAM_PROPERTIES",[...oe.MUTABLE_DOWNSTREAM_PROPERTIES,...oe.INMUTABLE_DOWNSTREAM_PROPERTIES]),f(oe,"PROPERTIES",[...oe.META_PROPERTIES,...oe.UPSTREAM_PROPERTIES,...oe.DOWNSTREAM_PROPERTIES]);let Wr=oe;function R1(r){const a=J5(),e=r.toJSON();a.safeParse(e).success,r.inputs.forEach(l=>l.validate());const s=[...Ar(r)];return Ke(r.errors,s)}const SJ=Object.freeze(Object.defineProperty({__proto__:null,validate:R1},Symbol.toStringTag,{value:"Module"}));var D1=(r=>(r.Parent="parent",r))(D1||{});const Ze=class Ze extends lt{constructor(e,t){super(e);f(this,"initialData");f(this,"id");f(this,"x");f(this,"y");f(this,"type",n.Condition);f(this,"successCalls",[]);f(this,"errorCalls",[]);f(this,"declaration");f(this,"inputs",[]);f(this,"calledBySuccess",[]);f(this,"calledByError",[]);f(this,"calledByEntry",[]);f(this,"project");f(this,"errors",[]);f(this,"parent");f(this,"detachedDependents",{});f(this,"knownVersions",null);f(this,"activeVersion",!1);f(this,"initialized",!1);f(this,"startedInitialization",!1);this.initialData=e,this.project=t,this.id=e.id,this.x=e.x,this.y=e.y}static new(e=null){return{id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:(e==null?void 0:e.author)||m.sessionAuthor,previousVersion:null,deleted:!1,type:n.Condition,declaration:null,inputs:[],parent:null,calledByEntry:[],calledBySuccess:[],calledByError:[],errorCalls:[],successCalls:[],x:0,y:0}}static fromGenerationTarget(e,t){let i=t;if(e.parent){const c=_(e.parent);i=t.get(c)}const s=e.calledByEntry.map(c=>{const E=_(c);return t.get(E)}),l=e.calledBySuccess.map(c=>{const E=_(c);return t.get(E)}),o=e.calledByError.map(c=>{const E=_(c);return t.get(E)});let d;if(e.declaration){const c=_(e.declaration);d=t.get(c)}const u={id:e.id,version:m.UUID.uuid(),createdAt:T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.Condition,declaration:d,calledByEntry:s,calledBySuccess:l,calledByError:o,errorCalls:[],successCalls:[],inputs:[],x:0,y:0,parent:i},h=C(u,t);return h.setParent(i,null),h.initChildren(null),h}static validateGenerationTarget(e,t){let i=JSON.parse(JSON.stringify(e));const s=[],l=bt(i,{parent:{list:!1,types:[...ht,n.Project],optional:!0}},t);return i=l.modifiedData,s.push(...l.errors,...ut(i)),e.declaration?t.get(e.declaration)?t.conditionDeclarations.find(u=>u.id===e.declaration)||s.push(new w({id:`${e.id}--${R.InvalidImplementsReference}`,code:R.InvalidImplementsReference,severity:O.Error,message:`Entity of type '${e.type}' with id '${e.id}' has an 'declaration' property that isn't pointing to an action descriptor reserved for '${n.Condition}' entities.
100
100
  ${Sl(t)}`,issue:null})):s.push(new w({id:`${e.id}--${R.ReferencedEntityNotFound}`,code:R.ReferencedEntityNotFound,severity:O.Error,message:`Entity of type '${e.type}' with id '${e.id}' has an 'declaration' property that isn't found in the project. The 'declaration' property must point to one of the built-in action descriptors reserved for '${n.Condition}' entities.
101
101
  ${Sl(t)}`,issue:null})):s.push(new w({id:`${e.id}--${$.InvalidObjectStructure}`,code:$.InvalidObjectStructure,severity:O.Error,message:`Entity of type '${e.type}' with id '${e.id}' is missing the 'declaration' property. This property is required for a '${e.type}' entity and must point to one of the built-in action descriptors reserved for '${n.Condition}' entities.
102
102
  ${Sl(t)}`,issue:null})),{errors:s,modifiedData:i}}validateGeneratedUpdate(e){const t=[];return e.parent&&t.push(new w({id:`${this.id}--${R.InvalidParentUpdate}`,code:R.InvalidParentUpdate,severity:O.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elyx-code/project-logic-tree",
3
- "version": "0.0.6256",
3
+ "version": "0.0.6258",
4
4
  "author": "Sergio Herrero",
5
5
  "license": "UNLICENSED",
6
6
  "description": "An installable module which contains the type definitions and ephemeral state management for a projects' logic tree data structure",